Skip to content

feat(plop): add VRT + Test unit to component scaffolding - #6574

Open
aramos-adobe wants to merge 2 commits into
caseyisonit/gen2-plop-templatesfrom
abdulr/feat-plop-generators
Open

feat(plop): add VRT + Test unit to component scaffolding #6574
aramos-adobe wants to merge 2 commits into
caseyisonit/gen2-plop-templatesfrom
abdulr/feat-plop-generators

Conversation

@aramos-adobe

@aramos-adobe aramos-adobe commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Description

Adds two standalone plop generators to the 2nd-gen scaffolder and extends the existing component generator 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).
  • component now also emits a baseline .vrt.ts stub 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 skipIfExists so they never clobber existing files, and format only the test/ / 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 component generator can't help there (re-running it collides with the existing files), and it previously shipped no .vrt.ts at all. These standalone generators make adding that coverage deterministic and one-command, and giving component a VRT stub means new components carry visual coverage from the start.

Related issue(s)

  • SWC-2448

Screenshots (if appropriate)

N/A — build-time tooling, no runtime or visual change.

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • component now scaffolds a VRT file

    1. From the repo root, run yarn plop component "test-widget" --force
    2. Confirm the skeleton includes 2nd-gen/packages/swc/components/test-widget/test/vrt/test-widget.vrt.ts alongside the test/*.test.ts and test/*.a11y.spec.ts files
    3. Clean up: rm -rf 2nd-gen/packages/{core,swc}/components/test-widget and git checkout -- 2nd-gen/packages/core/package.json
  • test and vrt retrofit an existing component

    1. Scaffold a component (yarn plop component "test-widget" --force), then delete its test/ directory
    2. Run yarn plop test "test-widget" --force and yarn plop vrt "test-widget" --force
    3. Confirm the test/a11y files and test/vrt/test-widget.vrt.ts are recreated, and the VRT import shape matches button.vrt.ts
    4. Clean up as above
  • Retrofit generators guard against a missing component

    1. Run yarn plop vrt "does-not-exist"
    2. Expect a clear abort message and no files written
  • Output is lint-clean

    1. On a generated component, run yarn lint, yarn lint:css, and yarn lint:docs-pages
    2. Expect all to pass (the a11y ARIA snapshot and VRT grid are intentional TODO scaffolds)

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

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 TODO for the author to complete.

  • Keyboard (required — document steps below)

    1. No runtime UI is added by this change; there are no keyboard interactions to verify.
    2. Confirm no regressions: the change is isolated to 2nd-gen/scaffolding/.
  • Screen reader (required — document steps below)

    1. No runtime UI is added by this change; there is nothing for a screen reader to announce.
    2. The generated *.a11y.spec.ts provides an ARIA-snapshot scaffold so each component carries screen-reader coverage from the start.

@aramos-adobe aramos-adobe self-assigned this Aug 3, 2026
@aramos-adobe
aramos-adobe requested a review from a team as a code owner August 3, 2026 22:27
@changeset-bot

changeset-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 33f321e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

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>
@aramos-adobe
aramos-adobe force-pushed the abdulr/feat-plop-generators branch from 35f63ad to 0bdbc8f Compare August 4, 2026 11:59
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📚 Branch Preview Links

🔍 Gen1 Visual Regression Test Results

When 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: pr-6574

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

@aramos-adobe aramos-adobe added skip_vrt Skip VRT build; mark UI Tests green without running Chromatic ready-for-review Status:Ready for review PR ready for review or re-review. Component:Tooling Issue or PR dealing with scripts, workflows, automation, etc. Component prefix is for Jira and removed ready-for-review labels Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component:Tooling Issue or PR dealing with scripts, workflows, automation, etc. Component prefix is for Jira skip_vrt Skip VRT build; mark UI Tests green without running Chromatic Status:Ready for review PR ready for review or re-review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant