Skip to content

Commit

Permalink
Add and update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLin0991 committed Nov 16, 2023
1 parent c3c565e commit 087c3e2
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function newHealthPlanFormData(): UnlockedHealthPlanFormDataType {
federalAuthorities: [],
stateContacts: [],
addtlActuaryContacts: [],
statutoryRegulatoryAttestation: true,
}
}

Expand Down Expand Up @@ -85,6 +86,7 @@ function basicHealthPlanFormData(): UnlockedHealthPlanFormDataType {
federalAuthorities: ['VOLUNTARY', 'BENCHMARK'],
stateContacts: [],
addtlActuaryContacts: [],
statutoryRegulatoryAttestation: true,
}
}

Expand Down Expand Up @@ -112,6 +114,7 @@ function contractOnly(): UnlockedHealthPlanFormDataType {
federalAuthorities: ['VOLUNTARY', 'BENCHMARK'],
stateContacts: [],
addtlActuaryContacts: [],
statutoryRegulatoryAttestation: true,
}
}

Expand Down Expand Up @@ -160,6 +163,8 @@ function contractAmendedOnly(): UnlockedHealthPlanFormDataType {
modifiedNonRiskPaymentArrangements: true,
},
},
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
}
}

Expand Down Expand Up @@ -248,6 +253,8 @@ function unlockedWithContacts(): UnlockedHealthPlanFormDataType {
},
],
addtlActuaryCommunicationPreference: 'OACT_TO_ACTUARY',
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
}
}

Expand Down Expand Up @@ -363,6 +370,8 @@ function unlockedWithDocuments(): UnlockedHealthPlanFormDataType {
},
],
addtlActuaryCommunicationPreference: 'OACT_TO_ACTUARY',
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
}
}

Expand Down Expand Up @@ -471,6 +480,8 @@ function unlockedWithFullRates(): UnlockedHealthPlanFormDataType {
},
],
addtlActuaryCommunicationPreference: 'OACT_TO_ACTUARY',
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
}
}

Expand Down Expand Up @@ -607,6 +618,8 @@ function unlockedWithFullContracts(): UnlockedHealthPlanFormDataType {
},
],
addtlActuaryCommunicationPreference: 'OACT_TO_ACTUARY',
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
}
}

Expand Down Expand Up @@ -747,6 +760,8 @@ function unlockedWithALittleBitOfEverything(): UnlockedHealthPlanFormDataType {
},
],
addtlActuaryCommunicationPreference: 'OACT_TO_ACTUARY',
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
}
}

Expand All @@ -763,7 +778,6 @@ function basicLockedHealthPlanFormData(): LockedHealthPlanFormDataType {
programIDs: [mockMNState().programs[0].id],
submissionType: 'CONTRACT_ONLY',
riskBasedContract: false,
statutoryRegulatoryAttestation: false,
submissionDescription: 'A real submission',
documents: [],
contractType: 'BASE',
Expand All @@ -789,6 +803,8 @@ function basicLockedHealthPlanFormData(): LockedHealthPlanFormDataType {
],
addtlActuaryContacts: [],
rateInfos: [],
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ describe('ContractDetailsSummarySection', () => {
it('displays correct contract 438 attestation yes and no text', async () => {
ldUseClientSpy({ '438-attestation': true })
const submission = mockContractAndRatesDraft({
statutoryRegulatoryAttestation: true,
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
})
renderWithProviders(
<ContractDetailsSummarySection
Expand All @@ -182,14 +183,20 @@ describe('ContractDetailsSummarySection', () => {
}
)

const attestationYes = StatutoryRegulatoryAttestation.YES

expect(
screen.getByRole('definition', {
name: StatutoryRegulatoryAttestationQuestion,
})
).toBeInTheDocument()
expect(await screen.findByText(attestationYes)).toBeInTheDocument()
expect(
screen.getByRole('definition', {
name: 'Non-compliance description',
})
).toBeInTheDocument()
expect(
await screen.findByText(StatutoryRegulatoryAttestation.NO)
).toBeInTheDocument()
expect(await screen.findByText('No compliance')).toBeInTheDocument()
})

it('displays correct effective dates text for base contract', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
mockDraft,
fetchCurrentUserMock,
mockBaseContract,
mockContractAndRatesDraft,
} from '../../../testHelpers/apolloMocks'

import {
Expand All @@ -29,6 +30,7 @@ import {
} from '../../../common-code/healthPlanFormDataType'
import {
StatutoryRegulatoryAttestation,
StatutoryRegulatoryAttestationDescription,
StatutoryRegulatoryAttestationQuestion,
} from '../../../constants/statutoryRegulatoryAttestation'

Expand Down Expand Up @@ -1055,17 +1057,31 @@ describe('ContractDetails', () => {
name: StatutoryRegulatoryAttestation.YES,
})
const noRadio = screen.getByRole('radio', {
name: StatutoryRegulatoryAttestation.YES,
name: StatutoryRegulatoryAttestation.NO,
})

// expect both yes and no answers on the page and yes to be checked
expect(yesRadio).toBeChecked()
expect(noRadio).toBeInTheDocument()

await userEvent.click(noRadio)
expect(noRadio).toBeChecked()

const nonComplianceTextBox = screen.getByRole('textbox', {
name: StatutoryRegulatoryAttestationDescription,
})
// expect 438 non-compliance description text box to be in the document
await waitFor(() => {
expect(nonComplianceTextBox).toBeInTheDocument()
})
})
it('errors when continuing without answering 438 attestation question', async () => {
ldUseClientSpy({ '438-attestation': true })
const draft = mockBaseContract({
const draft = mockContractAndRatesDraft({
contractDateStart: new Date('11-12-2023'),
contractDateEnd: new Date('11-12-2024'),
statutoryRegulatoryAttestation: undefined,
statutoryRegulatoryAttestationDescription: undefined,
})
const mockUpdateDraftFn = jest.fn()
await waitFor(() => {
Expand All @@ -1090,16 +1106,13 @@ describe('ContractDetails', () => {
name: StatutoryRegulatoryAttestation.YES,
})
const noRadio = screen.getByRole('radio', {
name: StatutoryRegulatoryAttestation.YES,
name: StatutoryRegulatoryAttestation.NO,
})

// expect both yes and no answers on the page and yes to be checked
expect(yesRadio).toBeInTheDocument()
expect(noRadio).toBeInTheDocument()

// check no radio
await userEvent.click(noRadio)

const continueButton = screen.getByRole('button', {
name: 'Continue',
})
Expand All @@ -1114,6 +1127,94 @@ describe('ContractDetails', () => {
screen.queryAllByText('You must select yes or no')
).toHaveLength(2)
})

// Click the Yes radio
await userEvent.click(yesRadio)

// click continue
await userEvent.click(continueButton)

// There should be no errors
await waitFor(() => {
expect(mockUpdateDraftFn).toHaveBeenCalled()
expect(
screen.queryAllByText('You must select yes or no')
).toHaveLength(0)
})
})
it('errors when continuing without description for 438 non-compliance', async () => {
ldUseClientSpy({ '438-attestation': true })
const draft = mockContractAndRatesDraft({
contractDateStart: new Date('11-12-2023'),
contractDateEnd: new Date('11-12-2024'),
statutoryRegulatoryAttestation: undefined,
statutoryRegulatoryAttestationDescription: undefined,
})
const mockUpdateDraftFn = jest.fn()
await waitFor(() => {
renderWithProviders(
<ContractDetails
draftSubmission={draft}
updateDraft={mockUpdateDraftFn}
previousDocuments={[]}
/>,
{
apolloProvider: defaultApolloProvider,
}
)
})

// expect 438 attestation question to be on the page
expect(
screen.getByText(StatutoryRegulatoryAttestationQuestion)
).toBeInTheDocument()

const continueButton = screen.getByRole('button', {
name: 'Continue',
})
const noRadio = screen.getByRole('radio', {
name: StatutoryRegulatoryAttestation.NO,
})

// check no radio
await userEvent.click(noRadio)

const nonComplianceTextBox = screen.getByRole('textbox', {
name: StatutoryRegulatoryAttestationDescription,
})

// expect 438 non-compliance description text box to be in the document
await waitFor(() => {
expect(nonComplianceTextBox).toBeInTheDocument()
})

// try to continue without typing in non-compliance explanation
await userEvent.click(continueButton)

// expect errors for attestation question
await waitFor(() => {
expect(mockUpdateDraftFn).not.toHaveBeenCalled()
expect(
screen.queryAllByText(
'You must provide a description of the contract’s non-compliance'
)
).toHaveLength(2)
})

await userEvent.type(nonComplianceTextBox, 'No compliance')

// continue with explanation
await userEvent.click(continueButton)

// expect no errors
await waitFor(() => {
expect(mockUpdateDraftFn).toHaveBeenCalled()
expect(
screen.queryAllByText(
'You must provide a description of the contract’s non-compliance'
)
).toHaveLength(0)
})
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ function mockDraft(
stateContacts: [],
addtlActuaryContacts: [],
addtlActuaryCommunicationPreference: undefined,
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
...partial,
}
}
Expand Down Expand Up @@ -116,7 +118,8 @@ function mockBaseContract(
],
addtlActuaryContacts: [],
addtlActuaryCommunicationPreference: undefined,
statutoryRegulatoryAttestation: true,
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
...partial,
}
}
Expand All @@ -139,7 +142,14 @@ function mockContractAndRatesDraft(
documents: [],
contractType: 'AMENDMENT',
contractExecutionStatus: 'EXECUTED',
contractDocuments: [],
contractDocuments: [
{
s3URL: 's3://bucketname/key/contract',
sha256: 'fakesha',
name: 'contract',
documentCategories: ['CONTRACT' as const],
},
],
contractDateStart: new Date(),
contractDateEnd: new Date(),
contractAmendmentInfo: {
Expand Down Expand Up @@ -212,7 +222,8 @@ function mockContractAndRatesDraft(
},
],
addtlActuaryCommunicationPreference: 'OACT_TO_ACTUARY',
statutoryRegulatoryAttestation: true,
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
...partial,
}
}
Expand Down Expand Up @@ -321,6 +332,7 @@ function mockStateSubmission(): LockedHealthPlanFormDataType {
addtlActuaryContacts: [],
addtlActuaryCommunicationPreference: undefined,
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
}
}

Expand Down Expand Up @@ -421,6 +433,7 @@ function mockStateSubmissionContractAmendment(): LockedHealthPlanFormDataType {
addtlActuaryContacts: [],
addtlActuaryCommunicationPreference: undefined,
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance',
}
}

Expand Down
7 changes: 6 additions & 1 deletion services/cypress/support/stateSubmissionFormCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ Cypress.Commands.add('fillOutContractActionAndRateCertification', () => {
Cypress.Commands.add('fillOutBaseContractDetails', () => {
// Must be on '/submissions/:id/edit/contract-details'
// Contract 438 attestation question
cy.findByText('Yes, the contract fully complies with all applicable requirements').click()
cy.findByText('No, the contract does not fully comply with all applicable requirements').click()

cy.findByRole('textbox', {name: 'Please provide a brief description of the contract’s non-compliance (with regulatory citations) and expected timeframe for remediation'})
.type('Non compliance explanation')

cy.findByText('Fully executed').click()
cy.findAllByLabelText('Start date', {timeout: 2000})
Expand Down Expand Up @@ -179,6 +182,8 @@ Cypress.Commands.add('fillOutAmendmentToBaseContractDetails', () => {
// Must be on '/submissions/:id/edit/contract-details'
// Contract 438 attestation question
cy.findByText('No, the contract does not fully comply with all applicable requirements').click()
cy.findByRole('textbox', {name: 'Please provide a brief description of the contract’s non-compliance (with regulatory citations) and expected timeframe for remediation'})
.type('Non compliance explanation')

cy.findByText('Unexecuted by some or all parties').click()

Expand Down
3 changes: 2 additions & 1 deletion services/cypress/utils/apollo-test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ const contractAndRatesData = (): Partial<UnlockedHealthPlanFormDataType>=> ({
packagesWithSharedRateCerts: [],
},
],
statutoryRegulatoryAttestation: true
statutoryRegulatoryAttestation: false,
statutoryRegulatoryAttestationDescription: 'No compliance'
})

const newSubmissionInput = (overrides?: Partial<UnlockedHealthPlanFormDataType> ): Partial<UnlockedHealthPlanFormDataType> => {
Expand Down

0 comments on commit 087c3e2

Please sign in to comment.