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-4024: Fix cypress tests for linked rates #2512

Merged
merged 14 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
88 changes: 46 additions & 42 deletions services/cypress/integration/cmsWorkflow/rateReview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,49 +29,54 @@ describe('CMS user can view rate reviews', () => {

// Create a new contract and rates submission with two attached rates
cy.apiCreateAndSubmitContractWithRates(stateUser()).then(
(pkg) => {
const submission = getFormData(pkg)
const submissionName = packageName(
pkg.stateCode,
submission.stateNumber,
submission.programIDs,
minnesotaStatePrograms
)
// Then check both rates in rate reviews table
cy.logInAsCMSUser({
initialURL: `/dashboard/rate-reviews`,
})
const rate1 = submission.rateInfos[0]
const rate2 = submission.rateInfos[1]
cy.get('table')
.findByRole('link', { name: rate1.rateCertificationName })
.should('exist')
cy.get('table')
.findByRole('link', { name: rate2.rateCertificationName })
.should('exist')
(contract) => {

const latestSubmission = contract.packageSubmissions[0]

const rate1 = latestSubmission.rateRevisions[0]
const rate2 = latestSubmission.rateRevisions[1]
let rate1Name = rate1.formData.rateCertificationName
let rate2Name = rate2.formData.rateCertificationName

if (!rate1Name || !rate2Name) {
throw new Error(`Unexpected error: Rate name(s) did not exist. Rate1Name: ${rate1Name}, Rate2Name: ${rate2Name}`)
}

// click the first rate to navigate to rate summary page
cy.get('table')
.findByRole('link', { name: rate1.rateCertificationName })
.should('exist').click()
cy.url({ timeout: 10_000 }).should('contain',rate1.id)
cy.findByRole('heading', {
name: `${rate1.rateCertificationName}`,
}).should('exist')
cy.findByText('Rate certification type').should('exist').siblings('dd').should('have.text', 'New rate certification')
cy.findByText('Rating period').should('exist').siblings('dd').should('have.text', '06/01/2025 to 05/30/2026')
cy.findByText('Date certified').should('exist').siblings('dd').should('have.text', '04/15/2025')
cy.findByText('Submission this rate was submitted with').should('exist').siblings('dd').should('have.text', submissionName)
cy.findByText('Certifying actuary').should('exist').siblings('dd').should('have.text', 'actuary1test titleemail@example.comMercer')
// cy.findByText('Download all rate documents').should('exist')
cy.findByRole('table', {
name: 'Rate certification',
}).should('exist')
cy.findByText('rate1Document1.pdf').should('exist')
cy.findByRole('table', {
name: 'Rate supporting documents',
}).should('exist')
// Then check both rates in rate reviews table
cy.logInAsCMSUser({
initialURL: `/dashboard/rate-reviews`,
})

// Rate names can be the same, rare in prod, but common in automated tests and manual tests.
// Here were just checking to make sure the first exists in findAll.
cy.get('table')
.findAllByRole('link', { name: rate1Name }).first()
JasonLin0991 marked this conversation as resolved.
Show resolved Hide resolved
.should('exist')
cy.get('table')
.findAllByRole('link', { name: rate2Name }).first()
.should('exist')

// click the first rate to navigate to rate summary page
cy.get('table')
.findAllByRole('link', { name: rate1Name }).first().click()
cy.url({ timeout: 10_000 }).should('contain',rate1.rateID)
cy.findByRole('heading', {
name: `${rate1.formData.rateCertificationName}`,
}).should('exist')
cy.findByText('Rate certification type').should('exist').siblings('dd').should('have.text', 'New rate certification')
cy.findByText('Rating period').should('exist').siblings('dd').should('have.text', '06/01/2025 to 05/30/2026')
cy.findByText('Date certified').should('exist').siblings('dd').should('have.text', '04/15/2025')
cy.findByText('Submission this rate was submitted with').should('exist').siblings('dd').should('have.text', latestSubmission.contractRevision.contractName)
cy.findByText('Certifying actuary').should('exist').siblings('dd').should('have.text', 'actuary1test titleemail@example.comMercer')
// cy.findByText('Download all rate documents').should('exist')
cy.findByRole('table', {
name: 'Rate certification',
}).should('exist')
cy.findByText('rate1Document1.pdf').should('exist')
cy.findByRole('table', {
name: 'Rate supporting documents',
}).should('exist')
})
cy.findByText('rate1SupportingDocument1.pdf').should('exist')

// No document dates or other fields are undefined
Expand All @@ -83,7 +88,6 @@ describe('CMS user can view rate reviews', () => {
cy.url({ timeout: 10_000 }).should('contain', 'rate-reviews')
cy.findByText('Rate reviews').should('exist')
cy.get('thead').should('have.attr', 'data-testid', 'rate-reviews-table').should('be.visible') // can't put id on table itself because data attributes not passing through in react-uswds component

})
})
})
214 changes: 213 additions & 1 deletion services/cypress/integration/cmsWorkflow/unlockResubmit.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {stateUser} from '../../utils/apollo-test-utils';

describe('CMS user', () => {
beforeEach(() => {
cy.stubFeatureFlags()
Expand Down Expand Up @@ -454,6 +456,216 @@ describe('CMS user', () => {
})

// TODO AFTER LINKED RATES AND LINKED RATES CHANGE HISTORY SHIPS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can clear out this comment^

// it('can unlock and resubmit a linked rate and change history updates')
it.only('can unlock and resubmit a linked rate and change history updates', () => {
// turn on feature flag
cy.interceptFeatureFlags({'link-rates': true, '438-attestation': true})

// Set up a submission with linked rates
cy.apiCreateAndSubmitContractWithRates(stateUser()).then(() => {
cy.logInAsStateUser()

cy.startNewContractAndRatesSubmission()
cy.fillOutBaseContractDetails()

cy.navigateFormByButtonClick('CONTINUE')

cy.findByRole('heading', { level: 2, name: /Rate details/ })
cy.fillOutLinkedRate()
cy.navigateContractRatesFormByButtonClick('CONTINUE')

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

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

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

// Test unlock and resubmit with a linked rate submission
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 })
cy.wait('@fetchContractQuery', { timeout: 20_000 })
// 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)
cy.wait('@fetchContractQuery', { timeout: 20_000 })

//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 })
cy.wait('@fetchContractQuery', { timeout: 20_000 })

// 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.wait('@fetchContractQuery', { timeout: 20_000 })
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('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:')

})
})
})
})
})
// it('can unlock and resubmit combination of linked and child rates as expected' )
})
Loading
Loading