feat(plop): add VRT + Test unit to component scaffolding - #6574
feat(plop): add VRT + Test unit to component scaffolding #6574aramos-adobe wants to merge 2 commits into
Conversation
|
Add standalone `test` and `vrt` plop generators that retrofit an existing 2nd-gen component with unit + a11y test files and a Chromatic VRT story. Component-side actions are unchanged from the base scaffolder. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
35f63ad to
0bdbc8f
Compare
📚 Branch Preview Links🔍 Gen1 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 |
Description
Adds two standalone plop generators to the 2nd-gen scaffolder and extends the existing
componentgenerator so a new component ships with VRT coverage out of the box.test— retrofits an existing component with unit (*.test.ts) and accessibility (*.a11y.spec.ts) test files.vrt— retrofits an existing component with a Chromatic VRT story (test/vrt/<name>.vrt.ts).componentnow also emits a baseline.vrt.tsstub alongside the test/a11y files it already scaffolds.The retrofit generators are safe by design: they guard that the target component exists (aborting with a clear message otherwise), use
skipIfExistsso they never clobber existing files, and format only thetest//test/vrt/subtree they write. All generated output is lint-clean and Prettier-formatted;TODOs mark where the author fills in component-specific detail.This is build-time authoring tooling. It adds no runtime code and changes no shipping component. Stacked on #6391 (base branch
caseyisonit/gen2-plop-templates).Motivation and context
Post-migration, the recurring authoring task shifts from creating new components to adding test and VRT coverage to the 100+ components that already exist, many migrated before the scaffolder landed. The
componentgenerator can't help there (re-running it collides with the existing files), and it previously shipped no.vrt.tsat all. These standalone generators make adding that coverage deterministic and one-command, and givingcomponenta VRT stub means new components carry visual coverage from the start.Related issue(s)
Screenshots (if appropriate)
N/A — build-time tooling, no runtime or visual change.
Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
componentnow scaffolds a VRT fileyarn plop component "test-widget" --force2nd-gen/packages/swc/components/test-widget/test/vrt/test-widget.vrt.tsalongside thetest/*.test.tsandtest/*.a11y.spec.tsfilesrm -rf 2nd-gen/packages/{core,swc}/components/test-widgetandgit checkout -- 2nd-gen/packages/core/package.jsontestandvrtretrofit an existing componentyarn plop component "test-widget" --force), then delete itstest/directoryyarn plop test "test-widget" --forceandyarn plop vrt "test-widget" --forcetest/vrt/test-widget.vrt.tsare recreated, and the VRT import shape matchesbutton.vrt.tsRetrofit generators guard against a missing component
yarn plop vrt "does-not-exist"Output is lint-clean
yarn lint,yarn lint:css, andyarn lint:docs-pagesTODOscaffolds)Device review
Accessibility testing checklist
This PR adds build-time scaffolding tooling. It introduces no runtime UI, component, or behavior, so there is no interactive surface to test here. The accessibility of any component created from the generators is validated during that component's own migration, not in this PR. The templates intentionally seed accessible defaults (label/slot content in stories, an ARIA-snapshot a11y spec) as a starting point, each marked with
TODOfor the author to complete.Keyboard (required — document steps below)
2nd-gen/scaffolding/.Screen reader (required — document steps below)
*.a11y.spec.tsprovides an ARIA-snapshot scaffold so each component carries screen-reader coverage from the start.