Skip to content

Commit

Permalink
SubmissionSummaryV2 bug (#2381)
Browse files Browse the repository at this point in the history
* add extra checks for data returned from fetchContract; change page header

* use mockedSubmitted contract in test
  • Loading branch information
pearl-truss authored Apr 25, 2024
1 parent dc216ba commit d78730d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ describe('SubmissionSummary', () => {
statusCode: 200,
}),
fetchContractMockSuccess({
contract: {
id: 'test-abc-123',
},
contract: mockContractPackageSubmitted(),
}),
fetchStateHealthPlanPackageWithQuestionsMockSuccess({
id: 'test-abc-123',
Expand All @@ -51,7 +49,6 @@ describe('SubmissionSummary', () => {
},
}
)
screen.debug()
expect(
await screen.findByRole('heading', { name: 'Contract details' })
).toBeInTheDocument()
Expand Down Expand Up @@ -461,9 +458,7 @@ describe('SubmissionSummary', () => {
id: 'test-abc-123',
}),
fetchContractMockSuccess({
contract: {
id: 'test-abc-123',
},
contract: mockContractPackageSubmitted(),
}),
],
},
Expand All @@ -475,6 +470,7 @@ describe('SubmissionSummary', () => {
},
}
)
screen.debug()
expect(
await screen.findByRole('heading', {
name: 'Contract details',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import React, { useEffect, useRef, useState } from 'react'
import { NavLink } from 'react-router-dom'
import { useAuth } from '../../../contexts/AuthContext'
import { packageName } from '../../../common-code/healthPlanFormDataType'
import { ContractDetailsSummarySectionV2 } from '../../StateSubmission/ReviewSubmit/V2/ReviewSubmit/ContractDetailsSummarySectionV2'
import { ContactsSummarySection } from '../../StateSubmission/ReviewSubmit/V2/ReviewSubmit/ContactsSummarySectionV2'
import { RateDetailsSummarySectionV2 } from '../../StateSubmission/ReviewSubmit/V2/ReviewSubmit/RateDetailsSummarySectionV2'
Expand Down Expand Up @@ -61,13 +60,9 @@ export const SubmissionSummaryV2 = (): React.ReactElement => {
// Page level state
const { updateHeading } = usePage()
const modalRef = useRef<ModalRef>(null)
const [pkgName, setPkgName] = useState<string | undefined>(undefined)
const [documentError, setDocumentError] = useState(false)
const { loggedInUser } = useAuth()

useEffect(() => {
updateHeading({ customHeading: pkgName })
}, [pkgName, updateHeading])
const { id } = useRouteParams()

const ldClient = useLDClient()
Expand All @@ -87,16 +82,29 @@ export const SubmissionSummaryV2 = (): React.ReactElement => {
contractID: id ?? 'unknown-contract',
},
},
fetchPolicy: 'network-only'
fetchPolicy: 'network-only',
})
const contract = fetchContractData?.fetchContract.contract
const name =
contract && contract?.packageSubmissions.length > 0
? contract.packageSubmissions[0].contractRevision.contractName
: ''
useEffect(() => {
updateHeading({
customHeading: name,
})
}, [name, updateHeading])
if (fetchContractLoading) {
return (
<GridContainer>
<Loading />
</GridContainer>
)
} else if (fetchContractError || !contract) {
} else if (
fetchContractError ||
!contract ||
contract.packageSubmissions.length === 0
) {
//error handling for a state user that tries to access rates for a different state
if (
fetchContractError?.graphQLErrors[0]?.extensions?.code ===
Expand All @@ -121,27 +129,15 @@ export const SubmissionSummaryV2 = (): React.ReactElement => {
const submissionStatus = contract.status
const statePrograms = contract.state.programs

const contractFormData = getVisibleLatestContractFormData(contract, isStateUser)
const contractFormData = getVisibleLatestContractFormData(
contract,
isStateUser
)
if (!contractFormData) {
console.error('no form data inside submission summary')
return <GenericErrorPage />
}

const programIDs = contractFormData.programIDs
const programs = statePrograms.filter((program) =>
programIDs.includes(program.id)
)
// set the page heading
const name = packageName(
contract.stateCode,
contract.stateNumber,
contractFormData.programIDs,
programs
)
if (pkgName !== name) {
setPkgName(name)
}

// Get the correct update info depending on the submission status
let updateInfo: UpdateInformation | undefined = undefined
if (submissionStatus === 'UNLOCKED' || submissionStatus === 'RESUBMITTED') {
Expand Down

0 comments on commit d78730d

Please sign in to comment.