test(DatasourceControl): await userEvent.click to deflake Edit dataset test

userEvent.click is asynchronous in @testing-library/user-event v14+;
unawaited calls left the downstream getByTestId assertion to race the
modal render. Awaits both clicks in the Edit-dataset test so the modal
is guaranteed open before the assertion runs.

Addresses codeant-ai review on PR #39461.
This commit is contained in:
Evan Rusackas
2026-04-22 16:03:15 -07:00
parent fa37cfde2d
commit 0732dfb5b3

View File

@@ -283,10 +283,10 @@ test('Click on Edit dataset', async () => {
useRedux: true,
useRouter: true,
});
userEvent.click(screen.getByTestId('datasource-menu-trigger'));
await userEvent.click(screen.getByTestId('datasource-menu-trigger'));
await act(async () => {
userEvent.click(screen.getByText('Edit dataset'));
await userEvent.click(screen.getByText('Edit dataset'));
});
expect(screen.getByTestId('mock-datasource-editor')).toBeInTheDocument();