test(image): pin toDOM's blockStart write with an absent-miss-breadcrumb click - #360
Merged
Conversation
…umb click Every click fixture in cm-image-widget.test.ts builds the widget and clicks it in the same breath, so the listener's miss fallback (this.docFrom, the toDOM-time closure) coincides with the WeakMap value: deleting blockStart.set(root, this.docFrom) from toDOM left the whole suite green. Assert instead that no miss breadcrumb is logged for a freshly-built widget, which is the only observable difference. Mirrors the pin PR #359 added on the table widget, closing the same gap on the image widget that introduced the pattern.
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
ImageBlockWidget.toDOM'sblockStart.set(root, this.docFrom)was unkillable by its own suite: every click fixture incm-image-widget.test.tsbuilds the widget and clicks it in the same breath, so the listener's miss fallback (this.docFrom, the toDOM-time closure) coincides with the WeakMap value and the dispatched anchor is identical either way. Deleting that line left the whole file green. This adds the one assertion that can tell them apart — the miss breadcrumb (console.error) must NOT be emitted for a freshly-built widget.Test-only; no production behaviour changes. Mirrors the pin PR #359 added on the table widget, so the converged pattern is no longer split on its test side: the image widget (whose #356 introduced the pattern) now carries the same guard.
Changes
test/webview/image/cm-image-widget.test.ts: new case "does not log a blockStart miss when a fresh toDOM'd widget is clicked" — spiesconsole.error, clicks a freshlytoDOM'd widget, asserts the anchor dispatch ANDnot.toHaveBeenCalled().updateDOMfixtures stay green under the same mutation (their ownblockStart.setrefills the entry).Related
image-widget.ts'stoDOMblockStart.setis unkillable by its own suite (scoped out of PR refactor(table): carry the root caret offset in a WeakMap, not a DOM stamp #359).Test Plan
pnpm vitest run test/webview/image/cm-image-widget.test.ts— 26 passed.blockStart.set(root, this.docFrom)fromtoDOM→ exactly 1 failure, the new test (25 others still green, confirming it is the only guard). Source restored.pnpm test:unit— 250 files / 4976 tests passed;pnpm compileandpnpm lintclean.