Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
997d43b
Update WP dependencies: api-fetch
renatho Oct 29, 2024
50fb1fc
Update WP dependencies: block-editor, blocks and element
renatho Oct 29, 2024
ac9f91b
Update WP dependencies: blocks, compose, and core-data
renatho Oct 29, 2024
049ac84
Update WP dependencies: data
renatho Oct 29, 2024
710033b
Update WP dependencies: data-controls, dom-ready
renatho Oct 29, 2024
4ec6f50
Update WP dependencies: escape-html, hooks
renatho Oct 29, 2024
74c28c2
Update WP dependencies: html-entities, keycodes, plugins, token-list,…
renatho Oct 29, 2024
2c0dcb4
Update WP dependencies: i18n
renatho Oct 29, 2024
21c0b6f
Replace calypso-build with wp-scripts
renatho Oct 30, 2024
971f3f2
Fix key
renatho Oct 30, 2024
6ca3cf5
Install specific version of sass and sass-loader
renatho Oct 31, 2024
6b09ac8
Update some dev dependencies
renatho Oct 31, 2024
31bc767
Point the renderHook to the new dependency
renatho Oct 31, 2024
d4d1f7e
Solve some dependency issues
renatho Nov 1, 2024
0b4e592
Update babel dependencies
m1r0 Nov 5, 2024
5c7e889
Fix tests failing because of `userEvent`
m1r0 Nov 5, 2024
ab5f7be
Fix JS unit tests
m1r0 Nov 5, 2024
0256973
Fix linters
m1r0 Nov 6, 2024
e98cc75
Remove unused lodash type
m1r0 Nov 6, 2024
65cd943
Update `@wordpress/base-styles`
m1r0 Nov 7, 2024
f04df1d
Update the rest of the wordpress packages
m1r0 Nov 7, 2024
d92b556
Add changelog
m1r0 Nov 7, 2024
8ab8e3e
Update `@automattic/components` and `@automattic/tour-kit`
m1r0 Nov 11, 2024
b3bb3ca
Merge branch 'trunk' into update/wordpress-dependencies
m1r0 Jan 15, 2025
8665b07
Downgrade packages to minimum supported WP version - `wp-6.5`
m1r0 Jan 15, 2025
ac8eb55
Fix eslint parser
m1r0 Jan 15, 2025
0435314
Remove old eslint rule
m1r0 Jan 15, 2025
5f45252
Fix eslint error
m1r0 Jan 15, 2025
2767fb7
Fix lodash lint-types
m1r0 Jan 15, 2025
3594025
Fix multiple versions of `@wordpress/private-apis` causing tests to fail
m1r0 Jan 16, 2025
73b1ca7
Merge branch 'trunk' of github.com:Automattic/sensei into update/word…
renatho Mar 20, 2025
4a2153c
Update and clean up dependencies
renatho Mar 21, 2025
7bcaefb
Fix prettier configuration
renatho Mar 21, 2025
8da4bfe
Uninstall webpack
renatho Mar 21, 2025
33cf73c
Use dependencies from WP 6.7 for now since WP 6.8 was not released yet
renatho Mar 21, 2025
9a50543
Update tests
renatho Mar 21, 2025
646e072
Run audit fix
renatho Mar 21, 2025
1e6c3ab
Make sure it will use the wp-prettier
renatho Mar 21, 2025
731ff5e
Update tests dependencies
renatho Mar 24, 2025
6b84b85
Fix mock
renatho Mar 24, 2025
400297f
Fix expectation finding multiple texts
renatho Mar 24, 2025
fb67d07
Use custom registry to test stores
renatho Mar 24, 2025
e89f389
Mock dependencies to fix test errors
renatho Mar 24, 2025
b3be22b
Fix click events
renatho Mar 24, 2025
a9ceea2
Revert sass loader check
renatho Mar 24, 2025
2ca60ad
Update event with click
renatho Mar 24, 2025
f412430
Fix issues with the color-zip dependency
renatho Mar 24, 2025
6a0bd7c
Move React from devDependencies to dependencies
renatho Mar 24, 2025
82ca947
Fix lint issues
renatho Mar 24, 2025
ff83253
Fix TS lint issues
renatho Mar 24, 2025
3d9f0ea
Replace deprecated setting
renatho Mar 24, 2025
cd5e498
Use screen instead, following Kent C Dodds recommendation
renatho Mar 24, 2025
373c916
Fix checkbox style after dependency update
renatho Mar 25, 2025
825da2f
Merge branch 'trunk' of github.com:Automattic/sensei into update/word…
renatho Mar 25, 2025
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
Prev Previous commit
Next Next commit
Fix tests failing because of userEvent
  • Loading branch information
