test(session): round-trip the window snapshot instead of grepping it - #568
Merged
Conversation
The two assertions covering `serializeState` and `restoreState` were a list of things their source must not contain — `doesNotMatch(/\.\.\.t/)`, `/rawContent/`, `/originalContent/`, `/isDirty/`, `/history/` — plus `match(/isDirty: false/)` on the way back. A blocklist of five spellings is not the property it stands for, which is: the file written on every close must contain window layout and no document text. Both functions are methods on an exported singleton, so the property can be asserted directly. The snapshot is now built from a tab holding unsaved text, and the test looks for that text in the JSON, then compares the key set of the persisted entry against the ten window-state fields — so a field added by hand fails here rather than shipping a layout file that is also a copy of every open document. Five behaviour tests replace the two, covering what the blocklist could not see: the round trip preserves per-tab layout, restored tabs arrive clean and empty, an activeTabId pointing at a dropped entry still lands on a real tab rather than none, and 'HOME'/untitled entries from older builds are rejected on the way in as well as on the way out. Replacing the field list with `...t` — the exact defect the blocklist was written against — turns the first two red. The seven assertions about windowSession, documentSession and MarkdownViewer are unchanged: those are wiring inside a Svelte component or an ordering between two calls, and the file already groups them apart. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
Fourth slice (after #564, #565, #567).
windowStateRestore.test.tsonly; no source changes.Mechanism
The two assertions covering
serializeState/restoreStatewere a blocklist of spellings their source must not contain:Five names is not the property they stand for. The property is: the file written on every window close contains layout and no document text. A field spelled anything else —
buffer,text,t.content— satisfies every line above and ships a window-layout file that is also a copy of every open document, including one the user never saved anywhere.tabManageris an exported singleton and both functions are ordinary methods, so the property can be asserted rather than approximated. The snapshot is now built from a tab holding unsaved text, and the test looks for that text in the JSON. It then compares the persisted entry's key set against the ten window-state fields, so adding a field is a deliberate act that fails here first.Five behaviour tests replace the two, covering what a blocklist cannot see:
isSplit,splitRatio,scrollPercentage)activeTabIdnaming an entry that was dropped on the way in still lands on a real tab — otherwise restore produces a window with files in the tab bar and nothing openHOMEand untitled entries from older builds are rejected on the way in as well as on the way outScope
windowSession.restore,canCloseTab, and an ordering insideMarkdownViewer.svelte's close handler — wiring in a Svelte component this runner cannot import. The file already grouped them separately.__TAURI_INTERNALS__stubs are the same eight lines the other store-driving tests carry.Tests
Restoring the defect the blocklist was written against —
.map((t) => ({ ...t, … }))with thehasRealFilePathfilter removed — turns the first two red and leaves the other ten green. Ran it, then reverted.Verification
Not verified: what the OS actually writes and reads back. The snapshot is exercised as a string in memory; the file round trip through Rust is covered by
sessionRestoreResilience.🤖 Generated with Claude Code