Skip to content

Commit

Permalink
Combine test into one.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLin0991 committed Nov 8, 2023
1 parent 8b94590 commit c9187f8
Showing 1 changed file with 1 addition and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import userEvent from '@testing-library/user-event'

describe('RateReviewsTable', () => {
afterEach(() => {
window.history.pushState({}, '', 'dashboard/rate-reviews')
window.history.pushState({}, '', '')
})

const statePrograms = mockMNState().programs
Expand Down Expand Up @@ -283,70 +283,6 @@ describe('RateReviewsTable', () => {
expect(
screen.getByText('Displaying 2 of 3 rate reviews')
).toBeInTheDocument()
})
it('can clear date range filter with clear filter button', async () => {
renderWithProviders(
<RateReviewsTable
tableData={tableData()}
showFilters={true}
caption={'Test table caption'}
/>,
{
apolloProvider: {
mocks: [
fetchCurrentUserMock({
statusCode: 200,
user: mockValidCMSUser(),
}),
],
},
}
)

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

const accordionButton = screen.getByTestId(
'accordionButton_filterAccordionItems'
)

await waitFor(async () => {
//Expect filter accordion and state filter to exist
expect(screen.queryByTestId('accordion')).toBeInTheDocument()
//Expand filter accordion
await userEvent.click(accordionButton)
})

const ratingPeriodFilter = screen.getByTestId(
'filter-date-range-picker'
)
const dateRangePickerInputs = within(
ratingPeriodFilter
).queryAllByTestId('date-picker-external-input')
const startDateFromInput = dateRangePickerInputs[0]
const startDateToInput = dateRangePickerInputs[1]

expect(startDateFromInput).toBeInTheDocument()
expect(startDateToInput).toBeInTheDocument()

// filter rates by start date from 11/01/2023
await userEvent.type(startDateFromInput, '11/01/2023')

// expect to only show rates with start dates on or after 11/01/2023
const firstFilterRows = await screen.findAllByRole('row')
expect(firstFilterRows).toHaveLength(3)
expect(
within(firstFilterRows[1]).getByText('rate-3-certification-name')
).toBeInTheDocument()
expect(
within(firstFilterRows[2]).getByText('rate-2-certification-name')
).toBeInTheDocument()
expect(
screen.getByText('Displaying 2 of 3 rate reviews')
).toBeInTheDocument()

const clearFilterButton = screen.getByRole('button', {
name: /Clear filters/,
Expand Down

0 comments on commit c9187f8

Please sign in to comment.