Skip to content

AUI: Add parity tests for reference tokens and CLI style generation - #316

Merged
bheston merged 3 commits into
mainfrom
aui-parity-and-oracle-tests
Oct 11, 2026
Merged

bheston merged 3 commits into
mainfrom
aui-parity-and-oracle-tests

Conversation

@bheston

@bheston bheston commented Oct 11, 2026

Copy link
Copy Markdown
Member

Pull Request

Description

Adds parity tests for the reference tokens and for style generation by the aui CLI, so refactors can be checked for regressions, and fixes a bug in aui compile-styles found while doing so.

  • Reference token parity snapshots (src/reference/parity.spec.ts): snapshots the evaluated color (base, layer, palette, and recipe) tokens for several base colors, light and dark layers, and layer nesting, and the density tokens for several density adjustments, design units, and stroke thicknesses. Tokens are resolved through a real element hierarchy (a stub stands in for FASTElement as jsdom has no custom elements), so inheritance and derived values behave as in the browser. Regenerate with npm run unit-tests:update-snapshots.
  • Fix aui compile-styles for code anatomies: path.format ignores ext when base is present, so prettier parsed the CSS as index.js and every component with a TypeScript/JavaScript anatomy failed to compile (only JSON anatomies worked). Includes a changeset.
  • CLI oracle (scripts/styles-oracle.mjs, src/__test__/styles-oracle): compiles test only fixtures with the real CLI (compile-styles, compile-style, compile-json-anatomy, and the -e option) and compares the generated stylesheets and reported warnings to a checked in baseline. The fixtures are samples adapted from Adaptive Web Components and Polar UI anatomies, plus made up anatomies that stress each capability of the style generation. About 55 capabilities are also asserted directly, so the baseline is not taken on trust. npm run styles:oracle diffs and npm run styles:oracle:update replaces the baseline.

Issues

Reviewer Notes

  • The generated CSS only references design tokens, so the oracle covers structure and selectors, and the parity snapshots cover evaluated values.
  • The oracle fixtures are test only and are not published (src/ and scripts/ are in .npmignore). The copies are not kept in sync with their sources.
  • Existing behavior recorded in the baseline, not changed here: parts starting with :: get no state selector (hover, active, and focus collapse to one selector), AWC's anchor generates the never matching :host(:not([href])[href]), and the header comment of code anatomies always says from index.js.
  • Smoke test: npm run build && npm run unit-tests in packages/adaptive-ui, then npm run styles:oracle.

🤖 Generated with Claude Code

bheston and others added 3 commits October 11, 2026 09:56
Snapshot the evaluated reference tokens:
- Color: base, layer, palette and recipe tokens for several base colors,
  light and dark layers, and layer nesting.
- Density: padding and gap tokens for several density adjustments, design
  units and stroke thicknesses.

Regenerate with UPDATE_SNAPSHOTS=1 when a change is intentional.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
path.format ignores ext when base is present, so the prettier filepath
stayed index.js for non-JSON anatomies and parsing the CSS failed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Compile test only fixtures with the aui CLI and compare the generated
stylesheets and reported warnings to a checked in baseline, so diffs of the
generated css show regressions in style generation.

The fixtures are samples adapted from Adaptive Web Components and Polar UI
anatomies, plus made up anatomies stressing each capability of the style
generation. The capabilities are also asserted directly by the unit tests.

npm run styles:oracle compiles and diffs, styles:oracle:update replaces
the baseline.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 30aaab3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@adaptive-web/adaptive-ui Patch
@adaptive-web/adaptive-web-components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@bheston bheston self-assigned this Oct 11, 2026
@bheston
bheston merged commit 74a20e7 into main Oct 11, 2026
2 checks passed
@bheston
bheston deleted the aui-parity-and-oracle-tests branch October 11, 2026 14:53
@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant