Skip to content

Commit

Permalink
refactor: updated tests for DiscussionsSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
BilalQamar95 committed Aug 15, 2023
1 parent e23917c commit 9064207
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/pages-and-resources/discussions/DiscussionsSettings.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -481,23 +481,19 @@ describe.each([

test(`${piiSharingAllowed ? 'shows PII share username/email field when piiSharingAllowed is true'
: 'hides PII share username/email field when piiSharingAllowed is false'}`, async () => {
setTimeout(async () => {
history.push(`/course/${courseId}/pages-and-resources/discussion`);
history.push(`/course/${courseId}/pages-and-resources/discussion`);

// This is an important line that ensures the spinner has been removed - and thus our main
// content has been loaded - prior to proceeding with our expectations.
await waitFor(() => expect(screen.queryByRole('status')).toBeNull());
// This is an important line that ensures the spinner has been removed - and thus our main
// content has been loaded - prior to proceeding with our expectations.
await waitForElementToBeRemoved(screen.getByRole('status'));

act(() => {
userEvent.click(queryByLabelText(container, 'Select Piazza'));
userEvent.click(queryByText(container, messages.nextButton.defaultMessage));
});
await waitFor(() => expect(screen.queryByRole('status')).toBeNull());
if (enablePIISharing) {
expect(queryByTestId(container, 'piiSharingFields')).toBeInTheDocument();
} else {
expect(queryByTestId(container, 'piiSharingFields')).not.toBeInTheDocument();
}
}, 0);
userEvent.click(queryByLabelText(container, 'Select Piazza'));
userEvent.click(queryByText(container, messages.nextButton.defaultMessage));
await waitFor(() => expect(screen.queryByRole('status')).toBeNull());
if (enablePIISharing) {
expect(queryByTestId(container, 'piiSharingFields')).toBeInTheDocument();
} else {
expect(queryByTestId(container, 'piiSharingFields')).not.toBeInTheDocument();
}
});
});

0 comments on commit 9064207

Please sign in to comment.