Skip to content

test: make the test:ci log clean and fail on unexpected console output - #3322

Merged
interactivellama merged 19 commits into
masterfrom
chore/clean-ci-warnings
Nov 20, 2026
Merged

interactivellama merged 19 commits into
masterfrom
chore/clean-ci-warnings

Conversation

@interactivellama

@interactivellama interactivellama commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Part of the v11 merge train, stack 1 "clean CI": ci-warnings → react-hooks-refs → deprecated-dom-apis → deprecated-prop lint (#3311) → private exports. It merges first, so later stacks rebase onto a clean log.

Additional description

This makes npm run test:ci print a clean log, and keeps it clean.

Root cause: most of the test noise came from fixtures, not components. The utilities/warning/* helpers warn once per module, which hid how many there were: CI showed 27 stderr blocks, but there were 289 console.error calls with warn-once defeated.

  • 213 were fixtures that left out a required controlled handler (onChange, onRowChange, onClick, onSelect, …).
  • About 63 came from tests using an API deprecated in v11, without asserting the warning.
  • The rest were act/jsdom-navigation noise and three real component bugs.

Changes:

  • Tests: fixtures pass the required handlers; deprecated-path tests assert their warning with vi.spyOn(console, 'error'); the act and jsdom navigation noise is fixed. A test-only reset clears the warn-once state between tests.
  • Component fixes:
    • Button and ButtonStateful: responsive now adds slds-button_stretch. On Button the prop did nothing and leaked to the DOM as an attribute; ButtonStateful used slds-max-small-button_stretch, which SLDS doesn't have. SLDS has no small-screen-only stretch class, so the button is full width at every screen size. The page-header title triggers in the split-view and Simple Data Table examples passed responsive while it did nothing, so they drop it and keep their width.
    • Button defaults type to submit when formAction is set (React rejects formAction on type="button").
    • SimpleDataTableInteractiveElement passes onOpen/onClose only to elements that open a popover. It injected them into every wrapped element, though only MenuDropdown uses them (to pause table keyboard navigation while its menu is open), so a wrapped Button rendered onOpen on the DOM. MenuDropdown still gets them automatically. A consumer's own popover opts in with the new option SimpleDataTableInteractiveElement(MyPopover, { tracksOpen: true }) (type SimpleDataTableInteractiveElementOptions). Button and Checkbox no longer receive them.
  • Build: drops the redundant lib.formats, which printed a Vite warning, and the dead jsxBracketSameLine prettier option.
  • Lint: fixes the mechanical warnings and the a11y and exhaustive-deps findings. The remaining 35 (react-hooks/refs and set-state-in-effect) are capped with --max-warnings. The next PR fixes them and removes the cap.
  • Reporting warnings on the PR:
    • Tests: vitest.console-guard.ts records any unexpected console.error/console.warn. scripts/vitest-console-reporter.ts lists them after the run and, on GitHub Actions, annotates each test file and writes them to the job summary. The run fails past maxWarnings (0).
    • Lint: scripts/eslint-github-formatter.cjs annotates each warning location once (with a count when ESLint repeats it) and lists every warning in the job summary.
    • Build warnings are printed and never fail the build.

This PR has no breaking API changes. None of the deprecations that fired were removed; they all stay deprecated through 11.x. Two behaviour changes for consumers: responsive on Button and ButtonStateful now makes the button full width, and Button defaults type to submit when formAction is set without a type.


CONTRIBUTOR checklist (do not remove)

Please complete for every pull request.

Green gate — all of these must pass locally (CI runs the same):

  • npm run lint passes with 0 errors (npm run lint:fix to auto-fix). Warnings are the tracked gradual-migration backlog; do not add new errors.
  • npm run typecheck is clean (tsc --noEmit).
  • npm test -- --run passes — this runs both Vitest projects (jsdom unit + real-browser browser) and the story HTML snapshots. If you changed rendered markup on purpose, update snapshots with npm test -- --run -u and review the diff.
  • npm run build succeeds (type-check + Vite library build + .d.ts + entry shims).

Behavior & docs:

  • First-time contributors: sign the CLA (a bot will comment with instructions).
  • Added/updated Vitest + React Testing Library tests for the change (template: components/button/__tests__). New props and bug fixes should get a regression test. Tests that genuinely need a real browser (focus traversal, layout/measurement, canvas) go in a *.browser.test.jsx file (the browser project); everything else is jsdom.
  • Reviewed the component's Storybook stories: npm run storybook → http://localhost:6007/. Confirm the story actually renders and behaves (deprecated Storyshots/Karma are gone; there is no separate browser-tests server).
  • Story/example code uses the component's real prop API (e.g. slots like content / visualPickerFigure, render props like renderItem, icon props, events), not assumptions — a common source of "component looks broken" reports has been stories authored against the wrong API. Cross-check against components/<name>/__examples__.
  • Storybook Accessibility (a11y) panel shows no new violations for the affected stories.
  • If you added or changed a type, remember runtime PropTypes were removed in the TS migration — types are the contract. Ship accurate .d.ts (they're generated by the build); JS consumers rely on them via editor type-acquisition.

REVIEWER checklist (do not remove)

  • CI is green (GitHub Actions CI workflow: lint, typecheck, test, build). Chromatic visual review, if configured, has been checked.
  • Change has adequate test coverage; bug fixes include a regression test.
  • Reviewed the affected Storybook stories and their a11y panels.
  • Rendered markup still conforms to SLDS — check the story HTML snapshot diff (components/__tests__/__snapshots__/story-snapshots.test.jsx.snap).
  • Public API / package surface: if exports changed, the deep-import contract still holds (@salesforce/design-system-react/components/<name> and nested paths resolve for ESM, CJS, and types). Removing/renaming a public component or export is a breaking change → feat!:/BREAKING CHANGE: and a major version bump.

@interactivellama
interactivellama force-pushed the chore/clean-ci-warnings branch 3 times, most recently from e965d09 to 61c3e3e Compare November 17, 2026 17:47
@interactivellama
interactivellama removed this pull request from stack #3324 November 17, 2026 17:47
@interactivellama
interactivellama changed the base branch from master to feat/v11-rc-breaking November 17, 2026 17:48
@interactivellama
interactivellama removed this pull request from stack #3334 November 17, 2026 22:47
@interactivellama
interactivellama removed this pull request from stack #3335 November 17, 2026 23:49
@interactivellama
interactivellama changed the base branch from feat/v11-rc-breaking to feat/v11-asks-1-release-policy November 17, 2026 23:49
@interactivellama
interactivellama changed the base branch from feat/v11-asks-1-release-policy to feat/block-private-exports November 17, 2026 23:50
@interactivellama
interactivellama changed the base branch from feat/block-private-exports to feat/v11-rc-breaking November 18, 2026 00:06
@interactivellama
interactivellama removed this pull request from stack #3336 November 18, 2026 00:38
@interactivellama interactivellama added this to the 11.0.0-rc.0 milestone Nov 18, 2026
@interactivellama
interactivellama removed this pull request from stack #3337 November 18, 2026 00:49
Base automatically changed from feat/v11-rc-breaking to master November 18, 2026 22:16
interactivellama added a commit that referenced this pull request Nov 18, 2026
no-style-elements mounts every story, which replays their deprecation and
Modal app-element warnings, and the tooltip browser test passed its trigger
as the deprecated children. The console guard from #3322 counts both. Mock
console in the story sweep, restoring it after cleanup since unmounting a
Modal warns too, and pass the tooltip trigger through trigger.
@interactivellama
interactivellama removed this pull request from stack #3339 November 18, 2026 23:30
interactivellama added a commit that referenced this pull request Nov 20, 2026
no-style-elements mounts every story, which replays their deprecation and
Modal app-element warnings, and the tooltip browser test passed its trigger
as the deprecated children. The console guard from #3322 counts both. Mock
console in the story sweep, restoring it after cleanup since unmounting a
Modal warns too, and pass the tooltip trigger through trigger.
Base automatically changed from chore/remove-legacy-icons to master November 20, 2026 23:43
`build.lib.formats` duplicated the `rollupOptions.output` array, so Vite
ignored it and warned on every build. The emitted dist/ files are
byte-identical without it. `jsxBracketSameLine` was removed in Prettier 3.
Fixtures rendered controlled components (ColorPicker, DatePicker, Slider,
ButtonStateful, Tree, Checkbox, SimpleDataTable) without their required
change handler, so every render logged an "is required by" error. Input and
ColorPicker fixtures also passed both label and assistiveText.label.

Fixtures now pass a no-op handler. Tests that cover the missing-handler or
both-labels path keep that input and silence the expected error with a spy.
General tests used APIs deprecated in v11 (ProgressIndicator completedSteps
and errorSteps, Tooltip children as trigger, Tree onClick/onExpandClick and
node.selected, Radio onRenderVisualPicker), so they logged deprecation
warnings that hid real ones. They now use the replacement APIs.

Tests that exercise a deprecated path on purpose (Combobox inline-listbox
multiple and action item onClick, Checkbox onRequestFocus, the
ProgressIndicator arrays) keep it and silence or assert the warning with a
spy. Removal tests for defaultValue and singleInputDisabled restored their
spy before the follow-up render, which warned again from the component's
fresh check-props instance; the spy now covers that render.

No props are removed: these were all deprecated in v11 and stay through 11.x.
ProgressIndicator path tests focused and clicked stages outside act(); the
focus handler moves the roving tab stop, a state update, so React warned.
They now run inside act().

Carousel and VerticalNavigation click tests clicked real links without
preventing the default action, which jsdom cannot perform and reports as
"navigation to another Document" being unimplemented. Their handlers now
call preventDefault, as the neighbouring tests already do.
Root cause: `ButtonProps.responsive` was declared but never destructured,
so it reached `<button>` through `restProps` and React warned about a
non-boolean attribute. 0.10.x declared the prop and never applied it.
ButtonStateful mapped it to `slds-max-small-button_stretch`, a class SLDS
does not have, so it had no effect there either.

Both now map `responsive` to `slds-button_stretch`, SLDS's full-width
button class. SLDS has no small-screen-only variant, so the button
stretches at every width. The examples' page-header title triggers passed
`responsive` while it did nothing; they drop it so they keep their width.
Root cause: Button always defaulted `type` to `button`, and browsers ignore
`formAction` on a `type="button"` button, so a Button given `formAction`
without an explicit `type` did nothing on click and React warned.

When `formAction` is set and `type` is not, `type` now defaults to `submit`.
An explicit `type` still wins, and without `formAction` the default stays
`button`.

Behaviour change for consumers: a Button with `formAction` and no `type`
now submits its form, as `formAction` implies.
Root cause: `SimpleDataTableInteractiveElement` injected `onOpen` and
`onClose` into every element it wrapped, though only MenuDropdown uses them
(to pause table keyboard navigation while its menu is open). Button passes
its native attributes through to `<button>`, so a wrapped Button rendered
them and React warned about an unknown `onOpen` event handler.

The wrapper now injects them only into MenuDropdown, or into an element
wrapped with the new `{ tracksOpen: true }` option, for a consumer's own
popover. Button is unchanged.
Drops unused variables, parameters and imports, removes initial values that
were always overwritten (no-useless-assignment), removes console.log calls
from test handlers, and associates the Panel story's labels with their
selects. Also deletes the unused `handleClickOutside` callbacks in Combobox
and Popover; click-outside is handled by Dialog.

No behaviour change. The Panel story snapshot gains the label `for` and
select `id`.
Behaviour fixes:
- tree: branch treeitems now set aria-selected, as leaf items already
  did. Branches were announced with no selection state.
- simple-data-table: the row's memoized cells depend on
  tableContext.isGrid, so the select cell's gridcell role follows
  keyboardNavigation instead of keeping the role from the first render.
- pill-container: the reset effect lists resetActiveSelectedOption,
  which is defined before it.
- filter: handleChange lists setPopoverIsOpen (a stable setter).

Accepted with a reason: the mount-only check-props and app-element
checks in modal and tooltip, and the src jsx-a11y sites whose markup
follows SLDS (anchors as tabs, options and heading links; click
handlers whose keyboard path lives on the focusable element or the
listbox). Each disable names its reason.

Lint-only cleanups: the unused combobox wrapper ref and its no-op
click-outside hook (the menu closes on input blur; popover handles
its own click-outside), the combobox non-null assertion, and the
empty SimpleDataTableSelection interface.

Docs and examples: placeholder href="#" anchors get fragment targets.
Story snapshots updated.
Lint is at 35 warnings, all from the React Compiler rule set
(react-hooks/refs and set-state-in-effect). They are carried past
11.0 GA. The lint script now fails above 35, so the count can only go
down. Recorded in ROADMAP.md.
These four files predate the prettier config and still used spaces. The
next two commits touch them, and lint-staged reformats a whole file when
it is staged, so format them on their own first to keep those diffs
readable.
Every warn-once helper in utilities/warning, plus the ColorPicker and
DatePicker missing-value checks, now keeps its warned keys in a map
from warned-registry. resetWarnings() clears them all, and both
Vitest setup files call it after each test. In an app nothing calls
it, so each message still prints once per page load.

Tests no longer need vi.resetModules() and a dynamic import to see a
warning. Two tests that only passed because an earlier test had used
the warn-once slot now assert what they meant: the checkbox test looks
for React's controlled/uncontrolled message only, and the progress
indicator test compares call counts across the re-render.
vitest.console-guard.ts, loaded by both setup files, fails any test
that writes to console.error or console.warn. A test that expects a
warning spies on the console itself, which bypasses the guard.
console.log is not guarded.

The guard caught one more source: the combobox renderMenuItem tests
open the menu at mount, and floating-ui's async positioning updated
SLDSDialog after the test ended (an act warning). They now use
menuPosition="relative", as the other open-state tests do.

`vite build` now fails on any warning: Vite's own warnings through a
throwing logger (build command only, so dev and Storybook keep the
default), and bundler warnings through onwarn.
Storybook's react-docgen-typescript plugin parses every *.tsx file
except stories. The Tree docs' sample data, __docs__/dynamic-hashmap.tsx,
is outside the TypeScript project (tsconfig excludes __docs__), so the
plugin warned that it was skipping it. Since the build now fails on any
warning, storybook build stopped there.

The file has no JSX, so it is now dynamic-hashmap.ts, which docgen
does not parse.
Root cause: `build-storybook` loads vite.config.ts with `command: 'build'`,
so the warning-to-error logger from 27b8582 also applied to Storybook. On
the Chromatic runner, Rolldown's PLUGIN_TIMINGS hint ("Your build spent 79%
... inside plugin hooks") is logged through that logger and failed the
build. The hint depends on runner speed, which is why it doesn't reproduce
locally.

Use the throwing logger only when Storybook is not the caller (Storybook
sets STORYBOOK=true before loading the config). Also turn off
`checks.pluginTimings` for the library build, so a slow CI machine can't
fail it with the same hint.
Root cause: four warn-once helpers set their flag to a value unrelated to
whether they warned.

- `is-trigger-tabbable` set it to `false`, so the warning repeated on every
  render.
- `if-one-then-both-required-property`, `only-one-of-properties` and
  `one-of-required-property` set it to `!!selectedProps`, which is always
  true. A valid first render used up the warning, so a later invalid one
  never warned.

Each now sets the flag from its own check, as `required-property` does.
Vite and Rollup warnings are printed again instead of thrown. Failing the
build on any warning made `npm run build`, and Storybook through the shared
config, depend on warnings outside the repo's control: Rolldown's
PLUGIN_TIMINGS hint failed Chromatic on a slow runner.

This reverts the throwing logger and `onwarn` from 27b8582 and the
Storybook carve-out from the previous commit. The redundant
`lib.formats` stays removed, so the build is still warning-free today.
Tests: the console guard now records unexpected console.error and
console.warn output on each test instead of throwing. A new Vitest
reporter (scripts/vitest-console-reporter.ts) lists it after every run
and, on GitHub Actions, annotates each test file and adds a table to the
job summary. The run fails once the total is over `maxWarnings`, which
starts at 0, so today's behaviour is unchanged.

Lint: a formatter (scripts/eslint-github-formatter.cjs) keeps the
stylish output and, on GitHub Actions, annotates each problem on its line
and lists them all in the job summary, since GitHub shows only the first
10 annotations per step. `--max-warnings=35` still decides failure.
React Compiler rules report the same location once per use of the value, so
one ColorPicker line produced 9 identical annotations and filled GitHub's 10
visible annotations. Annotate each location and rule once, with a count. The
job summary still lists every problem, and --max-warnings still counts them.
@interactivellama
interactivellama merged commit 24640a9 into master Nov 20, 2026
7 checks passed
@interactivellama
interactivellama deleted the chore/clean-ci-warnings branch November 20, 2026 23:51
interactivellama added a commit that referenced this pull request Nov 23, 2026
no-style-elements mounts every story, which replays their deprecation and
Modal app-element warnings, and the tooltip browser test passed its trigger
as the deprecated children. The console guard from #3322 counts both. Mock
console in the story sweep, restoring it after cleanup since unmounting a
Modal warns too, and pass the tooltip trigger through trigger.
interactivellama added a commit that referenced this pull request Nov 23, 2026
no-style-elements mounts every story, which replays their deprecation and
Modal app-element warnings, and the tooltip browser test passed its trigger
as the deprecated children. The console guard from #3322 counts both. Mock
console in the story sweep, restoring it after cleanup since unmounting a
Modal warns too, and pass the tooltip trigger through trigger.
interactivellama added a commit that referenced this pull request Nov 24, 2026
no-style-elements mounts every story, which replays their deprecation and
Modal app-element warnings, and the tooltip browser test passed its trigger
as the deprecated children. The console guard from #3322 counts both. Mock
console in the story sweep, restoring it after cleanup since unmounting a
Modal warns too, and pass the tooltip trigger through trigger.
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.

2 participants