-
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.
Merge branch 'main-iterations' into chore/EMS-3894
- Loading branch information
Showing
24 changed files
with
586 additions
and
39 deletions.
There are no files selected for viewing
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
116 changes: 116 additions & 0 deletions
116
...-agents-charge/change-your-answers-currency-of-agents-charge-alternative-currency.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,116 @@ | ||
import { summaryList } from '../../../../../../../../pages/shared'; | ||
import { INSURANCE_FIELD_IDS } from '../../../../../../../../constants/field-ids/insurance'; | ||
import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance'; | ||
import application from '../../../../../../../../fixtures/application'; | ||
import { EUR, NON_STANDARD_CURRENCY_CODE, NON_STANDARD_CURRENCY_NAME, SYMBOLS } from '../../../../../../../../fixtures/currencies'; | ||
import formatCurrency from '../../../../../../../../helpers/format-currency'; | ||
|
||
const { | ||
ROOT, | ||
CHECK_YOUR_ANSWERS: { EXPORT_CONTRACT }, | ||
} = INSURANCE_ROUTES; | ||
|
||
const { | ||
CURRENCY: { CURRENCY_CODE }, | ||
EXPORT_CONTRACT: { | ||
AGENT_CHARGES: { FIXED_SUM_AMOUNT }, | ||
}, | ||
} = INSURANCE_FIELD_IDS; | ||
|
||
const currencyAssertion = { | ||
row: summaryList.field(CURRENCY_CODE), | ||
expected: '', | ||
}; | ||
|
||
const amountAssertion = { | ||
row: summaryList.field(FIXED_SUM_AMOUNT), | ||
expected: '', | ||
}; | ||
|
||
const baseUrl = Cypress.config('baseUrl'); | ||
|
||
context( | ||
'Insurance - Change your answers - Export contract - Summary list - Currency of agent charges - Alternative currency - As an exporter, I want to change my answers to the export contract section', | ||
() => { | ||
let referenceNumber; | ||
let checkYourAnswersUrl; | ||
|
||
before(() => { | ||
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { | ||
referenceNumber = refNumber; | ||
|
||
cy.completePrepareApplicationSinglePolicyType({ | ||
referenceNumber, | ||
isUsingAgent: true, | ||
agentIsCharging: true, | ||
agentChargeMethodFixedSum: true, | ||
}); | ||
|
||
cy.clickTaskCheckAnswers(); | ||
|
||
// To get past previous "Check your answers" pages | ||
cy.completeAndSubmitMultipleCheckYourAnswers({ count: 3 }); | ||
|
||
checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${EXPORT_CONTRACT}`; | ||
|
||
cy.assertUrl(checkYourAnswersUrl); | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.saveSession(); | ||
|
||
cy.navigateToUrl(checkYourAnswersUrl); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteApplication(referenceNumber); | ||
}); | ||
|
||
describe(`changing ${CURRENCY_CODE} to an alternative currency (${NON_STANDARD_CURRENCY_CODE})`, () => { | ||
beforeEach(() => { | ||
cy.navigateToUrl(checkYourAnswersUrl); | ||
|
||
summaryList.field(CURRENCY_CODE).changeLink().click(); | ||
|
||
cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: true }); | ||
}); | ||
|
||
it(`should redirect to ${EXPORT_CONTRACT}`, () => { | ||
cy.assertChangeAnswersPageUrl({ referenceNumber, route: EXPORT_CONTRACT, fieldId: CURRENCY_CODE }); | ||
}); | ||
|
||
it(`should render the new answer for ${CURRENCY_CODE} and ${FIXED_SUM_AMOUNT}`, () => { | ||
currencyAssertion.expected = NON_STANDARD_CURRENCY_NAME; | ||
|
||
cy.checkText(currencyAssertion.row.value(), currencyAssertion.expected); | ||
|
||
amountAssertion.expected = formatCurrency(application.EXPORT_CONTRACT.AGENT_CHARGES[FIXED_SUM_AMOUNT], NON_STANDARD_CURRENCY_CODE); | ||
|
||
cy.checkText(amountAssertion.row.value(), amountAssertion.expected); | ||
}); | ||
}); | ||
|
||
describe(`changing ${CURRENCY_CODE} from an alternative currency to ${SYMBOLS.EUR}`, () => { | ||
const currencyCode = EUR.isoCode; | ||
|
||
beforeEach(() => { | ||
cy.navigateToUrl(checkYourAnswersUrl); | ||
|
||
summaryList.field(CURRENCY_CODE).changeLink().click(); | ||
|
||
cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: currencyCode }); | ||
}); | ||
|
||
it(`should render the new answer for ${CURRENCY_CODE} and ${FIXED_SUM_AMOUNT}`, () => { | ||
currencyAssertion.expected = EUR.name; | ||
|
||
cy.checkText(currencyAssertion.row.value(), currencyAssertion.expected); | ||
|
||
amountAssertion.expected = formatCurrency(application.EXPORT_CONTRACT.AGENT_CHARGES[FIXED_SUM_AMOUNT], currencyCode); | ||
|
||
cy.checkText(amountAssertion.row.value(), amountAssertion.expected); | ||
}); | ||
}); | ||
}, | ||
); |
103 changes: 103 additions & 0 deletions
103
...r-answers/currency-of-agents-charge/change-your-answers-currency-of-agents-charge.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,103 @@ | ||
import { summaryList } from '../../../../../../../../pages/shared'; | ||
import { INSURANCE_FIELD_IDS } from '../../../../../../../../constants/field-ids/insurance'; | ||
import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance'; | ||
import { USD } from '../../../../../../../../fixtures/currencies'; | ||
|
||
const { | ||
ROOT, | ||
CHECK_YOUR_ANSWERS: { EXPORT_CONTRACT }, | ||
EXPORT_CONTRACT: { AGENT_CHARGES_CURRENCY_CHECK_AND_CHANGE }, | ||
} = INSURANCE_ROUTES; | ||
|
||
const { | ||
CURRENCY: { CURRENCY_CODE }, | ||
} = INSURANCE_FIELD_IDS; | ||
|
||
const getFieldVariables = (fieldId, referenceNumber) => ({ | ||
changeLink: summaryList.field(fieldId).changeLink, | ||
checkYourAnswersRoute: EXPORT_CONTRACT, | ||
fieldId, | ||
newValueInput: '', | ||
referenceNumber, | ||
route: AGENT_CHARGES_CURRENCY_CHECK_AND_CHANGE, | ||
summaryList, | ||
}); | ||
|
||
const baseUrl = Cypress.config('baseUrl'); | ||
|
||
context('Insurance - Change your answers - Export contract - Summary list - Currency of agent charges', () => { | ||
let referenceNumber; | ||
let url; | ||
|
||
before(() => { | ||
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { | ||
referenceNumber = refNumber; | ||
|
||
cy.completePrepareApplicationSinglePolicyType({ | ||
referenceNumber, | ||
isUsingAgent: true, | ||
agentIsCharging: true, | ||
agentChargeMethodFixedSum: true, | ||
}); | ||
|
||
cy.clickTaskCheckAnswers(); | ||
|
||
// To get past previous "Check your answers" pages | ||
cy.completeAndSubmitMultipleCheckYourAnswers({ count: 3 }); | ||
|
||
url = `${baseUrl}${ROOT}/${referenceNumber}${EXPORT_CONTRACT}`; | ||
|
||
cy.assertUrl(url); | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.saveSession(); | ||
|
||
cy.navigateToUrl(url); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteApplication(referenceNumber); | ||
}); | ||
|
||
describe(CURRENCY_CODE, () => { | ||
const fieldId = CURRENCY_CODE; | ||
|
||
const fieldVariables = { | ||
...getFieldVariables(fieldId, referenceNumber), | ||
newValueInput: USD.isoCode, | ||
newValue: USD.name, | ||
}; | ||
|
||
describe('when clicking the `change` link', () => { | ||
beforeEach(() => { | ||
cy.navigateToUrl(url); | ||
}); | ||
|
||
it(`should redirect to ${AGENT_CHARGES_CURRENCY_CHECK_AND_CHANGE}`, () => { | ||
cy.navigateToUrl(url); | ||
|
||
cy.checkChangeLinkUrl(fieldVariables, referenceNumber); | ||
}); | ||
}); | ||
|
||
describe('form submission with a new answer', () => { | ||
beforeEach(() => { | ||
cy.navigateToUrl(url); | ||
|
||
summaryList.field(fieldId).changeLink().click(); | ||
|
||
cy.changeAnswerRadioField(fieldVariables); | ||
}); | ||
|
||
it(`should redirect to ${EXPORT_CONTRACT}`, () => { | ||
cy.assertChangeAnswersPageUrl({ referenceNumber, route: EXPORT_CONTRACT, fieldId }); | ||
}); | ||
|
||
it('should render the new answer', () => { | ||
cy.checkChangeAnswerRendered({ fieldVariables }); | ||
}); | ||
}); | ||
}); | ||
}); |
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
108 changes: 108 additions & 0 deletions
108
...-agents-charge/change-your-answers-currency-of-agents-charge-alternative-currency.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,108 @@ | ||
import { summaryList } from '../../../../../../../pages/shared'; | ||
import { INSURANCE_FIELD_IDS } from '../../../../../../../constants/field-ids/insurance'; | ||
import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insurance'; | ||
import application from '../../../../../../../fixtures/application'; | ||
import { EUR, NON_STANDARD_CURRENCY_CODE, NON_STANDARD_CURRENCY_NAME, SYMBOLS } from '../../../../../../../fixtures/currencies'; | ||
import formatCurrency from '../../../../../../../helpers/format-currency'; | ||
|
||
const { | ||
ROOT, | ||
EXPORT_CONTRACT: { CHECK_YOUR_ANSWERS }, | ||
} = INSURANCE_ROUTES; | ||
|
||
const { | ||
CURRENCY: { CURRENCY_CODE }, | ||
EXPORT_CONTRACT: { | ||
AGENT_CHARGES: { FIXED_SUM_AMOUNT }, | ||
}, | ||
} = INSURANCE_FIELD_IDS; | ||
|
||
const currencyAssertion = { | ||
row: summaryList.field(CURRENCY_CODE), | ||
expected: '', | ||
}; | ||
|
||
const amountAssertion = { | ||
row: summaryList.field(FIXED_SUM_AMOUNT), | ||
expected: '', | ||
}; | ||
|
||
const baseUrl = Cypress.config('baseUrl'); | ||
|
||
context( | ||
'Insurance - Export contract - Change your answers - Currency of agent charges - Alternative currency - As an exporter, I want to change my answers to the export contract section', | ||
() => { | ||
let referenceNumber; | ||
let checkYourAnswersUrl; | ||
|
||
before(() => { | ||
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { | ||
referenceNumber = refNumber; | ||
|
||
cy.completeExportContractSection({ | ||
isUsingAgent: true, | ||
agentIsCharging: true, | ||
agentChargeMethodFixedSum: true, | ||
}); | ||
|
||
checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; | ||
|
||
cy.assertUrl(checkYourAnswersUrl); | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.saveSession(); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteApplication(referenceNumber); | ||
}); | ||
|
||
describe(`changing ${CURRENCY_CODE} to an alternative currency (${NON_STANDARD_CURRENCY_CODE})`, () => { | ||
beforeEach(() => { | ||
cy.navigateToUrl(checkYourAnswersUrl); | ||
|
||
summaryList.field(CURRENCY_CODE).changeLink().click(); | ||
|
||
cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: true }); | ||
}); | ||
|
||
it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { | ||
cy.assertChangeAnswersPageUrl({ referenceNumber, route: CHECK_YOUR_ANSWERS, fieldId: CURRENCY_CODE }); | ||
}); | ||
|
||
it(`should render the new answer for ${CURRENCY_CODE} and ${FIXED_SUM_AMOUNT}`, () => { | ||
currencyAssertion.expected = NON_STANDARD_CURRENCY_NAME; | ||
|
||
cy.checkText(currencyAssertion.row.value(), currencyAssertion.expected); | ||
|
||
amountAssertion.expected = formatCurrency(application.EXPORT_CONTRACT.AGENT_CHARGES[FIXED_SUM_AMOUNT], NON_STANDARD_CURRENCY_CODE); | ||
|
||
cy.checkText(amountAssertion.row.value(), amountAssertion.expected); | ||
}); | ||
}); | ||
|
||
describe(`changing ${CURRENCY_CODE} from an alternative currency to ${SYMBOLS.EUR}`, () => { | ||
const currencyCode = EUR.isoCode; | ||
|
||
beforeEach(() => { | ||
cy.navigateToUrl(checkYourAnswersUrl); | ||
|
||
summaryList.field(CURRENCY_CODE).changeLink().click(); | ||
|
||
cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: currencyCode }); | ||
}); | ||
|
||
it(`should render the new answer for ${CURRENCY_CODE} and ${FIXED_SUM_AMOUNT}`, () => { | ||
currencyAssertion.expected = EUR.name; | ||
|
||
cy.checkText(currencyAssertion.row.value(), currencyAssertion.expected); | ||
|
||
amountAssertion.expected = formatCurrency(application.EXPORT_CONTRACT.AGENT_CHARGES[FIXED_SUM_AMOUNT], currencyCode); | ||
|
||
cy.checkText(amountAssertion.row.value(), amountAssertion.expected); | ||
}); | ||
}); | ||
}, | ||
); |
Oops, something went wrong.