m1r0 committed Nov 5, 2024
commit 5c7e88932961001d2ec2df66464af35e69df1afe
22 changes: 12 additions & 10 deletions assets/admin/exit-survey/form.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,52 @@ describe( '<ExitSurveyForm />', () => {
skip: () => screen.getByRole( 'button', { name: 'Skip Feedback' } ),
};

it( 'Submit is disabled until an item is selected and details filled out (if provided)', () => {
it( 'Submit is disabled until an item is selected and details filled out (if provided)', async () => {
const { getByLabelText, getByPlaceholderText } = render(
<ExitSurveyForm />
);

expect( buttons.submit() ).toBeDisabled();

// This reason does not require details.
userEvent.click( getByLabelText( 'I no longer need the plugin' ) );
await userEvent.click(
getByLabelText( 'I no longer need the plugin' )
);
expect( buttons.submit() ).not.toBeDisabled();

// This reason does expect details.
userEvent.click( getByLabelText( 'I found a better plugin' ) );
await userEvent.click( getByLabelText( 'I found a better plugin' ) );
expect( buttons.submit() ).toBeDisabled();
userEvent.type(
await userEvent.type(
getByPlaceholderText( "What's the name of the plugin?" ),
'Test detail'
);

expect( buttons.submit() ).not.toBeDisabled();
} );

it( 'Skip button skips submission', () => {
it( 'Skip button skips submission', async () => {
const skip = jest.fn();
const submit = jest.fn();
render( <ExitSurveyForm submit={ submit } skip={ skip } /> );
userEvent.click( buttons.skip() );
await userEvent.click( buttons.skip() );

expect( skip ).toHaveBeenCalled();
expect( submit ).not.toHaveBeenCalled();
} );

it( 'Submits selected reason and details', () => {
it( 'Submits selected reason and details', async () => {
const submit = jest.fn();
const { getByLabelText, getByPlaceholderText } = render(
<ExitSurveyForm submit={ submit } />
);

userEvent.click( getByLabelText( 'I found a better plugin' ) );
userEvent.type(
await userEvent.click( getByLabelText( 'I found a better plugin' ) );
await userEvent.type(
getByPlaceholderText( "What's the name of the plugin?" ),
'Test detail'
);
userEvent.click( buttons.submit() );
await userEvent.click( buttons.submit() );

expect( submit ).toHaveBeenCalledWith( {
reason: 'found-better-plugin',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,19 @@ describe( '<OutlinePlaceholder />', () => {
expect( getByText( 'Generate with AI' ) ).toBeVisible();
} );

it( 'Should create empty lessons', () => {
it( 'Should create empty lessons', async () => {
const { getByRole } = render(
<OutlinePlaceholder addBlocks={ addBlocksMock } />
);

userEvent.click( getByRole( 'button', { name: 'Start with blank' } ) );
await userEvent.click(
getByRole( 'button', { name: 'Start with blank' } )
);

expect( addBlocksMock ).toHaveBeenCalled();
} );

it( 'Should open the tailored modal', () => {
it( 'Should open the tailored modal', async () => {
const openTailoredModalMock = jest.fn();

const { getByRole } = render(
Expand All @@ -56,7 +58,7 @@ describe( '<OutlinePlaceholder />', () => {
/>
);

userEvent.click(
await userEvent.click(
getByRole( 'button', { name: 'Generate with AI Pro' } )
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ describe( '<StatusControl />', () => {
setStatus={ setStatusMock }
/>
);
userEvent.click( getByLabelText( 'Completed' ) );
await userEvent.click( getByLabelText( 'Completed' ) );
expect( setStatusMock ).toBeCalledWith( Status.COMPLETED );

userEvent.click( getByLabelText( 'In Progress' ) );
await userEvent.click( getByLabelText( 'In Progress' ) );
expect( setStatusMock ).toBeCalledWith( Status.IN_PROGRESS );
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe( '<LimitedTextControl />', () => {
expect( queryByText( 'Characters: 10/20' ) ).toBeTruthy();
} );

it( 'Should not call the `onChange` method when already at maxLength capacity', () => {
it( 'Should not call the `onChange` method when already at maxLength capacity', async () => {
const onChangeMock = jest.fn();
const { queryByRole } = render(
<LimitedTextControl
Expand All @@ -65,12 +65,12 @@ describe( '<LimitedTextControl />', () => {
/>
);

userEvent.type( queryByRole( 'textbox' ), 'DEF' );
await userEvent.type( queryByRole( 'textbox' ), 'DEF' );

expect( onChangeMock ).toHaveBeenCalledTimes( 0 );
} );

it( 'Should ignore new lines', () => {
it( 'Should ignore new lines', async () => {
const onChangeMock = jest.fn();
const { queryByRole } = render(
<LimitedTextControl
Expand All @@ -82,7 +82,7 @@ describe( '<LimitedTextControl />', () => {

const element = queryByRole( 'textbox' );

userEvent.type( element, '{enter}' );
await userEvent.type( element, '{enter}' );

expect( onChangeMock ).toHaveBeenCalledTimes( 0 );
} );
Expand Down Expand Up @@ -144,7 +144,7 @@ describe( '<LimitedTextControl multiline={ true }/>', () => {
expect( queryByText( 'Characters: 10/20' ) ).toBeTruthy();
} );

it( 'Should not call the `onChange` method when already at maxLength capacity', () => {
it( 'Should not call the `onChange` method when already at maxLength capacity', async () => {
const onChangeMock = jest.fn();
const { queryByRole } = render(
<LimitedTextControl
Expand All @@ -155,12 +155,12 @@ describe( '<LimitedTextControl multiline={ true }/>', () => {
/>
);

userEvent.type( queryByRole( 'textbox' ), 'DEF' );
await userEvent.type( queryByRole( 'textbox' ), 'DEF' );

expect( onChangeMock ).toHaveBeenCalledTimes( 0 );
} );

it( 'Should accept new lines', () => {
it( 'Should accept new lines', async () => {
const onChangeMock = jest.fn();
const { queryByRole } = render(
<LimitedTextControl
Expand All @@ -173,7 +173,7 @@ describe( '<LimitedTextControl multiline={ true }/>', () => {

const element = queryByRole( 'textbox' );

userEvent.type( element, '{enter}' );
await userEvent.type( element, '{enter}' );

expect( onChangeMock ).toHaveBeenCalledTimes( 1 );
} );
Expand Down
4 changes: 2 additions & 2 deletions assets/shared/blocks/block-metadata.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe( 'Block metadata', () => {
expect( getByText( 'Block metadata' ) ).toBeTruthy();
} );

it( 'Provides metadata setter to block', () => {
it( 'Provides metadata setter to block', async () => {
const Block = withBlockMeta( ( { setMeta } ) => (
<button
onClick={ () => setMeta( { secondTestMeta: 'clicked' } ) }
Expand All @@ -102,7 +102,7 @@ describe( 'Block metadata', () => {
</button>
) );
const { getByText } = render( <Block clientId="test-block-4" /> );
userEvent.click( getByText( 'Update' ) );
await userEvent.click( getByText( 'Update' ) );

const meta = select( STORE ).getBlockMeta(
'test-block-4',
Expand Down
12 changes: 6 additions & 6 deletions assets/shared/blocks/single-line-input/single-line-input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ describe( '<SingleLineInput />', () => {
expect( onChangeMock ).toBeCalledWith( 'changed' );
} );

it( 'Should not allow line breaks', () => {
it( 'Should not allow line breaks', async () => {
const onChangeMock = jest.fn();
const { getByRole } = render(
<SingleLineInput onChange={ onChangeMock } />
);

userEvent.type( getByRole( 'textbox' ), 'input {enter}line' );
await userEvent.type( getByRole( 'textbox' ), 'input {enter}line' );

expect( onChangeMock ).toHaveBeenLastCalledWith( 'input line' );
} );

it( 'Calls onRemove on backspace with an empty title', () => {
it( 'Calls onRemove on backspace with an empty title', async () => {
const onRemoveMock = jest.fn();
const { getByRole } = render(
<SingleLineInput
Expand All @@ -59,18 +59,18 @@ describe( '<SingleLineInput />', () => {
/>
);

userEvent.type( getByRole( 'textbox' ), '{backspace}' );
await userEvent.type( getByRole( 'textbox' ), '{backspace}' );

expect( onRemoveMock ).toHaveBeenCalledTimes( 1 );
} );

it( 'Calls onEnter on enter', () => {
it( 'Calls onEnter on enter', async () => {
const onEnterMock = jest.fn();
const { getByRole } = render(
<SingleLineInput onEnter={ onEnterMock } onChange={ jest.fn() } />
);

userEvent.type( getByRole( 'textbox' ), 'Title{enter}' );
await userEvent.type( getByRole( 'textbox' ), 'Title{enter}' );

expect( onEnterMock ).toHaveBeenCalledTimes( 1 );
} );
Expand Down