Skip to content

test(mouse-selection-keys): cover drag, copy, and non-terminal-yield branches#305

Open
dormouse-bot wants to merge 1 commit into
mainfrom
test/mouse-selection-keys-coverage
Open

test(mouse-selection-keys): cover drag, copy, and non-terminal-yield branches#305
dormouse-bot wants to merge 1 commit into
mainfrom
test/mouse-selection-keys-coverage

Conversation

@dormouse-bot

Copy link
Copy Markdown
Collaborator

The nightly survey flagged handle-mouse-selection-keys.test.ts as covering only two of the handler's paths — the editable-target paste guard and the xterm-helper-textarea paste — leaving the module's core selection logic untested. This adds cases for the untested branches in handle-mouse-selection-keys.ts, so a regression in any of them fails loudly instead of shipping green.

New cases:

  • Non-terminal yield — a surface whose nav.paneParams reports surfaceType: 'agent-browser' returns false and does not paste, matching the documented invariant that browser/iframe surfaces own their clipboard keys.
  • Drag: token extende with a hintToken active calls extendSelectionToToken(sid, hintToken).
  • Drag: Escape — clears the selection via setSelection(sid, null).
  • Drag: key swallowing — a non-Alt key during a drag is swallowed (preventDefault) and handled, while Alt is handled but left to reach the OS (the block-selection modifier).
  • CopyCmd+C calls copyRaw and Cmd+Shift+C calls copyRewrapped, each followed by flashCopy with the matching kind.

To drive the drag/selection shape the handler reads, the test now mocks lib/mouse-selection (the per-id module-state store) alongside the existing clipboard and platform mocks. The two original tests are unchanged.

Test-only change. vitest run (7 passed) and tsc -b both pass locally.

Surfaced by the nightly code-quality survey.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8ce61a2
Status: ✅  Deploy successful!
Preview URL: https://54617a22.mouseterm.pages.dev
Branch Preview URL: https://test-mouse-selection-keys-co.mouseterm.pages.dev

View logs

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