-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DTFS2-7720): redirect to check answers page if change query is t…
…rue (#4235)
- Loading branch information
1 parent
e8f23c3
commit bdc810b
Showing
63 changed files
with
1,232 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 152 additions & 0 deletions
152
...cypress/e2e/journeys/portal/amendments/journeys/check-your-answers-change-journey.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import relative from '../../../../relativeURL'; | ||
import MOCK_USERS from '../../../../../../../e2e-fixtures/portal-users.fixture'; | ||
import { MOCK_APPLICATION_AIN_DRAFT } from '../../../../../../../e2e-fixtures/gef/mocks/mock-deals'; | ||
import { anIssuedCashFacility } from '../../../../../../../e2e-fixtures/mock-gef-facilities'; | ||
import { MOCK_JOURNEYS_WITH_BRD, MOCK_JOURNEYS_WITH_FED } from '../../../../../fixtures/check-your-answers-change-journey'; | ||
import { applicationPreview } from '../../../../../../../gef/cypress/e2e/pages'; | ||
|
||
import whatDoYouNeedToChange from '../../../../../../../gef/cypress/e2e/pages/amendments/what-do-you-need-to-change'; | ||
import doYouHaveAFacilityEndDate from '../../../../../../../gef/cypress/e2e/pages/amendments/do-you-have-a-facility-end-date'; | ||
import facilityValue from '../../../../../../../gef/cypress/e2e/pages/amendments/facility-value'; | ||
import eligibility from '../../../../../../../gef/cypress/e2e/pages/amendments/eligibility'; | ||
import checkYourAnswers from '../../../../../../../gef/cypress/e2e/pages/amendments/check-your-answers'; | ||
import manualApprovalNeeded from '../../../../../../../gef/cypress/e2e/pages/amendments/manual-approval-needed'; | ||
|
||
const { BANK1_MAKER1 } = MOCK_USERS; | ||
|
||
context('Amendments - Check your answers change journey', () => { | ||
/** | ||
* @type {string} | ||
*/ | ||
let dealId; | ||
/** | ||
* @type {string} | ||
*/ | ||
let facilityId; | ||
/** | ||
* @type {string} | ||
*/ | ||
let amendmentUrl; | ||
/** | ||
* @type {Date} | ||
*/ | ||
const mockFacility = anIssuedCashFacility({ facilityEndDateEnabled: true }); | ||
const CHANGED_FACILITY_VALUE = '10000'; | ||
|
||
/** | ||
* This test suite covers the "Check your answers" change journey for amendments. | ||
*/ | ||
const setupTest = (testCases, amendmentPageActions, hasFacilityEndDate) => { | ||
before(() => { | ||
cy.insertOneGefDeal(MOCK_APPLICATION_AIN_DRAFT, BANK1_MAKER1).then((insertedDeal) => { | ||
dealId = insertedDeal._id; | ||
|
||
cy.updateGefDeal(dealId, MOCK_APPLICATION_AIN_DRAFT, BANK1_MAKER1); | ||
|
||
cy.createGefFacilities(dealId, [mockFacility], BANK1_MAKER1).then((createdFacility) => { | ||
facilityId = createdFacility.details._id; | ||
cy.makerLoginSubmitGefDealForReview(insertedDeal); | ||
cy.checkerLoginSubmitGefDealToUkef(insertedDeal); | ||
|
||
cy.clearSessionCookies(); | ||
cy.login(BANK1_MAKER1); | ||
cy.saveSession(); | ||
cy.visit(relative(`/gef/application-details/${dealId}`)); | ||
|
||
applicationPreview.makeAChangeButton(facilityId).click(); | ||
|
||
cy.getAmendmentIdFromUrl().then((amendmentId) => { | ||
amendmentUrl = `/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}`; | ||
amendmentPageActions(hasFacilityEndDate); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
after(() => { | ||
cy.clearCookies(); | ||
cy.clearSessionCookies(); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.clearSessionCookies(); | ||
cy.login(BANK1_MAKER1); | ||
}); | ||
|
||
testCases.forEach(({ description, page, nextPage, element, nextElement, checkYourAnswersChangeElement, fragment, nextPageHeading, change }) => { | ||
it(`should navigate back to "Check your answers" page when no changes are made on the ${description} page`, () => { | ||
cy.visit(relative(`${amendmentUrl}/check-your-answers`)); | ||
checkYourAnswersChangeElement().click(); | ||
cy.url().should('eq', relative(`${amendmentUrl}/${page}/?change=true#${fragment}`)); | ||
cy.clickContinueButton(); | ||
cy.url().should('eq', relative(`${amendmentUrl}/check-your-answers#${fragment}`)); | ||
checkYourAnswers.pageHeading().contains('Check your answers before submitting the amendment request'); | ||
}); | ||
|
||
it(`should navigate back to "Check your answers" page when the Back link is clicked on the ${description} page`, () => { | ||
cy.visit(relative(`${amendmentUrl}/check-your-answers`)); | ||
checkYourAnswersChangeElement().click(); | ||
cy.url().should('eq', relative(`${amendmentUrl}/${page}/?change=true#${fragment}`)); | ||
element.backLink().click(); | ||
cy.url().should('eq', relative(`${amendmentUrl}/check-your-answers`)); | ||
checkYourAnswers.pageHeading().contains('Check your answers before submitting the amendment request'); | ||
}); | ||
|
||
it(`should navigate through the amendment journey when changes are made on the ${description} page`, () => { | ||
cy.visit(relative(`${amendmentUrl}/check-your-answers`)); | ||
checkYourAnswersChangeElement().click(); | ||
cy.url().should('eq', relative(`${amendmentUrl}/${page}/?change=true#${fragment}`)); | ||
change(); | ||
if (nextPage !== 'manual-approval-needed') { | ||
cy.url().should('eq', relative(`${amendmentUrl}/${nextPage}#${fragment}`)); | ||
nextElement.pageHeading().contains(nextPageHeading); | ||
} else { | ||
cy.url().should('eq', relative(`${amendmentUrl}/${nextPage}#${fragment}`)); | ||
nextElement.pageHeading().contains(nextPageHeading); | ||
manualApprovalNeeded.backLink().click(); | ||
eligibility.allTrueRadioButtons().click({ multiple: true }); | ||
cy.clickContinueButton(); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
// These are the steps the user follows to amend the facility until they reach the "Check your answers" page. | ||
const amendmentPageActions = (hasFacilityEndDate) => { | ||
whatDoYouNeedToChange.coverEndDateCheckbox().click(); | ||
whatDoYouNeedToChange.facilityValueCheckbox().click(); | ||
cy.clickContinueButton(); | ||
|
||
cy.completeDateFormFields({ idPrefix: 'cover-end-date' }); | ||
cy.clickContinueButton(); | ||
|
||
if (hasFacilityEndDate) { | ||
doYouHaveAFacilityEndDate.yesRadioButton().click(); | ||
cy.clickContinueButton(); | ||
cy.completeDateFormFields({ idPrefix: 'facility-end-date' }); | ||
} else { | ||
doYouHaveAFacilityEndDate.noRadioButton().click(); | ||
cy.clickContinueButton(); | ||
cy.completeDateFormFields({ idPrefix: 'bank-review-date' }); | ||
} | ||
cy.clickContinueButton(); | ||
|
||
cy.keyboardInput(facilityValue.facilityValue(), CHANGED_FACILITY_VALUE); | ||
cy.clickContinueButton(); | ||
|
||
eligibility.allTrueRadioButtons().click({ multiple: true }); | ||
cy.clickContinueButton(); | ||
|
||
cy.completeDateFormFields({ idPrefix: 'effective-date' }); | ||
cy.clickContinueButton(); | ||
}; | ||
|
||
// If the amendmentPageActions function is called with false, the bankReviewDate is enabled in the journey | ||
describe('Bank Review Date Enabled', () => { | ||
setupTest(MOCK_JOURNEYS_WITH_BRD, amendmentPageActions, false); | ||
}); | ||
// If the amendmentPageActions function is called with true, the facilityEndDate is enabled in the journey | ||
describe('Facility End Date Endabled', () => { | ||
setupTest(MOCK_JOURNEYS_WITH_FED, amendmentPageActions, true); | ||
}); | ||
}); |
120 changes: 120 additions & 0 deletions
120
e2e-tests/ukef/cypress/fixtures/check-your-answers-change-journey.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import coverEndDate from '../../../gef/cypress/e2e/pages/amendments/cover-end-date'; | ||
import facilityEndDate from '../../../gef/cypress/e2e/pages/amendments/facility-end-date'; | ||
import bankReviewDate from '../../../gef/cypress/e2e/pages/amendments/bank-review-date'; | ||
import effectiveDate from '../../../gef/cypress/e2e/pages/amendments/effective-date'; | ||
import whatDoYouNeedToChange from '../../../gef/cypress/e2e/pages/amendments/what-do-you-need-to-change'; | ||
import doYouHaveAFacilityEndDate from '../../../gef/cypress/e2e/pages/amendments/do-you-have-a-facility-end-date'; | ||
import facilityValue from '../../../gef/cypress/e2e/pages/amendments/facility-value'; | ||
import eligibility from '../../../gef/cypress/e2e/pages/amendments/eligibility'; | ||
import checkYourAnswers from '../../../gef/cypress/e2e/pages/amendments/check-your-answers'; | ||
import manualApprovalNeeded from '../../../gef/cypress/e2e/pages/amendments/manual-approval-needed'; | ||
import { tomorrow } from '../../../e2e-fixtures/dateConstants'; | ||
|
||
const ELIGIBILITY_CRITERIA_COUNT = 7; | ||
const NEW_FACILITY_VALUE = '20000'; | ||
|
||
const MOCK_ELIGIBILITY_TEST_CASES = Array.from({ length: ELIGIBILITY_CRITERIA_COUNT }, (_, index) => ({ | ||
description: 'eligibility', | ||
page: 'eligibility', | ||
nextPage: 'manual-approval-needed', | ||
element: eligibility, | ||
nextElement: manualApprovalNeeded, | ||
checkYourAnswersChangeElement: () => checkYourAnswers.eligibilityCriteriaSummaryListTable().eligibilityCriterionChangeLink(index + 1), | ||
fragment: `${index + 1}`, | ||
nextPageHeading: 'This amendment cannot be automatically approved', | ||
change: () => { | ||
eligibility.allFalseRadioButtons().click({ multiple: true }); | ||
cy.clickContinueButton(); | ||
}, | ||
})); | ||
|
||
export const MOCK_JOURNEYS_WITH_FED = [ | ||
{ | ||
description: 'cover end date', | ||
page: 'cover-end-date', | ||
nextPage: 'do-you-have-a-facility-end-date', | ||
element: coverEndDate, | ||
nextElement: doYouHaveAFacilityEndDate, | ||
checkYourAnswersChangeElement: () => checkYourAnswers.amendmentSummaryListTable().coverEndDateChangeLink(), | ||
fragment: 'coverEndDate-day', | ||
nextPageHeading: 'Do you have a facility end date?', | ||
change: () => { | ||
cy.completeDateFormFields({ idPrefix: 'cover-end-date', date: tomorrow.date }); | ||
cy.clickContinueButton(); | ||
}, | ||
}, | ||
{ | ||
description: 'facility end date', | ||
page: 'facility-end-date', | ||
nextPage: 'facility-value', | ||
element: facilityEndDate, | ||
nextElement: facilityValue, | ||
checkYourAnswersChangeElement: () => checkYourAnswers.amendmentSummaryListTable().facilityEndDateChangeLink(), | ||
fragment: 'facilityEndDate-day', | ||
nextPageHeading: 'New facility value', | ||
change: () => { | ||
cy.completeDateFormFields({ idPrefix: 'facility-end-date', date: tomorrow.date }); | ||
cy.clickContinueButton(); | ||
}, | ||
}, | ||
{ | ||
description: 'facility value', | ||
page: 'facility-value', | ||
nextPage: 'eligibility', | ||
element: facilityValue, | ||
nextElement: eligibility, | ||
checkYourAnswersChangeElement: () => checkYourAnswers.amendmentSummaryListTable().facilityValueChangeLink(), | ||
fragment: 'facilityValue', | ||
nextPageHeading: 'Eligibility', | ||
change: () => { | ||
cy.keyboardInput(facilityValue.facilityValue(), NEW_FACILITY_VALUE); | ||
cy.clickContinueButton(); | ||
}, | ||
}, | ||
{ | ||
description: 'effective date', | ||
page: 'effective-date', | ||
nextPage: 'check-your-answers', | ||
element: effectiveDate, | ||
nextElement: checkYourAnswers, | ||
checkYourAnswersChangeElement: () => checkYourAnswers.effectiveDateSummaryListTable().effectiveDateChangeLink(), | ||
fragment: 'effectiveDate-day', | ||
nextPageHeading: 'Check your answers before submitting the amendment request', | ||
change: () => { | ||
cy.completeDateFormFields({ idPrefix: 'effective-date', date: tomorrow.date }); | ||
cy.clickContinueButton(); | ||
}, | ||
}, | ||
...MOCK_ELIGIBILITY_TEST_CASES, | ||
]; | ||
|
||
export const MOCK_JOURNEYS_WITH_BRD = [ | ||
{ | ||
description: 'what do you need to change', | ||
page: 'what-do-you-need-to-change', | ||
nextPage: 'cover-end-date', | ||
element: whatDoYouNeedToChange, | ||
nextElement: coverEndDate, | ||
checkYourAnswersChangeElement: () => checkYourAnswers.amendmentSummaryListTable().amendmentOptionsChangeLink(), | ||
fragment: 'amendmentOptions', | ||
nextPageHeading: 'New cover end date', | ||
change: () => { | ||
whatDoYouNeedToChange.facilityValueCheckbox().click(); | ||
cy.clickContinueButton(); | ||
}, | ||
}, | ||
{ | ||
description: 'bank review date', | ||
page: 'bank-review-date', | ||
nextPage: 'eligibility', | ||
element: bankReviewDate, | ||
nextElement: eligibility, | ||
checkYourAnswersChangeElement: () => checkYourAnswers.amendmentSummaryListTable().bankReviewDateChangeLink(), | ||
fragment: 'bankReviewDate-day', | ||
nextPageHeading: 'Eligibility', | ||
change: () => { | ||
cy.completeDateFormFields({ idPrefix: 'bank-review-date', date: tomorrow.date }); | ||
cy.clickContinueButton(); | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.