test(ui-library): add React render smoke test on React 18.3 and 19.2#23320
Open
enricobattocchi wants to merge 3 commits into
Open
test(ui-library): add React render smoke test on React 18.3 and 19.2#23320enricobattocchi wants to merge 3 commits into
enricobattocchi wants to merge 3 commits into
Conversation
Coverage Report for CI Build 0Coverage decreased (-0.4%) to 57.252%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
Render every exported visual component with only its required props inside `<Root>` and assert it mounts without throwing. Omitting optional props is exactly what surfaces the React 19 class of bug where a dropped `defaultProps` default becomes `undefined` and is dereferenced, so this catches that class in isolation, without a WordPress environment. The test is React-version-agnostic (it uses whatever React is installed); it has been verified green on both React 18.3.1 (WP 7.0) and React 19.2.4 (Gutenberg 23.3 RC / WP 7.1). Adds `@testing-library/react` and a `test` script, and excludes the disabled storyshots suite from `jest`. Refs: Yoast/reserved-tasks#231, Yoast/reserved-tasks#246 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add `ui-library` to the `yarn-test-full` matrix so its new render smoke test runs in CI on the default (lockfile) React 18.3. Add a dedicated `yarn-test-react19` job that runs the same test against React 19.2.4 (what WordPress 7.1 / the Gutenberg 23.3 RC ships), forcing the version across the workspace via a yarn `resolution` (a plain `yarn add -W` would not override packages that pin react@^18 themselves). @testing-library/react v16 supports both React versions, so only react/react-dom are pinned. The React-19 leg is scoped to ui-library for now rather than added as an axis on the full matrix, because other packages are not React-19-ready yet (e.g. `components` still uses `react-test-renderer`, removed in React 19). Widen the matrix as those are addressed. Refs: Yoast/reserved-tasks#231, Yoast/reserved-tasks#246 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The smoke test rendered some components with optional props that masked default-driven bugs (it passed `steps` to Stepper, hiding the empty-default render loop). Add cases that render the compound components via their `children` path with the data prop omitted (Stepper, CheckboxGroup, RadioGroup, Select), plus a required-only ImageSelect case, so the defaults are exercised. Verified: 58/58 pass on React 18.3.1, and a negative control (reverting the Stepper `DEFAULT_STEPS` fix) makes the new Stepper case fail with "Maximum update depth exceeded", confirming it catches the loop class. The React 19.2 leg runs via the jstest.yml matrix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
facd95c to
ee50099
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
React 19's automatic JSX runtime no longer applies
defaultPropsto function/forwardRefcomponents, which crashed@yoast/ui-libraryrendering (the Yoast metabox/sidebar/Settings). That was fixed by converting the components to ES6 default params in #23317.To stop that class of regression coming back silently, this PR adds a render smoke test that mounts every
@yoast/ui-librarycomponent and asserts it renders without throwing, run in CI on both React 18.3 and React 19.2. A failure on either runtime means a component lost a default (or otherwise fails to mount).Part of the React 19 readiness work tracked in Yoast/reserved-tasks#235.
Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
packages/ui-library/tests/react-render-smoke.test.js) renders each exported component with the minimal required props and asserts it mounts without throwing; the default-state render paths exercise the components whose defaults previously came fromdefaultProps..github/workflows/jstest.yml) runs the suite against React 18.3 and React 19.2, so the same test guards both the current and upcoming runtimes.Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
packages/ui-library, runnpx jest tests/react-render-smoke.test.js. Every component should render with no thrown errors.Relevant test scenarios
None of the above apply: this is a Jest/jsdom test run in CI, not a browser or editor test. The meaningful check is the smoke suite passing on both the React 18.3 and React 19.2 CI legs.
Test instructions for QA when the code is in the RC
QA can test this PR by following these steps:
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
packages/ui-library/tests/, the ui-library jest config, and.github/workflows/jstest.yml. No runtime / shipped-code impact.Other environments
[shopify-seo], added test instructions for Shopify and attached theShopifylabel to this PR.[yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached theGoogle Docs Add-onlabel to this PR.Documentation
Quality assurance
grunt build:imagesand committed the results, if my PR introduces or edits images or SVGs.Innovation
innovationlabel.Refs Yoast/reserved-tasks#235, Yoast/reserved-tasks#1251
🤖 Generated with Claude Code