diff --git a/src/__tests__/patients/care-goals/CareGoalTab.test.tsx b/src/__tests__/patients/care-goals/CareGoalTab.test.tsx index 054786e9a1..ec49489bb8 100644 --- a/src/__tests__/patients/care-goals/CareGoalTab.test.tsx +++ b/src/__tests__/patients/care-goals/CareGoalTab.test.tsx @@ -1,4 +1,4 @@ -import { render, screen, waitFor, within } from '@testing-library/react' +import { render, screen, waitFor, waitForElementToBeRemoved, within } from '@testing-library/react' import userEvent, { specialChars } from '@testing-library/user-event' import format from 'date-fns/format' import { createMemoryHistory } from 'history' @@ -63,9 +63,10 @@ const setup = ( describe('Care Goals Tab', () => { it('should not render add care goal button if user does not have permissions', async () => { - setup('/patients/123/care-goals', []) + const { container } = setup('/patients/123/care-goals', []) - expect(await screen.findByRole('table')).toBeInTheDocument() + // wait for spinner to disappear + await waitForElementToBeRemoved(container.querySelector('.css-0')) expect(screen.queryByRole('button', { name: /patient.careGoal.new/i })).not.toBeInTheDocument() }) diff --git a/src/__tests__/patients/related-persons/RelatedPersonsTab.test.tsx b/src/__tests__/patients/related-persons/RelatedPersonsTab.test.tsx index c2099b3ab9..ffdb97e62b 100644 --- a/src/__tests__/patients/related-persons/RelatedPersonsTab.test.tsx +++ b/src/__tests__/patients/related-persons/RelatedPersonsTab.test.tsx @@ -1,4 +1,4 @@ -import { render, screen } from '@testing-library/react' +import { render, screen, waitForElementToBeRemoved } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { createMemoryHistory } from 'history' import React from 'react' @@ -77,9 +77,11 @@ describe('Related Persons Tab', () => { }) it('should not render a New Related Person button if the user does not have write privileges for a patient', async () => { - setup({ permissions: [Permissions.ReadPatients] }) + const { container } = setup({ permissions: [Permissions.ReadPatients] }) + + // wait for spinner to disappear + await waitForElementToBeRemoved(container.querySelector(`[class^='css']`)) - expect(await screen.findByRole('alert')).toBeInTheDocument() expect( screen.queryByRole('button', { name: /patient\.relatedPersons\.add/i }), ).not.toBeInTheDocument()