Skip to content

feat(dev-validation): apply shared validation helpers across all Gen2 components#6510

Draft
rubencarvalho wants to merge 10 commits into
ruben/feat-dev-warning-validation-foundationfrom
ruben/feat-dev-warning-validation-components
Draft

feat(dev-validation): apply shared validation helpers across all Gen2 components#6510
rubencarvalho wants to merge 10 commits into
ruben/feat-dev-warning-validation-foundationfrom
ruben/feat-dev-warning-validation-components

Conversation

@rubencarvalho

@rubencarvalho rubencarvalho commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

Applies the shared dev-validation helpers introduced in #6508 (the foundation branch this PR targets) across all 20 Gen2 core components:

Component What changed
Badge, Tabs, IllustratedMessage enum/required/mutually-exclusive/allowed-children checks retrofitted onto the shared helpers
ProgressCircle, LinearProgressMixin (Meter) deprecation/required/value-range checks retrofitted; new staticColor/labelPosition enum checks added
Button, Card, Tooltip, ActionButton combo/required checks retrofitted; new staticColor (ActionButton), variant/placement (Tooltip) enum checks added
Asset, AlertBanner, StatusLight, Popover enum/deprecation/required checks retrofitted; new size enum check added (Popover)
Divider, Avatar, ButtonGroup enum checks retrofitted; new numeric size check added (Avatar)
Accordion new density enum check added (previously undeclared)
ColorLoupe, ColorHandle, Icon reviewed, confirmed no changes needed (booleans/free-text only, per the "don't validate" list)

