From 2c68621f269cd9633bd90c8e487f9727e1539753 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Sun, 21 Jun 2026 00:37:43 +0200 Subject: [PATCH] docs: aggiungi temp.md con TODO per completamento suite di test --- temp.md | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 temp.md diff --git a/temp.md b/temp.md new file mode 100644 index 0000000..9d5bee7 --- /dev/null +++ b/temp.md @@ -0,0 +1,108 @@ +# TODO — completamento suite di test + +Checkpoint: branch `test-suite-repair`, commit `bf9a6f8`. + +## Contesto + +La suite era allineata a una **vecchia forma dello stato** (`sp.punt` / `sp.set` / +`sp.servHome`) e a una **vecchia architettura e2e** (controller su `:3001`). +Baseline iniziale: **77/170 test Vitest falliti**, **tutti gli e2e rotti**. + +Nel commit `bf9a6f8`: +- Vitest riportato a **212/212 verde** (verificato con `npx vitest run`). +- e2e migrati **parzialmente** (porte + viewport + reset→config), **NON verificati verdi**. + +--- + +## ✅ Fatto (verificato) + +- `tests/unit/gameState.test.js` — riscritto con helper che derivano + punteggio/set/servizio dalla striscia; aggiunto blocco `formInizio`. +- `src/server-utils.js` — `getNetworkIPs(nets)` con interfacce iniettabili + + `printServerInfo(port, ips)` con IP iniettabili (deterministico anche su WSL); + filtro LAN unificato (esclude `127.` / `169.254.` / `172.`). Test riscritto. +- `tests/integration/websocket.test.js` + `tests/stress/websocket-load.test.js` + — punteggio letto via `punteggio(striscia)`. +- `tests/component/ControllerPage.test.js` + `DisplayPage.test.js` — forzato + layout mobile (viewport portrait), punteggi via striscia; aggiunto test REFERTO. +- Nuovi unit/integration: `referto.test.js`, `persist.test.js` (mock `fs`), + `wsMixin.test.js`, `integration/server.test.js` (routing). +- `src/referto.js` — estratta `buildRefertoHtml(state, now)` pura; `generaReferto` + resta wrapper con `window.open`/`print`. +- `server.js` — estratti `createApp()` / `startServer()`; avvio solo se entrypoint. + +--- + +## ⚠️ Da finire / verificare — e2e Playwright + +Gli e2e NON sono stati eseguiti fino a verde (run lenti). Punto di ripartenza. + +### Fix già applicati nei 6 spec +1. `:3001` → `:3000/controller`. +2. `setViewportSize({ width: 390, height: 844 })` prima di ogni `goto` controller + (su desktop renderizza la dashboard landscape `.e-dash`, ma i test cercano il + markup mobile `.team-score` / `.team-pts` / `.btn-set`). +3. Il reset ora chiude il dialog di configurazione che `doReset()` apre in automatico. +4. `game-simulation`: a 25 gestito il modal automatico "SET VINTO" con + "VAI AL SET SUCCESSIVO". + +### Da verificare / probabili fix residui + +- [ ] **`full-match.spec.cjs`** — RISCHIO ALTO. I test arrivano a 25/15 → scatta + il modal automatico (`squadraVincente`). Le asserzioni che cliccano + `.btn-set` o `.team-score` DOPO i 25 punti vengono bloccate dall'overlay del + modal. Da rivedere il flusso (usare i bottoni del modal). +- [ ] **`game-simulation.spec.cjs`** — verificare il nuovo finale col modal. +- [ ] **`game-operations.spec.cjs`** — verificare flusso cambi/toggle/config dopo + `resetGame` (config ora chiuso). +- [ ] **`basic-flow.spec.cjs`** — probabile OK, confermare. +- [ ] **`accessibility.spec.cjs`** — rieseguire axe sul markup attuale. +- [ ] **`visual-regression.spec.cjs`** — FALLIRÀ: snapshot baseline della vecchia + UI. Rigenerare con `npm run test:e2e -- --update-snapshots` DOPO aver + sistemato il resto. + +### Note importanti +- Stato e2e **condiviso e persistente** (`.segnapunti/state.json`): i test + dipendono dall'ordine e dal reset. Partire da stato pulito. +- I 3 progetti Playwright (chromium, firefox, Mobile Chrome) girano in serie + (`workers: 1`). + +--- + +## ⬜ Non ancora iniziato + +- [ ] **`tests/e2e/referto.spec.cjs`** (nuovo) — portare una partita 2/3 a fine + match, intercettare il popup con `page.waitForEvent('popup')` dopo il click + su REFERTO, verificare nomi squadre + punteggi. Stubbare `window.print` + (via `addInitScript`) perché può bloccare. +- [ ] **Documentazione**: + - `README.md` — sezione Controller: aggiungere il referto (PARTITA FINITA → + referto stampabile/PDF, prototipo). Sezione Test: aggiungere `test:ui`. + - `CLAUDE.md` — aggiungere `src/referto.js` (`buildRefertoHtml` + `generaReferto`), + menzionare `wsMixin.js` / `persist.js` / `server-utils.js`; nota su `formInizio`. + - `tests/README.md` — correggere i conteggi obsoleti ("159 passed (159)", + "6 files"); aggiungere referto / persist / wsMixin / routing server / spec + referto. + +--- + +## Comandi utili + +```bash +# Vitest (deve restare verde: 212/212) +npx vitest run + +# e2e — partire da stato pulito + server attivo +rm -f .segnapunti/state.json +npm run serve # in un terminale a parte + +# e2e mirati (chromium, dai più rischiosi) +npx playwright test --config=playwright.config.cjs --project=chromium tests/e2e/full-match.spec.cjs +npx playwright test --config=playwright.config.cjs --project=chromium tests/e2e/game-simulation.spec.cjs + +# rigenerare gli snapshot visual DOPO aver sistemato la UI dei test +npm run test:e2e -- --update-snapshots + +# suite e2e completa (3 browser, lenta) +npm run test:e2e +```