Skip to content

test(react-grab): e2e sweep for the global keyboard handler - #505

Closed
aidenybai wants to merge 1 commit into
mainfrom
test/keyboard-handler-e2e
Closed

test(react-grab): e2e sweep for the global keyboard handler#505
aidenybai wants to merge 1 commit into
mainfrom
test/keyboard-handler-e2e

Conversation

@aidenybai

@aidenybai aidenybai commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

The #1 item from the coverage report — and the only one that moves the V8 e2e branch numbers (unit tests don't feed that run). The global keydown handler in core/index.tsx is reached, but whole arms never fire. This adds the two highest-leverage, reliably-testable scenarios:

  • Keyboard context-menu trigger (tryHandleContextMenuKey, previously never reached): the ContextMenu key and Shift+F10 open the context menu on the hovered selection, and both are correctly ignored while inactive.
  • Window-refocus grace period (didWindowJustRegainFocus, the branch the report flagged as never taken): activation keys are suppressed for WINDOW_REFOCUS_GRACE_PERIOD_MS after the window regains focus, then work again once it elapses. The modifier is held before the synthetic focus event so only the single activation keydown must land inside the grace window — keeping it robust under parallel runs.

I prototyped a third case (Escape dismissing the toolbar menu popover) but it flaked under parallel contention (passed on retry / --workers=1), and the user explicitly wants fewer flaky specs, so I dropped it. The Escape-popover dismiss path is already partly covered by context-menu.spec.ts.

Test plan

  • playwright test e2e/keyboard-handler.spec.ts --project=chromium — 6/6 pass
  • --repeat-each=5 (parallel) — 25/25, no flakes after the trim
  • --repeat-each=8 --workers=1 — stable
  • pnpm --filter react-grab typecheck clean
  • pnpm lint clean

Note

Low Risk
Test-only addition; no runtime or production code changes.

Overview
Adds e2e/keyboard-handler.spec.ts with six Playwright cases aimed at previously untested branches in the global keydown handler.

Context-menu keys: With the overlay active and an element selected, ContextMenu and Shift+F10 open the context menu; ContextMenu does nothing while inactive.

Window-refocus grace: After a synthetic window focus event, activation shortcuts are ignored for ~WINDOW_REFOCUS_GRACE_PERIOD_MS (modifier held before focus so CI timing stays stable), then keyboard activation works again after the grace window passes.

Reviewed by Cursor Bugbot for commit a0e920c. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Add e2e tests for the global keyboard handler in react-grab, covering context‑menu triggers (ContextMenu key and Shift+F10) and the window‑refocus grace period. Verifies the menu opens on the hovered selection, ignores triggers while inactive, and suppresses activation during refocus before allowing it after the grace window.

Written for commit a0e920c. Summary will update on new commits.

Review in cubic

Covers the two highest-leverage gaps in the keydown handler that no spec
reached before:

- Keyboard context-menu trigger (tryHandleContextMenuKey): the ContextMenu
  key and Shift+F10 open the menu on the hovered selection, and both are
  ignored while inactive.
- Window-refocus grace period (didWindowJustRegainFocus): activation keys
  are suppressed for the grace window after the window regains focus, then
  work again once it elapses. The modifier is held before the focus event so
  only the single activation keydown must land inside the window, keeping the
  assertion robust under parallel runs.
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-grab-storybook Ready Ready Preview, Comment Jun 29, 2026 1:35am
react-grab-website Ready Ready Preview, Comment Jun 29, 2026 1:35am

@pkg-pr-new

pkg-pr-new Bot commented Jun 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@react-grab/cli@505
npm i https://pkg.pr.new/grab@505
npm i https://pkg.pr.new/react-grab@505

commit: a0e920c

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@aidenybai

Copy link
Copy Markdown
Owner Author

Superseded by #510, which consolidates all the test-coverage PRs into one. Commits preserved there.

@aidenybai aidenybai closed this Jun 29, 2026
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