Commit 322a7d3
committed
refactor: Extract command handlers and improve test coverage
Major refactoring to improve code organization and testability:
Command Handler Extraction:
- Create lib/command-handlers.js with dependency injection pattern
- Extract 19 commands: playback (9), queue (5), volume (2), search (3)
- Reduce index.js by ~500 lines
Queue Utilities:
- Create lib/queue-utils.js for sorting and track utilities
- Extract pure functions for better testability
Test Infrastructure:
- Add comprehensive mocks for Sonos, Slack, Discord, Spotify
- New test files: auth-handler, command-handlers, discord,
queue-utils, setconfig, slack
- Expand voting.test.mjs with direct module tests
- Total: 511 unit tests passing
Integration Tests:
- Expand from 21 to 70 integration tests
- Add pre-flight checks for clean state validation
- Add queue verification before/after modifications
- Keep volume safe (max 20, reset to 5)
- Fix all validators to match actual bot responses
Bug Fixes:
- Fix votecheck to show track metadata when track leaves queue
- Store track title/artist when votes are cast1 parent 0d2db7f commit 322a7d3
27 files changed
Lines changed: 5685 additions & 732 deletions
File tree
- .github/workflows
- docs
- lib
- templates/help
- test
- mocks
- tools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| 249 | + | |
249 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
Large diffs are not rendered by default.
0 commit comments