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

Upgrade @testing-library/user-event to latest ^14.5.2 #189949

Merged
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
8da200b
updated @testing-library/user-event to ^14.4.3
walterra Aug 6, 2024
830fbc1
add await to userEvent.click
walterra Aug 6, 2024
130bb08
x-pack/plugins/observability_solution/slo/public/components/burn_rate…
walterra Aug 23, 2024
2646a2f
fix missing awaits
walterra Aug 23, 2024
100e167
fix pointerEventsCheck
walterra Aug 23, 2024
a9bb202
adds missing asyncs
walterra Aug 23, 2024
dbaa3ed
eslint ignore fixes
walterra Aug 23, 2024
e14dd25
fix async/await
walterra Aug 23, 2024
e746371
fix async/await
walterra Aug 23, 2024
70c81a8
fix async/await for plugins/lens
walterra Aug 25, 2024
a6c5262
fix async/await for plugins/triggers_actions_ui
walterra Aug 25, 2024
eee0226
fix async/await for plugins/stack_connectors
walterra Aug 25, 2024
ecf1687
fix async/await for plugins/ml
walterra Aug 25, 2024
dcf7f82
fix async/await for plugins/fleet
walterra Aug 25, 2024
2bb5004
fix async/await
walterra Aug 25, 2024
9caa5dd
fix async/await for plugins/cloud_defend
walterra Aug 25, 2024
4cc253f
fix async/await for plugins/security_solution
walterra Aug 26, 2024
d8d8cfb
fix jest tests for plugins/lens
walterra Aug 26, 2024
eb3fae7
fix jest tests for plugins/triggers_actions_ui
walterra Aug 26, 2024
9739be3
fix {selectall}
walterra Aug 26, 2024
f707e39
fix jest tests for plugins/cloud_defend
walterra Aug 27, 2024
ff86ec0
fix jest tests for plugins/session_view
walterra Aug 27, 2024
2513102
fix jest tests for plugins/security_solution
walterra Aug 27, 2024
9526532
fix jest tests for packages/content-management
walterra Aug 27, 2024
2896165
fix jest tests for plugins/observability_solution
walterra Aug 27, 2024
dacbe68
fix jest tests for plugins/security_solution
walterra Aug 27, 2024
669103a
fix jest tests for packages/kbn-management
walterra Aug 27, 2024
ff59053
fix jest tests for packages/security-solution
walterra Aug 27, 2024
5cedd4b
fix/skip jest tests for packages/kbn-dom-drag-drop
walterra Aug 27, 2024
3916067
use user.paste instead of user.type for performance reasons
walterra Aug 27, 2024
72144ca
update related packages
walterra Aug 27, 2024
f6cfee3
align @testing-library/dom version for react testing lib and user event
walterra Aug 27, 2024
c7b8894
wip: fix enterCommand
walterra Aug 28, 2024
dbd2bb2
remove @types/testing-library__jest-dom
walterra Aug 28, 2024
3a7a5c1
fix jest tests for packages/security-solution using enterCommand(). u…
walterra Aug 28, 2024
0a536e6
update package.json
walterra Aug 29, 2024
b0f37f9
fix assertion
walterra Aug 29, 2024
78e95c8
remove extend-expect
walterra Aug 29, 2024
40ee98c
update github link
walterra Aug 29, 2024
71accf7
update github link
walterra Aug 29, 2024
633adf9
fix jest tests for plugins/cases
walterra Aug 29, 2024
5035037
fix jest tests for plugins/ml
walterra Aug 29, 2024
8e1970d
fix jest tests for plugins/security_solution
walterra Aug 30, 2024
00d5aa5
fix jest tests for plugins/lens
walterra Aug 30, 2024
f81eba7
fix jest tests for examples/content_management_examples
walterra Aug 30, 2024
5393bf6
fix jest tests for plugins/observability_solution/synthetics
walterra Aug 30, 2024
f514a67
fix jest tests for packages/kbn-unified-field-list
walterra Aug 30, 2024
c49858c
fix jest tests for plugins/cases
walterra Aug 30, 2024
050fa8c
fix typo
walterra Aug 30, 2024
86f3b99
fix jest tests for plugins/cloud_security_posture
walterra Aug 30, 2024
d8e038c
fix jest tests for plugins/security_solution
walterra Aug 30, 2024
711df98
fix jest tests for src/plugins/controls
walterra Aug 30, 2024
d849b19
fix jest tests for plugins/security_solution
walterra Aug 30, 2024
5b84189
fix jest tests for plugins/security_solution
walterra Sep 3, 2024
5d51148
fix package.json/yarn.lock
walterra Sep 3, 2024
c42a400
fix jest tests for plugins/global_search_bar
walterra Sep 3, 2024
bdfed98
fix jest tests for plugins/security_solution
walterra Sep 3, 2024
2c5a0f8
fix jest tests for plugins/cases
walterra Sep 3, 2024
8944644
fix jest tests for packages/kbn-unified-data-table/src/components/dat…
walterra Sep 4, 2024
81f2549
fix jest tests for plugins/security_solution
walterra Sep 4, 2024
ad8c127
fix jest tests for src/plugins/controls/public/options_list/component…
walterra Sep 4, 2024
fd99902
fix jest tests for packages/kbn-dom-drag-drop
walterra Sep 4, 2024
bf0438c
fix jest tests for packages/kbn-unified-data-table
walterra Sep 5, 2024
c2e7a95
Merge branch 'main' into update-testing-library-user-event-14-4-3
walterra Sep 5, 2024
3947811
refactor x-pack/plugins/lens/public/datasources/form_based/dimension_…
walterra Sep 5, 2024
5a9b526
Merge branch 'main' into update-testing-library-user-event-14-4-3
walterra Sep 5, 2024
956d127
adds awaits to userEvent.hover()
walterra Sep 5, 2024
e7f2390
fix timeouts for jest tests in x-pack/plugins/cases
walterra Sep 5, 2024
3fdf053
Merge branch 'main' into update-testing-library-user-event-14-4-3
walterra Sep 5, 2024
8669579
fix timeouts for jest tests in x-pack/plugins/cases
walterra Sep 5, 2024
a803117
refactor with more comments: x-pack/plugins/security_solution/public/…
walterra Sep 6, 2024
7d56410
adds missing fake timers
walterra Sep 6, 2024
0ee0b56
fix timeouts for jest tests in plugins/security_solution
walterra Sep 6, 2024
9c2b18a
user fireEvent instead of userEvent for enter key
walterra Sep 6, 2024
415bee5
revert rest of submitClick
walterra Sep 6, 2024
0d75919
remove unnecessary comment
walterra Sep 6, 2024
c36ce84
Merge branch 'main' into update-testing-library-user-event-14-4-3
walterra Sep 9, 2024
a355d0a
Merge branch 'main' into update-testing-library-user-event-14-4-3
walterra Sep 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React from 'react';
import { render, screen, within, waitForElementToBeRemoved } from '@testing-library/react';
import { render, screen, within, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { SimpleTodoApp } from './todo.stories';

Expand All @@ -28,7 +28,7 @@ test('SimpleTodoApp works', async () => {
// apply "completed" filter
let todoFilters = screen.getByRole('group', { name: 'Todo filters' });
let completedFilter = within(todoFilters).getByTestId('completed');
userEvent.click(completedFilter);
await userEvent.click(completedFilter);

// check only completed todos are shown
todos = await screen.findAllByRole('listitem');
Expand All @@ -39,7 +39,7 @@ test('SimpleTodoApp works', async () => {
// apply "todo" filter
todoFilters = screen.getByRole('group', { name: 'Todo filters' });
const todoFilter = within(todoFilters).getByTestId('todo');
userEvent.click(todoFilter);
await userEvent.click(todoFilter);

// check only todo todos are shown
todos = await screen.findAllByRole('listitem');
Expand All @@ -50,7 +50,7 @@ test('SimpleTodoApp works', async () => {
// apply "all" filter
todoFilters = screen.getByRole('group', { name: 'Todo filters' });
const allFilter = within(todoFilters).getByTestId('all');
userEvent.click(allFilter);
await userEvent.click(allFilter);

// check all todos are shown
todos = await screen.findAllByRole('listitem');
Expand All @@ -59,7 +59,7 @@ test('SimpleTodoApp works', async () => {

// add new todo
const newTodoInput = screen.getByTestId('newTodo');
userEvent.type(newTodoInput, 'Learn React{enter}');
await userEvent.type(newTodoInput, 'Learn React{enter}');

// wait for new todo to be added
await screen.findByText('Learn React');
Expand All @@ -68,12 +68,12 @@ test('SimpleTodoApp works', async () => {
let newTodo = todos[2];

// mark new todo as completed
userEvent.click(within(newTodo).getByRole('checkbox'));
await userEvent.click(within(newTodo).getByRole('checkbox'));

// apply "completed" filter again
todoFilters = screen.getByRole('group', { name: 'Todo filters' });
completedFilter = within(todoFilters).getByTestId('completed');
userEvent.click(completedFilter);
await userEvent.click(completedFilter);

// check only completed todos are shown and a new todo is there
await screen.findByText('Learn React'); // wait for new todo to be there
Expand All @@ -83,8 +83,10 @@ test('SimpleTodoApp works', async () => {
expect(newTodo).toHaveTextContent('Learn React');

// remove new todo
userEvent.click(within(newTodo).getByLabelText('Delete'));
await userEvent.click(within(newTodo).getByLabelText('Delete'));

// wait for new todo to be removed
await waitForElementToBeRemoved(() => screen.getByText('Learn React'));
await waitFor(() => {
expect(screen.queryByText('Learn React')).not.toBeInTheDocument();
});
});
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1483,10 +1483,10 @@
"@storybook/testing-react": "^1.3.0",
"@storybook/theming": "^6.5.16",
"@testing-library/dom": "^8.19.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^12.1.5",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/user-event": "^13.5.0",
"@testing-library/user-event": "^14.5.2",
"@types/adm-zip": "^0.5.0",
"@types/archiver": "^5.3.1",
"@types/async": "^3.2.3",
Expand Down Expand Up @@ -1612,7 +1612,6 @@
"@types/styled-components": "^5.1.0",
"@types/supertest": "^6.0.2",
"@types/tapable": "^1.0.6",
"@types/testing-library__jest-dom": "^5.14.7",
"@types/textarea-caret": "^3.0.1",
"@types/tinycolor2": "^1.4.1",
"@types/tough-cookie": "^4.0.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import { render, screen, within, waitForElementToBeRemoved } from '@testing-library/react';
import { render, screen, within } from '@testing-library/react';
import { I18nProvider } from '@kbn/i18n-react';
import { WithServices } from './tests.helpers';
import { TableListViewTable, type TableListViewTableProps } from '../table_list_view_table';
Expand Down Expand Up @@ -124,18 +124,18 @@ describe('created_by filter', () => {
// 5 items in the list
expect(screen.getAllByTestId(/userContentListingTitleLink/)).toHaveLength(4);

userEvent.click(screen.getByTestId('userFilterPopoverButton'));
await userEvent.click(screen.getByTestId('userFilterPopoverButton'));

const userSelectablePopover = screen.getByTestId('userSelectableList');
const popover = within(userSelectablePopover);
expect(await popover.findAllByTestId(/userProfileSelectableOption/)).toHaveLength(3);

userEvent.click(popover.getByTestId('userProfileSelectableOption-user1'));
await userEvent.click(popover.getByTestId('userProfileSelectableOption-user1'));

// 1 item in the list
expect(screen.getAllByTestId(/userContentListingTitleLink/)).toHaveLength(1);

userEvent.click(popover.getByTestId('userProfileSelectableOption-user2'));
await userEvent.click(popover.getByTestId('userProfileSelectableOption-user2'));

// 2 items in the list
expect(screen.getAllByTestId(/userContentListingTitleLink/)).toHaveLength(2);
Expand All @@ -150,11 +150,11 @@ describe('created_by filter', () => {
// 4 items in the list
expect(screen.getAllByTestId(/userContentListingTitleLink/)).toHaveLength(4);

userEvent.click(screen.getByTestId('userFilterPopoverButton'));
await userEvent.click(screen.getByTestId('userFilterPopoverButton'));

const userSelectablePopover = screen.getByTestId('userSelectableList');
const popover = within(userSelectablePopover);
userEvent.click(await popover.findByTestId('userProfileSelectableOption-null'));
await userEvent.click(await popover.findByTestId('userProfileSelectableOption-null'));

// just 1 item in the list
expect(screen.getAllByTestId(/userContentListingTitleLink/)).toHaveLength(1);
Expand All @@ -177,7 +177,7 @@ describe('created_by filter', () => {
// 3 items in the list
expect(screen.getAllByTestId(/userContentListingTitleLink/)).toHaveLength(3);

userEvent.click(screen.getByTestId('userFilterPopoverButton'));
await userEvent.click(screen.getByTestId('userFilterPopoverButton'));

const userSelectablePopover = screen.getByTestId('userSelectableList');
const popover = within(userSelectablePopover);
Expand All @@ -202,11 +202,11 @@ describe('created_by filter', () => {
// 1 item in the list
expect(screen.getAllByTestId(/userContentListingTitleLink/)).toHaveLength(1);

userEvent.click(screen.getByTestId('userFilterPopoverButton'));
await userEvent.click(screen.getByTestId('userFilterPopoverButton'));

const userSelectablePopover = screen.getByTestId('userSelectableList');
const popover = within(userSelectablePopover);
await waitForElementToBeRemoved(() => popover.getByRole('progressbar'));
expect(popover.queryByRole('progressbar')).not.toBeInTheDocument();
expect(popover.getAllByTestId('userFilterEmptyMessage')[1]).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Adapted from x-pack/plugins/security_solution/public/detections/components/alerts_table/alerts_grouping.test.tsx
*/
import React from 'react';
import { render, within, screen, waitFor } from '@testing-library/react';
import { render, within, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import type { Filter } from '@kbn/es-query';

Expand Down Expand Up @@ -120,14 +120,14 @@ describe('AlertsGrouping', () => {
expect(screen.getByTestId('empty-results-panel')).toBeInTheDocument();
});

it('renders grouping table in first accordion level when single group is selected', () => {
it('renders grouping table in first accordion level when single group is selected', async () => {
render(
<TestProviders>
<AlertsGrouping {...mockGroupingProps}>{renderChildComponent}</AlertsGrouping>
</TestProviders>
);

userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-0-group-0')).getByTestId('group-panel-toggle')
);
expect(
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('AlertsGrouping', () => {
);
});

it('renders grouping table in second accordion level when 2 groups are selected', () => {
it('renders grouping table in second accordion level when 2 groups are selected', async () => {
mockUseAlertsGroupingState.mockReturnValue({
...mockAlertsGroupingState,
grouping: {
Expand All @@ -185,13 +185,13 @@ describe('AlertsGrouping', () => {
<AlertsGrouping {...mockGroupingProps}>{renderChildComponent}</AlertsGrouping>
</TestProviders>
);
userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-0-group-0')).getByTestId('group-panel-toggle')
);
expect(
within(screen.getByTestId('level-0-group-0')).queryByTestId('alerts-table')
).not.toBeInTheDocument();
userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-1-group-0')).getByTestId('group-panel-toggle')
);
expect(
Expand All @@ -213,19 +213,19 @@ describe('AlertsGrouping', () => {
</TestProviders>
);

userEvent.click(screen.getByTestId('pagination-button-1'));
userEvent.click(
await userEvent.click(screen.getByTestId('pagination-button-1'));
await userEvent.click(
within(screen.getByTestId('level-0-group-0')).getByTestId('group-panel-toggle')
);

userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-0-group-0')).getByTestId('pagination-button-1')
);
userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-1-group-0')).getByTestId('group-panel-toggle')
);

userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-1-group-0')).getByTestId('pagination-button-1')
);

Expand All @@ -242,9 +242,9 @@ describe('AlertsGrouping', () => {
).toEqual('true');
});

userEvent.click(screen.getAllByTestId('group-selector-dropdown')[0]);
await userEvent.click(screen.getAllByTestId('group-selector-dropdown')[0]);
// Wait for element to have pointer events enabled
await waitFor(() => userEvent.click(screen.getAllByTestId('panel-user.name')[0]));
await userEvent.click(screen.getAllByTestId('panel-user.name')[0]);

[
screen.getByTestId('grouping-level-0-pagination'),
Expand All @@ -260,7 +260,7 @@ describe('AlertsGrouping', () => {
});
});

it('resets all levels pagination when global query updates', () => {
it('resets all levels pagination when global query updates', async () => {
mockUseAlertsGroupingState.mockReturnValue({
...mockAlertsGroupingState,
grouping: {
Expand All @@ -275,17 +275,17 @@ describe('AlertsGrouping', () => {
</TestProviders>
);

userEvent.click(screen.getByTestId('pagination-button-1'));
userEvent.click(
await userEvent.click(screen.getByTestId('pagination-button-1'));
await userEvent.click(
within(screen.getByTestId('level-0-group-0')).getByTestId('group-panel-toggle')
);
userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-0-group-0')).getByTestId('pagination-button-1')
);
userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-1-group-0')).getByTestId('group-panel-toggle')
);
userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-1-group-0')).getByTestId('pagination-button-1')
);

Expand Down Expand Up @@ -313,7 +313,7 @@ describe('AlertsGrouping', () => {
});
});

it('resets only most inner group pagination when its parent groups open/close', () => {
it('resets only most inner group pagination when its parent groups open/close', async () => {
mockUseAlertsGroupingState.mockReturnValue({
...mockAlertsGroupingState,
grouping: {
Expand All @@ -329,31 +329,31 @@ describe('AlertsGrouping', () => {
);

// set level 0 page to 2
userEvent.click(screen.getByTestId('pagination-button-1'));
userEvent.click(
await userEvent.click(screen.getByTestId('pagination-button-1'));
await userEvent.click(
within(screen.getByTestId('level-0-group-0')).getByTestId('group-panel-toggle')
);

// set level 1 page to 2
userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-0-group-0')).getByTestId('pagination-button-1')
);
userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-1-group-0')).getByTestId('group-panel-toggle')
);

// set level 2 page to 2
userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-1-group-0')).getByTestId('pagination-button-1')
);
userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-2-group-0')).getByTestId('group-panel-toggle')
);

// open different level 1 group

// level 0, 1 pagination is the same
userEvent.click(
await userEvent.click(
within(screen.getByTestId('level-1-group-1')).getByTestId('group-panel-toggle')
);
[
Expand Down Expand Up @@ -396,26 +396,26 @@ describe('AlertsGrouping', () => {
</TestProviders>
);

userEvent.click(await screen.findByTestId('pagination-button-1'));
userEvent.click(
await userEvent.click(await screen.findByTestId('pagination-button-1'));
await userEvent.click(
within(await screen.findByTestId('level-0-group-0')).getByTestId('group-panel-toggle')
);
userEvent.click(
await userEvent.click(
within(await screen.findByTestId('level-0-group-0')).getByTestId('pagination-button-1')
);
userEvent.click(
await userEvent.click(
within(await screen.findByTestId('level-1-group-0')).getByTestId('group-panel-toggle')
);

userEvent.click(
await userEvent.click(
within(await screen.findByTestId('level-1-group-0')).getByTestId('pagination-button-1')
);
userEvent.click(
await userEvent.click(
within(await screen.findByTestId('grouping-level-2')).getByTestId(
'tablePaginationPopoverButton'
)
);
userEvent.click(await screen.findByTestId('tablePagination-100-rows'));
await userEvent.click(await screen.findByTestId('tablePagination-100-rows'));

[
await screen.findByTestId('grouping-level-0-pagination'),
Expand Down Expand Up @@ -453,24 +453,24 @@ describe('AlertsGrouping', () => {
</TestProviders>
);

userEvent.click(screen.getByTestId('pagination-button-1'));
userEvent.click(
await userEvent.click(screen.getByTestId('pagination-button-1'));
await userEvent.click(
within(await screen.findByTestId('level-0-group-0')).getByTestId('group-panel-toggle')
);

userEvent.click(
await userEvent.click(
within(await screen.findByTestId('level-0-group-0')).getByTestId('pagination-button-1')
);
userEvent.click(
await userEvent.click(
within(await screen.findByTestId('level-1-group-0')).getByTestId('group-panel-toggle')
);

userEvent.click(
await userEvent.click(
within(await screen.findByTestId('level-1-group-0')).getByTestId('pagination-button-1')
);
const tablePaginations = await screen.findAllByTestId('tablePaginationPopoverButton');
userEvent.click(tablePaginations[tablePaginations.length - 1]);
await waitFor(() => userEvent.click(screen.getByTestId('tablePagination-100-rows')));
await userEvent.click(tablePaginations[tablePaginations.length - 1]);
await userEvent.click(screen.getByTestId('tablePagination-100-rows'));

[
screen.getByTestId('grouping-level-0-pagination'),
Expand Down
Loading