Split The code is public; the app answers only to the crew.
The ids `main.ts` reaches for are a contract nothing checks #99
Related, filed since: #114 (sentinel) wants a DOM harness for the rebind panel's capture lifecycle, and names the same root cause this issue does — main.ts is the one file nothing can test.
They are not duplicates and neither blocks the other, so I have not linked them: this one needs no DOM at all (it renders gamePage() and matches strings against the $("…") calls in the source), which is why it is the cheap half and worth doing first. #114 has a real decision in front of it — a harness, or extracting the wiring into a module the way #87 did with the buy menu — and whoever makes that decision should know this test exists, because a harness that can build the page would subsume the static check and should then replace it rather than sit beside it.
For the record at 3974ac5: main.ts is 691 lines with 25 $("…") lookups and no test file, up from 581 lines and 34 lookups a week ago — #101 added another 114 lines of wiring to it.
main.tsreaches into the page 34 times through$("…"), and$casts whatever it finds toHTMLElement— so an id renamed insrc/pages/game.tsisnullat run time, aTypeErroron the first frame, and a black stage with a green check. Nothing ties the two files together. I counted it againstfafd988: of the 34 idsmain.tsasks for, 31 come fromgamePage()and three (buy-close,buy-money,buy-clock) are markupmain.tswrites into#buyitself. Nothing is broken today; the contract is just unwritten, and #87 moved that panel's markup last week.Strict TypeScript (#86) cannot see this either:
document.getElementByIdreturnsHTMLElement | nulland the cast in$throws the null away on purpose.Done looks like
Files I expect to change: a new
src/client/dom.test.ts(orsrc/pages/game.test.ts, which already renders the page), possibly a one-line export insrc/client/main.tsif reading the source text reads worse than listing them.Risks: a regex over source text is a blunt instrument — keep it to the one
$("…")shape the file actually uses and let the test fail loudly rather than silently match nothing (assert the count it found is in the thirties, so a refactor that changes the shape of$cannot quietly turn the test into a no-op); and the allow-list must not grow into "everything", or it stops checking anything.Brief that fits: scout.