feat(dev-validation): apply shared validation helpers across all Gen2 components#6510
Conversation
…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.
|
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.
📚 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 |
… static" This reverts commit 2dc721c.
…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).
…n/feat-dev-warning-validation-components
…n/feat-dev-warning-validation-components
Description
Applies the shared dev-validation helpers introduced in #6508 (the foundation branch this PR targets) across all 20 Gen2 core components:
staticColor/labelPositionenum checks addedstaticColor(ActionButton),variant/placement(Tooltip) enum checks addedsizeenum check added (Popover)sizecheck added (Avatar)densityenum check added (previously undeclared)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
validateRequiredSlotcheck for IllustratedMessage's heading slot. Its JSDoc@todonotes 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.tsasserted an exact old warning message via.toBe(); updated it to.toContain()against the new standardizedvalidateEnumwording 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
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Existing warning behavior is unchanged across the whole package
yarn vitest --run --project storybookfrom2nd-gen/packages/swcConsole warnings still fire correctly in Storybook
yarn storybookfrom2nd-gen/packages/swc)variant,size,density,placement,orientation) via Controlsspectrum-web-components.adobe.com/?path=/docs/components-*--docs)Device review
Accessibility testing checklist
warnIf).