Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
...require( '@wordpress/prettier-config' ),
plugins: [ './scripts/prettier/prettier-plugin-jsdoc' ],
plugins: [ './scripts/prettier/prettier-plugin-jsdoc.js' ],
};
11 changes: 4 additions & 7 deletions assets/admin/editor-wizard/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import { EXTENSIONS_STORE } from '../../extensions/store';
* Update blocks content, replacing the placeholders with a content.
*
* @param {Object[]} blocks Blocks to replace with the new content.
* @param {Object} replaces Object containing content to be replaced. The keys are the block
* classNames to find. The values are the content to be replaced.
* @param {Object} replaces Object containing content to be replaced. The keys are the block classNames to find. The values are the content to be replaced.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Sensei LMS we have some custom plugin to apply a prettier fix to JSDoc.

It's broken for multiline now, so as a short-term fix, I just changed it to single line where needed.

*
* @return {Object[]} Blocks with the placeholders filled.
*/
Expand Down Expand Up @@ -103,8 +102,7 @@ export const useWizardOpenState = () => {
/**
* Hook to set the default post pattern with replaced content.
*
* @param {Object} replaces Object containing content to be replaced. The keys are the block
* classNames to find. The values are the content to be replaced.
* @param {Object} replaces Object containing content to be replaced. The keys are the block classNames to find. The values are the content to be replaced.
*
* @return {Function} Function to set the default pattern.
*/
Expand Down Expand Up @@ -168,9 +166,8 @@ export const useLogEvent = () => {
export const useHideEditorWizardUpsell = () => {
const { senseiProExtension } = useSelect(
( select ) => ( {
senseiProExtension: select(
EXTENSIONS_STORE
).getSenseiProExtension(),
senseiProExtension:
select( EXTENSIONS_STORE ).getSenseiProExtension(),
} ),
[]
);
Expand Down
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
5 changes: 2 additions & 3 deletions assets/admin/editor-wizard/steps/course-upgrade-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ import CheckIcon from '../../../icons/checked.svg';
const CourseUpgradeStep = () => {
const { senseiProExtension } = useSelect(
( select ) => ( {
senseiProExtension: select(
EXTENSIONS_STORE
).getSenseiProExtension(),
senseiProExtension:
select( EXTENSIONS_STORE ).getSenseiProExtension(),
} ),
[]
);
Expand Down
4 changes: 1 addition & 3 deletions assets/admin/editor-wizard/steps/patterns-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ const { Fill, Slot } = createSlotFill( 'Patterns Upsell' );
*
* @param {Object} props Component props.
* @param {string} props.title Step title.
* @param {Object} props.replaces Object containing content to be replaced. The keys are the
* block classNames to find. The values are the content to be
* replaced.
* @param {Object} props.replaces Object containing content to be replaced. The keys are the block classNames to find. The values are the content to be replaced.
* @param {Function} props.onCompletion On completion callback.
*/
const PatternsStep = ( { title, replaces, onCompletion } ) => {
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
7 changes: 4 additions & 3 deletions assets/admin/students/hooks/use-abort-controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ export default function useAbortController() {
return () => getAbortController().abort();
}, [ getAbortController ] );

const getSignal = useCallback( () => getAbortController().signal, [
getAbortController,
] );
const getSignal = useCallback(
() => getAbortController().signal,
[ getAbortController ]
);

return { getSignal };
}
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
21 changes: 4 additions & 17 deletions assets/admin/students/student-action-menu/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { act, fireEvent, render, screen } from '@testing-library/react';
/**
* WordPress dependencies
*/
import { DOWN } from '@wordpress/keycodes';
import { useSelect } from '@wordpress/data';

/**
Expand Down Expand Up @@ -38,10 +37,7 @@ describe( '<StudentActionMenu />', () => {
const button = screen.getByRole( 'button' );

button.focus();
fireEvent.keyDown( button, {
keyCode: DOWN,
preventDefault: () => {},
} );
fireEvent.click( button );

// Click the "Add to Course" menu item.
const menuItem = screen.getByText( 'Add to Course' );
Expand All @@ -63,10 +59,7 @@ describe( '<StudentActionMenu />', () => {
const button = screen.getByRole( 'button' );

button.focus();
fireEvent.keyDown( button, {
keyCode: DOWN,
preventDefault: () => {},
} );
fireEvent.click( button );

// Click the "Remove from Course" menu item.
const menuItem = screen.getByText( 'Remove from Course' );
Expand All @@ -88,10 +81,7 @@ describe( '<StudentActionMenu />', () => {
const button = screen.getByRole( 'button' );

button.focus();
fireEvent.keyDown( button, {
keyCode: DOWN,
preventDefault: () => {},
} );
fireEvent.click( button );

// Click the "Reset Progress" menu item.
const menuItem = screen.getByText( 'Reset Progress' );
Expand All @@ -115,10 +105,7 @@ describe( '<StudentActionMenu />', () => {
const button = screen.getByRole( 'button' );

button.focus();
fireEvent.keyDown( button, {
keyCode: DOWN,
preventDefault: () => {},
} );
fireEvent.click( button );

// Click the "Grading" menu item.
const menuItem = screen.getByText( 'Grading' );
Expand Down
46 changes: 31 additions & 15 deletions assets/admin/students/student-bulk-action-button/index.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { render, screen } from '@testing-library/react';
import { render, screen, fireEvent } from '@testing-library/react';

/**
* WordPress dependencies
Expand Down Expand Up @@ -45,11 +45,6 @@ beforeAll( () => {
spy = jest.spyOn( document, 'getElementById' );
} );
describe( '<StudentBulkActionButton />', () => {
const selectActionButton = () =>
screen.getByRole( 'button', {
name: 'Select Action',
} );

beforeAll( () => {
useSelect.mockReturnValue( { courses, isFetching: false } );
} );
Expand All @@ -62,15 +57,22 @@ 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 } /> );
const { getByRole } = render(
<StudentBulkActionButton isDisabled={ false } />
);

fireEvent.click(
getByRole( 'button', {
name: 'Select Action',
} )
);

selectActionButton().click();
expect(
screen.getByText(
ignoreInlineTags(
Expand All @@ -80,15 +82,21 @@ 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 } /> );
const { getByRole } = render(
<StudentBulkActionButton isDisabled={ false } />
);

selectActionButton().click();
fireEvent.click(
getByRole( 'button', {
name: 'Select Action',
} )
);

expect(
screen.getByText(
Expand All @@ -98,15 +106,23 @@ 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 } /> );
const { getByRole } = render(
<StudentBulkActionButton isDisabled={ false } />
);

fireEvent.click(
getByRole( 'button', {
name: 'Select Action',
} )
);

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
Loading
Loading