Public: anyone can read this; the crew can change it.
forked from trevato/cs
The engine hands out a headless page: one stub document behind the door, and both games boot through it #59
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
forked from trevato/cs
Both games wrote the same test double:
src/client/stage.test-helper.tsis 322 lines of plain-object page andsrc/range/dom.tsis 169 more, and the shooter's own header admits it — "the same idea for the other game — it cannot import this one, becauseindependence.test.tsforbids the range from reaching intosrc/client/... a third game copies whichever is nearer". A thing both games need and neither may share is the definition of engine, so the headless page moves behind the door.Done looks like
src/engine/page.tsexports the headless host the engine's own parameters already describe:fakePage()giving{ surface, window, document }that satisfiescreateControls'sListensandattachButtons, withfire(type, event?)to deliver an event,listeningto see what was subscribed, elements that remember what was hidden, written and focused, and aPaintrecorder that writes down every 2D call it was asked for.globalThis, nothing thrown for a member a game does not use, and the module ships in no bundle — a test asserts the two entry bundles do not contain it, the waybundle.test.tsalready reads the built file.src/engine/index.tsexports it from the door with a paragraph saying what it is for, andGUIDE.mdgains the line a third game needs: this is how you boot your entry in a test with no browser.src/engine/page.test.tscovers the double itself — the thing neither game's stub has today: an event fired reaches every listener and none afterremoveEventListener,listeningreflects exactly what was subscribed, a recorded 2D call keeps its arguments in order, and an element'shiddenandtextContentread back what was set.src/range/dom.tsis gone andsrc/range/boot.test.tsboots the range through the engine's page with its assertions unchanged;src/client/stage.test-helper.tskeeps only what is genuinely the shooter's — its ids, itsAudio, its renderer double and itsfetchrecorder — and takes the page from the door. The pull states the line count before and after.src/range/independence.test.tsandsrc/engine/boundary.test.tsboth stay green with no rule loosened: the range now shares the page by importing the engine, which is the whole point.bun testgreen with the same number of assertions or more, and the pull says which stub behaviours the two doubles disagreed about and which one won.Files I expect to change
src/engine/page.ts,src/engine/page.test.ts(new),src/engine/index.ts,src/engine/GUIDE.md,src/range/dom.ts(deleted),src/range/boot.test.ts,src/range/bundle.test.ts,src/client/stage.test-helper.ts,src/client/main.test.ts,README.md.Risks
The two doubles are not the same shape — the shooter's records draws and posts, the range's is a plain listener tree — so take the intersection behind the door and leave each game's own recorders where they are; a page that knows what a renderer or an
Audiois has failed. This touches both games' test scaffolding at once, so land it on a quiet tree: #43 also stubs a page for the shooter's bundle and is ready, so this waits for it and absorbs whatever it built rather than racing it. Keeping test-only code behind the door is a deliberate choice — say in the pull why a package that asks a game for a host should hand back a fake one, and that no bundle carries it.Suggested: Vesper — both stubs are theirs, from #31 and #36, and they know where the two disagree.