Skip to content

test(image): pin toDOM's blockStart write with an absent-miss-breadcrumb click - #360

Merged
mtskf merged 1 commit into
mainfrom
test/pin-image-todom-blockstart
Aug 16, 2026
Merged

test(image): pin toDOM's blockStart write with an absent-miss-breadcrumb click#360
mtskf merged 1 commit into
mainfrom
test/pin-image-todom-blockstart

Conversation

@mtskf

@mtskf mtskf commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Summary

ImageBlockWidget.toDOM's blockStart.set(root, this.docFrom) was unkillable by its own suite: 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 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" — spies console.error, clicks a freshly toDOM'd widget, asserts the anchor dispatch AND not.toHaveBeenCalled().
  • Comment records why the anchor value alone cannot pin this, and why the updateDOM fixtures stay green under the same mutation (their own blockStart.set refills the entry).

Related

Test Plan

  • pnpm vitest run test/webview/image/cm-image-widget.test.ts — 26 passed.
  • Non-vacuity: deleted blockStart.set(root, this.docFrom) from toDOM → 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 compile and pnpm lint clean.

…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.
@mtskf
mtskf merged commit 89dec4d into main Aug 16, 2026
2 checks passed
@mtskf
mtskf deleted the test/pin-image-todom-blockstart branch August 16, 2026 22:58
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