Also fixes the documentation URLs across every touched component (and the illustrative examples added to the style guide in the foundation branch) from the stale opensource.adobe.com/spectrum-web-components/components/* pattern to the actual Gen2 docs site: spectrum-web-components.adobe.com/?path=/docs/components-*--docs.

Deliberately not added: a validateRequiredSlot check for IllustratedMessage's heading slot. Its JSDoc @todo notes it should eventually be {required} via CEM tooling, but an existing test (illustrated-message.test.ts) explicitly asserts no warning fires when the heading slot is empty — adding the check would contradict that established, intentional behavior. Left alone rather than silently overridden.

One test fix along the way: status-light.test.ts asserted an exact old warning message via .toBe(); updated it to .toContain() against the new standardized validateEnum wording rather than hand-tuning the helper to preserve a stale string.

Motivation and context

Demonstrates the helper-based pattern established in the foundation branch across the entire component set, completing the "retrofit existing ad hoc call sites" item agreed for this branch and closing the gap on components that had no dev-mode validation at all.

Related issue(s)

Screenshots (if appropriate)

N/A — no visual changes; only dev-mode console warning behavior.

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

  • Existing warning behavior is unchanged across the whole package

    1. Run yarn vitest --run --project storybook from 2nd-gen/packages/swc
    2. Expect all 720 tests to pass, matching pre-retrofit behavior
  • Console warnings still fire correctly in Storybook

    1. Run Storybook locally (yarn storybook from 2nd-gen/packages/swc)
    2. Open any touched component's playground and set an invalid enum value (e.g. variant, size, density, placement, orientation) via Controls
    3. Expect a console warning referencing the correct doc URL (spectrum-web-components.adobe.com/?path=/docs/components-*--docs)

Device review

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

Accessibility testing checklist

  • Keyboard: No behavioral changes; confirm no regressions in keyboard interaction across touched components (unchanged by this PR).
  • Screen reader: No ARIA/DOM changes; confirm accessible-name-related warnings (Tabs, Avatar, Button, Popover) still fire correctly for their respective missing-label cases (unchanged checks, moved to warnIf).

…elpers

First representative batch applying the shared dev-validation helpers
from the foundation branch:

- Badge: variant enum check -> validateEnum; outline/non-semantic-
  variant combo -> warnIf.
- Tabs: keyboard-activation/density/direction enum checks -> validateEnum
  (kept in their property setters alongside the existing fallback-value
  logic); required accessible-label check -> warnIf.
- IllustratedMessage: size/orientation enum checks -> validateEnum;
  heading slot allowed-children check -> validateAllowedChildren
  (previously a one-off inline tag allowlist).

Also fixes the docs URLs in these three components (and this session's
style-guide examples) from the stale opensource.adobe.com/spectrum-web-
components/components/* pattern to the actual Gen2 docs site:
spectrum-web-components.adobe.com/?path=/docs/components-*--docs.

No new required-slot check was added for IllustratedMessage's heading
slot: an existing test explicitly asserts no warning fires when it's
empty, so that's left alone rather than overridden.

All existing tests for these three components pass unchanged (97 tests
across badge/tabs/illustrated-message/dev-validation), since the new
helpers preserve enough of each original message's wording for the
existing assertions to still match.
@changeset-bot

changeset-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 017ab27

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

VARIANTS_SEMANTIC has a fixed initializer directly on BadgeBase
(SHARED API section), unlike VARIANTS (API TO OVERRIDE, no
initializer, genuinely meant to differ per concrete subclass per its
JSDoc). Going through this.constructor for VARIANTS_SEMANTIC was
redundant indirection; the already-imported BADGE_VARIANTS_SEMANTIC
constant is identical. The VARIANTS lookup stays, since that one is
by design abstract and subclass-supplied.
@github-actions

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-6510

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.

…eter

- ProgressCircle: light-DOM-children deprecation and missing-
  accessible-name checks -> warnIf. New: staticColor enum check via
  validateEnum (previously undeclared/unvalidated despite STATIC_COLORS
  existing for styling purposes).
- LinearProgressMixin (shared by Meter): value-out-of-range and
  missing-accessible-name checks -> warnIf, keeping the mixin's own
  instance-level _hasWarned* flags as-is (they implement a distinct
  "warn once per bad-state entry, reset on recovery" policy layered on
  top of the shared warn() dedup, not something the helpers replace).
  New: labelPosition and staticColor enum checks via validateEnum
  (previously undeclared/unvalidated).
- Meter: variant enum check -> validateEnum.

All existing tests for progress-circle and meter pass unchanged (48
tests).
- Button: pending+disabled combo and icon-only-without-label checks ->
  warnIf (the latter now tagged type: 'accessibility', matching how
  every other accessible-name check in this effort is categorized).
- ActionButton: new staticColor enum check via validateEnum (previously
  undeclared/unvalidated; no core base class owns this property, so the
  check lives directly on the swc concrete class).
- Card: variant/density enum checks -> validateEnum; title-as-link-
  without-a-link-element check -> warnIf.
- Tooltip: dangling for="" reference check -> warnIf. New: variant and
  placement enum checks via validateEnum (both had a VARIANTS/PLACEMENTS
  static already declared but never actually validated against).

color-loupe was reviewed and needs no changes (boolean + free-text CSS
color property only, no enums/required/slots).

All existing tests for action-button, button, button-group, tooltip,
and card pass unchanged (142 tests).
- Asset: variant enum check -> validateEnum.
- AlertBanner: variant enum check (in the property setter) ->
  validateEnum.
- StatusLight: 'accent' deprecation and disabled-attribute-removed
  checks -> warnIf; variant enum check -> validateEnum. Fixed the
  variant check's stale opensource.adobe.com URL.
- Popover: dangling for="" reference check and required accessible-
  label-on-show check -> warnIf; placement enum check -> validateEnum.
  New: size enum check via validateEnum (VALID_SIZES existed but was
  never validated).

Updated one test (status-light) that asserted the exact old warning
message text via .toBe() rather than .toContain(); switched it to
match the new standardized validateEnum message format instead of
hand-tuning the helper's wording to preserve a stale test string.

All existing tests for asset, alert-banner, status-light, and popover
pass (90 tests).
- Divider: staticColor enum check -> validateEnum.
- Avatar: missing-alt accessibility check -> warnIf. New: numeric size
  enum check via warnIf (VALID_SIZES existed and the setter already
  fell back to the default on an invalid value, but never warned about
  it).
- ButtonGroup: orientation and align enum checks -> validateEnum.

Icon was reviewed and needs no changes (free-text label, no required
slot semantics beyond a graceful no-op when nothing is slotted).

All existing tests for divider, avatar, icon, and button-group pass
unchanged (78 tests).
ACCORDION_DENSITIES existed as the canonical valid-values source but
was never actually validated anywhere. Added via validateEnum.

ColorLoupe and ColorHandle were both already reviewed earlier this
effort and confirmed to need no changes (booleans + free-text CSS
color only).

All existing tests for accordion, color-handle, and color-loupe pass
unchanged (67 tests).
@rubencarvalho rubencarvalho changed the title feat(dev-validation): retrofit Badge, Tabs, IllustratedMessage onto shared helpers feat(dev-validation): apply shared validation helpers across all Gen2 components Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant