test: add command palette and fuzzy match tests

Tests for CommandPalette component (rendering, filtering, keyboard
navigation, grouped results, shortcuts display), useCommandRegistry
hook (contextual actions, archive toggle, git availability), fuzzyMatch
utility, and Cmd+K shortcut.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
lucaronin
2026-02-24 23:43:58 +01:00
parent 9bcc1776cc
commit 8a08fb67a3
4 changed files with 372 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ function fireKey(key: string, mods: { altKey?: boolean; metaKey?: boolean; ctrlK
function makeActions() {
return {
onQuickOpen: vi.fn(),
onCommandPalette: vi.fn(),
onCreateNote: vi.fn(),
onSave: vi.fn(),
onOpenSettings: vi.fn(),
@@ -86,4 +87,11 @@ describe('useAppKeyboard', () => {
fireKey('4', { altKey: true })
expect(actions.onSetViewMode).not.toHaveBeenCalled()
})
it('Cmd+K triggers command palette', () => {
const actions = makeActions()
renderHook(() => useAppKeyboard(actions))
fireKey('k', { metaKey: true })
expect(actions.onCommandPalette).toHaveBeenCalled()
})
})