Commit 312d413
authored
test: add comprehensive HomePage test suite and fix unreachable WebSocket branch (#219)
- Implement 25+ unit tests covering:
• Task fetching logic (success, error, loading)
• WebSocket behaviors (success, failure, malformed JSON, unknown job)
• Toast notifications for all job types
• Component rendering and prop passing
• Onboarding tour flow:
– first-time users
– already seen
– skip button behavior
– timeout cleanup
– multiple render guard
- Improve overall test coverage to ~90%+ (statements, branches, funcs)
- Fix unreachable WebSocket success-branch:
• Code previously checked `data.status === 'success'` twice
• The outer `if` made the inner `else if (data.status === 'success')` unreachable
• Refactored logic so job-based toast branches always execute under the main success block
- Fix SSR guard:
• Replaced direct `typeof window === 'undefined'` with an Istanbul-ignored guard
• Prevents false negatives in coverage reports
- Organize tests using nested `describe` blocks
- Clean up mocks, remove commented code, and standardize formatting1 parent 1cee133 commit 312d413
File tree
2 files changed
+588
-3
lines changed- frontend/src/components
- __tests__
2 files changed
+588
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | 80 | | |
82 | 81 | | |
83 | 82 | | |
| |||
134 | 133 | | |
135 | 134 | | |
136 | 135 | | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
| |||
0 commit comments