diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d4ddfde9e5..379f85f3eb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -597,8 +597,8 @@ jobs: 'export-contract/agent-details/**/*.spec.js', 'export-contract/agent-service/**/*.spec.js', 'export-contract/agent-charges/**/*.spec.js', - # TODO: EMS-3828 - renable - # 'export-contract/currency-of-agent-charges/*.spec.js', + 'export-contract/currency-of-agent-charges/*.spec.js', + 'export-contract/how-much-the-agent-is-charging/**/*.spec.js', 'export-contract/change-your-answers/about-goods-or-services/*.spec.js', 'export-contract/change-your-answers/agent/*.spec.js', 'export-contract/change-your-answers/agent-charges/*.spec.js', diff --git a/e2e-tests/commands/insurance/complete-and-submit-alternative-currency-form.js b/e2e-tests/commands/insurance/complete-and-submit-alternative-currency-form.js index fedd4032d2..94b5331088 100644 --- a/e2e-tests/commands/insurance/complete-and-submit-alternative-currency-form.js +++ b/e2e-tests/commands/insurance/complete-and-submit-alternative-currency-form.js @@ -10,23 +10,14 @@ const { CURRENCY_CODE } = INSURANCE_FIELD_IDS.CURRENCY; * if alternativeCurrency true, then enters alternative currency and submits alternative currency form * @param {String} isoCode: isoCode for radio selection. * @param {Boolean} alternativeCurrency: If alternative currency should be entered. - * @param {Boolean} clickAlternativeCurrencyLink: if the "Alternative currency" link should be clicked. */ -const completeAndSubmitAlternativeCurrencyForm = ({ isoCode, alternativeCurrency, clickAlternativeCurrencyLink = true }) => { +const completeAndSubmitAlternativeCurrencyForm = ({ isoCode, alternativeCurrency = true }) => { if (isoCode) { - if (clickAlternativeCurrencyLink) { - cy.clickProvideAlternativeCurrencyLink(); - } - radios(CURRENCY_CODE, isoCode).option.label().click(); cy.clickSubmitButton(); } if (alternativeCurrency) { - if (clickAlternativeCurrencyLink) { - cy.clickProvideAlternativeCurrencyLink(); - } - cy.clickAlternativeCurrencyRadioAndSubmitCurrency({ currency: isoCode }); } diff --git a/e2e-tests/commands/insurance/complete-and-submit-how-much-the-agent-is-charging-form.js b/e2e-tests/commands/insurance/complete-and-submit-how-much-the-agent-is-charging-form.js new file mode 100644 index 0000000000..69b8338129 --- /dev/null +++ b/e2e-tests/commands/insurance/complete-and-submit-how-much-the-agent-is-charging-form.js @@ -0,0 +1,12 @@ +/** + * completeAndSubmitHowMuchTheAgentIsChargingForm + * Complete and submit the "How much the agent is charging" form + * @param {String} fixedSumAmount: Fixed sum amount + */ +const completeAndSubmitHowMuchTheAgentIsChargingForm = ({ fixedSumAmount }) => { + cy.completeHowMuchTheAgentIsChargingForm({ fixedSumAmount }); + + cy.clickSubmitButton(); +}; + +export default completeAndSubmitHowMuchTheAgentIsChargingForm; diff --git a/e2e-tests/commands/insurance/complete-business-section.js b/e2e-tests/commands/insurance/complete-business-section.js index c8c5ee7c66..7ab9314f1a 100644 --- a/e2e-tests/commands/insurance/complete-business-section.js +++ b/e2e-tests/commands/insurance/complete-business-section.js @@ -15,7 +15,6 @@ const completeBusinessSection = ({ hasCreditControlProcess = false, submitCheckYourAnswers = false, alternativeCurrencyTurnover = false, - clickAlternativeCurrencyLink, }) => { cy.startYourBusinessSection({ viaTaskList }); @@ -26,7 +25,7 @@ const completeBusinessSection = ({ } cy.completeAndSubmitNatureOfYourBusiness(); - cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: alternativeCurrencyTurnover, clickAlternativeCurrencyLink }); + cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: alternativeCurrencyTurnover }); cy.completeAndSubmitTurnoverForm(); cy.completeAndSubmitCreditControlForm({ hasCreditControlProcess }); diff --git a/e2e-tests/commands/insurance/complete-buyer-section.js b/e2e-tests/commands/insurance/complete-buyer-section.js index 03a3bee6c5..8271f239ad 100644 --- a/e2e-tests/commands/insurance/complete-buyer-section.js +++ b/e2e-tests/commands/insurance/complete-buyer-section.js @@ -34,7 +34,7 @@ const completeBuyerSection = ({ cy.completeAndSubmitTradingHistoryWithBuyerForm({ outstandingPayments: outstandingPayments || fullyPopulatedBuyerTradingHistory }); if (outstandingPayments || fullyPopulatedBuyerTradingHistory) { - cy.completeAndSubmitAlternativeCurrencyForm({ clickAlternativeCurrencyLink: false }); + cy.completeAndSubmitAlternativeCurrencyForm({}); cy.completeAndSubmitOutstandingOrOverduePaymentsForm({ outstandingPayments }); } diff --git a/e2e-tests/commands/insurance/complete-export-contract-section.js b/e2e-tests/commands/insurance/complete-export-contract-section.js index ef5193435a..02d9e5e9ff 100644 --- a/e2e-tests/commands/insurance/complete-export-contract-section.js +++ b/e2e-tests/commands/insurance/complete-export-contract-section.js @@ -73,7 +73,7 @@ const completeExportContractSection = ({ if (agentChargeMethodFixedSum) { cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency }); - cy.completeAndSubmitHowMuchIsTheAgentChargingForm({ + cy.completeAndSubmitHowMuchTheAgentIsChargingForm({ fixedSumAmount: agentChargeFixedSumAmount, }); } diff --git a/e2e-tests/commands/insurance/complete-and-submit-how-much-is-the-agent-charging-form.js b/e2e-tests/commands/insurance/complete-how-much-the-agent-is-charging-form.js similarity index 51% rename from e2e-tests/commands/insurance/complete-and-submit-how-much-is-the-agent-charging-form.js rename to e2e-tests/commands/insurance/complete-how-much-the-agent-is-charging-form.js index 8d989f32b9..80c79a65b1 100644 --- a/e2e-tests/commands/insurance/complete-and-submit-how-much-is-the-agent-charging-form.js +++ b/e2e-tests/commands/insurance/complete-how-much-the-agent-is-charging-form.js @@ -7,14 +7,12 @@ const { } = FIELD_IDS; /** - * completeAndSubmitHowMuchIsTheAgentChargingForm - * Complete and submit the "How much is the agent charging" form + * completeHowMuchTheAgentIsChargingForm + * Complete the "How much the agent is charging" form * @param {String} fixedSumAmount: Fixed sum amount */ -const completeAndSubmitHowMuchIsTheAgentChargingForm = ({ fixedSumAmount = application.EXPORT_CONTRACT.AGENT_CHARGES[FIXED_SUM_AMOUNT] }) => { +const completeHowMuchTheAgentIsChargingForm = ({ fixedSumAmount = application.EXPORT_CONTRACT.AGENT_CHARGES[FIXED_SUM_AMOUNT] }) => { cy.keyboardInput(field(FIXED_SUM_AMOUNT).input(), fixedSumAmount); - - cy.clickSubmitButton(); }; -export default completeAndSubmitHowMuchIsTheAgentChargingForm; +export default completeHowMuchTheAgentIsChargingForm; diff --git a/e2e-tests/commands/insurance/complete-prepare-application-section-multiple-policy-type.js b/e2e-tests/commands/insurance/complete-prepare-application-section-multiple-policy-type.js index e51030384f..defcc32ca6 100644 --- a/e2e-tests/commands/insurance/complete-prepare-application-section-multiple-policy-type.js +++ b/e2e-tests/commands/insurance/complete-prepare-application-section-multiple-policy-type.js @@ -78,7 +78,6 @@ const completePrepareApplicationMultiplePolicyType = ({ totalContractValueOverThreshold = false, submitCheckYourAnswers = true, usingBroker = false, - clickAlternativeCurrencyLink, }) => { cy.completeBusinessSection({ differentTradingName, @@ -86,7 +85,6 @@ const completePrepareApplicationMultiplePolicyType = ({ hasCreditControlProcess, submitCheckYourAnswers, alternativeCurrencyTurnover, - clickAlternativeCurrencyLink, }); cy.completeBuyerSection({ diff --git a/e2e-tests/commands/insurance/complete-prepare-application-section-single-policy-type.js b/e2e-tests/commands/insurance/complete-prepare-application-section-single-policy-type.js index c4f80842f8..48b187c7e2 100644 --- a/e2e-tests/commands/insurance/complete-prepare-application-section-single-policy-type.js +++ b/e2e-tests/commands/insurance/complete-prepare-application-section-single-policy-type.js @@ -78,7 +78,6 @@ const completePrepareApplicationSinglePolicyType = ({ totalContractValueOverThreshold = false, submitCheckYourAnswers = true, usingBroker = false, - clickAlternativeCurrencyLink = true, }) => { cy.completeBusinessSection({ differentTradingName, @@ -86,7 +85,6 @@ const completePrepareApplicationSinglePolicyType = ({ hasCreditControlProcess, submitCheckYourAnswers, alternativeCurrencyTurnover, - clickAlternativeCurrencyLink, }); cy.completeBuyerSection({ diff --git a/e2e-tests/commands/insurance/complete-sign-in-and-submit-an-application.js b/e2e-tests/commands/insurance/complete-sign-in-and-submit-an-application.js index 5aba2d55ee..a980c709a5 100644 --- a/e2e-tests/commands/insurance/complete-sign-in-and-submit-an-application.js +++ b/e2e-tests/commands/insurance/complete-sign-in-and-submit-an-application.js @@ -76,7 +76,6 @@ const completeSignInAndSubmitAnApplication = ({ policyValueOverMvpMaximum = false, totalContractValueOverThreshold = false, usingBroker = false, - clickAlternativeCurrencyLink = true, }) => { completeSignInAndGoToApplication({ companyNumber, @@ -114,7 +113,6 @@ const completeSignInAndSubmitAnApplication = ({ referenceNumber, totalContractValueOverThreshold, usingBroker, - clickAlternativeCurrencyLink, }); } else { cy.completePrepareApplicationSinglePolicyType({ @@ -147,7 +145,6 @@ const completeSignInAndSubmitAnApplication = ({ referenceNumber, totalContractValueOverThreshold, usingBroker, - clickAlternativeCurrencyLink, }); } cy.completeAndSubmitCheckYourAnswers(); diff --git a/e2e-tests/commands/insurance/export-contract/complete-and-submit-export-contract-forms.js b/e2e-tests/commands/insurance/export-contract/complete-and-submit-export-contract-forms.js index edd0aa0fca..eeaabcec90 100644 --- a/e2e-tests/commands/insurance/export-contract/complete-and-submit-export-contract-forms.js +++ b/e2e-tests/commands/insurance/export-contract/complete-and-submit-export-contract-forms.js @@ -50,7 +50,7 @@ const completeAndSubmitExportContractForms = ({ steps = [ ...steps, { name: 'currencyOfAgentCharges', action: () => cy.completeAndSubmitAlternativeCurrencyForm({}) }, - { name: 'howMuchAgentIsCharging', action: () => cy.completeAndSubmitHowMuchIsTheAgentChargingForm({ fixedSumAmount }) }, + { name: 'howMuchAgentIsCharging', action: () => cy.completeAndSubmitHowMuchTheAgentIsChargingForm({ fixedSumAmount }) }, ]; } diff --git a/e2e-tests/commands/insurance/your-buyer/complete-and-submit-your-buyer-forms.js b/e2e-tests/commands/insurance/your-buyer/complete-and-submit-your-buyer-forms.js index ed35ae5117..a89b1434de 100644 --- a/e2e-tests/commands/insurance/your-buyer/complete-and-submit-your-buyer-forms.js +++ b/e2e-tests/commands/insurance/your-buyer/complete-and-submit-your-buyer-forms.js @@ -3,7 +3,6 @@ * completes your buyer forms up to the specified form to stop at * eg, when 'connectionWithTheBuyer' is passed, it will complete all forms up to and including 'connectionWithTheBuyer' * @param {Boolean} alternativeCurrency: If alternative currency should be entered. - * @param {Boolean} clickAlternativeCurrencyLink: if the "Alternative currency" link should be clicked. * @param {Boolean} exporterHasTradedWithBuyer: whether the exporter has traded with the buyer * @param {Boolean} failedToPay: whether the buyer has failed to pay the exporter * @param {String} formToStopAt: the form to stop at @@ -16,7 +15,6 @@ */ const completeAndSubmitYourBuyerForms = ({ alternativeCurrency, - clickAlternativeCurrencyLink, exporterHasTradedWithBuyer, failedToPay, formToStopAt, @@ -48,7 +46,7 @@ const completeAndSubmitYourBuyerForms = ({ if (outstandingPayments) { steps.push({ name: 'currencyOfLatePayments', - action: () => cy.completeAndSubmitAlternativeCurrencyForm({ isoCode, alternativeCurrency, clickAlternativeCurrencyLink }), + action: () => cy.completeAndSubmitAlternativeCurrencyForm({ isoCode, alternativeCurrency }), }); steps.push({ name: 'outstandingOrOverduePayments', action: () => cy.completeAndSubmitOutstandingOrOverduePaymentsForm({ outstandingPayments }) }); } diff --git a/e2e-tests/commands/shared-commands/click-events/click-provide-alternative-currency-link.js b/e2e-tests/commands/shared-commands/click-events/click-provide-alternative-currency-link.js deleted file mode 100644 index 51679bb698..0000000000 --- a/e2e-tests/commands/shared-commands/click-events/click-provide-alternative-currency-link.js +++ /dev/null @@ -1,11 +0,0 @@ -import partials from '../../../partials'; - -/** - * clickProvideAlternativeCurrencyLink - * Click the "provide alternative currency" link. - */ -const clickProvideAlternativeCurrencyLink = () => { - partials.provideAlternativeCurrencyLink().click(); -}; - -export default clickProvideAlternativeCurrencyLink; diff --git a/e2e-tests/commands/shared-commands/click-events/index.js b/e2e-tests/commands/shared-commands/click-events/index.js index 3e50459d03..e35fb4afe8 100644 --- a/e2e-tests/commands/shared-commands/click-events/index.js +++ b/e2e-tests/commands/shared-commands/click-events/index.js @@ -8,7 +8,6 @@ Cypress.Commands.add('clickSignInButtonLink', require('./click-sign-in-button-li Cypress.Commands.add('clickSignInResetPasswordLink', require('./click-sign-in-reset-password-link')); Cypress.Commands.add('clickYesRadioInput', require('./click-yes-radio-input')); -Cypress.Commands.add('clickProvideAlternativeCurrencyLink', require('./click-provide-alternative-currency-link')); Cypress.Commands.add('clickAlternativeCurrencyRadioOption', require('./click-alternative-currency-radio-option')); Cypress.Commands.add('clickFooterAccessibilityStatementLink', require('./click-footer-accessibility-statement-link')); diff --git a/e2e-tests/commands/shared-commands/form/click-alternative-currency-radio-and-submit-currency.js b/e2e-tests/commands/shared-commands/form/click-alternative-currency-radio-and-submit-currency.js index 0194e31186..cc49aec73d 100644 --- a/e2e-tests/commands/shared-commands/form/click-alternative-currency-radio-and-submit-currency.js +++ b/e2e-tests/commands/shared-commands/form/click-alternative-currency-radio-and-submit-currency.js @@ -3,11 +3,16 @@ * Complete and submit an "alternative currency" field * @param {String} fieldId: Field ID * @param {String} currency: Currency + * @param {Boolean} viaSaveAndBack: Flag whether to submit the form via the "save and back" button. */ -const clickAlternativeCurrencyRadioAndSubmitCurrency = ({ fieldId, currency }) => { +const clickAlternativeCurrencyRadioAndSubmitCurrency = ({ fieldId, currency, viaSaveAndBack }) => { cy.clickAlternativeCurrencyRadioAndCompleteCurrency({ fieldId, currency }); - cy.clickSubmitButton(); + if (viaSaveAndBack) { + cy.clickSaveAndBackButton(); + } else { + cy.clickSubmitButton(); + } }; export default clickAlternativeCurrencyRadioAndSubmitCurrency; diff --git a/e2e-tests/constants/routes/insurance/export-contract.js b/e2e-tests/constants/routes/insurance/export-contract.js index de8d74f680..a0a38d573d 100644 --- a/e2e-tests/constants/routes/insurance/export-contract.js +++ b/e2e-tests/constants/routes/insurance/export-contract.js @@ -9,7 +9,7 @@ const AGENT_DETAILS_ROOT = `${ROOT}/agent-details`; const AGENT_SERVICE_ROOT = `${ROOT}/agent-service`; const AGENT_CHARGES_ROOT = `${ROOT}/agent-charges`; const AGENT_CHARGES_CURRENCY_ROOT = `${ROOT}/currency-of-agents-charge`; -const HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT = `${ROOT}/how-much-is-the-agent-charging`; +const HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT = `${ROOT}/how-much-the-agent-is-charging`; export const EXPORT_CONTRACT = { ROOT, @@ -53,9 +53,9 @@ export const EXPORT_CONTRACT = { AGENT_CHARGES_CURRENCY: AGENT_CHARGES_CURRENCY_ROOT, AGENT_CHARGES_CURRENCY_CHANGE: `${AGENT_CHARGES_CURRENCY_ROOT}/change`, AGENT_CHARGES_CURRENCY_CHECK_AND_CHANGE: `${AGENT_CHARGES_CURRENCY_ROOT}/check-and-change`, - HOW_MUCH_IS_THE_AGENT_CHARGING_SAVE_AND_BACK: `${HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT}/save-and-go-back`, - HOW_MUCH_IS_THE_AGENT_CHARGING: HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT, - HOW_MUCH_IS_THE_AGENT_CHARGING_CHANGE: `${HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT}/change`, - HOW_MUCH_IS_THE_AGENT_CHARGING_CHECK_AND_CHANGE: `${HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT}/check-and-change`, + HOW_MUCH_THE_AGENT_IS_CHARGING_SAVE_AND_BACK: `${HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT}/save-and-go-back`, + HOW_MUCH_THE_AGENT_IS_CHARGING: HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT, + HOW_MUCH_THE_AGENT_IS_CHARGING_CHANGE: `${HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT}/change`, + HOW_MUCH_THE_AGENT_IS_CHARGING_CHECK_AND_CHANGE: `${HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT}/check-and-change`, CHECK_YOUR_ANSWERS: `${ROOT}/check-your-answers`, }; diff --git a/e2e-tests/content-strings/pages/insurance/export-contract/index.js b/e2e-tests/content-strings/pages/insurance/export-contract/index.js index 5b26b0143d..c477bec49d 100644 --- a/e2e-tests/content-strings/pages/insurance/export-contract/index.js +++ b/e2e-tests/content-strings/pages/insurance/export-contract/index.js @@ -66,7 +66,7 @@ const AGENT_CHARGES_CURRENCY = { PAGE_TITLE: 'What currency is the agent charging you in?', }; -const HOW_MUCH_IS_THE_AGENT_CHARGING = { +const HOW_MUCH_THE_AGENT_IS_CHARGING = { ...SHARED, PAGE_TITLE: 'How much is the agent charging in', }; @@ -88,6 +88,6 @@ module.exports = { AGENT_SERVICE, AGENT_CHARGES, AGENT_CHARGES_CURRENCY, - HOW_MUCH_IS_THE_AGENT_CHARGING, + HOW_MUCH_THE_AGENT_IS_CHARGING, CHECK_YOUR_ANSWERS, }; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/business-conditions/submit-an-application-multiple-policy-type-business-fully-populated.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/business-conditions/submit-an-application-multiple-policy-type-business-fully-populated.spec.js index da60dbfa47..2332483b9a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/business-conditions/submit-an-application-multiple-policy-type-business-fully-populated.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/business-conditions/submit-an-application-multiple-policy-type-business-fully-populated.spec.js @@ -10,7 +10,6 @@ context('Insurance - submit an application - Multiple policy - fully populated b differentTradingAddress: true, policyType: APPLICATION.POLICY_TYPE.MULTIPLE, usingBroker: true, - clickAlternativeCurrencyLink: false, }).then((refNumber) => { referenceNumber = refNumber; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/business-conditions/submit-an-application-multiple-policy-type-with-alternative-turnover-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/business-conditions/submit-an-application-multiple-policy-type-with-alternative-turnover-currency.spec.js index 707bb2208f..e1696e54d0 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/business-conditions/submit-an-application-multiple-policy-type-with-alternative-turnover-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/business-conditions/submit-an-application-multiple-policy-type-with-alternative-turnover-currency.spec.js @@ -9,7 +9,6 @@ context( cy.completeSignInAndSubmitAnApplication({ policyType: APPLICATION.POLICY_TYPE.MULTIPLE, alternativeCurrencyTurnover: true, - clickAlternativeCurrencyLink: false, }).then((refNumber) => { referenceNumber = refNumber; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/export-contract-conditions/submit-an-application-multiple-policy-type-using-an-agent-alternative-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/export-contract-conditions/submit-an-application-multiple-policy-type-using-an-agent-alternative-currency.spec.js index d77064a53f..882ba269f5 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/export-contract-conditions/submit-an-application-multiple-policy-type-using-an-agent-alternative-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/export-contract-conditions/submit-an-application-multiple-policy-type-using-an-agent-alternative-currency.spec.js @@ -1,7 +1,6 @@ import { APPLICATION } from '../../../../../../../constants'; -// TODO: EMS-3828 - renable -context.skip('Insurance - submit an application - Multiple policy type, using an agent, fixed sum method, alternative currency', () => { +context('Insurance - submit an application - Multiple policy type, using an agent, fixed sum method, alternative currency', () => { let referenceNumber; before(() => { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/business-conditions/submit-an-application-single-policy-type-business-fully-populated.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/business-conditions/submit-an-application-single-policy-type-business-fully-populated.spec.js index 2a19e0c249..b8735d68a8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/business-conditions/submit-an-application-single-policy-type-business-fully-populated.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/business-conditions/submit-an-application-single-policy-type-business-fully-populated.spec.js @@ -7,7 +7,6 @@ context('Insurance - submit an application - Single policy - fully populated bus differentTradingName: true, differentTradingAddress: true, usingBroker: true, - clickAlternativeCurrencyLink: false, }).then((refNumber) => { referenceNumber = refNumber; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/business-conditions/submit-an-application-single-policy-type-with-alternative-turnover-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/business-conditions/submit-an-application-single-policy-type-with-alternative-turnover-currency.spec.js index 16a32d432e..49173fa3b5 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/business-conditions/submit-an-application-single-policy-type-with-alternative-turnover-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/business-conditions/submit-an-application-single-policy-type-with-alternative-turnover-currency.spec.js @@ -4,7 +4,7 @@ context( let referenceNumber; before(() => { - cy.completeSignInAndSubmitAnApplication({ alternativeCurrencyTurnover: true, clickAlternativeCurrencyLink: false }).then((refNumber) => { + cy.completeSignInAndSubmitAnApplication({ alternativeCurrencyTurnover: true }).then((refNumber) => { referenceNumber = refNumber; }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/export-contract-conditions/submit-an-application-single-policy-type-attempted-private-market-cover-and-using-an-agent-with-charges-fixed-sum.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/export-contract-conditions/submit-an-application-single-policy-type-attempted-private-market-cover-and-using-an-agent-with-charges-fixed-sum.spec.js index 4217251150..0693caf791 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/export-contract-conditions/submit-an-application-single-policy-type-attempted-private-market-cover-and-using-an-agent-with-charges-fixed-sum.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/export-contract-conditions/submit-an-application-single-policy-type-attempted-private-market-cover-and-using-an-agent-with-charges-fixed-sum.spec.js @@ -1,35 +1,31 @@ -// TODO: EMS-3828 - renable -context.skip( - 'Insurance - submit an application - Single policy type, attempted private market cover, using an agent, agent is charging - fixed sum method', - () => { - let referenceNumber; +context('Insurance - submit an application - Single policy type, attempted private market cover, using an agent, agent is charging - fixed sum method', () => { + let referenceNumber; - before(() => { - cy.completeSignInAndSubmitAnApplication({ - totalContractValueOverThreshold: true, - attemptedPrivateMarketCover: true, - isUsingAgent: true, - agentIsCharging: true, - agentChargeMethodFixedSum: true, - }).then((refNumber) => { - referenceNumber = refNumber; - }); + before(() => { + cy.completeSignInAndSubmitAnApplication({ + totalContractValueOverThreshold: true, + attemptedPrivateMarketCover: true, + isUsingAgent: true, + agentIsCharging: true, + agentChargeMethodFixedSum: true, + }).then((refNumber) => { + referenceNumber = refNumber; }); + }); - beforeEach(() => { - cy.saveSession(); - }); + beforeEach(() => { + cy.saveSession(); + }); - after(() => { - cy.deleteApplication(referenceNumber); - }); + after(() => { + cy.deleteApplication(referenceNumber); + }); - it('should successfully submit the application and redirect to `application submitted`', () => { - cy.assertApplicationSubmittedUrl(referenceNumber); - }); + it('should successfully submit the application and redirect to `application submitted`', () => { + cy.assertApplicationSubmittedUrl(referenceNumber); + }); - it('should render in a `submitted` state in the dashboard', () => { - cy.assertDashboardApplicationSubmitted(referenceNumber); - }); - }, -); + it('should render in a `submitted` state in the dashboard', () => { + cy.assertDashboardApplicationSubmitted(referenceNumber); + }); +}); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/export-contract-conditions/submit-an-application-single-policy-type-using-an-agent-alternative-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/export-contract-conditions/submit-an-application-single-policy-type-using-an-agent-alternative-currency.spec.js index 028a9315ae..a75fb55b72 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/export-contract-conditions/submit-an-application-single-policy-type-using-an-agent-alternative-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/export-contract-conditions/submit-an-application-single-policy-type-using-an-agent-alternative-currency.spec.js @@ -1,5 +1,4 @@ -// TODO: EMS-3828 - renable -context.skip('Insurance - submit an application - Single policy type, using an agent, fixed sum method, alternative currency', () => { +context('Insurance - submit an application - Single policy type, using an agent, fixed sum method, alternative currency', () => { let referenceNumber; before(() => { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount-alternative-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount-alternative-currency.spec.js index 0f5f704746..e4c60fa135 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount-alternative-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount-alternative-currency.spec.js @@ -19,8 +19,7 @@ const fieldId = FIXED_SUM_AMOUNT; const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip( +context( `Insurance - Change your answers - Export contract - Summary list - Agent charges - ${FIXED_SUM_AMOUNT} - As an exporter, I want to change my answers to an alternative currency`, () => { let referenceNumber; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount.spec.js index 410f7f22cc..0b7de6e444 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount.spec.js @@ -18,8 +18,7 @@ const fieldId = FIXED_SUM_AMOUNT; const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip(`Insurance - Change your answers - Export contract - Summary list - Agent charges - ${FIXED_SUM_AMOUNT}`, () => { +context(`Insurance - Change your answers - Export contract - Summary list - Agent charges - ${FIXED_SUM_AMOUNT}`, () => { let referenceNumber; let url; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-to-percentage.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-to-percentage.spec.js index 8c27ad8272..a553789ae6 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-to-percentage.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-to-percentage.spec.js @@ -15,8 +15,7 @@ const { const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip('Insurance - Change your answers - Export contract - Summary list - Agent charges - Fixed sum to percentage', () => { +context('Insurance - Change your answers - Export contract - Summary list - Agent charges - Fixed sum to percentage', () => { let referenceNumber; let url; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-percentage-to-fixed-sum.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-percentage-to-fixed-sum.spec.js index 31a40db59c..c74b5ddd56 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-percentage-to-fixed-sum.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-percentage-to-fixed-sum.spec.js @@ -17,8 +17,7 @@ const fieldId = PERCENTAGE_CHARGE; const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip('Insurance - Change your answers - Export contract - Summary list - Percentage to Fixed sum', () => { +context('Insurance - Change your answers - Export contract - Summary list - Percentage to Fixed sum', () => { let referenceNumber; let url; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-no-to-yes.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-no-to-yes.spec.js index 9357603744..0ee4605c8a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-no-to-yes.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-no-to-yes.spec.js @@ -83,10 +83,9 @@ context('Insurance - Change your answers - Export contract - Summary list - Agen const expectedUrl = `${agentChargesUrl}#${FIELD_ID}-label`; cy.assertUrl(expectedUrl); - // TODO: EMS-3828 - renable cy.completeAndSubmitAgentChargesForm({ - // fixedSumMethod: true, - percentageMethod: true, + fixedSumMethod: true, + percentageMethod: false, }); cy.assertChangeAnswersPageUrl({ referenceNumber, route: EXPORT_CONTRACT, fieldId: FIELD_ID }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-yes-to-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-yes-to-no.spec.js index 2226c495f6..f7fbfc7fe8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-yes-to-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-yes-to-no.spec.js @@ -101,8 +101,7 @@ context('Insurance - Change your answers - Export contract - Summary list - Agen cy.assertRadioOptionIsNotChecked(agentChargesPage[METHOD][FIXED_SUM].input()); cy.assertRadioOptionIsNotChecked(agentChargesPage[METHOD][PERCENTAGE].input()); - // TODO: EMS-3828 - renable - // cy.checkValue(field(FIXED_SUM_AMOUNT), ''); + cy.checkValue(field(FIXED_SUM_AMOUNT), ''); cy.checkValue(field(PERCENTAGE_CHARGE), ''); cy.checkValue(autoCompleteField(PAYABLE_COUNTRY_CODE), ''); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum-decimals-multiple-policy.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum-decimals-multiple-policy.spec.js index 1a00cf1c6e..29775ee1e2 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum-decimals-multiple-policy.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum-decimals-multiple-policy.spec.js @@ -8,8 +8,7 @@ const { const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip( +context( 'Insurance - Check your answers - Export contract - Summary list - total contract value threshold, private insurance attempt, using an agent, agent is charging - fixed sum method with decimal places - multiple policy', () => { let referenceNumber; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum-decimals.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum-decimals.spec.js index 8861954192..f23ffe96bd 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum-decimals.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum-decimals.spec.js @@ -8,8 +8,7 @@ const { const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip( +context( 'Insurance - Check your answers - Export contract - Summary list - total contract value threshold, private insurance attempt, using an agent, agent is charging - fixed sum method with decimal places', () => { let referenceNumber; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum.spec.js index 7380143bcf..0667c4e9b9 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum.spec.js @@ -8,8 +8,7 @@ const { const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip( +context( 'Insurance - Check your answers - Export contract - Summary list - total contract value threshold, private insurance attempt, using an agent, agent is charging - fixed sum method', () => { let referenceNumber; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-business/change-your-answers/change-your-answers-change-turnover-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-business/change-your-answers/change-your-answers-change-turnover-currency.spec.js index 8187cd6436..6096d4161b 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-business/change-your-answers/change-your-answers-change-turnover-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-business/change-your-answers/change-your-answers-change-turnover-currency.spec.js @@ -68,7 +68,7 @@ context('Insurance - Check your answers - Turnover currency - Your business - Su summaryList.field(fieldId).changeLink().click(); - cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: true, clickAlternativeCurrencyLink: false }); + cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: true }); }); it(`should redirect to ${YOUR_BUSINESS}`, () => { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-buyer/change-your-answers/change-your-answers-change-alternative-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-buyer/change-your-answers/change-your-answers-change-alternative-currency.spec.js index 4289587987..ba5735a127 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-buyer/change-your-answers/change-your-answers-change-alternative-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-buyer/change-your-answers/change-your-answers-change-alternative-currency.spec.js @@ -74,7 +74,7 @@ context('Insurance - Check your answers - Your buyer - Alternative currency - As summaryList.field(currencyFieldId).changeLink().click(); - cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: EUR_CURRENCY_CODE, clickAlternativeCurrencyLink: false }); + cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: EUR_CURRENCY_CODE }); cy.clickSubmitButton(); }); @@ -124,7 +124,7 @@ context('Insurance - Check your answers - Your buyer - Alternative currency - As summaryList.field(currencyFieldId).changeLink().click(); - cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: true, clickAlternativeCurrencyLink: false }); + cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: true }); cy.clickSubmitButton(); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-buyer/change-your-answers/change-your-answers-change-traded-with-buyer-no-to-yes-outstanding-yes.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-buyer/change-your-answers/change-your-answers-change-traded-with-buyer-no-to-yes-outstanding-yes.spec.js index 99e5828652..89a8c147f6 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-buyer/change-your-answers/change-your-answers-change-traded-with-buyer-no-to-yes-outstanding-yes.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-buyer/change-your-answers/change-your-answers-change-traded-with-buyer-no-to-yes-outstanding-yes.spec.js @@ -64,7 +64,7 @@ context( cy.completeAndSubmitTradedWithBuyerForm({ exporterHasTradedWithBuyer: true }); cy.completeAndSubmitTradingHistoryWithBuyerForm({ outstandingPayments: true }); - cy.completeAndSubmitAlternativeCurrencyForm({ clickAlternativeCurrencyLink: false }); + cy.completeAndSubmitAlternativeCurrencyForm({}); cy.completeAndSubmitOutstandingOrOverduePaymentsForm({}); cy.completeAndSubmitFailedToPayForm({ failedToPay: true }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-buyer/change-your-answers/change-your-answers-change-trading-history-outstanding-payments-no-to-yes.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-buyer/change-your-answers/change-your-answers-change-trading-history-outstanding-payments-no-to-yes.spec.js index 1c40457c66..82ace4a99d 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-buyer/change-your-answers/change-your-answers-change-trading-history-outstanding-payments-no-to-yes.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-buyer/change-your-answers/change-your-answers-change-trading-history-outstanding-payments-no-to-yes.spec.js @@ -75,7 +75,7 @@ context( summaryList.field(fieldId).changeLink().click(); cy.completeAndSubmitTradingHistoryWithBuyerForm({ outstandingPayments: true }); - cy.completeAndSubmitAlternativeCurrencyForm({ clickAlternativeCurrencyLink: false }); + cy.completeAndSubmitAlternativeCurrencyForm({}); cy.completeAndSubmitOutstandingOrOverduePaymentsForm({}); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges-change-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges-change-currency.spec.js index 148f007acb..9136ef0775 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges-change-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges-change-currency.spec.js @@ -13,8 +13,7 @@ const { const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip("Insurance - Export contract - Agent charges page - As an Exporter I want to change the currency of my agent's charges", () => { +context("Insurance - Export contract - Agent charges page - As an Exporter I want to change the currency of my agent's charges", () => { let referenceNumber; let url; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges-fixed-sum-amount-as-decimal.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges-fixed-sum-amount-as-decimal.spec.js index a61b6e7823..d9b66db40c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges-fixed-sum-amount-as-decimal.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges-fixed-sum-amount-as-decimal.spec.js @@ -12,8 +12,7 @@ const { const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip('Insurance - Export contract - Agent charges page - Fixed sum amount as decimal', () => { +context('Insurance - Export contract - Agent charges page - Fixed sum amount as decimal', () => { let referenceNumber; let url; let checkYourAnswersUrl; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges-fixed-sum-amount-with-comma.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges-fixed-sum-amount-with-comma.spec.js index 479832b1fc..59abbbe37e 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges-fixed-sum-amount-with-comma.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges-fixed-sum-amount-with-comma.spec.js @@ -12,8 +12,7 @@ const { const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip('Insurance - Export contract - Agent charges page - Fixed sum amount with a comma', () => { +context('Insurance - Export contract - Agent charges page - Fixed sum amount with a comma', () => { let referenceNumber; let url; let checkYourAnswersUrl; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges.spec.js index e56eb6e113..f1074d8fd4 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/agent-charges.spec.js @@ -124,12 +124,11 @@ context( cy.assertUrl(agentChargesCurrencyUrl); }); - // TODO: EMS-3828 - renable - // it('should retain the `export contract` task status as `in progress`', () => { - // cy.navigateToAllSectionsUrl(referenceNumber); + it('should retain the `export contract` task status as `in progress`', () => { + cy.navigateToAllSectionsUrl(referenceNumber); - // cy.checkTaskExportContractStatusIsInProgress(); - // }); + cy.checkTaskExportContractStatusIsInProgress(); + }); describe('when going back to the page', () => { beforeEach(() => { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/save-and-back.spec.js index 4a5952acf3..f5fb639cf5 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/save-and-back.spec.js @@ -60,8 +60,7 @@ context(`Insurance - Export contract - Agent charges - Save and go back - empty cy.assertAllSectionsUrl(referenceNumber); - // TODO: EMS-3828 - renable - // cy.checkTaskExportContractStatusIsInProgress(); + cy.checkTaskExportContractStatusIsInProgress(); }); describe('when going back to the page', () => { @@ -87,8 +86,7 @@ context(`Insurance - Export contract - Agent charges - Save and go back - empty cy.assertAllSectionsUrl(referenceNumber); - // TODO: EMS-3828 - renable - // cy.checkTaskExportContractStatusIsInProgress(); + cy.checkTaskExportContractStatusIsInProgress(); }); describe('when going back to the page', () => { @@ -117,8 +115,7 @@ context(`Insurance - Export contract - Agent charges - Save and go back - empty cy.assertAllSectionsUrl(referenceNumber); - // TODO: EMS-3828 - renable - // cy.checkTaskExportContractStatusIsInProgress(); + cy.checkTaskExportContractStatusIsInProgress(); }); describe('when going back to the page', () => { @@ -146,8 +143,7 @@ context(`Insurance - Export contract - Agent charges - Save and go back - empty cy.assertAllSectionsUrl(referenceNumber); - // TODO: EMS-3828 - renable - // cy.checkTaskExportContractStatusIsInProgress(); + cy.checkTaskExportContractStatusIsInProgress(); }); describe('when going back to the page', () => { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount-alternative-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount-alternative-currency.spec.js index d1f8d219ff..09719f2702 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount-alternative-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount-alternative-currency.spec.js @@ -18,8 +18,7 @@ const fieldId = PAYABLE_COUNTRY_CODE; const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip( +context( `Insurance - Export contract - Change your answers - Agent charges - ${FIXED_SUM_AMOUNT} - As an exporter, I want to change my answers to an alternative currency`, () => { let referenceNumber; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount.spec.js index 0fd66c2282..6d0e73c736 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-amount.spec.js @@ -17,8 +17,7 @@ const fieldId = FIXED_SUM_AMOUNT; const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip( +context( `Insurance - Export contract - Change your answers - Agent charges - ${FIXED_SUM_AMOUNT} - As an Exporter, I want to be able to review my input regarding the amount an agent is charging for helping me win my export contract, So that I can be assured I am providing UKEF with the right information`, () => { let referenceNumber; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-to-percentage.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-to-percentage.spec.js index 88cca953df..3d98bebcb2 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-to-percentage.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-fixed-sum-to-percentage.spec.js @@ -14,8 +14,7 @@ const { const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip( +context( 'Insurance - Export contract - Change your answers - Agent charges - Fixed sum to percentage - As an Exporter, I want to be able to review my input regarding the amount an agent is charging for helping me win my export contract, So that I can be assured I am providing UKEF with the right information', () => { let referenceNumber; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-payable-country.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-payable-country.spec.js index f2019a259f..6c62d29ee6 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-payable-country.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-payable-country.spec.js @@ -18,8 +18,7 @@ const fieldId = PAYABLE_COUNTRY_CODE; const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3852 - renable -context.skip( +context( `Insurance - Export contract - Change your answers - Agent charges - ${PAYABLE_COUNTRY_CODE} - As an Exporter, I want to be able to review my input regarding the amount an agent is charging for helping me win my export contract, So that I can be assured I am providing UKEF with the right information`, () => { let referenceNumber; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-percentage-to-fixed-sum.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-percentage-to-fixed-sum.spec.js index 7c70f7b57b..6c780f820d 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-percentage-to-fixed-sum.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-charges/change-your-answers-agent-charges-percentage-to-fixed-sum.spec.js @@ -14,8 +14,7 @@ const { const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip( +context( 'Insurance - Export contract - Change your answers - Agent charges - Percentage to Fixed sum - As an Exporter, I want to be able to review my input regarding the amount an agent is charging for helping me win my export contract, So that I can be assured I am providing UKEF with the right information', () => { let referenceNumber; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-no-to-yes.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-no-to-yes.spec.js index b6e3ddea75..b59a654fa6 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-no-to-yes.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-no-to-yes.spec.js @@ -72,10 +72,9 @@ context( const expectedUrl = `${agentChargesUrl}#${FIELD_ID}-label`; cy.assertUrl(expectedUrl); - // TODO: EMS-3828 - renable cy.completeAndSubmitAgentChargesForm({ - // fixedSumMethod: true, - percentageMethod: true, + fixedSumMethod: true, + percentageMethod: false, }); cy.assertChangeAnswersPageUrl({ referenceNumber, route: CHECK_YOUR_ANSWERS, fieldId: FIELD_ID }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-yes-to-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-yes-to-no.spec.js index ad32b3a184..cb9fcbba44 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-yes-to-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/agent-service/change-your-answers-agent-service-charging-yes-to-no.spec.js @@ -90,8 +90,7 @@ context( cy.assertRadioOptionIsNotChecked(agentChargesPage[METHOD][FIXED_SUM].input()); cy.assertRadioOptionIsNotChecked(agentChargesPage[METHOD][PERCENTAGE].input()); - // TODO: EMS-3828 - renable - // cy.checkValue(field(FIXED_SUM_AMOUNT), ''); + cy.checkValue(field(FIXED_SUM_AMOUNT), ''); cy.checkValue(field(PERCENTAGE_CHARGE), ''); cy.checkValue(autoCompleteField(PAYABLE_COUNTRY_CODE), ''); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum-decimal.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum-decimal.spec.js index 86d92e5b44..125cff9984 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum-decimal.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum-decimal.spec.js @@ -5,8 +5,7 @@ const { ROOT, EXPORT_CONTRACT } = INSURANCE_ROUTES; const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip( +context( 'Insurance - Export contract - Check your answers - Summary list - application over total contract value threshold, private insurance attempt, using an agent, agent is charging - fixed sum method with decimals', () => { let referenceNumber; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum.spec.js index f5ec0c84d4..8f7b3c3853 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list-fully-populated-with-agent-charges-fixed-sum.spec.js @@ -5,8 +5,7 @@ const { ROOT, EXPORT_CONTRACT } = INSURANCE_ROUTES; const baseUrl = Cypress.config('baseUrl'); -// TODO: EMS-3828 - renable -context.skip( +context( 'Insurance - Export contract - Check your answers - Summary list - application over total contract value threshold, private insurance attempt, using an agent, agent is charging - fixed sum method', () => { let referenceNumber; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/currency-of-agent-charges/currency-of-agent-charges.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/currency-of-agent-charges/currency-of-agent-charges.spec.js index cfc5a6bb5a..71096192ca 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/currency-of-agent-charges/currency-of-agent-charges.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/currency-of-agent-charges/currency-of-agent-charges.spec.js @@ -9,7 +9,7 @@ const CONTENT_STRINGS = PAGES.INSURANCE.EXPORT_CONTRACT.AGENT_CHARGES_CURRENCY; const { ROOT, - EXPORT_CONTRACT: { AGENT_CHARGES, AGENT_CHARGES_CURRENCY, HOW_MUCH_IS_THE_AGENT_CHARGING }, + EXPORT_CONTRACT: { AGENT_CHARGES, AGENT_CHARGES_CURRENCY, HOW_MUCH_THE_AGENT_IS_CHARGING }, } = INSURANCE_ROUTES; const { @@ -39,7 +39,7 @@ context( cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentCharges', isUsingAgent: true, agentIsCharging: true, fixedSumMethod: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES_CURRENCY}`; - howMuchAgentIsChargingUrl = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_IS_THE_AGENT_CHARGING}`; + howMuchAgentIsChargingUrl = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`; }); }); @@ -90,7 +90,7 @@ context( }); describe('form submission', () => { - it(`should redirect to ${HOW_MUCH_IS_THE_AGENT_CHARGING}`, () => { + it(`should redirect to ${HOW_MUCH_THE_AGENT_IS_CHARGING}`, () => { cy.completeAndSubmitAlternativeCurrencyForm({}); cy.assertUrl(howMuchAgentIsChargingUrl); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-is-the-agent-charging/how-much-is-the-agent-charging.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-the-agent-is-charging/how-much-the-agent-is-charging.spec.js similarity index 76% rename from e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-is-the-agent-charging/how-much-is-the-agent-charging.spec.js rename to e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-the-agent-is-charging/how-much-the-agent-is-charging.spec.js index 6ed8ffb74f..0d0066bc56 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-is-the-agent-charging/how-much-is-the-agent-charging.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-the-agent-is-charging/how-much-the-agent-is-charging.spec.js @@ -4,12 +4,13 @@ import { EXPORT_CONTRACT_FIELDS as FIELD_STRINGS } from '../../../../../../conte import FIELD_IDS from '../../../../../../constants/field-ids/insurance/export-contract'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; import { GBP, SYMBOLS } from '../../../../../../fixtures/currencies'; +import application from '../../../../../../fixtures/application'; -const CONTENT_STRINGS = PAGES.INSURANCE.EXPORT_CONTRACT.HOW_MUCH_IS_THE_AGENT_CHARGING; +const CONTENT_STRINGS = PAGES.INSURANCE.EXPORT_CONTRACT.HOW_MUCH_THE_AGENT_IS_CHARGING; const { ROOT, - EXPORT_CONTRACT: { AGENT_CHARGES_CURRENCY, HOW_MUCH_IS_THE_AGENT_CHARGING, CHECK_YOUR_ANSWERS }, + EXPORT_CONTRACT: { AGENT_CHARGES_CURRENCY, HOW_MUCH_THE_AGENT_IS_CHARGING, CHECK_YOUR_ANSWERS }, } = INSURANCE_ROUTES; const { @@ -19,7 +20,7 @@ const { 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", + "Insurance - Export contract - How much the agent is 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; @@ -32,7 +33,7 @@ context( // go to the page we want to test. cy.completeAndSubmitExportContractForms({ formToStopAt: 'currencyOfAgentCharges', isUsingAgent: true, agentIsCharging: true, fixedSumMethod: true }); - url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_IS_THE_AGENT_CHARGING}`; + url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`; checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); }); @@ -48,7 +49,7 @@ context( it('renders core page elements', () => { cy.corePageChecks({ pageTitle: `${CONTENT_STRINGS.PAGE_TITLE} ${GBP.name}?`, - currentHref: `${ROOT}/${referenceNumber}${HOW_MUCH_IS_THE_AGENT_CHARGING}`, + currentHref: `${ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`, backLink: `${ROOT}/${referenceNumber}${AGENT_CHARGES_CURRENCY}`, }); }); @@ -81,10 +82,20 @@ context( it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { cy.navigateToUrl(url); - cy.completeAndSubmitHowMuchIsTheAgentChargingForm({}); + cy.completeAndSubmitHowMuchTheAgentIsChargingForm({}); cy.assertUrl(checkYourAnswersUrl); }); + + describe('when going back to the page', () => { + beforeEach(() => { + cy.navigateToUrl(url); + }); + + it('should have the submitted value', () => { + cy.checkValue(fieldSelector(FIELD_ID), application.EXPORT_CONTRACT.AGENT_CHARGES[FIELD_ID]); + }); + }); }); }, ); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-the-agent-is-charging/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-the-agent-is-charging/save-and-back.spec.js new file mode 100644 index 0000000000..cf62869935 --- /dev/null +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-the-agent-is-charging/save-and-back.spec.js @@ -0,0 +1,167 @@ +import { field } from '../../../../../../pages/shared'; +import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; +import FIELD_IDS from '../../../../../../constants/field-ids/insurance/export-contract'; + +const { + ROOT, + EXPORT_CONTRACT: { HOW_MUCH_THE_AGENT_IS_CHARGING }, +} = INSURANCE_ROUTES; + +const { + AGENT_CHARGES: { FIXED_SUM_AMOUNT: FIELD_ID }, +} = FIELD_IDS; + +const baseUrl = Cypress.config('baseUrl'); + +context('Insurance - Export contract - How much the agent is charging - Save and go back', () => { + let referenceNumber; + let url; + + before(() => { + cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { + referenceNumber = refNumber; + + // go to the page we want to test. + cy.completeAndSubmitExportContractForms({ + formToStopAt: 'currencyOfAgentCharges', + isUsingAgent: true, + agentIsCharging: true, + fixedSumMethod: true, + }); + + url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`; + + cy.assertUrl(url); + }); + }); + + beforeEach(() => { + cy.saveSession(); + }); + + after(() => { + cy.deleteApplication(referenceNumber); + }); + + describe('when submitting an empty form via `save and go back` button', () => { + beforeEach(() => { + cy.navigateToUrl(url); + + cy.completeHowMuchTheAgentIsChargingForm({}); + + cy.clickSaveAndBackButton(); + }); + + it('should redirect to `all sections`', () => { + cy.assertAllSectionsUrl(referenceNumber); + }); + + it('should retain the status of task `export contract` as ` in progress`', () => { + cy.navigateToUrl(url); + + cy.completeHowMuchTheAgentIsChargingForm({}); + + cy.clickSaveAndBackButton(); + + // TODO: EMS-3828 - renable + // cy.checkTaskExportContractStatusIsInProgress(); + }); + }); + + describe(`when submitting ${FIELD_ID} as a pure number`, () => { + const fixedSumAmount = '1000'; + + beforeEach(() => { + cy.navigateToUrl(url); + + cy.completeHowMuchTheAgentIsChargingForm({ fixedSumAmount }); + + cy.clickSaveAndBackButton(); + }); + + it('should redirect to `all sections`', () => { + cy.assertAllSectionsUrl(referenceNumber); + }); + + it('should update the `export contract` task status to `completed`', () => { + cy.navigateToAllSectionsUrl(referenceNumber); + + cy.checkTaskExportContractStatusIsComplete(); + }); + + describe('when going back to the page', () => { + beforeEach(() => { + cy.navigateToUrl(url); + }); + + it('should have the submitted value', () => { + cy.checkValue(field(FIELD_ID), fixedSumAmount); + }); + }); + }); + + describe(`when submitting ${FIELD_ID} with a comma`, () => { + const fixedSumAmount = '1,000'; + const amount = '1000'; + + beforeEach(() => { + cy.navigateToUrl(url); + + cy.completeHowMuchTheAgentIsChargingForm({ fixedSumAmount }); + + cy.clickSaveAndBackButton(); + }); + + it('should redirect to `all sections`', () => { + cy.assertAllSectionsUrl(referenceNumber); + }); + + it('should update the `export contract` task status to `completed`', () => { + cy.navigateToAllSectionsUrl(referenceNumber); + + cy.checkTaskExportContractStatusIsComplete(); + }); + + describe('when going back to the page', () => { + beforeEach(() => { + cy.navigateToUrl(url); + }); + + it('should have the submitted value without the comma', () => { + cy.checkValue(field(FIELD_ID), amount); + }); + }); + }); + + describe(`when submitting ${FIELD_ID} as a decimal number`, () => { + const fixedSumAmount = '100.54'; + + beforeEach(() => { + cy.navigateToUrl(url); + + cy.completeHowMuchTheAgentIsChargingForm({ fixedSumAmount }); + + cy.clickSaveAndBackButton(); + }); + + it('should redirect to `all sections`', () => { + cy.assertAllSectionsUrl(referenceNumber); + }); + + it('should update the `export contract` task status to `completed`', () => { + cy.navigateToAllSectionsUrl(referenceNumber); + + cy.checkTaskExportContractStatusIsComplete(); + }); + + describe('when going back to the page', () => { + beforeEach(() => { + cy.navigateToUrl(url); + }); + + it('should have the submitted value', () => { + cy.checkValue(field(FIELD_ID), fixedSumAmount); + }); + }); + }); +}); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-is-the-agent-charging/validation/how-much-is-the-agent-charging-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-the-agent-is-charging/validation/how-much-the-agent-is-charging-validation.spec.js similarity index 92% rename from e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-is-the-agent-charging/validation/how-much-is-the-agent-charging-validation.spec.js rename to e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-the-agent-is-charging/validation/how-much-the-agent-is-charging-validation.spec.js index 22cb81d954..9e6f88ae4a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-is-the-agent-charging/validation/how-much-is-the-agent-charging-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-the-agent-is-charging/validation/how-much-the-agent-is-charging-validation.spec.js @@ -6,7 +6,7 @@ import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insuranc const { ROOT, - EXPORT_CONTRACT: { HOW_MUCH_IS_THE_AGENT_CHARGING }, + EXPORT_CONTRACT: { HOW_MUCH_THE_AGENT_IS_CHARGING }, } = INSURANCE_ROUTES; const { @@ -29,7 +29,7 @@ const assertions = { const baseUrl = Cypress.config('baseUrl'); -context('Insurance - Export contract - How much is the agent charging page - form validation', () => { +context('Insurance - Export contract - How much the agent is charging page - form validation', () => { let referenceNumber; let url; @@ -37,7 +37,7 @@ context('Insurance - Export contract - How much is the agent charging page - for cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_IS_THE_AGENT_CHARGING}`; + url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`; }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-turnover.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-turnover.spec.js index 21d29e7a74..be6385c5a2 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-turnover.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-turnover.spec.js @@ -97,7 +97,7 @@ context('Insurance - Your business - Change your answers - Turnover - As an expo summaryList.field(fieldId).changeLink().click(); - cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: true, clickAlternativeCurrencyLink: false }); + cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: true }); }); it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover-currency/turnover-change-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover-currency/turnover-change-currency.spec.js index 4f352947f0..b70ac6da6b 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover-currency/turnover-change-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover-currency/turnover-change-currency.spec.js @@ -42,7 +42,7 @@ context('Insurance - Your business - Turnover currency page - As an Exporter I w }); describe('prefixes should be displayed based on the chosen currency', () => { - const { prefixAssertions } = assertCurrencyFormFields({ fieldId: ESTIMATED_ANNUAL_TURNOVER, clickAlternativeCurrencyLink: false }); + const { prefixAssertions } = assertCurrencyFormFields({ fieldId: ESTIMATED_ANNUAL_TURNOVER }); prefixAssertions(); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-alternative-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-alternative-currency.spec.js index 17c6c26d3a..76c2c55de8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-alternative-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-alternative-currency.spec.js @@ -60,7 +60,7 @@ context('Insurance - Your buyer - Change your answers - Alternative currency - A summaryList.field(currencyFieldId).changeLink().click(); - cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: EUR_CURRENCY_CODE, clickAlternativeCurrencyLink: false }); + cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: EUR_CURRENCY_CODE }); cy.clickSubmitButton(); }); @@ -109,7 +109,7 @@ context('Insurance - Your buyer - Change your answers - Alternative currency - A summaryList.field(currencyFieldId).changeLink().click(); - cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: true, clickAlternativeCurrencyLink: false }); + cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: true }); cy.clickSubmitButton(); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-traded-with-buyer-no-to-yes-outstanding-yes.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-traded-with-buyer-no-to-yes-outstanding-yes.spec.js index 9618f7e82b..bf531bd979 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-traded-with-buyer-no-to-yes-outstanding-yes.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-traded-with-buyer-no-to-yes-outstanding-yes.spec.js @@ -56,7 +56,7 @@ context( cy.completeAndSubmitTradedWithBuyerForm({ exporterHasTradedWithBuyer: true }); cy.completeAndSubmitTradingHistoryWithBuyerForm({ outstandingPayments: true }); - cy.completeAndSubmitAlternativeCurrencyForm({ clickAlternativeCurrencyLink: false }); + cy.completeAndSubmitAlternativeCurrencyForm({}); cy.completeAndSubmitOutstandingOrOverduePaymentsForm({}); cy.completeAndSubmitFailedToPayForm({ failedToPay: true }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-trading-history-outstanding-payments-no-to-yes.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-trading-history-outstanding-payments-no-to-yes.spec.js index 6628f5a20d..057b245f04 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-trading-history-outstanding-payments-no-to-yes.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-trading-history-outstanding-payments-no-to-yes.spec.js @@ -62,7 +62,7 @@ context( summaryList.field(fieldId).changeLink().click(); cy.completeAndSubmitTradingHistoryWithBuyerForm({ outstandingPayments: true }); - cy.completeAndSubmitAlternativeCurrencyForm({ clickAlternativeCurrencyLink: false }); + cy.completeAndSubmitAlternativeCurrencyForm({}); cy.completeAndSubmitOutstandingOrOverduePaymentsForm({}); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/currency-of-late-payments/currency-of-late-payments-change-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/currency-of-late-payments/currency-of-late-payments-change-currency.spec.js index 217df6821f..d29bd1b10f 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/currency-of-late-payments/currency-of-late-payments-change-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/currency-of-late-payments/currency-of-late-payments-change-currency.spec.js @@ -39,7 +39,7 @@ context('Insurance - Your business - Turnover currency page - As an Exporter I w }); describe(`prefixes should be displayed based on the chosen currency for ${TOTAL_OUTSTANDING_PAYMENTS}`, () => { - const { prefixAssertions } = assertCurrencyFormFields({ fieldId: TOTAL_OUTSTANDING_PAYMENTS, clickAlternativeCurrencyLink: false }); + const { prefixAssertions } = assertCurrencyFormFields({ fieldId: TOTAL_OUTSTANDING_PAYMENTS }); prefixAssertions(); }); @@ -49,10 +49,10 @@ context('Insurance - Your business - Turnover currency page - As an Exporter I w cy.saveSession(); cy.navigateToUrl(url); // change to GBP - cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: GBP_CURRENCY_CODE, clickAlternativeCurrencyLink: false }); + cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: GBP_CURRENCY_CODE }); }); - const { prefixAssertions } = assertCurrencyFormFields({ fieldId: TOTAL_AMOUNT_OVERDUE, clickAlternativeCurrencyLink: false }); + const { prefixAssertions } = assertCurrencyFormFields({ fieldId: TOTAL_AMOUNT_OVERDUE }); prefixAssertions(); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/outstanding-or-overdue-payments-alternative-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/outstanding-or-overdue-payments-alternative-currency.spec.js index 78b21ac17d..18691cbbe8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/outstanding-or-overdue-payments-alternative-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/outstanding-or-overdue-payments-alternative-currency.spec.js @@ -30,7 +30,6 @@ context('Insurance - Your buyer - Outstanding or overdue payments - Alternative outstandingPayments: true, exporterHasTradedWithBuyer: true, alternativeCurrency: true, - clickAlternativeCurrencyLink: false, }); cy.assertUrl(url); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/outstanding-or-overdue-payments-non-gbp-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/outstanding-or-overdue-payments-non-gbp-currency.spec.js index 3fb6445147..9375042968 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/outstanding-or-overdue-payments-non-gbp-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/outstanding-or-overdue-payments-non-gbp-currency.spec.js @@ -30,7 +30,6 @@ context('Insurance - Your buyer - Outstanding or overdue payments - Non-GBP (sup outstandingPayments: true, exporterHasTradedWithBuyer: true, isoCode: USD.isoCode, - clickAlternativeCurrencyLink: false, }); cy.assertUrl(url); diff --git a/e2e-tests/insurance/cypress/support/application/export-contract/index.js b/e2e-tests/insurance/cypress/support/application/export-contract/index.js index 61667ab82b..54cebfd54d 100644 --- a/e2e-tests/insurance/cypress/support/application/export-contract/index.js +++ b/e2e-tests/insurance/cypress/support/application/export-contract/index.js @@ -26,9 +26,11 @@ Cypress.Commands.add('completeAndSubmitAgentServiceForm', require('../../../../. Cypress.Commands.add('completeAgentChargesForm', require('../../../../../commands/insurance/complete-agent-charges-form')); Cypress.Commands.add('completeAndSubmitAgentChargesForm', require('../../../../../commands/insurance/complete-and-submit-agent-charges-form')); +Cypress.Commands.add('completeHowMuchTheAgentIsChargingForm', require('../../../../../commands/insurance/complete-how-much-the-agent-is-charging-form')); + Cypress.Commands.add( - 'completeAndSubmitHowMuchIsTheAgentChargingForm', - require('../../../../../commands/insurance/complete-and-submit-how-much-is-the-agent-charging-form'), + 'completeAndSubmitHowMuchTheAgentIsChargingForm', + require('../../../../../commands/insurance/complete-and-submit-how-much-the-agent-is-charging-form'), ); Cypress.Commands.add( diff --git a/e2e-tests/partials/index.js b/e2e-tests/partials/index.js index 4e5fb4650a..bb329dd433 100644 --- a/e2e-tests/partials/index.js +++ b/e2e-tests/partials/index.js @@ -24,7 +24,6 @@ const partials = { html: (id) => cy.get(`[data-cy="${id}-html"]`), pagination, phaseBanner, - provideAlternativeCurrencyLink: () => cy.get('[data-cy="provide-alternative-currency-link"]'), privateMarketWhyDescription, skipLink: () => cy.get('[data-cy="skip-link"]'), startNewApplicationButton: () => cy.get('[data-cy="start-new-application-button"]'), diff --git a/e2e-tests/shared-test-assertions/currency-form-fields/assertions.js b/e2e-tests/shared-test-assertions/currency-form-fields/assertions.js index 754b07c232..174d010ba6 100644 --- a/e2e-tests/shared-test-assertions/currency-form-fields/assertions.js +++ b/e2e-tests/shared-test-assertions/currency-form-fields/assertions.js @@ -160,10 +160,11 @@ const assertCurrencyFormFields = ({ cy.assertRadioOptionIsChecked(option.input()); }, - submitAlternativeCurrencyAndAssertUrl: (url) => { + submitAlternativeCurrencyAndAssertUrl: ({ url, viaSaveAndBack }) => { cy.clickAlternativeCurrencyRadioAndSubmitCurrency({ fieldId: alternativeCurrencyFieldId, currency: NON_STANDARD_CURRENCY_NAME, + viaSaveAndBack, }); cy.url().should('include', url); diff --git a/e2e-tests/shared-test-assertions/currency-form-fields/form-submission/index.js b/e2e-tests/shared-test-assertions/currency-form-fields/form-submission/index.js index f60644de83..0393237aef 100644 --- a/e2e-tests/shared-test-assertions/currency-form-fields/form-submission/index.js +++ b/e2e-tests/shared-test-assertions/currency-form-fields/form-submission/index.js @@ -35,9 +35,9 @@ const formSubmissionAssertions = ({ submitASupportedCurrency({ completeNonCurrencyFieldsFunction, + expectedRedirectUrl, submitRadioAndAssertUrl, submitAndAssertRadioIsChecked, - expectedRedirectUrl, }); submitAlternativeCurrency({ @@ -50,9 +50,9 @@ const formSubmissionAssertions = ({ describe('via `save and back` button', () => { submitASupportedCurrency({ completeNonCurrencyFieldsFunction, + expectedRedirectUrl: ALL_SECTIONS, submitRadioAndAssertUrl, submitAndAssertRadioIsChecked, - expectedRedirectUrl: ALL_SECTIONS, viaSaveAndBack: true, }); diff --git a/e2e-tests/shared-test-assertions/currency-form-fields/form-submission/submit-alternative-currency.js b/e2e-tests/shared-test-assertions/currency-form-fields/form-submission/submit-alternative-currency.js index c5cdb72e18..7e1fdee158 100644 --- a/e2e-tests/shared-test-assertions/currency-form-fields/form-submission/submit-alternative-currency.js +++ b/e2e-tests/shared-test-assertions/currency-form-fields/form-submission/submit-alternative-currency.js @@ -10,7 +10,7 @@ const submitAlternativeCurrency = ({ expectedRedirectUrl, submitAlternativeCurrencyAndAssertUrl, submitAlternativeCurrencyAndAssertInput, viaSaveAndBack }) => { describe('when submitting an alternative currency', () => { it('should redirect to the next page', () => { - submitAlternativeCurrencyAndAssertUrl(expectedRedirectUrl); + submitAlternativeCurrencyAndAssertUrl({ url: expectedRedirectUrl, viaSaveAndBack }); }); it('should render the submitted answer when going back to the page', () => { diff --git a/e2e-tests/shared-test-assertions/currency-form-fields/index.js b/e2e-tests/shared-test-assertions/currency-form-fields/index.js index 0392b7c03a..324e2937b8 100644 --- a/e2e-tests/shared-test-assertions/currency-form-fields/index.js +++ b/e2e-tests/shared-test-assertions/currency-form-fields/index.js @@ -25,7 +25,6 @@ const { */ export const assertCurrencyFormFields = ({ completeNonCurrencyFieldsFunction, - clickAlternativeCurrencyLink, errorIndex, errors, fieldId, @@ -51,7 +50,7 @@ export const assertCurrencyFormFields = ({ errorIndex, expectedRedirectUrl, }), - prefixAssertions: () => prefixAssertions({ fieldId, clickAlternativeCurrencyLink }), + prefixAssertions: () => prefixAssertions({ fieldId }), }; }; diff --git a/e2e-tests/shared-test-assertions/currency-form-fields/prefix.js b/e2e-tests/shared-test-assertions/currency-form-fields/prefix.js index 729fcef4ac..073e36bf70 100644 --- a/e2e-tests/shared-test-assertions/currency-form-fields/prefix.js +++ b/e2e-tests/shared-test-assertions/currency-form-fields/prefix.js @@ -6,40 +6,39 @@ import { SYMBOLS, USD_CURRENCY_CODE, JPY_CURRENCY_CODE, EUR_CURRENCY_CODE } from * @param {String} fieldId: Field ID of input for prefix assertion * @returns {Function} Mocha describe block with assertions. */ -const prefixAssertions = ({ fieldId, clickAlternativeCurrencyLink }) => { +const prefixAssertions = ({ fieldId }) => { describe('when not selecting a currency', () => { it(`should display ${SYMBOLS.GBP} as the prefix`, () => { - if (!clickAlternativeCurrencyLink) { - cy.clickSubmitButton(); - } + cy.clickSubmitButton(); + cy.assertPrefix({ fieldId, value: SYMBOLS.GBP }); }); }); describe(`when selecting ${USD_CURRENCY_CODE} as the currency code`, () => { it(`should display ${SYMBOLS.USD} as the prefix`, () => { - cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: USD_CURRENCY_CODE, clickAlternativeCurrencyLink }); + cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: USD_CURRENCY_CODE }); cy.assertPrefix({ fieldId, value: SYMBOLS.USD }); }); }); describe(`when selecting ${JPY_CURRENCY_CODE} as the currency code`, () => { it(`should display ${SYMBOLS.JPY} as the prefix`, () => { - cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: JPY_CURRENCY_CODE, clickAlternativeCurrencyLink }); + cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: JPY_CURRENCY_CODE }); cy.assertPrefix({ fieldId, value: SYMBOLS.JPY }); }); }); describe(`when selecting ${EUR_CURRENCY_CODE} as the currency code`, () => { it(`should display ${SYMBOLS.EUR} as the prefix`, () => { - cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: EUR_CURRENCY_CODE, clickAlternativeCurrencyLink }); + cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: EUR_CURRENCY_CODE }); cy.assertPrefix({ fieldId, value: SYMBOLS.EUR }); }); }); describe('when selecting an alternate currency as the currency code', () => { it('should not display a prefix', () => { - cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: true, clickAlternativeCurrencyLink }); + cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: true }); cy.assertPrefix({ fieldId }); }); }); diff --git a/src/ui/server/constants/routes/insurance/export-contract.ts b/src/ui/server/constants/routes/insurance/export-contract.ts index de8d74f680..a0a38d573d 100644 --- a/src/ui/server/constants/routes/insurance/export-contract.ts +++ b/src/ui/server/constants/routes/insurance/export-contract.ts @@ -9,7 +9,7 @@ const AGENT_DETAILS_ROOT = `${ROOT}/agent-details`; const AGENT_SERVICE_ROOT = `${ROOT}/agent-service`; const AGENT_CHARGES_ROOT = `${ROOT}/agent-charges`; const AGENT_CHARGES_CURRENCY_ROOT = `${ROOT}/currency-of-agents-charge`; -const HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT = `${ROOT}/how-much-is-the-agent-charging`; +const HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT = `${ROOT}/how-much-the-agent-is-charging`; export const EXPORT_CONTRACT = { ROOT, @@ -53,9 +53,9 @@ export const EXPORT_CONTRACT = { AGENT_CHARGES_CURRENCY: AGENT_CHARGES_CURRENCY_ROOT, AGENT_CHARGES_CURRENCY_CHANGE: `${AGENT_CHARGES_CURRENCY_ROOT}/change`, AGENT_CHARGES_CURRENCY_CHECK_AND_CHANGE: `${AGENT_CHARGES_CURRENCY_ROOT}/check-and-change`, - HOW_MUCH_IS_THE_AGENT_CHARGING_SAVE_AND_BACK: `${HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT}/save-and-go-back`, - HOW_MUCH_IS_THE_AGENT_CHARGING: HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT, - HOW_MUCH_IS_THE_AGENT_CHARGING_CHANGE: `${HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT}/change`, - HOW_MUCH_IS_THE_AGENT_CHARGING_CHECK_AND_CHANGE: `${HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT}/check-and-change`, + HOW_MUCH_THE_AGENT_IS_CHARGING_SAVE_AND_BACK: `${HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT}/save-and-go-back`, + HOW_MUCH_THE_AGENT_IS_CHARGING: HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT, + HOW_MUCH_THE_AGENT_IS_CHARGING_CHANGE: `${HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT}/change`, + HOW_MUCH_THE_AGENT_IS_CHARGING_CHECK_AND_CHANGE: `${HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT}/check-and-change`, CHECK_YOUR_ANSWERS: `${ROOT}/check-your-answers`, }; diff --git a/src/ui/server/constants/templates/insurance/export-contract/index.ts b/src/ui/server/constants/templates/insurance/export-contract/index.ts index 1b160289c1..48900d0c78 100644 --- a/src/ui/server/constants/templates/insurance/export-contract/index.ts +++ b/src/ui/server/constants/templates/insurance/export-contract/index.ts @@ -6,6 +6,6 @@ export const EXPORT_CONTRACT_TEMPLATES = { AGENT_DETAILS: 'insurance/export-contract/agent-details.njk', AGENT_SERVICE: 'insurance/export-contract/agent-service.njk', AGENT_CHARGES: 'insurance/export-contract/agent-charges.njk', - HOW_MUCH_IS_THE_AGENT_CHARGING: 'insurance/export-contract/how-much-is-the-agent-charging.njk', + HOW_MUCH_THE_AGENT_IS_CHARGING: 'insurance/export-contract/how-much-the-agent-is-charging.njk', CHECK_YOUR_ANSWERS: 'insurance/export-contract/check-your-answers.njk', }; diff --git a/src/ui/server/constants/templates/shared-pages.ts b/src/ui/server/constants/templates/shared-pages.ts index 9d58a2745f..7afb508134 100644 --- a/src/ui/server/constants/templates/shared-pages.ts +++ b/src/ui/server/constants/templates/shared-pages.ts @@ -3,5 +3,5 @@ export const SHARED_PAGES = { NEED_TO_START_AGAIN_EXIT: 'shared-pages/need-to-start-again.njk', SECTION_START: 'shared-pages/section-start.njk', SINGLE_RADIO: 'shared-pages/single-radio.njk', - ALTERNATIVE_CURRENCY: 'shared-pages/alternative-currency.njk', + CURRENCY: 'shared-pages/currency.njk', }; diff --git a/src/ui/server/content-strings/pages/insurance/export-contract/index.ts b/src/ui/server/content-strings/pages/insurance/export-contract/index.ts index 3fbff5641e..4548bb2841 100644 --- a/src/ui/server/content-strings/pages/insurance/export-contract/index.ts +++ b/src/ui/server/content-strings/pages/insurance/export-contract/index.ts @@ -66,7 +66,7 @@ const AGENT_CHARGES_CURRENCY = { PAGE_TITLE: 'What currency is the agent charging you in?', }; -const HOW_MUCH_IS_THE_AGENT_CHARGING = { +const HOW_MUCH_THE_AGENT_IS_CHARGING = { ...SHARED, PAGE_TITLE: 'How much is the agent charging in', }; @@ -88,6 +88,6 @@ export default { AGENT_SERVICE, AGENT_CHARGES, AGENT_CHARGES_CURRENCY, - HOW_MUCH_IS_THE_AGENT_CHARGING, + HOW_MUCH_THE_AGENT_IS_CHARGING, CHECK_YOUR_ANSWERS, }; diff --git a/src/ui/server/controllers/insurance/business/turnover-currency/index.test.ts b/src/ui/server/controllers/insurance/business/turnover-currency/index.test.ts index e2c67d46c4..e3fc0f76bf 100644 --- a/src/ui/server/controllers/insurance/business/turnover-currency/index.test.ts +++ b/src/ui/server/controllers/insurance/business/turnover-currency/index.test.ts @@ -86,7 +86,7 @@ describe('controllers/insurance/business/turnover-currency', () => { describe('TEMPLATE', () => { it('should have the correct template defined', () => { - expect(TEMPLATE).toEqual(TEMPLATES.SHARED_PAGES.ALTERNATIVE_CURRENCY); + expect(TEMPLATE).toEqual(TEMPLATES.SHARED_PAGES.CURRENCY); }); }); diff --git a/src/ui/server/controllers/insurance/business/turnover-currency/index.ts b/src/ui/server/controllers/insurance/business/turnover-currency/index.ts index ea83fe096e..b07b7ddfc2 100644 --- a/src/ui/server/controllers/insurance/business/turnover-currency/index.ts +++ b/src/ui/server/controllers/insurance/business/turnover-currency/index.ts @@ -31,7 +31,7 @@ const { export const FIELD_IDS = [CURRENCY_CODE, ALTERNATIVE_CURRENCY_CODE]; -export const TEMPLATE = TEMPLATES.SHARED_PAGES.ALTERNATIVE_CURRENCY; +export const TEMPLATE = TEMPLATES.SHARED_PAGES.CURRENCY; export const PAGE_CONTENT_STRINGS = PAGES.INSURANCE.EXPORTER_BUSINESS.TURNOVER_CURRENCY; diff --git a/src/ui/server/controllers/insurance/export-contract/currency-of-agents-charge/index.test.ts b/src/ui/server/controllers/insurance/export-contract/currency-of-agents-charge/index.test.ts index 46efeb9277..eecc64599d 100644 --- a/src/ui/server/controllers/insurance/export-contract/currency-of-agents-charge/index.test.ts +++ b/src/ui/server/controllers/insurance/export-contract/currency-of-agents-charge/index.test.ts @@ -26,7 +26,7 @@ import { const { INSURANCE_ROOT, PROBLEM_WITH_SERVICE, - EXPORT_CONTRACT: { AGENT_CHARGES_CURRENCY_SAVE_AND_BACK, HOW_MUCH_IS_THE_AGENT_CHARGING }, + EXPORT_CONTRACT: { AGENT_CHARGES_CURRENCY_SAVE_AND_BACK, HOW_MUCH_THE_AGENT_IS_CHARGING }, } = INSURANCE_ROUTES; const { @@ -82,7 +82,7 @@ describe('controllers/insurance/export-contract/currency-of-agents-charge', () = describe('TEMPLATE', () => { it('should have the correct template defined', () => { - expect(TEMPLATE).toEqual(TEMPLATES.SHARED_PAGES.ALTERNATIVE_CURRENCY); + expect(TEMPLATE).toEqual(TEMPLATES.SHARED_PAGES.CURRENCY); }); }); @@ -257,10 +257,10 @@ describe('controllers/insurance/export-contract/currency-of-agents-charge', () = expect(mapAndSave.exportContractAgentServiceCharge).toHaveBeenCalledWith(payload, res.locals.application); }); - it(`should redirect to ${HOW_MUCH_IS_THE_AGENT_CHARGING}`, async () => { + it(`should redirect to ${HOW_MUCH_THE_AGENT_IS_CHARGING}`, async () => { await post(req, res); - const expected = `${INSURANCE_ROOT}/${referenceNumber}${HOW_MUCH_IS_THE_AGENT_CHARGING}`; + const expected = `${INSURANCE_ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`; expect(res.redirect).toHaveBeenCalledWith(expected); }); diff --git a/src/ui/server/controllers/insurance/export-contract/currency-of-agents-charge/index.ts b/src/ui/server/controllers/insurance/export-contract/currency-of-agents-charge/index.ts index 64be942ce7..5672ecfa56 100644 --- a/src/ui/server/controllers/insurance/export-contract/currency-of-agents-charge/index.ts +++ b/src/ui/server/controllers/insurance/export-contract/currency-of-agents-charge/index.ts @@ -16,7 +16,7 @@ import { Request, Response } from '../../../../../types'; const { INSURANCE_ROOT, PROBLEM_WITH_SERVICE, - EXPORT_CONTRACT: { HOW_MUCH_IS_THE_AGENT_CHARGING, AGENT_CHARGES_CURRENCY_SAVE_AND_BACK }, + EXPORT_CONTRACT: { HOW_MUCH_THE_AGENT_IS_CHARGING, AGENT_CHARGES_CURRENCY_SAVE_AND_BACK }, } = INSURANCE_ROUTES; const { @@ -28,7 +28,7 @@ const { export const FIELD_IDS = [CURRENCY_CODE, ALTERNATIVE_CURRENCY_CODE]; -export const TEMPLATE = TEMPLATES.SHARED_PAGES.ALTERNATIVE_CURRENCY; +export const TEMPLATE = TEMPLATES.SHARED_PAGES.CURRENCY; export const PAGE_CONTENT_STRINGS = PAGES.INSURANCE.EXPORT_CONTRACT.AGENT_CHARGES_CURRENCY; @@ -147,7 +147,7 @@ export const post = async (req: Request, res: Response) => { return res.redirect(PROBLEM_WITH_SERVICE); } - return res.redirect(`${INSURANCE_ROOT}/${referenceNumber}${HOW_MUCH_IS_THE_AGENT_CHARGING}`); + return res.redirect(`${INSURANCE_ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`); } catch (error) { console.error('Error updating application - export contract - currency of agents charge %O', error); diff --git a/src/ui/server/controllers/insurance/export-contract/currency-of-agents-charge/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/export-contract/currency-of-agents-charge/save-and-back/index.test.ts index 37057f3ccc..6dc43b30a7 100644 --- a/src/ui/server/controllers/insurance/export-contract/currency-of-agents-charge/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/export-contract/currency-of-agents-charge/save-and-back/index.test.ts @@ -6,7 +6,7 @@ import constructPayload from '../../../../../helpers/construct-payload'; import mapAndSave from '../../map-and-save/export-contract-agent-service-charge'; import generateValidationErrors from '../validation'; import { Request, Response } from '../../../../../../types'; -import { mockCurrencies, mockReq, mockRes, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; +import { EUR, mockReq, mockRes, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = INSURANCE_ROUTES; @@ -24,7 +24,7 @@ describe('controllers/insurance/export-contract/currency-of-agents-charge/save-a const mockFormBody = { _csrf: '1234', - [CURRENCY_CODE]: mockCurrencies[0].isoCode, + [CURRENCY_CODE]: EUR.isoCode, }; beforeEach(() => { diff --git a/src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/index.test.ts b/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/index.test.ts similarity index 80% rename from src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/index.test.ts rename to src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/index.test.ts index d30a51acde..a21ef655cc 100644 --- a/src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/index.test.ts +++ b/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/index.test.ts @@ -4,20 +4,22 @@ import { INSURANCE_ROUTES } from '../../../../constants/routes/insurance'; import { EXPORT_CONTRACT as EXPORT_CONTRACT_FIELD_IDS } from '../../../../constants/field-ids/insurance/export-contract'; import { PAGES } from '../../../../content-strings'; import { EXPORT_CONTRACT_FIELDS as FIELDS } from '../../../../content-strings/fields/insurance/export-contract'; +import api from '../../../../api'; import getCurrencyByCode from '../../../../helpers/get-currency-by-code'; import singleInputPageVariables from '../../../../helpers/page-variables/single-input/insurance'; import getUserNameFromSession from '../../../../helpers/get-user-name-from-session'; -import constructPayload from '../../../../helpers/construct-payload'; -import api from '../../../../api'; import mapApplicationToFormFields from '../../../../helpers/mappings/map-application-to-form-fields'; +import constructPayload from '../../../../helpers/construct-payload'; import generateValidationErrors from './validation'; +import { sanitiseData } from '../../../../helpers/sanitise-data'; +import mapAndSave from '../map-and-save/export-contract-agent-service-charge'; import { Request, Response } from '../../../../../types'; import { mockReq, mockRes, mockCurrencies, mockCurrenciesResponse, mockCurrenciesEmptyResponse, mockSpyPromiseRejection } from '../../../../test-mocks'; import { mockApplicationMultiplePolicy as mockApplication } from '../../../../test-mocks/mock-application'; const { INSURANCE_ROOT, - EXPORT_CONTRACT: { CHECK_YOUR_ANSWERS }, + EXPORT_CONTRACT: { CHECK_YOUR_ANSWERS, HOW_MUCH_THE_AGENT_IS_CHARGING_SAVE_AND_BACK }, PROBLEM_WITH_SERVICE, } = INSURANCE_ROUTES; @@ -38,11 +40,14 @@ const { const { allCurrencies } = mockCurrenciesResponse; -describe('controllers/insurance/export-contract/how-much-is-the-agent-charging', () => { +describe('controllers/insurance/export-contract/how-much-the-agent-is-charging', () => { let req: Request; let res: Response; + jest.mock('../map-and-save/export-contract-agent-service-charge'); + let getCurrenciesSpy = jest.fn(() => Promise.resolve(mockCurrenciesResponse)); + mapAndSave.exportContractAgentServiceCharge = jest.fn(() => Promise.resolve(true)); beforeEach(() => { req = mockReq(); @@ -57,7 +62,7 @@ describe('controllers/insurance/export-contract/how-much-is-the-agent-charging', describe('PAGE_CONTENT_STRINGS', () => { it('should have the correct strings', () => { - expect(PAGE_CONTENT_STRINGS).toEqual(PAGES.INSURANCE.EXPORT_CONTRACT.HOW_MUCH_IS_THE_AGENT_CHARGING); + expect(PAGE_CONTENT_STRINGS).toEqual(PAGES.INSURANCE.EXPORT_CONTRACT.HOW_MUCH_THE_AGENT_IS_CHARGING); }); }); @@ -74,7 +79,7 @@ describe('controllers/insurance/export-contract/how-much-is-the-agent-charging', }, DYNAMIC_PAGE_TITLE: `${PAGE_CONTENT_STRINGS.PAGE_TITLE} ${currency.name}?`, CURRENCY_PREFIX_SYMBOL: currency.symbol, - SAVE_AND_BACK_URL: `#${referenceNumber}`, + SAVE_AND_BACK_URL: `${INSURANCE_ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING_SAVE_AND_BACK}`, }; expect(result).toEqual(expected); @@ -83,7 +88,7 @@ describe('controllers/insurance/export-contract/how-much-is-the-agent-charging', describe('TEMPLATE', () => { it('should have the correct template defined', () => { - expect(TEMPLATE).toEqual(TEMPLATES.INSURANCE.EXPORT_CONTRACT.HOW_MUCH_IS_THE_AGENT_CHARGING); + expect(TEMPLATE).toEqual(TEMPLATES.INSURANCE.EXPORT_CONTRACT.HOW_MUCH_THE_AGENT_IS_CHARGING); }); }); @@ -190,6 +195,18 @@ describe('controllers/insurance/export-contract/how-much-is-the-agent-charging', expect(getCurrenciesSpy).toHaveBeenCalledTimes(0); }); + it('should call mapAndSave.exportContractAgentServiceCharge with data from constructPayload function and application', async () => { + req.body = validBody; + + await post(req, res); + + const payload = constructPayload(req.body, [FIELD_ID]); + + expect(mapAndSave.exportContractAgentServiceCharge).toHaveBeenCalledTimes(1); + + expect(mapAndSave.exportContractAgentServiceCharge).toHaveBeenCalledWith(payload, res.locals.application); + }); + it(`should redirect to ${CHECK_YOUR_ANSWERS}`, async () => { await post(req, res); @@ -229,7 +246,7 @@ describe('controllers/insurance/export-contract/how-much-is-the-agent-charging', ...generatedPageVariables, userName: getUserNameFromSession(req.session.user), application: mapApplicationToFormFields(mockApplication), - submittedValues: payload, + submittedValues: sanitiseData(payload), validationErrors: generateValidationErrors(payload), }; @@ -249,6 +266,36 @@ describe('controllers/insurance/export-contract/how-much-is-the-agent-charging', }); }); + describe('when mapAndSave.exportContractAgentServiceCharge does not return a true boolean', () => { + beforeEach(() => { + req.body = validBody; + const mapAndSaveSpy = jest.fn(() => Promise.resolve(false)); + + mapAndSave.exportContractAgentServiceCharge = mapAndSaveSpy; + }); + + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); + }); + + describe('when mapAndSave.exportContractAgentServiceCharge returns an error', () => { + beforeEach(() => { + req.body = validBody; + const mapAndSaveSpy = mockSpyPromiseRejection; + + mapAndSave.exportContractAgentServiceCharge = mapAndSaveSpy; + }); + + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); + }); + describe('api error handling', () => { describe('get currencies call', () => { describe('when the get currencies API call fails', () => { diff --git a/src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/index.ts b/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/index.ts similarity index 84% rename from src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/index.ts rename to src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/index.ts index 25b5a4e560..d84e1f2664 100644 --- a/src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/index.ts +++ b/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/index.ts @@ -3,19 +3,21 @@ import { INSURANCE_ROUTES } from '../../../../constants/routes/insurance'; import { EXPORT_CONTRACT as EXPORT_CONTRACT_FIELD_IDS } from '../../../../constants/field-ids/insurance/export-contract'; import { PAGES } from '../../../../content-strings'; import { EXPORT_CONTRACT_FIELDS as FIELDS } from '../../../../content-strings/fields/insurance/export-contract'; +import api from '../../../../api'; import getCurrencyByCode from '../../../../helpers/get-currency-by-code'; import singleInputPageVariables from '../../../../helpers/page-variables/single-input/insurance'; import getUserNameFromSession from '../../../../helpers/get-user-name-from-session'; -import constructPayload from '../../../../helpers/construct-payload'; -import api from '../../../../api'; import { isPopulatedArray } from '../../../../helpers/array'; import mapApplicationToFormFields from '../../../../helpers/mappings/map-application-to-form-fields'; +import constructPayload from '../../../../helpers/construct-payload'; import generateValidationErrors from './validation'; +import { sanitiseData } from '../../../../helpers/sanitise-data'; +import mapAndSave from '../map-and-save/export-contract-agent-service-charge'; import { Currency, Request, Response } from '../../../../../types'; const { INSURANCE_ROOT, - EXPORT_CONTRACT: { CHECK_YOUR_ANSWERS }, + EXPORT_CONTRACT: { CHECK_YOUR_ANSWERS, HOW_MUCH_THE_AGENT_IS_CHARGING_SAVE_AND_BACK }, PROBLEM_WITH_SERVICE, } = INSURANCE_ROUTES; @@ -23,7 +25,7 @@ const { AGENT_CHARGES: { FIXED_SUM_AMOUNT }, } = EXPORT_CONTRACT_FIELD_IDS; -export const PAGE_CONTENT_STRINGS = PAGES.INSURANCE.EXPORT_CONTRACT.HOW_MUCH_IS_THE_AGENT_CHARGING; +export const PAGE_CONTENT_STRINGS = PAGES.INSURANCE.EXPORT_CONTRACT.HOW_MUCH_THE_AGENT_IS_CHARGING; export const FIELD_ID = FIXED_SUM_AMOUNT; @@ -45,18 +47,18 @@ export const pageVariables = (referenceNumber: number, currencies: Array { const { application } = res.locals; @@ -160,7 +162,7 @@ export const post = async (req: Request, res: Response) => { ...generatedPageVariables, userName: getUserNameFromSession(req.session.user), application: mapApplicationToFormFields(application), - submittedValues: payload, + submittedValues: sanitiseData(payload), validationErrors, }); } catch (error) { @@ -170,5 +172,17 @@ export const post = async (req: Request, res: Response) => { } } - return res.redirect(`${INSURANCE_ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`); + try { + const saveResponse = await mapAndSave.exportContractAgentServiceCharge(payload, application); + + if (!saveResponse) { + return res.redirect(PROBLEM_WITH_SERVICE); + } + + return res.redirect(`${INSURANCE_ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`); + } catch (error) { + console.error('Error updating application - export contract - how much the agent is charging %O', error); + + return res.redirect(PROBLEM_WITH_SERVICE); + } }; diff --git a/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/save-and-back/index.test.ts new file mode 100644 index 0000000000..0b57c12bfe --- /dev/null +++ b/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/save-and-back/index.test.ts @@ -0,0 +1,100 @@ +import { post } from '.'; +import { INSURANCE_ROUTES } from '../../../../../constants/routes/insurance'; +import { FIELD_ID } from '..'; +import constructPayload from '../../../../../helpers/construct-payload'; +import mapAndSave from '../../map-and-save/export-contract-agent-service-charge'; +import generateValidationErrors from '../validation'; +import { Request, Response } from '../../../../../../types'; +import { mockApplication, mockReq, mockRes, mockSpyPromiseRejection } from '../../../../../test-mocks'; + +const { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = INSURANCE_ROUTES; + +describe('controllers/insurance/export-contract/how-much-the-agent-is-charging/save-and-back', () => { + let req: Request; + let res: Response; + + jest.mock('../../map-and-save/export-contract-agent-service-charge'); + + let mapAndSaveSpy = jest.fn(() => Promise.resolve(true)); + + const refNumber = Number(mockApplication.referenceNumber); + + const mockFormBody = { + _csrf: '1234', + [FIELD_ID]: 'mock', + }; + + beforeEach(() => { + req = mockReq(); + res = mockRes(); + + req.params.referenceNumber = String(mockApplication.referenceNumber); + + req.body = mockFormBody; + + mapAndSave.exportContractAgentServiceCharge = mapAndSaveSpy; + }); + + describe('when the form has data', () => { + beforeEach(() => { + mapAndSave.exportContractAgentServiceCharge = mapAndSaveSpy; + }); + + it('should call mapAndSave.exportContractAgentServiceCharge with data from constructPayload function, application and validationErrors', async () => { + await post(req, res); + + const payload = constructPayload(req.body, [FIELD_ID]); + + const validationErrors = generateValidationErrors(payload); + + expect(mapAndSave.exportContractAgentServiceCharge).toHaveBeenCalledTimes(1); + expect(mapAndSave.exportContractAgentServiceCharge).toHaveBeenCalledWith(payload, res.locals.application, validationErrors); + }); + + it(`should redirect to ${ALL_SECTIONS}`, async () => { + await post(req, res); + + const expected = `${INSURANCE_ROOT}/${refNumber}${ALL_SECTIONS}`; + + expect(res.redirect).toHaveBeenCalledWith(expected); + }); + }); + + describe('when the form does not have any data', () => { + it(`should redirect to ${ALL_SECTIONS}`, async () => { + req.body = { _csrf: '1234' }; + + await post(req, res); + + const expected = `${INSURANCE_ROOT}/${refNumber}${ALL_SECTIONS}`; + + expect(res.redirect).toHaveBeenCalledWith(expected); + }); + }); + + describe('when there is no application', () => { + beforeEach(() => { + delete res.locals.application; + }); + + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); + }); + + describe('when there is an error calling the API', () => { + beforeAll(() => { + mapAndSaveSpy = mockSpyPromiseRejection; + + mapAndSave.exportContractAgentServiceCharge = mapAndSaveSpy; + }); + + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); + }); +}); diff --git a/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/save-and-back/index.ts b/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/save-and-back/index.ts new file mode 100644 index 0000000000..05cd5b2247 --- /dev/null +++ b/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/save-and-back/index.ts @@ -0,0 +1,52 @@ +import { INSURANCE_ROUTES } from '../../../../../constants/routes/insurance'; +import hasFormData from '../../../../../helpers/has-form-data'; +import { FIELD_ID } from '..'; +import constructPayload from '../../../../../helpers/construct-payload'; +import generateValidationErrors from '../validation'; +import mapAndSave from '../../map-and-save/export-contract-agent-service-charge'; +import { Request, Response } from '../../../../../../types'; + +const { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = INSURANCE_ROUTES; +/** + * post + * Save any valid "How much the agent is charging" form fields and if successful, redirect to the all sections page + * @param {Express.Request} Express request + * @param {Express.Response} Express response + * @returns {Express.Response.redirect} All sections page or error page + */ +export const post = async (req: Request, res: Response) => { + try { + const { application } = res.locals; + + if (!application) { + return res.redirect(PROBLEM_WITH_SERVICE); + } + + const { referenceNumber } = req.params; + + /** + * If form data is populated: + * 1) generate a payload. + * 2) generate validation errors. + * 3) call mapAndSave + * 4) redirect + */ + if (hasFormData(req.body)) { + const payload = constructPayload(req.body, [FIELD_ID]); + + const validationErrors = generateValidationErrors(payload); + + const saveResponse = await mapAndSave.exportContractAgentServiceCharge(payload, application, validationErrors); + + if (!saveResponse) { + return res.redirect(PROBLEM_WITH_SERVICE); + } + } + + return res.redirect(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); + } catch (error) { + console.error('Error updating application - export contract - how much the agent is charging (save and back) %O', error); + + return res.redirect(PROBLEM_WITH_SERVICE); + } +}; diff --git a/src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/validation/index.test.ts b/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/validation/index.test.ts similarity index 100% rename from src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/validation/index.test.ts rename to src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/validation/index.test.ts diff --git a/src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/validation/index.ts b/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/validation/index.ts similarity index 100% rename from src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/validation/index.ts rename to src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/validation/index.ts diff --git a/src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/validation/rules/fixed-sum-amount/index.test.ts b/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/validation/rules/fixed-sum-amount/index.test.ts similarity index 100% rename from src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/validation/rules/fixed-sum-amount/index.test.ts rename to src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/validation/rules/fixed-sum-amount/index.test.ts diff --git a/src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/validation/rules/fixed-sum-amount/index.ts b/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/validation/rules/fixed-sum-amount/index.ts similarity index 100% rename from src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/validation/rules/fixed-sum-amount/index.ts rename to src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/validation/rules/fixed-sum-amount/index.ts diff --git a/src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/validation/rules/index.ts b/src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/validation/rules/index.ts similarity index 100% rename from src/ui/server/controllers/insurance/export-contract/how-much-is-the-agent-charging/validation/rules/index.ts rename to src/ui/server/controllers/insurance/export-contract/how-much-the-agent-is-charging/validation/rules/index.ts diff --git a/src/ui/server/controllers/insurance/export-contract/map-submitted-data/agent-service-charge/index.test.ts b/src/ui/server/controllers/insurance/export-contract/map-submitted-data/agent-service-charge/index.test.ts index ff50d21c58..bf020d2e0f 100644 --- a/src/ui/server/controllers/insurance/export-contract/map-submitted-data/agent-service-charge/index.test.ts +++ b/src/ui/server/controllers/insurance/export-contract/map-submitted-data/agent-service-charge/index.test.ts @@ -1,6 +1,7 @@ import mapSubmittedData from '.'; import { APPLICATION } from '../../../../../constants'; import FIELD_IDS from '../../../../../constants/field-ids/insurance'; +import { stripCommas } from '../../../../../helpers/string'; import { EUR, HKD } from '../../../../../test-mocks'; const { @@ -23,7 +24,6 @@ describe('controllers/insurance/export-contract/map-submitted-data/agent-service it('should return the form body with mapped data', () => { const mockFormBody = { [METHOD]: FIXED_SUM, - [FIXED_SUM_AMOUNT]: '1', [ALTERNATIVE_CURRENCY_CODE]: EUR.isoCode, [CURRENCY_CODE]: EUR.isoCode, }; @@ -32,7 +32,6 @@ describe('controllers/insurance/export-contract/map-submitted-data/agent-service const expected = { ...mockFormBody, - [FIXED_SUM_AMOUNT]: String(mockFormBody[FIXED_SUM_AMOUNT]), [PERCENTAGE_CHARGE]: null, [FIXED_SUM_CURRENCY_CODE]: EUR.isoCode, }; @@ -40,33 +39,9 @@ describe('controllers/insurance/export-contract/map-submitted-data/agent-service expect(result).toEqual(expected); }); - describe(`when ${METHOD} is ${FIXED_SUM} and contains a comma`, () => { - it('should return the form body with mapped data with the comma stripped', () => { - const mockFormBody = { - [METHOD]: FIXED_SUM, - [FIXED_SUM_AMOUNT]: '1,500', - [ALTERNATIVE_CURRENCY_CODE]: EUR.isoCode, - [CURRENCY_CODE]: EUR.isoCode, - }; - - const result = mapSubmittedData(mockFormBody); - - const expected = { - ...mockFormBody, - // TODO: EMS-3828 - renable - // [FIXED_SUM_AMOUNT]: stripCommas(String(mockFormBody[FIXED_SUM_AMOUNT])), - [PERCENTAGE_CHARGE]: null, - [FIXED_SUM_CURRENCY_CODE]: EUR.isoCode, - }; - - expect(result).toEqual(expected); - }); - }); - it(`should set ${ALTERNATIVE_CURRENCY_CODE} to null when ${CURRENCY_CODE} is NOT ${ALTERNATIVE_CURRENCY_CODE}`, () => { const mockFormBody = { [METHOD]: FIXED_SUM, - [FIXED_SUM_AMOUNT]: '1', [ALTERNATIVE_CURRENCY_CODE]: HKD.isoCode, [CURRENCY_CODE]: EUR.isoCode, }; @@ -75,7 +50,6 @@ describe('controllers/insurance/export-contract/map-submitted-data/agent-service const expected = { ...mockFormBody, - [FIXED_SUM_AMOUNT]: String(mockFormBody[FIXED_SUM_AMOUNT]), [PERCENTAGE_CHARGE]: null, [FIXED_SUM_CURRENCY_CODE]: EUR.isoCode, [ALTERNATIVE_CURRENCY_CODE]: null, @@ -99,8 +73,24 @@ describe('controllers/insurance/export-contract/map-submitted-data/agent-service const expected = { ...mockFormBody, [PERCENTAGE_CHARGE]: Number(mockFormBody[PERCENTAGE_CHARGE]), - // [FIXED_SUM_AMOUNT]: null, - [FIXED_SUM_CURRENCY_CODE]: EUR.isoCode, + [FIXED_SUM_AMOUNT]: null, + [FIXED_SUM_CURRENCY_CODE]: null, + }; + + expect(result).toEqual(expected); + }); + }); + + describe(`when ${FIXED_SUM_AMOUNT} is provided`, () => { + it('should return the form body with mapped data', () => { + const mockFormBody = { + [FIXED_SUM_AMOUNT]: '1,23', + }; + + const result = mapSubmittedData(mockFormBody); + + const expected = { + [FIXED_SUM_AMOUNT]: stripCommas(String(mockFormBody[FIXED_SUM_AMOUNT])), }; expect(result).toEqual(expected); diff --git a/src/ui/server/controllers/insurance/export-contract/map-submitted-data/agent-service-charge/index.ts b/src/ui/server/controllers/insurance/export-contract/map-submitted-data/agent-service-charge/index.ts index 3c10bc5759..a93e2dc1ba 100644 --- a/src/ui/server/controllers/insurance/export-contract/map-submitted-data/agent-service-charge/index.ts +++ b/src/ui/server/controllers/insurance/export-contract/map-submitted-data/agent-service-charge/index.ts @@ -1,7 +1,7 @@ import { APPLICATION } from '../../../../../constants'; import FIELD_IDS from '../../../../../constants/field-ids/insurance'; import { objectHasProperty } from '../../../../../helpers/object'; -import { isEmptyString } from '../../../../../helpers/string'; +import { isEmptyString, stripCommas } from '../../../../../helpers/string'; import { RequestBody } from '../../../../../../types'; const { @@ -15,32 +15,26 @@ const { const { CURRENCY: { CURRENCY_CODE, ALTERNATIVE_CURRENCY_CODE }, EXPORT_CONTRACT: { - AGENT_CHARGES: { PERCENTAGE_CHARGE, FIXED_SUM_CURRENCY_CODE, METHOD }, + AGENT_CHARGES: { PERCENTAGE_CHARGE, FIXED_SUM_CURRENCY_CODE, FIXED_SUM_AMOUNT, METHOD }, }, } = FIELD_IDS; -// TODO: EMS-3828 - renable FIXED_SUM_AMOUNT mapping - /** * mapSubmittedData * Map agent service charge fields. - * If the METHOD is PERCENTAGE, map PERCENTAGE fields, nullify FIXED_SUM values. - * If the METHOD is FIXED_SUM, map FIXED_SUM fields, nullify PERCENTAGE values. + * If FIXED_SUM_AMOUNT is provided, map the value. + * If CURRENCY_CODE or ALTERNATIVE_CURRENCY_CODE are provided, map currency fields. + * If METHOD is an empty string, nullify the field. + * If the METHOD is PERCENTAGE, nullify FIXED_SUM values. + * If the METHOD is FIXED_SUM, nullify PERCENTAGE values. * @param {RequestBody} formBody: Form body * @returns {Object} populatedData */ const mapSubmittedData = (formBody: RequestBody): object => { const populatedData = formBody; - if (formBody[METHOD] === FIXED_SUM) { - // populatedData[FIXED_SUM_AMOUNT] = stripCommas(String(populatedData[FIXED_SUM_AMOUNT])); - populatedData[PERCENTAGE_CHARGE] = null; - } - - if (formBody[METHOD] === PERCENTAGE) { - populatedData[PERCENTAGE_CHARGE] = Number(populatedData[PERCENTAGE_CHARGE]); - // populatedData[FIXED_SUM_AMOUNT] = null; - populatedData[FIXED_SUM_CURRENCY_CODE] = null; + if (objectHasProperty(populatedData, FIXED_SUM_AMOUNT)) { + populatedData[FIXED_SUM_AMOUNT] = stripCommas(String(populatedData[FIXED_SUM_AMOUNT])); } if (objectHasProperty(populatedData, CURRENCY_CODE)) { @@ -81,6 +75,24 @@ const mapSubmittedData = (formBody: RequestBody): object => { populatedData[METHOD] = null; } + /** + * If METHOD is FIXED_SUM, + * nullify PERCENTAGE related fields. + */ + if (formBody[METHOD] === FIXED_SUM) { + populatedData[PERCENTAGE_CHARGE] = null; + } + + /** + * If METHOD is PERCENTAGE, + * nullify FIXED_SUM related fields. + */ + if (formBody[METHOD] === PERCENTAGE) { + populatedData[PERCENTAGE_CHARGE] = Number(populatedData[PERCENTAGE_CHARGE]); + populatedData[FIXED_SUM_AMOUNT] = null; + populatedData[FIXED_SUM_CURRENCY_CODE] = null; + } + return populatedData; }; diff --git a/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/index.test.ts b/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/index.test.ts index 7dc433ea8d..342607c27e 100644 --- a/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/index.test.ts +++ b/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/index.test.ts @@ -90,7 +90,7 @@ describe('controllers/insurance/your-buyer/currency-of-late-payments', () => { describe('TEMPLATE', () => { it('should have the correct template defined', () => { - expect(TEMPLATE).toEqual(TEMPLATES.SHARED_PAGES.ALTERNATIVE_CURRENCY); + expect(TEMPLATE).toEqual(TEMPLATES.SHARED_PAGES.CURRENCY); }); }); diff --git a/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/index.ts b/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/index.ts index 65158779d4..b6f74a772d 100644 --- a/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/index.ts +++ b/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/index.ts @@ -11,10 +11,10 @@ import api from '../../../../api'; import { isPopulatedArray } from '../../../../helpers/array'; import mapRadioAndSelectOptions from '../../../../helpers/mappings/map-currencies/radio-and-select-options'; import constructPayload from '../../../../helpers/construct-payload'; +import mapAndSave from '../map-and-save/buyer-trading-history'; import isChangeRoute from '../../../../helpers/is-change-route'; import isCheckAndChangeRoute from '../../../../helpers/is-check-and-change-route'; import { Request, Response } from '../../../../../types'; -import mapAndSave from '../map-and-save/buyer-trading-history'; const { INSURANCE_ROOT, @@ -33,7 +33,7 @@ const { export const FIELD_IDS = [CURRENCY_CODE, ALTERNATIVE_CURRENCY_CODE]; -export const TEMPLATE = TEMPLATES.SHARED_PAGES.ALTERNATIVE_CURRENCY; +export const TEMPLATE = TEMPLATES.SHARED_PAGES.CURRENCY; export const PAGE_CONTENT_STRINGS = PAGES.INSURANCE.YOUR_BUYER.CURRENCY_OF_LATE_PAYMENTS; diff --git a/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/save-and-back/index.test.ts new file mode 100644 index 0000000000..a4c8ad7c90 --- /dev/null +++ b/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/save-and-back/index.test.ts @@ -0,0 +1,125 @@ +import { FIELD_IDS } from '..'; +import { post } from '.'; +import { ROUTES } from '../../../../../constants'; +import INSURANCE_FIELD_IDS from '../../../../../constants/field-ids/insurance'; +import constructPayload from '../../../../../helpers/construct-payload'; +import generateValidationErrors from '../validation'; +import mapAndSave from '../../map-and-save/buyer-trading-history'; +import { Request, Response } from '../../../../../../types'; +import { EUR, mockReq, mockRes, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; + +const { + CURRENCY: { CURRENCY_CODE }, +} = INSURANCE_FIELD_IDS; + +const { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = ROUTES.INSURANCE; + +describe('controllers/insurance/your-buyer/currency-of-late-payments/save-and-back', () => { + let req: Request; + let res: Response; + + jest.mock('../../map-and-save/buyer-trading-history'); + + let mapAndSaveSpy = jest.fn(() => Promise.resolve(true)); + + const mockFormBody = { + [CURRENCY_CODE]: EUR.isoCode, + }; + + beforeEach(() => { + req = mockReq(); + res = mockRes(); + + req.body = mockFormBody; + + mapAndSave.buyerTradingHistory = mapAndSaveSpy; + }); + + afterAll(() => { + jest.resetAllMocks(); + }); + + describe('when the form has data', () => { + beforeEach(() => { + jest.resetAllMocks(); + + mapAndSaveSpy = jest.fn(() => Promise.resolve(true)); + mapAndSave.buyerTradingHistory = mapAndSaveSpy; + }); + + it('should call mapAndSave.buyerTradingHistory with data from constructPayload function, application and validationErrors', async () => { + await post(req, res); + + const payload = constructPayload(req.body, FIELD_IDS); + + const validationErrors = generateValidationErrors(payload); + + expect(mapAndSave.buyerTradingHistory).toHaveBeenCalledTimes(1); + expect(mapAndSave.buyerTradingHistory).toHaveBeenCalledWith(payload, res.locals.application, validationErrors); + }); + + it(`should redirect to ${ALL_SECTIONS}`, async () => { + mapAndSave.buyerTradingHistory = mapAndSaveSpy; + + await post(req, res); + + const expected = `${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`; + + expect(res.redirect).toHaveBeenCalledWith(expected); + }); + }); + + describe('when the form does not have any data', () => { + it(`should redirect to ${ALL_SECTIONS}`, async () => { + req.body = { _csrf: '1234' }; + + await post(req, res); + + const expected = `${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`; + + expect(res.redirect).toHaveBeenCalledWith(expected); + }); + }); + + describe('when there is no application', () => { + beforeEach(() => { + delete res.locals.application; + }); + + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); + }); + + describe('api error handling', () => { + describe('when mapAndSave.buyerTradingHistory returns false', () => { + beforeEach(() => { + res.locals = mockRes().locals; + mapAndSaveSpy = jest.fn(() => Promise.resolve(false)); + mapAndSave.buyerTradingHistory = mapAndSaveSpy; + }); + + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); + }); + + describe('when mapAndSave.buyerTradingHistory fails', () => { + beforeEach(() => { + res.locals = mockRes().locals; + mapAndSaveSpy = mockSpyPromiseRejection; + mapAndSave.buyerTradingHistory = mapAndSaveSpy; + }); + + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await post(req, res); + + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); + }); + }); +}); diff --git a/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/save-and-back/index.ts b/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/save-and-back/index.ts new file mode 100644 index 0000000000..4d9cfc2465 --- /dev/null +++ b/src/ui/server/controllers/insurance/your-buyer/currency-of-late-payments/save-and-back/index.ts @@ -0,0 +1,53 @@ +import { INSURANCE_ROUTES } from '../../../../../constants/routes/insurance'; +import hasFormData from '../../../../../helpers/has-form-data'; +import { FIELD_IDS } from '..'; +import constructPayload from '../../../../../helpers/construct-payload'; +import generateValidationErrors from '../validation'; +import mapAndSave from '../../map-and-save/buyer-trading-history'; +import { Request, Response } from '../../../../../../types'; + +const { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = INSURANCE_ROUTES; + +/** + * post + * Save any valid currency of late payments form fields and if successful, redirect to the all sections page + * @param {Express.Request} Express request + * @param {Express.Response} Express response + * @returns {Express.Response.redirect} All sections page or error page + */ +export const post = async (req: Request, res: Response) => { + try { + const { application } = res.locals; + + if (!application) { + return res.redirect(PROBLEM_WITH_SERVICE); + } + + const { referenceNumber } = req.params; + + /** + * If form data is populated: + * 1) generate a payload. + * 2) generate validation errors. + * 3) call mapAndSave + * 4) redirect + */ + if (hasFormData(req.body)) { + const payload = constructPayload(req.body, FIELD_IDS); + + const validationErrors = generateValidationErrors(payload); + + const saveResponse = await mapAndSave.buyerTradingHistory(payload, application, validationErrors); + + if (!saveResponse) { + return res.redirect(PROBLEM_WITH_SERVICE); + } + } + + return res.redirect(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); + } catch (error) { + console.error('Error updating application - your buyer - currency of late payments (save and back) %o', error); + + return res.redirect(PROBLEM_WITH_SERVICE); + } +}; diff --git a/src/ui/server/helpers/required-fields/export-contract/index.test.ts b/src/ui/server/helpers/required-fields/export-contract/index.test.ts index 28fd588a88..a39d44834e 100644 --- a/src/ui/server/helpers/required-fields/export-contract/index.test.ts +++ b/src/ui/server/helpers/required-fields/export-contract/index.test.ts @@ -15,7 +15,7 @@ const { USING_AGENT, AGENT_DETAILS: { AGENT_NAME, AGENT_FULL_ADDRESS, AGENT_COUNTRY_CODE }, AGENT_SERVICE: { IS_CHARGING, SERVICE_DESCRIPTION }, - AGENT_CHARGES: { METHOD, PAYABLE_COUNTRY_CODE, PERCENTAGE_CHARGE }, + AGENT_CHARGES: { FIXED_SUM_AMOUNT, FIXED_SUM_CURRENCY_CODE, METHOD, PAYABLE_COUNTRY_CODE, PERCENTAGE_CHARGE }, } = FIELD_IDS; describe('server/helpers/required-fields/export-contract', () => { @@ -91,23 +91,20 @@ describe('server/helpers/required-fields/export-contract', () => { }); describe('agentServiceChargeTasks', () => { - describe(`when agentIsCharging is true and agentChargeMethod is ${AGENT_SERVICE_CHARGE_METHOD.FIXED_SUM}`, () => { + describe(`when agentIsCharging is true and ${METHOD} is ${AGENT_SERVICE_CHARGE_METHOD.FIXED_SUM}`, () => { it('should return an array with required agent service charge field IDs', () => { const result = agentServiceChargeTasks({ agentIsCharging: true, agentChargeMethod: AGENT_SERVICE_CHARGE_METHOD.FIXED_SUM, }); - // TODO: EMS-3828- renable - // const expected = [METHOD, PAYABLE_COUNTRY_CODE, FIXED_SUM_AMOUNT, FIXED_SUM_CURRENCY_CODE]; - - const expected = [METHOD, PAYABLE_COUNTRY_CODE]; + const expected = [METHOD, PAYABLE_COUNTRY_CODE, FIXED_SUM_AMOUNT, FIXED_SUM_CURRENCY_CODE]; expect(result).toEqual(expected); }); }); - describe(`when agentIsCharging is true and agentChargeMethod is ${AGENT_SERVICE_CHARGE_METHOD.PERCENTAGE}`, () => { + describe(`when agentIsCharging is true and ${METHOD} is ${AGENT_SERVICE_CHARGE_METHOD.PERCENTAGE}`, () => { it('should return an array with required agent service charge field IDs', () => { const result = agentServiceChargeTasks({ agentIsCharging: true, @@ -120,7 +117,7 @@ describe('server/helpers/required-fields/export-contract', () => { }); }); - describe('when agentIsCharging is false and agentChargeMethod is NOT provided', () => { + describe(`when agentIsCharging is false and ${METHOD} is NOT provided`, () => { it('should return an array with required agent service charge field IDs', () => { const result = agentServiceChargeTasks({ agentIsCharging: true }); diff --git a/src/ui/server/helpers/required-fields/export-contract/index.ts b/src/ui/server/helpers/required-fields/export-contract/index.ts index 39fc7a08e5..6d392f4fbf 100644 --- a/src/ui/server/helpers/required-fields/export-contract/index.ts +++ b/src/ui/server/helpers/required-fields/export-contract/index.ts @@ -13,7 +13,7 @@ const { USING_AGENT, AGENT_DETAILS: { AGENT_NAME, AGENT_FULL_ADDRESS, AGENT_COUNTRY_CODE }, AGENT_SERVICE: { IS_CHARGING, SERVICE_DESCRIPTION }, - AGENT_CHARGES: { METHOD, PAYABLE_COUNTRY_CODE, PERCENTAGE_CHARGE }, + AGENT_CHARGES: { FIXED_SUM_AMOUNT, FIXED_SUM_CURRENCY_CODE, METHOD, PAYABLE_COUNTRY_CODE, PERCENTAGE_CHARGE }, } = FIELD_IDS; /** @@ -69,10 +69,9 @@ export const agentServiceChargeTasks = ({ agentIsCharging, agentChargeMethod }: if (agentIsCharging) { const tasks = [METHOD, PAYABLE_COUNTRY_CODE]; - // TODO: EMS-3828 - renable - // if (agentChargeMethod === AGENT_SERVICE_CHARGE_METHOD.FIXED_SUM) { - // tasks.push(FIXED_SUM_AMOUNT, FIXED_SUM_CURRENCY_CODE); - // } + if (agentChargeMethod === AGENT_SERVICE_CHARGE_METHOD.FIXED_SUM) { + tasks.push(FIXED_SUM_AMOUNT, FIXED_SUM_CURRENCY_CODE); + } if (agentChargeMethod === AGENT_SERVICE_CHARGE_METHOD.PERCENTAGE) { tasks.push(PERCENTAGE_CHARGE); diff --git a/src/ui/server/routes/insurance/export-contract/index.test.ts b/src/ui/server/routes/insurance/export-contract/index.test.ts index d74371662a..1ef5bbb207 100644 --- a/src/ui/server/routes/insurance/export-contract/index.test.ts +++ b/src/ui/server/routes/insurance/export-contract/index.test.ts @@ -27,9 +27,10 @@ import { post as agentChargesSaveAndBackPost } from '../../../controllers/insura import { get as agentChargesCurrencyGet, post as agentChargesCurrencyPost } from '../../../controllers/insurance/export-contract/currency-of-agents-charge'; import { post as agentChargesCurrencySaveAndBackPost } from '../../../controllers/insurance/export-contract/currency-of-agents-charge/save-and-back'; import { - get as howMuchIsTheAgentChargingGet, - post as howMuchIsTheAgentChargingPost, -} from '../../../controllers/insurance/export-contract/how-much-is-the-agent-charging'; + get as howMuchTheAgentIsChargingGet, + post as howMuchTheAgentIsChargingPost, +} from '../../../controllers/insurance/export-contract/how-much-the-agent-is-charging'; +import { post as howMuchTheAgentIsChargingSaveAndBackPost } from '../../../controllers/insurance/export-contract/how-much-the-agent-is-charging/save-and-back'; import { get as checkYourAnswersGet, post as checkYourAnswersPost } from '../../../controllers/insurance/export-contract/check-your-answers'; const { @@ -73,7 +74,8 @@ const { AGENT_CHARGES_CURRENCY_SAVE_AND_BACK, AGENT_CHARGES_CURRENCY_CHANGE, AGENT_CHARGES_CURRENCY_CHECK_AND_CHANGE, - HOW_MUCH_IS_THE_AGENT_CHARGING, + HOW_MUCH_THE_AGENT_IS_CHARGING, + HOW_MUCH_THE_AGENT_IS_CHARGING_SAVE_AND_BACK, CHECK_YOUR_ANSWERS, } = EXPORT_CONTRACT; @@ -88,7 +90,7 @@ describe('routes/insurance/export-contract', () => { it('should setup all routes', () => { expect(get).toHaveBeenCalledTimes(33); - expect(post).toHaveBeenCalledTimes(42); + expect(post).toHaveBeenCalledTimes(43); expect(get).toHaveBeenCalledWith(`/:referenceNumber${ROOT}`, exportContractRootGet); @@ -171,8 +173,9 @@ describe('routes/insurance/export-contract', () => { expect(get).toHaveBeenCalledWith(`/:referenceNumber${AGENT_CHARGES_CURRENCY_CHECK_AND_CHANGE}`, agentChargesCurrencyGet); expect(post).toHaveBeenCalledWith(`/:referenceNumber${AGENT_CHARGES_CURRENCY_CHECK_AND_CHANGE}`, agentChargesCurrencyPost); - expect(get).toHaveBeenCalledWith(`/:referenceNumber${HOW_MUCH_IS_THE_AGENT_CHARGING}`, howMuchIsTheAgentChargingGet); - expect(post).toHaveBeenCalledWith(`/:referenceNumber${HOW_MUCH_IS_THE_AGENT_CHARGING}`, howMuchIsTheAgentChargingPost); + expect(get).toHaveBeenCalledWith(`/:referenceNumber${HOW_MUCH_THE_AGENT_IS_CHARGING}`, howMuchTheAgentIsChargingGet); + expect(post).toHaveBeenCalledWith(`/:referenceNumber${HOW_MUCH_THE_AGENT_IS_CHARGING}`, howMuchTheAgentIsChargingPost); + expect(post).toHaveBeenCalledWith(`/:referenceNumber${HOW_MUCH_THE_AGENT_IS_CHARGING_SAVE_AND_BACK}`, howMuchTheAgentIsChargingSaveAndBackPost); expect(get).toHaveBeenCalledWith(`/:referenceNumber${CHECK_YOUR_ANSWERS}`, checkYourAnswersGet); expect(post).toHaveBeenCalledWith(`/:referenceNumber${CHECK_YOUR_ANSWERS}`, checkYourAnswersPost); diff --git a/src/ui/server/routes/insurance/export-contract/index.ts b/src/ui/server/routes/insurance/export-contract/index.ts index e6ef97965c..0d7e3f3675 100644 --- a/src/ui/server/routes/insurance/export-contract/index.ts +++ b/src/ui/server/routes/insurance/export-contract/index.ts @@ -28,9 +28,10 @@ import { post as agentChargesSaveAndBackPost } from '../../../controllers/insura import { get as agentChargesCurrencyGet, post as agentChargesCurrencyPost } from '../../../controllers/insurance/export-contract/currency-of-agents-charge'; import { post as agentChargesCurrencySaveAndBackPost } from '../../../controllers/insurance/export-contract/currency-of-agents-charge/save-and-back'; import { - get as howMuchIsTheAgentChargingGet, - post as howMuchIsTheAgentChargingPost, -} from '../../../controllers/insurance/export-contract/how-much-is-the-agent-charging'; + get as howMuchTheAgentIsChargingGet, + post as howMuchTheAgentIsChargingPost, +} from '../../../controllers/insurance/export-contract/how-much-the-agent-is-charging'; +import { post as howMuchTheAgentIsChargingSaveAndBackPost } from '../../../controllers/insurance/export-contract/how-much-the-agent-is-charging/save-and-back'; import { get as checkYourAnswersGet, post as checkYourAnswersPost } from '../../../controllers/insurance/export-contract/check-your-answers'; const { @@ -75,7 +76,8 @@ const { AGENT_CHARGES_CURRENCY_SAVE_AND_BACK, AGENT_CHARGES_CURRENCY_CHANGE, AGENT_CHARGES_CURRENCY_CHECK_AND_CHANGE, - HOW_MUCH_IS_THE_AGENT_CHARGING, + HOW_MUCH_THE_AGENT_IS_CHARGING, + HOW_MUCH_THE_AGENT_IS_CHARGING_SAVE_AND_BACK, CHECK_YOUR_ANSWERS, } = EXPORT_CONTRACT; @@ -168,8 +170,9 @@ exportContractRoute.post(`/:referenceNumber${AGENT_CHARGES_CURRENCY_CHANGE}`, ag exportContractRoute.get(`/:referenceNumber${AGENT_CHARGES_CURRENCY_CHECK_AND_CHANGE}`, agentChargesCurrencyGet); exportContractRoute.post(`/:referenceNumber${AGENT_CHARGES_CURRENCY_CHECK_AND_CHANGE}`, agentChargesCurrencyPost); -exportContractRoute.get(`/:referenceNumber${HOW_MUCH_IS_THE_AGENT_CHARGING}`, howMuchIsTheAgentChargingGet); -exportContractRoute.post(`/:referenceNumber${HOW_MUCH_IS_THE_AGENT_CHARGING}`, howMuchIsTheAgentChargingPost); +exportContractRoute.get(`/:referenceNumber${HOW_MUCH_THE_AGENT_IS_CHARGING}`, howMuchTheAgentIsChargingGet); +exportContractRoute.post(`/:referenceNumber${HOW_MUCH_THE_AGENT_IS_CHARGING}`, howMuchTheAgentIsChargingPost); +exportContractRoute.post(`/:referenceNumber${HOW_MUCH_THE_AGENT_IS_CHARGING_SAVE_AND_BACK}`, howMuchTheAgentIsChargingSaveAndBackPost); exportContractRoute.get(`/:referenceNumber${CHECK_YOUR_ANSWERS}`, checkYourAnswersGet); exportContractRoute.post(`/:referenceNumber${CHECK_YOUR_ANSWERS}`, checkYourAnswersPost); diff --git a/src/ui/server/routes/insurance/index.test.ts b/src/ui/server/routes/insurance/index.test.ts index db75b1a19d..7c1d4b7a94 100644 --- a/src/ui/server/routes/insurance/index.test.ts +++ b/src/ui/server/routes/insurance/index.test.ts @@ -22,7 +22,7 @@ describe('routes/insurance', () => { it('should setup all routes', () => { expect(get).toHaveBeenCalledTimes(216); - expect(post).toHaveBeenCalledTimes(225); + expect(post).toHaveBeenCalledTimes(227); expect(get).toHaveBeenCalledWith(INSURANCE_ROUTES.START, startGet); diff --git a/src/ui/server/routes/insurance/your-buyer/index.test.ts b/src/ui/server/routes/insurance/your-buyer/index.test.ts index 9791d019dd..718b8efbf9 100644 --- a/src/ui/server/routes/insurance/your-buyer/index.test.ts +++ b/src/ui/server/routes/insurance/your-buyer/index.test.ts @@ -14,6 +14,7 @@ import { get as getTradingHistory, post as postTradingHistory } from '../../../c import { post as postTradingHistorySaveAndBack } from '../../../controllers/insurance/your-buyer/trading-history/save-and-back'; import { get as getCurrencyOfLatePayments, post as postCurrencyOfLatePayments } from '../../../controllers/insurance/your-buyer/currency-of-late-payments'; +import { post as postCurrencyOfLatePaymentsSaveAndBack } from '../../../controllers/insurance/your-buyer/currency-of-late-payments/save-and-back'; import { get as getOutstandingOrOverduePayments, @@ -46,7 +47,7 @@ describe('routes/insurance/your-buyer', () => { it('should setup all routes', () => { expect(get).toHaveBeenCalledTimes(29); - expect(post).toHaveBeenCalledTimes(36); + expect(post).toHaveBeenCalledTimes(37); expect(get).toHaveBeenCalledWith(`/:referenceNumber${YOUR_BUYER.ROOT}`, buyerRootGet); @@ -84,6 +85,7 @@ describe('routes/insurance/your-buyer', () => { expect(get).toHaveBeenCalledWith(`/:referenceNumber${YOUR_BUYER.CURRENCY_OF_LATE_PAYMENTS}`, getCurrencyOfLatePayments); expect(post).toHaveBeenCalledWith(`/:referenceNumber${YOUR_BUYER.CURRENCY_OF_LATE_PAYMENTS}`, postCurrencyOfLatePayments); + expect(post).toHaveBeenCalledWith(`/:referenceNumber${YOUR_BUYER.CURRENCY_OF_LATE_PAYMENTS_SAVE_AND_BACK}`, postCurrencyOfLatePaymentsSaveAndBack); expect(get).toHaveBeenCalledWith(`/:referenceNumber${YOUR_BUYER.CURRENCY_OF_LATE_PAYMENTS_CHANGE}`, getCurrencyOfLatePayments); expect(post).toHaveBeenCalledWith(`/:referenceNumber${YOUR_BUYER.CURRENCY_OF_LATE_PAYMENTS_CHANGE}`, postCurrencyOfLatePayments); expect(get).toHaveBeenCalledWith(`/:referenceNumber${YOUR_BUYER.CURRENCY_OF_LATE_PAYMENTS_CHECK_AND_CHANGE}`, getCurrencyOfLatePayments); diff --git a/src/ui/server/routes/insurance/your-buyer/index.ts b/src/ui/server/routes/insurance/your-buyer/index.ts index 0771dba26f..2cdf1d5d9d 100644 --- a/src/ui/server/routes/insurance/your-buyer/index.ts +++ b/src/ui/server/routes/insurance/your-buyer/index.ts @@ -14,6 +14,7 @@ import { get as getTradingHistory, post as postTradingHistory } from '../../../c import { post as postTradingHistorySaveAndBack } from '../../../controllers/insurance/your-buyer/trading-history/save-and-back'; import { get as getCurrencyOfLatePayments, post as postCurrencyOfLatePayments } from '../../../controllers/insurance/your-buyer/currency-of-late-payments'; +import { post as postCurrencyOfLatePaymentsSaveAndBack } from '../../../controllers/insurance/your-buyer/currency-of-late-payments/save-and-back'; import { get as getOutstandingOrOverduePayments, @@ -74,6 +75,7 @@ yourBuyerRouter.post(`/:referenceNumber${YOUR_BUYER.TRADING_HISTORY_CHECK_AND_CH yourBuyerRouter.get(`/:referenceNumber${YOUR_BUYER.CURRENCY_OF_LATE_PAYMENTS}`, getCurrencyOfLatePayments); yourBuyerRouter.post(`/:referenceNumber${YOUR_BUYER.CURRENCY_OF_LATE_PAYMENTS}`, postCurrencyOfLatePayments); +yourBuyerRouter.post(`/:referenceNumber${YOUR_BUYER.CURRENCY_OF_LATE_PAYMENTS_SAVE_AND_BACK}`, postCurrencyOfLatePaymentsSaveAndBack); yourBuyerRouter.get(`/:referenceNumber${YOUR_BUYER.CURRENCY_OF_LATE_PAYMENTS_CHANGE}`, getCurrencyOfLatePayments); yourBuyerRouter.post(`/:referenceNumber${YOUR_BUYER.CURRENCY_OF_LATE_PAYMENTS_CHANGE}`, postCurrencyOfLatePayments); yourBuyerRouter.get(`/:referenceNumber${YOUR_BUYER.CURRENCY_OF_LATE_PAYMENTS_CHECK_AND_CHANGE}`, getCurrencyOfLatePayments); diff --git a/src/ui/templates/insurance/export-contract/how-much-is-the-agent-charging.njk b/src/ui/templates/insurance/export-contract/how-much-the-agent-is-charging.njk similarity index 100% rename from src/ui/templates/insurance/export-contract/how-much-is-the-agent-charging.njk rename to src/ui/templates/insurance/export-contract/how-much-the-agent-is-charging.njk diff --git a/src/ui/templates/shared-pages/alternative-currency.njk b/src/ui/templates/shared-pages/currency.njk similarity index 100% rename from src/ui/templates/shared-pages/alternative-currency.njk rename to src/ui/templates/shared-pages/currency.njk