this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

more fixes and tests

alice 400c16cc 56295d66

+96
+96
index.test.ts
··· 122 122 expect(cardNames).not.toContain(card1.name); 123 123 }); 124 124 125 + test('Part 1 to Part 2 transition BLOCKS if unassigned cards exist', () => { 126 + // Arrange: Leave some cards unassigned (initial state) 127 + const initialStateCards = app.undoManager.getState().cards; 128 + // Ensure there is at least one unassigned card 129 + expect(initialStateCards.some(c => c.column === 'unassigned')).toBe(true); 130 + 131 + // Act: Simulate clicking the button 132 + const button = document.getElementById('toPart2'); 133 + button?.click(); 134 + 135 + // Assert: Check that the state did NOT change 136 + const stateAfterClick = app.undoManager.getState(); 137 + expect(stateAfterClick.currentPart).toBe('part1'); // Should still be in part1 138 + expect(stateAfterClick.cards).toEqual(initialStateCards); // Cards state should be unchanged 139 + // We could also spy on window.alert if needed 140 + }); 141 + 142 + test('Part 2 to Part 4 transition SKIPS Part 3 if <= 5 veryImportant cards', () => { 143 + // Arrange: Setup state in Part 2 with 4 'veryImportant' cards 144 + let state = app.undoManager.getState(); 145 + state.currentPart = 'part2'; // Manually set part for setup 146 + state.cards = [ 147 + { id: 1, name: 'V1', column: 'veryImportant', order: 0 }, 148 + { id: 2, name: 'V2', column: 'veryImportant', order: 1 }, 149 + { id: 3, name: 'V3', column: 'veryImportant', order: 2 }, 150 + { id: 4, name: 'V4', column: 'veryImportant', order: 3 }, 151 + { id: 5, name: 'I1', column: 'important', order: 4 }, // Need some non-veryImportant too 152 + ]; 153 + app.updateState(state); 154 + // Note: Need to re-bind listeners if updateState doesn't do it, 155 + // but our simple listener binding in constructor might suffice if DOM isn't fully replaced. 156 + // For robustness, re-creating App instance or re-binding might be better in complex scenarios. 157 + app = new App(); // Re-create to ensure listeners are bound to correct state/DOM 158 + 159 + // Act: Click the 'Next' button (toPart3) 160 + const button = document.getElementById('toPart3'); 161 + button?.click(); 162 + 163 + // Assert: Should be in Part 4, and cards should be 'core' 164 + const part4State = app.undoManager.getState(); 165 + expect(part4State.currentPart).toBe('part4'); // Should skip to part4 166 + expect(part4State.cards.length).toBe(4); // Only the 4 veryImportant cards remain 167 + expect(part4State.cards.every(c => c.column === 'core')).toBe(true); 168 + }); 169 + 170 + test('Part 3 to Part 4 transition BLOCKS if > 5 core cards', () => { 171 + // Arrange: Setup state in Part 3 with 6 'core' cards 172 + let state = app.undoManager.getState(); 173 + state.currentPart = 'part3'; 174 + state.cards = [ 175 + { id: 1, name: 'C1', column: 'core', order: 0 }, 176 + { id: 2, name: 'C2', column: 'core', order: 1 }, 177 + { id: 3, name: 'C3', column: 'core', order: 2 }, 178 + { id: 4, name: 'C4', column: 'core', order: 3 }, 179 + { id: 5, name: 'C5', column: 'core', order: 4 }, 180 + { id: 6, name: 'C6', column: 'core', order: 5 }, 181 + ]; 182 + app.updateState(state); 183 + app = new App(); // Re-create for listeners 184 + 185 + // Act: Click the 'Next' button (toPart4) 186 + const button = document.getElementById('toPart4'); 187 + button?.click(); 188 + 189 + // Assert: Should still be in Part 3 190 + const stateAfterClick = app.undoManager.getState(); 191 + expect(stateAfterClick.currentPart).toBe('part3'); 192 + }); 193 + 194 + test('Part 3 to Part 4 transition SUCCEEDS if <= 5 core cards', () => { 195 + // Arrange: Setup state in Part 3 with 5 'core' cards 196 + let state = app.undoManager.getState(); 197 + state.currentPart = 'part3'; 198 + state.cards = [ 199 + { id: 1, name: 'C1', column: 'core', order: 0 }, 200 + { id: 2, name: 'C2', column: 'core', order: 1 }, 201 + { id: 3, name: 'C3', column: 'core', order: 2 }, 202 + { id: 4, name: 'C4', column: 'core', order: 3 }, 203 + { id: 5, name: 'C5', column: 'core', order: 4 }, 204 + { id: 6, name: 'A1', column: 'additional', order: 5 }, // One additional 205 + ]; 206 + app.updateState(state); 207 + app = new App(); // Re-create for listeners 208 + 209 + // Act: Click the 'Next' button (toPart4) 210 + const button = document.getElementById('toPart4'); 211 + button?.click(); 212 + 213 + // Assert: Should be in Part 4 214 + const part4State = app.undoManager.getState(); 215 + expect(part4State.currentPart).toBe('part4'); 216 + // Cards state should remain the same (core/additional separation is kept) 217 + expect(part4State.cards.filter(c => c.column === 'core').length).toBe(5); 218 + expect(part4State.cards.filter(c => c.column === 'additional').length).toBe(1); 219 + }); 220 + 125 221 // Add more tests for other transitions (Part 2 -> 3, 3 -> 4, etc.) 126 222 // Add tests for card movement logic (moveCard) 127 223 // Add tests for final statement input