diff --git a/docs/output.md b/docs/output.md index 4c5d992..fb18b49 100644 --- a/docs/output.md +++ b/docs/output.md @@ -61,6 +61,7 @@ the per-shot output when piped, `--no-progress` the summary on a terminal. | `1 accepted` | That many of the shot's changes are accepted; the rest are new. | | `findings: N repeated on 2+ routes` | After the routes: the same `dom` entry, text line, `fonts` face or element-less band delta (`band -24px`) on two or more routes, once per line with `×N routes` and where (`/a@1440,375`, then `+N routes`), most widespread first, accepted ones aside. Top 20; `summary.findings` in results.json has them all. One cause behind many rows: fix it once. A selector names an element per page, so the same path may be a different element on another route: check one crop. | | `computed: N findings` | With `--computed`: each `key prop left→right` once, with the routes and widths it was seen at; `dom identical`: the markup matches apart from asset hashes and generated class names, so look at CSS or script. See [below](#computed-styles---computed). | +| `rules: N changed groups` | With `--computed`: style rules only one side has, by stylesheet and `@media`, and whether any shot had an element they could style. `matched nothing`: the run proved nothing about those rules. See [below](#rule-coverage). | | `aria: identical on N of M route(s)` | With `--aria`: routes whose accessibility tree matches at every width, then each differing route's lines, `+` left only, `-` right only. See [below](#aria-snapshots---aria). | | `crops …` | Up to 3 PNGs per comparison, bands first, relative to `results.json`. Left is on top or on the left, and the change is boxed in red. | | `ERROR …` | Unmeasured, which is neither a pass nor a fail. Exits 3. | @@ -263,6 +264,43 @@ Links and controls (`a[href]`, `button`, `input`, `select`, `textarea`, `summary (`ul:has(a:hover) a:not(:hover)`) isn't seen, nor `:hover` on an ancestor (`li:hover` menus), `:active`, `:focus-within` or script hover handlers. +### Rule coverage + +A clean run doesn't show that a changed rule ever applied. So `--computed` also reads every +style rule in each side's stylesheets and lists the groups of rules only one side has: + +``` +rules: 3 changed groups, 1 never matched, 2 matched on some shots + +chat.css (1 rule) matched nothing: /help@1440,375 + +docs.css @media (width >= 60em) (5 rules) matched /a@960,1440 /b@960; nothing /a@959,375 + -docs.css @media (min-width: 60em) (5 rules) matched /a@960,1440 /b@960; nothing /a@959,375 +``` + +- A rule is its enclosing at-rules, selector (nesting resolved) and declarations, as Chrome + serializes them. So pure notation changes Chrome normalizes (`rgb(0 0 0)` and + `rgb(0, 0, 0)`) are no change, while `min-width:` against `width >=` is. Asset hashes in + `url()` and the left origin are read as on the other side. A rule moved to another file is + no change. Only style rules count: not `@font-face`, `@keyframes` or `@property`. +- `+` rules only the left (your change) has, `-` only the right. A group is a stylesheet's file + name (asset hash as `#`; a ` + + +
+

Rule coverage guard rail

+

The two sides write one breakpoint in different notation and render the same, so only rule coverage tells the rewritten rule apart, and whether any shot reached it.

+ + + +
+

Notes

+

At 960 the breakpoint holds and its rule styles three items; at 959 it styles none. A rule for an element no page has matches nothing on any shot.

+
+
+ + diff --git a/tests/fixtures/pages/rules/right.html b/tests/fixtures/pages/rules/right.html new file mode 100644 index 0000000..832e4ee --- /dev/null +++ b/tests/fixtures/pages/rules/right.html @@ -0,0 +1,32 @@ + + + + +Rule coverage + + + + +
+

Rule coverage guard rail

+

The two sides write one breakpoint in different notation and render the same, so only rule coverage tells the rewritten rule apart, and whether any shot reached it.

+ + + +
+

Notes

+

At 960 the breakpoint holds and its rule styles three items; at 959 it styles none. A rule for an element no page has matches nothing on any shot.

+
+
+ + diff --git a/tests/helpers/corpus.ts b/tests/helpers/corpus.ts index f822c5a..c5e4fb1 100644 --- a/tests/helpers/corpus.ts +++ b/tests/helpers/corpus.ts @@ -68,6 +68,7 @@ export const GUARDRAILS = [ "offcanvas", "appshell", "smooth-scroll", + "rules", ] as const; export const ALL: string[] = [...EQUIVALENCE, ...CONTROLS, ...GUARDRAILS]; diff --git a/tests/helpers/parse.ts b/tests/helpers/parse.ts index d17fc8e..3137cad 100644 --- a/tests/helpers/parse.ts +++ b/tests/helpers/parse.ts @@ -49,6 +49,8 @@ export interface Summary { accepted: string[]; /** `route@width` of each stale accepted difference, from the `stale accepted:` line. */ stale: string[]; + /** With `--computed`: the `rules:` line and the group lines under it; empty without one. */ + rules: string[]; /** The `rerun:` line of a `--rerun-failed` run, else null. */ rerun: { shots: number; routes: number; reused: number; untouched: number } | null; /** Each differing route: widths that were clean or accepted, then one row per collapsed width group. */ @@ -138,6 +140,7 @@ export function parseSummary(stdout: string): Summary { clean: listed("clean"), accepted: listed("accepted"), stale, + rules: /^rules: .*(?:\n .*)*/m.exec(stdout)?.[0].split("\n") ?? [], rerun: rerun && { shots: Number(rerun[1]), routes: Number(rerun[2]), diff --git a/tests/visual/guardrails.test.ts b/tests/visual/guardrails.test.ts index 8c84920..ed753e6 100644 --- a/tests/visual/guardrails.test.ts +++ b/tests/visual/guardrails.test.ts @@ -337,6 +337,51 @@ describe("consent chrome", () => { }); }); +test("--computed shows whether a rewritten breakpoint, and a rule nothing has, ever applied", async () => { + const run = await capture(["/rules"], { widths: [960, 959], extra: ["--computed"] }); + assert.equal(run.code, 0, context(run)); + const at = (widths: number[]) => (widths.length ? [{ url: "/rules", widths }] : []); + const group = (side: string, conditions: string[], matched: number[], unmatched: number[]) => ({ + side, + sheet: "inline#", + conditions, + rules: conditions[0] === "@media screen" ? 2 : 1, + matched: at(matched), + unmatched: at(unmatched), + }); + // Each side's