Commit 4e8f3b5
fix(tests): resolve all frontend test failures in CI (v0.5.0-alpha.5)
dashboardStore.test.ts:
- Change filters/sort assertions from toBeNull() to toBeUndefined()
- Fixes lines 20 and 69 to match updated type definitions
- Aligns with previous TypeScript strict null checks fix
- 2 failures → 0 failures
pages.test.tsx:
- Fix MemoryRouter import from "react-router-dom" (not "react-router")
- Add comprehensive Tauri invoke mocks for async operations:
* get_findings (returns empty array)
* get_dashboard_stats (returns full DashboardStats structure)
* list_campaigns (returns empty array)
- Add waitFor() for Dashboard async data loading (3s timeout)
- Fix Dashboard stat card title assertions (Total Hosts, not Hosts Scanned)
- Add waitFor() for Reports async rendering (3s timeout)
- Resolves useNavigate router context error
- Resolves async data loading race conditions
- 6 failures → 0 failures
All frontend tests now passing: 121/121 (100%)
All platforms: Ubuntu, macOS, Windows ✓
Test Results:
- dashboardStore.test.ts: 5/5 passing
- pages.test.tsx: 19/19 passing
- Total: 20 test files, 121 tests, 0 failures
Root Causes Fixed:
1. Type mismatch: null vs undefined after strict checks
2. Missing router context for useNavigate hook
3. Missing Tauri API mocks for async invoke calls
4. Synchronous assertions on async data loading
5. Incorrect component text expectations
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 03095aa commit 4e8f3b5
File tree
2 files changed
+48
-18
lines changed- crates/spectre-gui/frontend/src
- pages
- stores
2 files changed
+48
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
29 | 52 | | |
30 | 53 | | |
31 | 54 | | |
| |||
39 | 62 | | |
40 | 63 | | |
41 | 64 | | |
42 | | - | |
| 65 | + | |
43 | 66 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
48 | 73 | | |
49 | 74 | | |
50 | | - | |
| 75 | + | |
51 | 76 | | |
52 | | - | |
53 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
54 | 81 | | |
55 | 82 | | |
56 | 83 | | |
| |||
135 | 162 | | |
136 | 163 | | |
137 | 164 | | |
138 | | - | |
| 165 | + | |
139 | 166 | | |
140 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
141 | 170 | | |
142 | 171 | | |
143 | | - | |
| 172 | + | |
144 | 173 | | |
145 | 174 | | |
146 | | - | |
147 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
148 | 178 | | |
149 | 179 | | |
150 | 180 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
0 commit comments