diff --git a/services/app-web/src/pages/StateSubmission/ReviewSubmit/V2/ReviewSubmit/RateDetailsSummarySectionV2.test.tsx b/services/app-web/src/pages/StateSubmission/ReviewSubmit/V2/ReviewSubmit/RateDetailsSummarySectionV2.test.tsx index e3909417b7..31b9cb7b97 100644 --- a/services/app-web/src/pages/StateSubmission/ReviewSubmit/V2/ReviewSubmit/RateDetailsSummarySectionV2.test.tsx +++ b/services/app-web/src/pages/StateSubmission/ReviewSubmit/V2/ReviewSubmit/RateDetailsSummarySectionV2.test.tsx @@ -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( + , + { + 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( + , + { + 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(), diff --git a/services/app-web/src/pages/StateSubmission/ReviewSubmit/V2/ReviewSubmit/RateDetailsSummarySectionV2.tsx b/services/app-web/src/pages/StateSubmission/ReviewSubmit/V2/ReviewSubmit/RateDetailsSummarySectionV2.tsx index 2b9e16b167..e8f6952b7c 100644 --- a/services/app-web/src/pages/StateSubmission/ReviewSubmit/V2/ReviewSubmit/RateDetailsSummarySectionV2.tsx +++ b/services/app-web/src/pages/StateSubmission/ReviewSubmit/V2/ReviewSubmit/RateDetailsSummarySectionV2.tsx @@ -22,6 +22,7 @@ import { Program, RateRevision, RateFormData, + HealthPlanPackageStatus, } from '../../../../../gen/gqlClient' export type RateDetailsSummarySectionV2Props = { @@ -34,6 +35,18 @@ export type RateDetailsSummarySectionV2Props = { onDocumentError?: (error: true) => void } +type SharedRateCertDisplay = { + packageId?: string + packageName?: string +} +type PackageNameType = string +type PackageNamesLookupType = { + [id: string]: { + packageName: PackageNameType + status: HealthPlanPackageStatus + } +} + export function renderDownloadButton( zippedFilesURL: string | undefined | Error ) { @@ -57,6 +70,7 @@ export const RateDetailsSummarySectionV2 = ({ submissionName, statePrograms, onDocumentError, + isCMSUser, }: RateDetailsSummarySectionV2Props): React.ReactElement => { const isSubmitted = contract.status === 'SUBMITTED' const isEditing = !isSubmitted && editNavigateTo !== undefined @@ -70,6 +84,29 @@ export const RateDetailsSummarySectionV2 = ({ const [zippedFilesURL, setZippedFilesURL] = useState< string | undefined | Error >(undefined) + const [packageNamesLookup] = React.useState( + null + ) + + const refreshPackagesWithSharedRateCert = ( + rateFormData: RateFormData + ): SharedRateCertDisplay[] | undefined => { + return rateFormData.packagesWithSharedRateCerts?.map( + ({ packageId, packageName }) => { + const refreshedName = + packageId && + packageNamesLookup && + packageNamesLookup[packageId]?.packageName + const isDraftText = + isCMSUser && !refreshedName ? ' (Draft)' : '' + return { + packageId, + packageName: + refreshedName ?? `${packageName}${isDraftText}`, + } + } + ) + } const rateCapitationType = (rate: Rate | RateRevision) => { const rateFormData = getRateFormData(rate) @@ -291,6 +328,9 @@ export const RateDetailsSummarySectionV2 = ({ documentDateLookupTable={ documentDateLookupTable } + packagesWithSharedRateCerts={refreshPackagesWithSharedRateCert( + rateFormData + )} multipleDocumentsAllowed={false} caption="Rate certification" documentCategory="Rate certification" @@ -304,6 +344,9 @@ export const RateDetailsSummarySectionV2 = ({ documentDateLookupTable={ documentDateLookupTable } + packagesWithSharedRateCerts={refreshPackagesWithSharedRateCert( + rateFormData + )} caption="Rate supporting documents" isSupportingDocuments documentCategory="Rate-supporting"