Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update npm dependencies (especially @wordpress) #7695

Draft
wants to merge 23 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion assets/admin/editor-wizard/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe( 'useWizardOpenState', () => {
expect( await findByText( 'closed' ) ).toBeTruthy();

document.body.classList.remove( 'modal-open' );
expect( findByText( 'open' ) ).toBeTruthy();
expect( await findByText( 'open' ) ).toBeTruthy();
} );

it( 'Should be closed when wizard is done', async () => {
Expand Down
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 @@ -6,7 +6,7 @@ import useAbortController from '.';
/**
* External dependencies
*/
import { cleanup, renderHook } from '@testing-library/react-hooks';
import { cleanup, renderHook } from '@testing-library/react';

describe( 'useAbortController', () => {
it( 'Should return signal to be used on async operations', () => {
Expand Down
14 changes: 8 additions & 6 deletions assets/admin/students/student-bulk-action-button/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ describe( '<StudentBulkActionButton />', () => {
expect( button ).toBeDisabled();
} );

it( 'Should render the `Add to course` modal', () => {
it( 'Should render the `Add to course` modal', async () => {
setupSelector( [
{ value: 'enrol_restore_enrolment', selected: true },
{ value: 'remove_progress' },
{ value: 'remove_enrolment' },
] );
render( <StudentBulkActionButton isDisabled={ false } /> );

selectActionButton().click();
await selectActionButton().click();

expect(
screen.getByText(
ignoreInlineTags(
Expand All @@ -80,15 +81,15 @@ describe( '<StudentBulkActionButton />', () => {
).toBeInTheDocument();
} );

it( 'Should render the `Reset Progress` modal', () => {
it( 'Should render the `Reset Progress` modal', async () => {
setupSelector( [
{ value: 'enrol_restore_enrolment' },
{ value: 'remove_progress', selected: true },
{ value: 'remove_enrolment' },
] );
render( <StudentBulkActionButton isDisabled={ false } /> );

selectActionButton().click();
await selectActionButton().click();

expect(
screen.getByText(
Expand All @@ -98,15 +99,16 @@ describe( '<StudentBulkActionButton />', () => {
)
).toBeInTheDocument();
} );
it( 'Should render the `Remove from Course` modal', () => {
it( 'Should render the `Remove from Course` modal', async () => {
setupSelector( [
{ value: 'enrol_restore_enrolment' },
{ value: 'remove_progress' },
{ value: 'remove_enrolment', selected: true },
] );
render( <StudentBulkActionButton isDisabled={ false } /> );

selectActionButton().click();
await selectActionButton().click();

expect(
screen.getByText(
ignoreInlineTags(
Expand Down
26 changes: 14 additions & 12 deletions assets/admin/students/student-modal/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,14 @@ describe( '<StudentModal />', () => {
/>
);

fireEvent.click( await courseOptionAt( 0 ) );
fireEvent.click( await buttonByLabel( 'Add to Course' ) );
await fireEvent.click( await courseOptionAt( 0 ) );
await fireEvent.click( await buttonByLabel( 'Add to Course' ) );

expect(
await findAllByText(
'Unable to add student. Please try again.'
)
).toHaveLength( 2 ); // ARIA + notice
).toBeTruthy();
} );

it( 'Should display an error message when removing a student from a course', async () => {
Expand All @@ -363,7 +363,7 @@ describe( '<StudentModal />', () => {
await findAllByText(
'Unable to remove student. Please try again.'
)
).toHaveLength( 2 ); // ARIA + notice
).toBeTruthy();
} );

it( 'Should display an error message when resetting progress for a single student', async () => {
Expand All @@ -383,7 +383,7 @@ describe( '<StudentModal />', () => {
await findAllByText(
'Unable to reset progress for this student. Please try again.'
)
).toHaveLength( 2 ); // ARIA + notice
).toBeTruthy();
} );
} );

Expand Down Expand Up @@ -437,14 +437,14 @@ describe( '<StudentModal />', () => {
/>
);

fireEvent.click( await courseOptionAt( 0 ) );
fireEvent.click( await buttonByLabel( 'Add to Course' ) );
await fireEvent.click( await courseOptionAt( 0 ) );
await fireEvent.click( await buttonByLabel( 'Add to Course' ) );

expect(
await findAllByText(
'Unable to add students. Please try again.'
)
).toHaveLength( 2 ); // ARIA + notice
).toBeTruthy();
} );

it( 'Should display an error message when removing multiple students from a course', async () => {
Expand All @@ -456,14 +456,16 @@ describe( '<StudentModal />', () => {
/>
);

fireEvent.click( await courseOptionAt( 0 ) );
fireEvent.click( await buttonByLabel( 'Remove from Course' ) );
await fireEvent.click( await courseOptionAt( 0 ) );
await fireEvent.click(
await buttonByLabel( 'Remove from Course' )
);

expect(
await findAllByText(
'Unable to remove students. Please try again.'
)
).toHaveLength( 2 ); // ARIA + notice
).toBeTruthy();
} );

it( 'Should display an error message when resetting progress for multiple students', async () => {
Expand All @@ -482,7 +484,7 @@ describe( '<StudentModal />', () => {
await findAllByText(
'Unable to reset progress for these students. Please try again.'
)
).toHaveLength( 2 ); // ARIA + notice
).toBeTruthy();
} );
} );
} );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
/**
* Internal dependencies
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
import { when } from 'jest-when';
/**
* WordPress dependencies
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
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react';
/**
* Internal dependencies
*/
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
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { renderHook, act } from '@testing-library/react-hooks';
import { renderHook, act } from '@testing-library/react';

/**
* Internal dependencies
Expand Down Expand Up @@ -34,16 +34,15 @@ describe( 'useConfirmDialogProps()', () => {
const { result } = renderHook( () => useConfirmDialogProps() );
let [ props, confirm ] = result.current;
expect( props.isOpen ).toBe( false );
const confirmResponse = act( () =>
act( () => {
// eslint-disable-next-line jest/valid-expect
expect(
confirm( 'Hey Content', { title: 'Hey Title' } )
).resolves.toBe( true )
);
).resolves.toBe( true );
} );
[ props, confirm ] = result.current;
expect( props.isOpen ).toBe( true );
act( () => props.onConfirm() );
// We need to verify AFTER calling the props.on* callback, otherwise, the promise won't be resolved yet.
await confirmResponse;
[ props, confirm ] = result.current;
expect( props.isOpen ).toBe( false );
} );
Expand All @@ -52,16 +51,15 @@ describe( 'useConfirmDialogProps()', () => {
const { result } = renderHook( () => useConfirmDialogProps() );
let [ props, confirm ] = result.current;
expect( props.isOpen ).toBe( false );
const confirmResponse = act( () =>
act( () => {
// eslint-disable-next-line jest/valid-expect
expect(
confirm( 'Hey Content', { title: 'Hey Title' } )
).resolves.toBe( false )
);
).resolves.toBe( false );
} );
[ props, confirm ] = result.current;
expect( props.isOpen ).toBe( true );
act( () => props.onCancel() );
// We need to verify AFTER calling the props.on* callback, otherwise, the promise won't be resolved yet.
await confirmResponse;
[ props, confirm ] = result.current;
expect( props.isOpen ).toBe( false );
} );
Expand Down
Loading
Loading