diff --git a/src/pages-and-resources/discussions/DiscussionsSettings.test.jsx b/src/pages-and-resources/discussions/DiscussionsSettings.test.jsx index c73509b224..5fc74c7aed 100644 --- a/src/pages-and-resources/discussions/DiscussionsSettings.test.jsx +++ b/src/pages-and-resources/discussions/DiscussionsSettings.test.jsx @@ -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(); + } }); });