Refresh product docs and observation freshness

This commit is contained in:
2569718930@qq.com
2026-06-06 21:46:23 +08:00
parent 524ae7c8cf
commit 11fd482378
24 changed files with 997 additions and 592 deletions
@@ -1,4 +1,6 @@
import { getDocsPage } from "@/content/docs/docs";
import { DOCS_PAGES } from "@/content/docs/docs";
import { DOCS_GROUPS } from "@/content/docs/docs.config";
function assert(condition: unknown, message: string): asserts condition {
if (!condition) throw new Error(message);
@@ -24,16 +26,42 @@ function pageText(slug: string, locale: "zh-CN" | "en-US") {
}
export function runTests() {
const publicDocSlugs = DOCS_PAGES.map((page) => page.slug);
assert(
publicDocSlugs.join(",") === "intro,chart-guide,realtime-sources,settlement-sources,extension",
"public docs navigation should only expose current shipped user-facing surfaces",
);
for (const group of DOCS_GROUPS) {
assert(
DOCS_PAGES.some((page) => page.group === group.id),
`docs navigation group should not be empty: ${group.id}`,
);
}
const allDocsZh = publicDocSlugs.map((slug) => pageText(slug, "zh-CN")).join("\n");
const allDocsEn = publicDocSlugs.map((slug) => pageText(slug, "en-US")).join("\n");
for (const staleTerm of ["从地图进入", "机会榜", "日历", "EMOS", "LGBM", "城市决策卡", "付费判断台", "刷新锁"]) {
assert(!allDocsZh.includes(staleTerm), `public Chinese docs should not expose stale term: ${staleTerm}`);
}
for (const staleTerm of ["map-launched", "opportunity board", "calendar", "EMOS", "LGBM", "city decision card", "paid decision workspace", "refresh lock"]) {
assert(!allDocsEn.includes(staleTerm), `public English docs should not expose stale term: ${staleTerm}`);
}
const introZh = pageText("intro", "zh-CN");
assert(
introZh.includes("结算源优先") && introZh.includes("实时实测终端"),
"intro should position PolyWeather as a settlement-source-first live terminal",
introZh.includes("结算源优先") && introZh.includes("天气决策台"),
"intro should position PolyWeather as a settlement-source-first decision terminal",
);
assert(
introZh.includes("1-9 个图表槽位") && introZh.includes("天气决策 / 训练数据 / 使用指南"),
"intro should match the current terminal navigation and chart-slot workflow",
);
const chartGuideZh = pageText("chart-guide", "zh-CN");
assert(chartGuideZh.includes("如何读 PolyWeather 图表"), "chart guide title should be present");
assert(chartGuideZh.includes("高级气象变量") && chartGuideZh.includes("默认隐藏"), "chart guide should explain advanced variables as hidden-by-default context");
assert(chartGuideZh.includes("不要把概率温度带当成实测曲线"), "chart guide should warn against reading probability as observation");
assert(chartGuideZh.includes("高温 / 全天"), "chart guide should document the current chart view modes");
const realtimeSourcesZh = pageText("realtime-sources", "zh-CN");
assert(realtimeSourcesZh.includes("AMSC 180s"), "realtime sources should document the AMSC 180s cadence");
@@ -54,4 +82,5 @@ export function runTests() {
const chartGuideEn = pageText("chart-guide", "en-US");
assert(chartGuideEn.includes("How To Read PolyWeather Charts"), "English chart guide should exist");
assert(chartGuideEn.includes("hidden by default"), "English chart guide should describe hidden-by-default advanced variables");
assert(chartGuideEn.includes("Peak / All Day"), "English chart guide should document the current chart view modes");
}
@@ -28,6 +28,7 @@ export function runTests() {
const now = new Date("2026-05-14T12:00:00Z");
assert.equal(getObservationSourceProfile("amos").nativeUpdateIntervalSec, 60);
assert.equal(getObservationSourceProfile("amsc_awos").nativeUpdateIntervalSec, 180);
assert.equal(getObservationSourceProfile("metar").nativeUpdateIntervalSec, 900);
const amosFresh = buildObservationFreshness({
@@ -109,4 +110,28 @@ export function runTests() {
},
});
assert.equal(getObservationFreshness(amosDetail)?.source_code, "amos");
const amscDetail = detail({
amos: {
observation_time: "2026-05-14T11:57:20Z",
runway_obs: {
runway_pairs: [["35R", "17L"]],
temperatures: [[25.2, null]],
},
source: "amsc_awos",
source_label: "AMSC AWOS",
},
});
const amscFreshness = getObservationFreshness(amscDetail);
assert.equal(amscFreshness?.source_code, "amsc_awos");
assert.equal(amscFreshness?.native_update_interval_sec, 180);
const amscExpectedWait = buildObservationFreshness({
now,
observedAt: "2026-05-14T11:56:40Z",
sourceCode: "amsc_awos",
sourceLabel: "AMSC AWOS",
});
assert.equal(amscExpectedWait.native_update_interval_sec, 180);
assert.equal(amscExpectedWait.freshness_status, "expected_wait");
}
@@ -1170,6 +1170,29 @@ export function runTests() {
"Panama City high label should use airport METAR report wording, not weather-station or runway wording",
);
const shanghaiLabels = __getLiveObservationLabelsForTest(
{
city: "shanghai",
local_date: "2026-06-06",
local_time: "21:03",
tz_offset_seconds: 8 * 60 * 60,
} as any,
{
amos: {
source: "amsc_awos",
source_label: "AMSC AWOS",
},
airportPrimary: {
source_code: "amsc_awos",
source_label: "AMSC AWOS",
},
} as any,
);
assert(
shanghaiLabels.runwayHeaderLabel === "跑道实测 (3分钟)",
"AMSC runway cities should advertise the 3-minute source cadence instead of the AMOS 1-minute cadence",
);
const newYorkWithMadis = __buildTemperatureChartDataForTest(
{
city: "new york",
@@ -36,6 +36,18 @@ export function runTests() {
assert(shenzhen.runwayHigh === "HKO Live", "Shenzhen high summary should translate 天文台实测");
assert(shenzhen.metarHigh === "HKO", "Shenzhen high summary should translate 天文台");
const shanghai = __buildTemperatureStatsLabelsForTest({
isEn: true,
isShenzhen: false,
runwayHeaderLabel: "跑道实测 (3分钟)",
metarHeaderLabel: "METAR 结算 (30分钟)",
runwayHighLabel: "跑道实测",
metarHighLabel: "METAR 官方",
});
assert(shanghai.primary === "Runway Live (3m)", "AMSC English primary label should match 跑道实测 (3分钟)");
assert(shanghai.runwayHigh === "Runway", "AMSC runway high label should remain Runway");
const zh = __buildTemperatureStatsLabelsForTest({
isEn: false,
isShenzhen: true,