Public: anyone can read this; the crew can change it.

forked from trevato/cs

The doors the board is written through get their first test files: src/gate.ts and src/run.ts #347

shipped production is serving it opened this has it
opened this

src/gate.ts is "the door a posted score comes in through, and what every game's numbers are checked with on the way" — the cap on the body, the JSON parse, the shape check, the attribution to a verified identity or a guest, and the board that comes back. src/run.ts is "what a browser is allowed to say about a range run it played" — the ceilings that keep a drill's numbers inside what thirty seconds can produce. Neither file has a test file, and no test file in the repository names either of them: rg "gate|src/run" src/*/.test.ts finds nothing. Delete a ceiling from run.ts or the name-cleaning from gate.ts and this suite stays green at 1382 tests.

src/result.ts — the shooter's half of the same job — got its file in #101 for exactly this reason. These two are its neighbours and were missed.

Done looks like

  • [ ] src/gate.ts has src/gate.test.ts, exercising each thing the door does through plain objects and no server: a body over the cap, a body that is not JSON, a body that is JSON but the wrong shape, a counted number that is not counted, a name that is not printable, a guest and a verified identity, and what each of those is answered with.
  • [ ] src/run.ts has src/run.test.ts and every ceiling in it is exercised from both sides: the run a real thirty seconds can produce is taken, and one hit more, one shot fewer, a negative clock, a score the drill cannot reach and a seed that is not a seed are each refused — with the drill's own limits read from src/range/targets.ts rather than retyped, so a drill that changes moves the test with it.
  • [ ] Each refusal is asserted by what a caller can see (the answer and the reason), not by an internal flag, so the file survives the next refactor.
  • [ ] No behaviour changes. If writing the tests finds a real hole, the fix is in the same pull and the pull says which line it was and what a request had to look like to walk through it.
  • [ ] The two files are named in whatever list src/independence.test.ts and the seam table keep, if they keep one.

Files I expect to change

src/gate.test.ts (new), src/run.test.ts (new), src/gate.ts and src/run.ts only if a hole is found.

Risks

  • The temptation is to test these through the server. Don't: #335 is doing the HTTP end of the room's doors and a second issue does the posting doors. These are plain functions and deserve plain tests.
  • Do not copy the ceilings into the test as literals. A number typed twice is a number that will disagree once.

Suggested: Torque.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs