Skip to content

Replace cypress-real-events with native Cypress keyboard API#184

Open
Coteh wants to merge 3 commits into
masterfrom
claude/cypress-press-command-xlg3T
Open

Replace cypress-real-events with native Cypress keyboard API#184
Coteh wants to merge 3 commits into
masterfrom
claude/cypress-press-command-xlg3T

Conversation

@Coteh

@Coteh Coteh commented Mar 14, 2026

Copy link
Copy Markdown
Owner

Summary

Removed the cypress-real-events dependency and replaced its usage with Cypress's native keyboard event handling API. This simplifies the test setup and reduces external dependencies.

Key Changes

  • Replaced cy.get(".help-link").realType("{enter}") with cy.press(Cypress.Keyboard.Keys.ENTER) in the how-to-play test
  • Removed cypress-real-events from devDependencies in package.json
  • Removed the cypress-real-events/support import from cypress/support/e2e.js
  • Updated Cypress version from ^13.8.1 to ^15.12.0 to ensure native keyboard API support

Implementation Details

The test maintains the same functionality—dispatching an Enter key event to toggle the help dialog—but now uses Cypress's built-in keyboard handling instead of relying on the external real-events library. The updated comment clarifies that cy.press dispatches a real Enter key event to the browser window.

https://claude.ai/code/session_01MpqnEptGDtH5SFAk5BC98Z

Summary by CodeRabbit

  • Chores

    • Upgraded testing framework to a newer version and removed an unused real-events test helper.
    • Updated tests to close dialogs via the UI close control instead of relying on simulated key events.
  • Documentation

    • Developer docs now state Node.js ≥ 20 requirement.

The single realType("{enter}") call is replaced with cy.press(Cypress.Keyboard.Keys.ENTER),
which dispatches real native keyboard events natively in Cypress 14.3.0+. With no remaining
usages, cypress-real-events is fully removed from the project.

https://claude.ai/code/session_01MpqnEptGDtH5SFAk5BC98Z
@coderabbitai

coderabbitai Bot commented Mar 14, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 18a61b0f-d7f0-4b72-bca7-8aa150784157

📥 Commits

Reviewing files that changed from the base of the PR and between 564f5ee and 3ee2a39.

📒 Files selected for processing (1)
  • cypress/e2e/game/how-to-play.cy.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • cypress/e2e/game/how-to-play.cy.js

📝 Walkthrough

Walkthrough

Replace cypress-real-events usage and related import, update Cypress to ^15.12.0 and add Node engine >=20, and modify a Cypress test to close the how-to-play dialog via its close button instead of using real-events Enter typing; README notes Node ≥ 20.

Changes

Cohort / File(s) Summary
Test change
cypress/e2e/game/how-to-play.cy.js
Remove real-events Enter typing flow; open the dialog and close it via the dialog's close button; keep assertions that dialog and overlay disappear.
Support file
cypress/support/e2e.js
Removed cypress-real-events/support import; retained cypress-wait-until.
Deps & metadata
package.json
Added engines.node: ">=20", upgraded devDependencies.cypress to ^15.12.0, and removed cypress-real-events from devDependencies.
Docs
README.md
Added Development note: "Requires Node.js ≥ 20."

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through tests with careful paws,
swapped real keystrokes for a button's cause.
Node now asks for twenty and above,
Cypress upgraded, trimmed what I shove.
The dialog closes — a tidy little applause.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing cypress-real-events with native Cypress keyboard API, which is reflected in the dependency removal, support file changes, and test updates across the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/cypress-press-command-xlg3T
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
cypress/e2e/game/how-to-play.cy.js (1)

53-55: Enforce the help-link focus precondition explicitly.

The comment on line 53 claims the help link is focused, but the test does not enforce this precondition before pressing Enter. Add explicit focus to make this interaction deterministic and match the stated behavior.

