|
57 | 57 | - `frontend/docs/TEST_FAILURE_ANALYSIS.md`: Categorized frontend failures with fix priorities |
58 | 58 |
|
59 | 59 | ### Known Issues |
| 60 | +- **E2E Tests SKIPPED**: Critical E2E tests exist but are disabled |
| 61 | + - `frontend/src/e2e/complete-authoring-journey.spec.ts` - SKIPPED (line 47: "PARTIALLY IMPLEMENTED") |
| 62 | + - `frontend/tests/e2e/deployment/02-user-journey.spec.ts` - TOC workflow tests exist but need to be enabled |
| 63 | + - **ACTION REQUIRED**: Enable E2E tests and fix any failures before deployment (bd task auto-author-56) |
60 | 64 | - **Frontend Tests**: 75 failures due to missing mocks (Next.js router, ResizeObserver, module imports) |
61 | 65 | - Fix time: 3.5-5.5 hours across 4 phases |
62 | 66 | - All failures are environmental setup issues, not code bugs |
63 | 67 | - **Backend Coverage**: 41% vs 85% target |
64 | 68 | - Critical gaps: `security.py` (18%), `book_cover_upload.py` (0%), `transcription.py` (0%) |
65 | 69 | - Path to 85%: 4-5 weeks, 207-252 new tests |
66 | 70 | - **Backend Asyncio**: 2 test failures related to event loop lifecycle |
| 71 | +- **Manual TOC Bug**: Manual tester found bug in TOC workflow - needs investigation (bd task auto-author-55) |
67 | 72 |
|
68 | 73 | ### Package Updates |
69 | 74 | - Upgraded `lucide-react` to 0.468.0 |
@@ -204,6 +209,184 @@ See `CURRENT_SPRINT.md` for active tasks or run `bd ready` for unblocked work. |
204 | 209 |
|
205 | 210 | --- |
206 | 211 |
|
| 212 | +## 🔒 MANDATORY: TDD & E2E Test Enforcement |
| 213 | + |
| 214 | +**CRITICAL**: This project REQUIRES Test-Driven Development and E2E test coverage for ALL features. No feature is complete without proper test coverage. |
| 215 | + |
| 216 | +### Pre-Commit Hook Requirements |
| 217 | + |
| 218 | +**ALL commits MUST pass these gates:** |
| 219 | + |
| 220 | +1. **Unit Tests**: All unit tests must pass |
| 221 | + ```bash |
| 222 | + # Frontend |
| 223 | + cd frontend && npm test |
| 224 | + |
| 225 | + # Backend |
| 226 | + cd backend && uv run pytest tests/ |
| 227 | + ``` |
| 228 | + |
| 229 | +2. **E2E Tests**: All E2E tests must pass |
| 230 | + ```bash |
| 231 | + cd frontend && npx playwright test |
| 232 | + ``` |
| 233 | + |
| 234 | +3. **Test Coverage**: Minimum 85% coverage required |
| 235 | + ```bash |
| 236 | + # Frontend |
| 237 | + cd frontend && npm test -- --coverage --coverageThreshold='{"global":{"lines":85}}' |
| 238 | + |
| 239 | + # Backend |
| 240 | + cd backend && uv run pytest --cov=app tests/ --cov-fail-under=85 |
| 241 | + ``` |
| 242 | + |
| 243 | +4. **Linting & Type Checking**: No errors allowed |
| 244 | + ```bash |
| 245 | + cd frontend && npm run lint && npm run typecheck |
| 246 | + cd backend && uv run mypy app/ |
| 247 | + ``` |
| 248 | + |
| 249 | +### Feature Branch Workflow (MANDATORY) |
| 250 | + |
| 251 | +**NEVER commit directly to `main` or `develop`. Always use feature branches:** |
| 252 | + |
| 253 | +```bash |
| 254 | +# Create feature branch |
| 255 | +git checkout -b feature/your-feature-name |
| 256 | + |
| 257 | +# Make changes and commit (pre-commit hooks will run automatically) |
| 258 | +git add . |
| 259 | +git commit -m "feat: implement your feature" |
| 260 | + |
| 261 | +# Push to remote |
| 262 | +git push -u origin feature/your-feature-name |
| 263 | + |
| 264 | +# Create Pull Request for review |
| 265 | +# PR must have: |
| 266 | +# - All tests passing |
| 267 | +# - ≥85% test coverage |
| 268 | +# - E2E test for user-facing features |
| 269 | +# - Updated documentation |
| 270 | +``` |
| 271 | + |
| 272 | +### Feature Completion Checklist (ENFORCED) |
| 273 | + |
| 274 | +**A feature is NOT complete until ALL of these are done:** |
| 275 | + |
| 276 | +- [ ] **Unit tests written** (≥85% coverage for new code) |
| 277 | +- [ ] **E2E test created** (for user-facing features) |
| 278 | +- [ ] **All tests passing** (unit + E2E) |
| 279 | +- [ ] **Documentation updated** (CLAUDE.md, API docs, user guides) |
| 280 | +- [ ] **Performance validated** (meets operation budgets) |
| 281 | +- [ ] **Accessibility verified** (WCAG 2.1 Level AA minimum) |
| 282 | +- [ ] **Code reviewed** (PR approved by team) |
| 283 | +- [ ] **bd task closed** (`bd close <task-id> --reason "Completed in PR #123"`) |
| 284 | + |
| 285 | +### E2E Test Coverage Requirements |
| 286 | + |
| 287 | +**EVERY user-facing feature MUST have an E2E test that validates:** |
| 288 | + |
| 289 | +1. **Happy Path**: Complete user journey from start to finish |
| 290 | +2. **Error Handling**: How the system handles failures |
| 291 | +3. **Performance**: Operation completes within budget |
| 292 | +4. **Accessibility**: Keyboard navigation works |
| 293 | +5. **Data Integrity**: Data persists correctly |
| 294 | + |
| 295 | +**Example - TOC Generation Feature:** |
| 296 | +```typescript |
| 297 | +// frontend/tests/e2e/toc-generation.spec.ts |
| 298 | +test('user can generate TOC from book summary', async ({ page }) => { |
| 299 | + // 1. Create book with summary |
| 300 | + // 2. Navigate to TOC wizard |
| 301 | + // 3. Answer clarifying questions |
| 302 | + // 4. Verify TOC generates within 3000ms budget |
| 303 | + // 5. Verify TOC data saves to database |
| 304 | + // 6. Verify TOC appears in book view |
| 305 | +}); |
| 306 | +``` |
| 307 | + |
| 308 | +### Pre-Commit Hook Setup |
| 309 | + |
| 310 | +**Install pre-commit hooks for this project:** |
| 311 | + |
| 312 | +```bash |
| 313 | +# Install pre-commit (if not already installed) |
| 314 | +pip install pre-commit |
| 315 | + |
| 316 | +# Install the git hook scripts |
| 317 | +pre-commit install |
| 318 | + |
| 319 | +# Test the hooks |
| 320 | +pre-commit run --all-files |
| 321 | +``` |
| 322 | + |
| 323 | +**Hook configuration** (`.pre-commit-config.yaml` in project root): |
| 324 | +```yaml |
| 325 | +repos: |
| 326 | + - repo: local |
| 327 | + hooks: |
| 328 | + - id: frontend-tests |
| 329 | + name: Frontend Unit Tests |
| 330 | + entry: bash -c 'cd frontend && npm test' |
| 331 | + language: system |
| 332 | + pass_filenames: false |
| 333 | + |
| 334 | + - id: backend-tests |
| 335 | + name: Backend Unit Tests |
| 336 | + entry: bash -c 'cd backend && uv run pytest tests/' |
| 337 | + language: system |
| 338 | + pass_filenames: false |
| 339 | + |
| 340 | + - id: e2e-tests |
| 341 | + name: E2E Tests |
| 342 | + entry: bash -c 'cd frontend && npx playwright test' |
| 343 | + language: system |
| 344 | + pass_filenames: false |
| 345 | + |
| 346 | + - id: frontend-coverage |
| 347 | + name: Frontend Coverage Check |
| 348 | + entry: bash -c 'cd frontend && npm test -- --coverage --coverageThreshold='\''{"global":{"lines":85}}'\''' |
| 349 | + language: system |
| 350 | + pass_filenames: false |
| 351 | + |
| 352 | + - id: frontend-lint |
| 353 | + name: Frontend Linting |
| 354 | + entry: bash -c 'cd frontend && npm run lint' |
| 355 | + language: system |
| 356 | + pass_filenames: false |
| 357 | +``` |
| 358 | +
|
| 359 | +### Bypassing Hooks (EMERGENCY ONLY) |
| 360 | +
|
| 361 | +**Only use `--no-verify` in TRUE emergencies:** |
| 362 | + |
| 363 | +```bash |
| 364 | +# Emergency hotfix ONLY - will require post-fix validation |
| 365 | +git commit --no-verify -m "hotfix: critical production bug" |
| 366 | +
|
| 367 | +# Then immediately: |
| 368 | +# 1. Create follow-up task to add missing tests |
| 369 | +# 2. Create PR to add proper test coverage |
| 370 | +# 3. Document why emergency bypass was needed |
| 371 | +``` |
| 372 | + |
| 373 | +### Test Quality Standards |
| 374 | + |
| 375 | +**Tests MUST be:** |
| 376 | +- **Isolated**: No dependencies on external services (use mocks) |
| 377 | +- **Repeatable**: Same result every time |
| 378 | +- **Fast**: Unit tests <1s each, E2E tests <30s each |
| 379 | +- **Meaningful**: Test behavior, not implementation |
| 380 | +- **Maintainable**: Clear, well-documented test code |
| 381 | + |
| 382 | +**Tests MUST NOT:** |
| 383 | +- Use arbitrary timeouts (`await page.waitForTimeout(5000)` ❌) |
| 384 | +- Depend on test execution order |
| 385 | +- Leave side effects (data, files, processes) |
| 386 | +- Test internal implementation details |
| 387 | + |
| 388 | +--- |
| 389 | + |
207 | 390 | ## 🚀 Available Agents (54 Total) |
208 | 391 |
|
209 | 392 | ### Core Development |
|
0 commit comments