test(react-grab): e2e sweep for the global keyboard handler - #505
Closed
aidenybai wants to merge 1 commit into
Closed
test(react-grab): e2e sweep for the global keyboard handler#505aidenybai wants to merge 1 commit into
aidenybai wants to merge 1 commit into
Conversation
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.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
4 tasks
Owner
Author
|
Superseded by #510, which consolidates all the test-coverage PRs into one. Commits preserved there. |
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
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.tsxis reached, but whole arms never fire. This adds the two highest-leverage, reliably-testable scenarios:tryHandleContextMenuKey, previously never reached): theContextMenukey andShift+F10open the context menu on the hovered selection, and both are correctly ignored while inactive.didWindowJustRegainFocus, the branch the report flagged as never taken): activation keys are suppressed forWINDOW_REFOCUS_GRACE_PERIOD_MSafter 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 bycontext-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— stablepnpm --filter react-grab typecheckcleanpnpm lintcleanNote
Low Risk
Test-only addition; no runtime or production code changes.
Overview
Adds
e2e/keyboard-handler.spec.tswith 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
windowfocus 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.