Skip to content

Commit b2333b1

Browse files
committed
test(e2e): assert every marked view-state id keeps the rehydration marker
1 parent a9fb423 commit b2333b1

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

‎apps/vscode-e2e/src/suite/view-state.test.ts‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -378,27 +378,27 @@ suite("Roo Code View State", function () {
378378
// mode 'build' through the test-only global-state write. The sidebar provider's
379379
// in-memory mode is still 'ask' at this point, so the two assertions below each
380380
// pin a value only one failure mode can break: (a) passes only if the hide/show
381-
// cycle did not wipe, prune, or re-key the durable entry the marker was written
382-
// to (an unrelated surviving entry cannot satisfy a 'some entry is build'
383-
// assertion because no other test in this suite uses the build mode), and (b)
381+
// cycle did not wipe, prune, or re-key the durable entries the marker was written
382+
// to — the assertion requires every marked view-state id to retain the build
383+
// mode, so an unrelated surviving entry cannot satisfy it — and (b)
384384
// passes only if the cycle did not wipe the provider's in-memory view state.
385385
// Asserting the marker through getConfiguration() instead would not work: the
386386
// sidebar provider is a per-extension singleton that does not re-read durable
387387
// viewStates when its webview is re-shown, so its in-memory value is the one
388388
// getConfiguration() reports after the reload.
389+
const markedIds: string[] = []
389390
{
390391
const persisted = globalThis.api.getGlobalState("viewStates") as GlobalState["viewStates"]
391392
assert.ok(persisted, "Expected persisted viewStates before writing the rehydration marker")
392393

393394
const marked: NonNullable<GlobalState["viewStates"]> = { ...persisted }
394-
let markedAny = false
395395
for (const [viewStateId, entry] of Object.entries(marked)) {
396396
if (entry.mode === "ask") {
397397
marked[viewStateId] = { ...entry, mode: "build" }
398-
markedAny = true
398+
markedIds.push(viewStateId)
399399
}
400400
}
401-
assert.ok(markedAny, "Expected a persisted 'ask' entry to mark before the reload")
401+
assert.ok(markedIds.length > 0, "Expected a persisted 'ask' entry to mark before the reload")
402402
await globalThis.api.setGlobalState("viewStates", marked)
403403
}
404404

@@ -411,27 +411,27 @@ suite("Roo Code View State", function () {
411411
await vscode.commands.executeCommand("workbench.action.toggleSidebarVisibility")
412412
await sleep(2_000)
413413

414-
// (a) The durable entry the marker was written to still exists after the reload.
415-
// A wipe, prune, or re-key of the durable map during the cycle would drop the
416-
// marker even though a looser 'some entry is ask' assertion could still be
417-
// satisfied by an unrelated entry. Poll in case the just-written memento value
418-
// lags a synchronous read.
414+
// (a) Every durable entry the marker was written to still holds the build mode
415+
// after the reload. A wipe, prune, or re-key of the durable map during the
416+
// cycle would drop or rename the marked entries, and no unrelated entry can
417+
// substitute for them. Poll in case the just-written memento value lags a
418+
// synchronous read.
419419
await waitFor(
420420
() => {
421421
const persisted = globalThis.api.getGlobalState("viewStates") as GlobalState["viewStates"]
422422
if (!persisted) {
423423
return false
424424
}
425425

426-
return Object.entries(persisted).some(([, entry]) => entry.mode === "build")
426+
return markedIds.every((id) => persisted[id]?.mode === "build")
427427
},
428428
{ timeout: 30_000 },
429429
)
430430
const viewStates = globalThis.api.getGlobalState("viewStates") as GlobalState["viewStates"]
431431
assert.ok(viewStates, "Expected persisted viewStates to exist after the sidebar webview reload")
432432
assert.ok(
433-
Object.entries(viewStates).some(([, entry]) => entry.mode === "build"),
434-
"Expected the persisted view states to still contain the rehydration marker after the reload",
433+
markedIds.every((id) => viewStates[id]?.mode === "build"),
434+
"Expected every marked view-state id to still hold the rehydration marker after the reload",
435435
)
436436

437437
// (b) The reloaded sidebar view still reports the pre-reload in-memory mode.

0 commit comments

Comments
 (0)