-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(EMS-3829): export contract - how much is agent charging - e2e tests
- Loading branch information
Showing
4 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
e2e-tests/commands/insurance/complete-and-submit-how-much-is-the-agent-charging-form.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,20 @@ | ||
import { field } from '../../pages/shared'; | ||
import FIELD_IDS from '../../constants/field-ids/insurance/export-contract'; | ||
import application from '../../fixtures/application'; | ||
|
||
const { | ||
AGENT_CHARGES: { FIXED_SUM_AMOUNT }, | ||
} = FIELD_IDS; | ||
|
||
/** | ||
* completeAndSubmitHowMuchIsTheAgentChargingForm | ||
* Complete and submit the "How much is the agent charging" form | ||
* @param {String} fixedSumAmount: Fixed sum amount | ||
*/ | ||
const completeAndSubmitHowMuchIsTheAgentChargingForm = ({ fixedSumAmount = application.EXPORT_CONTRACT.AGENT_CHARGES[FIXED_SUM_AMOUNT] }) => { | ||
cy.keyboardInput(field(FIXED_SUM_AMOUNT).input(), fixedSumAmount); | ||
|
||
cy.clickSubmitButton(); | ||
}; | ||
|
||
export default completeAndSubmitHowMuchIsTheAgentChargingForm; |
86 changes: 86 additions & 0 deletions
86
...eys/export-contract/how-much-is-the-agent-charging/how-much-is-the-agent-charging.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,86 @@ | ||
import { field as fieldSelector, headingCaption } from '../../../../../../pages/shared'; | ||
import { PAGES } from '../../../../../../content-strings'; | ||
import { EXPORT_CONTRACT_FIELDS as FIELD_STRINGS } from '../../../../../../content-strings/fields/insurance/export-contract'; | ||
import FIELD_IDS from '../../../../../../constants/field-ids/insurance/export-contract'; | ||
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; | ||
|
||
const CONTENT_STRINGS = PAGES.INSURANCE.EXPORT_CONTRACT.HOW_MUCH_IS_THE_AGENT_CHARGING; | ||
|
||
const { | ||
ROOT, | ||
EXPORT_CONTRACT: { HOW_MUCH_IS_THE_AGENT_CHARGING, CHECK_YOUR_ANSWERS }, | ||
} = INSURANCE_ROUTES; | ||
|
||
const { | ||
AGENT_CHARGES: { FIXED_SUM_AMOUNT: FIELD_ID }, | ||
} = FIELD_IDS; | ||
|
||
const baseUrl = Cypress.config('baseUrl'); | ||
|
||
context( | ||
"Insurance - Export contract - How much is the agent charging page - As an exporter, I want to state what my agent's charges are, So that UKEF, the legal team and the British Embassy are aware of expenses incurred in my export contract bid", | ||
() => { | ||
let referenceNumber; | ||
let url; | ||
let checkYourAnswersUrl; | ||
|
||
before(() => { | ||
cy.completeSignInAndGoToApplication({ totalContractValueOverThreshold: true }).then(({ referenceNumber: refNumber }) => { | ||
referenceNumber = refNumber; | ||
|
||
url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_IS_THE_AGENT_CHARGING}`; | ||
checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; | ||
|
||
cy.navigateToUrl(); | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.saveSession(); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteApplication(referenceNumber); | ||
}); | ||
|
||
it('renders core page elements', () => { | ||
cy.corePageChecks({ | ||
pageTitle: CONTENT_STRINGS.PAGE_TITLE, | ||
currentHref: `${ROOT}/${referenceNumber}${HOW_MUCH_IS_THE_AGENT_CHARGING}`, | ||
backLink: '#', | ||
}); | ||
}); | ||
|
||
describe('page tests', () => { | ||
beforeEach(() => { | ||
cy.navigateToUrl(url); | ||
}); | ||
|
||
it('renders a heading caption', () => { | ||
cy.checkText(headingCaption(), CONTENT_STRINGS.HEADING_CAPTION); | ||
}); | ||
|
||
it(`renders ${FIELD_ID} hint and input`, () => { | ||
const field = fieldSelector(FIELD_ID); | ||
|
||
cy.checkText(field.hint(), FIELD_STRINGS.AGENT_CHARGES[FIELD_ID]); | ||
|
||
field.input().should('exist'); | ||
}); | ||
|
||
it('renders a `save and back` button', () => { | ||
cy.assertSaveAndBackButton(); | ||
}); | ||
}); | ||
|
||
describe('form submission', () => { | ||
it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { | ||
cy.navigateToUrl(url); | ||
|
||
cy.completeAndSubmitHowMuchIsTheAgentChargingForm({}); | ||
|
||
cy.assertUrl(checkYourAnswersUrl); | ||
}); | ||
}); | ||
}, | ||
); |
80 changes: 80 additions & 0 deletions
80
...w-much-is-the-agent-charging/validation/how-much-is-the-agent-charging-validation.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,80 @@ | ||
import { field as fieldSelector } from '../../../../../../../pages/shared'; | ||
import { MINIMUM_CHARACTERS } from '../../../../../../../constants'; | ||
import { ERROR_MESSAGES } from '../../../../../../../content-strings'; | ||
import FIELD_IDS from '../../../../../../../constants/field-ids/insurance/export-contract'; | ||
import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insurance'; | ||
|
||
const { | ||
ROOT, | ||
EXPORT_CONTRACT: { HOW_MUCH_IS_THE_AGENT_CHARGING }, | ||
} = INSURANCE_ROUTES; | ||
|
||
const { | ||
AGENT_CHARGES: { FIXED_SUM_AMOUNT: FIELD_ID }, | ||
} = FIELD_IDS; | ||
|
||
const { | ||
INSURANCE: { | ||
EXPORT_CONTRACT: { | ||
AGENT_CHARGES: { [FIELD_ID]: ERROR_MESSAGES_OBJECT }, | ||
}, | ||
}, | ||
} = ERROR_MESSAGES; | ||
|
||
const assertions = { | ||
field: fieldSelector(FIELD_ID), | ||
errorIndex: 0, | ||
expectedErrorsCount: 1, | ||
}; | ||
|
||
const baseUrl = Cypress.config('baseUrl'); | ||
|
||
context('Insurance - Export contract - How much is the agent charging page - form validation', () => { | ||
let referenceNumber; | ||
let url; | ||
|
||
before(() => { | ||
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { | ||
referenceNumber = refNumber; | ||
|
||
url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_IS_THE_AGENT_CHARGING}`; | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.saveSession(); | ||
|
||
cy.navigateToUrl(url); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteApplication(referenceNumber); | ||
}); | ||
|
||
it(`should display validation errors when ${FIELD_ID} is left empty`, () => { | ||
cy.submitAndAssertFieldErrors({ ...assertions, expectedErrorMessage: ERROR_MESSAGES_OBJECT.IS_EMPTY }); | ||
}); | ||
|
||
it(`should display validation errors when ${FIELD_ID} has special characters`, () => { | ||
cy.submitAndAssertFieldErrors({ | ||
...assertions, | ||
value: '10!', | ||
expectedErrorMessage: ERROR_MESSAGES_OBJECT.INCORRECT_FORMAT, | ||
}); | ||
}); | ||
|
||
it(`should display validation errors when ${FIELD_ID} is below ${MINIMUM_CHARACTERS.ONE}`, () => { | ||
cy.submitAndAssertFieldErrors({ | ||
...assertions, | ||
value: String(MINIMUM_CHARACTERS.ONE - 1), | ||
expectedErrorMessage: ERROR_MESSAGES_OBJECT.BELOW_MINIMUM, | ||
}); | ||
}); | ||
|
||
it(`should NOT display validation errors when ${FIELD_ID} is a decimal place number`, () => { | ||
cy.keyboardInput(fieldSelector(FIELD_ID).input(), '1.50'); | ||
|
||
cy.clickSubmitButton(); | ||
cy.assertErrorSummaryListDoesNotExist(); | ||
}); | ||
}); |
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