Suggested fix
-        // Use cy.press to dispatch a real Enter key event to the browser window while the help link is focused,
-        // triggering the exact scenario that happens in a real browser where the help dialog is toggled again.
+        // Ensure the help link is focused, then dispatch Enter to reproduce keyboard toggle behavior deterministically.
+        cy.get(".help-link").focus().should("have.focus");
         cy.press(Cypress.Keyboard.Keys.ENTER);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cypress/e2e/game/how-to-play.cy.js` around lines 53 - 55, The test assumes
the help link is focused before calling cy.press(Cypress.Keyboard.Keys.ENTER)
but doesn't enforce it; fix by explicitly focusing the help link element
immediately before the cy.press call (e.g. use cy.get(...) or the same selector
used elsewhere in this spec to locate the help link and call .focus() on it),
then call cy.press(Cypress.Keyboard.Keys.ENTER) to trigger the Enter key
interaction deterministically.
package.json (1)

25-25: Consider adding engines.node to explicitly guard against Cypress 15's Node.js 20+ requirement.

While GitHub Actions is configured with Node 20 (compatible with Cypress 15), local developers lack an explicit constraint in package.json and could attempt to run Cypress 15 on Node <20, which will fail. Adding "engines": { "node": ">=20" } makes the requirement explicit and prevents runtime surprises.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 25, Add an explicit Node engine constraint to
package.json to prevent running Cypress 15 on unsupported Node versions: add a
top-level "engines" object with "node": ">=20" (e.g., "engines": { "node":
">=20" }) so local developers and tools see the requirement alongside the
existing "cypress" dependency; update any README or dev setup notes if present
that reference Node version expectations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@cypress/e2e/game/how-to-play.cy.js`:
- Around line 53-55: The test assumes the help link is focused before calling
cy.press(Cypress.Keyboard.Keys.ENTER) but doesn't enforce it; fix by explicitly
focusing the help link element immediately before the cy.press call (e.g. use
cy.get(...) or the same selector used elsewhere in this spec to locate the help
link and call .focus() on it), then call cy.press(Cypress.Keyboard.Keys.ENTER)
to trigger the Enter key interaction deterministically.

In `@package.json`:
- Line 25: Add an explicit Node engine constraint to package.json to prevent
running Cypress 15 on unsupported Node versions: add a top-level "engines"
object with "node": ">=20" (e.g., "engines": { "node": ">=20" }) so local
developers and tools see the requirement alongside the existing "cypress"
dependency; update any README or dev setup notes if present that reference Node
version expectations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9d697996-b946-4982-934c-9bfcbb18ce82

📥 Commits

Reviewing files that changed from the base of the PR and between d0a04d6 and e8ce5b1.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • cypress/e2e/game/how-to-play.cy.js
  • cypress/support/e2e.js
  • package.json
💤 Files with no reviewable changes (1)
  • cypress/support/e2e.js

- Focus the close button explicitly before cy.press(ENTER) so the Enter key
  deterministically activates the close button (which is the mechanism that
  removes the dialog from the DOM). Focusing the help-link instead would re-invoke
  renderDialog and leave a new dialog open, failing the assertion.
- Add "engines": {"node": ">=20"} to package.json since Cypress 15 requires Node 20+.
- Document the Node >=20 requirement in the Development section of README.md.

https://claude.ai/code/session_01MpqnEptGDtH5SFAk5BC98Z
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 14, 2026

Copy link
Copy Markdown

Deploying wordle-clone with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3ee2a39
Status: ✅  Deploy successful!
Preview URL: https://fb7681f4.wordle-clone-8k1.pages.dev
Branch Preview URL: https://claude-cypress-press-command.wordle-clone-8k1.pages.dev

