Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down Expand Up @@ -77,14 +83,14 @@ describe( 'JetpackConnectionErrors', () => {
},
];

render( <JetpackConnectionErrors errors={ errors } /> );
render( <JetpackConnectionErrors errors={ errors } />, { initialState } );

expect(
screen.getByText( 'The connection owner needs to reconnect their account.' )
).toBeInTheDocument();
// No reconnect/restore CTA should be rendered for an informational notice.
expect( screen.queryByRole( 'button' ) ).not.toBeInTheDocument();
expect( screen.queryByText( 'Reconnect', { exact: false } ) ).not.toBeInTheDocument();
// Matched by label, not by role: NoticeAction renders an <a> 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', () => {
Expand All @@ -105,10 +111,12 @@ describe( 'JetpackConnectionErrors', () => {
},
];

render( <JetpackConnectionErrors errors={ errors } /> );
render( <JetpackConnectionErrors errors={ errors } />, { initialState } );

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();
} );
} );
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Test configuration only; no user-facing change.


14 changes: 4 additions & 10 deletions projects/plugins/jetpack/tests/jest.config.gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,20 @@ const baseConfig = require( './jest.config.base.js' );
module.exports = {
...baseConfig,
roots: [ '<rootDir>/_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: [
'<rootDir>/_inc/client/test/main.js',
'<rootDir>/_inc/client/**/test/component.js',
'<rootDir>/_inc/client/**/test/component.{js,jsx}',
'<rootDir>/_inc/client/**/test/*.test.{js,jsx}',
'<rootDir>/_inc/client/ai/test/ai-admin.jsx',
'<rootDir>/_inc/client/ai/features/test/component.jsx',
'<rootDir>/_inc/client/ai/mcp/test/allowlist-updated.jsx',
'<rootDir>/_inc/client/ai/mcp/test/use-mcp-settings.jsx',
'<rootDir>/_inc/client/ai/overview/assistant-banner/test/component.jsx',
'<rootDir>/_inc/client/ai/overview/test/component.jsx',
'<rootDir>/_inc/client/ai/scheduled-tasks/test/index.jsx',
'<rootDir>/_inc/client/ai/scheduled-tasks/test/use-scheduled-tasks.js',
'<rootDir>/_inc/client/ai/test/main.jsx',
'<rootDir>/_inc/client/ai/test/tracks.js',
'<rootDir>/_inc/client/at-a-glance/boost/test/component.jsx',
'<rootDir>/_inc/client/components/jetpack-notices/test/state-notices.test.jsx',
'<rootDir>/_inc/client/sharing/test/component.jsx',
'<rootDir>/_inc/client/traffic/test/component.jsx',
'<rootDir>/_inc/client/at-a-glance/stats/test/chart-bar-range.js',
],
setupFilesAfterEnv: [ ...baseConfig.setupFilesAfterEnv, '<rootDir>/tests/jest-globals.gui.js' ],
Expand Down
Loading