Skip to main content

Visual parity and first-row budgets

The visual-parity harness checks every redesigned apiome-ui page against its mockup in docs/mockups/. It has two checks. The parity score measures whether the page uses the same design tokens in the same places. The first-row budget measures how far down the page the first row of data starts. HIVE-10.1 (#5337) built the harness, and HIVE-13.3 (#5616) added the budget. Both run in the Apiome UI Visual Parity CI workflow, in the light and dark themes.

cd apiome-ui
yarn test:e2e:visual # every route, both themes
yarn test:e2e:visual -g catalog # one route

The harness starts its own app on port 3300. It needs no REST API and no database.

Which mockup a route is compared against​

Each route is compared against the page mockup that draws it, such as build/versions.html or sources/catalog.html. The round-2 proposals (docs/mockups/proposals/versions-status-strip.html, catalog-quiet.html, launcher-focused.html and rail-compact.html) were adopted in the quiet pass and folded into those page mockups by HIVE-13.4 (#5617). They stay in the ledger as adopted records of the change, and no route is compared against them.

When the mockup opens on another view​

Some mockups open on a different view from the one the route's fixture draws. sources/catalog.html opens on Cards, but the Catalog fixture is the table a returning reader sees. Comparing a table with cards would score the choice of view, not the page. So the route's mockupView names the mockup control to click first. Catalog uses [data-tabs="views"] [data-target="table"], and the harness then measures the mockup's own Table view.

The first-row budget​

PROPOSALS.md found that stat strips, banners and extra toolbars were pushing data below the fold. At 1440 × 900 the first row of data started 600–870 px down the page. The quiet pass (Epic 11) removed that clutter, and the budget stops it from coming back. The harness mounts each page at 1440 × 900 (comfortable density, md font scale) and reads where the page's first row of data starts:

Page kindBudgetExample
List page360 pxPublished (216 px), Catalog (352 px)
Detail page560 pxRepository detail (443 px), Catalog item
Versions700 pxVersions keeps its status strip and artifacts card

Analytics pages are exempt, because their figures and charts are the data. Forms and wizards are exempt as well, because their controls come first by design. Every other page has a budget, and a unit test fails if a route has neither a budget nor an exemption.

Allowances​

Some pages are over budget today because their quiet pass has not landed yet. Each one has an allowance: a ceiling set just above today's measurement, plus the reason the page is over. An allowance works like a ratchet:

  • the first row can move up, but not below the ceiling;
  • when the page comes back within budget, the check fails until you delete the allowance. That way an old allowance cannot hide a new regression.

Released pages carry no allowance. #6263 brought Catalog, Versions and Catalog item back within their budgets and deleted their allowances. Only three MCP pages still have one, until their quiet pass (#7064) lands:

RouteBudgetCeilingWhat stands above the data
mcp-servers360 px470 pxSaved-search and collection strips, totals, the shadowed-names alert
mcp-endpoint560 px600 pxA four-tile stat grid and the notes card
mcp-capabilities360 px420 pxThe preset tiles

A ceiling only ever goes down. When a change brings a page closer to its budget, lower the ceiling to the next multiple of ten above the new measurement.

Reading the result​

The report in visual-parity-report/<theme>/index.html, and the CI job summary, show a First row column beside each route's parity score:

CellMeaning
352 / 360 pxthe row starts at 352 px; the budget is 360 px
467 / 360 px (allowed 470)over budget, but inside its allowance
no match / 360 pxthe selector matched nothing (this fails)
—the route is exempt

When a page goes over its budget, the test failure tells you how far: catalog first row: 609 px, 249 px over the 360 px budget — something new stands above the data.

Setting a budget for a page​

When a redesigned page joins the harness, add a firstRow to its entry in apiome-ui/e2e/visual/routes.ts:

  1. Pick the page kind: firstRowBudget('list'), firstRowBudget('detail') or firstRowBudget('versions'). Budgets always come from this list; you cannot pick a custom number.
  2. The default selector is the first DataTable body row (.page-body tbody tr[data-row-id]). If the page's data is something else, such as a card list or a chart, pass that selector as the second argument.
  3. If the page is an analytics page or a form, add it to FIRST_ROW_EXEMPT instead.
  4. Run yarn test:e2e:visual -g <route id>. If the page is over budget and the fix belongs to a later ticket, add an allowance as the third argument, with ceilingPx set to the next multiple of ten above the measurement and a reason.

At size​

The parity fixtures hold a handful of rows. A real workspace can have a thousand catalog items, and a project can have hundreds of versions. RC6 checks both lists at that size:

  • Offset. e2e/visual/at-size.spec.ts mounts the Catalog table with 1,000 items and the versions table with 300 revisions. Each must meet its route's budget above, allowance included. The Catalog cards with 1,000 items must put their first card within 4 px of where three items put it. The fixtures in e2e/fixtures/hive-at-size/ are written by AT_SIZE_FIXTURE_DUMP=1 npx jest tests/rc6-list-budgets -t fixture.

  • Time. tests/rc6-list-budgets-catalog.test.tsx and tests/rc6-list-budgets-versions.test.tsx render the real screens at that size in jsdom. Each screen must mount only one page (50 rows) and stay inside these ceilings on the CI runner, while other suites run in parallel:

    StepCeiling (jsdom, CI)Measured (jsdom, idle)
    First row of data5,000 ms150–330 ms (2.4–2.6 s before paging)
    A filter3,000 ms100–160 ms
    A re-sort3,000 msabout 120 ms

    The CI runner is about ten times slower than a developer machine (a filter took 1.0 s and a sort 1.2–1.4 s there), which is why the ceilings are this wide.

    jsdom does the same React work as a browser, without painting, and does it more slowly. So the browser time is lower than the jsdom time, inside the 200 ms target for a filter or a sort.

apiome-ui/e2e/visual/README.md has the full detail, including how the parity score is weighted.