Skip to content

Commit

Permalink
fix: MCR-3988 document dates working again (#2369)
Browse files Browse the repository at this point in the history
  • Loading branch information
haworku authored Apr 22, 2024
1 parent b0751d0 commit ca138d4
Show file tree
Hide file tree
Showing 17 changed files with 474 additions and 42 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 @@ -99,7 +99,7 @@ export const SingleRateSummarySection = ({
const navigate = useNavigate()
const rateRevision = rate.revisions[0]
const formData: RateFormData = rateRevision?.formData
const lastSubmittedDate = rate.revisions[0]?.submitInfo?.updatedAt
const lastSubmittedDate = rate.revisions[0]?.submitInfo?.updatedAt ?? null
const isRateAmendment = formData.rateType === 'AMENDMENT'
const isUnlocked = rate.status === 'UNLOCKED'
const explainMissingData =
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 @@ -25,17 +25,17 @@ function makeDocumentDateTable(
revisionsLookup: RevisionsLookupType
): DocumentDateLookupTableType {
const lookupTable: DocumentDateLookupTableType = {
previousSubmissionDate: null,
previousSubmissionDate: null, // the last time there was a submission on this package
}
Object.keys(revisionsLookup).forEach(
(revisionId: string, index: number) => {
const listOfRevisionLookups = Object.keys(revisionsLookup)
listOfRevisionLookups.forEach(
(revisionId: string, index) => {
const revision = revisionsLookup[revisionId]
if (index === 1) {
// second most recent revision
const previousSubmission = getDateAdded(revision) // used in UploadedDocumentsTable to determine if we should show NEW tag
if (previousSubmission)
lookupTable['previousSubmissionDate'] = previousSubmission
}

const submitDate = revision.submitInfo?.updatedAt
if (submitDate && (listOfRevisionLookups.length === 1 || index === 1)) { // if we have a package with only one submitted revision, use that - otherwise use whatever in is the 1 index because thats the last submitted
lookupTable['previousSubmissionDate'] = submitDate
}

const allDocuments = getAllDocuments(revision.formData)
allDocuments.forEach((doc) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const LinkedRateSummary = ({
caption="Rate certification"
documentCategory="Rate certification"
isEditing={false}
previousSubmissionDate={null}
/>
</SectionCard>
)
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
Expand Up @@ -157,7 +157,7 @@ export const ContractDetailsSummarySectionV2 = ({
isPreviousSubmission,
])
const lastSubmittedDate =
getLastContractSubmission(contract)?.submitInfo.updatedAt
getLastContractSubmission(contract)?.submitInfo.updatedAt ?? null
return (
<SectionCard
id="contractDetailsSection"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const RateDetailsSummarySectionV2 = ({
? contract.draftRates
: getLastContractSubmission(contract)?.rateRevisions
const lastSubmittedDate =
getLastContractSubmission(contract)?.submitInfo.updatedAt
getLastContractSubmission(contract)?.submitInfo.updatedAt ?? null

const { getKey, getBulkDlURL } = useS3()
const [zippedFilesURL, setZippedFilesURL] = useState<
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { screen, waitFor } from '@testing-library/react'
import { screen, waitFor, within } from '@testing-library/react'
import { renderWithProviders } from '../../../../../testHelpers/jestHelpers'
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 @@ -174,6 +175,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 ca138d4

Please sign in to comment.