fix: improve chart tooltip and metar refresh

This commit is contained in:
2569718930@qq.com
2026-06-03 11:41:16 +08:00
parent 00f96150c5
commit c3fd0582ad
5 changed files with 170 additions and 32 deletions
@@ -99,6 +99,16 @@ export async function runTests() {
chartLogicSource.includes("recentlyRefreshed.data"),
"forced chart detail refreshes should reuse a very recent full-detail payload instead of refetching repeatedly",
);
assert(
chartLogicSource.includes("forceRefresh: boolean") &&
chartLogicSource.includes('force_refresh: forceRefresh ? "true" : "false"'),
"ignoreCache chart detail refreshes must send force_refresh=true so fresh METAR observations bypass proxy and backend chart caches",
);
assert(
chartLogicSource.includes("cityDetailBatchQueueKey") &&
chartLogicSource.includes('forceRefresh ? "force" : "cached"'),
"forced and cached chart detail requests must use separate batch queues so a normal first-paint request cannot downgrade a live refresh",
);
assert(
__shouldPollLiveChartForTest({ city: "shanghai", compact: true, isActive: false, isMaximized: false }) === true,
"compact grid slots are visible charts and should run the no-patch fallback guard",
@@ -148,7 +158,7 @@ export async function runTests() {
);
const fetchHourlyBlock = chartLogicSource.match(/async function fetchHourlyForecastForCity[\s\S]*?\r?\n}\r?\n\r?\nfunction shouldPollLiveChart/)?.[0] || "";
assert(
fetchHourlyBlock.includes("queueCityDetailBatch(city, resParam)") &&
fetchHourlyBlock.includes("queueCityDetailBatch(city, resParam, forceRefresh)") &&
!fetchHourlyBlock.includes("runQueuedHourlyDetailRequest"),
"first-paint and background city detail refreshes should both enter the batch queue without falling back to single requests",
);
@@ -1,4 +1,7 @@
import { __buildTemperatureTooltipRowsForTest } from "@/components/dashboard/scan-terminal/TemperatureTooltipContent";
import {
__buildTemperatureTooltipProbabilityRowsForTest,
__buildTemperatureTooltipRowsForTest,
} from "@/components/dashboard/scan-terminal/TemperatureTooltipContent";
function assert(condition: unknown, message: string) {
if (!condition) throw new Error(message);
@@ -48,4 +51,33 @@ export function runTests() {
rows.some((row) => row.key === "gfs" && row.value === 24.2),
"non-runway sparse series should keep nearest-value fallback",
);
const probabilityRows = __buildTemperatureTooltipProbabilityRowsForTest(
{
engine: "legacy",
muLine: { value: 27.4, label: "Gaussian μ 27.4°C" },
bands: [
{
key: "legacy_probability_27_0",
value: 27,
lower: 26.5,
upper: 27.5,
probability: 0.42,
label: "27°C 42%",
opacity: 0.13,
},
],
},
"°C",
true,
);
assert(
probabilityRows.some((row) => row.key === "gaussian_mu" && row.value === "27.4°C"),
"tooltip should expose the Gaussian μ line when the purple probability overlay is present",
);
assert(
probabilityRows.some((row) => row.value.includes("26.5-27.5°C") && row.value.includes("42%")),
"tooltip should expose purple probability-band range and probability values",
);
}