-
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-7781): add effective from date e2e tests (#4189)
- Loading branch information
1 parent
c416b1b
commit 15c0470
Showing
20 changed files
with
382 additions
and
231 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
e2e-tests/gef/cypress/e2e/pages/amendments/effective-date.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,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; |
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
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
131 changes: 131 additions & 0 deletions
131
e2e-tests/ukef/cypress/e2e/journeys/portal/amendments/pages/effective-date.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,131 @@ | ||
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 effectiveDate from '../../../../../../../gef/cypress/e2e/pages/amendments/effective-date'; | ||
import { twoDaysAgo, twoMonths, today } from '../../../../../../../e2e-fixtures/dateConstants'; | ||
|
||
const { BANK1_MAKER1 } = MOCK_USERS; | ||
|
||
context('Amendments - Date amendment effective from - 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(); | ||
}); | ||
}); | ||
}); | ||
|
||
after(() => { | ||
cy.clearCookies(); | ||
cy.clearSessionCookies(); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.clearSessionCookies(); | ||
cy.login(BANK1_MAKER1); | ||
cy.visit(relative(`/gef/application-details/${dealId}/facilities/${facilityId}/amendments/${amendmentId}/effective-date`)); | ||
}); | ||
|
||
it('should render key features of the page', () => { | ||
effectiveDate.pageHeading().contains('Date amendment effective from'); | ||
effectiveDate.backLink(); | ||
effectiveDate.cancelLink(); | ||
}); | ||
|
||
it('should render an error if no date is provided', () => { | ||
cy.clickContinueButton(); | ||
|
||
effectiveDate.errorSummary().should('be.visible'); | ||
effectiveDate.errorSummary().contains('Enter the date amendment effective from'); | ||
|
||
effectiveDate.effectiveDateInlineError().should('be.visible'); | ||
effectiveDate.effectiveDateInlineError().contains('Enter the date amendment effective from'); | ||
}); | ||
|
||
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', | ||
}, | ||
{ | ||
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', | ||
}, | ||
{ | ||
description: 'the date amendment effective from is greater than 30 days in the future', | ||
dateFieldInput: twoMonths, | ||
expectedErrorMessage: `You entered an amendment date more than 30 days from now. Amendments must be effective within the next 30 days - come back later or use the Schedule 8 form`, | ||
}, | ||
{ | ||
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 ${today.d_MMMM_yyyy}`, | ||
}, | ||
]; | ||
|
||
effectiveDateErrorTestCases.forEach(({ description, dateFieldInput, expectedErrorMessage }) => { | ||
it(`should render an error on the bank review date page if ${description}`, () => { | ||
cy.completeDateFormFields({ idPrefix: 'effective-date', ...dateFieldInput }); | ||
cy.clickContinueButton(); | ||
|
||
effectiveDate.errorSummary().should('be.visible'); | ||
effectiveDate.errorSummary().contains(expectedErrorMessage); | ||
effectiveDate.effectiveDateInlineError().should('be.visible'); | ||
effectiveDate.effectiveDateInlineError().contains(expectedErrorMessage); | ||
}); | ||
}); | ||
|
||
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`)); | ||
}); | ||
}); |
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.