# Test — DetectionClasses (Load, Hotkeys, Click, Fallback) **Task**: AZ-472_test_detection_classes **Name**: DetectionClasses load + 1-9 hotkeys + click path + empty/5xx fallback **Description**: Implement the 4 blackbox tests pinning `` behavior: load from `/api/annotations/classes`, hotkey 1-9 → `classes[(key-1) + P]` (P = current PhotoMode offset), click-to-select path, and the fallback list when the API is empty or 5xx. **Complexity**: 3 points **Dependencies**: AZ-456_test_infrastructure **Component**: 06_annotations (DetectionClasses) + 11_class-colors (Blackbox Tests) **Tracker**: AZ-472 **Epic**: AZ-455 ## Problem `` is keyboard-driven during annotation; the hotkey-to-class mapping changes with PhotoMode (offset P). Wrong P leaks the wrong class number on save — a quality regression hard to spot without explicit hotkey tests. ## Outcome - 4 scenarios pass — load contract, hotkey arithmetic, click selection, fallback robustness. ## Scope ### Included | Scenario | Profile | Source file | |----------|---------|-------------| | FT-P-44 — DetectionClasses loads from `/api/annotations/classes` | fast + e2e | blackbox-tests.md | | FT-P-45 — class hotkey 1–9 selects `classes[(key-1) + P]` | fast | blackbox-tests.md | | FT-P-46 — class click path | fast | blackbox-tests.md | | FT-P-47 — fallback class list on API empty/5xx | fast | blackbox-tests.md | ### Excluded - PhotoMode switching itself (covered in 18_test_photo_mode). - Class CRUD via Admin (out of scope; per-feature task in Phase B). ## Acceptance Criteria **AC-1: Load contract** FT-P-44 — outbound URL is `/api/annotations/classes`; response shape matches `seed_classes` (per the contract). **AC-2: Hotkey arithmetic** FT-P-45 — for each PhotoMode P ∈ {0, 20, 40}, pressing keys 1..9 selects the corresponding class from the appropriate window of 9. **AC-3: Click** FT-P-46 — clicking a class entry selects that class; outbound annotation save (if any) carries the right classId. **AC-4: Fallback** FT-P-47 — when `/api/annotations/classes` returns 200 with `[]` or any 5xx, the fallback class list is rendered; tests assert the fallback length and a marker indicating fallback mode. ## System Under Test Boundary - System under test: `` + `` (read-only here). - Allowed stubs: MSW for `/api/annotations/classes`. - Disallowed: stubbing `` or reading its React state. - Expected observables per `results_report.md` rows 73-77 (Group 16). ## Constraints - `seed_classes` MUST satisfy N≥9 (per test-data.md) so all hotkeys 1..9 are hot in P=0.