Clear chart stale retry state
This commit is contained in:
@@ -191,6 +191,22 @@ export async function runTests() {
|
||||
chartCanvasSourceIncludes(chartSource, "handleRetryDetail"),
|
||||
"city detail charts should show stale cache first and expose a retryable unavailable state",
|
||||
);
|
||||
const successfulHourlyDetailBlock =
|
||||
/const applySuccessfulHourlyDetail = useCallback\([\s\S]*?\n \}, \[\]\);/.exec(chartSource)?.[0] || "";
|
||||
assert(
|
||||
successfulHourlyDetailBlock.includes("setDetailError(null)") &&
|
||||
successfulHourlyDetailBlock.includes("setShowingStaleDetail(false)") &&
|
||||
successfulHourlyDetailBlock.includes("setHourly(data)"),
|
||||
"successful city detail refreshes must clear stale-cache retry state when fresh detail arrives",
|
||||
);
|
||||
const rawSuccessfulSetHourlyCalls = chartSource
|
||||
.replace(successfulHourlyDetailBlock, "")
|
||||
.match(/setHourly\(data\);/g) || [];
|
||||
assert(
|
||||
rawSuccessfulSetHourlyCalls.length === 0 &&
|
||||
(chartSource.match(/applySuccessfulHourlyDetail\(data/g) || []).length >= 5,
|
||||
"all successful city detail fetch branches should use the shared success handler",
|
||||
);
|
||||
assert(
|
||||
chartSource.includes("const showDetailErrorBadge = !compact || isActive || isMaximized") &&
|
||||
chartSource.includes("showDetailErrorBadge={showDetailErrorBadge}") &&
|
||||
|
||||
@@ -187,7 +187,7 @@ export function runTests() {
|
||||
!fallbackRefreshBlock.includes("setIsHourlyLoading(true)"),
|
||||
"no-patch fallback refresh should update the chart in the background without showing the loading overlay",
|
||||
);
|
||||
const resyncBlock = chart.match(/useEffect\(\(\) => \{\s*if \(!resyncVersion \|\| !city\) return;[\s\S]*?\}, \[resyncVersion, city, targetResolution\]\);/)?.[0] || "";
|
||||
const resyncBlock = chart.match(/useEffect\(\(\) => \{\s*if \(!resyncVersion \|\| !city\) return;[\s\S]*?\}, \[resyncVersion, city, targetResolution, applySuccessfulHourlyDetail\]\);/)?.[0] || "";
|
||||
assert(
|
||||
!resyncBlock.includes("setIsHourlyLoading(true)"),
|
||||
"SSE replay resync should refresh full detail in the background without showing the loading overlay",
|
||||
@@ -240,7 +240,7 @@ export function runTests() {
|
||||
chart.includes("refreshProbabilityOverlayAfterPatch"),
|
||||
"temperature chart must trigger a throttled background probability refresh after live observation patches",
|
||||
);
|
||||
const patchEffectBlock = chart.match(/useEffect\(\(\) => \{\s*if \(!latestPatch[\s\S]*?\}, \[latestPatch, row, city, targetResolution, compact, isActive, isMaximized\]\);/)?.[0] || "";
|
||||
const patchEffectBlock = chart.match(/useEffect\(\(\) => \{\s*if \(!latestPatch[\s\S]*?\}, \[latestPatch, row, city, targetResolution, compact, isActive, isMaximized, applySuccessfulHourlyDetail\]\);/)?.[0] || "";
|
||||
assert(
|
||||
patchEffectBlock.includes("refreshProbabilityOverlayAfterPatch") &&
|
||||
patchEffectBlock.includes("ignoreCache: true") &&
|
||||
|
||||
Reference in New Issue
Block a user