Repository navigation
Check the browser-free cards against Chrome weekly, on request and on a label - #352
Merged
Merged
Conversation
Contributor
|
Preview: https://2b227b5f.nstarkman-space.pages.dev Built from |
nstarman
force-pushed
the
add/card-layout-fuzz
branch
from
October 6, 2026 21:17
eb84c5b to
957c0f8
Compare
… a label tests/cardlayout.differential.test.js has fast-check generate a width, a title, text, a role and a subset of a package's buttons with labels, lays each card out in Chrome (the real card CSS, on the real embed page) and with cardlayout.js, and compares them; a difference is shrunk to the smallest card that shows it. It needs a browser and the dev server, so it only runs when CARD_FUZZ is set (npx vitest run tests/cardlayout.differential.test.js). .github/workflows/card-layout-fuzz.yml runs it on Mondays, from Actions with a number of cards and an optional seed and path to replay a failure, and when a pull request is given the fuzz-cards label (taken off again after, so adding it again runs it again). A failure is in the step summary and kept as an artifact. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
nstarman
force-pushed
the
add/card-layout-fuzz
branch
from
October 6, 2026 21:23
957c0f8 to
f569827
Compare
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.
Changing code or schema
What and why: #345 draws the README's software cards without a browser, as a second implementation of the card CSS. Its tests hold it to a recording of Chrome and to properties that must hold of any card — but the equivalence needs an oracle, and the oracle is Chrome. This asks Chrome, about cards nobody recorded.
tests/cardlayout.differential.test.js: fast-check generates a package, a width (160–900 px), a theme, a title, text, a role, a subset of its buttons and their labels; each card is laid out by the real card CSS in Chrome (the embed page, edited the same way) and bycardlayout.js, and compared op by op. A difference is shrunk to the smallest card that shows it, with a seed and path to replay (FC_SEED,FC_PATH). Skipped unlessCARD_FUZZis set, sonpm testis unchanged..github/workflows/card-layout-fuzz.ymlruns it:fuzz-cardsto a pull request runs it (300 cards), and the workflow takes the label off again when it ends so adding it again runs it again.A failure is in the step summary and kept as an artifact (
fuzz-report). It runs on the dev server (the test imports the site's modules into the page), with Chromium fromplaywright(a new dev dependency; the recorder script uses it too).fuzz-cardslabel (repo ▸ Labels) so it can be added.What running it found, so far (all fixed in #345, now merged, each with a unit test): a button is never under 24 px; a title breaks anywhere (
overflow-wrap); a card with no buttons has no box for them; HarfBuzz instead of opentype.js for text widths; Chrome measures at the font size floored to a hundredth of a px; three Plex Sans kerning pairs (jT, jV, jW) that HarfBuzz-for-JS misses; a labelled button is as wide as its content; the buttons' box leaves 0.8em less to wrap in; lengths are laid out in 1/64 px and a button's list item can be taller than the button; where Chrome breaks lines (after a hyphen before anything, an en dash, an ellipsis, a question mark); line height and half-leading, which turned out to be one rule once fitted to Chrome at 3,000 font sizes (the size to the nearest 1/64 px, the product down to a 64th, the half-leading halved in 64ths toward zero): after it, 500 generated cards in a row agreed with Chrome.npm run test:schemapasses; unit tests and the build pass (the fuzz is skipped withoutCARD_FUZZ); the workflow parses as YAML — its first real run is on this PR once the label is added🤖 Generated with Claude Code