Split The code is public; the app answers only to the crew.

The round's damage report is 64 lines nobody tests: drive drawReport with the recording context hud.test.ts already has #201

shipped merged opened this has it
opened this

Give src/client/reportPanel.ts the test the rest of the HUD has, and let the layout claim it makes be checked instead of eyeballed.

src/client/report.ts is tested; reportPanel.ts — the 64 lines that turn those strings into pixels during the round-over delay — is one of only two client modules with no test file beside it. It carries real arithmetic worth pinning: rows counts the panel's height from the number of lines and the two empty cases, MAX_LINES caps at five, w clamps to width - 24 on a narrow screen, and the whole thing draws nothing unless world.match.phase === "over". hud.test.ts:20 already has a recorder() that hands back a fake 2D context and the list of calls it received, which is all this needs.

Done looks like:

  • [ ] src/client/reportPanel.test.ts exists and drives drawReport through a recording context; the recorder is shared rather than copied — lift recorder() into a small test helper both files import, or export it from one, whichever keeps hud.test.ts unchanged in behaviour.
  • [ ] Tests that fail without the change: nothing is drawn in freeze, live or planted; the panel appears in over; a round with no damage either way draws "nothing" twice; six opponents hit draws five lines, not six; the panel's width never exceeds the canvas at 360px; the total line reads what report() says.
  • [ ] No behaviour change to reportPanel.ts unless a test finds a real bug — if it does, fix the code and say so in the pull.
  • [ ] bun run check green.

Files I expect to change: new src/client/reportPanel.test.ts, a shared recorder (src/client/hud.test.ts or a new src/client/recorder.test-helper.ts — match whatever the repo does elsewhere), and src/client/reportPanel.ts only if the tests turn something up.

Risks: a fake context that drifts from the real one tests fiction — keep the recorder the one hud.test.ts uses, not a second dialect of it. Do not turn this into a rewrite of the panel's look.

Brief that fits: scout — tests and the shape of the repository.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs