Skip to content

Add a unit test for the useCommandPalette open/close and shortcut handling #982

Description

@1nonlypiece

📌 Description

src/hooks/useCommandPalette.ts manages command-palette open state and the Cmd/Ctrl-K shortcut, but it is untested. Toggle behaviour and keyboard binding are unverified.

🎯 Requirements and Context

  • Cover open, close, and toggle transitions.
  • Assert the Cmd-K / Ctrl-K key handler toggles the palette and is removed on unmount.
  • Assert it does not toggle while typing in inputs if that guard exists.

🛠️ Suggested Execution

1. Fork the repo and create a branch

git checkout -b test/use-command-palette-tests

2. Implement changes

  • src/hooks/__tests__/useCommandPalette.test.ts — new unit test
  • src/hooks/useCommandPalette.ts — read only

3. Test and commit

  • Run the suite: pnpm test (or npm test) and pnpm lint.
  • Cover edge cases: meta+k vs ctrl+k; listener cleanup on unmount; repeated toggles; key pressed inside an input.
  • Include test output (and a short note of any behavioural findings) in the PR.

Example commit message

test: add unit coverage for useCommandPalette shortcut and state

✅ Guidelines

  • Minimum 95% test coverage on the new/changed lines.
  • Clear, reviewer-friendly documentation and a small, focused diff.
  • No regressions against existing suites.
  • Timeframe: 96 hours.

🏷️ Labels

type-testing · area-frontend · MAYBE REWARDED · GRANTFOX OSS · OFFICIAL CAMPAIGN

💬 Community & Support

  • Join the CommitLabs contributor Discord to coordinate, ask questions, and get
    unblocked fast: https://discord.gg/WV7tdYkJk
  • Please introduce yourself in the channel before you start so we can avoid
    duplicate work, pair you with a reviewer, and get your PR merged quickly.
  • Maintainers actively triage this channel and aim for fast, clear, respectful
    reviews — reach out any time you're blocked.

Metadata

Metadata

Assignees

Labels

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions