Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCR-4873: update the contract actions section on rate summary page #3069

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions packages/mocks/src/apollo/contractPackageDataMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,7 @@ function mockContractPackageApprovedWithQuestions(
function mockContractPackageSubmittedWithRevisions(
partial?: Partial<Contract>
): Contract {
const contractID = partial?.id || 'test-abc-123'
return {
__typename: 'Contract',
status: 'SUBMITTED',
Expand All @@ -1696,7 +1697,7 @@ function mockContractPackageSubmittedWithRevisions(
lastUpdatedForDisplay: new Date(),
initiallySubmittedAt: new Date('2024-01-01'),
mccrsID: null,
id: 'test-abc-123',
id: contractID,
webURL: 'https://testmcreview.example/submissions/test-abc-123',
stateCode: 'MN',
state: mockMNState(),
Expand All @@ -1719,8 +1720,9 @@ function mockContractPackageSubmittedWithRevisions(
},
updatedReason: 'submit 3',
},
submittedRevisions: [mockContractRevision('3')],
submittedRevisions: [mockContractRevision('3', { contractID })],
contractRevision: mockContractRevision('3', {
contractID,
unlockInfo: {
__typename: 'UpdateInformation',
updatedAt: '2024-03-01T17:54:39.173Z',
Expand Down Expand Up @@ -1749,8 +1751,9 @@ function mockContractPackageSubmittedWithRevisions(
},
updatedReason: 'submit 2',
},
submittedRevisions: [mockContractRevision('2')],
submittedRevisions: [mockContractRevision('2', { contractID })],
contractRevision: mockContractRevision('2', {
contractID,
unlockInfo: {
__typename: 'UpdateInformation',
updatedAt: '2024-01-25T21:13:56.174Z',
Expand Down Expand Up @@ -1779,8 +1782,8 @@ function mockContractPackageSubmittedWithRevisions(
},
updatedReason: 'submit 1',
},
submittedRevisions: [mockContractRevision('1')],
contractRevision: mockContractRevision('1'),
submittedRevisions: [mockContractRevision('1', { contractID })],
contractRevision: mockContractRevision('1', { contractID }),
rateRevisions: [mockRateRevision('1')],
},
],
Expand Down Expand Up @@ -2211,6 +2214,7 @@ function mockContractPackageWithDifferentProgramsInRevisions(): Contract {
function mockContractPackageUnlockedWithUnlockedType(
partial?: Partial<UnlockedContract>
): UnlockedContract {
const contractID = partial?.id ?? 'test-abc-123'
return {
status: 'UNLOCKED',
reviewStatus: 'UNDER_REVIEW',
Expand All @@ -2220,15 +2224,15 @@ function mockContractPackageUnlockedWithUnlockedType(
updatedAt: '2024-12-01T16:54:39.173Z',
lastUpdatedForDisplay: '2024-12-01T16:54:39.173Z',
initiallySubmittedAt: new Date('2023-01-01'),
id: 'test-abc-123',
id: contractID,
webURL: 'https://testmcreview.example/submissions/test-abc-123',
stateCode: 'MN',
state: mockMNState(),
stateNumber: 5,
mccrsID: '1234',
draftRevision: {
__typename: 'ContractRevision',
contractID: 'test-abc-123',
contractID,
submitInfo: null,
unlockInfo: {
__typename: 'UpdateInformation',
Expand Down Expand Up @@ -2312,7 +2316,7 @@ function mockContractPackageUnlockedWithUnlockedType(
revisions: [],
state: mockMNState(),
stateNumber: 5,
parentContractID: 'test-abc-123',
parentContractID: contractID,
draftRevision: {
__typename: 'RateRevision',
id: 'unlocked-rr-123',
Expand Down Expand Up @@ -2401,7 +2405,7 @@ function mockContractPackageUnlockedWithUnlockedType(
contractName: 'MCR-MN-0005-SNBC',
createdAt: new Date('01/01/2024'),
updatedAt: '2023-01-01T16:54:39.173Z',
contractID: 'test-abc-123',
contractID,
submitInfo: {
__typename: 'UpdateInformation',
updatedAt: '2023-01-01T16:54:39.173Z',
Expand Down Expand Up @@ -2465,7 +2469,7 @@ function mockContractPackageUnlockedWithUnlockedType(
],
contractRevision: {
__typename: 'ContractRevision',
contractID: 'test-abc-123',
contractID,
contractName: 'MCR-MN-0005-SNBC',
createdAt: new Date('01/01/2024'),
updatedAt: '2024-01-01T18:54:39.173Z',
Expand Down
2 changes: 1 addition & 1 deletion services/app-graphql/src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1976,7 +1976,7 @@ type UnlockedContract {
"""
consolidatedStatus: ConsolidatedContractStatus!
"initiallySubmittedAt is the initial date this contract was submitted at. Is not changed by unlock or resubmission."
initiallySubmittedAt: Date
initiallySubmittedAt: DateTime
"lastUpdatedForDisplay is the last time this contract was officially updated. When it's a draft it will be the last updatedAt date. Afterwards it will be the most recent submit or unlock or review action date."
lastUpdatedForDisplay: DateTime!
"stateCode is the state code (e.g. CA or TN) for the submitting state"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import { renderWithProviders } from '../../../testHelpers'
import { SingleRateSummarySection } from './SingleRateSummarySection'
import {
fetchCurrentUserMock,
mockContractPackageSubmittedWithRevisions,
mockContractPackageUnlockedWithUnlockedType,
mockEmptyDraftContractAndRate,
mockValidCMSUser,
mockValidHelpDeskUser,
mockValidStateUser,
} from '@mc-review/mocks'
import { screen, within } from '@testing-library/react'
import { rateWithHistoryMock } from '@mc-review/mocks'
import type { Contract } from '../../../gen/gqlClient'

describe('SingleRateSummarySection', () => {
it('can render rate details without errors', async () => {
Expand Down Expand Up @@ -260,6 +263,82 @@ describe('SingleRateSummarySection', () => {
)
})

it('renders contract actions correctly after rate withdraw', async () => {
const rateData = rateWithHistoryMock()
const parentContractRev =
rateData.packageSubmissions?.[2].contractRevisions[0]
if (!parentContractRev) {
throw new Error('no parent')
}

const withdrawnContractOne = mockContractPackageSubmittedWithRevisions({
id: 'c-01',
})

const withdrawnContractOnePkgName =
withdrawnContractOne.packageSubmissions[0].contractRevision
.contractName

const withdrawnContractTwo =
mockContractPackageUnlockedWithUnlockedType({
id: 'c-02',
})

const withdrawnContractTwoPkgName =
withdrawnContractTwo.packageSubmissions[0].contractRevision
.contractName

const withdrawnFromContracts = [
withdrawnContractOne,
withdrawnContractTwo as Contract,
]

// add in contracts this rate was withdrawn from
rateData.withdrawnFromContracts = withdrawnFromContracts

renderWithProviders(
<SingleRateSummarySection
rate={rateData}
isSubmitted={true}
statePrograms={rateData.state.programs}
/>,
{
apolloProvider: {
mocks: [
fetchCurrentUserMock({
statusCode: 200,
user: mockValidCMSUser(),
}),
],
},
}
)

expect(
screen.getByRole('heading', { name: 'Rate documents' })
).toBeInTheDocument()

const relatedContractActions = screen.getByRole('definition', {
name: 'Contract actions',
})

// Expect submissions this rate was submitted with link to exists
expect(relatedContractActions).toBeInTheDocument()
expect(
within(relatedContractActions).getByRole('link', {
name: withdrawnContractOnePkgName,
})
).toBeInTheDocument()
expect(
within(relatedContractActions).getByRole('link', {
name: withdrawnContractTwoPkgName,
})
).toHaveAttribute(
'href',
`/submissions/${parentContractRev.contractID}`
)
})

describe('Missing data error notifications', () => {
const mockEmptyRateData = () => {
const emptyDraftRates = mockEmptyDraftContractAndRate().draftRates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,21 @@ export const SingleRateSummarySection = ({
rate.status === 'SUBMITTED' ||
rate.status === 'RESUBMITTED' ||
isCMSUser
const isWithdrawn = rate.consolidatedStatus === 'WITHDRAWN'

const linkedContracts = latestSubmission.contractRevisions
const withdrawnFromContractRevs =
rate.withdrawnFromContracts?.reduce((acc, contract) => {
const latestRevision =
contract.packageSubmissions?.[0].contractRevision
if (latestRevision) {
acc.push(latestRevision)
}
return acc
}, [] as ContractRevision[]) ?? []

const contractActions = isWithdrawn
? withdrawnFromContractRevs
: latestSubmission.contractRevisions

// TODO BULK DOWNLOAD
// needs to be wrap in a standalone hook
Expand Down Expand Up @@ -338,7 +351,7 @@ export const SingleRateSummarySection = ({
<DataDetail
id="submittedWithContract"
label="Contract actions"
children={relatedSubmissions(linkedContracts)}
children={relatedSubmissions(contractActions)}
/>
</Grid>
</dl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ const convertIndexRatesGQLRateToRateForm = (getKey: S3ClientT['getKey'], rate?:
}
}


// Convert from GQL Rate to FormikRateForm object used in the form
// if rate is not passed in, return an empty RateForm // we need to pass in the s3 handler because 3 urls generated client-side
// useLatestSubmission means to pull the latest submitted info rather than the draft info
Expand Down
Loading