Skip to content

Commit

Permalink
More Cypress work
Browse files Browse the repository at this point in the history
  • Loading branch information
haworku committed Apr 23, 2024
1 parent 854f452 commit 466fd31
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ const Contacts = ({
showPageErrorMessage={showPageErrorMessage ?? false}
/>
</div>
<FormContainer id="state-submission-form-page">
<FormContainer id="Contacts">
<Formik
initialValues={contactsInitialValues}
onSubmit={handleFormSubmit}
Expand Down Expand Up @@ -448,6 +448,7 @@ const Contacts = ({
0 && (
<Button
type="button"

unstyled
className={
styles.removeContactBtn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ export const ContractDetails = ({
showPageErrorMessage={showPageErrorMessage ?? false}
/>
</div>
<FormContainer id="state-submission-form-page">
<FormContainer id="ContactDetails">
<Formik
initialValues={contractDetailsInitialValues}
onSubmit={(values, { setSubmitting }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export const Documents = (): React.ReactElement => {
showPageErrorMessage={showPageErrorMessage ?? false}
/>
</div>
<FormContainer id="state-submission-form-page">
<FormContainer id="Documents">
<UswdsForm
className={classNames(
styles.tableContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export const RateDetails = ({
showPageErrorMessage={showPageErrorMessage ?? false}
/>
</div>
<FormContainer id="state-submission-form-page">
<FormContainer id="RateDetails">
<Formik
initialValues={rateInfosInitialValues}
onSubmit={({ rateInfos }, { setSubmitting }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const ReviewSubmit = (): React.ReactElement => {
/>
</div>

<FormContainer id="state-submission-form-page">
<FormContainer id="ReviewSubmit">
<GridContainer className={styles.reviewSectionWrapper}>
<SubmissionTypeSummarySection
submission={draftSubmission}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const StateSubmissionForm = (): React.ReactElement => {
featureFlags.LINK_RATES.defaultValue
)
return (
<div className={styles.formPage}>
<div data-testid='state-submission-form-page' className={styles.formPage}>
<Routes>
<Route
path={getRelativePathFromNestedRoute('SUBMISSIONS_TYPE')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export const SubmissionType = ({
showPageErrorMessage={showPageErrorMessage ?? false}
/>
</div>
<FormContainer id="state-submission-form-page">
<FormContainer id="SubmissionType">
<Formik
initialValues={submissionTypeInitialValues}
onSubmit={handleFormSubmit}
Expand Down
26 changes: 18 additions & 8 deletions services/cypress/integration/cmsWorkflow/unlockResubmit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,16 @@ describe('CMS user', () => {
})
})

it('can unlock and resubmit with linked rates', () => {
cy.interceptFeatureFlags({"link-rates": true})
it.skip('can unlock and resubmit with linked rates', () => {
cy.interceptFeatureFlags({"link-rates": true, '438-attestation': true})
cy.logInAsStateUser()

// fill out an entire submission
// fill out contract details
cy.startNewContractAndRatesSubmission()
cy.fillOutBaseContractDetails()
cy.navigateFormByButtonClick('CONTINUE')

// fill out three rate details - two with child rates AND one with a linked rate
cy.findByRole('heading', {
level: 2,
name: /Rate details/,
Expand All @@ -244,18 +245,24 @@ describe('CMS user', () => {
name: 'Add another rate certification',
}).click()
cy.findAllByTestId('rate-certification-form').each((form) =>
cy.wrap(form).within(() => cy.fillOutNewRateCertification())
cy.wrap(form).within(() => {
cy.fillOutNewRateCertification();
})
)
cy.navigateFormByButtonClick('CONTINUE')
cy.navigateContractRatesFormByButtonClick('CONTINUE')

// fill out the rest of the form
cy.findByRole('heading', {
level: 2,
name: /Contacts/,
}).should('exist')
cy.fillOutStateContact()
cy.fillOutAdditionalActuaryContact()
// There is a currently bug with actuary contacts with linked rates that makes us delete actuary contacts that aren't even filled out on this page
cy.findAllByRole('button', { name: 'Remove contact' }).last()
.should('exist')
.click()
cy.fillOutAdditionalActuaryContact();
cy.navigateFormByButtonClick('CONTINUE')

cy.findByRole('heading', {
level: 2,
name: /Supporting documents/,
Expand All @@ -281,7 +288,7 @@ describe('CMS user', () => {
// Login as CMS User
cy.logOut()
cy.logInAsCMSUser({ initialURL: submissionURL })

cy.wait('@fetchContractQuery', { timeout: 20_000 })
// click on the unlock button, type in reason and confirm
cy.unlockSubmission()

Expand Down Expand Up @@ -319,6 +326,7 @@ describe('CMS user', () => {
.and('include', 'review-and-submit')

cy.navigateFormByDirectLink(reviewURL)
cy.wait('@fetchContractQuery', { timeout: 20_000 })

//Unlock banner for state user to be present with correct data.
cy.findByRole('heading', {
Expand Down Expand Up @@ -362,6 +370,7 @@ describe('CMS user', () => {
// Login as CMS User
cy.logOut()
cy.logInAsCMSUser({ initialURL: submissionURL })
cy.wait('@fetchContractQuery', { timeout: 20_000 })

// CMS user sees resubmitted submission and active unlock button
cy.findByTestId('submission-summary', {timeout: 4_000}).should('exist')
Expand Down Expand Up @@ -406,6 +415,7 @@ describe('CMS user', () => {
cy.logOut()
cy.logInAsStateUser()
cy.navigateFormByDirectLink(reviewURL)
cy.wait('@fetchContractQuery', { timeout: 20_000 })
cy.findByTestId('unlockedBanner').should('exist')
cy.submitStateSubmissionForm({
success: true,
Expand Down
2 changes: 1 addition & 1 deletion services/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ Cypress.Commands.add('interceptGraphQL', () => {
aliasQuery(req, 'fetchHealthPlanPackageWithQuestions')
aliasQuery(req, 'indexHealthPlanPackages')
aliasQuery(req, 'indexRates')
aliasQuery(req, 'fetchContract')
aliasMutation(req, 'createHealthPlanPackage')
aliasMutation(req, 'updateHealthPlanFormData')
aliasMutation(req, 'submitHealthPlanPackage')
aliasMutation(req, 'updateCMSUser')
aliasMutation(req, 'createQuestion')
aliasMutation(req, 'createQuestionResponse')
aliasMutation(req, 'fetchContract')
aliasMutation(req, 'updateDraftContractRates')
aliasMutation(req, 'submitContract')
}).as('GraphQL')
Expand Down
4 changes: 4 additions & 0 deletions services/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ declare global {
buttonName: FormButtonKey,
waitForLoad?: boolean
): void
navigateContractRatesFormByButtonClick(
buttonName: FormButtonKey,
waitForLoad?: boolean
): void
navigateFormByDirectLink(url: string, waitForLoad?: boolean): void

// dashboard commands
Expand Down
34 changes: 34 additions & 0 deletions services/cypress/support/navigateCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,40 @@ Cypress.Commands.add(
}
}
)
// navigate helper for v2 forms
Cypress.Commands.add(
'navigateContractRatesFormByButtonClick',
(buttonKey: FormButtonKey, waitForLoad = true) => {
cy.findByRole('button', {
name: buttonsWithLabels[buttonKey],
}).should('not.have.attr', 'aria-disabled')
cy.findByRole('button', {
name: buttonsWithLabels[buttonKey],
}).safeClick()

if (buttonKey === 'SAVE_DRAFT') {
if(waitForLoad) {
cy.wait('@updateDraftContractRatesMutation', { timeout: 50_000})
}
cy.findByTestId('state-dashboard-page').should('exist')
cy.findByRole('heading',{name:'Submissions'}).should('exist')
} else if (buttonKey === 'CONTINUE_FROM_START_NEW') {
if (waitForLoad) {
// cy.wait('@createContractMutation', { timeout: 50_000 })
cy.wait('@fetchContractQuery')
}
cy.findByTestId('state-submission-form-page').should('exist')
} else if (buttonKey === 'CONTINUE') {
if (waitForLoad) {
cy.findAllByTestId('errorMessage').should('have.length', 0)
cy.wait('@updateDraftContractRatesMutation', { timeout: 50_000})
}
cy.findByTestId('state-submission-form-page').should('exist')
} else {
cy.findByTestId('state-submission-form-page').should('exist')
}
}
)

Cypress.Commands.add(
'navigateFormByDirectLink',
Expand Down
74 changes: 56 additions & 18 deletions services/cypress/support/stateSubmissionFormCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,30 @@ Cypress.Commands.add('fillOutAmendmentToBaseContractDetails', () => {
Cypress.Commands.add('fillOutNewRateCertification', () => {
// Must be on '/submissions/:id/edit/rate-details'
// Must be a contract and rates submission
cy.findByRole('radiogroup', {
name: /Was this rate certification uploaded to any other submissions?/,
})
.should('exist')
.within(() => {
cy.findByText(/No/).click()
cy.getFeatureFlagStore(['link-rates']).then((store) => {

if (store['link-rates']) {
//If this flag value is true, then it will test this code hidden behind the feature flag
cy.findByRole('radiogroup', {
name: /Was this rate certification included with another submission?/,
})
.should('exist')
.within(() => {
cy.findByText('No, this rate certification was not included with any other submissions').click()
})

} else {
// otherwise use legacy packages with shared rates UI
cy.findByRole('radiogroup', {
name: /Was this rate certification uploaded to any other submissions?/,
})
.should('exist')
.within(() => {
cy.findByText(/No/).click()
})

}


cy.findByText('New rate certification').click()
cy.findByText(
Expand Down Expand Up @@ -362,19 +379,21 @@ Cypress.Commands.add('fillOutNewRateCertification', () => {
cy.waitForDocumentsToLoad()
cy.findAllByTestId('errorMessage').should('have.length', 0)
})
})

Cypress.Commands.add('fillOutLinkedRate', () => {
// Must be on '/submissions/:id/edit/rate-details'
// Must be a contract and rates submission
cy.findByRole('radiogroup', {
name: /Was this rate certification uploaded to any other submissions?/,
})
.should('exist')
.within(() => {
cy.findByText('Yes, this rate certification is part of another submissio').click()
})
cy.getFeatureFlagStore(['link-rates']).then((store) => {
//If this flag value is true, then it will test this code hidden behind the feature flag
cy.findByRole('radiogroup', {
name: /Was this rate certification included with another submission?/,
})
.should('exist')
.within(() => {
cy.findByText('Yes, this rate certification is part of another submission').click()
})

if (store['link-rates']) {
cy.findByRole('combobox', { name: 'Which rate certification was it?' }).click({
force: true,
Expand All @@ -387,7 +406,6 @@ Cypress.Commands.add('fillOutLinkedRate', () => {
cy.waitForDocumentsToLoad()
cy.findAllByTestId('errorMessage').should('have.length', 0)
})
cy.findAllByTestId('errorMessage').should('have.length', 0)
})

Cypress.Commands.add('fillOutAmendmentToPriorRateCertification', (id = 0) => {
Expand Down Expand Up @@ -511,24 +529,44 @@ Cypress.Commands.add(
name: 'Submit',
}).safeClick()

cy.findAllByTestId('modalWindow')
cy.getFeatureFlagStore(['link-rates']).then((store) => {
cy.findAllByTestId('modalWindow')
.eq(1)
.should('exist')
.within(() => {
if (resubmission) {
cy.get('#unlockSubmitModalInput').type(
summary || 'Resubmission summary'
)
cy.findByTestId('resubmit-modal-submit').click()
if (store['link-rates']) {
cy.findByTestId('resubmit_contract-modal-submit').click()
}else {
cy.findByTestId('resubmit-modal-submit').click()
}
} else {
cy.findByTestId('submit-modal-submit').click()

if (store['link-rates']) {
cy.findByTestId('submit_contract-modal-submit').click()
}else {
cy.findByTestId('submit-modal-submit').click()
}

}
})
cy.wait('@submitHealthPlanPackageMutation', { timeout: 50_000 })

if (store['link-rates']) {
cy.wait('@submitContractMutation', { timeout: 50_000 })
} else {
cy.wait('@submitHealthPlanPackageMutation', { timeout: 50_000 })
}


if (success) {
cy.findByTestId('state-dashboard-page').should('exist')
cy.findByRole('heading',{name:'Submissions'}).should('exist')
}
})


}
)

0 comments on commit 466fd31

Please sign in to comment.