diff --git a/.changeset/mosaic-fix-flaky-feature-tests.md b/.changeset/mosaic-fix-flaky-feature-tests.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/mosaic-fix-flaky-feature-tests.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/mosaic/src/__tests__/feature/menu.ts b/packages/mosaic/src/__tests__/feature/menu.ts index ca6f92ae552..3897441124f 100644 --- a/packages/mosaic/src/__tests__/feature/menu.ts +++ b/packages/mosaic/src/__tests__/feature/menu.ts @@ -3,5 +3,7 @@ import type { UserEvent } from '@testing-library/user-event'; export async function openMenu(user: UserEvent, trigger: HTMLElement) { await user.click(trigger); - return screen.findByRole('menu'); + const menu = await screen.findByRole('menu'); + await new Promise(requestAnimationFrame); + return menu; } diff --git a/packages/mosaic/src/features/organization-profile/organization-profile-members-panel/__tests__/organization-profile-members-panel.feature.test.tsx b/packages/mosaic/src/features/organization-profile/organization-profile-members-panel/__tests__/organization-profile-members-panel.feature.test.tsx index 29a3f740303..e911eeb2b7b 100644 --- a/packages/mosaic/src/features/organization-profile/organization-profile-members-panel/__tests__/organization-profile-members-panel.feature.test.tsx +++ b/packages/mosaic/src/features/organization-profile/organization-profile-members-panel/__tests__/organization-profile-members-panel.feature.test.tsx @@ -151,7 +151,8 @@ describe('OrganizationProfileMembersPanel', () => { await waitFor(() => expect(members.requests).toHaveLength(1)); expect(screen.getByRole('button', { name: 'Manage Bob Smith' })).toBeDisabled(); members.release(); - await openMenu(user, await screen.findByRole('button', { name: 'Manage Bob Smith' })); + await waitFor(() => expect(screen.getByRole('button', { name: 'Manage Bob Smith' })).toBeEnabled()); + await openMenu(user, screen.getByRole('button', { name: 'Manage Bob Smith' })); await user.click(screen.getByRole('menuitem', { name: 'Remove from organization' })); const dialog = await screen.findByRole('alertdialog', { name: 'Remove Bob Smith?' }); await user.click(within(dialog).getByRole('button', { name: 'Remove from organization' })); diff --git a/packages/mosaic/src/features/user-profile/user-profile-enterprise-accounts-section/__tests__/user-profile-enterprise-accounts.feature.test.tsx b/packages/mosaic/src/features/user-profile/user-profile-enterprise-accounts-section/__tests__/user-profile-enterprise-accounts.feature.test.tsx index 6d61eb847c6..ed46ec88112 100644 --- a/packages/mosaic/src/features/user-profile/user-profile-enterprise-accounts-section/__tests__/user-profile-enterprise-accounts.feature.test.tsx +++ b/packages/mosaic/src/features/user-profile/user-profile-enterprise-accounts-section/__tests__/user-profile-enterprise-accounts.feature.test.tsx @@ -225,7 +225,7 @@ describe('enterprise accounts', () => { expect(screen.getByRole('alert')).toHaveTextContent('The connection could not start. Please try again.'), ); expect(screen.getByRole('button', { name: 'Connect Acme Okta' })).toBeEnabled(); - expect(screen.queryByRole('progressbar')).not.toBeInTheDocument(); + await waitFor(() => expect(screen.queryByRole('progressbar')).not.toBeInTheDocument()); serveFapi(signedIn()); await user.click(screen.getByRole('button', { name: 'Connect Acme Okta' })); await waitFor(() =>