Skip to content

Commit

Permalink
Rate table tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLin0991 committed Jan 15, 2025
1 parent 6cd7027 commit 1b68df2
Showing 1 changed file with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,19 @@ describe('RateReviewsTable', () => {

await waitFor(() => {
expect(
screen.getByText('Displaying 3 of 3 rate reviews')
screen.getByText('Displaying 2 of 3 rate reviews')
).toBeInTheDocument()
})
// expect filter accordion to be present
expect(screen.getByTestId('accordion')).toBeInTheDocument()
expect(
screen.getByText('0 filters applied')
).toBeInTheDocument()

// expect table caption
expect(
screen.getByText('Test table caption')
screen.getByText('2 filters applied')
).toBeInTheDocument()

const tableRows = screen.getAllByRole('row')

// expect there to be 4 rows, one of which is the header row
expect(tableRows).toHaveLength(4)
expect(tableRows).toHaveLength(3)

// expect rows to be in order where latest updatedAt is first in the array
// expect statuses to be drawn from the consolidatedStatus field
Expand All @@ -115,17 +110,17 @@ describe('RateReviewsTable', () => {
within(tableRows[1]).getByText('Unlocked')
).toBeInTheDocument()
expect(
within(tableRows[2]).getByText('rate-2-certification-name')
).toBeInTheDocument()
expect(
within(tableRows[2]).getByText('Withdrawn')
within(tableRows[2]).getByText('rate-1-certification-name')
).toBeInTheDocument()
expect(
within(tableRows[3]).getByText('rate-1-certification-name')
within(tableRows[2]).getByText('Submitted')
).toBeInTheDocument()

// expect WITHDRAWN rates to be not visible
expect(
within(tableRows[3]).getByText('Submitted')
).toBeInTheDocument()
screen.queryByText('rate-2-certification-name')
).toBeNull()
expect(screen.queryByText('Withdrawn')).toBeNull()
})
it('renders rates table correctly without filters, captions and no rates', async () => {
renderWithProviders(<RateReviewsTable tableData={[]} />, {
Expand Down Expand Up @@ -183,6 +178,12 @@ describe('RateReviewsTable', () => {
await userEvent.click(accordionButton)
})

// clear out default status filter
const clearFilterButton = screen.getByRole('button', {
name: /Clear filters/,
})
await userEvent.click(clearFilterButton)

//Look for state filter
const stateCombobox = within(stateFilter).getByRole('combobox')
expect(stateCombobox).toBeInTheDocument()
Expand Down Expand Up @@ -233,7 +234,7 @@ describe('RateReviewsTable', () => {

await waitFor(() => {
expect(
screen.getByText('Displaying 3 of 3 rate reviews')
screen.getByText('Displaying 2 of 3 rate reviews')
).toBeInTheDocument()
})

Expand All @@ -250,6 +251,14 @@ describe('RateReviewsTable', () => {
await userEvent.click(accordionButton)
})

// clear out default status filter
const clearFilterButton = screen.getByRole('button', {
name: /Clear filters/,
})
expect(clearFilterButton).toBeInTheDocument()

await userEvent.click(clearFilterButton)

const ratingPeriodFilter = screen.getByTestId(
'filter-date-range-picker'
)
Expand Down Expand Up @@ -317,11 +326,6 @@ describe('RateReviewsTable', () => {
screen.getByText('Displaying 2 of 3 rate reviews')
).toBeInTheDocument()

const clearFilterButton = screen.getByRole('button', {
name: /Clear filters/,
})
expect(clearFilterButton).toBeInTheDocument()

// Clear all filters
await userEvent.click(clearFilterButton)

Expand Down Expand Up @@ -357,6 +361,14 @@ describe('RateReviewsTable', () => {
await userEvent.click(accordionButton)
})

// clear out default status filter
const clearFilterButton = screen.getByRole('button', {
name: /Clear filters/,
})
expect(clearFilterButton).toBeInTheDocument()

await userEvent.click(clearFilterButton)

//Look for status filter
const statusCombobox =
within(statusFilter).getByRole('combobox')
Expand Down

0 comments on commit 1b68df2

Please sign in to comment.