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

feat(DTFS2-7797): add check your answers e2e tests #4222

Merged
merged 6 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
43 changes: 43 additions & 0 deletions e2e-tests/gef/cypress/e2e/pages/amendments/check-your-answers.js
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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'));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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'));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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'));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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'));
});
});
Original file line number Diff line number Diff line change
@@ -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`));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ govukSummaryList({
rows: params.amendmentRows,
attributes: {
'data-cy': 'amendments-summary-list',
'data-cy': 'amendment-summary-list',
id: item.facilityId
}
}) }}
Expand Down
Loading