Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
pearl-truss committed Mar 15, 2024
1 parent 5bfff55 commit 0cb06e4
Showing 1 changed file with 97 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,103 @@ describe('RateDetailsSummarySection', () => {
).toBeNull()
})

it('renders all necessary information for documents with shared rate certifications', async () => {
const draftContract = mockContractPackageDraft()
if (
draftContract.draftRevision &&
draftContract.draftRates &&
draftContract.draftRates[0].draftRevision
) {
draftContract.draftRates[0].draftRevision.formData.packagesWithSharedRateCerts =
[
{
packageId: '333b4225-5b49-4e82-aa71-be0d33d7418d',
packageName: 'MCR-MN-0001-SNBC',
},
{
packageId: '21467dba-6ae8-11ed-a1eb-0242ac120002',
packageName: 'MCR-MN-0002-PMAP',
},
]
}

renderWithProviders(
<RateDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
contract={draftContract}
editNavigateTo="rate-details"
submissionName="MN-PMAP-0001"
statePrograms={statePrograms}
/>,
{
apolloProvider,
}
)
await waitFor(() => {
const rateDocsTable = screen.getByRole('table', {
name: /Rate certification/,
})
// has shared tag
expect(within(rateDocsTable).getByTestId('tag').textContent).toBe(
'SHARED'
)
// table has 'linked submissions' column
expect(
within(rateDocsTable).getByText('Linked submissions')
).toBeInTheDocument()
// table includes the correct submissions
expect(
within(rateDocsTable).getByText('MCR-MN-0001-SNBC')
).toBeInTheDocument()
expect(
within(rateDocsTable).getByText('MCR-MN-0002-PMAP')
).toBeInTheDocument()
// the document names link to the correct submissions
expect(
within(rateDocsTable).getByRole('link', {
name: 'MCR-MN-0001-SNBC',
})
).toHaveAttribute(
'href',
'/submissions/333b4225-5b49-4e82-aa71-be0d33d7418d'
)
expect(
within(rateDocsTable).getByRole('link', {
name: 'MCR-MN-0002-PMAP',
})
).toHaveAttribute(
'href',
'/submissions/21467dba-6ae8-11ed-a1eb-0242ac120002'
)
})
})

it('does not render shared rate cert info if none are present', async () => {
renderWithProviders(
<RateDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
contract={draftContract}
editNavigateTo="rate-details"
submissionName="MN-PMAP-0001"
statePrograms={statePrograms}
/>,
{
apolloProvider,
}
)
await waitFor(() => {
const rateDocsTable = screen.getByRole('table', {
name: /Rate certification/,
})
expect(
within(rateDocsTable).queryByTestId('tag')
).not.toBeInTheDocument()
expect(
within(rateDocsTable).queryByText('Linked submissions')
).not.toBeInTheDocument()
})
})

it('renders inline error when bulk URL is unavailable', async () => {
const s3Provider = {
...testS3Client(),
Expand Down

0 comments on commit 0cb06e4

Please sign in to comment.