# 10 — Testing ## Piramida tes ``` ┌─────────────┐ │ agent_test │ E2E (butuh model, lambat) ├─────────────┤ │ extractor │ Integrasi LLM ├─────────────┤ │ generator │ Unit — cepat, tanpa model └─────────────┘ ``` ## Menjalankan ```bash # Dari root repo, venv aktif python tests/test_generator.py # jalankan dulu — cepat python tests/test_extractor.py # butuh GGUF python tests/agent_test.py # pipeline penuh ``` Exit code `0` = semua lulus. --- ## `tests/test_generator.py` **Tanpa model.** Memakai mock JSON. ### Kasus | ID | Nama | Cek | |----|------|-----| | GEN001 | Full entity set | Semua nama di SVG, SVG valid | | GEN002 | Minimal kosong | Empty map, tidak crash | | GEN003 | All moods | 5 mood generate tanpa error | ### Validasi SVG - Dimulai dengan `` - Len > 200 byte - Nama character/place muncul di string --- ## `tests/test_extractor.py` **Butuh model loaded.** ### Kasus | ID | Input | Harapan | |----|-------|---------| | TC001 | Narasi standar | ≥1 character, ≥1 place, mood valid | | TC002 | Mimpi pendek | Field wajib, array boleh kosong | | TC003 | Emosional kompleks | characters + places + connections | ### Field wajib per kasus Lihat definisi `TEST_CASES` di file tes. --- ## `tests/agent_test.py` 3 mimpi E2E: 1. Library dengan wajah di cover buku 2. Gigi tanggal di pesta 3. Pilot pesawat awan hijau Assert: - `mood` dan `title` ada - SVG valid, len > 300 --- ## Fixture: mimpi uji manual File: `tests/fixtures/mimpi_uji.txt` Format: satu mimpi per blok, dipisah `---` Digunakan untuk: - Iterasi prompt (target 85%) - Regresi sebelum push Space ### 10 mimpi disarankan 3 dari `gr.Examples` (forest, underwater office, city of books) + 7 variasi: - flying / falling - teeth / chase - childhood home - water / fire symbol - minimal abstract - anxiety-heavy - joyful reunion --- ## Tes manual UX (Day 3) | Pertanyaan | Pass? | |------------|-------| | User tahu harus mengetik mimpi? | | | User paham tombol submit? | | | User bereaksi positif pada peta? | | Catat 3 bullet di issue atau `docs/ux-notes.md`. --- ## Tes Space (pre-submit) - [ ] Build log hijau - [ ] Status **Running** - [ ] Example 1 anxious → map <60s - [ ] Error input pendek → pesan ramah - [ ] Disclaimer privasi terlihat --- ## CI (opsional stretch) GitHub Action hanya `test_generator.py` — tidak download 5GB model. ```yaml # .github/workflows/test.yml — contoh - run: python tests/test_generator.py ``` --- ## Dokumen terkait - [05 Skema JSON](05-skema-json.md) - [07 Setup lokal](07-setup-lokal.md) - [13 Timeline](13-timeline-hackathon.md)