Skip to content

Commit

Permalink
feat(DTFS2-7498): refactor amendments E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BethThomas141 committed Jan 24, 2025
1 parent 515a1b2 commit ddb0bf7
Show file tree
Hide file tree
Showing 16 changed files with 598 additions and 190 deletions.
12 changes: 12 additions & 0 deletions e2e-tests/gef/cypress/e2e/pages/amendments/bank-review-date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const bankReviewDate = {
bankReviewDateDay: () => cy.get('[data-cy="bank-review-date-day"]'),
bankReviewDateMonth: () => cy.get('[data-cy="bank-review-date-month"]'),
bankReviewDateYear: () => cy.get('[data-cy="bank-review-date-year"]'),
errorSummary: () => cy.get('[data-cy="error-summary"]'),
bankReviewDateInlineError: () => cy.get('[data-cy="bank-review-date-inline-error"]'),
pageHeading: () => cy.get('[data-cy="page-heading"]'),
backLink: () => cy.get('[data-cy="back-link"]'),
cancelLink: () => cy.get('[data-cy="cancel-link"]'),
};

module.exports = bankReviewDate;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const doYouHaveAFacilityEndDate = {
inlineError: () => cy.get('[data-cy="is-using-facility-end-date-error"]'),
pageHeading: () => cy.get('[data-cy="page-heading"]'),
backLink: () => cy.get('[data-cy="back-link"]'),
cancelLink: () => cy.get('[data-cy="cancel-link"]'),
};

module.exports = doYouHaveAFacilityEndDate;
1 change: 1 addition & 0 deletions e2e-tests/gef/cypress/e2e/pages/amendments/eligibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const eligibility = {
criterionRadiosText: (id) => cy.get(`[data-cy="radio-wrapper-${id}"]`),
pageHeading: () => cy.get('[data-cy="page-heading"]'),
backLink: () => cy.get('[data-cy="back-link"]'),
cancelLink: () => cy.get('[data-cy="cancel-link"]'),
};

module.exports = eligibility;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const facilityValue = {
pageHeading: () => cy.get('[data-cy="page-heading"]'),
backLink: () => cy.get('[data-cy="back-link"]'),
facilityValuePrefix: () => cy.get('[data-cy="facility-value-prefix"]'),
cancelLink: () => cy.get('[data-cy="cancel-link"]'),
};

module.exports = facilityValue;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const whatDoYouNeedToChange = {
pageHeading: () => cy.get('[data-cy="page-heading"]'),
backLink: () => cy.get('[data-cy="back-link"]'),
warning: () => cy.get('[data-cy="warning"]'),
cancelLink: () => cy.get('[data-cy="cancel-link"]'),
};

module.exports = whatDoYouNeedToChange;
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
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 coverEndDate from '../../../../../../../gef/cypress/e2e/pages/amendments/cover-end-date';
import doYouHaveAFacilityEndDate from '../../../../../../../gef/cypress/e2e/pages/amendments/do-you-have-a-facility-end-date';
import facilityEndDate from '../../../../../../../gef/cypress/e2e/pages/amendments/facility-end-date';
import eligibility from '../../../../../../../gef/cypress/e2e/pages/amendments/eligibility';
import facilityValue from '../../../../../../../gef/cypress/e2e/pages/amendments/facility-value';

const { BANK1_MAKER1 } = MOCK_USERS;

context('Amendments - Change both cover end date and facility value - full journey', () => {
/**
* @type {string}
*/
let dealId;

/**
* @type {string}
*/
let facilityId;
/**
* @type {string}
*/
let amendmentId;
/**
* @type {Date}
*/
const mockFacility = anIssuedCashFacility({ facilityEndDateEnabled: true });

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.url().then((url) => {
const urlSplit = url.split('/');

amendmentId = urlSplit[9];
});
});
});
});

after(() => {
cy.clearCookies();
cy.clearSessionCookies();
});

beforeEach(() => {
cy.clearSessionCookies();
cy.login(BANK1_MAKER1);
});

