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

chore: add a bit of delay to reduce Modal test flakiness #1801

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/Modal/Modal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generateSnapshots } from '@chanzuckerberg/story-utils';
import { generateSnapshots, wait } from '@chanzuckerberg/story-utils';
import type { StoryFile } from '@storybook/testing-react';
import { composeStories } from '@storybook/testing-react';
import { render, screen, waitFor } from '@testing-library/react';
Expand Down Expand Up @@ -28,6 +28,10 @@ describe('Modal', () => {
});
await user.click(openModalButton);
const modal = await screen.findByRole('dialog');

// Give Headless UI's transition/style classes time to settle.
await wait(50);

return modal;
},
});
Expand Down
10 changes: 5 additions & 5 deletions src/components/Modal/__snapshots__/Modal.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ exports[`Modal DefaultInteractive story renders snapshot 1`] = `
<div
aria-labelledby="headlessui-dialog-title-:r2:"
aria-modal="true"
class="modal"
class="modal modal__transition--enterTo"
data-headlessui-state="open"
id="headlessui-dialog-:r0:"
role="dialog"
Expand Down Expand Up @@ -838,7 +838,7 @@ exports[`Modal WithLongText story renders snapshot 1`] = `
<div
aria-labelledby="headlessui-dialog-title-:r8:"
aria-modal="true"
class="modal"
class="modal modal__transition--enterTo"
data-headlessui-state="open"
id="headlessui-dialog-:r6:"
role="dialog"
Expand Down Expand Up @@ -935,7 +935,7 @@ exports[`Modal WithLongTextScrollable story renders snapshot 1`] = `
<div
aria-labelledby="headlessui-dialog-title-:rb:"
aria-modal="true"
class="modal"
class="modal modal__transition--enterTo"
data-headlessui-state="open"
id="headlessui-dialog-:r9:"
role="dialog"
Expand Down Expand Up @@ -1218,7 +1218,7 @@ exports[`Modal WithoutCloseButton story renders snapshot 1`] = `
<div
aria-labelledby="headlessui-dialog-title-:r5:"
aria-modal="true"
class="modal"
class="modal modal__transition--enterTo"
data-headlessui-state="open"
id="headlessui-dialog-:r3:"
role="dialog"
Expand Down Expand Up @@ -1277,7 +1277,7 @@ exports[`Modal WithoutHeaderAndFooter story renders snapshot 1`] = `
<div
aria-label="The Modal Amazing Modal You've Ever Seen"
aria-modal="true"
class="modal"
class="modal modal__transition--enterTo"
data-headlessui-state="open"
id="headlessui-dialog-:rc:"
role="dialog"
Expand Down
Loading