Skip to content

Commit

Permalink
Cypress work for unlockResubmit
Browse files Browse the repository at this point in the history
  • Loading branch information
haworku committed Apr 23, 2024
1 parent e1edb6c commit 854f452
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 3 deletions.
222 changes: 222 additions & 0 deletions services/cypress/integration/cmsWorkflow/unlockResubmit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,226 @@ describe('CMS user', () => {
})
})
})

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

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

cy.findByRole('heading', {
level: 2,
name: /Rate details/,
}).should('exist')

cy.findByRole('button', {
name: 'Add another rate certification',
}).click()
cy.findAllByTestId('rate-certification-form').each((form) =>
cy.wrap(form).within(() => cy.fillOutNewRateCertification())
)
cy.navigateFormByButtonClick('CONTINUE')

cy.findByRole('heading', {
level: 2,
name: /Contacts/,
}).should('exist')
cy.fillOutStateContact()
cy.fillOutAdditionalActuaryContact()
cy.navigateFormByButtonClick('CONTINUE')

cy.findByRole('heading', {
level: 2,
name: /Supporting documents/,
}).should('exist')
cy.navigateFormByButtonClick('CONTINUE')

cy.findByRole('heading', {
level: 2,
name: /Review and submit/,
}).should('exist')

// Store submission url for reference later
cy.location().then((fullUrl) => {
const reviewURL = fullUrl.toString()
const submissionURL = reviewURL.replace(
'edit/review-and-submit',
''
)

// Submit, sent to dashboard
cy.submitStateSubmissionForm()

// Login as CMS User
cy.logOut()
cy.logInAsCMSUser({ initialURL: submissionURL })

// click on the unlock button, type in reason and confirm
cy.unlockSubmission()

//Unlock banner for CMS user to be present with correct data.
cy.findByTestId('unlockedBanner')
.should('exist')
.and('contain.text', 'zuko@example.com')
.and('contain.text', 'Unlock submission reason.')
.contains(
/Unlocked on: (0?[1-9]|[12][0-9]|3[01])\/[0-9]+\/[0-9]+\s[0-9]+:[0-9]+[a-zA-Z]+ ET/i
)
.should('exist')

//Find unlocked submission name
cy.get('#submissionName', {timeout: 2_000}).then(($h2) => {
//Set name to variable for later use in finding the unlocked submission
const submissionName = $h2.text()

// Login as state user
cy.logOut()
cy.logInAsStateUser()

// State user sees unlocked submission - check tag then submission link
cy.get('table')
.should('exist')
.findByText(submissionName)
.parent()
.siblings('[data-testid="submission-status"]')
.should('have.text', 'Unlocked')

cy.get('table')
.should('exist')
.findByText(submissionName)
.should('have.attr', 'href')
.and('include', 'review-and-submit')

cy.navigateFormByDirectLink(reviewURL)

//Unlock banner for state user to be present with correct data.
cy.findByRole('heading', {
level: 2,
name: /Review and submit/,
})
cy.findByRole('heading', {
name: `Minnesota ${submissionName}`,
}).should('exist')
cy.findByTestId('unlockedBanner')
.should('exist')
.and('contain.text', 'zuko@example.com')
.and('contain.text', 'Unlock submission reason.')
.contains(
/Unlocked on: (0?[1-9]|[12][0-9]|3[01])\/[0-9]+\/[0-9]+\s[0-9]+:[0-9]+[a-zA-Z]+ ET+/i
)
.should('exist')

cy.submitStateSubmissionForm({success: true, resubmission: true})

cy.get('table')
.should('exist')
.findByText(submissionName)
.parent()
.siblings('[data-testid="submission-status"]')
.should('have.text', 'Submitted')

cy.get('table')
.findByText(submissionName)
.should('have.attr', 'href')
.and('not.include', 'review-and-submit')

// Navigate to resubmitted submission and check for submission updated banner
cy.get('table')
.findByRole('link', { name: submissionName })
.should('exist')
.click()

cy.findByTestId('updatedSubmissionBanner').should('exist')

// Login as CMS User
cy.logOut()
cy.logInAsCMSUser({ initialURL: submissionURL })

// CMS user sees resubmitted submission and active unlock button
cy.findByTestId('submission-summary', {timeout: 4_000}).should('exist')
cy.findByRole('button', { name: 'Unlock submission' }).should(
'not.be.disabled'
)

//CMS user should not see unlock banner and should see updated submission banner
cy.findByTestId('unlockedBanner').should('not.exist')
cy.findByTestId('updatedSubmissionBanner').should('exist')

//Open all change history accordion items
cy.findByTestId('accordion').should('exist')

cy.get('[data-testid^="accordionButton_"]').each((button) => {
button.trigger('click')
button.siblings().hasClass('usa-accordion__content') /// make sure accordion is expanded
})
//Check for view previous submission link in the initial accordion item to exist
cy.findByTestId('revision-link-1').should('be.visible')
cy.clickSubmissionLink('revision-link-1')
//Making sure we are on SubmissionRevisionSummary page and contains version text
cy.findByTestId('revision-version')
.should('exist')
.contains(
/(0?[1-9]|[12][0-9]|3[01])\/[0-9]+\/[0-9]+\s[0-9]+:[0-9]+[a-zA-Z]+ ET version/i
)
//Previous submission banner should exist and able to click link to go back to current submission
cy.findByTestId('previous-submission-banner').should('exist')
//Navigate back to current submission using link inside banner.
cy.clickSubmissionLink('currentSubmissionLink')
//Make sure banner and revision version text are gone.
cy.findByTestId('previous-submission-banner').should(
'not.exist'
)
cy.findByTestId('revision-version').should('not.exist')

// Unlock again and resubmit to test change history
cy.unlockSubmission('Second Unlock')

// Resubmit again
cy.logOut()
cy.logInAsStateUser()
cy.navigateFormByDirectLink(reviewURL)
cy.findByTestId('unlockedBanner').should('exist')
cy.submitStateSubmissionForm({
success: true,
resubmission: true,
summary: 'Second resubmit'
}
)

// Visit the submission url and check the history
cy.navigateFormByDirectLink(submissionURL)
cy.findByTestId('updatedSubmissionBanner').should('exist')

// No document dates or other fields are undefined
cy.findByText('N/A').should('not.exist')

// Should have change history records
cy.findAllByTestId('change-history-record').should('have.length', 5)

cy.findAllByTestId('change-history-record').then(records => {
// We put all the text of each record into an array
const recordText = records.map((index, record) => Cypress.$(record).text())

// Records are in reverse
// Second set of unlock and resubmit
expect(recordText[0]).to.contain('Changes made: Second resubmit')
expect(recordText[1]).to.contain('Reason for unlock: Second Unlock')

// First set of unlock and resubmit
expect(recordText[2]).to.contain('Changes made: Resubmission summary')
expect(recordText[3]).to.contain('Reason for unlock: Unlock submission reason.')

// Test for initial submission
expect(recordText[4]).to.contain('Submitted by: aang@example.com')
expect(recordText[4]).to.contain('View past submission version')
expect(recordText[4]).to.not.contain('Changes made:')
expect(recordText[4]).to.not.contain('Reason for unlock:')
console.log(recordText)
})
})
})
})
})
3 changes: 3 additions & 0 deletions services/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ Cypress.Commands.add('interceptGraphQL', () => {
aliasMutation(req, 'updateCMSUser')
aliasMutation(req, 'createQuestion')
aliasMutation(req, 'createQuestionResponse')
aliasMutation(req, 'fetchContract')
aliasMutation(req, 'updateDraftContractRates')
aliasMutation(req, 'submitContract')
}).as('GraphQL')
})

