Skip to content

Commit

Permalink
feat(DTFS2-7781): update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Roberts committed Feb 3, 2025
1 parent 08b9366 commit a590b7d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
12 changes: 12 additions & 0 deletions e2e-tests/gef/cypress/e2e/pages/amendments/effective-date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const effectiveDate = {
effectiveDateDay: () => cy.get('[data-cy="effective-date-day"]'),
effectiveDateMonth: () => cy.get('[data-cy="effective-date-month"]'),
effectiveDateYear: () => cy.get('[data-cy="effective-date-year"]'),
errorSummary: () => cy.get('[data-cy="error-summary"]'),
effectiveDateInlineError: () => cy.get('[data-cy="effective-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 = effectiveDate;
12 changes: 0 additions & 12 deletions e2e-tests/gef/cypress/e2e/pages/amendments/effective-from.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ 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}/effective-date`));
cy.completeDateFormFields({ idPrefix: 'effective-from' });
cy.completeDateFormFields({ idPrefix: 'effective-date' });
cy.clickContinueButton();

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/check-your-answers`));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ context('Amendments - Change cover end date with bank review date - full journey
cy.clickContinueButton();

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

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/check-your-answers`));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ context('Amendments - Change cover end date with facility end date - full journe
cy.clickContinueButton();

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

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/check-your-answers`));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ context('Amendments - change facility value - full journey', () => {
cy.clickContinueButton();

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

cy.url().should('eq', relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/check-your-answers`));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ 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 effectiveFrom from '../../../../../../../gef/cypress/e2e/pages/amendments/effective-from';
import { twoDaysAgo, twoMonths, yesterday } from '../../../../../../../e2e-fixtures/dateConstants';
import effectiveDate from '../../../../../../../gef/cypress/e2e/pages/amendments/effective-date';
import { twoDaysAgo, twoMonths, today } from '../../../../../../../e2e-fixtures/dateConstants';

const { BANK1_MAKER1 } = MOCK_USERS;

Expand Down Expand Up @@ -73,31 +73,31 @@ context('Amendments - Date amendment effective from - page tests', () => {
});

it('should render key features of the page', () => {
effectiveFrom.pageHeading().contains('Date amendment effective from');
effectiveFrom.backLink();
effectiveFrom.cancelLink();
effectiveDate.pageHeading().contains('Date amendment effective from');
effectiveDate.backLink();
effectiveDate.cancelLink();
});

it('should render an error if no date is provided', () => {
cy.clickContinueButton();

effectiveFrom.errorSummary().should('be.visible');
effectiveFrom.errorSummary().contains('Enter the date amendment effective from');
effectiveDate.errorSummary().should('be.visible');
effectiveDate.errorSummary().contains('Enter the date amendment effective from');

effectiveFrom.effectiveFromInlineError().should('be.visible');
effectiveFrom.effectiveFromInlineError().contains('Enter the date amendment effective from');
effectiveDate.effectiveDateInlineError().should('be.visible');
effectiveDate.effectiveDateInlineError().contains('Enter the date amendment effective from');
});

const effectiveFromErrorTestCases = [
const effectiveDateErrorTestCases = [
{
description: 'the date amendment effective from consists of invalid characters',
dateFieldInput: { day: 'aa', month: '11', year: '2025' },
expectedErrorMessage: 'date amendment effective from must be a real date',
expectedErrorMessage: 'Date amendment effective from must be a real date',
},
{
description: 'the date amendment effective from is missing a field',
dateFieldInput: { day: '2', month: '', year: '2025' },
expectedErrorMessage: 'date amendment effective from must include a month',
dateFieldInput: { day: '2', month: ' ', year: '2025' },
expectedErrorMessage: 'Date amendment effective from must include a month',
},
{
description: 'the date amendment effective from is greater than 30 days in the future',
Expand All @@ -107,19 +107,19 @@ context('Amendments - Date amendment effective from - page tests', () => {
{
description: 'the date amendment effective from is before the cover start date',
dateFieldInput: twoDaysAgo,
expectedErrorMessage: `Date amendment effective from cannot be before the cover start date ${yesterday.d_MMMM_yyyy}`,
expectedErrorMessage: `Date amendment effective from cannot be before the cover start date ${today.d_MMMM_yyyy}`,
},
];

effectiveFromErrorTestCases.forEach(({ description, dateFieldInput, expectedErrorMessage }) => {
effectiveDateErrorTestCases.forEach(({ description, dateFieldInput, expectedErrorMessage }) => {
it(`should render an error on the bank review date page if ${description}`, () => {
cy.completeDateFormFields({ idPrefix: 'effective-from', ...dateFieldInput });
cy.completeDateFormFields({ idPrefix: 'effective-date', ...dateFieldInput });
cy.clickContinueButton();

effectiveFrom.errorSummary().should('be.visible');
effectiveFrom.errorSummary().contains(expectedErrorMessage);
effectiveFrom.effectiveFromInlineError().should('be.visible');
effectiveFrom.effectiveFromInlineError().contains(expectedErrorMessage);
effectiveDate.errorSummary().should('be.visible');
effectiveDate.errorSummary().contains(expectedErrorMessage);
effectiveDate.effectiveDateInlineError().should('be.visible');
effectiveDate.effectiveDateInlineError().contains(expectedErrorMessage);
});
});

Expand Down

0 comments on commit a590b7d

Please sign in to comment.