Skip to content

Commit 2e6e08e

Browse files
authored
[8.19] Backward compatible testing library changes for switching to createRoot (elastic#213367) (elastic#220500)
# Backport This will backport the following commits from `main` to `8.19`: - [[Concurrent React@18] Switch testing library to `createRoot` (elastic#213367)](elastic#213367), but without actually enabling concurrent root for tests. Just the backward compatible unit test fixes <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Anton Dosov","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-05-08T11:59:44Z","message":"[Concurrent React@18] Switch testing library to `createRoot` (elastic#213367)\n\nCloses elastic#218076. \nPart of the preparation for migrating Kibana to React’s createRoot\n([Epic](https://github.com/elastic/kibana-team/issues/1564)).\n\n## What’s in this PR\n\n- Switch to `createRoot` in tests: Updates `@testing-library/react` to\nuse `createRoot` by default. All unit tests using Testing Library now\nrun in concurrent mode. See commit:\nhttps://github.com/elastic/pull/213367/commits/8e51e07054ab5d0993e9856a851c55716e90190b\n- Test updates: Most test failures from the switch have been addressed.\nAbout a dozen tests still explicitly set `legacyRoot: true`. These will\nneed closer review by the owning teams during app migrations.\n- Enzyme tests: Enzyme tests continue to use the React 17 adapter and\nrun in legacy mode. [Current\nplan](https://docs.google.com/document/d/1CXybQiBAtXt3Kay0j_CJxWO7bZ2EYYhaveK4fban2-M/edit?tab=t.kfgvma8ti7q0)\nis to migrate away from Enzyme before upgrading to React 19.\n\n## Background\n\nWhen we upgraded to React 18, we also updated `@testing-library/react`,\nwhich by default uses `createRoot`.\nTo avoid dealing with concurrent mode failures early, we temporarily\nforced Testing Library to use `legacyRoot` (`ReactDOM.render`).\n\nThis PR removes that override and fixes the resulting test issues,\ncompleting the move to concurrent root for Testing Library tests.\n\n\n### Common Failures\n\n#### 🔴 `el.click()` \n\nA common testing mistake is using el.click() and immediately checking\nfor a DOM update:\n```\nel.click();\nexpect(el).toHaveAttribute('state-updated');\n```\n\nThis often fails with Concurrent React, because state updates might not\nbe synchronous anymore.\nDirectly calling `el.click()` doesn't automatically trigger React’s\nupdate cycle (`act`), so your test can read outdated DOM.\n\nInstead, you should either manually wrap the interaction in `act`, or\n(better) use `userEvent.click`, which already uses `act` internally and\nsimulates real user behavior more accurately:\n\n```diff\n- el.click();\n+ await userEvent.click(el);\nexpect(el).toHaveAttribute('state-updated');\n```\n\n\n#### 🔴 Wrapping `render` call inside `act` `act(() => render(<App/>))`\n\nAnother common mistake is wrapping the render call inside act:\n\n```\nawait act(async () => {\n render(<MyComponent />);\n});\n```\n\nThis is sometimes done to \"mute\" warnings about Promises resolving\ninside `useEffect`.\nHowever, wrapping `render` in `act` manually breaks a lot of tests in\nConcurrent React, because the library (like React Testing Library)\nalready wraps render in act internally. Manually adding act here can\ncause unexpected behavior, like missing updates or wrong timing.\n\nThe approach I took was to remove the manual `act` around `render` in\nplaces where tests started failing with Concurrent React, even if, in\nsome cases, it means seeing `act` warnings in the console. This is safer\nfor correctness and allows the tests to pass reliably.\n\nTo properly mute such warnings, the right way would be to wrap the\nactual resolved Promises (like those inside useEffect) in act.However,\nsince doing that depends a lot on the specific test setup, and could\nvary case-by-case, I chose not to try to fix it myself. Teams are\nwelcome to follow up if they wish.\n\n### 🟡 In specific tests we keep `legacyMode: true`\n\nWhen it wasn't immediately clear to me what caused the failure or when\nthe tests were checking React internals, like the number of re-renders,\nI decided to keep that test running in legacy mode by using the option\n`legacyRoot: true` in `render`.\n\nThe idea behind these in-place overrides is that when we're ready to\nstart migrating the runtime to concurrent mode, the owning teams will\nneed to take a closer look at those tests when moving their apps to the\nconcurrent root.","sha":"24d4c8aa0b60156e87a614bae5e7d6489c8c5972","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:skip","Team:Fleet","Team:SharedUX","ci:project-deploy-observability","Team:obs-ux-infra_services","Team:obs-ux-management","React@18","v9.1.0","v8.19.0"],"title":"[Concurrent React@18] Switch testing library to `createRoot` ","number":213367,"url":"https://github.com/elastic/kibana/pull/213367","mergeCommit":{"message":"[Concurrent React@18] Switch testing library to `createRoot` (elastic#213367)\n\nCloses elastic#218076. \nPart of the preparation for migrating Kibana to React’s createRoot\n([Epic](https://github.com/elastic/kibana-team/issues/1564)).\n\n## What’s in this PR\n\n- Switch to `createRoot` in tests: Updates `@testing-library/react` to\nuse `createRoot` by default. All unit tests using Testing Library now\nrun in concurrent mode. See commit:\nhttps://github.com/elastic/pull/213367/commits/8e51e07054ab5d0993e9856a851c55716e90190b\n- Test updates: Most test failures from the switch have been addressed.\nAbout a dozen tests still explicitly set `legacyRoot: true`. These will\nneed closer review by the owning teams during app migrations.\n- Enzyme tests: Enzyme tests continue to use the React 17 adapter and\nrun in legacy mode. [Current\nplan](https://docs.google.com/document/d/1CXybQiBAtXt3Kay0j_CJxWO7bZ2EYYhaveK4fban2-M/edit?tab=t.kfgvma8ti7q0)\nis to migrate away from Enzyme before upgrading to React 19.\n\n## Background\n\nWhen we upgraded to React 18, we also updated `@testing-library/react`,\nwhich by default uses `createRoot`.\nTo avoid dealing with concurrent mode failures early, we temporarily\nforced Testing Library to use `legacyRoot` (`ReactDOM.render`).\n\nThis PR removes that override and fixes the resulting test issues,\ncompleting the move to concurrent root for Testing Library tests.\n\n\n### Common Failures\n\n#### 🔴 `el.click()` \n\nA common testing mistake is using el.click() and immediately checking\nfor a DOM update:\n```\nel.click();\nexpect(el).toHaveAttribute('state-updated');\n```\n\nThis often fails with Concurrent React, because state updates might not\nbe synchronous anymore.\nDirectly calling `el.click()` doesn't automatically trigger React’s\nupdate cycle (`act`), so your test can read outdated DOM.\n\nInstead, you should either manually wrap the interaction in `act`, or\n(better) use `userEvent.click`, which already uses `act` internally and\nsimulates real user behavior more accurately:\n\n```diff\n- el.click();\n+ await userEvent.click(el);\nexpect(el).toHaveAttribute('state-updated');\n```\n\n\n#### 🔴 Wrapping `render` call inside `act` `act(() => render(<App/>))`\n\nAnother common mistake is wrapping the render call inside act:\n\n```\nawait act(async () => {\n render(<MyComponent />);\n});\n```\n\nThis is sometimes done to \"mute\" warnings about Promises resolving\ninside `useEffect`.\nHowever, wrapping `render` in `act` manually breaks a lot of tests in\nConcurrent React, because the library (like React Testing Library)\nalready wraps render in act internally. Manually adding act here can\ncause unexpected behavior, like missing updates or wrong timing.\n\nThe approach I took was to remove the manual `act` around `render` in\nplaces where tests started failing with Concurrent React, even if, in\nsome cases, it means seeing `act` warnings in the console. This is safer\nfor correctness and allows the tests to pass reliably.\n\nTo properly mute such warnings, the right way would be to wrap the\nactual resolved Promises (like those inside useEffect) in act.However,\nsince doing that depends a lot on the specific test setup, and could\nvary case-by-case, I chose not to try to fix it myself. Teams are\nwelcome to follow up if they wish.\n\n### 🟡 In specific tests we keep `legacyMode: true`\n\nWhen it wasn't immediately clear to me what caused the failure or when\nthe tests were checking React internals, like the number of re-renders,\nI decided to keep that test running in legacy mode by using the option\n`legacyRoot: true` in `render`.\n\nThe idea behind these in-place overrides is that when we're ready to\nstart migrating the runtime to concurrent mode, the owning teams will\nneed to take a closer look at those tests when moving their apps to the\nconcurrent root.","sha":"24d4c8aa0b60156e87a614bae5e7d6489c8c5972"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/213367","number":213367,"mergeCommit":{"message":"[Concurrent React@18] Switch testing library to `createRoot` (elastic#213367)\n\nCloses elastic#218076. \nPart of the preparation for migrating Kibana to React’s createRoot\n([Epic](https://github.com/elastic/kibana-team/issues/1564)).\n\n## What’s in this PR\n\n- Switch to `createRoot` in tests: Updates `@testing-library/react` to\nuse `createRoot` by default. All unit tests using Testing Library now\nrun in concurrent mode. See commit:\nhttps://github.com/elastic/pull/213367/commits/8e51e07054ab5d0993e9856a851c55716e90190b\n- Test updates: Most test failures from the switch have been addressed.\nAbout a dozen tests still explicitly set `legacyRoot: true`. These will\nneed closer review by the owning teams during app migrations.\n- Enzyme tests: Enzyme tests continue to use the React 17 adapter and\nrun in legacy mode. [Current\nplan](https://docs.google.com/document/d/1CXybQiBAtXt3Kay0j_CJxWO7bZ2EYYhaveK4fban2-M/edit?tab=t.kfgvma8ti7q0)\nis to migrate away from Enzyme before upgrading to React 19.\n\n## Background\n\nWhen we upgraded to React 18, we also updated `@testing-library/react`,\nwhich by default uses `createRoot`.\nTo avoid dealing with concurrent mode failures early, we temporarily\nforced Testing Library to use `legacyRoot` (`ReactDOM.render`).\n\nThis PR removes that override and fixes the resulting test issues,\ncompleting the move to concurrent root for Testing Library tests.\n\n\n### Common Failures\n\n#### 🔴 `el.click()` \n\nA common testing mistake is using el.click() and immediately checking\nfor a DOM update:\n```\nel.click();\nexpect(el).toHaveAttribute('state-updated');\n```\n\nThis often fails with Concurrent React, because state updates might not\nbe synchronous anymore.\nDirectly calling `el.click()` doesn't automatically trigger React’s\nupdate cycle (`act`), so your test can read outdated DOM.\n\nInstead, you should either manually wrap the interaction in `act`, or\n(better) use `userEvent.click`, which already uses `act` internally and\nsimulates real user behavior more accurately:\n\n```diff\n- el.click();\n+ await userEvent.click(el);\nexpect(el).toHaveAttribute('state-updated');\n```\n\n\n#### 🔴 Wrapping `render` call inside `act` `act(() => render(<App/>))`\n\nAnother common mistake is wrapping the render call inside act:\n\n```\nawait act(async () => {\n render(<MyComponent />);\n});\n```\n\nThis is sometimes done to \"mute\" warnings about Promises resolving\ninside `useEffect`.\nHowever, wrapping `render` in `act` manually breaks a lot of tests in\nConcurrent React, because the library (like React Testing Library)\nalready wraps render in act internally. Manually adding act here can\ncause unexpected behavior, like missing updates or wrong timing.\n\nThe approach I took was to remove the manual `act` around `render` in\nplaces where tests started failing with Concurrent React, even if, in\nsome cases, it means seeing `act` warnings in the console. This is safer\nfor correctness and allows the tests to pass reliably.\n\nTo properly mute such warnings, the right way would be to wrap the\nactual resolved Promises (like those inside useEffect) in act.However,\nsince doing that depends a lot on the specific test setup, and could\nvary case-by-case, I chose not to try to fix it myself. Teams are\nwelcome to follow up if they wish.\n\n### 🟡 In specific tests we keep `legacyMode: true`\n\nWhen it wasn't immediately clear to me what caused the failure or when\nthe tests were checking React internals, like the number of re-renders,\nI decided to keep that test running in legacy mode by using the option\n`legacyRoot: true` in `render`.\n\nThe idea behind these in-place overrides is that when we're ready to\nstart migrating the runtime to concurrent mode, the owning teams will\nneed to take a closer look at those tests when moving their apps to the\nconcurrent root.","sha":"24d4c8aa0b60156e87a614bae5e7d6489c8c5972"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
1 parent 214d12f commit 2e6e08e

File tree

96 files changed

+866
-743
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+866
-743
lines changed

src/core/packages/application/browser-internal/integration_tests/application_service.test.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,9 @@ describe('ApplicationService', () => {
351351

352352
await act(async () => {
353353
await navigate('/app/app1');
354+
});
355+
356+
await act(async () => {
354357
await navigateToApp('app2');
355358
});
356359

@@ -422,6 +425,9 @@ describe('ApplicationService', () => {
422425

423426
await act(async () => {
424427
await navigate('/app/app1');
428+
});
429+
430+
await act(async () => {
425431
await navigateToApp('app2');
426432
});
427433

src/platform/packages/private/kbn-esql-editor/src/editor_footer/history_starred_queries.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
HistoryAndStarredQueriesTabs,
1919
} from './history_starred_queries';
2020
import { of } from 'rxjs';
21+
import { act } from 'react-dom/test-utils';
2122

2223
jest.mock('../history_local_storage', () => {
2324
const module = jest.requireActual('../history_local_storage');
@@ -269,7 +270,9 @@ describe('Starred and History queries components', () => {
269270
</KibanaContextProvider>
270271
);
271272
// click the starred queries tab
272-
screen.getByTestId('starred-queries-tab').click();
273+
act(() => {
274+
screen.getByTestId('starred-queries-tab').click();
275+
});
273276

274277
expect(screen.getByTestId('ESQLEditor-starredQueries')).toBeInTheDocument();
275278
expect(screen.getByTestId('ESQLEditor-history-starred-queries-helpText')).toHaveTextContent(

src/platform/packages/private/kbn-react-mute-legacy-root-warning/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
*/
99

1010
/* eslint-disable no-console */
11-
const originalConsoleError = console.error;
1211

1312
/**
1413
* After we upgrade to React 18, we will see a warning in the console that we are using the legacy ReactDOM.render API.
1514
* This warning is expected as we are in the process of migrating to the new createRoot API.
1615
* However, it is very noisy and we want to mute it for now.
1716
*/
1817
export function muteLegacyRootWarning() {
18+
const originalConsoleError = console.error;
1919
console.error = (message, ...args) => {
2020
if (
2121
typeof message === 'string' &&
@@ -28,4 +28,9 @@ export function muteLegacyRootWarning() {
2828

2929
originalConsoleError.call(console, message, ...args);
3030
};
31+
32+
/* unmute */
33+
return () => {
34+
console.error = originalConsoleError;
35+
};
3136
}

src/platform/packages/shared/kbn-discover-contextual-components/src/data_types/logs/components/summary_column/summary_column.test.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import React from 'react';
1111
import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks';
1212
import { render, screen } from '@testing-library/react';
13+
import { userEvent } from '@testing-library/user-event';
1314
import SummaryColumn, {
1415
AllSummaryColumnProps,
1516
SummaryCellPopover,
@@ -141,11 +142,13 @@ describe('SummaryColumn', () => {
141142
expect(screen.queryByText('+2')).not.toBeInTheDocument();
142143
});
143144

144-
it('should display a popover with details and actions upon a badge click', () => {
145+
it('should display a popover with details and actions upon a badge click', async () => {
145146
const record = getBaseRecord();
146147
renderSummary(record);
147148
// Open badge popover
148-
screen.getByTestId(`dataTableCellActionsPopover_${constants.SERVICE_NAME_FIELD}`).click();
149+
await userEvent.click(
150+
screen.getByTestId(`dataTableCellActionsPopover_${constants.SERVICE_NAME_FIELD}`)
151+
);
149152

150153
expect(screen.getByTestId('dataTableCellActionPopoverTitle')).toHaveTextContent(
151154
'service.name synth-service-2'

src/platform/packages/shared/kbn-field-utils/src/components/field_description/field_description.test.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import React from 'react';
1111
import { FieldDescription } from './field_description';
1212
import { render, screen } from '@testing-library/react';
13+
import { userEvent } from '@testing-library/user-event';
1314
import { FieldsMetadataPublicStart } from '@kbn/fields-metadata-plugin/public';
1415
import { SHOULD_TRUNCATE_FIELD_DESCRIPTION_LOCALSTORAGE_KEY } from './field_description';
1516

@@ -51,12 +52,16 @@ describe('FieldDescription', () => {
5152
const customDescription = 'test this long desc '.repeat(8).trim();
5253
render(<FieldDescription field={{ name: 'bytes', type: 'number', customDescription }} />);
5354
expect(screen.queryByTestId('fieldDescription-bytes')).toHaveTextContent(customDescription);
54-
screen.queryByTestId('toggleFieldDescription-bytes')?.click();
55+
56+
await userEvent.click(screen.getByTestId('toggleFieldDescription-bytes'));
57+
5558
expect(screen.queryByTestId('fieldDescription-bytes')).toHaveTextContent(
5659
`${customDescription}View less`
5760
);
5861
expect(mockSetLocalStorage).toHaveBeenCalledWith(false);
59-
screen.queryByTestId('toggleFieldDescription-bytes')?.click();
62+
63+
await userEvent.click(screen.getByTestId('toggleFieldDescription-bytes'));
64+
6065
expect(screen.queryByTestId('fieldDescription-bytes')).toHaveTextContent(customDescription);
6166
expect(mockSetLocalStorage).toHaveBeenCalledWith(true);
6267
});

src/platform/packages/shared/kbn-test/src/jest/setup/enzyme.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,15 @@ jest.mock('enzyme', () => {
3737
mockEnsureEmotionStyleTag();
3838
return actual.render(node, options);
3939
},
40+
mount: (node, options) => {
41+
// Since we're using React 17 enzyme adapter, we need to mute the warning about using legacy root API
42+
// Otherwise console will be flooded with warnings
43+
const unmute = require('@kbn/react-mute-legacy-root-warning').muteLegacyRootWarning();
44+
try {
45+
return actual.mount(node, options);
46+
} finally {
47+
unmute();
48+
}
49+
},
4050
};
4151
});

src/platform/packages/shared/kbn-unified-data-table/src/components/custom_control_columns/additional_row_control/row_menu_control_column.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ import { getRowMenuControlColumn } from './row_menu_control_column';
1414
import { dataTableContextMock } from '../../../../__mocks__/table_context';
1515
import { mockRowAdditionalLeadingControls } from '../../../../__mocks__/external_control_columns';
1616
import { UnifiedDataTableContext } from '../../../table_context';
17+
import userEvent from '@testing-library/user-event';
1718

1819
describe('getRowMenuControlColumn', () => {
1920
const contextMock = {
2021
...dataTableContextMock,
2122
};
2223

23-
it('should render the component', () => {
24+
it('should render the component', async () => {
2425
const mockClick = jest.fn();
2526
const props = {
2627
id: 'test_row_menu_control',
@@ -57,15 +58,16 @@ describe('getRowMenuControlColumn', () => {
5758
const menuButton = screen.getByTestId('unifiedDataTable_test_row_menu_control');
5859
expect(menuButton).toBeInTheDocument();
5960

60-
menuButton.click();
61+
await userEvent.click(menuButton);
6162

6263
expect(screen.getByTestId('exampleRowControl-visBarVerticalStacked')).toBeInTheDocument();
6364
expect(screen.getByTestId('exampleRowControl-heart')).toBeInTheDocument();
6465

6566
const button = screen.getByTestId('unifiedDataTable_rowMenu_test_row_menu_control');
6667
expect(button).toBeInTheDocument();
6768

68-
button.click();
69+
await userEvent.click(button);
70+
6971
expect(mockClick).toHaveBeenCalledWith({ record: contextMock.getRowByIndex(1), rowIndex: 1 });
7072
});
7173
});

src/platform/packages/shared/kbn-unified-data-table/src/components/data_table.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1518,7 +1518,7 @@ describe('UnifiedDataTable', () => {
15181518

15191519
expect(screen.getByTestId(BUTTON_TEST_SUBJ)).toBeInTheDocument();
15201520

1521-
screen.getByTestId(BUTTON_TEST_SUBJ).click();
1521+
await userEvent.click(screen.getByTestId(BUTTON_TEST_SUBJ));
15221522

15231523
expect(screen.getByTestId(INPUT_TEST_SUBJ)).toBeInTheDocument();
15241524

src/platform/packages/shared/kbn-unified-data-table/src/components/data_table_document_selection.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { getDocId } from '@kbn/discover-utils';
2727
import { render, screen } from '@testing-library/react';
2828
import { __IntlProvider as IntlProvider } from '@kbn/i18n-react';
2929
import { servicesMock } from '../../__mocks__/services';
30+
import userEvent from '@testing-library/user-event';
3031

3132
describe('document selection', () => {
3233
describe('getDocId', () => {
@@ -409,7 +410,7 @@ describe('document selection', () => {
409410
return {
410411
getButton: async () => {
411412
const menuButton = await screen.findByTestId('unifiedDataTableSelectionBtn');
412-
menuButton.click();
413+
await userEvent.click(menuButton);
413414
return screen.queryByRole('button', { name: /Compare/ });
414415
},
415416
};

src/platform/packages/shared/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer.test.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import React from 'react';
1111
import { mount, shallow } from 'enzyme';
12-
import { render, screen } from '@testing-library/react';
12+
import { act, render, screen } from '@testing-library/react';
1313
import { findTestSubject } from '@elastic/eui/lib/test';
1414
import { buildDataTableRecord } from '@kbn/discover-utils';
1515
import { DocViewer, INITIAL_TAB } from './doc_viewer';
@@ -88,13 +88,17 @@ describe('<DocViewer />', () => {
8888
expect(screen.getByTestId('docViewerTab-test1').getAttribute('aria-selected')).toBe('true');
8989
expect(screen.getByTestId('docViewerTab-test2').getAttribute('aria-selected')).toBe('false');
9090

91-
screen.getByTestId('docViewerTab-test2').click();
91+
act(() => {
92+
screen.getByTestId('docViewerTab-test2').click();
93+
});
9294

9395
expect(screen.getByTestId('docViewerTab-test1').getAttribute('aria-selected')).toBe('false');
9496
expect(screen.getByTestId('docViewerTab-test2').getAttribute('aria-selected')).toBe('true');
9597
expect(mockSetLocalStorage).toHaveBeenCalledWith('kbn_doc_viewer_tab_test2');
9698

97-
screen.getByTestId('docViewerTab-test1').click();
99+
act(() => {
100+
screen.getByTestId('docViewerTab-test1').click();
101+
});
98102

99103
expect(screen.getByTestId('docViewerTab-test1').getAttribute('aria-selected')).toBe('true');
100104
expect(screen.getByTestId('docViewerTab-test2').getAttribute('aria-selected')).toBe('false');

0 commit comments

Comments
 (0)