diff --git a/CLAUDE.md b/CLAUDE.md index 1e6729f9..788e6efd 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -51,9 +51,21 @@ requires a rebuild+redeploy, not just a file edit. | `npm run version-sync` | Sync all version references to root `package.json` | | `npm run check:version` | Verify all version references match (CI gate — run before every commit that touches versions) | | `npm run check:llm-guide` | Verify `docs/llm-guide.md` only references live tokens (CI gate) | +| `npm run check:macros` | Verify `.sf-*` macro classes match `docs/macros.md` (not currently wired into CI — run manually before committing macro changes) | +| `npm run check:registry` | Verify `token-registry.json` is in sync with source (CI gate) | +| `npm run audit:check` | Verify `docs/registry.json` matches source without writing (CI gate) | +| `npm run lint:css` | Lint all CSS source with stylelint (CI gate) | +| `npm run lint:css:fix` | Lint CSS source and auto-fix violations | | `npm run docs` | Regenerate docs and sync configurator API index | +| `npm run docs:tokens` | Regenerate `docs/tokens.md` only | +| `npm run docs:index` | Regenerate `docs/token-index.md` + `.json` only | +| `npm run docs:api` | Regenerate `docs/api-index.md` + `.json` only | +| `npm run docs:classes` | Regenerate `docs/classes.md` only | +| `npm run gen:registry` | Regenerate `token-registry.json` (stable id assignments) | | `npm run configurator:sync` | Push `docs/api-index.json` → `configurator/src/data/api-index.generated.json` | -| `npm run audit` | Audit CSS tokens for consistency | +| `npm run audit` | Audit CSS tokens for consistency, writing `docs/registry.json` | +| `npm run watch` | Rebuild CSS bundles on file change (dev watch mode) | +| `npm run test:unit` | Run the Node `--test` unit suite only, without the Playwright e2e build. Some tests read from `badges/` — run `npm run build` first on a clean checkout (CI instead downloads the `badges` artifact from the `build` job before this step) | | `npm test` | Full suite: build → unit → Playwright e2e | ## Release process diff --git a/docs/migration.md b/docs/migration.md index ecfbcb98..a2dff8fe 100644 --- a/docs/migration.md +++ b/docs/migration.md @@ -3,7 +3,7 @@ Mapping concepts from popular CSS frameworks to SLASHED, plus intra-project upgrade notes. -## SLASHED 0.6.25 → next +## SLASHED 0.6.25 → 0.6.26 ### `base` relative shade aliases removed diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 00000000..6ffd799d --- /dev/null +++ b/tests/README.md @@ -0,0 +1,28 @@ +# Test conventions + +Two runners, split by whether a test needs a real browser: + +- **`*.spec.js`** — Playwright (`npm test`). Runs across chromium/firefox/webkit. + Use for anything that renders CSS and reads computed styles, layout geometry, + or visual output — imports `test`/`expect` from `@playwright/test`. +- **`*.test.js`** — Node's built-in test runner (`npm run test:unit`), single + process, no browser. Use for pure fs/regex/data-shape checks that never touch + a DOM — imports `test`/`describe` from `node:test` and `assert` from + `node:assert/strict`. Wire new files into `pretest`/`test:unit` in + `package.json`. + +If a test doesn't call `page.*` or read a computed style, it almost certainly +belongs in `*.test.js`, not `*.spec.js` — see SL-027 (`coverage.test.js` used +to be Playwright-discovered despite never touching a browser, tripling its CI +cost for no reason). + +## `tier1-p*` numbering (SL-032) + +`tier1-p2-coverage`, `tier1-p7-oldengine`, `tier1-p8-modern`, and +`tier1-p10-contrast` number their properties P2/P7/P8/P10 with no P1, +P3-P6, or P9 anywhere in the repo. These numbers come from the +tier-1-color-fallback feature's original property enumeration (see each +file's own `Property N:` header comment) — only a subset of the enumerated +properties warranted a dedicated automated test; the rest were covered by +other existing tests, manual review, or judged unnecessary to automate. The +gaps are not dead history — don't renumber these files sequentially. diff --git a/tests/a11y-patterns.spec.js b/tests/a11y-patterns.spec.js index ecaba27e..2c30d363 100644 --- a/tests/a11y-patterns.spec.js +++ b/tests/a11y-patterns.spec.js @@ -4,16 +4,11 @@ // .sf-focus-parent, .sf-clickable-parent, // touch-target token, forced-colors, disabled cursor. import { test, expect } from '@playwright/test'; -import path from 'node:path'; - -const BUNDLE = path.join(process.cwd(), 'badges', 'slashed.optimal.css'); +import { renderWithBundle, NO_TRANSITIONS_STYLE } from './render-helpers.js'; async function setup(page, html) { - await page.setViewportSize({ width: 800, height: 600 }); - await page.setContent(`
${html}`); - await page.addStyleTag({ path: BUNDLE }); // Disable transitions so computed property reads are stable (no mid-animation values). - await page.addStyleTag({ content: '*, *::before, *::after { transition: none !important; animation-duration: 0s !important; }' }); + await renderWithBundle(page, html, { width: 800, height: 600, extraStyle: NO_TRANSITIONS_STYLE }); } // ── .sr-only ──────────────────────────────────────────────────── diff --git a/tests/container-queries.spec.js b/tests/container-queries.spec.js index c7e50853..e6236de3 100644 --- a/tests/container-queries.spec.js +++ b/tests/container-queries.spec.js @@ -5,9 +5,7 @@ // setupInContainer pins font-size to 16px so em-based CQ thresholds are stable // across browsers (WebKit 26+ resolves em against inherited font-size, not 16px). import { test, expect } from '@playwright/test'; -import path from 'node:path'; - -const BUNDLE = path.join(process.cwd(), 'badges', 'slashed.optimal.css'); +import { BUNDLE } from './render-helpers.js'; // Wraps grid HTML in a container of a known inline-size so anonymous // @container queries fire against that width, not the viewport. diff --git a/tests/layers.spec.js b/tests/layers.spec.js index 96989c17..6d84e33e 100644 --- a/tests/layers.spec.js +++ b/tests/layers.spec.js @@ -1,6 +1,6 @@ // @ts-check import { test, expect } from '@playwright/test'; -import path from 'node:path'; +import { BUNDLE } from './render-helpers.js'; /** * Layer ordering invariant test. @@ -26,7 +26,7 @@ test.describe('Layer ordering', () => {Highlighted text
`); - await page.addStyleTag({ path: path.join(process.cwd(), 'badges', 'slashed.optimal.css') }); + await page.addStyleTag({ path: BUNDLE }); const bg = await page.locator('mark').evaluate(el => getComputedStyle(el).backgroundColor @@ -29,7 +29,7 @@ test.describe('Print styles', () => {