Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
test: add back more semantic spinner queries
Browse files Browse the repository at this point in the history
  • Loading branch information
codyarose committed Jan 14, 2021
1 parent 6f3567c commit 1ea596f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/__tests__/patients/care-goals/CareGoalTab.test.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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()
})

Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 1ea596f

Please sign in to comment.