Skip to content

Commit

Permalink
Fixup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
haworku committed Apr 18, 2024
1 parent 8458874 commit 07d292d
Show file tree
Hide file tree
Showing 8 changed files with 439 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export const ContractDetailsSummarySection = ({
? new Date(
documentDateLookupTable.previousSubmissionDate
)
: undefined
: null
}
caption="Contract"
documentCategory="Contract"
Expand All @@ -325,7 +325,7 @@ export const ContractDetailsSummarySection = ({
? new Date(
documentDateLookupTable.previousSubmissionDate
)
: undefined
: null
}
caption="Contract supporting documents"
documentCategory="Contract-supporting"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export const RateDetailsSummarySection = ({
? new Date(
documentDateLookupTable.previousSubmissionDate
)
: undefined
: null
}
multipleDocumentsAllowed={false}
caption="Rate certification"
Expand All @@ -388,7 +388,7 @@ export const RateDetailsSummarySection = ({
? new Date(
documentDateLookupTable.previousSubmissionDate
)
: undefined
: null
}
caption="Rate supporting documents"
isSupportingDocuments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe('UploadedDocumentsTable', () => {

renderWithProviders(
<UploadedDocumentsTable
previousSubmissionDate={null}
documents={testDocuments}
caption="Contract supporting"
documentCategory="Contract-supporting"
Expand Down Expand Up @@ -217,6 +218,7 @@ describe('UploadedDocumentsTable', () => {
renderWithProviders(
<UploadedDocumentsTable
documents={testDocuments}
previousSubmissionDate={null}
caption="Contract supporting"
documentCategory="Contract-supporting"
isSupportingDocuments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export const convertFromSubmissionDocumentsToGenericDocuments = (
export type UploadedDocumentsTableProps = {
documents: GenericDocument[]
caption: string | null
previousSubmissionDate: Date | null // used to calculate NEW tag based on doc dateAdded
packagesWithSharedRateCerts?: SharedRateCertDisplay[] // deprecated - could be deleted after we resolve all historical data linked rates
previousSubmissionDate?: Date // used to calculate NEW tag based on doc dateAdded
isSupportingDocuments?: boolean // used to calculate empty state and styles around the secondary supporting docs tables - would be nice to remove this in favor of more domain agnostic prop such as 'emptyStateText'
multipleDocumentsAllowed?: boolean // used to determined if we display validations based on doc list length
documentCategory?: string // used to determine if we display document category column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
StatutoryRegulatoryAttestation,
StatutoryRegulatoryAttestationQuestion,
} from '../../../../../constants/statutoryRegulatoryAttestation'
import { mockContractFormData } from '../../../../../testHelpers/apolloMocks/contractPackageDataMock'

describe('ContractDetailsSummarySection', () => {
const defaultApolloMocks = {
Expand Down Expand Up @@ -314,7 +315,20 @@ describe('ContractDetailsSummarySection', () => {
it('does not render supporting contract documents table when no documents exist', () => {
renderWithProviders(
<ContractDetailsSummarySection
contract={mockContractPackageDraft()}
contract={mockContractPackageDraft({
draftRevision: {
__typename: 'ContractRevision',
submitInfo: undefined,
unlockInfo: undefined,
id: '123',
createdAt: new Date(),
updatedAt: new Date(),
contractName: 'MCR-0005-alvhalfhdsalf',
formData: mockContractFormData({
supportingDocuments: [],
}),
},
})}
submissionName="MN-PMAP-0001"
/>,
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { screen, waitFor } from '@testing-library/react'
import { screen, waitFor, within } from '@testing-library/react'
import {
renderWithProviders,
userClickByRole,
Expand All @@ -7,6 +7,7 @@ import { ReviewSubmitV2 } from './ReviewSubmitV2'
import {
fetchCurrentUserMock,
fetchContractMockSuccess,
mockContractPackageUnlocked,
} from '../../../../../testHelpers/apolloMocks'
import { Route, Routes } from 'react-router-dom'
import { RoutesRecord } from '../../../../../constants'
Expand Down Expand Up @@ -177,6 +178,60 @@ describe('ReviewSubmit', () => {
})
})

it('extracts the correct dates from unlocked submission and displays them in tables', async () => {
const contractMock = fetchContractMockSuccess({
contract: mockContractPackageUnlocked(),
})

renderWithProviders(
<Routes>
<Route
path={RoutesRecord.SUBMISSIONS_REVIEW_SUBMIT}
element={<ReviewSubmitV2 />}
/>
</Routes>,
{
apolloProvider: {
mocks: [
fetchCurrentUserMock({ statusCode: 200 }),
contractMock,
],
},
routerProvider: {
route: '/submissions/test-abc-123/edit/review-and-submit',
},
featureFlags: {
'link-rates': true,
},
}
)

await waitFor(() => {
const contractDocRow = screen.getByRole('row', {
name: /contract document/,
})
expect(
within(contractDocRow).getByText('1/1/24')
).toBeInTheDocument()
const contractSupporting1Row = screen.getByRole('row', {
name: /contractSupporting1/,
})
expect(
within(contractSupporting1Row).getByText('1/15/24')
).toBeInTheDocument()
const rateDocRow = screen.getByRole('row', {
name: /rate certification/,
})
expect(within(rateDocRow).getByText('1/13/24')).toBeInTheDocument()
const rateSupporting1Row = screen.getByRole('row', {
name: /rateSupporting1/,
})
expect(
within(rateSupporting1Row).getByText('1/15/24')
).toBeInTheDocument()
})
})

it('displays back, save as draft, and submit buttons', async () => {
renderWithProviders(
<Routes>
Expand Down
Loading

0 comments on commit 07d292d

Please sign in to comment.