From 2817544ae1368f040a8748791c91a848c895e475 Mon Sep 17 00:00:00 2001 From: rebuildup Date: Sun, 29 Nov 2026 21:04:08 +0900 Subject: [PATCH] test(e2e): poll for app.json restore convergence instead of one-shot read The snapshot wrapper restores files and best-effort reloads panel-1, but an in-flight settings save serialized through the managed-root persistence lock can land after the restore and be overwritten again by the panel post-reload persist. Sampling app.json once right after reload catches the transient state (UC-E01 false FAIL while the file converges to the snapshot bytes seconds later). Poll until the parsed document matches the pre-case value; genuine non-convergence still fails. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- scripts/verify/e2e/cases/settings.ts | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/scripts/verify/e2e/cases/settings.ts b/scripts/verify/e2e/cases/settings.ts index 8ef1accc..638e9678 100644 --- a/scripts/verify/e2e/cases/settings.ts +++ b/scripts/verify/e2e/cases/settings.ts @@ -228,6 +228,28 @@ const waitForAppJson = async ( return last; }; +/** + * Wait for `settings/app.json` to converge back to the pre-case snapshot. + * The restore writes the files and reloads panel-1, but an in-flight + * settings save (serialized through the managed-root persistence lock) can + * land after the restore and be overwritten again by the panel's + * post-reload persist. Sampling once right after reload can catch the + * transient state, so poll until the file matches `before`. + */ +const waitForRestoredAppJson = async ( + ctx: E2EContext, + before: AppJson | null, + timeoutMs = 25_000, +): Promise => { + const deadline = Date.now() + timeoutMs; + let last = await readAppJson(ctx); + while (!appJsonMatches(last, before) && Date.now() < deadline) { + await sleep(700); + last = await readAppJson(ctx); + } + return last; +}; + /** * Reload the pooled settings dialog surface so its SettingsProvider * re-reads `settings/app.json` from disk, then re-resolve the live target @@ -358,7 +380,7 @@ export const settingsCases: E2ECase[] = [ // restore already ran; reload is best-effort } } - const restored = await readAppJson(ctx); + const restored = await waitForRestoredAppJson(ctx, before); checks.push( check( "settings/app.json restored after case", @@ -551,7 +573,7 @@ export const settingsCases: E2ECase[] = [ }); // Snapshot restore + panel reload (wrapper finally) bring the // locale back to the pre-case value. - const restored = await readAppJson(ctx); + const restored = await waitForRestoredAppJson(ctx, before); checks.push( check( "settings/app.json restored after case", @@ -747,7 +769,7 @@ export const settingsCases: E2ECase[] = [ await closeSettingsDialog(ctx); } }); - const restored = await readAppJson(ctx); + const restored = await waitForRestoredAppJson(ctx, before); checks.push( check( "settings/app.json restored after case",