it('should navigate through the journey correctly', () => {
cy.visit(relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/what-do-you-need-to-change`));

whatDoYouNeedToChange.coverEndDateCheckbox().should('not.be.checked');
whatDoYouNeedToChange.facilityValueCheckbox().should('not.be.checked');
whatDoYouNeedToChange.pageHeading().contains('What do you need to change?');
whatDoYouNeedToChange.backLink();
whatDoYouNeedToChange.warning().contains('Check your records for the most up-to-date values');

whatDoYouNeedToChange.coverEndDateCheckbox().click();
whatDoYouNeedToChange.facilityValueCheckbox().click();
cy.clickContinueButton();

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/cover-end-date`));

coverEndDate.pageHeading().contains('New cover end date');
coverEndDate.backLink();

cy.completeDateFormFields({ idPrefix: 'cover-end-date' });
cy.clickContinueButton();

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/do-you-have-a-facility-end-date`));

doYouHaveAFacilityEndDate.noRadioButton().should('not.be.checked');
doYouHaveAFacilityEndDate.yesRadioButton().should('not.be.checked');
doYouHaveAFacilityEndDate.pageHeading().contains('Do you have a facility end date?');
doYouHaveAFacilityEndDate.backLink();

doYouHaveAFacilityEndDate.yesRadioButton().click();
cy.clickContinueButton();

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/facility-end-date`));

facilityEndDate.pageHeading().contains('Facility end date');
facilityEndDate.backLink();

cy.completeDateFormFields({ idPrefix: 'facility-end-date' });
cy.clickContinueButton();

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/facility-value`));

facilityValue.pageHeading().contains('New facility value');
facilityValue.backLink();
facilityValue.facilityValuePrefix().contains('£');

cy.keyboardInput(facilityValue.facilityValue(), '10000');
cy.clickContinueButton();

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/eligibility`));

eligibility.pageHeading().contains('Eligibility');
eligibility.backLink();

eligibility.allTrueRadioButtons().should('not.be.checked');
eligibility.allFalseRadioButtons().should('not.be.checked');

eligibility.criterionRadiosText(1).contains('The Facility is not an Affected Facility');
eligibility.criterionRadiosText(2).contains('Neither the Exporter, nor its UK Parent Obligor is an Affected Person');

eligibility.allTrueRadioButtons().click({ multiple: true });
cy.clickContinueButton();

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/effective-date`));

// TODO DTFS2-7524: add steps for effective from date

// TODO DTFS2-7519: add steps for check your answer page
});
});
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { now } from '@ukef/dtfs2-common';
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 coverEndDate from '../../../../../../gef/cypress/e2e/pages/amendments/cover-end-date';
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 coverEndDate from '../../../../../../../gef/cypress/e2e/pages/amendments/cover-end-date';
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 bankReviewDate from '../../../../../../../gef/cypress/e2e/pages/amendments/bank-review-date';

const { BANK1_MAKER1 } = MOCK_USERS;

context('Change cover end date journey - happy path', () => {
context('Amendments - Change cover end date with bank review date - full journey', () => {
/**
* @type {string}
*/
Expand All @@ -26,8 +28,6 @@ context('Change cover end date journey - happy path', () => {
/**
* @type {Date}
*/
let coverStartDate;

const mockFacility = anIssuedCashFacility({ facilityEndDateEnabled: true });

before(() => {
Expand All @@ -38,7 +38,6 @@ context('Change cover end date journey - happy path', () => {

cy.createGefFacilities(dealId, [mockFacility], BANK1_MAKER1).then((createdFacility) => {
facilityId = createdFacility.details._id;
coverStartDate = createdFacility.details.coverStartDate ? new Date(createdFacility.details.coverStartDate) : now();
cy.makerLoginSubmitGefDealForReview(insertedDeal);
cy.checkerLoginSubmitGefDealToUkef(insertedDeal);

Expand Down Expand Up @@ -89,23 +88,41 @@ context('Change cover end date journey - happy path', () => {
cy.clickContinueButton();

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/do-you-have-a-facility-end-date`));
});

