mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-05-25 02:05:46 +00:00
c24ae4b617
## Summary Adds Playwright E2E coverage for the **B1 audio batch** per umbrella issue #1297. Targets the audio frontend trio that previously had near-zero browser-side coverage: `public/audio.js`, `public/audio-v1-constellation.js`, `public/audio-lab.js` (562 LOC, 4.2% prior coverage). ## What's added | Suite | Covers | Scenarios | |---|---|---| | `test-audio-live-1297-e2e.js` | `audio.js` + `audio-v1-constellation.js` via `/#/live` | 16 | | `test-audio-lab-1297-e2e.js` | `audio-lab.js` via `/#/audio-lab` | 15 | Both suites stub `AudioContext` via `page.addInitScript` so headless Chromium can verify oscillator scheduling / voice playback paths without real audio hardware — covers the `voice.play()` ADSR chain for ADVERT/GRP_TXT/TXT_MSG/TRACE and the `UNKNOWN`/default branches. ### `test-audio-live-1297-e2e.js` - MeshAudio API surface (14 keys) - `constellation` voice auto-registration - `#liveAudioToggle` ↔ `#audioControls` show/hide round trip - BPM slider → `#audioBpmVal` text + `MeshAudio.getBPM()` + localStorage - Volume slider → `#audioVolVal` + `MeshAudio.getVolume()` + localStorage - Voice select population - Helpers: `buildScale`, `midiToFreq(69)≈440`, `mapRange`, `quantizeToScale` - `sonifyPacket()` exercises `parsePacketBytes` + `voice.play` (asserts oscillator count increments) across 5 packet types - localStorage persistence for `live-audio-enabled` / `bpm` / `volume` ### `test-audio-lab-1297-e2e.js` - `/api/audio-lab/buckets` is intercepted with deterministic fixture data (3 packet types, 4 packets) so coverage doesn't depend on CI's packet mix - Sidebar populated, packet selection (`.alab-pkt.selected`) - `renderDetail` + `computeMapping`: hex panel, note table (≥2 rows), byte viz bars (≥3 bars), map table - Type header click toggles list `display:none` ↔ visible - BPM / Vol slider handlers - Speed buttons (active class swap) - Loop button toggle on/off - Play button → `MeshAudio.sonifyPacket` (oscillator count↑) - Note-row click → `playOneNote` (oscillator count↑) - `destroy()` removes sidebar + injected stylesheet on navigation away ## Coverage estimate (per-file) Measured locally (assertion counts, not nyc — that runs in CI): | File | Before | After (estimated) | Notes | |---|---|---|---| | `public/audio.js` | ~low | **≥70%** | All public API methods + helpers + sonifyPacket path exercised | | `public/audio-v1-constellation.js` | ~0% | **≥60%** | `play()` invoked across 5 type branches | | `public/audio-lab.js` | 4.2% | **≥55%** | `init`, `renderDetail`, `computeMapping`, `playOneNote`, `playSelected`, `destroy`, all slider/button handlers | Actual coverage will be confirmed by the `Generate frontend coverage badges` step in CI on this PR. ## TDD exemption These are **net-new UI coverage** suites — there are no prior assertions to break, and no production behavior is changing. Per `AGENTS.md` TDD rules: > Net-new UI surfaces (no prior assertions to break): test must land in the > SAME PR but doesn't need to be the FIRST commit. Single commit; no red→green choreography possible because the assertions exercise already-shipped behavior. Suites are designed to FAIL loudly if the audio engine or audio-lab page regresses (e.g. if `#audioBpmVal` stops updating, or `voice.play` stops scheduling oscillators). ## Workflow hookup Appended to the existing `playwright-tests` step in `.github/workflows/deploy.yml`: ```yaml CHROMIUM_REQUIRE=1 BASE_URL=http://localhost:13581 node test-audio-live-1297-e2e.js ... CHROMIUM_REQUIRE=1 BASE_URL=http://localhost:13581 node test-audio-lab-1297-e2e.js ... ``` Both run with `CHROMIUM_REQUIRE=1` — missing Chromium is a hard fail in CI (per the project convention shared with `test-bottom-nav-1061-e2e.js` et al). ## Local verification ``` 16 passed, 0 failed (test-audio-live-1297-e2e.js) 15 passed, 0 failed (test-audio-lab-1297-e2e.js) ``` Run against a local `/tmp/cov-b1-server -port 13591 -db <fixture>` instance with `test-fixtures/e2e-fixture.db`. Refs #1297 Co-authored-by: clawbot <bot@kpa-clawbot>