Repository navigation
Play page: the fleet in the first frame, and end-to-end tests - #17
Merged
Merged
Conversation
The ships were drawn by the game's script, which comes a round trip after the page whenever it isn't cached (a first visit, or any visit after a release). From the home page, the page showed at 0.25 s and the ships at 0.42 s. Now the page's own inline script draws the fleet (saved or random), fills in the dock and enables Start before the first paint; game.ts takes that fleet over as it is. A press of Start before game.ts is in is noted and acted on once it is. The placed tick (✓) in the dock is now drawn with a mask: Newsreader has no ✓, and finding one among the system's fonts cost a 50 ms layout (slow phone) in the first frame. End-to-end tests (site/e2e, Playwright): the site, placing, whole games, the heat map, resigning mid-move, the no-worker fallback, a forced win, an engine that fails to load, and the offline file from disk, in Chromium, WebKit, Firefox and a phone. CI runs them after the build.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
On CI's WebKit the page took over a second to come up, so the script was in before Start was pressed and the test checked nothing. Now the script waits for the test, so the press always comes first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why the ships came in late
The game's script (
game.ts) drew the ships. It arrives a round trip after the page whenever it isn't cached: on a first visit, or on any visit after a release changes its file name. Coming from the homepage, the page showed at 0.25 s and the ships popped in at 0.42 s. The ship list ("Not placed"), the count ("0 of 5 placed") and the Start button changed at the same moment.What changes
Game.astro, placed after the dock, runs before the first paint. It draws the saved fleet, or a random one with the same uniform draw asgame.ts. It also fills in the ship list and count, and enables Start.game.tstakes that fleet over as it is (from#home'sdata-fleet), so nothing is redrawn or animated in again.game.tsstarts the battle once the engine is in.currentColor, and ✓ is dropped from the font's declared character range. The font files are byte-identical, so their cache entries survive.Measured
Headless Chromium, slow-4G-like network, 4× CPU throttle, median of 9 runs:
/play, before/play, afterEnd-to-end tests (
site/e2e, Playwright 1.65.1)npm run test:e2eruns after a build. A small static server (e2e/serve.mjs) servesdistas Vercel does. The suite runs in Chromium, WebKit, Firefox and a phone (iPhone 15). Every test fails if the page throws or logs an error. CI runs the suite in the website job and uploads traces when it fails.What it covers:
It already caught one bug in this PR: the early Start press was handled before the engine's callback was registered, so the press was silently lost. Fixed.
Checks
cargo fmt --check,cargo clippy -D warnings: clean.cargo test: 61 passed.npm run check: 0 errors, 0 warnings, 0 hints.npm run build: builds.npm run test:e2e, locally on Chromium, WebKit and the phone, three repeats: 159 passed, 3 skipped (the keyboard test on the phone).