From ba15eb2c4cfcad8a6413f736f81c28a4788402fb Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Mon, 7 Sep 2026 17:55:25 -0300 Subject: [PATCH 1/4] Jetpack: run the component tests in CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `jest.config.gui.js` matched `_inc/client/**/test/component.js`. Every component test under `_inc/client/components/` is named `component.jsx`, and `jest.config.client.js` excludes `components/` from its roots, so 20 files ran in neither suite. PR #52015 broke seven of them and CI stayed green for six commits. Matching `.jsx` as well takes the GUI suite from 19 files and 203 tests to 54 and 487. The list stays curated rather than becoming a bare glob, for the reason the comment above it already gives. Two tests in `jetpack-connection-errors.test.jsx` failed once visible, both since before #52015. It rendered through `@testing-library/react` directly, so there was no store for the `reconnect` action's connected `NoticeActionReconnect`; it now uses the shared helper and supplies the state that selector reads. And an assertion that no reconnect CTA is present used a substring match, which the notice's own message satisfies — it now names the action. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01NfGbCrDbhYmgwY5hW68VLA --- .../test/jetpack-connection-errors.test.jsx | 13 ++++++++++--- .../changelog/jetpack-2543-component-tests-in-ci | 5 +++++ projects/plugins/jetpack/tests/jest.config.gui.js | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/jetpack-2543-component-tests-in-ci diff --git a/projects/plugins/jetpack/_inc/client/components/jetpack-notices/test/jetpack-connection-errors.test.jsx b/projects/plugins/jetpack/_inc/client/components/jetpack-notices/test/jetpack-connection-errors.test.jsx index 268da4d0dfa7..d5672998c6c8 100644 --- a/projects/plugins/jetpack/_inc/client/components/jetpack-notices/test/jetpack-connection-errors.test.jsx +++ b/projects/plugins/jetpack/_inc/client/components/jetpack-notices/test/jetpack-connection-errors.test.jsx @@ -1,6 +1,12 @@ -import { render, screen } from '@testing-library/react'; +import { render, screen } from 'test/test-utils'; import JetpackConnectionErrors from '../jetpack-connection-errors'; +// The 'reconnect' action reaches a connected NoticeActionReconnect, which reads +// the site reconnection request state. +const initialState = { + jetpack: { connection: { requests: { reconnectingSite: false } } }, +}; + describe( 'JetpackConnectionErrors', () => { it( 'should render error with URL action', () => { const errors = [ @@ -83,8 +89,9 @@ describe( 'JetpackConnectionErrors', () => { screen.getByText( 'The connection owner needs to reconnect their account.' ) ).toBeInTheDocument(); // No reconnect/restore CTA should be rendered for an informational notice. + // Matched exactly: the notice's own message contains the word "reconnect". expect( screen.queryByRole( 'button' ) ).not.toBeInTheDocument(); - expect( screen.queryByText( 'Reconnect', { exact: false } ) ).not.toBeInTheDocument(); + expect( screen.queryByRole( 'link', { name: 'Restore Connection' } ) ).not.toBeInTheDocument(); } ); it( 'should handle multiple errors correctly', () => { @@ -105,7 +112,7 @@ describe( 'JetpackConnectionErrors', () => { }, ]; - render( ); + render( , { initialState } ); expect( screen.getByText( 'First error' ) ).toBeInTheDocument(); expect( screen.getByText( 'Second error' ) ).toBeInTheDocument(); diff --git a/projects/plugins/jetpack/changelog/jetpack-2543-component-tests-in-ci b/projects/plugins/jetpack/changelog/jetpack-2543-component-tests-in-ci new file mode 100644 index 000000000000..76861c7a5615 --- /dev/null +++ b/projects/plugins/jetpack/changelog/jetpack-2543-component-tests-in-ci @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Test configuration only; no user-facing change. + + diff --git a/projects/plugins/jetpack/tests/jest.config.gui.js b/projects/plugins/jetpack/tests/jest.config.gui.js index 94b4c94a1042..4c765aa6a984 100644 --- a/projects/plugins/jetpack/tests/jest.config.gui.js +++ b/projects/plugins/jetpack/tests/jest.config.gui.js @@ -9,6 +9,8 @@ module.exports = { testMatch: [ '/_inc/client/test/main.js', '/_inc/client/**/test/component.js', + '/_inc/client/**/test/component.jsx', + '/_inc/client/components/**/test/*.test.jsx', '/_inc/client/ai/test/ai-admin.jsx', '/_inc/client/ai/features/test/component.jsx', '/_inc/client/ai/mcp/test/allowlist-updated.jsx', From a26a9761e756ba9446184fa006bb7afd64b207c2 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Tue, 8 Sep 2026 09:19:41 -0300 Subject: [PATCH 2/4] Jetpack: make the 'none' connection-error assertion guard something The replacement assertion could not fail either. `NoticeAction` renders an `` with no `href` when given `onClick`, and an anchor without `href` has no implicit link role, so `queryByRole( 'link' )` returns null whether or not the reconnect CTA is present. The neighbouring `queryByRole( 'button' )` was vacuous for the same shape: every variant of this notice passes `showDismiss={ false }`, so none of them renders a button. Match the CTA by its label instead, and give the test the store state the connected `NoticeActionReconnect` needs, so a regression renders rather than crashes. Broaden the `.test.{js,jsx}` pattern from `components/` to all of `_inc/client`, so a file added under `traffic/` or `at-a-glance/` cannot land in neither suite the same way. `_inc/client` holds exactly two such files today, both already selected; the 20 others live under `jest.config.client.js`'s roots, outside this config's `_inc/client/**` anchor. Drop the seven entries the name globs already match. `jest --listTests` selects the same 54 files before and after. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01NfGbCrDbhYmgwY5hW68VLA --- .../test/jetpack-connection-errors.test.jsx | 9 ++++----- projects/plugins/jetpack/tests/jest.config.gui.js | 13 +++---------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/projects/plugins/jetpack/_inc/client/components/jetpack-notices/test/jetpack-connection-errors.test.jsx b/projects/plugins/jetpack/_inc/client/components/jetpack-notices/test/jetpack-connection-errors.test.jsx index d5672998c6c8..3ed18e1ddc0c 100644 --- a/projects/plugins/jetpack/_inc/client/components/jetpack-notices/test/jetpack-connection-errors.test.jsx +++ b/projects/plugins/jetpack/_inc/client/components/jetpack-notices/test/jetpack-connection-errors.test.jsx @@ -83,15 +83,14 @@ describe( 'JetpackConnectionErrors', () => { }, ]; - render( ); + render( , { initialState } ); expect( screen.getByText( 'The connection owner needs to reconnect their account.' ) ).toBeInTheDocument(); - // No reconnect/restore CTA should be rendered for an informational notice. - // Matched exactly: the notice's own message contains the word "reconnect". - expect( screen.queryByRole( 'button' ) ).not.toBeInTheDocument(); - expect( screen.queryByRole( 'link', { name: 'Restore Connection' } ) ).not.toBeInTheDocument(); + // Matched by label, not by role: NoticeAction renders an with no href, which + // has no implicit link role, so queryByRole( 'link' ) can never fail here. + expect( screen.queryByText( 'Restore Connection' ) ).not.toBeInTheDocument(); } ); it( 'should handle multiple errors correctly', () => { diff --git a/projects/plugins/jetpack/tests/jest.config.gui.js b/projects/plugins/jetpack/tests/jest.config.gui.js index 4c765aa6a984..a1d0b7f318f0 100644 --- a/projects/plugins/jetpack/tests/jest.config.gui.js +++ b/projects/plugins/jetpack/tests/jest.config.gui.js @@ -3,28 +3,21 @@ const baseConfig = require( './jest.config.base.js' ); module.exports = { ...baseConfig, roots: [ '/_inc/client/' ], - // Curated rather than a glob: `**/test/*.js` would also pick up the many - // `test/fixtures.js` files (which contain no tests) and re-run the + // Matched by filename rather than a bare `**/test/*`: that would also pick up the + // many `test/fixtures.js` files (which contain no tests) and re-run the // `_inc/client/state/` suites that jest.config.client.js already owns. testMatch: [ '/_inc/client/test/main.js', '/_inc/client/**/test/component.js', '/_inc/client/**/test/component.jsx', - '/_inc/client/components/**/test/*.test.jsx', + '/_inc/client/**/test/*.test.{js,jsx}', '/_inc/client/ai/test/ai-admin.jsx', - '/_inc/client/ai/features/test/component.jsx', '/_inc/client/ai/mcp/test/allowlist-updated.jsx', '/_inc/client/ai/mcp/test/use-mcp-settings.jsx', - '/_inc/client/ai/overview/assistant-banner/test/component.jsx', - '/_inc/client/ai/overview/test/component.jsx', '/_inc/client/ai/scheduled-tasks/test/index.jsx', '/_inc/client/ai/scheduled-tasks/test/use-scheduled-tasks.js', '/_inc/client/ai/test/main.jsx', '/_inc/client/ai/test/tracks.js', - '/_inc/client/at-a-glance/boost/test/component.jsx', - '/_inc/client/components/jetpack-notices/test/state-notices.test.jsx', - '/_inc/client/sharing/test/component.jsx', - '/_inc/client/traffic/test/component.jsx', '/_inc/client/at-a-glance/stats/test/chart-bar-range.js', ], setupFilesAfterEnv: [ ...baseConfig.setupFilesAfterEnv, '/tests/jest-globals.gui.js' ], From 3899e87ab2a0e6e756b6d9aee39846da77aa39d6 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Tue, 8 Sep 2026 12:12:01 -0300 Subject: [PATCH 3/4] Jetpack: fold the component.js and component.jsx patterns together Matches the `*.test.{js,jsx}` glob on the line below. Four `component.js` files remain under `_inc/client`, so both extensions are still needed. `jest --listTests` selects the same 54 files before and after. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01NfGbCrDbhYmgwY5hW68VLA --- projects/plugins/jetpack/tests/jest.config.gui.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/plugins/jetpack/tests/jest.config.gui.js b/projects/plugins/jetpack/tests/jest.config.gui.js index a1d0b7f318f0..282373d35e60 100644 --- a/projects/plugins/jetpack/tests/jest.config.gui.js +++ b/projects/plugins/jetpack/tests/jest.config.gui.js @@ -8,8 +8,7 @@ module.exports = { // `_inc/client/state/` suites that jest.config.client.js already owns. testMatch: [ '/_inc/client/test/main.js', - '/_inc/client/**/test/component.js', - '/_inc/client/**/test/component.jsx', + '/_inc/client/**/test/component.{js,jsx}', '/_inc/client/**/test/*.test.{js,jsx}', '/_inc/client/ai/test/ai-admin.jsx', '/_inc/client/ai/mcp/test/allowlist-updated.jsx', From 35110470cc508ab17c1866554569ddec04109d30 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Tue, 8 Sep 2026 12:14:13 -0300 Subject: [PATCH 4/4] Jetpack: add a positive control for the connection-error CTA query The 'none' case asserts the reconnect CTA is absent. Nothing proved that query could see the CTA when it is present, so the assertion could rot back into a no-op without anyone noticing. The multiple-errors test already renders a `reconnect` action, so it can carry the control. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01NfGbCrDbhYmgwY5hW68VLA --- .../jetpack-notices/test/jetpack-connection-errors.test.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/plugins/jetpack/_inc/client/components/jetpack-notices/test/jetpack-connection-errors.test.jsx b/projects/plugins/jetpack/_inc/client/components/jetpack-notices/test/jetpack-connection-errors.test.jsx index 3ed18e1ddc0c..5b55b332be4e 100644 --- a/projects/plugins/jetpack/_inc/client/components/jetpack-notices/test/jetpack-connection-errors.test.jsx +++ b/projects/plugins/jetpack/_inc/client/components/jetpack-notices/test/jetpack-connection-errors.test.jsx @@ -116,5 +116,7 @@ describe( 'JetpackConnectionErrors', () => { expect( screen.getByText( 'First error' ) ).toBeInTheDocument(); expect( screen.getByText( 'Second error' ) ).toBeInTheDocument(); expect( screen.getByText( 'Fix Issue' ) ).toBeInTheDocument(); + // Positive control for the 'none' case above: proves this query can see the CTA. + expect( screen.getByText( 'Restore Connection' ) ).toBeInTheDocument(); } ); } );