Skip to content

Commit

Permalink
Roll back attempts to refactor - go with prop drilling because testin…
Browse files Browse the repository at this point in the history
…g is taking too long for new code
  • Loading branch information
haworku committed Jul 20, 2023
1 parent 22d404f commit c9c3bcc
Show file tree
Hide file tree
Showing 16 changed files with 168 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('ContractDetailsSummarySection', () => {

renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
submission={testSubmission}
navigateTo="contract-details"
submissionName="MN-PMAP-0001"
Expand Down Expand Up @@ -66,6 +67,7 @@ describe('ContractDetailsSummarySection', () => {
it('can render state submission on summary page without errors (submission summary behavior)', () => {
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
submission={{
...mockStateSubmission(),
status: 'SUBMITTED',
Expand All @@ -91,6 +93,7 @@ describe('ContractDetailsSummarySection', () => {
it('can render all contract details fields', () => {
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
submission={mockContractAndRatesDraft()}
navigateTo="contract-details"
submissionName="MN-PMAP-0001"
Expand Down Expand Up @@ -127,6 +130,7 @@ describe('ContractDetailsSummarySection', () => {
it('displays correct effective dates text for base contract', () => {
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
submission={mockStateSubmission()}
submissionName="MN-PMAP-0001"
/>
Expand All @@ -137,6 +141,7 @@ describe('ContractDetailsSummarySection', () => {
it('displays correct effective dates text for contract amendment', () => {
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
submission={mockContractAndRatesDraft()}
submissionName="MN-PMAP-0001"
/>
Expand Down Expand Up @@ -179,6 +184,7 @@ describe('ContractDetailsSummarySection', () => {
}
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
submission={testSubmission}
submissionName="MN-PMAP-0001"
/>
Expand Down Expand Up @@ -220,6 +226,7 @@ describe('ContractDetailsSummarySection', () => {
it('does not render supporting contract documents table when no documents exist', () => {
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
submission={mockContractAndRatesDraft()}
submissionName="MN-PMAP-0001"
/>
Expand All @@ -235,6 +242,7 @@ describe('ContractDetailsSummarySection', () => {
it('does not render download all button when on previous submission', () => {
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
submission={mockContractAndRatesDraft()}
submissionName="MN-PMAP-0001"
/>
Expand All @@ -249,6 +257,7 @@ describe('ContractDetailsSummarySection', () => {
it('renders federal authorities for a medicaid contract', async () => {
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
submission={{
...mockContractAndRatesDraft(),
// Add all medicaid federal authorities, as if medicaid contract being unlocked
Expand Down Expand Up @@ -289,6 +298,7 @@ describe('ContractDetailsSummarySection', () => {
it('renders federal authorities for a CHIP contract as expected, removing invalid authorities', async () => {
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{ previousSubmissionDate: '01/01/01' }}
submission={{
...mockContractAndRatesDraft(),
populationCovered: 'CHIP',
Expand Down Expand Up @@ -330,6 +340,9 @@ describe('ContractDetailsSummarySection', () => {
it('renders provisions and MLR references for a medicaid amendment', () => {
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{
previousSubmissionDate: '01/01/01',
}}
submission={mockContractAndRatesDraft()}
submissionName="MN-PMAP-0001"
/>
Expand All @@ -354,9 +367,7 @@ describe('ContractDetailsSummarySection', () => {
).toBeInTheDocument()

expect(
within(modifiedProvisions).getByText(
/Risk-sharing strategy/
)
within(modifiedProvisions).getByText(/Risk-sharing strategy/)
).toBeInTheDocument()
expect(
within(modifiedProvisions).getByText(
Expand Down Expand Up @@ -425,6 +436,9 @@ describe('ContractDetailsSummarySection', () => {
it('renders provisions and MLR references for a medicaid base contract', () => {
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{
previousSubmissionDate: '01/01/01',
}}
submission={mockContractAndRatesDraft({
contractType: 'BASE',
})}
Expand All @@ -447,9 +461,7 @@ describe('ContractDetailsSummarySection', () => {
).toBeInTheDocument()

expect(
within(modifiedProvisions).getByText(
/Risk-sharing strategy/
)
within(modifiedProvisions).getByText(/Risk-sharing strategy/)
).toBeInTheDocument()
expect(
within(modifiedProvisions).getByText(
Expand All @@ -475,6 +487,9 @@ describe('ContractDetailsSummarySection', () => {
it('renders provisions with correct MLR references for CHIP amendment', () => {
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{
previousSubmissionDate: '01/01/01',
}}
submission={{
...mockContractAndRatesDraft(),
populationCovered: 'CHIP',
Expand Down Expand Up @@ -554,6 +569,9 @@ describe('ContractDetailsSummarySection', () => {
}
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{
previousSubmissionDate: '01/01/01',
}}
submission={contractWithUnansweredProvisions}
submissionName="MN-PMAP-0001"
navigateTo="contract-details"
Expand Down Expand Up @@ -602,6 +620,9 @@ describe('ContractDetailsSummarySection', () => {
}
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{
previousSubmissionDate: '01/01/01',
}}
submission={contractWithUnansweredProvisions}
submissionName="MN-PMAP-0001"
navigateTo="contract-details"
Expand Down Expand Up @@ -650,6 +671,9 @@ describe('ContractDetailsSummarySection', () => {
}
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{
previousSubmissionDate: '01/01/01',
}}
submission={contractWithUnansweredProvisions}
submissionName="MN-PMAP-0001"
/>,
Expand Down Expand Up @@ -701,6 +725,9 @@ describe('ContractDetailsSummarySection', () => {
}
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{
previousSubmissionDate: '01/01/01',
}}
submission={contractWithAllUnmodifiedProvisions}
submissionName="MN-PMAP-0001"
navigateTo="contract-details"
Expand Down Expand Up @@ -760,6 +787,9 @@ describe('ContractDetailsSummarySection', () => {
}
renderWithProviders(
<ContractDetailsSummarySection
documentDateLookupTable={{
previousSubmissionDate: '01/01/01',
}}
submission={contractWithAllUnmodifiedProvisions}
submissionName="MN-PMAP-0001"
/>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,20 @@ import {
HealthPlanFormDataType,
federalAuthorityKeysForCHIP,
} from '../../../common-code/healthPlanFormDataType'
import { useOutletContext } from 'react-router-dom'
import { SideNavOutletContextType } from '../../../pages/SubmissionSideNav/SubmissionSideNav'
import { DocumentDateLookupTableType } from '../../../documentHelpers/makeDocumentDateLookupTable'

export type ContractDetailsSummarySectionProps = {
submission: HealthPlanFormDataType
navigateTo?: string
documentDateLookupTable: DocumentDateLookupTableType
isCMSUser?: boolean
submissionName: string
}

export const ContractDetailsSummarySection = ({
submission,
navigateTo, // this is the edit link for the section. When this prop exists, summary section is loaded in edit mode
documentDateLookupTable,
isCMSUser,
submissionName,
}: ContractDetailsSummarySectionProps): React.ReactElement => {
Expand All @@ -62,8 +63,7 @@ export const ContractDetailsSummarySection = ({
const [modifiedProvisions, unmodifiedProvisions] =
sortModifiedProvisions(submission)
const provisionsAreInvalid = isMissingProvisions(submission) && isEditing
const { documentDates } =
useOutletContext<SideNavOutletContextType>()

useEffect(() => {
// get all the keys for the documents we want to zip
async function fetchZipUrl() {
Expand Down Expand Up @@ -168,23 +168,31 @@ export const ContractDetailsSummarySection = ({
<DoubleColumnGrid>
<DataDetail
id="modifiedProvisions"
label={isBaseContract(submission)? "This contract action includes provisions related to the following" : "This contract action includes new or modified provisions related to the following"}
label={
isBaseContract(submission)
? 'This contract action includes provisions related to the following'
: 'This contract action includes new or modified provisions related to the following'
}
explainMissingData={
provisionsAreInvalid && !isSubmitted(submission)
}
>
{provisionsAreInvalid ? null : (
<DataDetailCheckboxList
list={modifiedProvisions}
dict={getProvisionDictionary(submission) }
dict={getProvisionDictionary(submission)}
displayEmptyList
/>
)}
</DataDetail>

<DataDetail
id="unmodifiedProvisions"
label={isBaseContract(submission)? "This contract action does NOT include provisions related to the following": "This contract action does NOT include new or modified provisions related to the following"}
label={
isBaseContract(submission)
? 'This contract action does NOT include provisions related to the following'
: 'This contract action does NOT include new or modified provisions related to the following'
}
explainMissingData={
provisionsAreInvalid && !isSubmitted(submission)
}
Expand All @@ -202,14 +210,14 @@ export const ContractDetailsSummarySection = ({
</dl>
<UploadedDocumentsTable
documents={submission.contractDocuments}
documentDateLookupTable={documentDates}
documentDateLookupTable={documentDateLookupTable}
isCMSUser={isCMSUser}
caption="Contract"
documentCategory="Contract"
/>
<UploadedDocumentsTable
documents={contractSupportingDocuments}
documentDateLookupTable={documentDates}
documentDateLookupTable={documentDateLookupTable}
isCMSUser={isCMSUser}
caption="Contract supporting documents"
documentCategory="Contract-supporting"
Expand Down
Loading

0 comments on commit c9c3bcc

Please sign in to comment.