Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions scripts/verify/e2e/cases/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AppJson | null> => {
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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Loading