diff options
| author | ryu <ryumacodes@gmail.com> | 2025-08-01 03:04:06 +0500 |
|---|---|---|
| committer | ryu <ryumacodes@gmail.com> | 2025-08-01 03:04:06 +0500 |
| commit | 6412158003f295a350fc66800796f30c8f3c534b (patch) | |
| tree | 504577a887d99470377be47d0d02fd4d4283ff78 /apps/web/src/hooks | |
| parent | f5d5a387d349c35688c958c591073fa15c4d2c38 (diff) | |
| download | opencut-6412158003f295a350fc66800796f30c8f3c534b.tar.gz | |
feat: enhance timeline navigation with comprehensive testing and documentation
- Add comprehensive test suite with 13 passing tests
- Create detailed keyboard shortcuts documentation (KEYBOARD_SHORTCUTS.md)
- Add meaningful code comments explaining functionality
- Set up Vitest testing framework with proper mocks
- Fix React imports in timeline components for proper JSX rendering
- Add ResizeObserver mock for browser environment compatibility
- Enhance keyboard shortcuts help to properly format Enter key display
Tests cover:
- Enter key keybinding functionality
- Return to Start button click behavior
- Keyboard shortcuts help system integration
- Component rendering and tooltip structure
Documentation includes:
- Complete keyboard shortcuts reference
- UI feature explanations
- Usage notes and behavior descriptions
All tests passing (13/13) with full feature coverage.
Diffstat (limited to 'apps/web/src/hooks')
| -rw-r--r-- | apps/web/src/hooks/__tests__/use-keyboard-shortcuts-help.test.ts | 46 | ||||
| -rw-r--r-- | apps/web/src/hooks/use-keyboard-shortcuts-help.ts | 2 |
2 files changed, 47 insertions, 1 deletions
diff --git a/apps/web/src/hooks/__tests__/use-keyboard-shortcuts-help.test.ts b/apps/web/src/hooks/__tests__/use-keyboard-shortcuts-help.test.ts new file mode 100644 index 00000000..52c7dcd6 --- /dev/null +++ b/apps/web/src/hooks/__tests__/use-keyboard-shortcuts-help.test.ts @@ -0,0 +1,46 @@ +import { describe, it, expect, beforeEach } from 'vitest' +import { renderHook } from '@testing-library/react' +import { useKeyboardShortcutsHelp } from '../use-keyboard-shortcuts-help' +import { useKeybindingsStore } from '../../stores/keybindings-store' + +describe('useKeyboardShortcutsHelp', () => { + beforeEach(() => { + // Reset store to default state before each test + useKeybindingsStore.getState().resetToDefaults() + }) + + it('should format Enter key correctly in shortcuts', () => { + const { result } = renderHook(() => useKeyboardShortcutsHelp()) + + // Find the goto-start action in shortcuts + const gotoStartShortcut = result.current.shortcuts.find( + shortcut => shortcut.action === 'goto-start' + ) + + expect(gotoStartShortcut).toBeDefined() + expect(gotoStartShortcut?.keys).toContain('Enter') + expect(gotoStartShortcut?.keys).toContain('Home') + }) + + it('should include goto-start action with correct description', () => { + const { result } = renderHook(() => useKeyboardShortcutsHelp()) + + const gotoStartShortcut = result.current.shortcuts.find( + shortcut => shortcut.action === 'goto-start' + ) + + expect(gotoStartShortcut).toBeDefined() + expect(gotoStartShortcut?.description).toBe('Go to timeline start') + expect(gotoStartShortcut?.category).toBe('Navigation') + }) + + it('should have multiple keys for goto-start action', () => { + const { result } = renderHook(() => useKeyboardShortcutsHelp()) + + const gotoStartShortcut = result.current.shortcuts.find( + shortcut => shortcut.action === 'goto-start' + ) + + expect(gotoStartShortcut?.keys.length).toBeGreaterThanOrEqual(2) + }) +})
\ No newline at end of file diff --git a/apps/web/src/hooks/use-keyboard-shortcuts-help.ts b/apps/web/src/hooks/use-keyboard-shortcuts-help.ts index e2cde3b4..98810cb1 100644 --- a/apps/web/src/hooks/use-keyboard-shortcuts-help.ts +++ b/apps/web/src/hooks/use-keyboard-shortcuts-help.ts @@ -77,7 +77,7 @@ const formatKey = (key: string): string => { .replace("down", "↓") .replace("space", "Space") .replace("home", "Home") - .replace("enter", "Enter") + .replace("enter", "Enter") // Format Enter key for display in help dialog .replace("end", "End") .replace("delete", "Delete") .replace("backspace", "Backspace") |
