diff --git a/scripts/verify/e2e/cases/workspace.ts b/scripts/verify/e2e/cases/workspace.ts index c55a120d..3c3ecf47 100644 --- a/scripts/verify/e2e/cases/workspace.ts +++ b/scripts/verify/e2e/cases/workspace.ts @@ -1316,10 +1316,23 @@ export const workspaceCases: E2ECase[] = [ } return value; }; + // The outgoing document can flush its in-memory chrome state + // during teardown and clobber the seed before the new document + // reads it (same persist race as UC-E01 restore, #845). Verify + // the file still holds the seed after boot and retry once. + const seedCollapsedAndReload = async ( + collapsed: boolean, + ): Promise => { + for (let attempt = 0; ; attempt++) { + await seedCollapsed(collapsed); + const panel = await reloadPanel1(ctx, 45_000); + const settled = await waitFileCollapsed(collapsed); + if (settled === collapsed || attempt === 1) return panel; + } + }; await withManagedRootSnapshot(ctx, "uc-b09-cp-collapse", async () => { - await seedCollapsed(true); - const panel = await reloadPanel1(ctx, 45_000); + const panel = await seedCollapsedAndReload(true); const cpSeen = await waitForDom( ctx, @@ -1397,11 +1410,10 @@ export const workspaceCases: E2ECase[] = [ // Round-trip the other direction through persistence: re-seed // collapsed and confirm boot restores it (the collapse action // itself is a native context-menu path, not DOM-addressable). - await seedCollapsed(true); - await reloadPanel1(ctx, 45_000); + const reseeded = await seedCollapsedAndReload(true); const recollected = await waitForDom( ctx, - panel, + reseeded, `(() => { const cp = document.querySelector("[data-cp]"); return cp && cp.getAttribute("data-collapsed") === "true"; @@ -1412,7 +1424,7 @@ export const workspaceCases: E2ECase[] = [ check( "re-seeded collapsed state survives reload", Boolean(recollected), - await domCollapsed(panel), + await domCollapsed(reseeded), ), ); });