Skip to content

test(table): split the cell-render suite by concern - #376

Merged
mtskf merged 5 commits into
mainfrom
chore/split-cell-render-test
Aug 21, 2026
Merged

test(table): split the cell-render suite by concern#376
mtskf merged 5 commits into
mainfrom
chore/split-cell-render-test

Conversation

@mtskf

@mtskf mtskf commented Aug 21, 2026

Copy link
Copy Markdown
Owner

What

Splits test/webview/table/cm-table-cell-render.test.ts (1314 lines, 169 tests) into six concern-named suites, and extracts the two helpers they share. Follow-up to #372, which split the widget suite in the same directory.

New file Concern its describe names Tests Lines
cm-table-cell-render-urls.test.ts the destination gate — allowlist, entity/backslash bypasses, CommonMark destination parsing, MAX_HREF_LENGTH cap, relative-image containment 38 315
cm-table-cell-render-emphasis.test.ts the shared delimiter stack — emphasis, strong, strikethrough, highlight 45 323
cm-table-cell-render-text.test.ts text, code spans, escapes + the node-count merging topology 11 90
cm-table-cell-render-clicks.test.ts click / modifier-click / auxclick / contextmenu routing on a live link 15 179
cm-table-cell-inline-ir.test.ts parseCellInline span losslessness 23 186
cm-table-cell-render-map.test.ts the source map renderCellInto emits 37 318

Why these groupings

Unlike #372, this file did not cut along existing describe boundaries — one 777-line describe("renderCellInline") held ~90 flat its spanning five unrelated contracts, so the grouping had to be decided rather than derived.

Two calls worth flagging:

  • Emphasis and marks stay together. *, _, ~~ and == are emitted as delimiter runs into the same stack (inline-emphasis.ts) and paired by one resolveInline pass. Several rows assert exactly that coupling (*a~~b*c~~d*, *a==b*c==d*, ~~a ==b== c~~); splitting marks into their own file would leave those rows with no home that owns both sides.
  • The MAX_HREF_LENGTH cap lives with the URL gate, not the click routing, because it decides whether an anchor is created at all. Two of its rows also observe a click, but only as proof the anchor really went live.

One row was relocated rather than carried: renders a pathologically deep-emphasis cell without crashing sat inside the text-node topology describe but asserts the walker stopping at MAX_INLINE_NESTING_DEPTH — the delimiter stack's termination behaviour, not text merging. It moves to the emphasis suite.

Shared helpers

html() (85 call sites) and the tooltip-stripping regex (11 occurrences) move to helpers/cell-render-fixtures.ts, matching the helpers/widget-fixtures.ts precedent. Two hardenings came with sharing:

  • html() appends clones. It previously appendChilded the caller's nodes, moving them out of the array the caller still held. No call site reads its nodes after serialising them, so this changes no result — it removes a trap a shared serialiser would set for the first test that wants to check markup and then dispatch an event.
  • The strip matches the tooltip's exact shape rather than any title attribute, so a meaningful title added later cannot vanish from every structural snapshot silently. The tooltip's own contract stays pinned where it already is: the two a.title rows in the clicks suite.

How conservation was proven

The split was generated from a pinned blob, not hand-edited, so "no test was lost, duplicated or quietly reworded" is checkable rather than asserted:

  • Reassembling every manifest range reproduces the original file byte-for-byte, so the ranges tile the file and the join rule loses nothing.
  • The line partition is exact — 0 duplicated, 0 missing across all 1314 lines.
  • Every emitted body line is verified identical to its source line except three named deviations (11 tooltip-strip rewrites, 1 comment repoint, 2 Biome reflows that the shortened expressions require), with the strip re-derived independently of the matcher that applied it.
  • Regenerating afterwards reproduces all six committed files byte-identically.

The checks were mutation-tested: dropping a body line, corrupting one, extending a range, and breaking a reflow's source block each fail a different guard.

Verification

  • pnpm test:unit5041 passed, unchanged from before the split (files 259 → 264)
  • Per-file counts 38 / 45 / 11 / 15 / 23 / 37 = 169, matching the original file exactly
  • pnpm compile clean; pnpm lint exit 0 (remaining warnings are pre-existing, in a file this PR does not touch)
  • No file in test/webview/table/ exceeds ~600 lines; the largest is unchanged at 504

Notes

Test-only. Nothing under src/ is modified.

One comment repoint was necessary: a comment reading "the dedicated tooltip test below" moved to the urls suite while the tooltip test it referenced moved to clicks. It now names the clicks suite. All ten positional comment references were checked; that was the only one crossing a file boundary. A stale cm-table-cell-render reference in styles-contract.test.ts is repointed to the module it actually meant, cell-render.ts.

mtskf added 5 commits August 21, 2026 23:27
… prose

Review found four claims in the new headers that the tree contradicts:

- the fixtures header said render-map never touches innerHTML, but
  cm-table-cell-render-map.test.ts:275 asserts on it. The conclusion (that
  suite does not need the shared serialiser) was right, the reason was not.
- the urls header said both at-cap rows observe a click. Only the absolute
  arm does; the autolink arm asserts liveness and stops. The header now
  records why that modifier-click loop must stay: the clicks suite only ever
  uses short URLs, so it is the sole pin on at-cap x modifier-click routing.
- the inline-ir header justified its happy-dom pragma as how every file in
  the directory declares its environment. cm-table-fallback-warn.test.ts
  carries none, and vitest.config.ts sets node globally, so the pragma is a
  per-file opt-in rather than a declaration.
- a cross-file reference dropped the .test segment, so following it landed
  on nothing. Pre-existing in the pre-split file, corrected here because
  every other such reference in the six new suites spells the suffix out.
The per-file 'Fixtures: helpers/cell-render-fixtures.ts' line repeated what
the import directly below it already states, and the fixtures header carried
a rhetorical aside that added no information the preceding clause lacked.
@mtskf
mtskf merged commit bb6b284 into main Aug 21, 2026
2 checks passed
@mtskf
mtskf deleted the chore/split-cell-render-test branch August 21, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant