|
| 1 | +# API Testing - Phase 2: Card Detail Features |
| 2 | + |
| 3 | +**Status:** Planned |
| 4 | +**Created:** 2025-11-17 |
| 5 | +**Priority:** MEDIUM-HIGH |
| 6 | +**Duration Estimate:** 4-5 days |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## Overview |
| 11 | + |
| 12 | +Phase 2 focuses on testing card-related detail features that enhance card functionality. These modules provide rich interaction capabilities for cards including labeling, task tracking, commenting, and user assignment. |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Goals |
| 17 | + |
| 18 | +- ✅ Complete testing for all card detail features |
| 19 | +- ✅ Achieve 85%+ coverage for all modules |
| 20 | +- ✅ Validate complex queries (joins, counts, filtering) |
| 21 | +- ✅ Test duplicate prevention mechanisms |
| 22 | +- ✅ Verify cascading behaviors |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## Modules to Test |
| 27 | + |
| 28 | +### 1. Labels |
| 29 | +**Priority:** Medium-High |
| 30 | +**Current Status:** ❌ 0 tests |
| 31 | +**Endpoints:** 10 |
| 32 | +**Test Goal:** 90%+ coverage |
| 33 | + |
| 34 | +| Endpoint | Method | Status | Priority | |
| 35 | +|----------|--------|--------|----------| |
| 36 | +| `/labels` | POST | ❌ Not tested | High | |
| 37 | +| `/labels/:id` | GET | ❌ Not tested | Medium | |
| 38 | +| `/labels/:id` | PUT | ❌ Not tested | Medium | |
| 39 | +| `/labels/:id` | DELETE | ❌ Not tested | Medium | |
| 40 | +| `/labels/board/:board_id` | GET | ❌ Not tested | High | |
| 41 | +| `/labels/board/:board_id/with-counts` | GET | ❌ Not tested | Medium | |
| 42 | +| `/cards/:card_id/labels` | POST | ❌ Not tested | High | |
| 43 | +| `/cards/:card_id/labels/:label_id` | DELETE | ❌ Not tested | High | |
| 44 | +| `/cards/:card_id/labels` | GET | ❌ Not tested | High | |
| 45 | +| `/labels/:label_id/cards` | GET | ❌ Not tested | Medium | |
| 46 | + |
| 47 | +**Estimated Tests:** 45-50 tests |
| 48 | + |
| 49 | +**Key Features to Test:** |
| 50 | +- Label CRUD operations |
| 51 | +- Color validation |
| 52 | +- Name validation (length, uniqueness per board) |
| 53 | +- Assigning labels to cards |
| 54 | +- Removing labels from cards |
| 55 | +- Getting cards by label |
| 56 | +- Label counts per board |
| 57 | +- Duplicate prevention |
| 58 | +- Cascading deletes |
| 59 | + |
| 60 | +--- |
| 61 | + |
| 62 | +### 2. Checklists |
| 63 | +**Priority:** Medium |
| 64 | +**Current Status:** ❌ 0 tests |
| 65 | +**Endpoints:** 9 |
| 66 | +**Test Goal:** 85%+ coverage |
| 67 | + |
| 68 | +| Endpoint | Method | Status | Priority | |
| 69 | +|----------|--------|--------|----------| |
| 70 | +| `/checklist-items` | POST | ❌ Not tested | High | |
| 71 | +| `/checklist-items/:id` | GET | ❌ Not tested | Medium | |
| 72 | +| `/checklist-items/:id` | PUT | ❌ Not tested | High | |
| 73 | +| `/checklist-items/:id` | DELETE | ❌ Not tested | Medium | |
| 74 | +| `/checklist-items/card/:card_id` | GET | ❌ Not tested | High | |
| 75 | +| `/checklist-items/:id/toggle` | PATCH | ❌ Not tested | High | |
| 76 | +| `/checklist-items/card/:card_id/progress` | GET | ❌ Not tested | Medium | |
| 77 | +| `/checklist-items/card/:card_id/with-progress` | GET | ❌ Not tested | Medium | |
| 78 | +| `/checklist-items/card/:card_id/reorder` | PUT | ❌ Not tested | Medium | |
| 79 | + |
| 80 | +**Estimated Tests:** 40-45 tests |
| 81 | + |
| 82 | +**Key Features to Test:** |
| 83 | +- Checklist item CRUD operations |
| 84 | +- Toggle completion status |
| 85 | +- Progress calculation (% complete) |
| 86 | +- Ordering/reordering items |
| 87 | +- Title validation |
| 88 | +- Getting items with progress |
| 89 | +- Cascading deletes |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +### 3. Comments |
| 94 | +**Priority:** Medium |
| 95 | +**Current Status:** ❌ 0 tests |
| 96 | +**Endpoints:** 9 |
| 97 | +**Test Goal:** 85%+ coverage |
| 98 | + |
| 99 | +| Endpoint | Method | Status | Priority | |
| 100 | +|----------|--------|--------|----------| |
| 101 | +| `/comments` | POST | ❌ Not tested | High | |
| 102 | +| `/comments/:id` | GET | ❌ Not tested | Medium | |
| 103 | +| `/comments/:id` | PUT | ❌ Not tested | High | |
| 104 | +| `/comments/:id` | DELETE | ❌ Not tested | Medium | |
| 105 | +| `/comments/card/:card_id` | GET | ❌ Not tested | High | |
| 106 | +| `/comments/card/:card_id/with-users` | GET | ❌ Not tested | High | |
| 107 | +| `/comments/:parent_id/replies` | GET | ❌ Not tested | Medium | |
| 108 | +| `/comments/card/:card_id/threaded` | GET | ❌ Not tested | Medium | |
| 109 | +| `/comments/card/:card_id/count` | GET | ❌ Not tested | Low | |
| 110 | + |
| 111 | +**Estimated Tests:** 40-45 tests |
| 112 | + |
| 113 | +**Key Features to Test:** |
| 114 | +- Comment CRUD operations |
| 115 | +- User joins (author information) |
| 116 | +- Threading (parent-child relationships) |
| 117 | +- Replies to comments |
| 118 | +- Threaded view (nested structure) |
| 119 | +- Comment count |
| 120 | +- Authorization (edit own comments only) |
| 121 | +- Content validation |
| 122 | +- Pagination |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +### 4. Assignees |
| 127 | +**Priority:** Medium |
| 128 | +**Current Status:** ❌ 0 tests |
| 129 | +**Endpoints:** 5 |
| 130 | +**Test Goal:** 90%+ coverage |
| 131 | + |
| 132 | +| Endpoint | Method | Status | Priority | |
| 133 | +|----------|--------|--------|----------| |
| 134 | +| `/cards/:card_id/assignees` | POST | ❌ Not tested | High | |
| 135 | +| `/cards/:card_id/assignees/:user_id` | DELETE | ❌ Not tested | High | |
| 136 | +| `/cards/:card_id/assignees` | GET | ❌ Not tested | High | |
| 137 | +| `/cards/:card_id/assignees/:user_id/check` | GET | ❌ Not tested | Low | |
| 138 | +| `/users/:user_id/assigned-cards` | GET | ❌ Not tested | Medium | |
| 139 | + |
| 140 | +**Estimated Tests:** 25-30 tests |
| 141 | + |
| 142 | +**Key Features to Test:** |
| 143 | +- Add assignee to card |
| 144 | +- Remove assignee from card |
| 145 | +- Get all assignees for card |
| 146 | +- Check if user is assigned |
| 147 | +- Get user's assigned cards |
| 148 | +- Duplicate assignment prevention |
| 149 | +- User/card validation |
| 150 | +- User information joins |
| 151 | + |
| 152 | +--- |
| 153 | + |
| 154 | +## Implementation Order |
| 155 | + |
| 156 | +1. **Labels** (Day 1) - Most complex, sets patterns |
| 157 | +2. **Assignees** (Day 2) - Simpler, builds confidence |
| 158 | +3. **Checklists** (Day 3) - Progress calculation logic |
| 159 | +4. **Comments** (Day 4-5) - Threading complexity |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +## Testing Strategy |
| 164 | + |
| 165 | +### Unit Tests (Service Layer) |
| 166 | +- Mock repository methods |
| 167 | +- Test business logic |
| 168 | +- Validate error handling |
| 169 | +- Test edge cases |
| 170 | + |
| 171 | +### Integration Tests (Optional) |
| 172 | +- Full API endpoint tests |
| 173 | +- Database interactions |
| 174 | +- Join operations |
| 175 | +- Mark as `.skip` for future work |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | +## Common Test Patterns |
| 180 | + |
| 181 | +### CRUD Pattern |
| 182 | +```typescript |
| 183 | +describe('create', () => { |
| 184 | + it('should create with valid data') |
| 185 | + it('should validate required fields') |
| 186 | + it('should handle duplicates') |
| 187 | + it('should handle database errors') |
| 188 | +}) |
| 189 | + |
| 190 | +describe('read', () => { |
| 191 | + it('should return when found') |
| 192 | + it('should return null/undefined when not found') |
| 193 | + it('should include related data (joins)') |
| 194 | +}) |
| 195 | + |
| 196 | +describe('update', () => { |
| 197 | + it('should update with valid data') |
| 198 | + it('should return undefined when not found') |
| 199 | + it('should validate input') |
| 200 | +}) |
| 201 | + |
| 202 | +describe('delete', () => { |
| 203 | + it('should delete successfully') |
| 204 | + it('should return false when not found') |
| 205 | + it('should cascade to related records') |
| 206 | +}) |
| 207 | +``` |
| 208 | + |
| 209 | +### Association Pattern (Labels, Assignees) |
| 210 | +```typescript |
| 211 | +describe('add association', () => { |
| 212 | + it('should add successfully') |
| 213 | + it('should prevent duplicates') |
| 214 | + it('should validate both IDs') |
| 215 | +}) |
| 216 | + |
| 217 | +describe('remove association', () => { |
| 218 | + it('should remove successfully') |
| 219 | + it('should handle not found') |
| 220 | +}) |
| 221 | + |
| 222 | +describe('list associations', () => { |
| 223 | + it('should return all') |
| 224 | + it('should return empty array') |
| 225 | + it('should include user/label details') |
| 226 | +}) |
| 227 | +``` |
| 228 | + |
| 229 | +--- |
| 230 | + |
| 231 | +## Acceptance Criteria |
| 232 | + |
| 233 | +### Phase 2 Complete When: |
| 234 | +- ✅ All unit tests passing |
| 235 | +- ✅ Coverage goals met: |
| 236 | + - Labels: 90%+ |
| 237 | + - Checklists: 85%+ |
| 238 | + - Comments: 85%+ |
| 239 | + - Assignees: 90%+ |
| 240 | +- ✅ Complex queries tested (joins, counts) |
| 241 | +- ✅ Duplicate prevention validated |
| 242 | +- ✅ Cascading behaviors verified |
| 243 | +- ✅ No test flakiness |
| 244 | + |
| 245 | +--- |
| 246 | + |
| 247 | +## Expected Deliverables |
| 248 | + |
| 249 | +### Test Files (8 new files) |
| 250 | +1. `api/src/__test__/label.test.ts` |
| 251 | +2. `api/src/__test__/label.integration.test.ts` |
| 252 | +3. `api/src/__test__/checklist.test.ts` |
| 253 | +4. `api/src/__test__/checklist.integration.test.ts` |
| 254 | +5. `api/src/__test__/comment.test.ts` |
| 255 | +6. `api/src/__test__/comment.integration.test.ts` |
| 256 | +7. `api/src/__test__/assignee.test.ts` |
| 257 | +8. `api/src/__test__/assignee.integration.test.ts` |
| 258 | + |
| 259 | +### Test Count |
| 260 | +- **Total:** 150-170 tests |
| 261 | +- **Labels:** 45-50 tests |
| 262 | +- **Checklists:** 40-45 tests |
| 263 | +- **Comments:** 40-45 tests |
| 264 | +- **Assignees:** 25-30 tests |
| 265 | + |
| 266 | +--- |
| 267 | + |
| 268 | +## Success Metrics |
| 269 | + |
| 270 | +### Quantitative |
| 271 | +- ✅ 150-170 tests created |
| 272 | +- ✅ 85%+ line coverage |
| 273 | +- ✅ 80%+ branch coverage |
| 274 | +- ✅ All tests passing |
| 275 | +- ✅ Test execution < 60s |
| 276 | + |
| 277 | +### Qualitative |
| 278 | +- ✅ Tests are maintainable |
| 279 | +- ✅ Tests document behavior |
| 280 | +- ✅ Tests catch regressions |
| 281 | +- ✅ Patterns from Phase 1 reused |
| 282 | + |
| 283 | +--- |
| 284 | + |
| 285 | +## Risks & Mitigations |
| 286 | + |
| 287 | +| Risk | Impact | Likelihood | Mitigation | |
| 288 | +|------|--------|------------|------------| |
| 289 | +| Complex threading logic (Comments) | Medium | Medium | Start simple, add complexity gradually | |
| 290 | +| Progress calculation bugs (Checklists) | Low | Medium | Test edge cases (0%, 100%, partial) | |
| 291 | +| Join query complexity | Medium | Low | Mock joins, test separately | |
| 292 | +| Test execution time | Low | Medium | Run in parallel where possible | |
| 293 | + |
| 294 | +--- |
| 295 | + |
| 296 | +## Time Breakdown |
| 297 | + |
| 298 | +| Module | Estimated Time | |
| 299 | +|--------|----------------| |
| 300 | +| **Labels** | 1.5-2 days | |
| 301 | +| - Unit tests (45 tests) | 6-8 hours | |
| 302 | +| - Integration blueprints | 2-3 hours | |
| 303 | +| **Assignees** | 1 day | |
| 304 | +| - Unit tests (25 tests) | 4-5 hours | |
| 305 | +| - Integration blueprints | 1-2 hours | |
| 306 | +| **Checklists** | 1.5 days | |
| 307 | +| - Unit tests (40 tests) | 6-7 hours | |
| 308 | +| - Integration blueprints | 2 hours | |
| 309 | +| **Comments** | 1.5-2 days | |
| 310 | +| - Unit tests (40 tests) | 6-8 hours | |
| 311 | +| - Integration blueprints | 2-3 hours | |
| 312 | +| **TOTAL** | 5-6.5 days | |
| 313 | + |
| 314 | +--- |
| 315 | + |
| 316 | +## Next Steps |
| 317 | + |
| 318 | +1. Create `phase-2.md` plan document ✅ |
| 319 | +2. Rename to `phase-2-wip.md` when starting |
| 320 | +3. Begin with Labels tests |
| 321 | +4. Follow with Assignees |
| 322 | +5. Then Checklists |
| 323 | +6. Finish with Comments |
| 324 | +7. Mark as `phase-2-done.md` when complete |
| 325 | + |
| 326 | +--- |
| 327 | + |
| 328 | +**Status:** ✅ Phase 2 Planned - Ready to Begin |
| 329 | +**Next:** Rename to `phase-2-wip.md` and start Labels tests |
0 commit comments