Skip to content

feat(preprod): Add structured tags to snapshot test metadata#116307

Merged
mtopo27 merged 4 commits into
masterfrom
max/snapshot-tags-metadata
May 27, 2026
Merged

feat(preprod): Add structured tags to snapshot test metadata#116307
mtopo27 merged 4 commits into
masterfrom
max/snapshot-tags-metadata

Conversation

@mtopo27
Copy link
Copy Markdown
Contributor

@mtopo27 mtopo27 commented May 27, 2026

Move all custom metadata (theme, variant, size, state, etc.) from flat top-level keys into a structured tags: Record<string, string> field across all 14 snapshot test files. This makes snapshot properties filterable and queryable on the product side without relying on extra = "allow" passthrough fields.

Framework type changes

SnapshotTestMetadata replaces the previous Record<string, string> parameter on it.snapshot() and it.snapshot.each(). The new type restricts metadata to three keys: group, display_name, and tags. The SnapshotImageMetadata output interface gains a matching tags field. No backend changes needed — ImageMetadata in manifest.py already has tags: dict[str, str] | None with coercion.

Per-file tag mapping

Every snapshot test now passes an explicit tags object containing the relevant axes for that component — theme is universal, size/variant/state vary by file. An area tag distinguishes core design system primitives (core) from product-side snapshot UI (snapshots). Three files (checkbox, radio, switch) that previously had no metadata now gain tags for the first time.

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.58%

mtopo27 and others added 2 commits May 27, 2026 11:50
Move all custom metadata (theme, variant, size, state, etc.) from flat
top-level keys into a structured `tags: Record<string, string>` field
across all 14 snapshot test files. Add an `area` tag to distinguish
core design system primitives from product-side snapshot UI.
The state tag duplicates information already captured by the snapshot
test name and is not needed for area-level filtering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mtopo27 mtopo27 force-pushed the max/snapshot-tags-metadata branch from 1917daa to d0f12ba Compare May 27, 2026 15:56
@mtopo27 mtopo27 marked this pull request as ready for review May 27, 2026 16:01
@mtopo27 mtopo27 requested review from a team as code owners May 27, 2026 16:01
@mtopo27 mtopo27 removed request for a team May 27, 2026 16:01
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d0f12ba. Configure here.

</Wrapper>
),
diffMode => ({theme: themeName, state: diffMode})
_diffMode => ({tags: {theme: themeName, area: 'snapshots'}})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dynamic diffMode value dropped from .each() tags

Low Severity

The diffMode parameter in the .each() metadata callback is renamed to _diffMode (marking it unused) and excluded from tags. All three iterations ('split', 'wipe', 'onion') now produce identical tags {theme, area}, making them indistinguishable when filtering. Every core component .each() callback consistently includes its varying parameter in tags (e.g., variant, size, checked), so omitting diffMode here appears to be an oversight during the migration from the flat state: diffMode field.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d0f12ba. Configure here.

…etadata

Parse the theme (light/dark) from Jest's describe ancestry in
parseSnapshotDetails, removing the need to manually pass it in every
snapshot test. Explicit metadata.tags.theme still takes precedence.

Replace the unsafe ...metadata spread in takeSnapshot with explicit
field assignment so display_name and group overrides are intentional
rather than side effects of object spreading.

Add SnapshotArea union type to constrain area tags to known values,
making it a compile error to use an unregistered area.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mtopo27 mtopo27 merged commit 8f5cbe9 into master May 27, 2026
75 checks passed
@mtopo27 mtopo27 deleted the max/snapshot-tags-metadata branch May 27, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants