diff --git a/.changeset/mosaic-feature-test-races.md b/.changeset/mosaic-feature-test-races.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/mosaic-feature-test-races.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/mosaic/src/blocks/destructive/destructive.feature.test.tsx b/packages/mosaic/src/blocks/destructive/destructive.feature.test.tsx index 8e29986f811..363a3ba7a24 100644 --- a/packages/mosaic/src/blocks/destructive/destructive.feature.test.tsx +++ b/packages/mosaic/src/blocks/destructive/destructive.feature.test.tsx @@ -70,10 +70,16 @@ function Host({ ); } +async function typeConfirmation(user: ReturnType) { + await user.click(screen.getByRole('button', { name: 'Open' })); + const dialog = await screen.findByRole('dialog'); + await waitFor(() => expect(dialog).toContainElement(document.activeElement as HTMLElement)); + await user.type(screen.getByRole('textbox'), 'Delete'); +} + async function openVerification() { const user = userEvent.setup(); - await user.click(screen.getByRole('button', { name: 'Open' })); - await user.type(await screen.findByRole('textbox'), 'Delete'); + await typeConfirmation(user); await user.click(screen.getByRole('button', { name: 'Delete account' })); return { user }; } @@ -200,8 +206,7 @@ describe('Destructive with reverification', () => { await user.click(screen.getAllByRole('button', { name: 'Close' })[0]); await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull()); - await user.click(screen.getByRole('button', { name: 'Open' })); - await user.type(await screen.findByRole('textbox'), 'Delete'); + await typeConfirmation(user); const stopWatching = watchForConfirmStep(); await user.click(screen.getByRole('button', { name: 'Delete account' })); await new Promise(resolve => setTimeout(resolve, 150)); diff --git a/packages/mosaic/src/features/reverification/__tests__/reverification.feature.test.tsx b/packages/mosaic/src/features/reverification/__tests__/reverification.feature.test.tsx index bb0f200a164..4a45cdac1b2 100644 --- a/packages/mosaic/src/features/reverification/__tests__/reverification.feature.test.tsx +++ b/packages/mosaic/src/features/reverification/__tests__/reverification.feature.test.tsx @@ -932,7 +932,7 @@ describe('Reverification', () => { // The code step opens with an empty field and no error once the code is sent expect(await screen.findByText(STEP.emailCode)).toBeVisible(); - expect(slotValues()).toEqual(['', '', '', '', '', '']); + await waitFor(() => expect(slotValues()).toEqual(['', '', '', '', '', ''])); expect(screen.queryByText('Incorrect code')).toBeNull(); // Picking a phone code sends the SMS code through the first factor endpoints