it('should navigate to cancel page when cancel is clicked', () => {
cy.visit(relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/cover-end-date`));
doYouHaveAFacilityEndDate.noRadioButton().should('not.be.checked');
doYouHaveAFacilityEndDate.yesRadioButton().should('not.be.checked');
doYouHaveAFacilityEndDate.pageHeading().contains('Do you have a facility end date?');
doYouHaveAFacilityEndDate.backLink();

coverEndDate.pageHeading().contains('New cover end date');
coverEndDate.cancelLink().click();
doYouHaveAFacilityEndDate.noRadioButton().click();
cy.clickContinueButton();

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/cancel`));
});
cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/bank-review-date`));

it('should navigate through the journey correctly if cover end date is the same with cover start date', () => {
cy.visit(relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/cover-end-date`));
bankReviewDate.pageHeading().contains('Bank review date');
bankReviewDate.backLink();

cy.completeDateFormFields({ idPrefix: 'cover-end-date', date: coverStartDate });
cy.completeDateFormFields({ idPrefix: 'bank-review-date' });
cy.clickContinueButton();

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/do-you-have-a-facility-end-date`));
cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/eligibility`));

eligibility.pageHeading().contains('Eligibility');
eligibility.backLink();

eligibility.allTrueRadioButtons().should('not.be.checked');
eligibility.allFalseRadioButtons().should('not.be.checked');

eligibility.criterionRadiosText(1).contains('The Facility is not an Affected Facility');
eligibility.criterionRadiosText(2).contains('Neither the Exporter, nor its UK Parent Obligor is an Affected Person');

eligibility.allTrueRadioButtons().click({ multiple: true });
cy.clickContinueButton();

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/effective-date`));

// TODO DTFS2-7524: add steps for effective from date

// TODO DTFS2-7519: add steps for check your answer page
});
});
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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 coverEndDate from '../../../../../../gef/cypress/e2e/pages/amendments/cover-end-date';
import doYouHaveAFacilityEndDate from '../../../../../../gef/cypress/e2e/pages/amendments/do-you-have-a-facility-end-date';
import facilityEndDate from '../../../../../../gef/cypress/e2e/pages/amendments/facility-end-date';
import eligibility from '../../../../../../gef/cypress/e2e/pages/amendments/eligibility';
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 coverEndDate from '../../../../../../../gef/cypress/e2e/pages/amendments/cover-end-date';
import doYouHaveAFacilityEndDate from '../../../../../../../gef/cypress/e2e/pages/amendments/do-you-have-a-facility-end-date';
import facilityEndDate from '../../../../../../../gef/cypress/e2e/pages/amendments/facility-end-date';
import eligibility from '../../../../../../../gef/cypress/e2e/pages/amendments/eligibility';

const { BANK1_MAKER1 } = MOCK_USERS;

context('Amendments - Change facility end date journey - happy path', () => {
context('Amendments - Change cover end date with facility end date - full journey', () => {
/**
* @type {string}
*/
Expand Down Expand Up @@ -120,14 +120,9 @@ context('Amendments - Change facility end date journey - happy path', () => {
cy.clickContinueButton();

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/effective-date`));
});

it('should navigate to cancel page when cancel is clicked', () => {
cy.visit(relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/facility-end-date`));

facilityEndDate.pageHeading().contains('Facility end date');
facilityEndDate.cancelLink().click();
// TODO DTFS2-7524: add steps for effective from date

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/cancel`));
// TODO DTFS2-7519: add steps for check your answer page
});
});
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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 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';

const { BANK1_MAKER1 } = MOCK_USERS;

context('Amendments - change facility value journey - happy path', () => {
context('Amendments - change facility value - full journey', () => {
/**
* @type {string}
*/
Expand Down Expand Up @@ -94,5 +94,9 @@ context('Amendments - change facility value journey - happy path', () => {
cy.clickContinueButton();

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/effective-date`));

// TODO DTFS2-7524: add steps for effective from date

// TODO DTFS2-7519: add steps for check your answer page
});
});
Loading

0 comments on commit ddb0bf7

Please sign in to comment.