test(super-editor): remove dead layout-resolved mocks and add alignment tests#2845
Open
tupizz wants to merge 1 commit intotadeu/sd-2563-12-delete-dead-hashfrom
Open
test(super-editor): remove dead layout-resolved mocks and add alignment tests#2845tupizz wants to merge 1 commit intotadeu/sd-2563-12-delete-dead-hashfrom
tupizz wants to merge 1 commit intotadeu/sd-2563-12-delete-dead-hashfrom
Conversation
…nt tests Applies testing-excellence principles to the SD-2563 test suite: 1. Remove dead mock stubs (Iron Law #3: never mock what you don't understand). 11 test files carried vi.mock('@superdoc/layout-resolved') stubs that no test depends on — PresentationEditor imports the module, but these tests don't exercise paths that call it. Verified by removing and running the full suite: all 11348 tests pass without the stubs. 2. Kept the stubs in 2 files whose tests genuinely depend on controlled resolveLayout behavior (PresentationEditor.footnotesPmMarkers and PresentationEditor.sectionPageStyles). 3. Added HeaderFooterSessionManager.alignment.test.ts covering the two previously-untested risk areas: - rId-based path delivers items aligned 1:1 with fragments (multi-section documents — uses real resolveHeaderFooterLayout) - Length-mismatch guard drops items and emits a warning when resolved and fragment counts diverge (proves the runtime safety net works) Net: -44 lines of dead mock boilerplate, +190 lines of real test coverage. Total super-editor tests: 11348 -> 11350.
This was referenced Apr 16, 2026
This was referenced Apr 16, 2026
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.
Summary
Applies testing-excellence principles to the SD-2563 test suite. Two independent changes:
1. Remove dead
@superdoc/layout-resolvedmock stubs (Iron Law #3)11 test files carried a
vi.mock('@superdoc/layout-resolved')block that no test depends on. Verified empirically: after removing all 11, the full super-editor suite (11,348 tests) still passes.These stubs were added during PRs 9/10 as import-time plumbing but were never load-bearing. Anti-pattern: "mocking without understanding."
Kept the stubs in 2 files whose tests genuinely rely on controlled
resolveLayoutbehavior:PresentationEditor.footnotesPmMarkers.test.ts— asserts specific data is passed toresolveLayoutPresentationEditor.sectionPageStyles.test.ts— exercises layout paths where real resolver would fail on minimal fixtures2. New alignment test file covers two previously-untested risk areas
HeaderFooterSessionManager.alignment.test.tsadds two tests:Test A: rId-based path delivers items aligned 1:1 with fragments
PR 10's original implementer explicitly flagged this as uncovered — only the variant-based (by-type) path had a test. The rId-based path (multi-section documents) shares the same alignment contract but a different code path. This test seeds
headerLayoutsByRIdvia a mockedlayoutPerRIdHeaderFooters, lets the realresolveHeaderFooterLayoutrun downstream, and assertspayload.items[i]corresponds topayload.fragments[i].Test B: Length-mismatch guard drops items and warns
The runtime safety net at
HeaderFooterSessionManager.ts:1702-1707and:1763-1765is the last line of defense against alignment corruption. Before this PR, nothing verified it fires correctly. This test stubs the resolver to return 2 items for 1 fragment (a divergence only possible from a resolver bug), assertspayload.items === undefined(items dropped), and assertsconsole.warnwas called with the expected guard message.Why this matters
The 12-PR stack for SD-2563 made the painter "dumb" but relied heavily on layout comparison (407/407 byte-identical) for confidence. These two unit tests protect the specific behavioral contracts that layout-compare can't cheaply verify:
Test plan
super-editorbuild cleanStack
PR Stack (SD-2563: Dumb Painter Refactor)