diff --git a/e2e-tests/gef/cypress/e2e/pages/amendments/check-your-answers.js b/e2e-tests/gef/cypress/e2e/pages/amendments/check-your-answers.js new file mode 100644 index 0000000000..0975b84075 --- /dev/null +++ b/e2e-tests/gef/cypress/e2e/pages/amendments/check-your-answers.js @@ -0,0 +1,43 @@ +const cyGetAmendmentsSummaryListChild = (selector) => cy.get('[data-cy="amendment-summary-list"]').find(selector); +const cyGetAmendmentsSummaryListValue = (actionSelector) => + cyGetAmendmentsSummaryListChild(actionSelector).parent().parent().find('.govuk-summary-list__value'); + +const cyGetEligibilitySummaryListChild = (selector) => cy.get('[data-cy="eligibility-summary-list"]').find(selector); +const cyGetEligibilitySummaryListValue = (actionSelector) => + cyGetEligibilitySummaryListChild(actionSelector).parent().parent().find('.govuk-summary-list__value'); + +const cyGetEffectiveDateSummaryListChild = (selector) => cy.get('[data-cy="effective-date-summary-list"]').find(selector); +const cyGetEffectiveDateSummaryListValue = (actionSelector) => + cyGetEffectiveDateSummaryListChild(actionSelector).parent().parent().find('.govuk-summary-list__value'); + +const checkYourAnswers = { + pageHeading: () => cy.get('[data-cy="page-heading"]'), + backLink: () => cy.get('[data-cy="back-link"]'), + cancelLink: () => cy.get('[data-cy="cancel-link"]'), + + amendmentSummaryListTable: () => ({ + amendmentOptionsChangeLink: () => cyGetAmendmentsSummaryListChild('[data-cy="change-amendment-options-link"]'), + amendmentOptionsValue: () => cyGetAmendmentsSummaryListValue('[data-cy="change-amendment-options-link"]'), + coverEndDateChangeLink: () => cyGetAmendmentsSummaryListChild('[data-cy="change-cover-end-date-link"]'), + coverEndDateValue: () => cyGetAmendmentsSummaryListValue('[data-cy="change-cover-end-date-link"]'), + facilityEndDateChangeLink: () => cyGetAmendmentsSummaryListChild('[data-cy="change-facility-end-date-link"]'), + facilityEndDateValue: () => cyGetAmendmentsSummaryListValue('[data-cy="change-facility-end-date-link"]'), + bankReviewDateChangeLink: () => cyGetAmendmentsSummaryListChild('[data-cy="change-bank-review-date-link"]'), + bankReviewDateValue: () => cyGetAmendmentsSummaryListValue('[data-cy="change-bank-review-date-link"]'), + facilityValueChangeLink: () => cyGetAmendmentsSummaryListChild('[data-cy="change-facility-value-link"]'), + facilityValueValue: () => cyGetAmendmentsSummaryListValue('[data-cy="change-facility-value-link"]'), + }), + + eligibilityCriteriaSummaryListTable: () => ({ + eligibilityCriterionChangeLink: (id) => cyGetEligibilitySummaryListChild(`[data-cy="change-eligibility-criterion-${id}-link"]`), + eligibilityCriterionValue: (id) => cyGetEligibilitySummaryListValue(`[data-cy="change-eligibility-criterion-${id}-link"]`), + allEligibilityCriterionChangeLinks: () => cyGetEligibilitySummaryListChild('[data-cy^="change-eligibility-criterion-"]'), + }), + + effectiveDateSummaryListTable: () => ({ + effectiveDateChangeLink: () => cyGetEffectiveDateSummaryListChild('[data-cy="change-effective-date-link"]'), + effectiveDateValue: () => cyGetEffectiveDateSummaryListValue('[data-cy="change-effective-date-link"]'), + }), +}; + +module.exports = checkYourAnswers; diff --git a/e2e-tests/gef/cypress/e2e/pages/amendments/submitted-for-checking.js b/e2e-tests/gef/cypress/e2e/pages/amendments/submitted-for-checking.js new file mode 100644 index 0000000000..e88d34d5cd --- /dev/null +++ b/e2e-tests/gef/cypress/e2e/pages/amendments/submitted-for-checking.js @@ -0,0 +1,6 @@ +const submittedForChecking = { + submittedForCheckingConfirmationPanel: () => cy.get('[data-cy="submitted-for-checking-confirmation-panel"'), + returnLink: () => cy.get('[data-cy="return-link"]'), +}; + +module.exports = submittedForChecking; diff --git a/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-both-cover-end-date-and-facility-value.spec.js b/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-both-cover-end-date-and-facility-value.spec.js index f36dbaf3a7..7e1bbdac60 100644 --- a/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-both-cover-end-date-and-facility-value.spec.js +++ b/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-both-cover-end-date-and-facility-value.spec.js @@ -6,7 +6,10 @@ 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 eligibility from '../../../../../../../gef/cypress/e2e/pages/amendments/eligibility'; +import checkYourAnswers from '../../../../../../../gef/cypress/e2e/pages/amendments/check-your-answers'; import facilityValue from '../../../../../../../gef/cypress/e2e/pages/amendments/facility-value'; +import submittedForChecking from '../../../../../../../gef/cypress/e2e/pages/amendments/submitted-for-checking'; +import { today } from '../../../../../../../e2e-fixtures/dateConstants'; const { BANK1_MAKER1 } = MOCK_USERS; @@ -97,7 +100,32 @@ context('Amendments - Change both cover end date and facility value - full journ cy.clickContinueButton(); cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/check-your-answers`)); + checkYourAnswers.amendmentSummaryListTable().amendmentOptionsValue().contains('Cover end date'); + checkYourAnswers.amendmentSummaryListTable().amendmentOptionsValue().contains('Facility end date'); + checkYourAnswers.amendmentSummaryListTable().amendmentOptionsValue().contains('Facility value'); + + checkYourAnswers.amendmentSummaryListTable().coverEndDateValue().contains(today.d_MMMM_yyyy); + checkYourAnswers.amendmentSummaryListTable().facilityEndDateValue().contains(today.d_MMMM_yyyy); + checkYourAnswers.amendmentSummaryListTable().bankReviewDateChangeLink().should('not.exist'); + checkYourAnswers.amendmentSummaryListTable().facilityValueValue().contains('10000'); + + checkYourAnswers + .eligibilityCriteriaSummaryListTable() + .allEligibilityCriterionChangeLinks() + .each(($ele, index) => { + checkYourAnswers + .eligibilityCriteriaSummaryListTable() + .eligibilityCriterionValue(index + 1) + .contains('True'); + }); + + checkYourAnswers.effectiveDateSummaryListTable().effectiveDateValue().contains(today.d_MMMM_yyyy); + cy.clickSubmitButton(); + + cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/submitted-for-checking`)); + submittedForChecking.submittedForCheckingConfirmationPanel().contains('Amendment submitted for checking at your bank'); + submittedForChecking.returnLink().click(); - // TODO DTFS2-7519: add steps for check your answer page + cy.url().should('eq', relative('/dashboard/deals/0')); }); }); diff --git a/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-cover-end-date-with-BRD-journey.spec.js b/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-cover-end-date-with-BRD-journey.spec.js index 972c9711ad..a403e6232a 100644 --- a/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-cover-end-date-with-BRD-journey.spec.js +++ b/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-cover-end-date-with-BRD-journey.spec.js @@ -6,6 +6,9 @@ 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 eligibility from '../../../../../../../gef/cypress/e2e/pages/amendments/eligibility'; +import checkYourAnswers from '../../../../../../../gef/cypress/e2e/pages/amendments/check-your-answers'; +import submittedForChecking from '../../../../../../../gef/cypress/e2e/pages/amendments/submitted-for-checking'; +import { today } from '../../../../../../../e2e-fixtures/dateConstants'; const { BANK1_MAKER1 } = MOCK_USERS; @@ -93,6 +96,31 @@ context('Amendments - Change cover end date with bank review date - full journey cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/check-your-answers`)); - // TODO DTFS2-7519: add steps for check your answer page + checkYourAnswers.amendmentSummaryListTable().amendmentOptionsValue().contains('Cover end date'); + checkYourAnswers.amendmentSummaryListTable().amendmentOptionsValue().contains('Bank review date'); + checkYourAnswers.amendmentSummaryListTable().amendmentOptionsValue().should('not.contain', 'Facility value'); + + checkYourAnswers.amendmentSummaryListTable().coverEndDateValue().contains(today.d_MMMM_yyyy); + checkYourAnswers.amendmentSummaryListTable().bankReviewDateValue().contains(today.d_MMMM_yyyy); + checkYourAnswers.amendmentSummaryListTable().facilityEndDateChangeLink().should('not.exist'); + + checkYourAnswers + .eligibilityCriteriaSummaryListTable() + .allEligibilityCriterionChangeLinks() + .each(($ele, index) => { + checkYourAnswers + .eligibilityCriteriaSummaryListTable() + .eligibilityCriterionValue(index + 1) + .contains('True'); + }); + + checkYourAnswers.effectiveDateSummaryListTable().effectiveDateValue().contains(today.d_MMMM_yyyy); + cy.clickSubmitButton(); + + cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/submitted-for-checking`)); + submittedForChecking.submittedForCheckingConfirmationPanel().contains('Amendment submitted for checking at your bank'); + submittedForChecking.returnLink().click(); + + cy.url().should('eq', relative('/dashboard/deals/0')); }); }); diff --git a/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-cover-end-date-with-FED-journey.spec.js b/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-cover-end-date-with-FED-journey.spec.js index 56fbd5e29d..bcd278e5ec 100644 --- a/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-cover-end-date-with-FED-journey.spec.js +++ b/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-cover-end-date-with-FED-journey.spec.js @@ -6,6 +6,9 @@ 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 eligibility from '../../../../../../../gef/cypress/e2e/pages/amendments/eligibility'; +import checkYourAnswers from '../../../../../../../gef/cypress/e2e/pages/amendments/check-your-answers'; +import submittedForChecking from '../../../../../../../gef/cypress/e2e/pages/amendments/submitted-for-checking'; +import { today } from '../../../../../../../e2e-fixtures/dateConstants'; const { BANK1_MAKER1 } = MOCK_USERS; @@ -92,6 +95,31 @@ context('Amendments - Change cover end date with facility end date - full journe cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/check-your-answers`)); - // TODO DTFS2-7519: add steps for check your answer page + checkYourAnswers.amendmentSummaryListTable().amendmentOptionsValue().contains('Cover end date'); + checkYourAnswers.amendmentSummaryListTable().amendmentOptionsValue().contains('Facility end date'); + checkYourAnswers.amendmentSummaryListTable().amendmentOptionsValue().should('not.contain', 'Facility value'); + + checkYourAnswers.amendmentSummaryListTable().coverEndDateValue().contains(today.d_MMMM_yyyy); + checkYourAnswers.amendmentSummaryListTable().facilityEndDateValue().contains(today.d_MMMM_yyyy); + checkYourAnswers.amendmentSummaryListTable().bankReviewDateChangeLink().should('not.exist'); + + checkYourAnswers + .eligibilityCriteriaSummaryListTable() + .allEligibilityCriterionChangeLinks() + .each(($ele, index) => { + checkYourAnswers + .eligibilityCriteriaSummaryListTable() + .eligibilityCriterionValue(index + 1) + .contains('True'); + }); + + checkYourAnswers.effectiveDateSummaryListTable().effectiveDateValue().contains(today.d_MMMM_yyyy); + cy.clickSubmitButton(); + + cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/submitted-for-checking`)); + submittedForChecking.submittedForCheckingConfirmationPanel().contains('Amendment submitted for checking at your bank'); + submittedForChecking.returnLink().click(); + + cy.url().should('eq', relative('/dashboard/deals/0')); }); }); diff --git a/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-facility-value-journey.spec.js b/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-facility-value-journey.spec.js index 6551a061a6..3c7e6dd59c 100644 --- a/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-facility-value-journey.spec.js +++ b/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/journeys/change-facility-value-journey.spec.js @@ -6,6 +6,9 @@ import { applicationPreview } from '../../../../../../../gef/cypress/e2e/pages'; import whatDoYouNeedToChange from '../../../../../../../gef/cypress/e2e/pages/amendments/what-do-you-need-to-change'; 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 submittedForChecking from '../../../../../../../gef/cypress/e2e/pages/amendments/submitted-for-checking'; +import { today } from '../../../../../../../e2e-fixtures/dateConstants'; const { BANK1_MAKER1 } = MOCK_USERS; @@ -77,6 +80,31 @@ context('Amendments - change facility value - full journey', () => { cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/check-your-answers`)); - // TODO DTFS2-7519: add steps for check your answer page + checkYourAnswers.amendmentSummaryListTable().amendmentOptionsValue().contains('Facility value'); + checkYourAnswers.amendmentSummaryListTable().amendmentOptionsValue().should('not.contain', 'Cover end date'); + + checkYourAnswers.amendmentSummaryListTable().coverEndDateChangeLink().should('not.exist'); + checkYourAnswers.amendmentSummaryListTable().bankReviewDateChangeLink().should('not.exist'); + checkYourAnswers.amendmentSummaryListTable().facilityEndDateChangeLink().should('not.exist'); + checkYourAnswers.amendmentSummaryListTable().facilityValueValue().contains('10000'); + + checkYourAnswers + .eligibilityCriteriaSummaryListTable() + .allEligibilityCriterionChangeLinks() + .each(($ele, index) => { + checkYourAnswers + .eligibilityCriteriaSummaryListTable() + .eligibilityCriterionValue(index + 1) + .contains('True'); + }); + + checkYourAnswers.effectiveDateSummaryListTable().effectiveDateValue().contains(today.d_MMMM_yyyy); + cy.clickSubmitButton(); + + cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/submitted-for-checking`)); + submittedForChecking.submittedForCheckingConfirmationPanel().contains('Amendment submitted for checking at your bank'); + submittedForChecking.returnLink().click(); + + cy.url().should('eq', relative('/dashboard/deals/0')); }); }); diff --git a/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/pages/check-your-answers.spec.js b/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/pages/check-your-answers.spec.js new file mode 100644 index 0000000000..0aae4b36df --- /dev/null +++ b/e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/pages/check-your-answers.spec.js @@ -0,0 +1,86 @@ +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 { applicationPreview } from '../../../../../../../gef/cypress/e2e/pages'; +import whatDoYouNeedToChange from '../../../../../../../gef/cypress/e2e/pages/amendments/what-do-you-need-to-change'; +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'; + +const { BANK1_MAKER1 } = MOCK_USERS; + +context('Amendments - Check your answers - page tests', () => { + /** + * @type {string} + */ + let dealId; + /** + * @type {string} + */ + let facilityId; + /** + * @type {string} + */ + let amendmentId; + + 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, [anIssuedCashFacility({ facilityEndDateEnabled: true })], 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.url().then((url) => { + const urlSplit = url.split('/'); + + amendmentId = urlSplit[9]; + }); + + whatDoYouNeedToChange.facilityValueCheckbox().click(); + cy.clickContinueButton(); + cy.keyboardInput(facilityValue.facilityValue(), '10000'); + cy.clickContinueButton(); + eligibility.allTrueRadioButtons().click({ multiple: true }); + cy.clickContinueButton(); + cy.completeDateFormFields({ idPrefix: 'effective-date' }); + cy.clickContinueButton(); + }); + }); + }); + + after(() => { + cy.clearCookies(); + cy.clearSessionCookies(); + }); + + beforeEach(() => { + cy.clearSessionCookies(); + cy.login(BANK1_MAKER1); + cy.visit(relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/check-your-answers`)); + }); + + it('should render key features of the page', () => { + checkYourAnswers.pageHeading().contains('Check your answers before submitting the amendment request'); + checkYourAnswers.backLink(); + checkYourAnswers.cancelLink(); + }); + + it('should navigate to cancel page when cancel is clicked', () => { + eligibility.cancelLink().click(); + + cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/cancel`)); + }); +}); diff --git a/gef-ui/component-tests/_macros/amendment-summary-list.component-test.ts b/gef-ui/component-tests/_macros/amendment-summary-list.component-test.ts index d207c9de63..dcaef5dc1b 100644 --- a/gef-ui/component-tests/_macros/amendment-summary-list.component-test.ts +++ b/gef-ui/component-tests/_macros/amendment-summary-list.component-test.ts @@ -16,7 +16,7 @@ describe(component, () => { it('should render amendment summary list', () => { const wrapper = render(params); - wrapper.expectElement('[data-cy="amendments-summary-list"]').toExist(); + wrapper.expectElement('[data-cy="amendment-summary-list"]').toExist(); }); it('should render eligibility summary list', () => { diff --git a/gef-ui/component-tests/partials/amendments/check-your-answers.component-test.ts b/gef-ui/component-tests/partials/amendments/check-your-answers.component-test.ts index 83c263eef3..0db516355b 100644 --- a/gef-ui/component-tests/partials/amendments/check-your-answers.component-test.ts +++ b/gef-ui/component-tests/partials/amendments/check-your-answers.component-test.ts @@ -56,7 +56,7 @@ describe(page, () => { it('should render amendment summary list', () => { const wrapper = render(params); - wrapper.expectElement('[data-cy="amendments-summary-list"]').toExist(); + wrapper.expectElement('[data-cy="amendment-summary-list"]').toExist(); }); it('should render eligibility summary list', () => { diff --git a/gef-ui/templates/_macros/amendments/amendment-summary-list.njk b/gef-ui/templates/_macros/amendments/amendment-summary-list.njk index 53e94f112a..a79512e9e1 100644 --- a/gef-ui/templates/_macros/amendments/amendment-summary-list.njk +++ b/gef-ui/templates/_macros/amendments/amendment-summary-list.njk @@ -6,7 +6,7 @@ {{ govukSummaryList({ rows: params.amendmentRows, attributes: { - 'data-cy': 'amendments-summary-list', + 'data-cy': 'amendment-summary-list', id: item.facilityId } }) }}