1 change: 1 addition & 0 deletions services/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ declare global {
fillOutBaseContractDetails(): void
fillOutAmendmentToBaseContractDetails(): void
fillOutNewRateCertification(): void
fillOutLinkedRate(): void
fillOutAmendmentToPriorRateCertification(id?: number): void
fillOutStateContact(): void
fillOutAdditionalActuaryContact(): void
Expand Down
33 changes: 30 additions & 3 deletions services/cypress/support/stateSubmissionFormCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ Cypress.Commands.add('fillOutAmendmentToBaseContractDetails', () => {
cy.findByText('No, the contract does not fully comply with all applicable requirements').click()
cy.findByRole('textbox', {name: 'Provide a brief description of any contractual or operational non-compliance, including regulatory citations and expected timeframe for remediation'})
.type('Non compliance explanation')

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

cy.findAllByLabelText('Start date', {timeout: 2000})
.parents()
.findByTestId('date-picker-external-input')
Expand Down Expand Up @@ -323,7 +323,7 @@ Cypress.Commands.add('fillOutNewRateCertification', () => {
})
.should('exist')
.within(() => {
cy.findByText('No').click()
cy.findByText(/No/).click()
})

cy.findByText('New rate certification').click()
Expand Down Expand Up @@ -363,6 +363,33 @@ Cypress.Commands.add('fillOutNewRateCertification', () => {
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
if (store['link-rates']) {
cy.findByRole('combobox', { name: 'Which rate certification was it?' }).click({
force: true,
})
cy.findAllByRole('option').first().click()
cy.findByText(/`Rate ID:/).should('be.visible')
}

cy.verifyDocumentsHaveNoErrors()
cy.waitForDocumentsToLoad()
cy.findAllByTestId('errorMessage').should('have.length', 0)
})
cy.findAllByTestId('errorMessage').should('have.length', 0)
})

Cypress.Commands.add('fillOutAmendmentToPriorRateCertification', (id = 0) => {
// Must be on '/submissions/:id/edit/rate-details'
// Must be a contract and rates submission
Expand Down

0 comments on commit 854f452

Please sign in to comment.