View logs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package.json`:
- Around line 20-22: Update the Node engine constraint in package.json to
require Node >=20.1.0 instead of ">=20"; locate the "engines" -> "node" entry
and change its value to ">=20.1.0" so it aligns with Cypress 15.12.0's supported
Node ranges.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3447a726-17f5-4661-9663-4c1ba13b1a3f

📥 Commits

Reviewing files that changed from the base of the PR and between e8ce5b1 and 564f5ee.

📒 Files selected for processing (3)
  • README.md
  • cypress/e2e/game/how-to-play.cy.js
  • package.json
✅ Files skipped from review due to trivial changes (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • cypress/e2e/game/how-to-play.cy.js

Comment thread package.json
Comment on lines +20 to +22
"engines": {
"node": ">=20"
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Cypress 15 cy.press keyboard API documentation

💡 Result:

Cypress v15’s keyboard “press a key” API is cy.press() (for native keydown/keyup events).

  • Official API docs (syntax, options, supported keys, examples): cy.press() (docs.cypress.io)

    • Syntax: cy.press(key) / cy.press(key, options) (docs.cypress.io)
    • Prefer named keys via Cypress.Keyboard.Keys (e.g., Cypress.Keyboard.Keys.TAB, ENTER, arrows, etc.). (docs.cypress.io)
    • Notes include limitations (e.g., no multi-character strings; F1–F12 not supported). (docs.cypress.io)
  • Background/announcement blog post: “Press tab in your tests: Introducing cy.press()” (cypress.io)

Citations:


🌐 Web query:

Cypress 15 Node.js version requirement compatibility

💡 Result:

Cypress 15.x requires Node.js 20, 22, or 24+ on the machine where you install/run Cypress via the cypress npm package. Node.js 18 and 23 are not supported for Cypress 15 installs. [1]

Compatibility summary (Node.js → Cypress 15):

  • Node 20 LTS: supported [1]
  • Node 22 LTS: supported [1]
  • Node 24 (and newer): supported [1]
  • Node 18: not supported (upgrade required) [1]
  • Node 23: not supported [1]

Note: Cypress includes a bundled Node.js for parts of its internal runtime, but your system Node.js is still used when installing the cypress npm package and fetching the Cypress binary. [1]

Sources

  1. Cypress Docs — Migration Guide (Cypress 15.0: “Node.js 20, 22 and 24+ support”) [1]

🌐 Web query:

Cypress 15.12.0 release version npm registry

💡 Result:

Cypress 15.12.0 is published on the npm registry.

Citations:


Update Node engine constraint to ">=20.1.0" for precision.

All three points are confirmed:

  • Cypress 15.12.0 is a valid published release (latest as of March 2026)
  • The cy.press() API exists in Cypress 15 with full support for Cypress.Keyboard.Keys (e.g., ENTER)
  • Node 20+ is indeed required

However, Cypress 15.12.0 specifies ^20.1.0 || ^22.0.0 || >=24.0.0. The current constraint ">=20" would allow Node 20.0.x, which does not satisfy the requirement. Change to ">=20.1.0" for alignment.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 20 - 22, Update the Node engine constraint in
package.json to require Node >=20.1.0 instead of ">=20"; locate the "engines" ->
"node" entry and change its value to ">=20.1.0" so it aligns with Cypress
15.12.0's supported Node ranges.

@github-actions

github-actions Bot commented Mar 14, 2026

Copy link
Copy Markdown

Test Results

 14 files  ±0   87 suites  ±0   4m 29s ⏱️ -33s
264 tests ±0  264 ✅ ±0  0 💤 ±0  0 ❌ ±0 
273 runs  ±0  273 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 3ee2a39. ± Comparison against base commit d0a04d6.

This pull request removes 1 and adds 1 tests. Note that renamed tests count towards both.
can be closed by pressing enter key after clicking help icon ‑ how to play can be closed by pressing enter key after clicking help icon
can be closed via close button after clicking help icon ‑ how to play can be closed via close button after clicking help icon

♻️ This comment has been updated with latest results.

cy.press dispatches keydown/keyup directly to the browser window via
window.dispatchEvent. The window-level keydown handler only closes the
dialog on Escape; Enter returns early when a dialog is open. No DOM
element's click is synthesised, so cy.press(ENTER) can never dismiss
the dialog regardless of which element is focused.

Replace the focus+press approach with a direct close button click, which
is the actual mechanism that removes the dialog from the DOM. Rename the
test to match the updated behaviour.

https://claude.ai/code/session_01MpqnEptGDtH5SFAk5BC98Z
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.

2 participants