test: add unit tests for temperature series visibility policy and peak glow state logic

This commit is contained in:
2569718930@qq.com
2026-05-29 23:21:17 +08:00
parent 53268560ec
commit b3a63aa9af
@@ -230,42 +230,52 @@ export function runTests() {
"airport-primary weather-station observations should be visible by default",
);
const amsterdamKnmi = __buildTemperatureChartDataForTest(
{
city: "amsterdam",
local_date: "2026-05-29",
local_time: "17:03",
tz_offset_seconds: 2 * 60 * 60,
airport: "EHAM",
} as any,
{
localTime: "17:03",
times: ["00:00", "06:00", "12:00", "18:00"],
temps: [19, 18, 27, 20],
airportPrimary: {
source_code: "knmi",
source_label: "KNMI",
temp: 19.0,
obs_time: "2026-05-29T15:03:00Z",
},
airportPrimaryTodayObs: [
{ time: "2026-05-29T13:00:00Z", temp: 26.2 },
{ time: "2026-05-29T14:00:00Z", temp: 24.5 },
{ time: "2026-05-29T15:00:00Z", temp: 19.9 },
],
} as any,
"1D",
);
const amsterdamDefaultSeries = __getActiveTemperatureSeriesForTest(
"amsterdam",
amsterdamKnmi.series as any,
{},
true,
);
assert(
amsterdamDefaultSeries.some((item: any) => item.key === "madis" && item.label === "KNMI"),
"Amsterdam KNMI weather-station curve should be visible by default",
);
[
{ city: "amsterdam", airport: "EHAM", sourceCode: "knmi", sourceLabel: "KNMI" },
{ city: "tel aviv", airport: "LLBG", sourceCode: "ims", sourceLabel: "IMS Lod Airport" },
{ city: "helsinki", airport: "EFHK", sourceCode: "fmi", sourceLabel: "FMI" },
{ city: "tokyo", airport: "RJTT", sourceCode: "jma_amedas", sourceLabel: "JMA" },
{ city: "singapore", airport: "WSSS", sourceCode: "singapore_mss", sourceLabel: "MSS" },
{ city: "panama city", airport: "MPMG", sourceCode: "ncm", sourceLabel: "NCM" },
{ city: "brussels", airport: "EBBR", sourceCode: "aeroweb", sourceLabel: "AeroWeb" },
].forEach(({ city: stationCity, airport, sourceCode, sourceLabel }) => {
const stationChart = __buildTemperatureChartDataForTest(
{
city: stationCity,
local_date: "2026-05-29",
local_time: "17:03",
tz_offset_seconds: 2 * 60 * 60,
airport,
} as any,
{
localTime: "17:03",
times: ["00:00", "06:00", "12:00", "18:00"],
temps: [19, 18, 27, 20],
airportPrimary: {
source_code: sourceCode,
source_label: sourceLabel,
temp: 19.0,
obs_time: "2026-05-29T15:03:00Z",
},
airportPrimaryTodayObs: [
{ time: "2026-05-29T13:00:00Z", temp: 26.2 },
{ time: "2026-05-29T14:00:00Z", temp: 24.5 },
{ time: "2026-05-29T15:00:00Z", temp: 19.9 },
],
} as any,
"1D",
);
const stationDefaultSeries = __getActiveTemperatureSeriesForTest(
stationCity,
stationChart.series as any,
{},
true,
);
assert(
stationDefaultSeries.some((item: any) => item.key === "madis" && item.label === sourceLabel),
`${stationCity} ${sourceLabel} weather-station curve should be visible by default`,
);
});
const ankaraMgmWithMetarBackup = __buildTemperatureChartDataForTest(
{