Remap Caps Lock to Escape when keymap is enabled#18
Conversation
This change fixes the Caps Lock remapping functionality by using the consistent `keymapEnabled` state instead of the unused `isKeymapActive`. Redundant state is removed and a new test is added to verify the behavior. Co-authored-by: coderFeedForwardAlg <76785692+coderFeedForwardAlg@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
📝 WalkthroughWalkthrough
ChangesCapsLock keymap state consolidation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/CapsLock.test.js`:
- Around line 36-38: The `jest.restoreAllMocks()` call in the afterEach hook
does not clean up direct assignments to the global window.io object, which can
leak state between tests and cause cross-test coupling. Add explicit cleanup in
the afterEach hook to delete or reset the window.io property after
jest.restoreAllMocks() is called, ensuring each test starts with a clean global
state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 47978788-98bb-40e1-8b9b-b7fba3be05f0
📒 Files selected for processing (2)
frontend/src/App.jsfrontend/src/CapsLock.test.js
| afterEach(() => { | ||
| jest.restoreAllMocks(); | ||
| }); |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Clean up window.io explicitly in teardown.
jest.restoreAllMocks() won’t undo direct assignment to window.io, so this global can leak into later tests and cause cross-test coupling.
Suggested fix
afterEach(() => {
jest.restoreAllMocks();
+ delete window.io;
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| afterEach(() => { | |
| jest.restoreAllMocks(); | |
| }); | |
| afterEach(() => { | |
| jest.restoreAllMocks(); | |
| delete window.io; | |
| }); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@frontend/src/CapsLock.test.js` around lines 36 - 38, The
`jest.restoreAllMocks()` call in the afterEach hook does not clean up direct
assignments to the global window.io object, which can leak state between tests
and cause cross-test coupling. Add explicit cleanup in the afterEach hook to
delete or reset the window.io property after jest.restoreAllMocks() is called,
ensuring each test starts with a clean global state.
Updated the keymap functionality in
frontend/src/App.jsto correctly remap the Caps Lock key to the Escape key when the keymap is enabled. The fix involved consolidating the keymap state by removing the unusedisKeymapActivevariable and usingkeymapEnabledconsistently. A new test filefrontend/src/CapsLock.test.jswas added to ensure the remapping works as expected.PR created automatically by Jules for task 12538920612504833576 started by @coderFeedForwardAlg
Summary by CodeRabbit
Refactor
Tests