feat(storybook): testing grid WIP#6317
Conversation
|
📚 Branch Preview Links🔍 First Generation Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
Revert accidental 03_project-planning doc deletions from this branch so the PR stays focused on Storybook testing grid work. Co-authored-by: Cursor <cursoragent@cursor.com>
Reset the full CONTRIBUTOR-DOCS tree to match origin/main so this PR does not include unrelated planning doc changes. Co-authored-by: Cursor <cursoragent@cursor.com>
Description
Adds a Spectrum CSS–style Storybook testing grid for 2nd-gen SWC, with Button as the reference implementation. The grid is used for local VRT preview and Chromatic captures, separate from docs-friendly single-instance stories.
Storybook infrastructure
testing-grid.ts— Lit helpers ported from Spectrum CSSutilities.js:Container,States,ArgGrid,Sizes,Variants,renderContent,isChromatic().testing-preview.tsdecorator + Testing preview toolbar global (beaker icon) — maps toparameters.showTestingGrid, matching Spectrum CSS behavior.main.ts— Play-function tests stay under**/test/*.test.ts; VRT case lists live instories/*.test.ts(imported by*.stories.ts, not indexed as separate CSF files)..storybook/helpers/README.mdfor thestories/*.template.ts+stories/*.test.tspattern.Button reference implementation
button.template.ts— Pure Lit template for grid cells (avoids@wc-toolkit/storybook-helperstemplate(), which callsuseArgs()per cell and triggers React “Rendered more hooks…” errors in large grids).button.test.ts— VRT case list (testData, interactionstateData) imported by stories; not a standalone Storybook entry.button.stories.ts— Testing grid story wired toButtonGroups.vrt-state="hover" | "focus" | "active"— forces pseudo-state visuals via.is-hover,.is-focus-visible,.is-activeclasses (mirrors Spectrum CSS).vrt-pending-active— skips the 1s pending delay for snapshot capture.global-button.css— Updated with the same forced-state selectors for global button styling.Other
response-status.stories.ts(accidentally removed on branch).color-loupestory fix (static button import vs loader).a11y-helperschange (customElements.whenDefined).Motivation and context
Spectrum CSS uses a testing grid (
Variants,ArgGrid, toolbar toggle) for comprehensive Chromatic VRT. 2nd-gen SWC had hand-rolled option stories (Sizes,Variants, etc.) but no shared grid or Chromatic-oriented layout. This PR establishes the shared helper layer and proves the pattern on Button.How to test
Local Storybook
cd 2nd-gen/packages/swc yarn storybookdata-testing-previewwrapper with bordered sections).data-html-preview(docs-style).Chromatic / PR preview
run_vrtis on the PR for 2nd-gen Chromatic when ready.Regression spot-checks
swc-button.Screenshots
Add Testing grid + Testing preview on/off screenshots before review.
Open questions for the team
vrt-state/vrt-pending-activeonswc-button— Acceptable as dev-only reflected attributes, or should forced states live entirely in Storybook CSS (no component API)?Default = ButtonGroups), or stay a separate dev story while Playground remains docs default?@adobe/spectrum-wcfor Storybook helpers only, or also document the Button VRT attributes in contributor docs?Known gaps / follow-ups
*.test.ts+ grid; pattern not yet applied elsewhere.vrt-pending-activeis a test hook; real 1s delay not exercised in grid..swc-Button; global-button.css duplicated selectors — keep in sync via codegen (already the case).a11y-helpers/ color-loupe tweaks could still be split into a separate PR if reviewers prefer.Author's checklist
Reviewer's checklist
.storybook/helpers/testing-grid.ts,testing-preview.ts, andbutton.test.ts/button.template.ts.run_vrtlabel is applied.Manual review test cases
Testing grid — Button
Testing preview toggle
Device review
Accessibility testing checklist
N/A for Storybook infrastructure. If reviewing Button
vrt-*attributes: they only affect visual presentation in Storybook and do not change runtime a11y behavior for consumers.