From b3a63aa9af72c95f49d16126493a6e101a15d3a9 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Fri, 29 May 2026 23:21:17 +0800 Subject: [PATCH] test: add unit tests for temperature series visibility policy and peak glow state logic --- ...temperatureDefaultVisibilityPolicy.test.ts | 82 +++++++++++-------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/frontend/components/dashboard/scan-terminal/__tests__/temperatureDefaultVisibilityPolicy.test.ts b/frontend/components/dashboard/scan-terminal/__tests__/temperatureDefaultVisibilityPolicy.test.ts index 52c2ac0e..15a21820 100644 --- a/frontend/components/dashboard/scan-terminal/__tests__/temperatureDefaultVisibilityPolicy.test.ts +++ b/frontend/components/dashboard/scan-terminal/__tests__/temperatureDefaultVisibilityPolicy.test.ts @@ -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( {