Skip to content

Commit 51e3e4a

Browse files
committed
test: fix flaky test
1 parent 10b24e8 commit 51e3e4a

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

src/course-unit/CourseUnit.test.jsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -581,17 +581,16 @@ describe('<CourseUnit />', () => {
581581
published_preview_link: publishedPreviewLink,
582582
} = courseSectionVerticalMock;
583583

584-
await waitFor(async () => {
585-
const viewLiveButton = screen.getByRole('button', { name: headerNavigationsMessages.viewLiveButton.defaultMessage });
586-
await user.click(viewLiveButton);
587-
expect(window.open).toHaveBeenCalled();
588-
expect(window.open).toHaveBeenCalledWith(publishedPreviewLink, '_blank');
584+
const viewLiveButton = await screen.findByRole('button', { name: headerNavigationsMessages.viewLiveButton.defaultMessage });
589585

590-
const previewButton = screen.getByRole('button', { name: headerNavigationsMessages.previewButton.defaultMessage });
591-
await user.click(previewButton);
592-
expect(window.open).toHaveBeenCalled();
593-
expect(window.open).toHaveBeenCalledWith(draftPreviewLink, '_blank');
594-
});
586+
await user.click(viewLiveButton);
587+
expect(window.open).toHaveBeenCalled();
588+
expect(window.open).toHaveBeenCalledWith(publishedPreviewLink, '_blank');
589+
590+
const previewButton = screen.getByRole('button', { name: headerNavigationsMessages.previewButton.defaultMessage });
591+
await user.click(previewButton);
592+
expect(window.open).toHaveBeenCalled();
593+
expect(window.open).toHaveBeenCalledWith(draftPreviewLink, '_blank');
595594

596595
window.open = open;
597596
});

0 commit comments

Comments
 (0)