diff --git a/CHANGELOG.md b/CHANGELOG.md index a6acdc7891..ecfeaa3c51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,72 +2,65 @@ ## [2.36.3](https://github.com/UK-Export-Finance/exip/compare/v2.36.2...v2.36.3) (2024-11-14) - ### Bug Fixes -* **EMS-3988:** apply - type of policy - hint text ([#3305](https://github.com/UK-Export-Finance/exip/issues/3305)) ([885194b](https://github.com/UK-Export-Finance/exip/commit/885194b3bffed7c4e28fd1767406495ed75b7e56)) +- **EMS-3988:** apply - type of policy - hint text ([#3305](https://github.com/UK-Export-Finance/exip/issues/3305)) ([885194b](https://github.com/UK-Export-Finance/exip/commit/885194b3bffed7c4e28fd1767406495ed75b7e56)) ## [2.36.2](https://github.com/UK-Export-Finance/exip/compare/v2.36.1...v2.36.2) (2024-11-13) - ### Bug Fixes -* **EMS-3988:** regenerate api schema ([#3301](https://github.com/UK-Export-Finance/exip/issues/3301)) ([81b382c](https://github.com/UK-Export-Finance/exip/commit/81b382c4039f089101623f2b1a740a1a97ce9797)) +- **EMS-3988:** regenerate api schema ([#3301](https://github.com/UK-Export-Finance/exip/issues/3301)) ([81b382c](https://github.com/UK-Export-Finance/exip/commit/81b382c4039f089101623f2b1a740a1a97ce9797)) ## [2.36.1](https://github.com/UK-Export-Finance/exip/compare/v2.36.0...v2.36.1) (2024-11-13) - ### Bug Fixes -* **EMS-3988:** quote tool - type of policy - hint text ([3bd562c](https://github.com/UK-Export-Finance/exip/commit/3bd562ca8df1c85c787137e251f62c4b601d9a45)) +- **EMS-3988:** quote tool - type of policy - hint text ([3bd562c](https://github.com/UK-Export-Finance/exip/commit/3bd562ca8df1c85c787137e251f62c4b601d9a45)) ## [2.36.0](https://github.com/UK-Export-Finance/exip/compare/v2.35.5...v2.36.0) (2024-11-01) - ### Features -* **EMS-3767-3768-3781:** business - turnover currency page and check your answers ([#2987](https://github.com/UK-Export-Finance/exip/issues/2987)) ([869054b](https://github.com/UK-Export-Finance/exip/commit/869054b49ce984d928a7a90af911614f38804ca3)) -* **EMS-3769-3770-3771-3772-3782:** buyer - split outstanding/overdue and failed payments ([#3012](https://github.com/UK-Export-Finance/exip/issues/3012)) ([00a704b](https://github.com/UK-Export-Finance/exip/commit/00a704b1bbada6f3b274a52305421abbb660c800)) -* **EMS-3773-3792:** policy - single contract - credit limit field ([#3026](https://github.com/UK-Export-Finance/exip/issues/3026)) ([ef3edaf](https://github.com/UK-Export-Finance/exip/commit/ef3edafd00a5ed8e956578086159f54b87848c68)) -* **EMS-3783-3792:** policy - check/change your answers - credit limit field ([#3029](https://github.com/UK-Export-Finance/exip/issues/3029)) ([76d8bad](https://github.com/UK-Export-Finance/exip/commit/76d8badc3537c1d6a570e918400dd8aaa870d1b5)) -* **EMS-3825:** export contract - remove fixed sum amount from the ui ([#3051](https://github.com/UK-Export-Finance/exip/issues/3051)) ([a01d96b](https://github.com/UK-Export-Finance/exip/commit/a01d96b937ddcf94bdb90fb17d4bb861d0931808)) -* **EMS-3826-3827:** export contract - agent charges currency - page setup ([#3067](https://github.com/UK-Export-Finance/exip/issues/3067)) ([e059ccc](https://github.com/UK-Export-Finance/exip/commit/e059ccc5310ffb704214bd02439039c6434bbe89)) -* **EMS-3826-3829:** export contract - agent charges - user flow ([#3098](https://github.com/UK-Export-Finance/exip/issues/3098)) ([be6a35a](https://github.com/UK-Export-Finance/exip/commit/be6a35a7aca016b80845f53efa9afa4f2bd48abb)) -* **EMS-3828-3876:** currency of agent charges - save and back, improve e2e assertions ([#3101](https://github.com/UK-Export-Finance/exip/issues/3101)) ([f9769ee](https://github.com/UK-Export-Finance/exip/commit/f9769ee48e17d7b3284f52a0886eb2b8e987c18c)) -* **EMS-3829:** export contract - how much is the agent charging - page setup, validation ([#3072](https://github.com/UK-Export-Finance/exip/issues/3072)) ([42e4c11](https://github.com/UK-Export-Finance/exip/commit/42e4c11f8b52a01db279172bb05277887686d2a7)) -* **EMS-3833:** export contract - how much agent is charging - data saving ([#3122](https://github.com/UK-Export-Finance/exip/issues/3122)) ([cd6398b](https://github.com/UK-Export-Finance/exip/commit/cd6398b21f6e7905c1f43ac855af2d26ad332f99)) -* **EMS-3851-3852:** export contract - change answers - currency of agent charges ([#3132](https://github.com/UK-Export-Finance/exip/issues/3132)) ([e3fa1ae](https://github.com/UK-Export-Finance/exip/commit/e3fa1ae3adff3be04cff8aaf41e5da902dea4cb8)) -* **EMS-3853-54-55:** export contract - agent charges - change answers ([#3142](https://github.com/UK-Export-Finance/exip/issues/3142)) ([3087bed](https://github.com/UK-Export-Finance/exip/commit/3087bed0e2e40fad8d581af7ceeacab315b407ad)) -* **EMS-3877-3879:** business - turnover currency - save and back ([#3129](https://github.com/UK-Export-Finance/exip/issues/3129)) ([ff4fcf4](https://github.com/UK-Export-Finance/exip/commit/ff4fcf465c015edd689807be6ade950eca609c7b)) -* **EMS-3893:** buyer - currency of late payments - save and back ([#3128](https://github.com/UK-Export-Finance/exip/issues/3128)) ([1a59d47](https://github.com/UK-Export-Finance/exip/commit/1a59d470c2e4f4d1e7c2f333f45137da5861fa10)) - +- **EMS-3767-3768-3781:** business - turnover currency page and check your answers ([#2987](https://github.com/UK-Export-Finance/exip/issues/2987)) ([869054b](https://github.com/UK-Export-Finance/exip/commit/869054b49ce984d928a7a90af911614f38804ca3)) +- **EMS-3769-3770-3771-3772-3782:** buyer - split outstanding/overdue and failed payments ([#3012](https://github.com/UK-Export-Finance/exip/issues/3012)) ([00a704b](https://github.com/UK-Export-Finance/exip/commit/00a704b1bbada6f3b274a52305421abbb660c800)) +- **EMS-3773-3792:** policy - single contract - credit limit field ([#3026](https://github.com/UK-Export-Finance/exip/issues/3026)) ([ef3edaf](https://github.com/UK-Export-Finance/exip/commit/ef3edafd00a5ed8e956578086159f54b87848c68)) +- **EMS-3783-3792:** policy - check/change your answers - credit limit field ([#3029](https://github.com/UK-Export-Finance/exip/issues/3029)) ([76d8bad](https://github.com/UK-Export-Finance/exip/commit/76d8badc3537c1d6a570e918400dd8aaa870d1b5)) +- **EMS-3825:** export contract - remove fixed sum amount from the ui ([#3051](https://github.com/UK-Export-Finance/exip/issues/3051)) ([a01d96b](https://github.com/UK-Export-Finance/exip/commit/a01d96b937ddcf94bdb90fb17d4bb861d0931808)) +- **EMS-3826-3827:** export contract - agent charges currency - page setup ([#3067](https://github.com/UK-Export-Finance/exip/issues/3067)) ([e059ccc](https://github.com/UK-Export-Finance/exip/commit/e059ccc5310ffb704214bd02439039c6434bbe89)) +- **EMS-3826-3829:** export contract - agent charges - user flow ([#3098](https://github.com/UK-Export-Finance/exip/issues/3098)) ([be6a35a](https://github.com/UK-Export-Finance/exip/commit/be6a35a7aca016b80845f53efa9afa4f2bd48abb)) +- **EMS-3828-3876:** currency of agent charges - save and back, improve e2e assertions ([#3101](https://github.com/UK-Export-Finance/exip/issues/3101)) ([f9769ee](https://github.com/UK-Export-Finance/exip/commit/f9769ee48e17d7b3284f52a0886eb2b8e987c18c)) +- **EMS-3829:** export contract - how much is the agent charging - page setup, validation ([#3072](https://github.com/UK-Export-Finance/exip/issues/3072)) ([42e4c11](https://github.com/UK-Export-Finance/exip/commit/42e4c11f8b52a01db279172bb05277887686d2a7)) +- **EMS-3833:** export contract - how much agent is charging - data saving ([#3122](https://github.com/UK-Export-Finance/exip/issues/3122)) ([cd6398b](https://github.com/UK-Export-Finance/exip/commit/cd6398b21f6e7905c1f43ac855af2d26ad332f99)) +- **EMS-3851-3852:** export contract - change answers - currency of agent charges ([#3132](https://github.com/UK-Export-Finance/exip/issues/3132)) ([e3fa1ae](https://github.com/UK-Export-Finance/exip/commit/e3fa1ae3adff3be04cff8aaf41e5da902dea4cb8)) +- **EMS-3853-54-55:** export contract - agent charges - change answers ([#3142](https://github.com/UK-Export-Finance/exip/issues/3142)) ([3087bed](https://github.com/UK-Export-Finance/exip/commit/3087bed0e2e40fad8d581af7ceeacab315b407ad)) +- **EMS-3877-3879:** business - turnover currency - save and back ([#3129](https://github.com/UK-Export-Finance/exip/issues/3129)) ([ff4fcf4](https://github.com/UK-Export-Finance/exip/commit/ff4fcf465c015edd689807be6ade950eca609c7b)) +- **EMS-3893:** buyer - currency of late payments - save and back ([#3128](https://github.com/UK-Export-Finance/exip/issues/3128)) ([1a59d47](https://github.com/UK-Export-Finance/exip/commit/1a59d470c2e4f4d1e7c2f333f45137da5861fa10)) ### Bug Fixes -* **EMS-3511:** task list - declarations/submit dependencies ([#2965](https://github.com/UK-Export-Finance/exip/issues/2965)) ([57b5c8f](https://github.com/UK-Export-Finance/exip/commit/57b5c8f5491d3c0671ec44b3af049305e66f23f2)) -* **EMS-3659:** declarations - confirmation/acknowledgements - submit button copy ([#2960](https://github.com/UK-Export-Finance/exip/issues/2960)) ([d183d21](https://github.com/UK-Export-Finance/exip/commit/d183d210e1cee28e538f1ec938fd64fb8c5b9f1e)) -* **EMS-3755:** fix failing e2e tests ([#2949](https://github.com/UK-Export-Finance/exip/issues/2949)) ([994e19a](https://github.com/UK-Export-Finance/exip/commit/994e19a3c692a4ba88c5f6b406e29af16ad509e5)) -* **EMS-3787:** export contract - agent name with an apostrophe ([#2989](https://github.com/UK-Export-Finance/exip/issues/2989)) ([7f64dcf](https://github.com/UK-Export-Finance/exip/commit/7f64dcf4fd244ef8fdc4b634a31a44dccec642a4)) -* **EMS-3804:** eligibility - end buyer - error message ([#3049](https://github.com/UK-Export-Finance/exip/issues/3049)) ([3a02b8c](https://github.com/UK-Export-Finance/exip/commit/3a02b8c85f5476d5faa3064f97034aa730b54549)) -* **EMS-3822:** your buyer - outstanding/overdue payments - label currencies ([#3048](https://github.com/UK-Export-Finance/exip/issues/3048)) ([c905028](https://github.com/UK-Export-Finance/exip/commit/c905028e9c12138fcf514204ec550502650ba807)) -* **EMS-3831:** buyer - outstanding/overdue payments - missing hint text ([#3120](https://github.com/UK-Export-Finance/exip/issues/3120)) ([adedd9a](https://github.com/UK-Export-Finance/exip/commit/adedd9a8594ebd42645de4e2ac5bf2c5a1d1b9eb)) -* **EMS-3901:** data migration - requestedCreditLimit column ([#3255](https://github.com/UK-Export-Finance/exip/issues/3255)) ([cf86b8e](https://github.com/UK-Export-Finance/exip/commit/cf86b8e0d6b5876fd8806726e5fb5c769f2a0ca2)) -* **EMS-3945:** policy - total contract value - credit limit hint ([#3197](https://github.com/UK-Export-Finance/exip/issues/3197)) ([f562f23](https://github.com/UK-Export-Finance/exip/commit/f562f23e71821155ff04d1132c89ea8fdca8573a)) -* **EMS-3959:** multiple contract policy - error message/hint ([c266b2e](https://github.com/UK-Export-Finance/exip/commit/c266b2e7895d7a21ae2d43f413086fb437c5fe21)) +- **EMS-3511:** task list - declarations/submit dependencies ([#2965](https://github.com/UK-Export-Finance/exip/issues/2965)) ([57b5c8f](https://github.com/UK-Export-Finance/exip/commit/57b5c8f5491d3c0671ec44b3af049305e66f23f2)) +- **EMS-3659:** declarations - confirmation/acknowledgements - submit button copy ([#2960](https://github.com/UK-Export-Finance/exip/issues/2960)) ([d183d21](https://github.com/UK-Export-Finance/exip/commit/d183d210e1cee28e538f1ec938fd64fb8c5b9f1e)) +- **EMS-3755:** fix failing e2e tests ([#2949](https://github.com/UK-Export-Finance/exip/issues/2949)) ([994e19a](https://github.com/UK-Export-Finance/exip/commit/994e19a3c692a4ba88c5f6b406e29af16ad509e5)) +- **EMS-3787:** export contract - agent name with an apostrophe ([#2989](https://github.com/UK-Export-Finance/exip/issues/2989)) ([7f64dcf](https://github.com/UK-Export-Finance/exip/commit/7f64dcf4fd244ef8fdc4b634a31a44dccec642a4)) +- **EMS-3804:** eligibility - end buyer - error message ([#3049](https://github.com/UK-Export-Finance/exip/issues/3049)) ([3a02b8c](https://github.com/UK-Export-Finance/exip/commit/3a02b8c85f5476d5faa3064f97034aa730b54549)) +- **EMS-3822:** your buyer - outstanding/overdue payments - label currencies ([#3048](https://github.com/UK-Export-Finance/exip/issues/3048)) ([c905028](https://github.com/UK-Export-Finance/exip/commit/c905028e9c12138fcf514204ec550502650ba807)) +- **EMS-3831:** buyer - outstanding/overdue payments - missing hint text ([#3120](https://github.com/UK-Export-Finance/exip/issues/3120)) ([adedd9a](https://github.com/UK-Export-Finance/exip/commit/adedd9a8594ebd42645de4e2ac5bf2c5a1d1b9eb)) +- **EMS-3901:** data migration - requestedCreditLimit column ([#3255](https://github.com/UK-Export-Finance/exip/issues/3255)) ([cf86b8e](https://github.com/UK-Export-Finance/exip/commit/cf86b8e0d6b5876fd8806726e5fb5c769f2a0ca2)) +- **EMS-3945:** policy - total contract value - credit limit hint ([#3197](https://github.com/UK-Export-Finance/exip/issues/3197)) ([f562f23](https://github.com/UK-Export-Finance/exip/commit/f562f23e71821155ff04d1132c89ea8fdca8573a)) +- **EMS-3959:** multiple contract policy - error message/hint ([c266b2e](https://github.com/UK-Export-Finance/exip/commit/c266b2e7895d7a21ae2d43f413086fb437c5fe21)) ## [2.35.5](https://github.com/UK-Export-Finance/exip/compare/v2.35.4...v2.35.5) (2024-08-12) - ### Bug Fixes -* **EMS-3633:** data migration - xlsx - total contract value ([#2934](https://github.com/UK-Export-Finance/exip/issues/2934)) ([f0bfdba](https://github.com/UK-Export-Finance/exip/commit/f0bfdba5d1b1300018ab67b0224c2dfeb6993e4c)) +- **EMS-3633:** data migration - xlsx - total contract value ([#2934](https://github.com/UK-Export-Finance/exip/issues/2934)) ([f0bfdba](https://github.com/UK-Export-Finance/exip/commit/f0bfdba5d1b1300018ab67b0224c2dfeb6993e4c)) ## [2.35.4](https://github.com/UK-Export-Finance/exip/compare/v2.35.3...v2.35.4) (2024-08-09) - ### Bug Fixes -* **EMS-3633:** data migration - xlsx - eligibility questions ([#2932](https://github.com/UK-Export-Finance/exip/issues/2932)) ([f80ac41](https://github.com/UK-Export-Finance/exip/commit/f80ac410e050353a055ed4d1ca462c7bc96c617c)) +- **EMS-3633:** data migration - xlsx - eligibility questions ([#2932](https://github.com/UK-Export-Finance/exip/issues/2932)) ([f80ac41](https://github.com/UK-Export-Finance/exip/commit/f80ac410e050353a055ed4d1ca462c7bc96c617c)) ## [2.35.3](https://github.com/UK-Export-Finance/exip/compare/v2.35.2...v2.35.3) (2024-08-09) diff --git a/e2e-tests/commands/api/index.js b/e2e-tests/commands/api/index.js index 7146750647..61b40c340a 100644 --- a/e2e-tests/commands/api/index.js +++ b/e2e-tests/commands/api/index.js @@ -274,7 +274,7 @@ const createApplications = (accountId, count) => { return responseBody; } catch (error) { - console.error('Creating applications', error); + console.error('Creating applications %o', error); throw new Error('Creating applications', { error }); } diff --git a/e2e-tests/commands/core-page-checks.js b/e2e-tests/commands/core-page-checks.js index cf1a1fec14..fdf13a88fa 100644 --- a/e2e-tests/commands/core-page-checks.js +++ b/e2e-tests/commands/core-page-checks.js @@ -21,7 +21,6 @@ const baseUrl = Cypress.config('baseUrl'); * @param {String} expectedHref - Expected "back" HREF/route */ const checkBackLink = (currentHref, expectedHref) => { - backLinkSelector().should('exist'); cy.checkText(backLinkSelector(), LINKS.BACK); cy.clickBackLink(); diff --git a/e2e-tests/commands/insurance/account/assert-password-reveal-button.js b/e2e-tests/commands/insurance/account/assert-password-reveal-button.js index aab487d6fd..a7124281d6 100644 --- a/e2e-tests/commands/insurance/account/assert-password-reveal-button.js +++ b/e2e-tests/commands/insurance/account/assert-password-reveal-button.js @@ -14,8 +14,6 @@ const EXPECTED_ARIA_LABELS = { }; const shouldRender = () => { - passwordField.revealButton().should('exist'); - cy.checkText(passwordField.revealButton(), FIELD_STRINGS.REVEAL.SHOW); cy.checkAriaLabel(passwordField.revealButton(), EXPECTED_ARIA_LABELS.SHOW); }; diff --git a/e2e-tests/commands/insurance/account/delete-account.js b/e2e-tests/commands/insurance/account/delete-account.js index d1c9cc3944..3da8f81393 100644 --- a/e2e-tests/commands/insurance/account/delete-account.js +++ b/e2e-tests/commands/insurance/account/delete-account.js @@ -14,7 +14,7 @@ const deleteAccount = (email = accountEmail) => { return deleteResponse; } catch (error) { - console.error('Deleting account', error); + console.error('Deleting account %o', error); return error; } diff --git a/e2e-tests/commands/insurance/complete-and-submit-export-value-form.js b/e2e-tests/commands/insurance/complete-and-submit-export-value-form.js index dfdae296a2..da73cdee85 100644 --- a/e2e-tests/commands/insurance/complete-and-submit-export-value-form.js +++ b/e2e-tests/commands/insurance/complete-and-submit-export-value-form.js @@ -1,9 +1,12 @@ /** * completeAndSubmitExportValueForm * Complete and submit the "Export value" form + * @param {String} totalSalesToBuyer: Total sales to the buyer + * @param {String} maximumBuyerWillOwe: Maximum buyer will owe */ -const completeAndSubmitExportValueForm = () => { - cy.completeExportValueForm(); +const completeAndSubmitExportValueForm = ({ totalSalesToBuyer, maximumBuyerWillOwe }) => { + cy.completeExportValueForm({ totalSalesToBuyer, maximumBuyerWillOwe }); + cy.clickSubmitButton(); }; diff --git a/e2e-tests/commands/insurance/complete-export-value-form.js b/e2e-tests/commands/insurance/complete-export-value-form.js index 0a42941ddc..e8b9c737ce 100644 --- a/e2e-tests/commands/insurance/complete-export-value-form.js +++ b/e2e-tests/commands/insurance/complete-export-value-form.js @@ -12,11 +12,16 @@ const { /** * completeExportValueForm * Complete the "Export value" form + * @param {String} totalSalesToBuyer: Total sales to the buyer + * @param {String} maximumBuyerWillOwe: Maximum buyer will owe */ -const completeExportValueForm = () => { - cy.keyboardInput(field(TOTAL_SALES_TO_BUYER).input(), application.POLICY[TOTAL_SALES_TO_BUYER]); +const completeExportValueForm = ({ + totalSalesToBuyer = application.POLICY[TOTAL_SALES_TO_BUYER], + maximumBuyerWillOwe = application.POLICY[MAXIMUM_BUYER_WILL_OWE], +}) => { + cy.keyboardInput(field(TOTAL_SALES_TO_BUYER).input(), totalSalesToBuyer); - cy.keyboardInput(multipleContractPolicyExportValuePage[MAXIMUM_BUYER_WILL_OWE].input(), application.POLICY[MAXIMUM_BUYER_WILL_OWE]); + cy.keyboardInput(multipleContractPolicyExportValuePage[MAXIMUM_BUYER_WILL_OWE].input(), maximumBuyerWillOwe); }; export default completeExportValueForm; diff --git a/e2e-tests/commands/insurance/complete-policy-section.js b/e2e-tests/commands/insurance/complete-policy-section.js index f1a9d8aea9..146a05136d 100644 --- a/e2e-tests/commands/insurance/complete-policy-section.js +++ b/e2e-tests/commands/insurance/complete-policy-section.js @@ -10,6 +10,7 @@ const { POLICY_TYPE } = APPLICATION; * @param {Boolean} policyValueOverMvpMaximum: If the value should be over the MVP maximum amount * @param {String} isoCode: Policy currency ISO code * @param {Boolean} alternativeCurrency: Select the "alternative currency" option + * @param {String} maximumBuyerWillOwe: Maximum buyer will owe * @param {Boolean} sameName: If name on policy is the same as the signed in user - defaults to true * @param {Boolean} needPreCreditPeriod: If the user needs a pre-credit period - defaults to false * @param {Boolean} usingBroker: If "using broker" on - defaults to false @@ -24,6 +25,7 @@ const completePolicySection = ({ policyValueOverMvpMaximum = false, isoCode, alternativeCurrency = false, + maximumBuyerWillOwe, sameName = true, needPreCreditPeriod = false, usingBroker = false, @@ -49,7 +51,7 @@ const completePolicySection = ({ alternativeCurrency, }); - cy.completeAndSubmitExportValueForm({ policyType }); + cy.completeAndSubmitExportValueForm({ maximumBuyerWillOwe }); } cy.completeAndSubmitNameOnPolicyForm({ sameName }); 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 defcc32ca6..f738d5f622 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 @@ -22,6 +22,7 @@ const { POLICY_TYPE } = APPLICATION; * @param {Boolean} contractAwardedNegotiatedContract: "How was the contract awarded" method as NEGOTIATED_CONTRACT * @param {Boolean} contractAwardedOpenTender: "How was the contract awarded" method as OPEN_TENDER * @param {Boolean} contractAwardedOtherMethod: "How was the contract awarded" method as OTHER + * @param {String} maximumBuyerWillOwe: Maximum buyer will owe * @param {Boolean} differentPolicyContact: Should submit an application with a different policy contact to the owner. * @param {Boolean} differentTradingName: Should submit "yes" to "have a different trading name" in the "company details" form. * @param {Boolean} differentTradingAddress: Should submit "yes" to "trade from a different address" in the "company details" form. @@ -59,6 +60,7 @@ const completePrepareApplicationMultiplePolicyType = ({ contractAwardedNegotiatedContract = false, contractAwardedOpenTender = true, contractAwardedOtherMethod = false, + maximumBuyerWillOwe, differentPolicyContact = false, differentTradingName = false, differentTradingAddress = false, @@ -102,6 +104,7 @@ const completePrepareApplicationMultiplePolicyType = ({ cy.completePolicySection({ policyType: POLICY_TYPE.MULTIPLE, + maximumBuyerWillOwe, sameName: !differentPolicyContact, policyValueOverMvpMaximum, submitCheckYourAnswers, 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 a980c709a5..a09e49777c 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 @@ -20,6 +20,7 @@ import completeSignInAndGoToApplication from './account/complete-sign-in-and-go- * @param {Boolean} buyerFailedToPayOnTime: Buyer has failed to pay the exporter on the time. * @param {String} companyNumber: Company number/Companies house number * @param {Boolean} contractAwardedOtherMethod: "How was the contract awarded" method as "other" + * @param {String} maximumBuyerWillOwe: Maximum buyer will owe * @param {Boolean} createApplicationViaApi: Flag whether to create the application via API instead of going through the eligibility journey. * @param {Boolean} differentPolicyContact: Should submit an application with a different policy contact to the owner. * @param {Boolean} differentTradingName: Should submit "yes" to "have a different trading name" in the "company details" form. @@ -56,6 +57,7 @@ const completeSignInAndSubmitAnApplication = ({ createApplicationViaApi, companyNumber, contractAwardedOtherMethod = false, + maximumBuyerWillOwe, differentPolicyContact = false, differentTradingName = false, differentTradingAddress = false, @@ -95,6 +97,7 @@ const completeSignInAndSubmitAnApplication = ({ buyerOutstandingPayments, buyerFailedToPayOnTime, contractAwardedOtherMethod, + maximumBuyerWillOwe, differentPolicyContact, differentTradingName, differentTradingAddress, diff --git a/e2e-tests/commands/insurance/create-an-abandoned-application.js b/e2e-tests/commands/insurance/create-an-abandoned-application.js index 183ba80b68..9fe28869b0 100644 --- a/e2e-tests/commands/insurance/create-an-abandoned-application.js +++ b/e2e-tests/commands/insurance/create-an-abandoned-application.js @@ -31,7 +31,7 @@ const createAnAbandonedApplication = (accountId) => { return api.createAnAbandonedApplication(accountId, mockEligibilityAnswers, company, sectionReview).then((application) => application); } catch (error) { - console.error('Creating an abandoned application', error); + console.error('Creating an abandoned application %o', error); return error; } diff --git a/e2e-tests/commands/insurance/create-an-application.js b/e2e-tests/commands/insurance/create-an-application.js index ebfa4858cd..2d53fd58d5 100644 --- a/e2e-tests/commands/insurance/create-an-application.js +++ b/e2e-tests/commands/insurance/create-an-application.js @@ -58,7 +58,7 @@ const createAnApplication = (accountId, companyNumber, totalContractValueOverThr return api.createAnApplication(accountId, mockEligibilityAnswers, company, sectionReview).then((application) => application); } catch (error) { - console.error('Creating an application', error); + console.error('Creating an application %o', error); return error; } diff --git a/e2e-tests/commands/insurance/create-applications.js b/e2e-tests/commands/insurance/create-applications.js index 1ce0a3a5d6..274a7cb7dd 100644 --- a/e2e-tests/commands/insurance/create-applications.js +++ b/e2e-tests/commands/insurance/create-applications.js @@ -14,7 +14,7 @@ const createApplications = (accountId, count) => { try { return api.createApplications(accountId, count).then((applications) => applications); } catch (error) { - console.error('Creating applications', error); + console.error('Creating applications %o', error); return error; } } diff --git a/e2e-tests/commands/insurance/declarations/complete-and-submit-declarations-forms.js b/e2e-tests/commands/insurance/declarations/complete-and-submit-declarations-forms.js index 54e6a0bb55..96b819d1d2 100644 --- a/e2e-tests/commands/insurance/declarations/complete-and-submit-declarations-forms.js +++ b/e2e-tests/commands/insurance/declarations/complete-and-submit-declarations-forms.js @@ -2,10 +2,10 @@ * completeAndDeclarationsForms * completes declarations forms up to the specified form to stop at * eg, when 'antiBribery' is passed, it will complete all forms up to and including 'antiBribery' - * @param {String} formToStopAt: the form to stop at - * @param {String} referenceNumber: application reference number + * @param {String} stopSubmittingAfter: The final form to submit + * @param {String} referenceNumber: Application reference number */ -const completeAndSubmitDeclarationsForms = ({ formToStopAt, referenceNumber }) => { +const completeAndSubmitDeclarationsForms = ({ stopSubmittingAfter, referenceNumber }) => { cy.completePrepareApplicationSinglePolicyType({ referenceNumber }); cy.completeAndSubmitCheckYourAnswers(); @@ -27,7 +27,7 @@ const completeAndSubmitDeclarationsForms = ({ formToStopAt, referenceNumber }) = for (const step of steps) { step.action(); - if (step.name === formToStopAt) { + if (step.name === stopSubmittingAfter) { break; } } diff --git a/e2e-tests/commands/insurance/eligibility/complete-and-submit-eligibility-forms.js b/e2e-tests/commands/insurance/eligibility/complete-and-submit-eligibility-forms.js index 3d49a99b5f..3f9d77975e 100644 --- a/e2e-tests/commands/insurance/eligibility/complete-and-submit-eligibility-forms.js +++ b/e2e-tests/commands/insurance/eligibility/complete-and-submit-eligibility-forms.js @@ -2,13 +2,13 @@ * completeAndSubmitEligibilityForms * completes eligibility forms up to the specified form to stop at * eg, when 'companyDetails' is passed, it will complete all forms up to and including 'companyDetails' - * @param {String} formToStopAt: the form to stop at + * @param {String} stopSubmittingAfter: The final form to submit * @param {String} companyNumber: the company number to use in the companies house search form * @param {Boolean} coverPeriodIsUnderThreshold: whether the cover period is under the threshold * @param {Boolean} memberOfAGroup: whether the company is a member of a group * @param {Boolean} partyToConsortium: whether the company is a party to a consortium */ -const completeAndSubmitEligibilityForms = ({ formToStopAt, companyNumber, coverPeriodIsUnderThreshold, memberOfAGroup, partyToConsortium }) => { +const completeAndSubmitEligibilityForms = ({ stopSubmittingAfter, companyNumber, coverPeriodIsUnderThreshold, memberOfAGroup, partyToConsortium }) => { cy.navigateToCheckIfEligibleUrl(); const steps = [ @@ -33,7 +33,7 @@ const completeAndSubmitEligibilityForms = ({ formToStopAt, companyNumber, coverP for (const step of steps) { step.action(); - if (step.name === formToStopAt) { + if (step.name === stopSubmittingAfter) { break; } } 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 13f96d932c..34b3a0cd3a 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 @@ -2,7 +2,7 @@ * completeAndSubmitExportContractForms * completes export contract forms up to the specified form to stop at * eg, when 'aboutGoodsOrServices' is passed, it will complete all forms up to and including 'aboutGoodsOrServices' - * @param {String} formToStopAt: the form to stop at + * @param {String} stopSubmittingAfter: The final form to submit * @param {Boolean} viaTaskList: Start the "export contract" section from the task list. * @param {Boolean} finalDestinationKnown: whether the final destination is known * @param {Boolean} totalContractValueOverThreshold: whether total contract value is over threshold @@ -13,7 +13,7 @@ * @param {String} fixedSumAmount: Fixed sum amount */ const completeAndSubmitExportContractForms = ({ - formToStopAt, + stopSubmittingAfter, viaTaskList, finalDestinationKnown, totalContractValueOverThreshold, @@ -61,7 +61,7 @@ const completeAndSubmitExportContractForms = ({ for (const step of steps) { step.action(); - if (step.name === formToStopAt) { + if (step.name === stopSubmittingAfter) { break; } } diff --git a/e2e-tests/commands/insurance/policy/complete-and-submit-policy-forms.js b/e2e-tests/commands/insurance/policy/complete-and-submit-policy-forms.js index f5139e0d90..a244ec3d13 100644 --- a/e2e-tests/commands/insurance/policy/complete-and-submit-policy-forms.js +++ b/e2e-tests/commands/insurance/policy/complete-and-submit-policy-forms.js @@ -6,7 +6,7 @@ const { SINGLE } = APPLICATION.POLICY_TYPE; * completeAndPolicyForms * completes policy forms up to the specified form to stop at * eg, when 'exportValue' is passed, it will complete all forms up to and including 'exportValue' - * @param {String} formToStopAt: the form to stop at + * @param {String} stopSubmittingAfter: The final form to submit * @param {String} policyType: Single or multiple. Defaults to single. * @param {Boolean} sameName: if name on policy is the same as the signed in user - defaults to true * @param {Boolean} usingBroker: Should submit "yes" or "no" to "using a broker" @@ -17,7 +17,7 @@ const { SINGLE } = APPLICATION.POLICY_TYPE; * @param {Boolean} otherCompanyInvolved: If "another company to be insured" is on. */ const completeAndPolicyForms = ({ - formToStopAt, + stopSubmittingAfter, policyType = SINGLE, sameName = true, usingBroker, @@ -42,7 +42,7 @@ const completeAndPolicyForms = ({ name: 'multipleContractPolicy', action: () => cy.completeAndSubmitMultipleContractPolicyForm({ isoCode, alternativeCurrency }), }); - steps.push({ name: 'exportValue', action: () => cy.completeAndSubmitExportValueForm({ policyType }) }); + steps.push({ name: 'exportValue', action: () => cy.completeAndSubmitExportValueForm({}) }); } steps.push({ name: 'nameOnPolicy', action: () => cy.completeAndSubmitNameOnPolicyForm({ sameName }) }); @@ -67,7 +67,7 @@ const completeAndPolicyForms = ({ for (const step of steps) { step.action(); - if (step.name === formToStopAt) { + if (step.name === stopSubmittingAfter) { break; } } diff --git a/e2e-tests/commands/insurance/your-business/complete-and-submit-your-business-forms.js b/e2e-tests/commands/insurance/your-business/complete-and-submit-your-business-forms.js index a39e7be626..dd0829df6f 100644 --- a/e2e-tests/commands/insurance/your-business/complete-and-submit-your-business-forms.js +++ b/e2e-tests/commands/insurance/your-business/complete-and-submit-your-business-forms.js @@ -2,12 +2,12 @@ * completeAndSubmitYourBusinessForms * completes your business forms up to the specified form to stop at * eg, when 'turnover' is passed, it will complete all forms up to and including 'turnover' - * @param {String} formToStopAt: the form to stop at + * @param {String} stopSubmittingAfter: The final form to submit * @param {Boolean} hasCreditControlProcess: whether the exporter has a credit control process * @param {Boolean} differentTradingAddress: whether the exporter has a different trading address * @param {Boolean} differentTradingName: whether the exporter has a different trading name */ -const completeAndSubmitYourBusinessForms = ({ formToStopAt, hasCreditControlProcess, differentTradingAddress, differentTradingName }) => { +const completeAndSubmitYourBusinessForms = ({ stopSubmittingAfter, hasCreditControlProcess, differentTradingAddress, differentTradingName }) => { cy.startYourBusinessSection({}); const initialSteps = [{ name: 'companyDetails', action: () => cy.completeAndSubmitCompanyDetails({ differentTradingAddress, differentTradingName }) }]; @@ -31,7 +31,7 @@ const completeAndSubmitYourBusinessForms = ({ formToStopAt, hasCreditControlProc for (const step of steps) { step.action(); - if (step.name === formToStopAt) { + if (step.name === stopSubmittingAfter) { break; } } 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 d3d41c778f..55e1be364f 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 @@ -5,7 +5,7 @@ * @param {Boolean} alternativeCurrency: If alternative currency should be entered. * @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 + * @param {String} stopSubmittingAfter: The final form to submit * @param {Boolean} fullyPopulatedBuyerTradingHistory: whether to fully populate the buyer trading history form * @param {Boolean} hasConnectionToBuyer: whether the exporter has a connection with the buyer * @param {Boolean} exporterHasBuyerFinancialAccounts: whether the exporter has buyer financial accounts @@ -17,7 +17,7 @@ const completeAndSubmitYourBuyerForms = ({ alternativeCurrency, exporterHasTradedWithBuyer, failedToPay, - formToStopAt, + stopSubmittingAfter, fullyPopulatedBuyerTradingHistory, exporterHasBuyerFinancialAccounts, hasConnectionToBuyer, @@ -63,7 +63,7 @@ const completeAndSubmitYourBuyerForms = ({ for (const step of steps) { step.action(); - if (step.name === formToStopAt) { + if (step.name === stopSubmittingAfter) { break; } } diff --git a/e2e-tests/commands/shared-commands/assertions/assert-empty-agent-charges-field-values.js b/e2e-tests/commands/shared-commands/assertions/assert-empty-agent-charges-field-values.js index 1c5b42ac7e..e3bda2492d 100644 --- a/e2e-tests/commands/shared-commands/assertions/assert-empty-agent-charges-field-values.js +++ b/e2e-tests/commands/shared-commands/assertions/assert-empty-agent-charges-field-values.js @@ -14,7 +14,7 @@ const assertEmptyAgentChargesFieldValues = () => { cy.assertRadioOptionIsNotChecked(field(`${METHOD}-${FIXED_SUM}`).input()); cy.assertRadioOptionIsNotChecked(field(`${METHOD}-${PERCENTAGE}`).input()); - cy.checkValue(field(PERCENTAGE_CHARGE), ''); + cy.assertEmptyFieldValue(PERCENTAGE_CHARGE); checkAutocompleteInput.checkEmptyResults(COUNTRY_CODE); }; diff --git a/e2e-tests/commands/shared-commands/assertions/assert-empty-agent-details-field-values.js b/e2e-tests/commands/shared-commands/assertions/assert-empty-agent-details-field-values.js index 99a6197b40..43ef1acf95 100644 --- a/e2e-tests/commands/shared-commands/assertions/assert-empty-agent-details-field-values.js +++ b/e2e-tests/commands/shared-commands/assertions/assert-empty-agent-details-field-values.js @@ -1,4 +1,3 @@ -import { field } from '../../../pages/shared'; import FIELD_IDS from '../../../constants/field-ids/insurance/export-contract'; import { checkAutocompleteInput } from '../../../shared-test-assertions'; @@ -11,7 +10,7 @@ const { * Assert all field values in the "agent details" form are empty. */ const assertEmptyAgentDetailsFieldValues = () => { - cy.checkValue(field(NAME), ''); + cy.assertEmptyFieldValue(NAME); cy.checkTextareaValue({ fieldId: FULL_ADDRESS, diff --git a/e2e-tests/commands/shared-commands/assertions/assert-empty-autocomplete-field-value.js b/e2e-tests/commands/shared-commands/assertions/assert-empty-autocomplete-field-value.js new file mode 100644 index 0000000000..52cc8ad1bb --- /dev/null +++ b/e2e-tests/commands/shared-commands/assertions/assert-empty-autocomplete-field-value.js @@ -0,0 +1,12 @@ +import { autoCompleteField } from '../../../pages/shared'; + +/** + * assertEmptyAutocompleteFieldValue + * Assert that an autocomplete field value is empty. + * @param {String} fieldId: Field ID + */ +const assertEmptyAutocompleteFieldValue = (fieldId) => { + cy.checkValue(autoCompleteField(fieldId), ''); +}; + +export default assertEmptyAutocompleteFieldValue; diff --git a/e2e-tests/commands/shared-commands/assertions/assert-empty-field-value.js b/e2e-tests/commands/shared-commands/assertions/assert-empty-field-value.js new file mode 100644 index 0000000000..be4b9dc666 --- /dev/null +++ b/e2e-tests/commands/shared-commands/assertions/assert-empty-field-value.js @@ -0,0 +1,12 @@ +import { field } from '../../../pages/shared'; + +/** + * assertEmptyFieldValue + * Assert that a field value is empty. + * @param {String} fieldId: Field ID + */ +const assertEmptyFieldValue = (fieldId) => { + cy.checkValue(field(fieldId), ''); +}; + +export default assertEmptyFieldValue; diff --git a/e2e-tests/commands/shared-commands/assertions/assert-empty-loss-payee-details-field-values.js b/e2e-tests/commands/shared-commands/assertions/assert-empty-loss-payee-details-field-values.js index 0155e21d91..ac1284b085 100644 --- a/e2e-tests/commands/shared-commands/assertions/assert-empty-loss-payee-details-field-values.js +++ b/e2e-tests/commands/shared-commands/assertions/assert-empty-loss-payee-details-field-values.js @@ -10,7 +10,7 @@ const { * Assert all field values in the "loss payee details" form are empty. */ const assertEmptyLossPayeeDetailsFieldValues = () => { - cy.checkValue(field(NAME), ''); + cy.assertEmptyFieldValue(NAME); cy.assertRadioOptionIsNotChecked(field(`location-${IS_LOCATED_IN_UK}`).input()); cy.assertRadioOptionIsNotChecked(field(`location-${IS_LOCATED_INTERNATIONALLY}`).input()); diff --git a/e2e-tests/commands/shared-commands/assertions/assert-empty-loss-payee-financial-international-field-values.js b/e2e-tests/commands/shared-commands/assertions/assert-empty-loss-payee-financial-international-field-values.js index a4d6b402c5..cc8abb43a1 100644 --- a/e2e-tests/commands/shared-commands/assertions/assert-empty-loss-payee-financial-international-field-values.js +++ b/e2e-tests/commands/shared-commands/assertions/assert-empty-loss-payee-financial-international-field-values.js @@ -1,4 +1,3 @@ -import { field, autoCompleteField } from '../../../pages/shared'; import { POLICY as POLICY_FIELD_IDS } from '../../../constants/field-ids/insurance/policy'; const { @@ -11,9 +10,9 @@ const { * Assert all field values in the "loss payee financial international" form are empty. */ const assertEmptyLossPayeeFinancialInternationalFieldValues = () => { - cy.checkValue(field(IBAN), ''); + cy.assertEmptyFieldValue(IBAN); - cy.checkValue(autoCompleteField(BIC_SWIFT_CODE), ''); + cy.assertEmptyAutocompleteFieldValue(BIC_SWIFT_CODE); cy.checkTextareaValue({ fieldId: FINANCIAL_ADDRESS, diff --git a/e2e-tests/commands/shared-commands/assertions/assert-empty-loss-payee-financial-uk-field-values.js b/e2e-tests/commands/shared-commands/assertions/assert-empty-loss-payee-financial-uk-field-values.js index 9c3f5cb7b6..8a90197a9a 100644 --- a/e2e-tests/commands/shared-commands/assertions/assert-empty-loss-payee-financial-uk-field-values.js +++ b/e2e-tests/commands/shared-commands/assertions/assert-empty-loss-payee-financial-uk-field-values.js @@ -1,4 +1,3 @@ -import { field, autoCompleteField } from '../../../pages/shared'; import { POLICY as POLICY_FIELD_IDS } from '../../../constants/field-ids/insurance/policy'; const { @@ -11,9 +10,9 @@ const { * Assert all field values in the "loss payee financial uk" form are empty. */ const assertEmptyLossPayeeFinancialUkFieldValues = () => { - cy.checkValue(field(ACCOUNT_NUMBER), ''); + cy.assertEmptyFieldValue(ACCOUNT_NUMBER); - cy.checkValue(autoCompleteField(SORT_CODE), ''); + cy.assertEmptyAutocompleteFieldValue(SORT_CODE); cy.checkTextareaValue({ fieldId: FINANCIAL_ADDRESS, diff --git a/e2e-tests/commands/shared-commands/assertions/assert-empty-other-company-details-field-values.js b/e2e-tests/commands/shared-commands/assertions/assert-empty-other-company-details-field-values.js index 26b4e0d3fb..c540c9c701 100644 --- a/e2e-tests/commands/shared-commands/assertions/assert-empty-other-company-details-field-values.js +++ b/e2e-tests/commands/shared-commands/assertions/assert-empty-other-company-details-field-values.js @@ -1,4 +1,3 @@ -import { field as fieldSelector, autoCompleteField } from '../../../pages/shared'; import { POLICY as POLICY_FIELD_IDS } from '../../../constants/field-ids/insurance/policy'; const { @@ -10,9 +9,9 @@ const { * Assert all field values in the "other company details" form are empty */ const assertEmptyOtherCompanyDetailsFieldValues = () => { - cy.checkValue(fieldSelector(COMPANY_NAME), ''); - cy.checkValue(autoCompleteField(COUNTRY_CODE), ''); - cy.checkValue(fieldSelector(COMPANY_NUMBER), ''); + cy.assertEmptyFieldValue(COMPANY_NAME); + cy.assertEmptyAutocompleteFieldValue(COUNTRY_CODE); + cy.assertEmptyFieldValue(COMPANY_NUMBER); }; export default assertEmptyOtherCompanyDetailsFieldValues; diff --git a/e2e-tests/commands/shared-commands/assertions/assert-empty-overdue-or-outstanding-field-values.js b/e2e-tests/commands/shared-commands/assertions/assert-empty-overdue-or-outstanding-field-values.js index 751ebed3c1..22afc0c176 100644 --- a/e2e-tests/commands/shared-commands/assertions/assert-empty-overdue-or-outstanding-field-values.js +++ b/e2e-tests/commands/shared-commands/assertions/assert-empty-overdue-or-outstanding-field-values.js @@ -1,4 +1,3 @@ -import { field } from '../../../pages/shared'; import { YOUR_BUYER as FIELD_IDS } from '../../../constants/field-ids/insurance/your-buyer'; const { TOTAL_AMOUNT_OVERDUE, TOTAL_OUTSTANDING_PAYMENTS } = FIELD_IDS; @@ -8,8 +7,8 @@ const { TOTAL_AMOUNT_OVERDUE, TOTAL_OUTSTANDING_PAYMENTS } = FIELD_IDS; * Assert all field values in the "overdue or outstanding" form are empty. */ const assertEmptyOverdueOrOutstandingFieldValues = () => { - cy.checkValue(field(TOTAL_AMOUNT_OVERDUE), ''); - cy.checkValue(field(TOTAL_OUTSTANDING_PAYMENTS), ''); + cy.assertEmptyFieldValue(TOTAL_AMOUNT_OVERDUE); + cy.assertEmptyFieldValue(TOTAL_OUTSTANDING_PAYMENTS); }; export default assertEmptyOverdueOrOutstandingFieldValues; diff --git a/e2e-tests/commands/shared-commands/assertions/assert-empty-textarea-field-value.js b/e2e-tests/commands/shared-commands/assertions/assert-empty-textarea-field-value.js new file mode 100644 index 0000000000..91701b4354 --- /dev/null +++ b/e2e-tests/commands/shared-commands/assertions/assert-empty-textarea-field-value.js @@ -0,0 +1,12 @@ +import { field } from '../../../pages/shared'; + +/** + * assertEmptyTextareaFieldValue + * Assert that a textarea field value is empty. + * @param {String} fieldId: Field ID + */ +const assertEmptyTextareaFieldValue = (fieldId) => { + field(fieldId).textarea().should('have.value', ''); +}; + +export default assertEmptyTextareaFieldValue; diff --git a/e2e-tests/commands/shared-commands/assertions/check-email-field-rendering.js b/e2e-tests/commands/shared-commands/assertions/check-email-field-rendering.js index 3ac0bf3533..4bddb9190f 100644 --- a/e2e-tests/commands/shared-commands/assertions/check-email-field-rendering.js +++ b/e2e-tests/commands/shared-commands/assertions/check-email-field-rendering.js @@ -11,8 +11,6 @@ const checkEmailFieldRendering = ({ fieldId, contentStrings }) => { cy.checkText(field.label(), contentStrings.LABEL); - field.input().should('exist'); - cy.checkTypeAttribute(field.input(), 'email'); }; diff --git a/e2e-tests/commands/shared-commands/assertions/index.js b/e2e-tests/commands/shared-commands/assertions/index.js index f3a78734bc..545a7a2599 100644 --- a/e2e-tests/commands/shared-commands/assertions/index.js +++ b/e2e-tests/commands/shared-commands/assertions/index.js @@ -24,6 +24,9 @@ Cypress.Commands.add('assertCurrencyFormFieldsAreEmpty', require('./assert-curre Cypress.Commands.add('assertNameEmailAndPositionFields', require('./assert-name-email-and-position-fields')); Cypress.Commands.add('assertCopyWithCurrencyName', require('./assert-copy-with-currency-name')); +Cypress.Commands.add('assertEmptyAutocompleteFieldValue', require('./assert-empty-autocomplete-field-value')); +Cypress.Commands.add('assertEmptyFieldValue', require('./assert-empty-field-value')); +Cypress.Commands.add('assertEmptyTextareaFieldValue', require('./assert-empty-textarea-field-value')); Cypress.Commands.add('assertPrefix', require('./assert-prefix')); Cypress.Commands.add('assertSuffix', require('./assert-suffix')); Cypress.Commands.add('assertTextareaRendering', require('./assert-textarea-rendering')); diff --git a/e2e-tests/constants/application.js b/e2e-tests/constants/application.js index 32b6d6d492..f98d774287 100644 --- a/e2e-tests/constants/application.js +++ b/e2e-tests/constants/application.js @@ -31,4 +31,7 @@ export const APPLICATION = { }, }, }, + SMALL_EXPORT_BUILDER: { + MAXIMUM_BUYER_WILL_OWE: 25000, + }, }; diff --git a/e2e-tests/content-strings/fields/insurance/policy/index.js b/e2e-tests/content-strings/fields/insurance/policy/index.js index e8e3c7cec2..4bf8a5332b 100644 --- a/e2e-tests/content-strings/fields/insurance/policy/index.js +++ b/e2e-tests/content-strings/fields/insurance/policy/index.js @@ -1,6 +1,8 @@ -import { APPLICATION, ELIGIBILITY, FIELD_VALUES, MAXIMUM_CHARACTERS } from '../../../../constants'; +import { APPLICATION, ELIGIBILITY, FIELD_VALUES, GBP_CURRENCY_CODE, MAXIMUM_CHARACTERS } from '../../../../constants'; import { INSURANCE_FIELD_IDS } from '../../../../constants/field-ids/insurance'; import { FORM_TITLES } from '../../../form-titles'; +import { LINKS } from '../../../links'; +import formatCurrency from '../../../../helpers/format-currency'; const { ACCOUNT: { EMAIL }, @@ -27,12 +29,16 @@ const { } = INSURANCE_FIELD_IDS; const { MAX_COVER_PERIOD_MONTHS } = ELIGIBILITY; + const { + SMALL_EXPORT_BUILDER, POLICY: { TOTAL_MONTHS_OF_COVER }, } = APPLICATION; const { POLICY: POLICY_FORM_TITLES } = FORM_TITLES; +const SMALL_EXPORT_BUILDER_THRESHOLD = formatCurrency(SMALL_EXPORT_BUILDER.MAXIMUM_BUYER_WILL_OWE, GBP_CURRENCY_CODE); + export const POLICY_FIELDS = { [POLICY_TYPE]: { ID: POLICY_TYPE, @@ -140,6 +146,13 @@ export const POLICY_FIELDS = { LABEL: 'Estimate the maximum amount your buyer will owe you at any single point during this time', HINT: { FOR_EXAMPLE: 'For example, your total sales might be £250,000 but the maximum the buyer will owe you at any single point is £100,000.', + INITIAL_CREDIT_LIMIT: { + INTRO: `If your initial credit limit request is ${SMALL_EXPORT_BUILDER_THRESHOLD} or less you could be eligible for the`, + LINK: { + TEXT: 'Small Export Builder.', + HREF: LINKS.EXTERNAL.SMALL_EXPORT_BUILDER, + }, + }, NO_DECIMALS: 'Enter a whole number. Do not enter decimals.', }, SUMMARY: { diff --git a/e2e-tests/content-strings/links.js b/e2e-tests/content-strings/links.js index 615b3ff46c..ef54027875 100644 --- a/e2e-tests/content-strings/links.js +++ b/e2e-tests/content-strings/links.js @@ -31,5 +31,6 @@ export const LINKS = { BRIBERY_ACT_2010_GUIDANCE: 'https://assets.publishing.service.gov.uk/media/5d80cfc3ed915d51e9aff85a/bribery-act-2010-guidance.pdf', ICO_MAKE_A_COMPLAINT: 'https://ico.org.uk/make-a-complaint', COMPANIES_HOUSE: 'https://find-and-update.company-information.service.gov.uk', + SMALL_EXPORT_BUILDER: 'Small Export Builder', }, }; diff --git a/e2e-tests/content-strings/pages/insurance/eligibility/index.js b/e2e-tests/content-strings/pages/insurance/eligibility/index.js index aa81837374..d87c80905d 100644 --- a/e2e-tests/content-strings/pages/insurance/eligibility/index.js +++ b/e2e-tests/content-strings/pages/insurance/eligibility/index.js @@ -3,7 +3,7 @@ import formatCurrency from '../../../../helpers/format-currency'; import { ACTIONS } from '../../../actions'; import { LINKS } from '../../../links'; -export const THRESHOLD = formatCurrency(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE, 0); +export const THRESHOLD = formatCurrency(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE); export const CHECK_IF_ELIGIBLE = { PAGE_TITLE: 'Check you can apply for credit insurance for your export', diff --git a/e2e-tests/insurance/cypress/e2e/journeys/account/sign-in/enter-code/account-sign-in-enter-code.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/account/sign-in/enter-code/account-sign-in-enter-code.spec.js index 2ea1015626..18858748c7 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/account/sign-in/enter-code/account-sign-in-enter-code.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/account/sign-in/enter-code/account-sign-in-enter-code.spec.js @@ -69,8 +69,6 @@ context( cy.checkText(field.label(), FIELD_STRINGS.LABEL); - field.input().should('exist'); - cy.checkClassName(field.input(), 'govuk-input govuk-input--width-4 govuk-input--extra-letter-spacing'); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/all-sections.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/all-sections.spec.js index 5bc7f3e963..dea6bb8592 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/all-sections.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/all-sections.spec.js @@ -165,13 +165,10 @@ context('Insurance - All sections - new application', () => { }); it('should render a heading', () => { - insurance.allSectionsPage.submissionDeadlineHeading().should('exist'); cy.checkText(insurance.allSectionsPage.submissionDeadlineHeading(), CONTENT_STRINGS.DEADLINE_TO_SUBMIT); }); it('should render correct submission deadline', () => { - insurance.allSectionsPage.submissionDeadline().should('exist'); - const now = new Date(); const timestamp = addMonths(new Date(now), APPLICATION.SUBMISSION_DEADLINE_IN_MONTHS); @@ -187,13 +184,10 @@ context('Insurance - All sections - new application', () => { }); it('should render a heading', () => { - insurance.allSectionsPage.yourReferenceNumberHeading().should('exist'); cy.checkText(insurance.allSectionsPage.yourReferenceNumberHeading(), CONTENT_STRINGS.REFERENCE_NUMBER); }); it('should render correct reference number', () => { - insurance.allSectionsPage.yourReferenceNumber().should('exist'); - const expectedReferenceNumber = String(referenceNumber); cy.checkText(insurance.allSectionsPage.yourReferenceNumber(), expectedReferenceNumber); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-eligible-for-small-export-builder-alternative-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-eligible-for-small-export-builder-alternative-currency.spec.js new file mode 100644 index 0000000000..f8357de5ed --- /dev/null +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-eligible-for-small-export-builder-alternative-currency.spec.js @@ -0,0 +1,34 @@ +import { APPLICATION } from '../../../../../../../constants'; + +context( + 'Insurance - submit an application - Multiple policy type - Eligible for small export builder - Alternative currency - As an Exporter, I want to submit my completed credit insurance application, So that UKEF can process and make a decision on my application', + () => { + let referenceNumber; + + before(() => { + cy.completeSignInAndSubmitAnApplication({ + policyType: APPLICATION.POLICY_TYPE.MULTIPLE, + alternativeCurrencyPolicy: true, + maximumBuyerWillOwe: '100', + }).then((refNumber) => { + referenceNumber = refNumber; + }); + }); + + beforeEach(() => { + cy.saveSession(); + }); + + after(() => { + cy.deleteApplication(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); + }); + }, +); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-eligible-for-small-export-builder.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-eligible-for-small-export-builder.spec.js new file mode 100644 index 0000000000..f44ea29e9e --- /dev/null +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-eligible-for-small-export-builder.spec.js @@ -0,0 +1,33 @@ +import { APPLICATION } from '../../../../../../../constants'; + +context( + 'Insurance - submit an application - Multiple policy type - Eligible for small export builder - As an Exporter, I want to submit my completed credit insurance application, So that UKEF can process and make a decision on my application', + () => { + let referenceNumber; + + before(() => { + cy.completeSignInAndSubmitAnApplication({ + policyType: APPLICATION.POLICY_TYPE.MULTIPLE, + maximumBuyerWillOwe: APPLICATION.SMALL_EXPORT_BUILDER.MAXIMUM_BUYER_WILL_OWE - 1, + }).then((refNumber) => { + referenceNumber = refNumber; + }); + }); + + beforeEach(() => { + cy.saveSession(); + }); + + after(() => { + cy.deleteApplication(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); + }); + }, +); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-not-eligible-for-small-export-builder-alternative-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-not-eligible-for-small-export-builder-alternative-currency.spec.js new file mode 100644 index 0000000000..5203352f75 --- /dev/null +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-not-eligible-for-small-export-builder-alternative-currency.spec.js @@ -0,0 +1,34 @@ +import { APPLICATION } from '../../../../../../../constants'; + +context( + 'Insurance - submit an application - Multiple policy type - Not eligible for small export builder - Alternative currency - As an Exporter, I want to submit my completed credit insurance application, So that UKEF can process and make a decision on my application', + () => { + let referenceNumber; + + before(() => { + cy.completeSignInAndSubmitAnApplication({ + policyType: APPLICATION.POLICY_TYPE.MULTIPLE, + alternativeCurrencyPolicy: true, + maximumBuyerWillOwe: '5000000', + }).then((refNumber) => { + referenceNumber = refNumber; + }); + }); + + beforeEach(() => { + cy.saveSession(); + }); + + after(() => { + cy.deleteApplication(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); + }); + }, +); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-not-eligible-for-small-export-builder.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-not-eligible-for-small-export-builder.spec.js new file mode 100644 index 0000000000..d07246a33f --- /dev/null +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-not-eligible-for-small-export-builder.spec.js @@ -0,0 +1,33 @@ +import { APPLICATION } from '../../../../../../../constants'; + +context( + 'Insurance - submit an application - Multiple policy type - Not eligible for small export builder - As an Exporter, I want to submit my completed credit insurance application, So that UKEF can process and make a decision on my application', + () => { + let referenceNumber; + + before(() => { + cy.completeSignInAndSubmitAnApplication({ + policyType: APPLICATION.POLICY_TYPE.MULTIPLE, + maximumBuyerWillOwe: APPLICATION.SMALL_EXPORT_BUILDER.MAXIMUM_BUYER_WILL_OWE + 1, + }).then((refNumber) => { + referenceNumber = refNumber; + }); + }); + + beforeEach(() => { + cy.saveSession(); + }); + + after(() => { + cy.deleteApplication(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); + }); + }, +); 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 1b55df7954..26aec45876 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 @@ -1,4 +1,4 @@ -import { autoCompleteField, field, status, summaryList, radios } from '../../../../../../../../pages/shared'; +import { status, summaryList, radios } from '../../../../../../../../pages/shared'; import { agentChargesPage } from '../../../../../../../../pages/insurance/export-contract'; import { INSURANCE_FIELD_IDS } from '../../../../../../../../constants/field-ids/insurance'; import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance'; @@ -106,8 +106,9 @@ context('Insurance - Change your answers - Export contract - Summary list - Agen cy.assertRadioOptionIsNotChecked(agentChargesPage[METHOD][FIXED_SUM].input()); cy.assertRadioOptionIsNotChecked(agentChargesPage[METHOD][PERCENTAGE].input()); - cy.checkValue(field(PERCENTAGE_CHARGE), ''); - cy.checkValue(autoCompleteField(PAYABLE_COUNTRY_CODE), ''); + cy.assertEmptyFieldValue(PERCENTAGE_CHARGE); + + cy.assertEmptyAutocompleteFieldValue(PAYABLE_COUNTRY_CODE); cy.completeAndSubmitAgentChargesForm({ fixedSumMethod: true }); @@ -122,7 +123,7 @@ context('Insurance - Change your answers - Export contract - Summary list - Agen cy.completeAndSubmitCurrencyForm({}); // assert HOW_MUCH_THE_AGENT_IS_CHARGING field values. - cy.checkValue(field(FIXED_SUM_AMOUNT), ''); + cy.assertEmptyFieldValue(FIXED_SUM_AMOUNT); }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/how-the-contract-was-awarded/change-your-answers-how-the-contract-was-awarded-from-other-method.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/how-the-contract-was-awarded/change-your-answers-how-the-contract-was-awarded-from-other-method.spec.js index a24cf72620..d0b83502e8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/how-the-contract-was-awarded/change-your-answers-how-the-contract-was-awarded-from-other-method.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/export-contract/change-your-answers/how-the-contract-was-awarded/change-your-answers-how-the-contract-was-awarded-from-other-method.spec.js @@ -1,4 +1,4 @@ -import { summaryList, radios, field } from '../../../../../../../../pages/shared'; +import { summaryList, radios } from '../../../../../../../../pages/shared'; import FIELD_IDS from '../../../../../../../../constants/field-ids/insurance/export-contract'; import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance'; import { EXPORT_CONTRACT_FIELDS as FIELDS } from '../../../../../../../../content-strings/fields/insurance/export-contract'; @@ -66,7 +66,7 @@ context( }); it(`should have no value for ${OTHER_AWARD_METHOD} text input`, () => { - cy.checkValue(field(OTHER_AWARD_METHOD), ''); + cy.assertEmptyFieldValue(OTHER_AWARD_METHOD); }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/policy/change-your-answers/broker/change-your-answers-change-broker-yes-to-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/policy/change-your-answers/broker/change-your-answers-change-broker-yes-to-no.spec.js index 7286f65d9a..713da7684b 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/policy/change-your-answers/broker/change-your-answers-change-broker-yes-to-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/policy/change-your-answers/broker/change-your-answers-change-broker-yes-to-no.spec.js @@ -1,4 +1,4 @@ -import { field, status, summaryList } from '../../../../../../../../pages/shared'; +import { status, summaryList } from '../../../../../../../../pages/shared'; import { POLICY as POLICY_FIELD_IDS } from '../../../../../../../../constants/field-ids/insurance/policy'; import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance'; import { FIELD_VALUES } from '../../../../../../../../constants'; @@ -98,8 +98,8 @@ context('Insurance - Change your answers - Policy - Broker - Yes to no - As an e cy.completeAndSubmitBrokerForm({ usingBroker: true }); - cy.checkValue(field(NAME), ''); - cy.checkValue(field(EMAIL), ''); + cy.assertEmptyFieldValue(NAME); + cy.assertEmptyFieldValue(EMAIL); cy.checkTextareaValue({ fieldId: FULL_ADDRESS, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/policy/change-your-answers/single-policy/change-your-answers-policy-type-change-single-to-multiple-policy-type-summary-list.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/policy/change-your-answers/single-policy/change-your-answers-policy-type-change-single-to-multiple-policy-type-summary-list.spec.js index c754400085..77e688acf4 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/policy/change-your-answers/single-policy/change-your-answers-policy-type-change-single-to-multiple-policy-type-summary-list.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/policy/change-your-answers/single-policy/change-your-answers-policy-type-change-single-to-multiple-policy-type-summary-list.spec.js @@ -84,7 +84,7 @@ context('Insurance - Change your answers - Policy - Change single to multiple po cy.assertUrl(`${exportValueUrl}#heading`); // complete the now required "export value" form. - cy.completeAndSubmitExportValueForm(); + cy.completeAndSubmitExportValueForm({}); // assert the URL is CHECK_YOUR_ANSWERS.TYPE_OF_POLICY cy.assertUrl(`${checkYourAnswersUrl}#heading`); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-business/change-your-answers/change-your-answers-change-company-details-trading-address-yes-to-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-business/change-your-answers/change-your-answers-change-company-details-trading-address-yes-to-no.spec.js index 3755324c9e..a9ec5dfb05 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-business/change-your-answers/change-your-answers-change-company-details-trading-address-yes-to-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/your-business/change-your-answers/change-your-answers-change-company-details-trading-address-yes-to-no.spec.js @@ -1,4 +1,4 @@ -import { field, status, summaryList } from '../../../../../../../pages/shared'; +import { status, summaryList } from '../../../../../../../pages/shared'; import { FIELD_VALUES } from '../../../../../../../constants'; import { INSURANCE_FIELD_IDS } from '../../../../../../../constants/field-ids/insurance'; import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insurance'; @@ -96,7 +96,7 @@ context(`Insurance - Check your answers - Company details - Your business - ${FI cy.completeAndSubmitCompanyDetails({ differentTradingAddress: true }); - cy.checkText(field(FULL_ADDRESS).textarea(), ''); + cy.assertEmptyTextareaFieldValue(FULL_ADDRESS); }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/complete-eligibility-answers-for-a-second-time.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/complete-eligibility-answers-for-a-second-time.spec.js index f193f8df8e..2a3a8db701 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/complete-eligibility-answers-for-a-second-time.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/complete-eligibility-answers-for-a-second-time.spec.js @@ -1,4 +1,3 @@ -import { autoCompleteField, field } from '../../../../pages/shared'; import { ROUTES, FIELD_IDS } from '../../../../constants'; const { @@ -53,7 +52,7 @@ context('Insurance - Eligibility - start and complete for a second time after cr cy.completeCompaniesHouseNumberForm(); // companies house search form - cy.checkValue(field(COMPANY_NUMBER), ''); + cy.assertEmptyFieldValue(COMPANY_NUMBER); cy.completeAndSubmitCompaniesHouseSearchForm({}); @@ -61,7 +60,7 @@ context('Insurance - Eligibility - start and complete for a second time after cr cy.completeEligibilityCompanyDetailsForm(); // buyer country question - cy.checkValue(autoCompleteField(BUYER_COUNTRY), ''); + cy.assertEmptyAutocompleteFieldValue(BUYER_COUNTRY); cy.completeAndSubmitBuyerCountryForm({}); /** diff --git a/e2e-tests/insurance/cypress/e2e/journeys/cookies.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/cookies.spec.js index 3fabc51256..b36261f73b 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/cookies.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/cookies.spec.js @@ -174,13 +174,9 @@ context('Cookies page - Insurance', () => { }); it('should render validation errors', () => { - const expectedErrorsCount = 1; - const expectedErrorMessage = ERROR_MESSAGES[FIELD_ID]; - cy.submitAndAssertRadioErrors({ field: cookiesPage[FIELD_ID].accept, - expectedErrorsCount, - expectedErrorMessage, + expectedErrorMessage: ERROR_MESSAGES[FIELD_ID], }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-populated-application-gbp-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-populated-application-gbp-currency.spec.js index 7ac4283b33..3abe7e3dd2 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-populated-application-gbp-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-populated-application-gbp-currency.spec.js @@ -135,7 +135,7 @@ context('Insurance - Dashboard - populated application - GBP currency', () => { // complete and submit the next 2 forms cy.completeAndSubmitMultipleContractPolicyForm({}); - cy.completeAndSubmitExportValueForm({ policyType }); + cy.completeAndSubmitExportValueForm({}); }); it(`should render a formatted value of ${MAXIMUM_BUYER_WILL_OWE} in the ${TABLE_HEADERS.VALUE} cell`, () => { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-populated-application-non-gbp-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-populated-application-non-gbp-currency.spec.js index 3004070331..9137d13b1b 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-populated-application-non-gbp-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-populated-application-non-gbp-currency.spec.js @@ -96,7 +96,7 @@ context('Insurance - Dashboard - populated application - alternative (non GBP) c // complete and submit the next 2 forms cy.completeAndSubmitMultipleContractPolicyForm({ alternativeCurrency: true, chooseCurrency: true }); - cy.completeAndSubmitExportValueForm({ policyType }); + cy.completeAndSubmitExportValueForm({}); }); it(`should render a formatted value of ${MAXIMUM_BUYER_WILL_OWE} in the ${TABLE_HEADERS.VALUE} cell`, () => { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery-expandable-definition-content.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery-expandable-definition-content.spec.js index ab7b55bf5c..e4c070f2b2 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery-expandable-definition-content.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery-expandable-definition-content.spec.js @@ -31,7 +31,7 @@ context('Insurance - Declarations - Anti-bribery page - expandable `definition` cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitDeclarationsForms({ formToStopAt: 'confidentiality', referenceNumber }); + cy.completeAndSubmitDeclarationsForms({ stopSubmittingAfter: 'confidentiality', referenceNumber }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${ANTI_BRIBERY_ROOT}`; @@ -50,8 +50,6 @@ context('Insurance - Declarations - Anti-bribery page - expandable `definition` }); it('renders summary text', () => { - expandable.summary().should('exist'); - cy.checkText(expandable.summary(), INTRO); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery.spec.js index 07179ac8bf..09833054e3 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery.spec.js @@ -28,7 +28,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitDeclarationsForms({ formToStopAt: 'confidentiality', referenceNumber }); + cy.completeAndSubmitDeclarationsForms({ stopSubmittingAfter: 'confidentiality', referenceNumber }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${ANTI_BRIBERY_ROOT}`; @@ -147,11 +147,8 @@ context( }); it('should render a validation error', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertFieldErrors({ field, - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.DECLARATIONS[FIELD_ID].IS_EMPTY, clearInput: false, }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/anti-bribery-code-of-conduct-answer-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/anti-bribery-code-of-conduct-answer-no.spec.js index c98a67c807..51cba2920c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/anti-bribery-code-of-conduct-answer-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/anti-bribery-code-of-conduct-answer-no.spec.js @@ -20,7 +20,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitDeclarationsForms({ formToStopAt: 'antiBribery', referenceNumber }); + cy.completeAndSubmitDeclarationsForms({ stopSubmittingAfter: 'antiBribery', referenceNumber }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${CODE_OF_CONDUCT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/anti-bribery-code-of-conduct-answer-yes.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/anti-bribery-code-of-conduct-answer-yes.spec.js index aff4c3c9df..248e5e8afc 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/anti-bribery-code-of-conduct-answer-yes.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/anti-bribery-code-of-conduct-answer-yes.spec.js @@ -19,7 +19,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitDeclarationsForms({ formToStopAt: 'antiBribery', referenceNumber }); + cy.completeAndSubmitDeclarationsForms({ stopSubmittingAfter: 'antiBribery', referenceNumber }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${CODE_OF_CONDUCT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/anti-bribery-code-of-conduct.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/anti-bribery-code-of-conduct.spec.js index b604bc226f..b559c86ff4 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/anti-bribery-code-of-conduct.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/anti-bribery-code-of-conduct.spec.js @@ -27,7 +27,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitDeclarationsForms({ formToStopAt: 'antiBribery', referenceNumber }); + cy.completeAndSubmitDeclarationsForms({ stopSubmittingAfter: 'antiBribery', referenceNumber }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${CODE_OF_CONDUCT}`; @@ -86,11 +86,11 @@ context( cy.assertSubmitAndSaveButtons(); }); - it('should NOT render conditional `we will email you` hint without selecting the "yes" radio', () => { + it('should NOT render a conditional `we will email you` hint without selecting the "yes" radio', () => { codeOfConductPage.revealText().should('not.be.visible'); }); - it('should display conditional `we will email you` hint when selecting the "yes" radio', () => { + it('should render a conditional `we will email you` hint when selecting the "yes" radio', () => { cy.clickYesRadioInput(); codeOfConductPage.revealText().should('be.visible'); @@ -106,11 +106,8 @@ context( }); it('should render a validation error', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: yesRadio(FIELD_ID), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.DECLARATIONS[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/save-and-back.spec.js index e264ac33e7..44aaed293a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/code-of-conduct/save-and-back.spec.js @@ -25,7 +25,7 @@ context('Insurance - Declarations - Anti-bribery - Code of conduct page - Save a cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitDeclarationsForms({ formToStopAt: 'antiBribery', referenceNumber }); + cy.completeAndSubmitDeclarationsForms({ stopSubmittingAfter: 'antiBribery', referenceNumber }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${CODE_OF_CONDUCT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/exporting-with-code-of-conduct/anti-bribery-exporting-with-code-of-conduct.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/exporting-with-code-of-conduct/anti-bribery-exporting-with-code-of-conduct.spec.js index facb5e9782..3bd115e7f0 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/exporting-with-code-of-conduct/anti-bribery-exporting-with-code-of-conduct.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/exporting-with-code-of-conduct/anti-bribery-exporting-with-code-of-conduct.spec.js @@ -27,7 +27,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitDeclarationsForms({ formToStopAt: 'codeOfConduct', referenceNumber }); + cy.completeAndSubmitDeclarationsForms({ stopSubmittingAfter: 'codeOfConduct', referenceNumber }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${EXPORTING_WITH_CODE_OF_CONDUCT}`; @@ -88,11 +88,8 @@ context( }); it('should render a validation error', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: yesRadio(FIELD_ID), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.DECLARATIONS[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/exporting-with-code-of-conduct/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/exporting-with-code-of-conduct/save-and-back.spec.js index c12a34c852..50a6a729ac 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/exporting-with-code-of-conduct/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/exporting-with-code-of-conduct/save-and-back.spec.js @@ -25,7 +25,7 @@ context('Insurance - Declarations - Exporting with code of conduct page - Save a cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitDeclarationsForms({ formToStopAt: 'codeOfConduct', referenceNumber }); + cy.completeAndSubmitDeclarationsForms({ stopSubmittingAfter: 'codeOfConduct', referenceNumber }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${EXPORTING_WITH_CODE_OF_CONDUCT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/save-and-back.spec.js index 37491318f8..3770bac249 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/save-and-back.spec.js @@ -23,7 +23,7 @@ context('Insurance - Declarations - Anti-bribery page - Save and go back', () => cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitDeclarationsForms({ formToStopAt: 'confidentiality', referenceNumber }); + cy.completeAndSubmitDeclarationsForms({ stopSubmittingAfter: 'confidentiality', referenceNumber }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${ANTI_BRIBERY_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confidentiality/confidentiality.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confidentiality/confidentiality.spec.js index 5df91960e0..b363cfe6b1 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confidentiality/confidentiality.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confidentiality/confidentiality.spec.js @@ -122,11 +122,8 @@ context( }); it('should render a validation error', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field, - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.DECLARATIONS[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/confirmation-and-acknowledgements.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/confirmation-and-acknowledgements.spec.js index 9f05dcf0d1..8b852f7d88 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/confirmation-and-acknowledgements.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/confirmation-and-acknowledgements.spec.js @@ -30,7 +30,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitDeclarationsForms({ formToStopAt: 'exportingWithCodeOfConduct', referenceNumber }); + cy.completeAndSubmitDeclarationsForms({ stopSubmittingAfter: 'exportingWithCodeOfConduct', referenceNumber }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${CONFIRMATION_AND_ACKNOWLEDGEMENTS}`; @@ -107,11 +107,8 @@ context( }); it('should render a validation error', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field, - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.DECLARATIONS[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/save-and-back.spec.js index 4ef9244cf0..3162577dd7 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/save-and-back.spec.js @@ -19,7 +19,7 @@ context('Insurance - Declarations - Confirmation and acknowledgements page - Sav cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitDeclarationsForms({ formToStopAt: 'exportingWithCodeOfConduct', referenceNumber }); + cy.completeAndSubmitDeclarationsForms({ stopSubmittingAfter: 'exportingWithCodeOfConduct', referenceNumber }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${CONFIRMATION_AND_ACKNOWLEDGEMENTS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-short-term-cover.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-short-term-cover.spec.js index 46b31d399e..1c8c31169e 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-short-term-cover.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-no-short-term-cover.spec.js @@ -14,7 +14,7 @@ context( beforeEach(() => { cy.saveSession(); - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'companyDetails' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'companyDetails' }); }); describe(COUNTRY_NAME_1, () => { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-unsupported-countries.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-unsupported-countries.spec.js index 0f3f5e2684..9974e85429 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-unsupported-countries.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country-unsupported-countries.spec.js @@ -17,7 +17,7 @@ context(`Insurance - Buyer country page - ${contextString} - Unsupported countri beforeEach(() => { cy.saveSession(); - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'companyDetails' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'companyDetails' }); }); describe(COUNTRY_NAME_1, () => { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country.spec.js index b1e99a2372..1d3a134cd9 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/buyer-country/buyer-country.spec.js @@ -19,7 +19,7 @@ const baseUrl = Cypress.config('baseUrl'); context('Insurance - Buyer country page - as an exporter, I want to check if UKEF offer credit insurance policy for where my buyer is based', () => { beforeEach(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'companyDetails' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'companyDetails' }); const expectedUrl = `${baseUrl}${BUYER_COUNTRY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-multiple-risks/cannot-apply-multiple-risks.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-multiple-risks/cannot-apply-multiple-risks.spec.js index 6ec1be0908..8d7e80d37f 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-multiple-risks/cannot-apply-multiple-risks.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-multiple-risks/cannot-apply-multiple-risks.spec.js @@ -20,7 +20,7 @@ context( const url = `${baseUrl}${CANNOT_APPLY_MULTIPLE_RISKS_EXIT}`; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'ukGoodsAndServices' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'ukGoodsAndServices' }); cy.clickYesRadioInput(); cy.clickSubmitButton(); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js index 0de7e240a5..ff143ee64f 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply-page.spec.js @@ -18,7 +18,7 @@ const baseUrl = Cypress.config('baseUrl'); context('Insurance Eligibility - Cannot apply exit page', () => { beforeEach(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'companyDetails' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'companyDetails' }); cy.keyboardInput(autoCompleteField(FIELD_ID).input(), COUNTRY_NAME_UNSUPPORTED); const results = autoCompleteField(FIELD_ID).results(); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js index 68c0d22dd4..7344d8a363 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cannot-apply/cannot-apply-page.spec.js @@ -25,7 +25,7 @@ context( cy.navigateToCheckIfEligibleUrl(); - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'companyDetails' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'companyDetails' }); cy.keyboardInput(autoCompleteField(FIELD_ID).input(), COUNTRY_NAME); @@ -42,9 +42,8 @@ context( }); it('renders a reason', () => { - cannotApplyPage.reason().should('exist'); - const expected = `${REASON.INTRO} ${REASON.UNSUPPORTED_BUYER_COUNTRY_1} ${COUNTRY_NAME}, ${REASON.UNSUPPORTED_BUYER_COUNTRY_2}`; + cy.checkText(cannotApplyPage.reason(), expected); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-number/companies-house-number-answer-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-number/companies-house-number-answer-no.spec.js index a1c08162f9..9fb48b0e40 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-number/companies-house-number-answer-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-number/companies-house-number-answer-no.spec.js @@ -14,7 +14,7 @@ context( const url = `${baseUrl}${COMPANIES_HOUSE_NUMBER}`; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'exporterLocation' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'exporterLocation' }); }); beforeEach(() => { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-number/companies-house-number.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-number/companies-house-number.spec.js index 5a30446213..3d21fd02c2 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-number/companies-house-number.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-number/companies-house-number.spec.js @@ -17,7 +17,7 @@ context( const url = `${baseUrl}${ROUTES.INSURANCE.ELIGIBILITY.COMPANIES_HOUSE_NUMBER}`; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'exporterLocation' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'exporterLocation' }); cy.assertUrl(url); }); @@ -65,11 +65,8 @@ context( }); it('should render validation errors', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: yesRadio(FIELD_ID), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.ELIGIBILITY[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-search/companies-house-search-no-financial-year-end-date.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-search/companies-house-search-no-financial-year-end-date.spec.js index d97f1473c5..7b91dc2a35 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-search/companies-house-search-no-financial-year-end-date.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-search/companies-house-search-no-financial-year-end-date.spec.js @@ -14,7 +14,7 @@ context( before(() => { cy.completeAndSubmitEligibilityForms({ - formToStopAt: 'companiesHouseNumberSearch', + stopSubmittingAfter: 'companiesHouseNumberSearch', companyNumber: COMPANIES_HOUSE_NUMBER_NO_FINANCIAL_YEAR_END_DATE, }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-search/companies-house-search.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-search/companies-house-search.spec.js index aea87d6ed5..61d2678741 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-search/companies-house-search.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/companies-house/companies-house-search/companies-house-search.spec.js @@ -37,7 +37,7 @@ context('Insurance - Eligibility - Companies house search page - I want to check let companyNumber; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'companiesHouseNumber' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'companiesHouseNumber' }); cy.assertUrl(url); }); @@ -76,7 +76,7 @@ context('Insurance - Eligibility - Companies house search page - I want to check cy.navigateToUrl(url); }); - it('should display the `is empty` error', () => { + it('should render the `is empty` error', () => { cy.submitAndAssertFieldErrors({ field, value: companyNumber, @@ -92,7 +92,7 @@ context('Insurance - Eligibility - Companies house search page - I want to check companyNumber = COMPANIES_HOUSE_NUMBER_EMPTY; }); - it('should display the `is empty` error', () => { + it('should render the `is empty` error', () => { cy.submitAndAssertFieldErrors({ field, value: companyNumber, @@ -108,7 +108,7 @@ context('Insurance - Eligibility - Companies house search page - I want to check companyNumber = COMPANIES_HOUSE_NUMBER_TOO_SHORT; }); - it('should display the `incorrect format` error', () => { + it('should render the `incorrect format` error', () => { cy.submitAndAssertFieldErrors({ field, value: companyNumber, @@ -126,7 +126,7 @@ context('Insurance - Eligibility - Companies house search page - I want to check cy.interceptCompaniesHousePost({ companyNumber }); }); - it('should display the `incorrect format` error', () => { + it('should render the `incorrect format` error', () => { cy.submitAndAssertFieldErrors({ field, value: companyNumber, @@ -144,7 +144,7 @@ context('Insurance - Eligibility - Companies house search page - I want to check cy.interceptCompaniesHousePost({ companyNumber }); }); - it('should display the `not found` error', () => { + it('should render the `not found` error', () => { cy.submitAndAssertFieldErrors({ field, value: companyNumber, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details-company-name-special-characters.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details-company-name-special-characters.spec.js index 73fd67b4da..e35047319c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details-company-name-special-characters.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details-company-name-special-characters.spec.js @@ -15,7 +15,7 @@ context( before(() => { cy.completeAndSubmitEligibilityForms({ - formToStopAt: 'companiesHouseNumberSearch', + stopSubmittingAfter: 'companiesHouseNumberSearch', companyNumber: COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME, }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details-multiple-SIC-codes.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details-multiple-SIC-codes.spec.js index 04b6ffee7b..c4a344b7a9 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details-multiple-SIC-codes.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details-multiple-SIC-codes.spec.js @@ -21,7 +21,7 @@ context( before(() => { cy.completeAndSubmitEligibilityForms({ - formToStopAt: 'companiesHouseNumberSearch', + stopSubmittingAfter: 'companiesHouseNumberSearch', companyNumber: COMPANIES_HOUSE_NUMBER_MULTIPLE_SIC_CODES, }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details.spec.js index 8a37b1fc76..4b2015738c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details.spec.js @@ -16,7 +16,7 @@ context('Insurance - Eligibility - Companies details page - I want to check if I const url = `${baseUrl}${COMPANY_DETAILS}`; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'companiesHouseNumberSearch' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'companiesHouseNumberSearch' }); cy.assertUrl(url); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-not-active/company-not-active.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-not-active/company-not-active.spec.js index 60c99e0690..46f50a7bf9 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-not-active/company-not-active.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-not-active/company-not-active.spec.js @@ -20,7 +20,7 @@ context('Insurance - Eligibility - Company not active - I want to check if I can before(() => { cy.completeAndSubmitEligibilityForms({ - formToStopAt: 'companiesHouseNumberSearch', + stopSubmittingAfter: 'companiesHouseNumberSearch', companyNumber: COMPANIES_HOUSE_NUMBER_NOT_ACTIVE, }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cover-period/cover-period.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cover-period/cover-period.spec.js index 331077cf1c..48c6f9271e 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cover-period/cover-period.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/cover-period/cover-period.spec.js @@ -25,7 +25,7 @@ context( let url; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'totalValueInsured' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'totalValueInsured' }); url = `${baseUrl}${COVER_PERIOD_ROUTE}`; @@ -81,11 +81,8 @@ context( it('should render validation errors', () => { const fieldId = `${FIELD_ID}-${BELOW.ID}`; - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: fieldSelector(fieldId), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.ELIGIBILITY[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/eligible-to-apply-online/eligible-to-apply-online.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/eligible-to-apply-online/eligible-to-apply-online.spec.js index 023f852b0d..bf7a24f2ba 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/eligible-to-apply-online/eligible-to-apply-online.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/eligible-to-apply-online/eligible-to-apply-online.spec.js @@ -51,8 +51,6 @@ context( }); it('renders inset text', () => { - eligibleToApplyOnlinePage.insetText().should('exist'); - cy.checkText(eligibleToApplyOnlinePage.insetText(), CONTENT_STRINGS.INSET); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/end-buyer/end-buyer.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/end-buyer/end-buyer.spec.js index 1e0a4c1aeb..0b2e1ff0e0 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/end-buyer/end-buyer.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/end-buyer/end-buyer.spec.js @@ -24,7 +24,7 @@ context( const url = `${baseUrl}${END_BUYER}`; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'ukGoodsAndServices' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'ukGoodsAndServices' }); cy.assertUrl(url); }); @@ -97,11 +97,8 @@ context( }); it('should render validation errors', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: yesRadio(FIELD_ID), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.ELIGIBILITY[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/exporter-location/exporter-location-answer-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/exporter-location/exporter-location-answer-no.spec.js index 91f82ff608..a910096ef7 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/exporter-location/exporter-location-answer-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/exporter-location/exporter-location-answer-no.spec.js @@ -16,7 +16,7 @@ context( const url = `${baseUrl}${EXPORTER_LOCATION}`; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'checkIfEligible' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'checkIfEligible' }); cy.assertUrl(url); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/exporter-location/exporter-location.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/exporter-location/exporter-location.spec.js index 1c1c69441d..1c03679fdf 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/exporter-location/exporter-location.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/exporter-location/exporter-location.spec.js @@ -19,7 +19,7 @@ const baseUrl = Cypress.config('baseUrl'); context('Insurance - Exporter location page - as an exporter, I want to check if my company can get UKEF issue credit insurance cover', () => { beforeEach(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'checkIfEligible' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'checkIfEligible' }); const expectedUrl = `${baseUrl}${EXPORTER_LOCATION}`; @@ -57,11 +57,8 @@ context('Insurance - Exporter location page - as an exporter, I want to check if describe('form submission', () => { describe('when submitting an empty form', () => { it('should render validation errors', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: yesRadio(FIELD_ID), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.ELIGIBILITY[FIELD_ID], }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/have-an-account/have-an-account.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/have-an-account/have-an-account.spec.js index 2857b7e6a3..a71a31308f 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/have-an-account/have-an-account.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/have-an-account/have-an-account.spec.js @@ -75,11 +75,8 @@ context( }); it('should render validation errors', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: yesRadio(FIELD_ID), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.ELIGIBILITY[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/long-term-cover.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/long-term-cover.spec.js index 44b4eb680b..3e4567fd2d 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/long-term-cover.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/long-term-cover.spec.js @@ -15,7 +15,7 @@ context( let url; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'coverPeriod', coverPeriodIsUnderThreshold: false }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'coverPeriod', coverPeriodIsUnderThreshold: false }); url = `${baseUrl}${LONG_TERM_COVER_EXIT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/member-of-a-group-exit-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/member-of-a-group-exit-page.spec.js index 824e4797c7..21faca199d 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/member-of-a-group-exit-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/member-of-a-group-exit-page.spec.js @@ -15,7 +15,7 @@ context( let url; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'memberOfAGroup', memberOfAGroup: true }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'memberOfAGroup', memberOfAGroup: true }); url = `${baseUrl}${MEMBER_OF_A_GROUP_EXIT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/member-of-a-group/member-of-a-group.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/member-of-a-group/member-of-a-group.spec.js index 9980c86a2d..ef5e4ac0d8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/member-of-a-group/member-of-a-group.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/member-of-a-group/member-of-a-group.spec.js @@ -23,7 +23,7 @@ context( const url = `${baseUrl}${MEMBER_OF_A_GROUP}`; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'partyToConsortium' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'partyToConsortium' }); cy.assertUrl(url); }); @@ -83,11 +83,8 @@ context( }); it('should render validation errors', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: yesRadio(FIELD_ID), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.ELIGIBILITY[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/party-to-consortium-exit-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/party-to-consortium-exit-page.spec.js index ad3e816676..7318c93b4b 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/party-to-consortium-exit-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/party-to-consortium-exit-page.spec.js @@ -15,7 +15,7 @@ context( let url; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'partyToConsortium', partyToConsortium: true }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'partyToConsortium', partyToConsortium: true }); url = `${baseUrl}${PARTY_TO_CONSORTIUM_EXIT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/party-to-consortium/party-to-consortium.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/party-to-consortium/party-to-consortium.spec.js index 9fbc1486eb..4b457e732a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/party-to-consortium/party-to-consortium.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/party-to-consortium/party-to-consortium.spec.js @@ -22,7 +22,7 @@ context( const url = `${baseUrl}${PARTY_TO_CONSORTIUM}`; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'endBuyer' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'endBuyer' }); cy.assertUrl(url); }); @@ -67,11 +67,8 @@ context( }); it('should render validation errors', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: yesRadio(FIELD_ID), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.ELIGIBILITY[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/total-value-insured/total-value-insured.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/total-value-insured/total-value-insured.spec.js index 15aa13d1b9..1bcfeac75f 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/total-value-insured/total-value-insured.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/total-value-insured/total-value-insured.spec.js @@ -25,7 +25,7 @@ context( let url; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'buyerCountry' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'buyerCountry' }); url = `${baseUrl}${TOTAL_VALUE_INSURED}`; @@ -83,11 +83,8 @@ context( it('should render validation errors', () => { const fieldId = `${FIELD_ID}-${BELOW.ID}`; - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: fieldSelector(fieldId), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.ELIGIBILITY[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/uk-goods-or-services/uk-goods-or-services-answer-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/uk-goods-or-services/uk-goods-or-services-answer-no.spec.js index 20d7839b73..8ff00ed45c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/uk-goods-or-services/uk-goods-or-services-answer-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/uk-goods-or-services/uk-goods-or-services-answer-no.spec.js @@ -10,7 +10,7 @@ context( 'Insurance - UK goods or services page - as an exporter, I want to check if my export value is eligible for UKEF credit insurance cover - submit `no - UK goods/services is below the minimum`', () => { beforeEach(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'coverPeriod' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'coverPeriod' }); cy.clickNoRadioInput(); cy.clickSubmitButton(); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/uk-goods-or-services/uk-goods-or-services.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/uk-goods-or-services/uk-goods-or-services.spec.js index a39bee62e5..26904ef26e 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/uk-goods-or-services/uk-goods-or-services.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/uk-goods-or-services/uk-goods-or-services.spec.js @@ -29,7 +29,7 @@ context('Insurance - UK goods or services page - as an exporter, I want to check const url = `${baseUrl}${UK_GOODS_OR_SERVICES}`; before(() => { - cy.completeAndSubmitEligibilityForms({ formToStopAt: 'coverPeriod' }); + cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'coverPeriod' }); cy.assertUrl(url); }); @@ -104,11 +104,8 @@ context('Insurance - UK goods or services page - as an exporter, I want to check }); it('should render validation errors', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: yesRadio(FIELD_ID), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.ELIGIBILITY[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services-final-destination-not-known-and-total-contract-value-over-threshold.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services-final-destination-not-known-and-total-contract-value-over-threshold.spec.js index 5296392da4..f258d543ed 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services-final-destination-not-known-and-total-contract-value-over-threshold.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services-final-destination-not-known-and-total-contract-value-over-threshold.spec.js @@ -16,7 +16,7 @@ context('Insurance - Export contract - About goods or services page - Final dest referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'howWasTheContractAwarded' }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'howWasTheContractAwarded' }); url = `${baseUrl}${ROOT}/${referenceNumber}${ABOUT_GOODS_OR_SERVICES}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services-final-destination-not-known.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services-final-destination-not-known.spec.js index 972c28340c..8a516b386a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services-final-destination-not-known.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services-final-destination-not-known.spec.js @@ -28,7 +28,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'howWasTheContractAwarded' }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'howWasTheContractAwarded' }); url = `${baseUrl}${ROOT}/${referenceNumber}${ABOUT_GOODS_OR_SERVICES}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services-total-contract-value-over-threshold.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services-total-contract-value-over-threshold.spec.js index dbf8b7175c..c2542c3748 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services-total-contract-value-over-threshold.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services-total-contract-value-over-threshold.spec.js @@ -16,7 +16,7 @@ context('Insurance - Export contract - About goods or services page - Submission referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'howWasTheContractAwarded' }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'howWasTheContractAwarded' }); url = `${baseUrl}${ROOT}/${referenceNumber}${ABOUT_GOODS_OR_SERVICES}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services.spec.js index 9e4b6076a6..ed18eb857a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/about-goods-or-services.spec.js @@ -35,7 +35,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'howWasTheContractAwarded' }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'howWasTheContractAwarded' }); url = `${baseUrl}${ROOT}/${referenceNumber}${ABOUT_GOODS_OR_SERVICES}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/save-and-back.spec.js index 30b3a5857c..39b1650e20 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/save-and-back.spec.js @@ -25,7 +25,7 @@ context('Insurance - Export contract - About goods or services page - Save and g referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'howWasTheContractAwarded' }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'howWasTheContractAwarded' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${ABOUT_GOODS_OR_SERVICES}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/validation/about-goods-or-services-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/validation/about-goods-or-services-validation.spec.js index 22fdadcf7f..ad31782676 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/validation/about-goods-or-services-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/about-goods-or-services/validation/about-goods-or-services-validation.spec.js @@ -50,7 +50,7 @@ context('Insurance - Export contract - About goods or services page - form valid referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'howWasTheContractAwarded' }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'howWasTheContractAwarded' }); url = `${baseUrl}${ROOT}/${referenceNumber}${ABOUT_GOODS_OR_SERVICES}`; @@ -85,7 +85,7 @@ context('Insurance - Export contract - About goods or services page - form valid }); }); - it(`should display validation errors if ${DESCRIPTION} is over ${MAXIMUM} characters`, () => { + it(`should render validation errors if ${DESCRIPTION} is over ${MAXIMUM} characters`, () => { cy.navigateToUrl(url); cy.submitAndAssertFieldErrors({ 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 57e6b41a30..eed1008e4c 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 @@ -22,7 +22,7 @@ context("Insurance - Export contract - Agent charges page - As an Exporter I wan referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentService', isUsingAgent: true, agentIsCharging: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agentService', isUsingAgent: true, agentIsCharging: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES}`; 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 546513063b..b4f4179d5c 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 @@ -22,7 +22,7 @@ context('Insurance - Export contract - Agent charges page - Fixed sum amount as referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentService', isUsingAgent: true, agentIsCharging: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agentService', isUsingAgent: true, agentIsCharging: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES}`; agentChargesCurrencyUrl = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES_CURRENCY}`; 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 b3749d0360..2ebf201827 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 @@ -22,7 +22,7 @@ context('Insurance - Export contract - Agent charges page - Fixed sum amount wit referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentService', isUsingAgent: true, agentIsCharging: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agentService', isUsingAgent: true, agentIsCharging: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES}`; agentChargesCurrencyUrl = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES_CURRENCY}`; 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 734436cf5f..99bfad98d2 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 @@ -32,7 +32,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentService', isUsingAgent: true, agentIsCharging: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agentService', isUsingAgent: true, agentIsCharging: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES}`; agentChargesCurrencyUrl = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES_CURRENCY}`; @@ -86,11 +86,11 @@ context( cy.checkText(field.label(), OPTIONS.PERCENTAGE.TEXT); }); - it(`should NOT display conditional "${PERCENTAGE_CHARGE}" field`, () => { + it(`should NOT display a conditional "${PERCENTAGE_CHARGE}" field`, () => { fieldSelector(PERCENTAGE_CHARGE).input().should('not.be.visible'); }); - it(`should display conditional "${PERCENTAGE_CHARGE}" field when selecting the ${PERCENTAGE} radio`, () => { + it(`should render a conditional "${PERCENTAGE_CHARGE}" field when selecting the ${PERCENTAGE} radio`, () => { agentChargesPage[METHOD][PERCENTAGE].label().click(); const fieldId = PERCENTAGE_CHARGE; @@ -163,7 +163,7 @@ context( cy.assertAgentChargesFieldValues({ percentageMethod: true }); }); - it(`should display conditional "${PERCENTAGE_CHARGE}" field`, () => { + it(`should render a conditional "${PERCENTAGE_CHARGE}" field`, () => { fieldSelector(PERCENTAGE_CHARGE).input().should('be.visible'); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/save-and-back-method-fixed-sum.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/save-and-back-method-fixed-sum.spec.js index e109b93746..e030b43696 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/save-and-back-method-fixed-sum.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/save-and-back-method-fixed-sum.spec.js @@ -21,7 +21,7 @@ context(`Insurance - Export contract - Agent charges - Save and go back - ${METH referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentService', isUsingAgent: true, agentIsCharging: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agentService', isUsingAgent: true, agentIsCharging: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/save-and-back-method-percentage.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/save-and-back-method-percentage.spec.js index 1bad160285..1a1b8a4904 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/save-and-back-method-percentage.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/save-and-back-method-percentage.spec.js @@ -21,7 +21,7 @@ context(`Insurance - Export contract - Agent charges - Save and go back - ${METH referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentService', isUsingAgent: true, agentIsCharging: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agentService', isUsingAgent: true, agentIsCharging: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES}`; 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 f5fb639cf5..db3e60835a 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 @@ -21,7 +21,7 @@ context(`Insurance - Export contract - Agent charges - Save and go back - empty referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentService', isUsingAgent: true, agentIsCharging: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agentService', isUsingAgent: true, agentIsCharging: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/validation/agent-charges-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/validation/agent-charges-validation.spec.js index 78db1fafdf..091cb54e1c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/validation/agent-charges-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-charges/validation/agent-charges-validation.spec.js @@ -32,7 +32,7 @@ context('Insurance - Export contract - Agent charges page - form validation', () referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentService', isUsingAgent: true, agentIsCharging: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agentService', isUsingAgent: true, agentIsCharging: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/agent-details.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/agent-details.spec.js index d00ffdcbed..5200479c1f 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/agent-details.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/agent-details.spec.js @@ -32,7 +32,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agent', isUsingAgent: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agent', isUsingAgent: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_DETAILS}`; agentServiceUrl = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_SERVICE}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/save-and-back.spec.js index 6e672fceb8..53284cc9b9 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/save-and-back.spec.js @@ -16,7 +16,7 @@ context('Insurance - Export contract - Agent details - Save and go back', () => referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agent', isUsingAgent: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agent', isUsingAgent: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_DETAILS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/validation/agent-details-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/validation/agent-details-validation.spec.js index 362447b73b..ac1eb571dd 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/validation/agent-details-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-details/validation/agent-details-validation.spec.js @@ -33,7 +33,7 @@ context('Insurance - Export contract - Agent details page - form validation', () referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agent', isUsingAgent: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agent', isUsingAgent: true }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${AGENT_DETAILS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-service/agent-service.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-service/agent-service.spec.js index da9f7ffd4f..81f4ccf77c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-service/agent-service.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-service/agent-service.spec.js @@ -31,7 +31,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentDetails', isUsingAgent: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agentDetails', isUsingAgent: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_SERVICE}`; checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-service/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-service/save-and-back.spec.js index 977a375d8d..0bd98286e0 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-service/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-service/save-and-back.spec.js @@ -16,7 +16,7 @@ context('Insurance - Export contract - Agent service - Save and go back', () => referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentDetails', isUsingAgent: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agentDetails', isUsingAgent: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_SERVICE}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-service/validation/agent-service-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-service/validation/agent-service-validation.spec.js index b52fe4794c..c7df629c5d 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-service/validation/agent-service-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent-service/validation/agent-service-validation.spec.js @@ -32,7 +32,7 @@ context('Insurance - Export contract - Agent service page - form validation', () referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentDetails', isUsingAgent: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agentDetails', isUsingAgent: true }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${AGENT_SERVICE}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent/agent.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent/agent.spec.js index 0e91990a61..459217e177 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent/agent.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent/agent.spec.js @@ -30,7 +30,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'howYouWillGetPaid' }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'howYouWillGetPaid' }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT}`; agentDetailsUrl = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_DETAILS}`; @@ -96,7 +96,7 @@ context( }); describe('when submitting an empty form', () => { - it(`should display validation errors if ${FIELD_ID} radio is not selected`, () => { + it(`should render validation errors if ${FIELD_ID} radio is not selected`, () => { const radioField = { ...fieldSelector(FIELD_ID), input: noRadioInput, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent/save-and-back.spec.js index a83a8f3a39..f60c57a333 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/agent/save-and-back.spec.js @@ -21,7 +21,7 @@ context('Insurance - Export contract - Agent - Save and go back', () => { referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'howYouWillGetPaid' }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'howYouWillGetPaid' }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT}`; 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 661494b93c..2d7eac4033 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 @@ -1,4 +1,4 @@ -import { autoCompleteField, field, radios, summaryList } from '../../../../../../../pages/shared'; +import { radios, summaryList } from '../../../../../../../pages/shared'; import { agentChargesPage } from '../../../../../../../pages/insurance/export-contract'; import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insurance'; import { INSURANCE_FIELD_IDS } from '../../../../../../../constants/field-ids/insurance'; @@ -95,8 +95,8 @@ context( cy.assertRadioOptionIsNotChecked(agentChargesPage[METHOD][FIXED_SUM].input()); cy.assertRadioOptionIsNotChecked(agentChargesPage[METHOD][PERCENTAGE].input()); - cy.checkValue(field(PERCENTAGE_CHARGE), ''); - cy.checkValue(autoCompleteField(PAYABLE_COUNTRY_CODE), ''); + cy.assertEmptyFieldValue(PERCENTAGE_CHARGE); + cy.assertEmptyAutocompleteFieldValue(PAYABLE_COUNTRY_CODE); cy.completeAndSubmitAgentChargesForm({ fixedSumMethod: true }); @@ -111,7 +111,7 @@ context( cy.completeAndSubmitCurrencyForm({}); // assert HOW_MUCH_THE_AGENT_IS_CHARGING field values. - cy.checkValue(field(FIXED_SUM_AMOUNT), ''); + cy.assertEmptyFieldValue(FIXED_SUM_AMOUNT); }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/how-the-contract-was-awarded/change-your-answers-how-the-contract-was-awarded-from-other-method.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/how-the-contract-was-awarded/change-your-answers-how-the-contract-was-awarded-from-other-method.spec.js index ac7252a596..c2db1e6fad 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/how-the-contract-was-awarded/change-your-answers-how-the-contract-was-awarded-from-other-method.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/change-your-answers/how-the-contract-was-awarded/change-your-answers-how-the-contract-was-awarded-from-other-method.spec.js @@ -1,4 +1,4 @@ -import { summaryList, radios, field } from '../../../../../../../pages/shared'; +import { summaryList, radios } from '../../../../../../../pages/shared'; import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insurance'; import FIELD_IDS from '../../../../../../../constants/field-ids/insurance/export-contract'; import { EXPORT_CONTRACT_FIELDS as FIELDS } from '../../../../../../../content-strings/fields/insurance/export-contract'; @@ -58,7 +58,7 @@ context( }); it(`should have no value for ${OTHER_AWARD_METHOD} text input`, () => { - cy.checkValue(field(OTHER_AWARD_METHOD), ''); + cy.assertEmptyFieldValue(OTHER_AWARD_METHOD); }); }); }); 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 44dbd09955..907fcfa618 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 @@ -36,7 +36,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentCharges', isUsingAgent: true, agentIsCharging: true, fixedSumMethod: true }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'agentCharges', isUsingAgent: true, agentIsCharging: true, fixedSumMethod: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES_CURRENCY}`; howMuchAgentIsChargingUrl = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/declined-by-private-market/declined-by-private-market.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/declined-by-private-market/declined-by-private-market.spec.js index 9b6e76967b..04493174d4 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/declined-by-private-market/declined-by-private-market.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/declined-by-private-market/declined-by-private-market.spec.js @@ -41,7 +41,11 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'privateMarket', totalContractValueOverThreshold: true, attemptedPrivateMarketCover: true }); + cy.completeAndSubmitExportContractForms({ + stopSubmittingAfter: 'privateMarket', + totalContractValueOverThreshold: true, + attemptedPrivateMarketCover: true, + }); url = `${baseUrl}${ROOT}/${referenceNumber}${DECLINED_BY_PRIVATE_MARKET}`; agentUrl = `${baseUrl}${ROOT}/${referenceNumber}${AGENT}`; @@ -89,7 +93,7 @@ context( cy.navigateToUrl(url); }); - it(`should display validation errors if ${FIELD_ID} is left empty`, () => { + it(`should render validation errors if ${FIELD_ID} is left empty`, () => { cy.submitAndAssertFieldErrors({ field: textareaField, expectedErrorMessage: ERRORS[FIELD_ID].IS_EMPTY, @@ -97,7 +101,7 @@ context( }); describe(`when ${FIELD_ID} is over ${MAXIMUM_CHARACTERS.DECLINED_BY_PRIVATE_MARKET_DESCRIPTION} characters`, () => { - it('should display validation errors and retain the submitted value', () => { + it('should render validation errors and retain the submitted value', () => { const submittedValue = 'a'.repeat(MAXIMUM_CHARACTERS.DECLINED_BY_PRIVATE_MARKET_DESCRIPTION + 1); cy.submitAndAssertFieldErrors({ diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/declined-by-private-market/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/declined-by-private-market/save-and-back.spec.js index 437c2b5d42..ae8ff84ce3 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/declined-by-private-market/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/declined-by-private-market/save-and-back.spec.js @@ -22,7 +22,11 @@ context('Insurance - Export contract - Declined by private market - Save and go referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'privateMarket', totalContractValueOverThreshold: true, attemptedPrivateMarketCover: true }); + cy.completeAndSubmitExportContractForms({ + stopSubmittingAfter: 'privateMarket', + totalContractValueOverThreshold: true, + attemptedPrivateMarketCover: true, + }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${DECLINED_BY_PRIVATE_MARKET}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-the-agent-is-charging/how-much-the-agent-is-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 index 06371bb5ed..68f72e8faf 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-the-agent-is-charging/how-much-the-agent-is-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 @@ -31,7 +31,12 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'currencyOfAgentCharges', isUsingAgent: true, agentIsCharging: true, fixedSumMethod: true }); + cy.completeAndSubmitExportContractForms({ + stopSubmittingAfter: 'currencyOfAgentCharges', + isUsingAgent: true, + agentIsCharging: true, + fixedSumMethod: true, + }); url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`; checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; 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 index 5a5ad45afd..2e2abd3497 100644 --- 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 @@ -23,7 +23,7 @@ context('Insurance - Export contract - How much the agent is charging - Save and // go to the page we want to test. cy.completeAndSubmitExportContractForms({ - formToStopAt: 'currencyOfAgentCharges', + stopSubmittingAfter: 'currencyOfAgentCharges', isUsingAgent: true, agentIsCharging: true, fixedSumMethod: true, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-the-agent-is-charging/validation/how-much-the-agent-is-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 index 9e6f88ae4a..5f4bebc895 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-much-the-agent-is-charging/validation/how-much-the-agent-is-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 @@ -51,11 +51,11 @@ context('Insurance - Export contract - How much the agent is charging page - for cy.deleteApplication(referenceNumber); }); - it(`should display validation errors when ${FIELD_ID} is left empty`, () => { + it(`should render validation errors when ${FIELD_ID} is left empty`, () => { cy.submitAndAssertFieldErrors({ ...assertions, expectedErrorMessage: ERROR_MESSAGES_OBJECT.IS_EMPTY }); }); - it(`should display validation errors when ${FIELD_ID} has special characters`, () => { + it(`should render validation errors when ${FIELD_ID} has special characters`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '10!', @@ -63,7 +63,7 @@ context('Insurance - Export contract - How much the agent is charging page - for }); }); - it(`should display validation errors when ${FIELD_ID} has letters`, () => { + it(`should render validation errors when ${FIELD_ID} has letters`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: 'one', @@ -71,7 +71,7 @@ context('Insurance - Export contract - How much the agent is charging page - for }); }); - it(`should display validation errors when ${FIELD_ID} is below ${MINIMUM_CHARACTERS.ONE}`, () => { + it(`should render validation errors when ${FIELD_ID} is below ${MINIMUM_CHARACTERS.ONE}`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: String(MINIMUM_CHARACTERS.ONE - 1), diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-was-the-contract-awarded/how-was-the-contract-awarded-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-was-the-contract-awarded/how-was-the-contract-awarded-validation.spec.js index e941962447..78f1605052 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-was-the-contract-awarded/how-was-the-contract-awarded-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-was-the-contract-awarded/how-was-the-contract-awarded-validation.spec.js @@ -56,7 +56,7 @@ context('Insurance - Export contract - How was the contract awarded page - form cy.navigateToUrl(url); }); - it('should display validation error', () => { + it('should render a validation error', () => { const expectedErrorMessage = ERROR_MESSAGES_OBJECT[AWARD_METHOD].IS_EMPTY; const radioField = { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-was-the-contract-awarded/how-was-the-contract-awarded.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-was-the-contract-awarded/how-was-the-contract-awarded.spec.js index d04ecfd560..dfa3822e48 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-was-the-contract-awarded/how-was-the-contract-awarded.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-was-the-contract-awarded/how-was-the-contract-awarded.spec.js @@ -103,11 +103,11 @@ context( cy.checkValue(selector, OTHER.DB_ID); }); - it(`should NOT display conditional "${OTHER_AWARD_METHOD}" section without selecting the "${OTHER.VALUE}" radio`, () => { + it(`should NOT display a conditional "${OTHER_AWARD_METHOD}" section without selecting the "${OTHER.VALUE}" radio`, () => { fieldSelector(OTHER_AWARD_METHOD).input().should('not.be.visible'); }); - it(`should display conditional "${OTHER_AWARD_METHOD}" section when selecting the "${OTHER.VALUE}" radio`, () => { + it(`should render a conditional "${OTHER_AWARD_METHOD}" section when selecting the "${OTHER.VALUE}" radio`, () => { radios(AWARD_METHOD_OPTIONS.OTHER.ID).option.label().click(); fieldSelector(OTHER_AWARD_METHOD).input().should('be.visible'); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-will-you-get-paid/how-will-you-get-paid-total-contract-value-over-threshold.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-will-you-get-paid/how-will-you-get-paid-total-contract-value-over-threshold.spec.js index 8c2c359639..80b1f58526 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-will-you-get-paid/how-will-you-get-paid-total-contract-value-over-threshold.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-will-you-get-paid/how-will-you-get-paid-total-contract-value-over-threshold.spec.js @@ -16,7 +16,7 @@ context('Insurance - Export contract - How will you get paid page - Submission w referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'aboutGoodsOrServices' }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'aboutGoodsOrServices' }); privateMarketUrl = `${baseUrl}${ROOT}/${referenceNumber}${PRIVATE_MARKET}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-will-you-get-paid/how-will-you-get-paid.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-will-you-get-paid/how-will-you-get-paid.spec.js index ceb6a80223..0d12b7577c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-will-you-get-paid/how-will-you-get-paid.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-will-you-get-paid/how-will-you-get-paid.spec.js @@ -24,7 +24,6 @@ const { } = ERROR_MESSAGES; const field = howWillYouGetPaidPage[FIELD_ID]; -const expectedErrorsCount = 1; const baseUrl = Cypress.config('baseUrl'); @@ -39,7 +38,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'aboutGoodsOrServices' }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'aboutGoodsOrServices' }); url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_WILL_YOU_GET_PAID}`; }); @@ -95,22 +94,20 @@ context( cy.navigateToUrl(url); }); - it(`should display validation errors if ${FIELD_ID} is left empty`, () => { + it(`should render validation errors if ${FIELD_ID} is left empty`, () => { cy.submitAndAssertFieldErrors({ field, - expectedErrorsCount, expectedErrorMessage: ERRORS[FIELD_ID].IS_EMPTY, }); }); describe(`when ${FIELD_ID} is over ${MAXIMUM_CHARACTERS.PAYMENT_TERMS_DESCRIPTION} characters`, () => { - it('should display validation errors and retain the submitted value', () => { + it('should render validation errors and retain the submitted value', () => { const submittedValue = 'a'.repeat(MAXIMUM_CHARACTERS.PAYMENT_TERMS_DESCRIPTION + 1); cy.submitAndAssertFieldErrors({ field, value: submittedValue, - expectedErrorsCount, expectedErrorMessage: ERRORS[FIELD_ID].ABOVE_MAXIMUM, }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-will-you-get-paid/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-will-you-get-paid/save-and-back.spec.js index 86305cda3f..64ddb835f8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-will-you-get-paid/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/how-will-you-get-paid/save-and-back.spec.js @@ -26,7 +26,7 @@ context('Insurance - Export contract - How will you get paid page - Save and go referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'aboutGoodsOrServices' }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'aboutGoodsOrServices' }); url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_WILL_YOU_GET_PAID}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/private-market/private-market.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/private-market/private-market.spec.js index c0fb80497f..155fa44d76 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/private-market/private-market.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/private-market/private-market.spec.js @@ -37,7 +37,7 @@ context( declinedByPrivateMarketUrl = `${baseUrl}${ROOT}/${referenceNumber}${DECLINED_BY_PRIVATE_MARKET}`; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'howYouWillGetPaid' }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'howYouWillGetPaid' }); }); }); @@ -110,7 +110,7 @@ context( }); describe('when submitting an empty form', () => { - it(`should display validation errors if ${FIELD_ID} radio is not selected`, () => { + it(`should render validation errors if ${FIELD_ID} radio is not selected`, () => { const radioField = { ...fieldSelector(FIELD_ID), input: noRadioInput, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/private-market/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/private-market/save-and-back.spec.js index 24b539ece6..46f686fcd9 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/export-contract/private-market/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/export-contract/private-market/save-and-back.spec.js @@ -21,7 +21,7 @@ context('Insurance - Export contract - Private market - Save and go back', () => referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitExportContractForms({ formToStopAt: 'howYouWillGetPaid' }); + cy.completeAndSubmitExportContractForms({ stopSubmittingAfter: 'howYouWillGetPaid' }); url = `${baseUrl}${ROOT}/${referenceNumber}${PRIVATE_MARKET}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/another-company/another-company.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/another-company/another-company.spec.js index bf078aca13..8ae1d91ced 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/another-company/another-company.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/another-company/another-company.spec.js @@ -42,7 +42,7 @@ context(`Insurance - Policy - Another company page - ${story}`, () => { referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'preCreditPeriod' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'preCreditPeriod' }); url = `${baseUrl}${ROOT}/${referenceNumber}${ANOTHER_COMPANY}`; brokerUrl = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/another-company/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/another-company/save-and-back.spec.js index 515bb46243..876979b978 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/another-company/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/another-company/save-and-back.spec.js @@ -21,7 +21,7 @@ context('Insurance - Policy - Another company page - Save and back', () => { referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'preCreditPeriod' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'preCreditPeriod' }); url = `${baseUrl}${ROOT}/${referenceNumber}${ANOTHER_COMPANY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-confirm-address/broker-confirm-address.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-confirm-address/broker-confirm-address.spec.js index a57a29dc4f..2e1ebd592b 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-confirm-address/broker-confirm-address.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-confirm-address/broker-confirm-address.spec.js @@ -1,5 +1,4 @@ -import { headingCaption } from '../../../../../../partials'; -import { insetTextHtml, insetTextHtmlLineBreak } from '../../../../../../pages/shared'; +import { insetTextHtml, insetTextHtmlLineBreak, headingCaption } from '../../../../../../pages/shared'; import { brokerConfirmAddressPage } from '../../../../../../pages/insurance/policy'; import { BUTTONS, PAGES } from '../../../../../../content-strings'; import { EXPECTED_SINGLE_LINE_STRING } from '../../../../../../constants'; @@ -32,7 +31,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'brokerDetails', usingBroker: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'brokerDetails', usingBroker: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_CONFIRM_ADDRESS_ROOT}`; lossPayeeUrl = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-details/broker-details-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-details/broker-details-page.spec.js index 849b5872ca..b423b824d7 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-details/broker-details-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-details/broker-details-page.spec.js @@ -1,5 +1,4 @@ -import { headingCaption } from '../../../../../../partials'; -import { field as fieldSelector } from '../../../../../../pages/shared'; +import { field as fieldSelector, headingCaption } from '../../../../../../pages/shared'; import { PAGES } from '../../../../../../content-strings'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; import { POLICY as POLICY_FIELD_IDS } from '../../../../../../constants/field-ids/insurance/policy'; @@ -32,7 +31,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'broker', usingBroker: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'broker', usingBroker: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_DETAILS_ROOT}`; brokerConfirmAddressUrl = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_CONFIRM_ADDRESS_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-details/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-details/save-and-back.spec.js index 6e7c2d6157..c3b5bd688d 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-details/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-details/save-and-back.spec.js @@ -23,7 +23,7 @@ context('Insurance - Policy - Broker details page - Save and back', () => { referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'broker', usingBroker: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'broker', usingBroker: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_DETAILS_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-details/validation/broker-details-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-details/validation/broker-details-validation.spec.js index 3c3aa6f356..6af28e7417 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-details/validation/broker-details-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/broker-details/validation/broker-details-validation.spec.js @@ -31,7 +31,7 @@ context('Insurance - Policy - Broker details page - validation', () => { referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'broker', usingBroker: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'broker', usingBroker: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_DETAILS_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/broker/broker-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/broker/broker-page.spec.js index 2c5a121732..61f46762b5 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/broker/broker-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/broker/broker-page.spec.js @@ -1,6 +1,5 @@ import { brokerPage } from '../../../../../../pages/insurance/policy'; -import { headingCaption } from '../../../../../../partials'; -import { field as fieldSelector, yesRadio, noRadio, noRadioInput } from '../../../../../../pages/shared'; +import { field as fieldSelector, yesRadio, noRadio, noRadioInput, headingCaption } from '../../../../../../pages/shared'; import { PAGES, ERROR_MESSAGES, LINKS } from '../../../../../../content-strings'; import { FIELD_VALUES } from '../../../../../../constants'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; @@ -40,7 +39,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'anotherCompany' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'anotherCompany' }); url = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_ROOT}`; lossPayeeUrl = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_ROOT}`; @@ -156,7 +155,7 @@ context( }); describe('when submitting an empty form', () => { - it(`should display validation errors if ${FIELD_ID} radio is not selected`, () => { + it(`should render validation errors if ${FIELD_ID} radio is not selected`, () => { cy.navigateToUrl(url); const { numberOfExpectedErrors, errorIndex } = ERROR_ASSERTIONS; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/broker/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/broker/save-and-back.spec.js index 78b6c45bc0..972bf14104 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/broker/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/broker/save-and-back.spec.js @@ -19,7 +19,7 @@ context('Insurance - Policy - Broker page - Save and back', () => { referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'anotherCompany' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'anotherCompany' }); url = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/broker/change-your-answers-change-broker-yes-to-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/broker/change-your-answers-change-broker-yes-to-no.spec.js index ec5f57bfbd..efcc09007c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/broker/change-your-answers-change-broker-yes-to-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/broker/change-your-answers-change-broker-yes-to-no.spec.js @@ -1,4 +1,4 @@ -import { field, summaryList } from '../../../../../../../pages/shared'; +import { summaryList } from '../../../../../../../pages/shared'; import { POLICY as POLICY_FIELD_IDS } from '../../../../../../../constants/field-ids/insurance/policy'; import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insurance'; import { FIELD_VALUES } from '../../../../../../../constants'; @@ -80,8 +80,8 @@ context('Insurance - Policy - Change your answers - Broker - Yes to no - As an e cy.completeAndSubmitBrokerForm({ usingBroker: true }); - cy.checkValue(field(NAME), ''); - cy.checkValue(field(EMAIL), ''); + cy.assertEmptyFieldValue(NAME); + cy.assertEmptyFieldValue(EMAIL); cy.checkTextareaValue({ fieldId: FULL_ADDRESS, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/multiple-policy/change-your-answers-change-policy-type-multiple-to-single-to-multiple.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/multiple-policy/change-your-answers-change-policy-type-multiple-to-single-to-multiple.spec.js index 8ece870962..fa8f1b716b 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/multiple-policy/change-your-answers-change-policy-type-multiple-to-single-to-multiple.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/multiple-policy/change-your-answers-change-policy-type-multiple-to-single-to-multiple.spec.js @@ -1,4 +1,4 @@ -import { field, summaryList } from '../../../../../../../pages/shared'; +import { summaryList } from '../../../../../../../pages/shared'; import { FIELD_VALUES } from '../../../../../../../constants'; import FIELD_IDS from '../../../../../../../constants/field-ids/insurance/policy'; import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insurance'; @@ -64,13 +64,13 @@ context('Insurance - Policy - Change your answers - Policy type - multiple to si it(`should have empty field values when going back to ${MULTIPLE_CONTRACT_POLICY} and ${MULTIPLE_CONTRACT_POLICY_EXPORT_VALUE}`, () => { cy.assertEmptyRequestedStartDateFieldValues(); - cy.checkValue(field(TOTAL_MONTHS_OF_COVER), ''); + cy.assertEmptyFieldValue(TOTAL_MONTHS_OF_COVER); cy.assertCurrencyFormFieldsAreEmpty(); cy.navigateToUrl(exportValueUrl); - cy.checkValue(field(TOTAL_SALES_TO_BUYER), ''); - cy.checkValue(field(MAXIMUM_BUYER_WILL_OWE), ''); + cy.assertEmptyFieldValue(TOTAL_SALES_TO_BUYER); + cy.assertEmptyFieldValue(MAXIMUM_BUYER_WILL_OWE); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/single-policy/change-your-answers-change-policy-type-single-to-multiple-to-single.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/single-policy/change-your-answers-change-policy-type-single-to-multiple-to-single.spec.js index 8eff29e48a..03c7a7e1d9 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/single-policy/change-your-answers-change-policy-type-single-to-multiple-to-single.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/single-policy/change-your-answers-change-policy-type-single-to-multiple-to-single.spec.js @@ -1,4 +1,4 @@ -import { field, summaryList } from '../../../../../../../pages/shared'; +import { summaryList } from '../../../../../../../pages/shared'; import { FIELD_VALUES } from '../../../../../../../constants'; import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insurance'; import FIELD_IDS from '../../../../../../../constants/field-ids/insurance/policy'; @@ -47,7 +47,7 @@ context('Insurance - Policy - Change your answers - Policy type - single to mult cy.navigateToUrl(checkYourAnswersUrl); cy.changePolicyTypeToMultipleAndSubmitContractPolicyForm(); - cy.completeAndSubmitExportValueForm(); + cy.completeAndSubmitExportValueForm({}); summaryList.field(POLICY_TYPE).changeLink().click(); @@ -66,7 +66,7 @@ context('Insurance - Policy - Change your answers - Policy type - single to mult cy.navigateToUrl(totalContractValueUrl); - cy.checkValue(field(TOTAL_CONTRACT_VALUE), ''); - cy.checkValue(field(REQUESTED_CREDIT_LIMIT), ''); + cy.assertEmptyFieldValue(TOTAL_CONTRACT_VALUE); + cy.assertEmptyFieldValue(REQUESTED_CREDIT_LIMIT); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/single-policy/change-your-answers-change-policy-type-single-to-multiple.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/single-policy/change-your-answers-change-policy-type-single-to-multiple.spec.js index 6bba51ddb4..e3dcf15f3c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/single-policy/change-your-answers-change-policy-type-single-to-multiple.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/change-your-answers/single-policy/change-your-answers-change-policy-type-single-to-multiple.spec.js @@ -81,7 +81,7 @@ context('Insurance - Policy - Change your answers - Policy type - single to mult cy.navigateToUrl(checkYourAnswersUrl); cy.changePolicyTypeToMultipleAndSubmitContractPolicyForm(); - cy.completeAndSubmitExportValueForm(); + cy.completeAndSubmitExportValueForm({}); }); it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/complete-policy-as-multiple-contract-policy.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/complete-policy-as-multiple-contract-policy.spec.js index c84169e33f..6707f53525 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/complete-policy-as-multiple-contract-policy.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/complete-policy-as-multiple-contract-policy.spec.js @@ -9,7 +9,7 @@ context('Insurance - Policy - Complete the entire section as a multiple contract cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayee', policyType }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayee', policyType }); /** * Submit the "Policy - check your answers" form, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/complete-policy-as-single-contract-policy.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/complete-policy-as-single-contract-policy.spec.js index 85794964b3..9ad461c99c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/complete-policy-as-single-contract-policy.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/complete-policy-as-single-contract-policy.spec.js @@ -5,7 +5,7 @@ context('Insurance - Policy - Complete the entire section as a single contract p cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayee' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayee' }); /** * Submit the "Policy - check your answers" form, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/changing-from-different-name-to-same-name-then-back-to-different-name.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/changing-from-different-name-to-same-name-then-back-to-different-name.spec.js index a9e65e64cb..e41adca909 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/changing-from-different-name-to-same-name-then-back-to-different-name.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/changing-from-different-name-to-same-name-then-back-to-different-name.spec.js @@ -24,7 +24,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayee' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayee' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/changing-from-same-name-to-different-name.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/changing-from-same-name-to-different-name.spec.js index 0e1edfd1e2..db69c04a8a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/changing-from-same-name-to-different-name.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/changing-from-same-name-to-different-name.spec.js @@ -24,7 +24,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayee' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayee' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/different-name-on-policy-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/different-name-on-policy-page.spec.js index 7292de0bc1..e3e54f5b89 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/different-name-on-policy-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/different-name-on-policy-page.spec.js @@ -35,7 +35,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'nameOnPolicy', sameName: false }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'nameOnPolicy', sameName: false }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${DIFFERENT_NAME_ON_POLICY}`; @@ -72,7 +72,7 @@ context( cy.checkText(fieldSelector(POLICY_CONTACT_DETAIL).hint(), CONTENT_STRINGS.HINT); }); - it(`should display ${FIRST_NAME} field and be prepopulated`, () => { + it(`should render a prepopulated ${FIRST_NAME} field`, () => { const fieldId = FIRST_NAME; const field = fieldSelector(fieldId); @@ -81,7 +81,7 @@ context( cy.checkText(field.label(), ACCOUNT_FIELDS[fieldId].LABEL); }); - it(`should display ${LAST_NAME} field and be prepopulated`, () => { + it(`should render a prepopulated ${LAST_NAME} field`, () => { const fieldId = LAST_NAME; const field = fieldSelector(fieldId); @@ -90,7 +90,7 @@ context( cy.checkText(field.label(), ACCOUNT_FIELDS[fieldId].LABEL); }); - it(`should display ${EMAIL} field and be prepopulated`, () => { + it(`should render a prepopulated ${EMAIL} field`, () => { const fieldId = EMAIL; const field = fieldSelector(fieldId); @@ -99,7 +99,7 @@ context( cy.checkText(field.label(), ACCOUNT_FIELDS[fieldId].LABEL); }); - it(`should display ${POSITION} field and should not be prepopulated`, () => { + it(`should render a ${POSITION} field that is not prepopulated`, () => { const fieldId = POSITION; const field = fieldSelector(fieldId); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/entering-details-of-policy-owner.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/entering-details-of-policy-owner.spec.js index 3b8645ea51..87d4e998f9 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/entering-details-of-policy-owner.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/entering-details-of-policy-owner.spec.js @@ -30,7 +30,7 @@ context(`Insurance - Policy - Different name on Policy page - Entering name of p referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'nameOnPolicy', sameName: false }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'nameOnPolicy', sameName: false }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${DIFFERENT_NAME_ON_POLICY}`; cy.assertUrl(url); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/save-and-back.spec.js index 5c33b4bf92..bd342a0762 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/save-and-back.spec.js @@ -27,7 +27,7 @@ context('Insurance - Policy - Different name on policy - Save and go back', () = cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'nameOnPolicy', sameName: false }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'nameOnPolicy', sameName: false }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${DIFFERENT_NAME_ON_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/validation/different-name-on-policy-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/validation/different-name-on-policy-validation.spec.js index 2538ca7f2c..18450f313c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/validation/different-name-on-policy-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/different-name-on-policy/validation/different-name-on-policy-validation.spec.js @@ -37,7 +37,7 @@ context('Insurance - Policy - Different name on Policy page - Validation', () => referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'nameOnPolicy', sameName: false }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'nameOnPolicy', sameName: false }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${DIFFERENT_NAME_ON_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-details/loss-payee-details.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-details/loss-payee-details.spec.js index 487c4f059f..9752222297 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-details/loss-payee-details.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-details/loss-payee-details.spec.js @@ -1,5 +1,4 @@ -import { headingCaption } from '../../../../../../partials'; -import { field as fieldSelector } from '../../../../../../pages/shared'; +import { field as fieldSelector, headingCaption } from '../../../../../../pages/shared'; import { PAGES } from '../../../../../../content-strings'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; import { POLICY as POLICY_FIELD_IDS } from '../../../../../../constants/field-ids/insurance/policy'; @@ -36,7 +35,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayee', isAppointingLossPayee: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayee', isAppointingLossPayee: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_DETAILS_ROOT}`; lossPayeeFinancialUkUrl = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_FINANCIAL_DETAILS_UK_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-details/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-details/save-and-back.spec.js index 0041dc733a..4e604b8489 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-details/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-details/save-and-back.spec.js @@ -25,7 +25,7 @@ context('Insurance - Policy - Loss payee details page - Save and back', () => { referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayee', isAppointingLossPayee: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayee', isAppointingLossPayee: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_DETAILS_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-details/validation/loss-payee-details-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-details/validation/loss-payee-details-validation.spec.js index 877f6e246f..f04e85dde4 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-details/validation/loss-payee-details-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-details/validation/loss-payee-details-validation.spec.js @@ -27,7 +27,7 @@ context('Insurance - Policy - Loss Payee Details - Validation', () => { referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayee', isAppointingLossPayee: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayee', isAppointingLossPayee: true }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${LOSS_PAYEE_DETAILS_ROOT}`; @@ -67,7 +67,7 @@ context('Insurance - Policy - Loss Payee Details - Validation', () => { const FIELD_ID = LOCATION; const ERROR = ERRORS[FIELD_ID]; - it('should display validation error when radio is not selected', () => { + it('should render a validation error when radio is not selected', () => { const radioField = { ...fieldSelector(FIELD_ID), input: fieldSelector(`${LOCATION}-${IS_LOCATED_IN_UK}`).input, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/loss-payee-financial-details-international-lower-case.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/loss-payee-financial-details-international-lower-case.spec.js index 8ebecfc2d6..b292a25eb3 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/loss-payee-financial-details-international-lower-case.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/loss-payee-financial-details-international-lower-case.spec.js @@ -21,7 +21,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayeeDetails', isAppointingLossPayee: true, locatedInUK: false }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayeeDetails', isAppointingLossPayee: true, locatedInUK: false }); url = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_FINANCIAL_DETAILS_INTERNATIONAL_ROOT}`; checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/loss-payee-financial-details-international.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/loss-payee-financial-details-international.spec.js index c3120b4100..e9216c5dc4 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/loss-payee-financial-details-international.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/loss-payee-financial-details-international.spec.js @@ -1,5 +1,4 @@ -import { headingCaption } from '../../../../../../partials'; -import { field as fieldSelector } from '../../../../../../pages/shared'; +import { field as fieldSelector, headingCaption } from '../../../../../../pages/shared'; import { PAGES } from '../../../../../../content-strings'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; import { POLICY as POLICY_FIELD_IDS } from '../../../../../../constants/field-ids/insurance/policy'; @@ -31,7 +30,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayeeDetails', isAppointingLossPayee: true, locatedInUK: false }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayeeDetails', isAppointingLossPayee: true, locatedInUK: false }); url = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_FINANCIAL_DETAILS_INTERNATIONAL_ROOT}`; checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/save-and-back.spec.js index a70b7a2625..322c8def20 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/save-and-back.spec.js @@ -24,7 +24,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayeeDetails', isAppointingLossPayee: true, locatedInUK: false }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayeeDetails', isAppointingLossPayee: true, locatedInUK: false }); url = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_FINANCIAL_DETAILS_INTERNATIONAL_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/validation/bic-swift-code-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/validation/bic-swift-code-validation.spec.js index bfd448c5da..b194fe9ec8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/validation/bic-swift-code-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/validation/bic-swift-code-validation.spec.js @@ -17,7 +17,7 @@ context('Insurance - Policy - Loss Payee Financial Details International - BIC/S referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayeeDetails', isAppointingLossPayee: true, locatedInUK: false }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayeeDetails', isAppointingLossPayee: true, locatedInUK: false }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${LOSS_PAYEE_FINANCIAL_DETAILS_INTERNATIONAL_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/validation/financial-address-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/validation/financial-address-validation.spec.js index 472f4d8b13..2a96b20bc8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/validation/financial-address-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/validation/financial-address-validation.spec.js @@ -17,7 +17,7 @@ context('Insurance - Policy - Loss Payee Financial Details International - Finan referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayeeDetails', isAppointingLossPayee: true, locatedInUK: false }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayeeDetails', isAppointingLossPayee: true, locatedInUK: false }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${LOSS_PAYEE_FINANCIAL_DETAILS_INTERNATIONAL_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/validation/iban-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/validation/iban-validation.spec.js index 36ef3dd1a3..42ae7572fc 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/validation/iban-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-international/validation/iban-validation.spec.js @@ -17,7 +17,7 @@ context('Insurance - Policy - Loss Payee Financial Details International - IBAN referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayeeDetails', isAppointingLossPayee: true, locatedInUK: false }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayeeDetails', isAppointingLossPayee: true, locatedInUK: false }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${LOSS_PAYEE_FINANCIAL_DETAILS_INTERNATIONAL_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/loss-payee-financial-details-uk.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/loss-payee-financial-details-uk.spec.js index 8c4b3f4ca9..1c614436f1 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/loss-payee-financial-details-uk.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/loss-payee-financial-details-uk.spec.js @@ -1,5 +1,4 @@ -import { headingCaption } from '../../../../../../partials'; -import { field as fieldSelector } from '../../../../../../pages/shared'; +import { field as fieldSelector, headingCaption } from '../../../../../../pages/shared'; import { PAGES } from '../../../../../../content-strings'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; import { POLICY as POLICY_FIELD_IDS } from '../../../../../../constants/field-ids/insurance/policy'; @@ -31,7 +30,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayeeDetails', isAppointingLossPayee: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayeeDetails', isAppointingLossPayee: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_FINANCIAL_DETAILS_UK_ROOT}`; checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/save-and-back.spec.js index 4597bd5bb5..305e53c518 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/save-and-back.spec.js @@ -24,7 +24,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayeeDetails', isAppointingLossPayee: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayeeDetails', isAppointingLossPayee: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_FINANCIAL_DETAILS_UK_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/validation/account-number-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/validation/account-number-validation.spec.js index 6e8211811e..1ee6284dde 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/validation/account-number-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/validation/account-number-validation.spec.js @@ -31,7 +31,7 @@ context('Insurance - Policy - Loss Payee Financial Details UK - Account number - referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayeeDetails', isAppointingLossPayee: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayeeDetails', isAppointingLossPayee: true }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${LOSS_PAYEE_FINANCIAL_DETAILS_UK_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/validation/financial-address-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/validation/financial-address-validation.spec.js index 8248476779..2dc7d52897 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/validation/financial-address-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/validation/financial-address-validation.spec.js @@ -17,7 +17,7 @@ context('Insurance - Policy - Loss Payee Financial Details UK - Financial addres referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayeeDetails', isAppointingLossPayee: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayeeDetails', isAppointingLossPayee: true }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${LOSS_PAYEE_FINANCIAL_DETAILS_UK_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/validation/sort-code-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/validation/sort-code-validation.spec.js index 5e5c78f96b..7c45449984 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/validation/sort-code-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee-financial-details-uk/validation/sort-code-validation.spec.js @@ -31,7 +31,7 @@ context('Insurance - Policy - Loss Payee Financial Details UK - Sort code - Vali referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'lossPayeeDetails', isAppointingLossPayee: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'lossPayeeDetails', isAppointingLossPayee: true }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${LOSS_PAYEE_FINANCIAL_DETAILS_UK_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee/loss-payee.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee/loss-payee.spec.js index ee015bb595..08b6b59292 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee/loss-payee.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee/loss-payee.spec.js @@ -1,5 +1,4 @@ -import { headingCaption } from '../../../../../../partials'; -import { field as fieldSelector, noRadio, noRadioInput, yesRadio } from '../../../../../../pages/shared'; +import { field as fieldSelector, headingCaption, noRadio, noRadioInput, yesRadio } from '../../../../../../pages/shared'; import { ERROR_MESSAGES, PAGES } from '../../../../../../content-strings'; import { FIELD_VALUES } from '../../../../../../constants'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; @@ -36,7 +35,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'broker' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'broker' }); url = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_ROOT}`; checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; @@ -107,7 +106,7 @@ context( }); describe('when submitting an empty form', () => { - it(`should display validation errors if ${FIELD_ID} radio is not selected`, () => { + it(`should render validation errors if ${FIELD_ID} radio is not selected`, () => { const radioField = { ...fieldSelector(FIELD_ID), input: noRadioInput, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee/save-and-back.spec.js index 26da9f83c3..ae0c8010d3 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/loss-payee/save-and-back.spec.js @@ -21,7 +21,7 @@ context('Insurance - Policy - Loss payee page - Save and back', () => { referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'broker' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'broker' }); url = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/multiple-contract-policy-export-value-alternative-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/multiple-contract-policy-export-value-alternative-currency.spec.js index 578861331e..733b57ef3e 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/multiple-contract-policy-export-value-alternative-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/multiple-contract-policy-export-value-alternative-currency.spec.js @@ -37,7 +37,7 @@ context('Insurance - Policy - Multiple contract policy - Export value page - Alt referenceNumber = refNumber; cy.completeAndSubmitPolicyForms({ - formToStopAt: 'multipleContractPolicy', + stopSubmittingAfter: 'multipleContractPolicy', policyType, isoCode: NON_STANDARD_CURRENCY_CODE, alternativeCurrency: true, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/multiple-contract-policy-export-value-non-gbp-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/multiple-contract-policy-export-value-non-gbp-currency.spec.js index 34d07740eb..637e266731 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/multiple-contract-policy-export-value-non-gbp-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/multiple-contract-policy-export-value-non-gbp-currency.spec.js @@ -36,7 +36,7 @@ context('Insurance - Policy - Multiple contract policy - Export value page - Non cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'multipleContractPolicy', policyType, isoCode: USD.isoCode }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'multipleContractPolicy', policyType, isoCode: USD.isoCode }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MULTIPLE_CONTRACT_POLICY_EXPORT_VALUE}`; multipleContractPolicyUrl = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MULTIPLE_CONTRACT_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/multiple-contract-policy-export-value.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/multiple-contract-policy-export-value.spec.js index 8bd3fbdbcd..0e36a12c6c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/multiple-contract-policy-export-value.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/multiple-contract-policy-export-value.spec.js @@ -1,6 +1,6 @@ import { field as fieldSelector, headingCaption } from '../../../../../../../pages/shared'; import { multipleContractPolicyExportValuePage } from '../../../../../../../pages/insurance/policy'; -import { PAGES } from '../../../../../../../content-strings'; +import { LINKS, PAGES } from '../../../../../../../content-strings'; import { POLICY_FIELDS as FIELDS } from '../../../../../../../content-strings/fields/insurance/policy'; import { FIELD_VALUES } from '../../../../../../../constants'; import { POLICY as POLICY_FIELD_IDS } from '../../../../../../../constants/field-ids/insurance/policy'; @@ -38,7 +38,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'multipleContractPolicy', policyType }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'multipleContractPolicy', policyType }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MULTIPLE_CONTRACT_POLICY_EXPORT_VALUE}`; @@ -54,7 +54,7 @@ context( cy.deleteApplication(referenceNumber); }); - it('renders core page elements', () => { + it('should render core page elements', () => { cy.corePageChecks({ pageTitle: `${CONTENT_STRINGS.PAGE_TITLE} ${GBP.name}`, currentHref: `${INSURANCE_ROOT}/${referenceNumber}${MULTIPLE_CONTRACT_POLICY_EXPORT_VALUE}`, @@ -67,11 +67,11 @@ context( cy.navigateToUrl(url); }); - it('renders a heading caption', () => { + it('should render a heading caption', () => { cy.checkText(headingCaption(), CONTENT_STRINGS.HEADING_CAPTION); }); - it('renders `total sales to buyer` label, hint, prefix and input', () => { + it('should render `total sales to buyer` label, hint, prefix and input', () => { const fieldId = TOTAL_SALES_TO_BUYER; const field = fieldSelector(fieldId); @@ -84,20 +84,43 @@ context( field.input().should('exist'); }); - it('renders `maximum buyer will owe` label, hint, prefix, input', () => { + describe('`maximum buyer will owe` field', () => { const fieldId = MAXIMUM_BUYER_WILL_OWE; const field = multipleContractPolicyExportValuePage[fieldId]; const { HINT } = EXPORT_VALUE.MULTIPLE[fieldId]; - cy.checkText(field.label(), EXPORT_VALUE.MULTIPLE[fieldId].LABEL); + it('should render a label', () => { + cy.checkText(field.label(), EXPORT_VALUE.MULTIPLE[fieldId].LABEL); - cy.assertPrefix({ fieldId, value: SYMBOLS.GBP }); + cy.assertPrefix({ fieldId, value: SYMBOLS.GBP }); + }); - cy.checkText(field.hint.forExample(), HINT.FOR_EXAMPLE); + it('should render a prefix', () => { + cy.assertPrefix({ fieldId, value: SYMBOLS.GBP }); + }); - cy.checkText(field.hint.noDecimals(), HINT.NO_DECIMALS); + it('should render a `for example` hint', () => { + cy.checkText(field.hint.forExample(), HINT.FOR_EXAMPLE); + }); - field.input().should('exist'); + it('should render an `initial credit limit` hint intro', () => { + cy.checkText(field.hint.initialCreditLimit.intro(), HINT.INITIAL_CREDIT_LIMIT.INTRO); + }); + + it('should render an `initial credit limit` hint link', () => { + const expectedHref = LINKS.EXTERNAL.SMALL_EXPORT_BUILDER; + const expectedText = HINT.INITIAL_CREDIT_LIMIT.LINK.TEXT; + + cy.checkLink(field.hint.initialCreditLimit.link(), expectedHref, expectedText); + }); + + it('should render a `no decimals` hint', () => { + cy.checkText(field.hint.noDecimals(), HINT.NO_DECIMALS); + }); + + it('should render an input', () => { + field.input().should('exist'); + }); }); }); @@ -107,7 +130,7 @@ context( }); it(`should redirect to ${NAME_ON_POLICY}`, () => { - cy.completeAndSubmitExportValueForm({ policyType }); + cy.completeAndSubmitExportValueForm({}); const expectedUrl = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${NAME_ON_POLICY}`; cy.assertUrl(expectedUrl); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/save-and-back.spec.js index a56cc14c25..6070faca8d 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/save-and-back.spec.js @@ -27,7 +27,7 @@ context('Insurance - Policy - Multiple contract policy Export value page - Save cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'multipleContractPolicy', policyType }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'multipleContractPolicy', policyType }); url = `${baseUrl}${ROOT}/${referenceNumber}${MULTIPLE_CONTRACT_POLICY_EXPORT_VALUE}`; @@ -94,7 +94,7 @@ context('Insurance - Policy - Multiple contract policy Export value page - Save }); it('should NOT have saved the submitted value', () => { - cy.checkValue(field, ''); + cy.assertEmptyFieldValue(TOTAL_SALES_TO_BUYER); }); }); }); @@ -133,7 +133,7 @@ context('Insurance - Policy - Multiple contract policy Export value page - Save beforeEach(() => { cy.navigateToUrl(url); - cy.completeExportValueForm(); + cy.completeExportValueForm({}); cy.clickSaveAndBackButton(); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/validation/multiple-contract-policy-export-value-validation-maximum-buyer-will-owe.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/validation/multiple-contract-policy-export-value-validation-maximum-buyer-will-owe.spec.js index d7b6edf394..e722c1165a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/validation/multiple-contract-policy-export-value-validation-maximum-buyer-will-owe.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/validation/multiple-contract-policy-export-value-validation-maximum-buyer-will-owe.spec.js @@ -36,7 +36,7 @@ context('Insurance - Policy - Multiple contract policy - Export value page - for cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'multipleContractPolicy', policyType }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'multipleContractPolicy', policyType }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MULTIPLE_CONTRACT_POLICY_EXPORT_VALUE}`; @@ -101,7 +101,7 @@ context('Insurance - Policy - Multiple contract policy - Export value page - for }); it('should redirect to the next page when maximum buyer will owe is valid and contains a comma as all fields are valid', () => { - cy.completeExportValueForm(); + cy.completeExportValueForm({}); cy.clickBackLink(); cy.keyboardInput(multipleContractPolicyExportValuePage[MAXIMUM_BUYER_WILL_OWE].input(), '1,234'); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/validation/multiple-contract-policy-export-value-validation-total-sales-to-buyer.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/validation/multiple-contract-policy-export-value-validation-total-sales-to-buyer.spec.js index 0c5c8c4da7..5c3f3a2701 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/validation/multiple-contract-policy-export-value-validation-total-sales-to-buyer.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/export-value/validation/multiple-contract-policy-export-value-validation-total-sales-to-buyer.spec.js @@ -36,7 +36,7 @@ context('Insurance - Policy - Multiple contract policy - Export value page - for cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'multipleContractPolicy', policyType }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'multipleContractPolicy', policyType }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MULTIPLE_CONTRACT_POLICY_EXPORT_VALUE}`; @@ -104,7 +104,7 @@ context('Insurance - Policy - Multiple contract policy - Export value page - for it('should redirect to the next page as all fields are valid', () => { cy.navigateToUrl(url); - cy.completeExportValueForm(); + cy.completeExportValueForm({}); cy.clickBackLink(); cy.keyboardInput(fieldSelector(TOTAL_SALES_TO_BUYER).input(), '1,234'); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/multiple-contract-policy.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/multiple-contract-policy.spec.js index b883666bf7..4b314d3b65 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/multiple-contract-policy.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/multiple-contract-policy.spec.js @@ -46,7 +46,7 @@ context('Insurance - Policy - Multiple contract policy page - As an exporter, I cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'policyType', policyType: MULTIPLE }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'policyType', policyType: MULTIPLE }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MULTIPLE_CONTRACT_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/save-and-back.spec.js index a92ee39e61..9ac9eecf3b 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/save-and-back.spec.js @@ -18,7 +18,7 @@ context('Insurance - Policy - Multiple contract policy page - Save and go back', cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'policyType', policyType: MULTIPLE }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'policyType', policyType: MULTIPLE }); url = `${baseUrl}${ROOT}/${referenceNumber}${MULTIPLE_CONTRACT_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/validation/multiple-contract-policy-validation-requested-start-date.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/validation/multiple-contract-policy-validation-requested-start-date.spec.js index 0150d37ee7..9a97d800a5 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/validation/multiple-contract-policy-validation-requested-start-date.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/validation/multiple-contract-policy-validation-requested-start-date.spec.js @@ -42,7 +42,7 @@ context('Insurance - Policy - Multiple contract policy page - form validation - cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'policyType', policyType: MULTIPLE }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'policyType', policyType: MULTIPLE }); url = `${baseUrl}${ROOT}/${referenceNumber}${MULTIPLE_CONTRACT_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/validation/multiple-contract-policy-validation-total-months-of-cover.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/validation/multiple-contract-policy-validation-total-months-of-cover.spec.js index a8e3050656..d571e096d2 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/validation/multiple-contract-policy-validation-total-months-of-cover.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/validation/multiple-contract-policy-validation-total-months-of-cover.spec.js @@ -48,7 +48,7 @@ context('Insurance - Policy - Multiple contract policy page - form validation - cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'policyType', policyType: MULTIPLE }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'policyType', policyType: MULTIPLE }); url = `${baseUrl}${ROOT}/${referenceNumber}${MULTIPLE_CONTRACT_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/validation/multiple-contract-policy-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/validation/multiple-contract-policy-validation.spec.js index 88721ad31b..0df8f51e3d 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/validation/multiple-contract-policy-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/multiple-contract-policy/validation/multiple-contract-policy-validation.spec.js @@ -37,7 +37,7 @@ context('Insurance - Policy - Multiple contract policy page - form validation', cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'policyType', policyType: MULTIPLE }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'policyType', policyType: MULTIPLE }); url = `${baseUrl}${ROOT}/${referenceNumber}${MULTIPLE_CONTRACT_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/name-on-policy/name-on-policy-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/name-on-policy/name-on-policy-page.spec.js index cfe7fc111e..5244d52316 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/name-on-policy/name-on-policy-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/name-on-policy/name-on-policy-page.spec.js @@ -33,7 +33,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'totalContractValue' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'totalContractValue' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${NAME_ON_POLICY}`; @@ -77,11 +77,11 @@ context( cy.checkText(field(SAME_NAME).label(), nameAndEmail); }); - it(`should NOT display conditional "${POSITION}" section without selecting the "same name" radio`, () => { + it(`should NOT display a conditional "${POSITION}" section without selecting the "same name" radio`, () => { field(POSITION).input().should('not.be.visible'); }); - it(`should display conditional "${POSITION}" section when selecting the "yes" radio`, () => { + it(`should render a conditional "${POSITION}" section when selecting the "yes" radio`, () => { field(SAME_NAME).label().click(); field(POSITION).input().should('be.visible'); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/name-on-policy/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/name-on-policy/save-and-back.spec.js index 0d3b3a4d44..e0dd20ca0a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/name-on-policy/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/name-on-policy/save-and-back.spec.js @@ -24,7 +24,7 @@ context('Insurance - Policy - Name on policy - Save and go back', () => { cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'totalContractValue' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'totalContractValue' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${NAME_ON_POLICY}`; @@ -101,7 +101,7 @@ context('Insurance - Policy - Name on policy - Save and go back', () => { cy.assertRadioOptionIsChecked(field(SAME_NAME).input()); - cy.checkValue(field(POSITION), ''); + cy.assertEmptyFieldValue(POSITION); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/name-on-policy/validation/name-on-policy-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/name-on-policy/validation/name-on-policy-validation.spec.js index a80a058659..6127d19660 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/name-on-policy/validation/name-on-policy-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/name-on-policy/validation/name-on-policy-validation.spec.js @@ -35,7 +35,7 @@ context('Insurance - Policy - Name on policy - Validation', () => { referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'totalContractValue' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'totalContractValue' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${NAME_ON_POLICY}`; @@ -56,14 +56,10 @@ context('Insurance - Policy - Name on policy - Validation', () => { cy.navigateToUrl(url); }); - it('should display validation error', () => { - const expectedErrorsCount = 1; - const expectedErrorMessage = NAME_ON_POLICY_ERRORS[NAME].IS_EMPTY; - + it('should render a validation error', () => { cy.submitAndAssertRadioErrors({ field: fieldSelector(SAME_NAME), - expectedErrorsCount, - expectedErrorMessage, + expectedErrorMessage: NAME_ON_POLICY_ERRORS[NAME].IS_EMPTY, }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/changing-another-company-from-yes-to-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/changing-another-company-from-yes-to-no.spec.js index c03404004b..b9f7967119 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/changing-another-company-from-yes-to-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/changing-another-company-from-yes-to-no.spec.js @@ -1,4 +1,3 @@ -import { field as fieldSelector, autoCompleteField } from '../../../../../../pages/shared'; import { POLICY as POLICY_FIELD_IDS } from '../../../../../../constants/field-ids/insurance/policy'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; @@ -23,7 +22,7 @@ context(`Insurance - Policy - Other company details page - Changing ${REQUESTED} referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'anotherCompany', otherCompanyInvolved: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'anotherCompany', otherCompanyInvolved: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${OTHER_COMPANY_DETAILS}`; anotherCompanyUrl = `${baseUrl}${ROOT}/${referenceNumber}${ANOTHER_COMPANY}`; @@ -59,9 +58,9 @@ context(`Insurance - Policy - Other company details page - Changing ${REQUESTED} }); it('should NOT have fields populated on different name on policy page', () => { - cy.checkValue(fieldSelector(COMPANY_NAME), ''); - cy.checkValue(autoCompleteField(COUNTRY_CODE), ''); - cy.checkValue(fieldSelector(COMPANY_NUMBER), ''); + cy.assertEmptyFieldValue(COMPANY_NAME); + cy.assertEmptyAutocompleteFieldValue(COUNTRY_CODE); + cy.assertEmptyFieldValue(COMPANY_NUMBER); }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/other-company-details.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/other-company-details.spec.js index 0f971b3382..f378f6207e 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/other-company-details.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/other-company-details.spec.js @@ -33,7 +33,7 @@ context(`Insurance - Policy - Other company details page - ${story}`, () => { referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'anotherCompany', otherCompanyInvolved: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'anotherCompany', otherCompanyInvolved: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${OTHER_COMPANY_DETAILS}`; brokerUrl = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/save-and-back.spec.js index bca3553c3f..d15e76fd10 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/save-and-back.spec.js @@ -25,7 +25,7 @@ context('Insurance - Policy - Other company details page - Save and back', () => referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'anotherCompany', otherCompanyInvolved: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'anotherCompany', otherCompanyInvolved: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${OTHER_COMPANY_DETAILS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/validation/other-company-details-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/validation/other-company-details-validation.spec.js index b67e42e8b3..3766824081 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/validation/other-company-details-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/other-company-details/validation/other-company-details-validation.spec.js @@ -33,7 +33,7 @@ context('Insurance - Policy - Other company details page - Validation', () => { referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'anotherCompany', otherCompanyInvolved: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'anotherCompany', otherCompanyInvolved: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${OTHER_COMPANY_DETAILS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/pre-credit-period/pre-credit-period.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/pre-credit-period/pre-credit-period.spec.js index 10587c44e3..c28478ec70 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/pre-credit-period/pre-credit-period.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/pre-credit-period/pre-credit-period.spec.js @@ -32,7 +32,7 @@ context(`Insurance - Policy - Pre-credit period page - ${story}`, () => { referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitPolicyForms({ formToStopAt: 'nameOnPolicy' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'nameOnPolicy' }); url = `${baseUrl}${ROOT}/${referenceNumber}${PRE_CREDIT_PERIOD}`; anotherCompanyUrl = `${baseUrl}${ROOT}/${referenceNumber}${ANOTHER_COMPANY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/pre-credit-period/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/pre-credit-period/save-and-back.spec.js index 3b6d18bdbb..2c002fbaa9 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/pre-credit-period/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/pre-credit-period/save-and-back.spec.js @@ -24,7 +24,7 @@ context('Insurance - Policy - Pre-credit period page - Save and go back', () => cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'nameOnPolicy' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'nameOnPolicy' }); url = `${baseUrl}${ROOT}/${referenceNumber}${PRE_CREDIT_PERIOD}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/pre-credit-period/validation/pre-credit-period-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/pre-credit-period/validation/pre-credit-period-validation.spec.js index fde0cb4993..9a098db3a0 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/pre-credit-period/validation/pre-credit-period-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/pre-credit-period/validation/pre-credit-period-validation.spec.js @@ -48,13 +48,9 @@ context('Insurance - Policy - Pre-credit period page - validation', () => { it(`should render a validation error when ${NEED_PRE_CREDIT_PERIOD} is not provided`, () => { const fieldId = NEED_PRE_CREDIT_PERIOD; - const expectedErrorsCount = 1; - const expectedErrorMessage = POLICY_ERROR_MESSAGES[fieldId].IS_EMPTY; - cy.submitAndAssertRadioErrors({ field: noRadio(fieldId), - expectedErrorsCount, - expectedErrorMessage, + expectedErrorMessage: POLICY_ERROR_MESSAGES[fieldId].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/save-and-back.spec.js index 6ded29db6f..24c4dae2e5 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/save-and-back.spec.js @@ -25,7 +25,7 @@ context('Insurance - Policy - Single contract policy page - Save and go back', ( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'policyType' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'policyType' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${SINGLE_CONTRACT_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/single-contract-policy.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/single-contract-policy.spec.js index c8fe6e707e..b546fe9f75 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/single-contract-policy.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/single-contract-policy.spec.js @@ -43,7 +43,7 @@ context('Insurance - Policy - Single contract policy page - As an exporter, I wa cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'policyType' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'policyType' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${SINGLE_CONTRACT_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/save-and-back.spec.js index c41c932d9c..929f87b71a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/save-and-back.spec.js @@ -24,7 +24,7 @@ context('Insurance - Policy - Single contract policy - Total contract value page cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'singleContractPolicy' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'singleContractPolicy' }); url = `${baseUrl}${ROOT}/${referenceNumber}${SINGLE_CONTRACT_POLICY_TOTAL_CONTRACT_VALUE}`; @@ -73,7 +73,7 @@ context('Insurance - Policy - Single contract policy - Total contract value page cy.navigateToUrl(url); cy.checkValue(fieldSelector(TOTAL_CONTRACT_VALUE), application.POLICY[TOTAL_CONTRACT_VALUE]); - cy.checkValue(fieldSelector(REQUESTED_CREDIT_LIMIT), ''); + cy.assertEmptyFieldValue(REQUESTED_CREDIT_LIMIT); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/single-contract-policy-total-contract-value-alternative-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/single-contract-policy-total-contract-value-alternative-currency.spec.js index 8d8a14fdaa..b0f11a987b 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/single-contract-policy-total-contract-value-alternative-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/single-contract-policy-total-contract-value-alternative-currency.spec.js @@ -33,7 +33,7 @@ context('Insurance - Policy - Single contract policy - Total contract value page cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'singleContractPolicy', isoCode: NON_STANDARD_CURRENCY_CODE, alternativeCurrency: true }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'singleContractPolicy', isoCode: NON_STANDARD_CURRENCY_CODE, alternativeCurrency: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${SINGLE_CONTRACT_POLICY_TOTAL_CONTRACT_VALUE}`; singleContractPolicyUrl = `${baseUrl}${ROOT}/${referenceNumber}${SINGLE_CONTRACT_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/single-contract-policy-total-contract-value-non-gbp-currency.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/single-contract-policy-total-contract-value-non-gbp-currency.spec.js index 67f5f80166..4aabf5bf4f 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/single-contract-policy-total-contract-value-non-gbp-currency.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/single-contract-policy-total-contract-value-non-gbp-currency.spec.js @@ -33,7 +33,7 @@ context('Insurance - Policy - Single contract policy - Total contract value page cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'singleContractPolicy', isoCode: USD.isoCode }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'singleContractPolicy', isoCode: USD.isoCode }); url = `${baseUrl}${ROOT}/${referenceNumber}${SINGLE_CONTRACT_POLICY_TOTAL_CONTRACT_VALUE}`; singleContractPolicyUrl = `${baseUrl}${ROOT}/${referenceNumber}${SINGLE_CONTRACT_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/single-contract-policy-total-contract-value.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/single-contract-policy-total-contract-value.spec.js index 48b1f465cd..0818acb7d8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/single-contract-policy-total-contract-value.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/single-contract-policy-total-contract-value.spec.js @@ -32,7 +32,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'singleContractPolicy' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'singleContractPolicy' }); url = `${baseUrl}${ROOT}/${referenceNumber}${SINGLE_CONTRACT_POLICY_TOTAL_CONTRACT_VALUE}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/validation/single-contract-policy-credit-limit-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/validation/single-contract-policy-credit-limit-validation.spec.js index b4e5f701b2..ee27f9f07c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/validation/single-contract-policy-credit-limit-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/validation/single-contract-policy-credit-limit-validation.spec.js @@ -35,7 +35,7 @@ context(`Insurance - Policy - Single contract policy - Total contract value page cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'singleContractPolicy' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'singleContractPolicy' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${SINGLE_CONTRACT_POLICY_TOTAL_CONTRACT_VALUE}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/validation/single-contract-policy-total-contract-value-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/validation/single-contract-policy-total-contract-value-validation.spec.js index 9bc045cc1f..157c560243 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/validation/single-contract-policy-total-contract-value-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/total-contract-value/validation/single-contract-policy-total-contract-value-validation.spec.js @@ -35,7 +35,7 @@ context(`Insurance - Policy - Single contract policy - Total contract value page cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'singleContractPolicy' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'singleContractPolicy' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${SINGLE_CONTRACT_POLICY_TOTAL_CONTRACT_VALUE}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/validation/single-contract-policy-validation-contract-completion-date.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/validation/single-contract-policy-validation-contract-completion-date.spec.js index 15e72703fc..132021c42f 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/validation/single-contract-policy-validation-contract-completion-date.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/validation/single-contract-policy-validation-contract-completion-date.spec.js @@ -45,7 +45,7 @@ context('Insurance - Policy - Single contract policy page - form validation - co cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'policyType' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'policyType' }); url = `${baseUrl}${ROOT}/${referenceNumber}${SINGLE_CONTRACT_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/validation/single-contract-policy-validation-requested-start-date.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/validation/single-contract-policy-validation-requested-start-date.spec.js index ea2851ff90..09f73dd589 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/validation/single-contract-policy-validation-requested-start-date.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/validation/single-contract-policy-validation-requested-start-date.spec.js @@ -39,7 +39,7 @@ context('Insurance - Policy - Single contract policy page - form validation - re cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'policyType' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'policyType' }); url = `${baseUrl}${ROOT}/${referenceNumber}${SINGLE_CONTRACT_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/validation/single-contract-policy-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/validation/single-contract-policy-validation.spec.js index 5363e9240e..863081e8e8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/validation/single-contract-policy-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/single-contract-policy/validation/single-contract-policy-validation.spec.js @@ -36,7 +36,7 @@ context('Insurance - Policy - Single contract policy page - form validation', () cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitPolicyForms({ formToStopAt: 'policyType' }); + cy.completeAndSubmitPolicyForms({ stopSubmittingAfter: 'policyType' }); url = `${baseUrl}${ROOT}/${referenceNumber}${SINGLE_CONTRACT_POLICY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/policy/type-of-policy/type-of-policy.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/policy/type-of-policy/type-of-policy.spec.js index 4ecee9f2e6..129295489c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/policy/type-of-policy/type-of-policy.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/policy/type-of-policy/type-of-policy.spec.js @@ -123,8 +123,6 @@ context('Insurance - Policy - Type of policy page - As an exporter, I want to en }); it('should render a validation error', () => { - const expectedErrorsCount = 1; - const { errorMessage } = field(FIELD_ID); const radioField = { @@ -134,7 +132,6 @@ context('Insurance - Policy - Type of policy page - As an exporter, I want to en cy.submitAndAssertRadioErrors({ field: radioField, - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.POLICY.TYPE_OF_POLICY[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/submit-name-fields-with-special-characters/submit-name-fields-with-special-characters-export-contract.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/submit-name-fields-with-special-characters/submit-name-fields-with-special-characters-export-contract.spec.js index 874a3c9a79..1cf68bb3fd 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/submit-name-fields-with-special-characters/submit-name-fields-with-special-characters-export-contract.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/submit-name-fields-with-special-characters/submit-name-fields-with-special-characters-export-contract.spec.js @@ -26,7 +26,7 @@ context('Insurance - Name fields - Export contract - Name field should render an // go to the page we want to test. cy.completeAndSubmitExportContractForms({ isUsingAgent: true, - formToStopAt: 'agent', + stopSubmittingAfter: 'agent', }); agentDetailsUrl = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${AGENT_DETAILS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/alternative-trading-address/alternative-trading-address.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/alternative-trading-address/alternative-trading-address.spec.js index cd219bd9bc..9ad9ce58ed 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/alternative-trading-address/alternative-trading-address.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/alternative-trading-address/alternative-trading-address.spec.js @@ -1,5 +1,5 @@ -import { headingCaption, html } from '../../../../../../partials'; -import { field as fieldSelector } from '../../../../../../pages/shared'; +import { html } from '../../../../../../partials'; +import { field as fieldSelector, headingCaption } from '../../../../../../pages/shared'; import { PAGES, ERROR_MESSAGES } from '../../../../../../content-strings'; import { EXPORTER_BUSINESS_FIELDS as FIELD_STRINGS } from '../../../../../../content-strings/fields/insurance/business'; import { INSURANCE_FIELD_IDS } from '../../../../../../constants/field-ids/insurance'; @@ -45,7 +45,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'companyDetails', differentTradingAddress: true }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'companyDetails', differentTradingAddress: true }); alternativeAddressUrl = `${baseUrl}${ROOT}/${referenceNumber}${ALTERNATIVE_TRADING_ADDRESS_ROOT}`; @@ -93,7 +93,7 @@ context( cy.checkText(html(COMPANY_ADDRESS), addressText); }); - it(`should display ${FULL_ADDRESS} textarea`, () => { + it(`should render ${FULL_ADDRESS} textarea`, () => { const fieldStrings = FIELD_STRINGS[fieldId]; cy.assertTextareaRendering({ @@ -109,14 +109,14 @@ context( cy.navigateToUrl(alternativeAddressUrl); }); - it(`should display validation errors if ${FULL_ADDRESS} is left empty`, () => { + it(`should render validation errors if ${FULL_ADDRESS} is left empty`, () => { cy.submitAndAssertFieldErrors({ field: textareaField, expectedErrorMessage: ERRORS[FULL_ADDRESS].IS_EMPTY, }); }); - it(`should display validation errors if ${FULL_ADDRESS} is over ${MAXIMUM_CHARACTERS.FULL_ADDRESS} characters`, () => { + it(`should render validation errors if ${FULL_ADDRESS} is over ${MAXIMUM_CHARACTERS.FULL_ADDRESS} characters`, () => { cy.submitAndAssertFieldErrors({ field: textareaField, value: 'a'.repeat(MAXIMUM_CHARACTERS.FULL_ADDRESS + 1), diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/alternative-trading-address/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/alternative-trading-address/save-and-back.spec.js index e4687a1ce4..414ea9dc58 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/alternative-trading-address/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/alternative-trading-address/save-and-back.spec.js @@ -27,7 +27,7 @@ context('Insurance - Your business - Alternative trading address - Save and go b cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'companyDetails', differentTradingAddress: true }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'companyDetails', differentTradingAddress: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${ALTERNATIVE_TRADING_ADDRESS_ROOT}`; @@ -83,7 +83,7 @@ context('Insurance - Your business - Alternative trading address - Save and go b it('should NOT have the originally submitted answer', () => { cy.navigateToUrl(url); - cy.checkText(field(FULL_ADDRESS).textarea(), ''); + cy.assertEmptyTextareaFieldValue(FULL_ADDRESS); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-company-details-trading-address-yes-to-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-company-details-trading-address-yes-to-no.spec.js index 5aed8e440d..d14cb6d5a8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-company-details-trading-address-yes-to-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-company-details-trading-address-yes-to-no.spec.js @@ -1,5 +1,5 @@ import { FIELD_VALUES } from '../../../../../../constants'; -import { field, summaryList } from '../../../../../../pages/shared'; +import { summaryList } from '../../../../../../pages/shared'; import { INSURANCE_FIELD_IDS } from '../../../../../../constants/field-ids/insurance'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; @@ -29,7 +29,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'creditControl', differentTradingAddress: true }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'creditControl', differentTradingAddress: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); @@ -77,7 +77,7 @@ context( cy.completeAndSubmitCompanyDetails({ differentTradingAddress: true }); - cy.checkText(field(FULL_ADDRESS).textarea(), ''); + cy.assertEmptyTextareaFieldValue(FULL_ADDRESS); }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-company-details.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-company-details.spec.js index 30ff7d0239..07f9883f83 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-company-details.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-company-details.spec.js @@ -30,7 +30,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'creditControl' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'creditControl' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-credit-control-no-to-yes.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-credit-control-no-to-yes.spec.js index c9a56c154c..3b99226ab3 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-credit-control-no-to-yes.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-credit-control-no-to-yes.spec.js @@ -24,7 +24,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'creditControl', hasCreditControlProcess: false }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'creditControl', hasCreditControlProcess: false }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-credit-control-yes-to-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-credit-control-yes-to-no.spec.js index 95685cc559..d479b1becc 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-credit-control-yes-to-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-credit-control-yes-to-no.spec.js @@ -24,7 +24,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'creditControl', hasCreditControlProcess: true }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'creditControl', hasCreditControlProcess: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-nature-of-your-business.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-nature-of-your-business.spec.js index ba4b687638..1fdd3a650f 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-nature-of-your-business.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-nature-of-your-business.spec.js @@ -25,7 +25,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'creditControl' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'creditControl' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-trading-address.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-trading-address.spec.js index 953548a14e..c2895a9a47 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-trading-address.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/change-your-answers/change-your-answers-change-trading-address.spec.js @@ -30,7 +30,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'creditControl' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'creditControl' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); 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 00e53bff65..35ea39ab41 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 @@ -28,7 +28,7 @@ context('Insurance - Your business - Change your answers - Turnover - As an expo cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'creditControl' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'creditControl' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/check-your-answers/check-your-answers-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/check-your-answers/check-your-answers-page.spec.js index 8ad68dd9a7..d0e38f2ff8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/check-your-answers/check-your-answers-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/check-your-answers/check-your-answers-page.spec.js @@ -19,7 +19,7 @@ context('Insurance - Your Business - Check your answers - As an exporter, I want cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'creditControl' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'creditControl' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list.spec.js index f66dd20cfe..28a84bc1b5 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list.spec.js @@ -28,7 +28,7 @@ context('Insurance - Your business - Check your answers - Summary list - your bu cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'creditControl', hasCreditControlProcess: true }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'creditControl', hasCreditControlProcess: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); @@ -94,7 +94,7 @@ context('Insurance - Your business - Check your answers - Summary list - your bu cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'creditControl', differentTradingAddress: true }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'creditControl', differentTradingAddress: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); @@ -120,7 +120,7 @@ context('Insurance - Your business - Check your answers - Summary list - your bu cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'creditControl', differentTradingName: true }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'creditControl', differentTradingName: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-page.spec.js index 42f49ac7cc..df6fb7fe6b 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-page.spec.js @@ -1,6 +1,5 @@ import { companyDetails } from '../../../../../../pages/your-business'; -import { headingCaption } from '../../../../../../partials'; -import { body, field, yesRadioInput, noRadioInput } from '../../../../../../pages/shared'; +import { body, field, headingCaption, noRadioInput, yesRadioInput } from '../../../../../../pages/shared'; import { PAGES } from '../../../../../../content-strings'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; import { INSURANCE_FIELD_IDS } from '../../../../../../constants/field-ids/insurance'; @@ -93,7 +92,7 @@ context( }); }); - it('should display the trading name radios', () => { + it('should render the trading name radios', () => { cy.checkText(companyDetails[HAS_DIFFERENT_TRADING_NAME].label(), CONTENT_STRINGS.HAS_DIFFERENT_TRADING_NAME); cy.checkRadioInputYesAriaLabel(CONTENT_STRINGS.HAS_DIFFERENT_TRADING_NAME); @@ -101,11 +100,11 @@ context( cy.checkRadioInputNoAriaLabel(CONTENT_STRINGS.HAS_DIFFERENT_TRADING_NAME); }); - it(`should NOT display conditional ${DIFFERENT_TRADING_NAME} input without selecting the trading name "yes" radio`, () => { + it(`should NOT display a conditional ${DIFFERENT_TRADING_NAME} input without selecting the trading name "yes" radio`, () => { field(DIFFERENT_TRADING_NAME).input().should('not.be.visible'); }); - it(`should display conditional ${DIFFERENT_TRADING_NAME} input when selecting the trading name "yes" radio`, () => { + it(`should render a conditional ${DIFFERENT_TRADING_NAME} input when selecting the trading name "yes" radio`, () => { cy.clickYesRadioInput(); field(DIFFERENT_TRADING_NAME).input().should('be.visible'); @@ -114,7 +113,7 @@ context( cy.checkText(field(DIFFERENT_TRADING_NAME).hint(), CONTENT_STRINGS.DIFFERENT_TRADING_NAME_HINT); }); - it('should display the trading address radios', () => { + it('should render the trading address radios', () => { cy.checkText(companyDetails[HAS_DIFFERENT_TRADING_ADDRESS].label(), CONTENT_STRINGS.HAS_DIFFERENT_TRADING_ADDRESS); cy.checkAriaLabel(yesRadioInput().eq(1), `${CONTENT_STRINGS.HAS_DIFFERENT_TRADING_ADDRESS} Yes`); @@ -122,19 +121,17 @@ context( cy.checkAriaLabel(noRadioInput().eq(1), `${CONTENT_STRINGS.HAS_DIFFERENT_TRADING_ADDRESS} No`); }); - it('should display the company website text input', () => { + it('should render the company website text input', () => { cy.checkText(field(WEBSITE).label(), CONTENT_STRINGS.WEBSITE); - field(WEBSITE).input().should('exist'); cy.checkAriaLabel(field(WEBSITE).input(), CONTENT_STRINGS.WEBSITE); }); - it('should display the phone number text input', () => { + it('should render the phone number text input', () => { cy.checkText(field(PHONE_NUMBER).label(), CONTENT_STRINGS.PHONE_NUMBER); cy.checkText(field(PHONE_NUMBER).hint(), CONTENT_STRINGS.PHONE_NUMBER_HINT); - field(PHONE_NUMBER).input().should('exist'); cy.checkAriaLabel(field(PHONE_NUMBER).input(), CONTENT_STRINGS.PHONE_NUMBER); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-submit-different-trading-name.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-submit-different-trading-name.spec.js index 34c631cc4a..18d96025c5 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-submit-different-trading-name.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-submit-different-trading-name.spec.js @@ -77,7 +77,7 @@ describe(`Insurance - Your business - Company details page - submit ${DIFFERENT_ // check input is not populated cy.clickYesRadioInput(); - cy.checkValue(field(DIFFERENT_TRADING_NAME), ''); + cy.assertEmptyFieldValue(DIFFERENT_TRADING_NAME); }); }); @@ -100,7 +100,8 @@ describe(`Insurance - Your business - Company details page - submit ${DIFFERENT_ // check input is not populated cy.clickYesRadioInput(); - cy.checkValue(field(DIFFERENT_TRADING_NAME), ''); + + cy.assertEmptyFieldValue(DIFFERENT_TRADING_NAME); }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-submit.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-submit.spec.js index f1742a5aab..cb294b1b38 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-submit.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-submit.spec.js @@ -58,7 +58,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa }); describe('all page errors', () => { - it('should display the validation error for trading name in radio error summary', () => { + it('should render the validation error for trading name in radio error summary', () => { const field = companyDetails[HAS_DIFFERENT_TRADING_NAME]; const radioField = { @@ -73,7 +73,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa }); }); - it('should display the validation error for trading address in radio error summary', () => { + it('should render the validation error for trading address in radio error summary', () => { const field = companyDetails[HAS_DIFFERENT_TRADING_ADDRESS]; const radioField = { @@ -89,7 +89,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa }); }); - it('should display the validation error for company website in company website section', () => { + it('should render the validation error for company website in company website section', () => { cy.submitAndAssertFieldErrors({ field: fieldSelector(WEBSITE), value: WEBSITE_EXAMPLES.INVALID, @@ -99,7 +99,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa }); }); - it('should display the validation error for phone number in phone number section', () => { + it('should render the validation error for phone number in phone number section', () => { cy.submitAndAssertFieldErrors({ field: fieldSelector(PHONE_NUMBER), value: INVALID_PHONE_NUMBER, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-company-website-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-company-website-validation.spec.js index 073af05bf0..f1b3b55c98 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-company-website-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-company-website-validation.spec.js @@ -52,7 +52,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa cy.completeCompanyDetailsForm({}); }); - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ field, value: WEBSITE_EXAMPLES.INVALID, @@ -68,7 +68,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa cy.completeCompanyDetailsForm({}); }); - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ field, value: WEBSITE_EXAMPLES.ABOVE_MAX_LENGTH, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-different-trading-name-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-different-trading-name-validation.spec.js index d5a9fbc220..9662b085d6 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-different-trading-name-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-different-trading-name-validation.spec.js @@ -44,7 +44,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa cy.deleteApplication(referenceNumber); }); - it(`should display validation errors if ${FIELD_ID} is left empty`, () => { + it(`should render validation errors if ${FIELD_ID} is left empty`, () => { cy.submitAndAssertFieldErrors({ field: fieldSelector(FIELD_ID), expectedErrorMessage: COMPANY_DETAILS_ERRORS[FIELD_ID].IS_EMPTY, @@ -52,7 +52,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa }); describe(`when ${FIELD_ID} is over ${MAXIMUM_CHARACTERS.COMPANY_DIFFERENT_TRADING_NAME} characters`, () => { - it('should display validation errors and retain the submitted value', () => { + it('should render validation errors and retain the submitted value', () => { const submittedValue = 'a'.repeat(MAXIMUM_CHARACTERS.COMPANY_DIFFERENT_TRADING_NAME + 1); cy.submitAndAssertFieldErrors({ diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-invalid-phone-number-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-invalid-phone-number-validation.spec.js index d4be4bef0f..da11e0e9bb 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-invalid-phone-number-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-invalid-phone-number-validation.spec.js @@ -64,7 +64,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa completeAllFields(); }); - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ ...assertions, value: INVALID_PHONE_NUMBERS.LANDLINE.LONG, @@ -79,7 +79,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa completeAllFields(); }); - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ ...assertions, value: INVALID_PHONE_NUMBERS.INTERNATIONAL, @@ -94,7 +94,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa completeAllFields(); }); - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ ...assertions, value: INVALID_PHONE_NUMBERS.INTERNATIONAL_PLUS, @@ -109,7 +109,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa completeAllFields(); }); - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ ...assertions, value: INVALID_PHONE_NUMBERS.MOBILE.LONG, @@ -124,7 +124,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa completeAllFields(); }); - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ ...assertions, value: INVALID_PHONE_NUMBERS.LANDLINE.SHORT, @@ -139,7 +139,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa completeAllFields(); }); - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ ...assertions, value: INVALID_PHONE_NUMBERS.LANDLINE.SPECIAL_CHAR, @@ -154,7 +154,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa completeAllFields(); }); - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ ...assertions, value: INVALID_PHONE_NUMBERS.LANDLINE.LETTER, @@ -169,7 +169,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa completeAllFields(); }); - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ ...assertions, value: INVALID_PHONE_NUMBERS.MOBILE.SPECIAL_CHAR, @@ -184,7 +184,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa completeAllFields(); }); - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ ...assertions, value: INVALID_PHONE_NUMBERS.TOO_SHORT, @@ -192,14 +192,14 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa }); }); - describe('should display validation errors for a number above the maximum allowed characters', () => { + describe('should render validation errors for a number above the maximum allowed characters', () => { beforeEach(() => { cy.navigateToUrl(url); completeAllFields(); }); - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ ...assertions, value: INVALID_PHONE_NUMBERS.ABOVE_MAX_CHARS, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-trading-address-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-trading-address-validation.spec.js index 68fc704b9a..11ed9daa26 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-trading-address-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-trading-address-validation.spec.js @@ -44,7 +44,7 @@ describe("Insurance - Your business - Company details page - As an Exporter I wa cy.deleteApplication(referenceNumber); }); - it(`should display validation errors if ${HAS_DIFFERENT_TRADING_ADDRESS} is left empty`, () => { + it(`should render validation errors if ${HAS_DIFFERENT_TRADING_ADDRESS} is left empty`, () => { const field = companyDetails[HAS_DIFFERENT_TRADING_ADDRESS]; const radioField = { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-trading-name-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-trading-name-validation.spec.js index d00f433eda..5d957767d9 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-trading-name-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/validation/company-details-trading-name-validation.spec.js @@ -44,7 +44,7 @@ describe("Insurance - Your business - Company details page- As an Exporter I wan cy.deleteApplication(referenceNumber); }); - it('should display validation errors if trading name question is not answered', () => { + it('should render validation errors if trading name question is not answered', () => { const field = companyDetails[HAS_DIFFERENT_TRADING_NAME]; const radioField = { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/credit-control/credit-control-answer-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/credit-control/credit-control-answer-no.spec.js index 54035345e6..c39bd44a49 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/credit-control/credit-control-answer-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/credit-control/credit-control-answer-no.spec.js @@ -18,7 +18,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'turnover' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'turnover' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CREDIT_CONTROL}`; brokerUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/credit-control/credit-control.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/credit-control/credit-control.spec.js index b94e04af9f..db3503ee28 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/credit-control/credit-control.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/credit-control/credit-control.spec.js @@ -1,5 +1,4 @@ -import { headingCaption } from '../../../../../../partials'; -import { yesNoRadioHint, yesRadio, noRadio } from '../../../../../../pages/shared'; +import { headingCaption, noRadio, yesNoRadioHint, yesRadio } from '../../../../../../pages/shared'; import { ERROR_MESSAGES, PAGES } from '../../../../../../content-strings'; import { EXPORTER_BUSINESS_FIELDS as FIELDS } from '../../../../../../content-strings/fields/insurance/business'; import { FIELD_VALUES } from '../../../../../../constants'; @@ -28,7 +27,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'turnover' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'turnover' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CREDIT_CONTROL}`; checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; @@ -87,11 +86,8 @@ context( }); it('should render validation errors', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: yesRadio(FIELD_ID), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGES.INSURANCE.EXPORTER_BUSINESS[FIELD_ID].IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/credit-control/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/credit-control/save-and-back.spec.js index 85a92ddf8b..0d88495a59 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/credit-control/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/credit-control/save-and-back.spec.js @@ -15,7 +15,7 @@ context('Insurance - Your business - Credit control - Save and go back', () => { cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'turnover' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'turnover' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CREDIT_CONTROL}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/nature-of-business-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/nature-of-business-page.spec.js index afaf9881d6..f15ce7c507 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/nature-of-business-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/nature-of-business-page.spec.js @@ -1,5 +1,4 @@ -import { headingCaption } from '../../../../../../partials'; -import { field as fieldSelector } from '../../../../../../pages/shared'; +import { field as fieldSelector, headingCaption } from '../../../../../../pages/shared'; import { PAGES } from '../../../../../../content-strings'; import { EXPORTER_BUSINESS_FIELDS as FIELDS } from '../../../../../../content-strings/fields/insurance/business'; import { INSURANCE_FIELD_IDS } from '../../../../../../constants/field-ids/insurance'; @@ -32,7 +31,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'companyDetails' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'companyDetails' }); natureOfBusinessUrl = `${baseUrl}${ROOT}/${referenceNumber}${NATURE_OF_BUSINESS_ROOT}`; @@ -67,7 +66,7 @@ context( cy.checkText(headingCaption(), CONTENT_STRINGS.HEADING_CAPTION); }); - it(`should display ${GOODS_OR_SERVICES} label, input and hint`, () => { + it(`should render ${GOODS_OR_SERVICES} label, input and hint`, () => { const fieldId = GOODS_OR_SERVICES; const field = fieldSelector(fieldId); @@ -77,7 +76,7 @@ context( field.hint().contains(FIELDS.NATURE_OF_YOUR_BUSINESS[fieldId].HINT); }); - it(`should display ${YEARS_EXPORTING} label, input and hint`, () => { + it(`should render ${YEARS_EXPORTING} label, input and hint`, () => { const fieldId = YEARS_EXPORTING; const field = fieldSelector(fieldId); @@ -88,7 +87,7 @@ context( cy.assertSuffix({ fieldId, value: FIELDS.NATURE_OF_YOUR_BUSINESS[fieldId].SUFFIX }); }); - it(`should display ${EMPLOYEES_UK} label and input`, () => { + it(`should render ${EMPLOYEES_UK} label and input`, () => { const fieldId = EMPLOYEES_UK; const field = fieldSelector(fieldId); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/save-and-back.spec.js index b64cdfcc5a..d10c216b72 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/save-and-back.spec.js @@ -21,7 +21,7 @@ context('Insurance - Your business - Nature of your business page - Save and bac cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'companyDetails' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'companyDetails' }); url = `${baseUrl}${ROOT}/${referenceNumber}${NATURE_OF_BUSINESS_ROOT}`; @@ -81,8 +81,8 @@ context('Insurance - Your business - Nature of your business page - Save and bac expectedValue: application.EXPORTER_BUSINESS[GOODS_OR_SERVICES], }); - cy.checkValue(field(YEARS_EXPORTING), ''); - cy.checkValue(field(EMPLOYEES_UK), ''); + cy.assertEmptyFieldValue(YEARS_EXPORTING); + cy.assertEmptyFieldValue(EMPLOYEES_UK); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/validation/nature-of-business-employees-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/validation/nature-of-business-employees-validation.spec.js index 3c85e6c397..06172d7055 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/validation/nature-of-business-employees-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/validation/nature-of-business-employees-validation.spec.js @@ -34,7 +34,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'companyDetails' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'companyDetails' }); url = `${baseUrl}${ROOT}/${referenceNumber}${NATURE_OF_BUSINESS_ROOT}`; @@ -60,7 +60,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor }); describe(`when ${FIELD_ID} is left empty`, () => { - it(`should display validation errors for ${FIELD_ID}`, () => { + it(`should render validation errors for ${FIELD_ID}`, () => { cy.submitAndAssertFieldErrors({ ...assertions, expectedErrorMessage: NATURE_OF_BUSINESS_ERRORS[FIELD_ID].IS_EMPTY, @@ -69,7 +69,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor }); describe(`when ${FIELD_ID} is a decimal place number`, () => { - it(`should display validation errors for ${FIELD_ID}`, () => { + it(`should render validation errors for ${FIELD_ID}`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '5.5', @@ -79,7 +79,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor }); describe(`when ${FIELD_ID} has special characters`, () => { - it(`should display validation errors for ${FIELD_ID}`, () => { + it(`should render validation errors for ${FIELD_ID}`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '35!', @@ -89,7 +89,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor }); describe(`when ${FIELD_ID} has letters`, () => { - it(`should display validation errors for ${FIELD_ID}`, () => { + it(`should render validation errors for ${FIELD_ID}`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: 'one', @@ -99,7 +99,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor }); describe(`when ${FIELD_ID} is below 0`, () => { - it(`should display validation errors for ${FIELD_ID}`, () => { + it(`should render validation errors for ${FIELD_ID}`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '-5', @@ -109,7 +109,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor }); describe(`when ${FIELD_ID} is entered as 0`, () => { - it(`should display validation errors for ${FIELD_ID}`, () => { + it(`should render validation errors for ${FIELD_ID}`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '0', diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/validation/nature-of-business-goods-or-services-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/validation/nature-of-business-goods-or-services-validation.spec.js index 8b8be7fbf1..4c3d99eb48 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/validation/nature-of-business-goods-or-services-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/validation/nature-of-business-goods-or-services-validation.spec.js @@ -34,7 +34,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'companyDetails' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'companyDetails' }); url = `${baseUrl}${ROOT}/${referenceNumber}${NATURE_OF_BUSINESS_ROOT}`; @@ -53,7 +53,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor }); describe(`when ${FIELD_ID} is left empty`, () => { - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ ...assertions, expectedErrorMessage: NATURE_OF_BUSINESS_ERRORS[FIELD_ID].IS_EMPTY, @@ -69,7 +69,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor }); describe(`when ${FIELD_ID} has over the maximum`, () => { - it('should display validation errors', () => { + it('should render validation errors', () => { cy.submitAndAssertFieldErrors({ ...assertions, value: 'a'.repeat(MAXIMUM_CHARACTERS.BUSINESS.GOODS_OR_SERVICES_DESCRIPTION + 1), diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/validation/nature-of-business-years-exporting-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/validation/nature-of-business-years-exporting-validation.spec.js index 5abbdad53d..47926a7353 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/validation/nature-of-business-years-exporting-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/nature-of-business/validation/nature-of-business-years-exporting-validation.spec.js @@ -27,7 +27,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'companyDetails' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'companyDetails' }); url = `${baseUrl}${ROUTES.INSURANCE.ROOT}/${referenceNumber}${ROUTES.INSURANCE.EXPORTER_BUSINESS.NATURE_OF_BUSINESS_ROOT}`; @@ -49,7 +49,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor cy.navigateToUrl(url); }); - it(`should display validation errors if ${FIELD_ID} is left empty`, () => { + it(`should render validation errors if ${FIELD_ID} is left empty`, () => { cy.submitAndAssertFieldErrors({ ...assertions, expectedErrorMessage: NATURE_OF_BUSINESS_ERRORS[FIELD_ID].IS_EMPTY, @@ -69,7 +69,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor cy.navigateToUrl(url); }); - it(`should display validation errors for ${FIELD_ID}`, () => { + it(`should render validation errors for ${FIELD_ID}`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '5.5', @@ -83,7 +83,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor cy.navigateToUrl(url); }); - it(`should display validation errors for ${FIELD_ID}`, () => { + it(`should render validation errors for ${FIELD_ID}`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '5!', @@ -97,7 +97,7 @@ describe('Insurance - Your business - Nature of your business page - As an Expor cy.navigateToUrl(url); }); - it(`should display validation errors for ${FIELD_ID}`, () => { + it(`should render validation errors for ${FIELD_ID}`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: 'one', 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 b70ac6da6b..112ee70f93 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 @@ -24,7 +24,7 @@ context('Insurance - Your business - Turnover currency page - As an Exporter I w cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'natureOfYourBusiness' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'natureOfYourBusiness' }); url = `${baseUrl}${ROOT}/${referenceNumber}${TURNOVER_CURRENCY_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover-currency/turnover-currency-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover-currency/turnover-currency-page.spec.js index 999fde3d23..c4b0dae189 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover-currency/turnover-currency-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover-currency/turnover-currency-page.spec.js @@ -26,7 +26,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'natureOfYourBusiness' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'natureOfYourBusiness' }); url = `${baseUrl}${ROOT}/${referenceNumber}${TURNOVER_CURRENCY_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/save-and-back.spec.js index aab7f0ec81..1b0ecbb25f 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/save-and-back.spec.js @@ -21,7 +21,7 @@ context('Insurance - Your business - Turnover page - Save and back', () => { cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'turnoverCurrency' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'turnoverCurrency' }); url = `${baseUrl}${ROOT}/${referenceNumber}${TURNOVER_ROOT}`; @@ -77,7 +77,7 @@ context('Insurance - Your business - Turnover page - Save and back', () => { cy.clickSubmitButtonMultipleTimes({ count: 3 }); cy.checkValue(field(ESTIMATED_ANNUAL_TURNOVER), application.EXPORTER_BUSINESS[ESTIMATED_ANNUAL_TURNOVER]); - cy.checkValue(field(PERCENTAGE_TURNOVER), ''); + cy.assertEmptyFieldValue(PERCENTAGE_TURNOVER); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/turnover-financial-year-end.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/turnover-financial-year-end.spec.js index fc9bfd92cc..2f5e464db4 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/turnover-financial-year-end.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/turnover-financial-year-end.spec.js @@ -43,7 +43,7 @@ context(`Insurance - Your business - Turnover page - when ${fieldId} exists`, () cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'turnoverCurrency' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'turnoverCurrency' }); url = `${baseUrl}${ROOT}/${referenceNumber}${TURNOVER_ROOT}`; @@ -55,7 +55,7 @@ context(`Insurance - Your business - Turnover page - when ${fieldId} exists`, () cy.deleteApplication(referenceNumber); }); - it(`should display ${FINANCIAL_YEAR_END_DATE} section`, () => { + it(`should render a ${FINANCIAL_YEAR_END_DATE} section`, () => { cy.checkText(field.label(), FIELDS.TURNOVER[fieldId].LABEL); cy.checkText(turnoverPage[fieldId](), expectedValue); @@ -76,7 +76,7 @@ context(`Insurance - Your business - Turnover page - when ${fieldId} does not ex }).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'turnoverCurrency' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'turnoverCurrency' }); const url = `${baseUrl}${ROOT}/${referenceNumber}${TURNOVER_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/turnover-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/turnover-page.spec.js index f18b723fa5..b2b5cde7af 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/turnover-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/turnover-page.spec.js @@ -1,5 +1,4 @@ -import { headingCaption } from '../../../../../../partials'; -import { field as fieldSelector } from '../../../../../../pages/shared'; +import { field as fieldSelector, headingCaption } from '../../../../../../pages/shared'; import { turnoverPage } from '../../../../../../pages/your-business'; import { PAGES } from '../../../../../../content-strings'; import { EXPORTER_BUSINESS_FIELDS as FIELDS } from '../../../../../../content-strings/fields/insurance/business'; @@ -40,7 +39,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'turnoverCurrency' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'turnoverCurrency' }); url = `${baseUrl}${ROOT}/${referenceNumber}${TURNOVER_ROOT}`; creditControlUrl = `${baseUrl}${ROOT}/${referenceNumber}${CREDIT_CONTROL}`; @@ -74,7 +73,7 @@ context( cy.checkText(headingCaption(), CONTENT_STRINGS.HEADING_CAPTION); }); - it(`should display ${FINANCIAL_YEAR_END_DATE} section`, () => { + it(`should render a ${FINANCIAL_YEAR_END_DATE} section`, () => { const fieldId = FINANCIAL_YEAR_END_DATE; const field = fieldSelector(fieldId); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/validation/turnover-estimated-annual-turnover-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/validation/turnover-estimated-annual-turnover-validation.spec.js index e9dd271708..381bf49259 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/validation/turnover-estimated-annual-turnover-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/validation/turnover-estimated-annual-turnover-validation.spec.js @@ -25,7 +25,7 @@ describe(`Insurance - Your business - Turnover page - form validation - ${FIELD_ cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'turnoverCurrency' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'turnoverCurrency' }); url = `${baseUrl}${ROUTES.INSURANCE.ROOT}/${referenceNumber}${ROUTES.INSURANCE.EXPORTER_BUSINESS.TURNOVER_ROOT}`; @@ -43,11 +43,11 @@ describe(`Insurance - Your business - Turnover page - form validation - ${FIELD_ cy.deleteApplication(referenceNumber); }); - it(`should display validation errors when ${FIELD_ID} is left empty`, () => { + it(`should render validation errors when ${FIELD_ID} is left empty`, () => { cy.submitAndAssertFieldErrors({ ...assertions, expectedErrorMessage: ERROR_MESSAGE.IS_EMPTY }); }); - it(`should display validation errors when ${FIELD_ID} is a decimal place number`, () => { + it(`should render validation errors when ${FIELD_ID} is a decimal place number`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '5.5', @@ -55,7 +55,7 @@ describe(`Insurance - Your business - Turnover page - form validation - ${FIELD_ }); }); - it(`should display validation errors when ${FIELD_ID} has special characters`, () => { + it(`should render validation errors when ${FIELD_ID} has special characters`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '50!', @@ -63,7 +63,7 @@ describe(`Insurance - Your business - Turnover page - form validation - ${FIELD_ }); }); - it(`should display validation errors when ${FIELD_ID} has letters`, () => { + it(`should render validation errors when ${FIELD_ID} has letters`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: 'one', @@ -71,7 +71,7 @@ describe(`Insurance - Your business - Turnover page - form validation - ${FIELD_ }); }); - it(`should display validation errors when ${FIELD_ID} is negative but has a decimal place`, () => { + it(`should render validation errors when ${FIELD_ID} is negative but has a decimal place`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '-123.456', diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/validation/turnover-percentage-turnover-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/validation/turnover-percentage-turnover-validation.spec.js index 50e43e6ef1..b50229151f 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/validation/turnover-percentage-turnover-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/turnover/validation/turnover-percentage-turnover-validation.spec.js @@ -19,7 +19,7 @@ describe(`Insurance - Your business - Turnover page - form validation - ${FIELD_ cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBusinessForms({ formToStopAt: 'turnoverCurrency' }); + cy.completeAndSubmitYourBusinessForms({ stopSubmittingAfter: 'turnoverCurrency' }); url = `${baseUrl}${ROUTES.INSURANCE.ROOT}/${referenceNumber}${ROUTES.INSURANCE.EXPORTER_BUSINESS.TURNOVER_ROOT}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/buyer-financial-information/buyer-financial-information-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/buyer-financial-information/buyer-financial-information-page.spec.js index 42043c12de..9333414598 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/buyer-financial-information/buyer-financial-information-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/buyer-financial-information/buyer-financial-information-page.spec.js @@ -35,7 +35,7 @@ context( url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${BUYER_FINANCIAL_INFORMATION}`; checkYourAnswersUrl = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'tradedWithBuyer' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'tradedWithBuyer' }); cy.assertUrl(url); }); @@ -82,7 +82,7 @@ context( cy.checkRadioInputNoAriaLabel(CONTENT_STRINGS.PAGE_TITLE); }); - it('should display summary text with collapsed conditional `details` content', () => { + it('should render summary text with collapsed conditional `details` content', () => { cy.checkText(buyerFinancialInformationPage.summary(), CONTENT_STRINGS.SUMMARY); buyerFinancialInformationPage.details().should('not.have.attr', 'open'); @@ -106,11 +106,8 @@ context( }); it('should render validation errors', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: noRadio(FIELD_ID), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGE.IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/buyer-financial-information/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/buyer-financial-information/save-and-back.spec.js index e5ec2a2fec..59b8389f7a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/buyer-financial-information/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/buyer-financial-information/save-and-back.spec.js @@ -15,7 +15,7 @@ context('Insurance - Your buyer - Buyer financial information - Save and back', cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'tradedWithBuyer' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'tradedWithBuyer' }); url = `${baseUrl}${ROOT}/${referenceNumber}${BUYER_FINANCIAL_INFORMATION}`; 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 61ff033e6f..80aaa982ef 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 @@ -27,7 +27,7 @@ context('Insurance - Your buyer - Change your answers - Alternative currency - A cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation', exporterHasTradedWithBuyer: true, outstandingPayments: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation', exporterHasTradedWithBuyer: true, outstandingPayments: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-buyer-financial-accounts.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-buyer-financial-accounts.spec.js index 06386a2b92..bba35bd7b1 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-buyer-financial-accounts.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-buyer-financial-accounts.spec.js @@ -22,7 +22,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-company-or-organisation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-company-or-organisation.spec.js index b507fb8326..29a4b3b7fe 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-company-or-organisation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-company-or-organisation.spec.js @@ -25,7 +25,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-connection-with-buyer-no-to-yes.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-connection-with-buyer-no-to-yes.spec.js index bb20c0c773..aee78cb428 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-connection-with-buyer-no-to-yes.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-connection-with-buyer-no-to-yes.spec.js @@ -22,7 +22,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation', hasConnectionToBuyer: false }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation', hasConnectionToBuyer: false }); checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-connection-with-buyer-yes-to-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-connection-with-buyer-yes-to-no.spec.js index 381f135f87..9b8657b570 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-connection-with-buyer-yes-to-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-connection-with-buyer-yes-to-no.spec.js @@ -22,7 +22,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation', hasConnectionToBuyer: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation', hasConnectionToBuyer: true }); checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-credit-insurance-history.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-credit-insurance-history.spec.js index 3319dff426..0369e9e51e 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-credit-insurance-history.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-credit-insurance-history.spec.js @@ -25,7 +25,7 @@ context( cy.completeSignInAndGoToApplication({ totalContractValueOverThreshold: true }).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); 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-no.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-no.spec.js index c44bc09ffb..0d914ff16e 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-traded-with-buyer-no-to-yes-outstanding-no.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-no.spec.js @@ -25,7 +25,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation', exporterHasTradedWithBuyer: false }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation', exporterHasTradedWithBuyer: false }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); 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 043774df37..8d80fbecf1 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 @@ -35,7 +35,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation', exporterHasTradedWithBuyer: false }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation', exporterHasTradedWithBuyer: false }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-traded-with-buyer-yes-to-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-traded-with-buyer-yes-to-no.spec.js index 25f0432497..96961e703e 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-traded-with-buyer-yes-to-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-traded-with-buyer-yes-to-no.spec.js @@ -27,7 +27,7 @@ context( referenceNumber = refNumber; cy.completeAndSubmitYourBuyerForms({ - formToStopAt: 'buyerFinancialInformation', + stopSubmittingAfter: 'buyerFinancialInformation', exporterHasTradedWithBuyer: true, outstandingPayments: true, failedToPay: true, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-trading-history-failed-payments.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-trading-history-failed-payments.spec.js index 5d938f420d..28f65a9f9d 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-trading-history-failed-payments.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-trading-history-failed-payments.spec.js @@ -24,7 +24,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation', exporterHasTradedWithBuyer: true, failedToPay: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation', exporterHasTradedWithBuyer: true, failedToPay: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); 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 73a66f8d21..455689ddeb 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 @@ -31,7 +31,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation', exporterHasTradedWithBuyer: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation', exporterHasTradedWithBuyer: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-trading-history-outstanding-payments-yes-to-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-trading-history-outstanding-payments-yes-to-no.spec.js index 1721712432..064172bc6a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-trading-history-outstanding-payments-yes-to-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-trading-history-outstanding-payments-yes-to-no.spec.js @@ -25,7 +25,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation', exporterHasTradedWithBuyer: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation', exporterHasTradedWithBuyer: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; tradingHistoryUrl = `${baseUrl}${ROOT}/${referenceNumber}${TRADING_HISTORY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-working-with-buyer-no-to-yes.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-working-with-buyer-no-to-yes.spec.js index cbafcb85be..3987f2e0b4 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-working-with-buyer-no-to-yes.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-working-with-buyer-no-to-yes.spec.js @@ -36,7 +36,7 @@ context( cy.completeSignInAndGoToApplication({ totalContractValueOverThreshold: true }).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation', hasConnectionToBuyer: false }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation', hasConnectionToBuyer: false }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-working-with-buyer-yes-to-no.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-working-with-buyer-yes-to-no.spec.js index 608decb96c..0f217e415c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-working-with-buyer-yes-to-no.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/change-your-answers/change-your-answers-change-working-with-buyer-yes-to-no.spec.js @@ -34,7 +34,7 @@ context( cy.completeSignInAndGoToApplication({ totalContractValueOverThreshold: true }).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation', hasConnectionToBuyer: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation', hasConnectionToBuyer: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; connectionWithBuyerUrl = `${baseUrl}${ROOT}/${referenceNumber}${CONNECTION_WITH_BUYER}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/check-your-answers/check-your-answers-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/check-your-answers/check-your-answers-page.spec.js index c9aa527f36..6a71162c8d 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/check-your-answers/check-your-answers-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/check-your-answers/check-your-answers-page.spec.js @@ -19,7 +19,7 @@ context('Insurance - Your buyer - Check your answers - As an exporter, I want to cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list-minimal.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list-minimal.spec.js index 7f8e98c820..d1e3ebfd0a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list-minimal.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/check-your-answers/check-your-answers-summary-list/check-your-answers-summary-list-minimal.spec.js @@ -39,7 +39,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'buyerFinancialInformation' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'buyerFinancialInformation' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/company-or-organisation/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/company-or-organisation/save-and-back.spec.js index a1ffa4f7ee..c9c0a8b167 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/company-or-organisation/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/company-or-organisation/save-and-back.spec.js @@ -83,8 +83,8 @@ context('Insurance - Your buyer - Company or organisation - Save and back', () = expectedValue: '', }); - cy.checkValue(field(REGISTRATION_NUMBER), ''); - cy.checkValue(field(WEBSITE), ''); + cy.assertEmptyFieldValue(REGISTRATION_NUMBER); + cy.assertEmptyFieldValue(WEBSITE); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/company-or-organisation/validation/company-or-organisation-validation-name.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/company-or-organisation/validation/company-or-organisation-validation-name.spec.js index 7eab317bd0..191752d0d1 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/company-or-organisation/validation/company-or-organisation-validation-name.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/company-or-organisation/validation/company-or-organisation-validation-name.spec.js @@ -48,7 +48,7 @@ context('Insurance - Your buyer - Company or organisation page - form validation }); describe(`when ${FIELD_ID} is over ${MAXIMUM_CHARACTERS.BUYER.COMPANY_OR_ORGANISATION} characters`, () => { - it('should display validation errors and retain the submitted value', () => { + it('should render validation errors and retain the submitted value', () => { const submittedValue = 'a'.repeat(MAXIMUM_CHARACTERS.BUYER.COMPANY_OR_ORGANISATION + 1); cy.submitAndAssertFieldErrors({ diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/company-or-organisation/validation/company-or-organisation-validation-website.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/company-or-organisation/validation/company-or-organisation-validation-website.spec.js index 537dfdee65..d7a0938f6a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/company-or-organisation/validation/company-or-organisation-validation-website.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/company-or-organisation/validation/company-or-organisation-validation-website.spec.js @@ -50,7 +50,7 @@ context('Insurance - Your buyer - Company or organisation page - form validation expectedErrorsCount: 3, }; - it(`should display validation errors if when ${FIELD_ID} is the incorrect format`, () => { + it(`should render validation errors if when ${FIELD_ID} is the incorrect format`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: WEBSITE_EXAMPLES.INVALID, @@ -58,7 +58,7 @@ context('Insurance - Your buyer - Company or organisation page - form validation }); }); - it(`should display validation errors when ${FIELD_ID} is above 191 characters`, () => { + it(`should render validation errors when ${FIELD_ID} is above 191 characters`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: WEBSITE_EXAMPLES.ABOVE_MAX_LENGTH, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/connection-with-the-buyer-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/connection-with-the-buyer-page.spec.js index 23a8490d01..206d426e93 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/connection-with-the-buyer-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/connection-with-the-buyer-page.spec.js @@ -27,7 +27,7 @@ context( cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'companyOrOrganisation' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'companyOrOrganisation' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${CONNECTION_WITH_BUYER_ROUTE}`; tradedWithBuyerUrl = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${TRADED_WITH_BUYER}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/save-and-back/no-connection-with-the-buyer-save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/save-and-back/no-connection-with-the-buyer-save-and-back.spec.js index ab93daf901..dfc80c7a5c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/save-and-back/no-connection-with-the-buyer-save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/save-and-back/no-connection-with-the-buyer-save-and-back.spec.js @@ -15,7 +15,7 @@ context('Insurance - Your buyer - Connection with the buyer - No connection to b cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'companyOrOrganisation' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'companyOrOrganisation' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CONNECTION_WITH_BUYER_ROUTE}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/save-and-back/yes-connection-with-the-buyer-save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/save-and-back/yes-connection-with-the-buyer-save-and-back.spec.js index 9f38884735..620a93277c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/save-and-back/yes-connection-with-the-buyer-save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/save-and-back/yes-connection-with-the-buyer-save-and-back.spec.js @@ -22,7 +22,7 @@ context('Insurance - Your buyer - Connection with the buyer - Has connection to cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'companyOrOrganisation' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'companyOrOrganisation' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CONNECTION_WITH_BUYER_ROUTE}`; @@ -79,7 +79,8 @@ context('Insurance - Your buyer - Connection with the buyer - Has connection to cy.clickSubmitButton(); cy.assertYesRadioOptionIsChecked(); - cy.checkText(field(CONNECTION_WITH_BUYER_DESCRIPTION).textarea(), ''); + + cy.assertEmptyTextareaFieldValue(CONNECTION_WITH_BUYER_DESCRIPTION); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/validation/connection-with-the-buyer-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/validation/connection-with-the-buyer-validation.spec.js index f62b996557..4aad9cfd36 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/validation/connection-with-the-buyer-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/connection-with-the-buyer/validation/connection-with-the-buyer-validation.spec.js @@ -25,7 +25,7 @@ context('Insurance - Your buyer - Connection to the buyer page - form validation cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'companyOrOrganisation' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'companyOrOrganisation' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${CONNECTION_WITH_BUYER_ROUTE}`; @@ -44,7 +44,7 @@ context('Insurance - Your buyer - Connection to the buyer page - form validation }); describe(`when ${CONNECTION_WITH_BUYER} 'no' is selected`, () => { - it('should display validation errors', () => { + it('should render validation errors', () => { cy.navigateToUrl(url); const radioField = { diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/credit-insurance-cover.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/credit-insurance-cover.spec.js index 00865cbf75..93f43310be 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/credit-insurance-cover.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/credit-insurance-cover.spec.js @@ -33,7 +33,7 @@ context( url = `${baseUrl}${ROOT}/${referenceNumber}${CREDIT_INSURANCE_COVER}`; buyerFinancialInformationUrl = `${baseUrl}${ROOT}/${referenceNumber}${BUYER_FINANCIAL_INFORMATION}`; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'tradedWithBuyer' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'tradedWithBuyer' }); cy.assertUrl(url); }); @@ -169,9 +169,7 @@ context( cy.clickYesRadioInput(); - const field = fieldSelector(PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER).textarea(); - - cy.checkText(field, ''); + cy.assertEmptyTextareaFieldValue(PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER); }); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/save-and-back/credit-insurance-cover-answer-no-save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/save-and-back/credit-insurance-cover-answer-no-save-and-back.spec.js index 64e38ecaca..f6044085c2 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/save-and-back/credit-insurance-cover-answer-no-save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/save-and-back/credit-insurance-cover-answer-no-save-and-back.spec.js @@ -15,7 +15,7 @@ context('Insurance - Your buyer - Credit insurance cover - Save and back - No', cy.completeSignInAndGoToApplication({ totalContractValueOverThreshold: true }).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'tradedWithBuyer' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'tradedWithBuyer' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CREDIT_INSURANCE_COVER}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/save-and-back/credit-insurance-cover-answer-yes-save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/save-and-back/credit-insurance-cover-answer-yes-save-and-back.spec.js index eadb802a45..a6b4400a61 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/save-and-back/credit-insurance-cover-answer-yes-save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/save-and-back/credit-insurance-cover-answer-yes-save-and-back.spec.js @@ -22,7 +22,7 @@ context('Insurance - Your buyer - Credit insurance cover - Save and back - Yes', cy.completeSignInAndGoToApplication({ totalContractValueOverThreshold: true }).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'tradedWithBuyer' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'tradedWithBuyer' }); url = `${baseUrl}${ROOT}/${referenceNumber}${CREDIT_INSURANCE_COVER}`; @@ -78,8 +78,7 @@ context('Insurance - Your buyer - Credit insurance cover - Save and back - Yes', cy.assertYesRadioOptionIsChecked(); - const textArea = field(PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER).textarea(); - cy.checkText(textArea, ''); + cy.assertEmptyTextareaFieldValue(PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/validation/credit-insurance-cover-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/validation/credit-insurance-cover-validation.spec.js index ccd68f11a7..ebd49d4dfa 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/validation/credit-insurance-cover-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/credit-insurance-cover/validation/credit-insurance-cover-validation.spec.js @@ -27,7 +27,7 @@ context('Insurance - Your buyer - Credit insurance cover - form validation', () url = `${baseUrl}${ROOT}/${referenceNumber}${CREDIT_INSURANCE_COVER}`; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'tradedWithBuyer' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'tradedWithBuyer' }); cy.assertUrl(url); }); @@ -46,7 +46,7 @@ context('Insurance - Your buyer - Credit insurance cover - form validation', () describe(`when ${HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER} 'no' is selected`, () => { const FIELD_ID = HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER; - it('should display validation errors', () => { + it('should render validation errors', () => { cy.navigateToUrl(url); const radioField = { 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 a12ef65163..c88deedc9a 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 @@ -21,7 +21,7 @@ context('Insurance - Your business - Turnover currency page - As an Exporter I w referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'tradingHistoryWithBuyer', outstandingPayments: true, exporterHasTradedWithBuyer: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'tradingHistoryWithBuyer', outstandingPayments: true, exporterHasTradedWithBuyer: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${CURRENCY_OF_LATE_PAYMENTS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/currency-of-late-payments/currency-of-late-payments.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/currency-of-late-payments/currency-of-late-payments.spec.js index fa20351444..a11551ec95 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/currency-of-late-payments/currency-of-late-payments.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/currency-of-late-payments/currency-of-late-payments.spec.js @@ -33,7 +33,7 @@ context( referenceNumber = refNumber; // go to the page we want to test. - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'tradingHistoryWithBuyer', outstandingPayments: true, exporterHasTradedWithBuyer: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'tradingHistoryWithBuyer', outstandingPayments: true, exporterHasTradedWithBuyer: true }); url = `${baseUrl}${ROOT}/${referenceNumber}${CURRENCY_OF_LATE_PAYMENTS}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/failed-to-pay-on-time-total-contract-value-over-threshold.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/failed-to-pay-on-time-total-contract-value-over-threshold.spec.js index e643489442..107da22401 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/failed-to-pay-on-time-total-contract-value-over-threshold.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/failed-to-pay-on-time-total-contract-value-over-threshold.spec.js @@ -19,7 +19,7 @@ context('Insurance - Your buyer - Failed to pay on time page - total contract va url = `${baseUrl}${ROOT}/${referenceNumber}${FAILED_TO_PAY}`; creditInsuranceCoverUrl = `${baseUrl}${ROOT}/${referenceNumber}${CREDIT_INSURANCE_COVER}`; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'outstandingOrOverduePayments', exporterHasTradedWithBuyer: true, outstandingPayments: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'outstandingOrOverduePayments', exporterHasTradedWithBuyer: true, outstandingPayments: true }); cy.assertUrl(url); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/failed-to-pay-on-time.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/failed-to-pay-on-time.spec.js index dab4068dda..3aa13d3bd8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/failed-to-pay-on-time.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/failed-to-pay-on-time.spec.js @@ -30,7 +30,11 @@ context( url = `${baseUrl}${ROOT}/${referenceNumber}${FAILED_TO_PAY}`; buyerFinancialInformationUrl = `${baseUrl}${ROOT}/${referenceNumber}${BUYER_FINANCIAL_INFORMATION}`; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'outstandingOrOverduePayments', exporterHasTradedWithBuyer: true, outstandingPayments: true }); + cy.completeAndSubmitYourBuyerForms({ + stopSubmittingAfter: 'outstandingOrOverduePayments', + exporterHasTradedWithBuyer: true, + outstandingPayments: true, + }); cy.assertUrl(url); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/save-and-back/failed-to-pay-on-time-save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/save-and-back/failed-to-pay-on-time-save-and-back.spec.js index 329ddb6c98..dbf6513fdb 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/save-and-back/failed-to-pay-on-time-save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/save-and-back/failed-to-pay-on-time-save-and-back.spec.js @@ -18,7 +18,7 @@ context('Insurance - Your buyer - Failed to pay on time - Save and back', () => url = `${baseUrl}${ROOT}/${referenceNumber}${FAILED_TO_PAY}`; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'outstandingOrOverduePayments', exporterHasTradedWithBuyer: true, outstandingPayments: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'outstandingOrOverduePayments', exporterHasTradedWithBuyer: true, outstandingPayments: true }); cy.assertUrl(url); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/validation/failed-to-pay-on-time-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/validation/failed-to-pay-on-time-validation.spec.js index a0642a7567..940ad05eb2 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/validation/failed-to-pay-on-time-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/failed-to-pay-on-time/validation/failed-to-pay-on-time-validation.spec.js @@ -26,7 +26,7 @@ context('Insurance - Your buyer - Failed to pay on time page - Validation', () = url = `${baseUrl}${ROOT}/${referenceNumber}${FAILED_TO_PAY}`; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'outstandingOrOverduePayments', exporterHasTradedWithBuyer: true, outstandingPayments: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'outstandingOrOverduePayments', exporterHasTradedWithBuyer: true, outstandingPayments: true }); cy.assertUrl(url); }); 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 bb134256db..47b2252e66 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 @@ -26,7 +26,7 @@ context('Insurance - Your buyer - Outstanding or overdue payments - Alternative url = `${baseUrl}${ROOT}/${referenceNumber}${OUTSTANDING_OR_OVERDUE_PAYMENTS}`; cy.completeAndSubmitYourBuyerForms({ - formToStopAt: 'currencyOfLatePayments', + stopSubmittingAfter: 'currencyOfLatePayments', outstandingPayments: true, exporterHasTradedWithBuyer: true, alternativeCurrency: true, 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 b6b84f7aab..ba48023953 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 @@ -26,7 +26,7 @@ context('Insurance - Your buyer - Outstanding or overdue payments - Non-GBP (sup url = `${baseUrl}${ROOT}/${referenceNumber}${OUTSTANDING_OR_OVERDUE_PAYMENTS}`; cy.completeAndSubmitYourBuyerForms({ - formToStopAt: 'currencyOfLatePayments', + stopSubmittingAfter: 'currencyOfLatePayments', outstandingPayments: true, exporterHasTradedWithBuyer: true, isoCode: USD.isoCode, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/outstanding-or-overdue-payments.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/outstanding-or-overdue-payments.spec.js index a84deaefa6..5e12493fb4 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/outstanding-or-overdue-payments.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/outstanding-or-overdue-payments.spec.js @@ -37,7 +37,7 @@ context( failedToPayUrl = `${baseUrl}${ROOT}/${referenceNumber}${FAILED_TO_PAY}`; tradingHistoryUrl = `${baseUrl}${ROOT}/${referenceNumber}${TRADING_HISTORY}`; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'currencyOfLatePayments', outstandingPayments: true, exporterHasTradedWithBuyer: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'currencyOfLatePayments', outstandingPayments: true, exporterHasTradedWithBuyer: true }); cy.assertUrl(url); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/save-and-back/outstanding-or-overdue-payments-save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/save-and-back/outstanding-or-overdue-payments-save-and-back.spec.js index 0acac81c1a..c9886ddf92 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/save-and-back/outstanding-or-overdue-payments-save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/save-and-back/outstanding-or-overdue-payments-save-and-back.spec.js @@ -24,7 +24,7 @@ context('Insurance - Your buyer - Outstanding or overdue payments - Save and bac url = `${baseUrl}${ROOT}/${referenceNumber}${OUTSTANDING_OR_OVERDUE_PAYMENTS}`; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'currencyOfLatePayments', outstandingPayments: true, exporterHasTradedWithBuyer: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'currencyOfLatePayments', outstandingPayments: true, exporterHasTradedWithBuyer: true }); cy.assertUrl(url); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/validation/outstanding-or-overdue-payments-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/validation/outstanding-or-overdue-payments-validation.spec.js index e5eb78525d..32862f160d 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/validation/outstanding-or-overdue-payments-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/outstanding-or-overdue-payments/validation/outstanding-or-overdue-payments-validation.spec.js @@ -52,7 +52,7 @@ context('Insurance - Your buyer - Outstanding or overdue payments - validation', url = `${baseUrl}${ROOT}/${referenceNumber}${OUTSTANDING_OR_OVERDUE_PAYMENTS}`; failedToPayUrl = `${baseUrl}${ROOT}/${referenceNumber}${FAILED_TO_PAY}`; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'currencyOfLatePayments', outstandingPayments: true, exporterHasTradedWithBuyer: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'currencyOfLatePayments', outstandingPayments: true, exporterHasTradedWithBuyer: true }); cy.assertUrl(url); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/traded-with-buyer/save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/traded-with-buyer/save-and-back.spec.js index f3de0e37b5..fcf13c77f3 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/traded-with-buyer/save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/traded-with-buyer/save-and-back.spec.js @@ -15,7 +15,7 @@ context('Insurance - Your buyer - Working with buyer - Save and back', () => { cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'connectionWithTheBuyer' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'connectionWithTheBuyer' }); url = `${baseUrl}${ROOT}/${referenceNumber}${TRADED_WITH_BUYER}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/traded-with-buyer/traded-with-buyer-total-contract-value-over-threshold.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/traded-with-buyer/traded-with-buyer-total-contract-value-over-threshold.spec.js index 0c9621f134..3c7c66ae64 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/traded-with-buyer/traded-with-buyer-total-contract-value-over-threshold.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/traded-with-buyer/traded-with-buyer-total-contract-value-over-threshold.spec.js @@ -17,7 +17,7 @@ context('Insurance - Your buyer - Traded with buyer page - Submission with total cy.completeSignInAndGoToApplication({ totalContractValueOverThreshold: true }).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'connectionWithTheBuyer' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'connectionWithTheBuyer' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${TRADED_WITH_BUYER}`; tradingHistoryUrl = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${TRADING_HISTORY}`; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/traded-with-buyer/traded-with-buyer.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/traded-with-buyer/traded-with-buyer.spec.js index 4f14dfe352..fd5788f0a8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/traded-with-buyer/traded-with-buyer.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/traded-with-buyer/traded-with-buyer.spec.js @@ -30,7 +30,7 @@ context('Insurance - Your buyer - Traded with buyer page - As an exporter, I wan cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { referenceNumber = refNumber; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'connectionWithTheBuyer' }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'connectionWithTheBuyer' }); url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${TRADED_WITH_BUYER}`; tradingHistoryUrl = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${TRADING_HISTORY}`; @@ -96,11 +96,8 @@ context('Insurance - Your buyer - Traded with buyer page - As an exporter, I wan }); it('should render validation errors', () => { - const expectedErrorsCount = 1; - cy.submitAndAssertRadioErrors({ field: noRadio(FIELD_ID), - expectedErrorsCount, expectedErrorMessage: ERROR_MESSAGE.IS_EMPTY, }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/trading-history/save-and-back/trading-history-save-and-back.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/trading-history/save-and-back/trading-history-save-and-back.spec.js index 1ee228c63a..c13b8e33f2 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/trading-history/save-and-back/trading-history-save-and-back.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/trading-history/save-and-back/trading-history-save-and-back.spec.js @@ -18,7 +18,7 @@ context('Insurance - Your buyer - Trading history - No outstanding payments - Sa url = `${baseUrl}${ROOT}/${referenceNumber}${TRADING_HISTORY}`; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'tradedWithBuyer', exporterHasTradedWithBuyer: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'tradedWithBuyer', exporterHasTradedWithBuyer: true }); cy.assertUrl(url); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/trading-history/trading-history-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/trading-history/trading-history-page.spec.js index 054c8f9f59..69e217a19c 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/trading-history/trading-history-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/trading-history/trading-history-page.spec.js @@ -32,7 +32,7 @@ context( failedToPayUrl = `${baseUrl}${ROOT}/${referenceNumber}${FAILED_TO_PAY}`; currencyOfLatePaymentsUrl = `${baseUrl}${ROOT}/${referenceNumber}${CURRENCY_OF_LATE_PAYMENTS}`; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'tradedWithBuyer', exporterHasTradedWithBuyer: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'tradedWithBuyer', exporterHasTradedWithBuyer: true }); cy.assertUrl(url); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/trading-history/validation/trading-history-validation.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/trading-history/validation/trading-history-validation.spec.js index bd8cbf8592..a93918bfbc 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/trading-history/validation/trading-history-validation.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-buyer/trading-history/validation/trading-history-validation.spec.js @@ -26,7 +26,7 @@ context('Insurance - Your buyer - Trading history page - Validation', () => { url = `${baseUrl}${ROOT}/${referenceNumber}${TRADING_HISTORY}`; - cy.completeAndSubmitYourBuyerForms({ formToStopAt: 'tradedWithBuyer', exporterHasTradedWithBuyer: true }); + cy.completeAndSubmitYourBuyerForms({ stopSubmittingAfter: 'tradedWithBuyer', exporterHasTradedWithBuyer: true }); cy.assertUrl(url); }); diff --git a/e2e-tests/pages/insurance/policy/multipleContractPolicyExportValue.js b/e2e-tests/pages/insurance/policy/multipleContractPolicyExportValue.js index d9728114fa..92218b2b1e 100644 --- a/e2e-tests/pages/insurance/policy/multipleContractPolicyExportValue.js +++ b/e2e-tests/pages/insurance/policy/multipleContractPolicyExportValue.js @@ -12,8 +12,10 @@ const multipleContractPolicyExportValue = { ...field(MAXIMUM_BUYER_WILL_OWE), hint: { forExample: () => cy.get(`[data-cy="${MAXIMUM_BUYER_WILL_OWE}-hint-for-example"]`), - needMoreCover: () => cy.get(`[data-cy="${MAXIMUM_BUYER_WILL_OWE}-hint-need-more-cover"]`), - fillInFormLink: () => cy.get(`[data-cy="${MAXIMUM_BUYER_WILL_OWE}-hint-fill-in-form-link"]`), + initialCreditLimit: { + intro: () => cy.get(`[data-cy="${MAXIMUM_BUYER_WILL_OWE}-hint-initial-credit-limit-intro"]`), + link: () => cy.get(`[data-cy="${MAXIMUM_BUYER_WILL_OWE}-hint-initial-credit-limit-link"]`), + }, noDecimals: () => cy.get(`[data-cy="${MAXIMUM_BUYER_WILL_OWE}-hint-no-decimals"]`), }, text: () => cy.get('[data-cy="details-1"]'), diff --git a/e2e-tests/partials/headingCaption.js b/e2e-tests/partials/headingCaption.js deleted file mode 100644 index 0458f73e58..0000000000 --- a/e2e-tests/partials/headingCaption.js +++ /dev/null @@ -1 +0,0 @@ -export const headingCaption = () => cy.get('[data-cy="heading-caption'); diff --git a/e2e-tests/partials/index.js b/e2e-tests/partials/index.js index e398587346..ac106ddb29 100644 --- a/e2e-tests/partials/index.js +++ b/e2e-tests/partials/index.js @@ -4,7 +4,6 @@ export * from './creditPeriodWithBuyer'; export * from './errorSummaryList'; export * from './footer'; export * from './header'; -export * from './headingCaption'; export * from './html'; export * from './insurance'; export * from './pagination'; diff --git a/e2e-tests/quote/cypress/e2e/journeys/cookies-consent/banner/cookies-consent-reject.spec.js b/e2e-tests/quote/cypress/e2e/journeys/cookies-consent/banner/cookies-consent-reject.spec.js index dc1d94cd41..0bec67ed20 100644 --- a/e2e-tests/quote/cypress/e2e/journeys/cookies-consent/banner/cookies-consent-reject.spec.js +++ b/e2e-tests/quote/cypress/e2e/journeys/cookies-consent/banner/cookies-consent-reject.spec.js @@ -45,7 +45,6 @@ context('Cookies consent - reject', () => { cy.checkLink(cookieBanner.cookiesLink(), ROUTES.COOKIES, COOKIES_CONSENT.COOKIES_LINK); - cookieBanner.hideButton().should('exist'); cy.checkText(cookieBanner.hideButton(), COOKIES_CONSENT.HIDE_BUTTON); }); diff --git a/e2e-tests/quote/cypress/e2e/journeys/quote/change-your-answers/change-your-answers-policy-type-and-length.spec.js b/e2e-tests/quote/cypress/e2e/journeys/quote/change-your-answers/change-your-answers-policy-type-and-length.spec.js index 6ae70374f8..9b972f44b0 100644 --- a/e2e-tests/quote/cypress/e2e/journeys/quote/change-your-answers/change-your-answers-policy-type-and-length.spec.js +++ b/e2e-tests/quote/cypress/e2e/journeys/quote/change-your-answers/change-your-answers-policy-type-and-length.spec.js @@ -178,8 +178,6 @@ context('Change your answers - as an exporter, I want to change the details befo }); it('renders a back link with correct url', () => { - backLink().should('exist'); - const expectedHref = `${baseUrl}${CHECK_YOUR_ANSWERS}`; cy.checkLink(backLink(), expectedHref, LINKS.BACK); diff --git a/e2e-tests/quote/cypress/e2e/journeys/quote/tell-us-about-your-policy/tell-us-about-your-multi-policy.spec.js b/e2e-tests/quote/cypress/e2e/journeys/quote/tell-us-about-your-policy/tell-us-about-your-multi-policy.spec.js index f2ce6d3de2..0df6d04786 100644 --- a/e2e-tests/quote/cypress/e2e/journeys/quote/tell-us-about-your-policy/tell-us-about-your-multi-policy.spec.js +++ b/e2e-tests/quote/cypress/e2e/journeys/quote/tell-us-about-your-policy/tell-us-about-your-multi-policy.spec.js @@ -61,7 +61,6 @@ context('Tell us about your multiple policy page - as an exporter, I want to pro const field = fieldSelector(fieldId); - field.legend().should('exist'); cy.checkText(field.legend(), FIELDS[fieldId].MULTIPLE_POLICY.LEGEND); }); diff --git a/e2e-tests/quote/cypress/e2e/journeys/quote/tell-us-about-your-policy/tell-us-about-your-single-policy.spec.js b/e2e-tests/quote/cypress/e2e/journeys/quote/tell-us-about-your-policy/tell-us-about-your-single-policy.spec.js index c794d662ba..d63349b730 100644 --- a/e2e-tests/quote/cypress/e2e/journeys/quote/tell-us-about-your-policy/tell-us-about-your-single-policy.spec.js +++ b/e2e-tests/quote/cypress/e2e/journeys/quote/tell-us-about-your-policy/tell-us-about-your-single-policy.spec.js @@ -67,7 +67,6 @@ context('Tell us about your single policy page - as an exporter, I want to provi const field = fieldSelector(fieldId); - field.legend().should('exist'); cy.checkText(field.legend(), FIELDS[fieldId].SINGLE_POLICY.LEGEND); }); diff --git a/e2e-tests/quote/cypress/e2e/journeys/skip-link.spec.js b/e2e-tests/quote/cypress/e2e/journeys/skip-link.spec.js index 5755cb0080..1960089fa2 100644 --- a/e2e-tests/quote/cypress/e2e/journeys/skip-link.spec.js +++ b/e2e-tests/quote/cypress/e2e/journeys/skip-link.spec.js @@ -10,8 +10,6 @@ context('Skip link should take user to the main content of a page', () => { it("When a user keyboard tabs from the html body, skip link should be focused and take the user to the page's #main-content", () => { cy.navigateToRootUrl(); - skipLink().should('exist'); - cy.checkText(skipLink(), LINKS.SKIP_TO_MAIN_CONTENT); }); }); 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 5fc5227eff..f55288375c 100644 --- a/e2e-tests/shared-test-assertions/currency-form-fields/prefix.js +++ b/e2e-tests/shared-test-assertions/currency-form-fields/prefix.js @@ -8,7 +8,7 @@ import { SYMBOLS, USD_CURRENCY_CODE, JPY_CURRENCY_CODE, EUR_CURRENCY_CODE } from */ const prefixAssertions = ({ fieldId }) => { describe('when not selecting a currency', () => { - it(`should display ${SYMBOLS.GBP} as the prefix`, () => { + it(`should render ${SYMBOLS.GBP} as the prefix`, () => { cy.clickSubmitButton(); cy.assertPrefix({ fieldId, value: SYMBOLS.GBP }); @@ -16,21 +16,21 @@ const prefixAssertions = ({ fieldId }) => { }); describe(`when selecting ${USD_CURRENCY_CODE} as the currency code`, () => { - it(`should display ${SYMBOLS.USD} as the prefix`, () => { + it(`should render ${SYMBOLS.USD} as the prefix`, () => { cy.completeAndSubmitCurrencyForm({ 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`, () => { + it(`should render ${SYMBOLS.JPY} as the prefix`, () => { cy.completeAndSubmitCurrencyForm({ 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`, () => { + it(`should render ${SYMBOLS.EUR} as the prefix`, () => { cy.completeAndSubmitCurrencyForm({ isoCode: EUR_CURRENCY_CODE }); cy.assertPrefix({ fieldId, value: SYMBOLS.EUR }); }); diff --git a/e2e-tests/shared-test-assertions/percentage-field-validation/index.js b/e2e-tests/shared-test-assertions/percentage-field-validation/index.js index dceb398c9b..3714155d1f 100644 --- a/e2e-tests/shared-test-assertions/percentage-field-validation/index.js +++ b/e2e-tests/shared-test-assertions/percentage-field-validation/index.js @@ -28,11 +28,11 @@ export const percentageFieldValidation = ({ expectedErrorsCount: totalExpectedErrors, }; - it(`should display validation errors when ${fieldId} percentage field is left empty`, () => { + it(`should render validation errors when ${fieldId} percentage field is left empty`, () => { cy.submitAndAssertFieldErrors({ ...assertions, expectedErrorMessage: errorMessages.IS_EMPTY }); }); - it(`should display validation errors when ${fieldId} percentage field is a decimal place number`, () => { + it(`should render validation errors when ${fieldId} percentage field is a decimal place number`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '5.5', @@ -40,7 +40,7 @@ export const percentageFieldValidation = ({ }); }); - it(`should display validation errors when ${fieldId} percentage has a comma`, () => { + it(`should render validation errors when ${fieldId} percentage has a comma`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '4,4', @@ -48,7 +48,7 @@ export const percentageFieldValidation = ({ }); }); - it(`should display validation errors when ${fieldId} percentage has special characters`, () => { + it(`should render validation errors when ${fieldId} percentage has special characters`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '50!', @@ -56,7 +56,7 @@ export const percentageFieldValidation = ({ }); }); - it(`should display validation errors when ${fieldId} percentage has letters`, () => { + it(`should render validation errors when ${fieldId} percentage has letters`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: 'one', @@ -64,7 +64,7 @@ export const percentageFieldValidation = ({ }); }); - it(`should display validation errors when ${fieldId} percentage field is over 100`, () => { + it(`should render validation errors when ${fieldId} percentage field is over 100`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: '101', @@ -72,7 +72,7 @@ export const percentageFieldValidation = ({ }); }); - it(`should display validation errors when ${fieldId} percentage field is below ${minimum}`, () => { + it(`should render validation errors when ${fieldId} percentage field is below ${minimum}`, () => { cy.submitAndAssertFieldErrors({ ...assertions, value: `${minimum - 1}`, diff --git a/generate-exip-pricing-grid/index.js b/generate-exip-pricing-grid/index.js index 8c51b0602b..3b4f8ae408 100644 --- a/generate-exip-pricing-grid/index.js +++ b/generate-exip-pricing-grid/index.js @@ -135,21 +135,21 @@ const mapRowRates = (row) => { }; /** - * mapRiskCategory - * Map a risk category in the spreadsheet to the risk name in the grid. - * @param {String} Risk category from spreadsheet, e.g "Standard Risk" - * @returns {String} Risk category in the grid, e.g "STANDARD" + * mapEsraClassification + * Map an ESRA classification in the spreadsheet to the ESRA classification in the grid. + * @param {String} esraClassification: ESRA classification from spreadsheet, e.g "Standard Risk" + * @returns {String | null} Risk category in the grid, e.g "STANDARD" */ -const mapRiskCategory = (riskCategory) => { - if (riskCategory === RISK.STANDARD) { +const mapEsraClassification = (esraClassification) => { + if (esraClassification === RISK.STANDARD) { return RISK_FIELDS.STANDARD; } - if (riskCategory === RISK.HIGH) { + if (esraClassification === RISK.HIGH) { return RISK_FIELDS.HIGH; } - if (riskCategory === RISK.VERY_HIGH) { + if (esraClassification === RISK.VERY_HIGH) { return RISK_FIELDS.VERY_HIGH; } @@ -159,15 +159,15 @@ const mapRiskCategory = (riskCategory) => { /** * addRowToGrid * add a single row to the pricing grid. - * @param {Object} Pricing grid - * @param {Number} Months of cover for the row - * @param {Array} The rates to add - * @param {String} Policy type - * @param {String} Risk category + * @param {Object} grid: Pricing grid + * @param {Number} months: Months of cover for the row + * @param {Array} rates: The rates to add + * @param {String} policyType: Policy type + * @param {String} esraClassification: ESRA classification from spreadsheet, e.g "Standard Risk" * @returns {Object} Updated pricing grid */ -const addRowToGrid = (grid, months, rates, policyType, riskCategory) => { - grid[policyType][riskCategory].push({ +const addRowToGrid = (grid, months, rates, policyType, esraClassification) => { + grid[policyType][esraClassification].push({ months, rates, }); @@ -178,9 +178,9 @@ const addRowToGrid = (grid, months, rates, policyType, riskCategory) => { /** * addPolicyToGrid * Map over every row for a policy and add to the grid - * @param {Object} Pricing grid - * @param {String} Policy type - * @param {String} All rows for the policy type (all risk categories and associated data) + * @param {Object} grid: Pricing grid + * @param {String} policyType: Policy type + * @param {Array} rows: All rows for the policy type (all risk categories and associated data) * @returns {Object} Updated pricing grid */ const addPolicyToGrid = (grid, policyType, rows) => { @@ -193,9 +193,9 @@ const addPolicyToGrid = (grid, policyType, rows) => { const months = Number(row[1]); const rates = mapRowRates(row); - const riskCategory = mapRiskCategory(row[0]); + const esraClassification = mapEsraClassification(row[0]); - updatedGrid = addRowToGrid(grid, months, rates, policyType, riskCategory); + updatedGrid = addRowToGrid(grid, months, rates, policyType, esraClassification); } }); diff --git a/package-lock.json b/package-lock.json index 98afcce59e..6d283467f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2210,15 +2210,15 @@ } }, "node_modules/@commitlint/cli": { - "version": "19.6.0", - "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-19.6.0.tgz", - "integrity": "sha512-v17BgGD9w5KnthaKxXnEg6KLq6DYiAxyiN44TpiRtqyW8NSq+Kx99mkEG8Qo6uu6cI5eMzMojW2muJxjmPnF8w==", + "version": "19.6.1", + "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-19.6.1.tgz", + "integrity": "sha512-8hcyA6ZoHwWXC76BoC8qVOSr8xHy00LZhZpauiD0iO0VYbVhMnED0da85lTfIULxl7Lj4c6vZgF0Wu/ed1+jlQ==", "dev": true, "license": "MIT", "dependencies": { "@commitlint/format": "^19.5.0", "@commitlint/lint": "^19.6.0", - "@commitlint/load": "^19.5.0", + "@commitlint/load": "^19.6.1", "@commitlint/read": "^19.5.0", "@commitlint/types": "^19.5.0", "tinyexec": "^0.3.0", @@ -2250,6 +2250,7 @@ "resolved": "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-19.5.0.tgz", "integrity": "sha512-CHtj92H5rdhKt17RmgALhfQt95VayrUo2tSqY9g2w+laAXyk7K/Ef6uPm9tn5qSIwSmrLjKaXK9eiNuxmQrDBw==", "dev": true, + "license": "MIT", "dependencies": { "@commitlint/types": "^19.5.0", "ajv": "^8.11.0" @@ -2281,6 +2282,7 @@ "resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-19.5.0.tgz", "integrity": "sha512-aqyGgytXhl2ejlk+/rfgtwpPexYyri4t8/n4ku6rRJoRhGZpLFMqrZ+YaubeGysCP6oz4mMA34YSTaSOKEeNrg==", "dev": true, + "license": "MIT", "engines": { "node": ">=v18" } @@ -2329,10 +2331,11 @@ } }, "node_modules/@commitlint/load": { - "version": "19.5.0", - "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-19.5.0.tgz", - "integrity": "sha512-INOUhkL/qaKqwcTUvCE8iIUf5XHsEPCLY9looJ/ipzi7jtGhgmtH7OOFiNvwYgH7mA8osUWOUDV8t4E2HAi4xA==", + "version": "19.6.1", + "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-19.6.1.tgz", + "integrity": "sha512-kE4mRKWWNju2QpsCWt428XBvUH55OET2N4QKQ0bF85qS/XbsRGG1MiTByDNlEVpEPceMkDr46LNH95DtRwcsfA==", "dev": true, + "license": "MIT", "dependencies": { "@commitlint/config-validator": "^19.5.0", "@commitlint/execute-rule": "^19.5.0", @@ -2340,7 +2343,7 @@ "@commitlint/types": "^19.5.0", "chalk": "^5.3.0", "cosmiconfig": "^9.0.0", - "cosmiconfig-typescript-loader": "^5.0.0", + "cosmiconfig-typescript-loader": "^6.1.0", "lodash.isplainobject": "^4.0.6", "lodash.merge": "^4.6.2", "lodash.uniq": "^4.5.0" @@ -2395,6 +2398,7 @@ "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-19.5.0.tgz", "integrity": "sha512-CU/GscZhCUsJwcKTJS9Ndh3AKGZTNFIOoQB2n8CmFnizE0VnEuJoum+COW+C1lNABEeqk6ssfc1Kkalm4bDklA==", "dev": true, + "license": "MIT", "dependencies": { "@commitlint/config-validator": "^19.5.0", "@commitlint/types": "^19.5.0", @@ -2582,121 +2586,121 @@ } }, "node_modules/@cspell/dict-ada": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/@cspell/dict-ada/-/dict-ada-4.0.5.tgz", - "integrity": "sha512-6/RtZ/a+lhFVmrx/B7bfP7rzC4yjEYe8o74EybXcvu4Oue6J4Ey2WSYj96iuodloj1LWrkNCQyX5h4Pmcj0Iag==", + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@cspell/dict-ada/-/dict-ada-4.0.6.tgz", + "integrity": "sha512-1DpA3LeidQS5Wec5ZnrIRtuv/ijUcfcUq8G5hj/3QZT4vTTRXtIaQnfsq7t3XYsRlisYHkVmm2CgsJ/8hKChLw==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-al": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@cspell/dict-al/-/dict-al-1.0.3.tgz", - "integrity": "sha512-V1HClwlfU/qwSq2Kt+MkqRAsonNu3mxjSCDyGRecdLGIHmh7yeEeaxqRiO/VZ4KP+eVSiSIlbwrb5YNFfxYZbw==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-al/-/dict-al-1.0.4.tgz", + "integrity": "sha512-W4ppuwhZN6A1genmj9Q4NC8UKy7TrRb7UjvMsuPDen+V8anePTys9a0DpKp3z0S6nlrcZgqYNe9Hw/9k76mkAQ==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-aws": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/@cspell/dict-aws/-/dict-aws-4.0.7.tgz", - "integrity": "sha512-PoaPpa2NXtSkhGIMIKhsJUXB6UbtTt6Ao3x9JdU9kn7fRZkwD4RjHDGqulucIOz7KeEX/dNRafap6oK9xHe4RA==", + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@cspell/dict-aws/-/dict-aws-4.0.9.tgz", + "integrity": "sha512-bDYdnnJGwSkIZ4gzrauu7qzOs/ZAY/FnU4k11LgdMI8BhwMfsbsy2EI1iS+sD/BI5ZnNT9kU5YR3WADeNOmhRg==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-bash": { - "version": "4.1.8", - "resolved": "https://registry.npmjs.org/@cspell/dict-bash/-/dict-bash-4.1.8.tgz", - "integrity": "sha512-I2CM2pTNthQwW069lKcrVxchJGMVQBzru2ygsHCwgidXRnJL/NTjAPOFTxN58Jc1bf7THWghfEDyKX/oyfc0yg==", + "version": "4.1.10", + "resolved": "https://registry.npmjs.org/@cspell/dict-bash/-/dict-bash-4.1.10.tgz", + "integrity": "sha512-8n/W1tbjkLoXac0nC8N94IXZVf42Pye6ywP01gksYVu5dOr6pB9BA9N6Kop8rPJP4X0yQmFM8Ht+xpggyHpuMQ==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-companies": { - "version": "3.1.9", - "resolved": "https://registry.npmjs.org/@cspell/dict-companies/-/dict-companies-3.1.9.tgz", - "integrity": "sha512-w7XEJ2B6x2jq9ws5XNyYgpYj2MxdZ3jW3PETLxjK7nc8pulCFmaGVgZ0JTnDWfJ3QMOczoagn5f9LM2PZ/CuJg==", + "version": "3.1.12", + "resolved": "https://registry.npmjs.org/@cspell/dict-companies/-/dict-companies-3.1.12.tgz", + "integrity": "sha512-99FxBNdLOQc3nVQ663Xh7JqDLbIy/AdqOecQ5bk3HpmXpSkoDvTT7XCUU5nQZvmFBrrQlXFKlRRYjLfTEOUDdA==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-cpp": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/@cspell/dict-cpp/-/dict-cpp-6.0.2.tgz", - "integrity": "sha512-yw5eejWvY4bAnc6LUA44m4WsFwlmgPt2uMSnO7QViGMBDuoeopMma4z9XYvs4lSjTi8fIJs/A1YDfM9AVzb8eg==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@cspell/dict-cpp/-/dict-cpp-6.0.3.tgz", + "integrity": "sha512-OFrVXdxCeGKnon36Pe3yFjBuY4kzzEwWFf3vDz+cJTodZDkjFkBifQeTtt5YfimgF8cfAJZXkBCsxjipAgmAiw==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-cryptocurrencies": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/@cspell/dict-cryptocurrencies/-/dict-cryptocurrencies-5.0.3.tgz", - "integrity": "sha512-bl5q+Mk+T3xOZ12+FG37dB30GDxStza49Rmoax95n37MTLksk9wBo1ICOlPJ6PnDUSyeuv4SIVKgRKMKkJJglA==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-cryptocurrencies/-/dict-cryptocurrencies-5.0.4.tgz", + "integrity": "sha512-6iFu7Abu+4Mgqq08YhTKHfH59mpMpGTwdzDB2Y8bbgiwnGFCeoiSkVkgLn1Kel2++hYcZ8vsAW/MJS9oXxuMag==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-csharp": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/@cspell/dict-csharp/-/dict-csharp-4.0.5.tgz", - "integrity": "sha512-c/sFnNgtRwRJxtC3JHKkyOm+U3/sUrltFeNwml9VsxKBHVmvlg4tk4ar58PdpW9/zTlGUkWi2i85//DN1EsUCA==", + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@cspell/dict-csharp/-/dict-csharp-4.0.6.tgz", + "integrity": "sha512-w/+YsqOknjQXmIlWDRmkW+BHBPJZ/XDrfJhZRQnp0wzpPOGml7W0q1iae65P2AFRtTdPKYmvSz7AL5ZRkCnSIw==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-css": { - "version": "4.0.16", - "resolved": "https://registry.npmjs.org/@cspell/dict-css/-/dict-css-4.0.16.tgz", - "integrity": "sha512-70qu7L9z/JR6QLyJPk38fNTKitlIHnfunx0wjpWQUQ8/jGADIhMCrz6hInBjqPNdtGpYm8d1dNFyF8taEkOgrQ==", + "version": "4.0.17", + "resolved": "https://registry.npmjs.org/@cspell/dict-css/-/dict-css-4.0.17.tgz", + "integrity": "sha512-2EisRLHk6X/PdicybwlajLGKF5aJf4xnX2uuG5lexuYKt05xV/J/OiBADmi8q9obhxf1nesrMQbqAt+6CsHo/w==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-dart": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@cspell/dict-dart/-/dict-dart-2.2.4.tgz", - "integrity": "sha512-of/cVuUIZZK/+iqefGln8G3bVpfyN6ZtH+LyLkHMoR5tEj+2vtilGNk9ngwyR8L4lEqbKuzSkOxgfVjsXf5PsQ==", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@cspell/dict-dart/-/dict-dart-2.2.5.tgz", + "integrity": "sha512-j/J99MH4NV2Klok0XMqnHxGl2lkewBcYjGYWdBKvVSbLXyA4oOaL+vCZR8Nmwf+lHInJFN8nkMU2k7TnC0MgUw==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-data-science": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@cspell/dict-data-science/-/dict-data-science-2.0.5.tgz", - "integrity": "sha512-nNSILXmhSJox9/QoXICPQgm8q5PbiSQP4afpbkBqPi/u/b3K9MbNH5HvOOa6230gxcGdbZ9Argl2hY/U8siBlg==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@cspell/dict-data-science/-/dict-data-science-2.0.6.tgz", + "integrity": "sha512-gOYKZOg358yhnnQfr1/f232REmjeIymXUHJdrLEMPirluv2rzMWvEBBazqRVQ++jMUNg9IduVI0v096ZWMDekA==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-django": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/@cspell/dict-django/-/dict-django-4.1.3.tgz", - "integrity": "sha512-yBspeL3roJlO0a1vKKNaWABURuHdHZ9b1L8d3AukX0AsBy9snSggc8xCavPmSzNfeMDXbH+1lgQiYBd3IW03fg==", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-django/-/dict-django-4.1.4.tgz", + "integrity": "sha512-fX38eUoPvytZ/2GA+g4bbdUtCMGNFSLbdJJPKX2vbewIQGfgSFJKY56vvcHJKAvw7FopjvgyS/98Ta9WN1gckg==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-docker": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/@cspell/dict-docker/-/dict-docker-1.1.11.tgz", - "integrity": "sha512-s0Yhb16/R+UT1y727ekbR/itWQF3Qz275DR1ahOa66wYtPjHUXmhM3B/LT3aPaX+hD6AWmK23v57SuyfYHUjsw==", + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/@cspell/dict-docker/-/dict-docker-1.1.12.tgz", + "integrity": "sha512-6d25ZPBnYZaT9D9An/x6g/4mk542R8bR3ipnby3QFCxnfdd6xaWiTcwDPsCgwN2aQZIQ1jX/fil9KmBEqIK/qA==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-dotnet": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/@cspell/dict-dotnet/-/dict-dotnet-5.0.8.tgz", - "integrity": "sha512-MD8CmMgMEdJAIPl2Py3iqrx3B708MbCIXAuOeZ0Mzzb8YmLmiisY7QEYSZPg08D7xuwARycP0Ki+bb0GAkFSqg==", + "version": "5.0.9", + "resolved": "https://registry.npmjs.org/@cspell/dict-dotnet/-/dict-dotnet-5.0.9.tgz", + "integrity": "sha512-JGD6RJW5sHtO5lfiJl11a5DpPN6eKSz5M1YBa1I76j4dDOIqgZB6rQexlDlK1DH9B06X4GdDQwdBfnpAB0r2uQ==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-elixir": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@cspell/dict-elixir/-/dict-elixir-4.0.6.tgz", - "integrity": "sha512-TfqSTxMHZ2jhiqnXlVKM0bUADtCvwKQv2XZL/DI0rx3doG8mEMS8SGPOmiyyGkHpR/pGOq18AFH3BEm4lViHIw==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/@cspell/dict-elixir/-/dict-elixir-4.0.7.tgz", + "integrity": "sha512-MAUqlMw73mgtSdxvbAvyRlvc3bYnrDqXQrx5K9SwW8F7fRYf9V4vWYFULh+UWwwkqkhX9w03ZqFYRTdkFku6uA==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-en_us": { - "version": "4.3.28", - "resolved": "https://registry.npmjs.org/@cspell/dict-en_us/-/dict-en_us-4.3.28.tgz", - "integrity": "sha512-BN1PME7cOl7DXRQJ92pEd1f0Xk5sqjcDfThDGkKcsgwbSOY7KnTc/czBW6Pr3WXIchIm6cT12KEfjNqx7U7Rrw==", + "version": "4.3.29", + "resolved": "https://registry.npmjs.org/@cspell/dict-en_us/-/dict-en_us-4.3.29.tgz", + "integrity": "sha512-7kHP0sJ271oS5RqakxvhWvHFoCUFCBDV6+cgIRIpKwW0aYVB4F2AwElGsdeE/XEmihhYUje7e/e6X3IEWHrcrQ==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-en-common-misspellings": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/@cspell/dict-en-common-misspellings/-/dict-en-common-misspellings-2.0.7.tgz", - "integrity": "sha512-qNFo3G4wyabcwnM+hDrMYKN9vNVg/k9QkhqSlSst6pULjdvPyPs1mqz1689xO/v9t8e6sR4IKc3CgUXDMTYOpA==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/@cspell/dict-en-common-misspellings/-/dict-en-common-misspellings-2.0.8.tgz", + "integrity": "sha512-l1u/pDjwrPyWwBd1hCkZhdsK8yLbLFPD2xWz+1tFFI7WaV9ckDZoF3woRc/0wFGRy53yrfSAVuwhoYOQnHe/fA==", "dev": true, "license": "CC BY-SA 4.0" }, @@ -2708,30 +2712,30 @@ "license": "MIT" }, "node_modules/@cspell/dict-filetypes": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/@cspell/dict-filetypes/-/dict-filetypes-3.0.9.tgz", - "integrity": "sha512-U7ycC1cE32A5aEgwzp/iE0TVabonUFnVt+Ygbf6NsIWqEuFWZgZChC7gfztA4T1fpuj602nFdp7eOnTWKORsnQ==", + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@cspell/dict-filetypes/-/dict-filetypes-3.0.10.tgz", + "integrity": "sha512-JEN3627joBVtpa1yfkdN9vz1Z129PoKGHBKjXCEziJvf2Zt1LeULWYYYg/O6pzRR4yzRa5YbXDTuyrN7vX7DFg==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-flutter": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@cspell/dict-flutter/-/dict-flutter-1.0.3.tgz", - "integrity": "sha512-52C9aUEU22ptpgYh6gQyIdA4MP6NPwzbEqndfgPh3Sra191/kgs7CVqXiO1qbtZa9gnYHUoVApkoxRE7mrXHfg==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-flutter/-/dict-flutter-1.0.4.tgz", + "integrity": "sha512-XlWLCUsI9m2rKJ5TqYcDucajzQOqa7Hy8dhHaRQEyWic6oYvikpA1KtXsi8JD6JaiqfhejZZ6vNsQm1//6iSAg==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-fonts": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@cspell/dict-fonts/-/dict-fonts-4.0.3.tgz", - "integrity": "sha512-sPd17kV5qgYXLteuHFPn5mbp/oCHKgitNfsZLFC3W2fWEgZlhg4hK+UGig3KzrYhhvQ8wBnmZrAQm0TFKCKzsA==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-fonts/-/dict-fonts-4.0.4.tgz", + "integrity": "sha512-cHFho4hjojBcHl6qxidl9CvUb492IuSk7xIf2G2wJzcHwGaCFa2o3gRcxmIg1j62guetAeDDFELizDaJlVRIOg==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-fsharp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@cspell/dict-fsharp/-/dict-fsharp-1.0.4.tgz", - "integrity": "sha512-G5wk0o1qyHUNi9nVgdE1h5wl5ylq7pcBjX8vhjHcO4XBq20D5eMoXjwqMo/+szKAqzJ+WV3BgAL50akLKrT9Rw==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@cspell/dict-fsharp/-/dict-fsharp-1.0.5.tgz", + "integrity": "sha512-6SsdHOtUsTDZ50wjK4FcvIjPiwBSDU9M/+zmUWpFfT5k5d5Ei80n4HGisFtuFdtmoLgz2F/xNnVvhsA2MWJv+w==", "dev": true, "license": "MIT" }, @@ -2743,44 +2747,44 @@ "license": "MIT" }, "node_modules/@cspell/dict-gaming-terms": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@cspell/dict-gaming-terms/-/dict-gaming-terms-1.0.9.tgz", - "integrity": "sha512-AVIrZt3YiUnxsUzzGYTZ1XqgtkgwGEO0LWIlEf+SiDUEVLtv4CYmmyXFQ+WXDN0pyJ0wOwDazWrP0Cu7avYQmQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@cspell/dict-gaming-terms/-/dict-gaming-terms-1.1.0.tgz", + "integrity": "sha512-46AnDs9XkgJ2f1Sqol1WgfJ8gOqp60fojpc9Wxch7x+BA63g4JfMV5/M5x0sI0TLlLY8EBSglcr8wQF/7C80AQ==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-git": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@cspell/dict-git/-/dict-git-3.0.3.tgz", - "integrity": "sha512-LSxB+psZ0qoj83GkyjeEH/ZViyVsGEF/A6BAo8Nqc0w0HjD2qX/QR4sfA6JHUgQ3Yi/ccxdK7xNIo67L2ScW5A==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-git/-/dict-git-3.0.4.tgz", + "integrity": "sha512-C44M+m56rYn6QCsLbiKiedyPTMZxlDdEYAsPwwlL5bhMDDzXZ3Ic8OCQIhMbiunhCOJJT+er4URmOmM+sllnjg==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-golang": { - "version": "6.0.17", - "resolved": "https://registry.npmjs.org/@cspell/dict-golang/-/dict-golang-6.0.17.tgz", - "integrity": "sha512-uDDLEJ/cHdLiqPw4+5BnmIo2i/TSR+uDvYd6JlBjTmjBKpOCyvUgYRztH7nv5e7virsN5WDiUWah4/ATQGz4Pw==", + "version": "6.0.18", + "resolved": "https://registry.npmjs.org/@cspell/dict-golang/-/dict-golang-6.0.18.tgz", + "integrity": "sha512-Mt+7NwfodDwUk7423DdaQa0YaA+4UoV3XSxQwZioqjpFBCuxfvvv4l80MxCTAAbK6duGj0uHbGTwpv8fyKYPKg==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-google": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@cspell/dict-google/-/dict-google-1.0.4.tgz", - "integrity": "sha512-JThUT9eiguCja1mHHLwYESgxkhk17Gv7P3b1S7ZJzXw86QyVHPrbpVoMpozHk0C9o+Ym764B7gZGKmw9uMGduQ==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@cspell/dict-google/-/dict-google-1.0.5.tgz", + "integrity": "sha512-KNrzfUsoFat94slWzo36g601sIGz6KtE4kBMM0gpqwFLK/MXRyaW65IL4SwysY0PEhuRzg9spLLMnUXuVcY2hQ==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-haskell": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@cspell/dict-haskell/-/dict-haskell-4.0.4.tgz", - "integrity": "sha512-EwQsedEEnND/vY6tqRfg9y7tsnZdxNqOxLXSXTsFA6JRhUlr8Qs88iUUAfsUzWc4nNmmzQH2UbtT25ooG9x4nA==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@cspell/dict-haskell/-/dict-haskell-4.0.5.tgz", + "integrity": "sha512-s4BG/4tlj2pPM9Ha7IZYMhUujXDnI0Eq1+38UTTCpatYLbQqDwRFf2KNPLRqkroU+a44yTUAe0rkkKbwy4yRtQ==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-html": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/@cspell/dict-html/-/dict-html-4.0.10.tgz", - "integrity": "sha512-I9uRAcdtHbh0wEtYZlgF0TTcgH0xaw1B54G2CW+tx4vHUwlde/+JBOfIzird4+WcMv4smZOfw+qHf7puFUbI5g==", + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/@cspell/dict-html/-/dict-html-4.0.11.tgz", + "integrity": "sha512-QR3b/PB972SRQ2xICR1Nw/M44IJ6rjypwzA4jn+GH8ydjAX9acFNfc+hLZVyNe0FqsE90Gw3evLCOIF0vy1vQw==", "dev": true, "license": "MIT" }, @@ -2792,23 +2796,23 @@ "license": "MIT" }, "node_modules/@cspell/dict-java": { - "version": "5.0.10", - "resolved": "https://registry.npmjs.org/@cspell/dict-java/-/dict-java-5.0.10.tgz", - "integrity": "sha512-pVNcOnmoGiNL8GSVq4WbX/Vs2FGS0Nej+1aEeGuUY9CU14X8yAVCG+oih5ZoLt1jaR8YfR8byUF8wdp4qG4XIw==", + "version": "5.0.11", + "resolved": "https://registry.npmjs.org/@cspell/dict-java/-/dict-java-5.0.11.tgz", + "integrity": "sha512-T4t/1JqeH33Raa/QK/eQe26FE17eUCtWu+JsYcTLkQTci2dk1DfcIKo8YVHvZXBnuM43ATns9Xs0s+AlqDeH7w==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-julia": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@cspell/dict-julia/-/dict-julia-1.0.4.tgz", - "integrity": "sha512-bFVgNX35MD3kZRbXbJVzdnN7OuEqmQXGpdOi9jzB40TSgBTlJWA4nxeAKV4CPCZxNRUGnLH0p05T/AD7Aom9/w==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@cspell/dict-julia/-/dict-julia-1.0.5.tgz", + "integrity": "sha512-rMC9OC8POmGw9pN96ByZJaY0YGtzSh64AtuJu4uFcuooF0MGmtXwiAhazRC5kPK5XMS+pKMQql/ItTyKbYh1yg==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-k8s": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@cspell/dict-k8s/-/dict-k8s-1.0.9.tgz", - "integrity": "sha512-Q7GELSQIzo+BERl2ya/nBEnZeQC+zJP19SN1pI6gqDYraM51uYJacbbcWLYYO2Y+5joDjNt/sd/lJtLaQwoSlA==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@cspell/dict-k8s/-/dict-k8s-1.0.10.tgz", + "integrity": "sha512-313haTrX9prep1yWO7N6Xw4D6tvUJ0Xsx+YhCP+5YrrcIKoEw5Rtlg8R4PPzLqe6zibw6aJ+Eqq+y76Vx5BZkw==", "dev": true, "license": "MIT" }, @@ -2820,95 +2824,95 @@ "license": "MIT" }, "node_modules/@cspell/dict-lorem-ipsum": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@cspell/dict-lorem-ipsum/-/dict-lorem-ipsum-4.0.3.tgz", - "integrity": "sha512-WFpDi/PDYHXft6p0eCXuYnn7mzMEQLVeqpO+wHSUd+kz5ADusZ4cpslAA4wUZJstF1/1kMCQCZM6HLZic9bT8A==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-lorem-ipsum/-/dict-lorem-ipsum-4.0.4.tgz", + "integrity": "sha512-+4f7vtY4dp2b9N5fn0za/UR0kwFq2zDtA62JCbWHbpjvO9wukkbl4rZg4YudHbBgkl73HRnXFgCiwNhdIA1JPw==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-lua": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@cspell/dict-lua/-/dict-lua-4.0.6.tgz", - "integrity": "sha512-Jwvh1jmAd9b+SP9e1GkS2ACbqKKRo9E1f9GdjF/ijmooZuHU0hPyqvnhZzUAxO1egbnNjxS/J2T6iUtjAUK2KQ==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/@cspell/dict-lua/-/dict-lua-4.0.7.tgz", + "integrity": "sha512-Wbr7YSQw+cLHhTYTKV6cAljgMgcY+EUAxVIZW3ljKswEe4OLxnVJ7lPqZF5JKjlXdgCjbPSimsHqyAbC5pQN/Q==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-makefile": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@cspell/dict-makefile/-/dict-makefile-1.0.3.tgz", - "integrity": "sha512-R3U0DSpvTs6qdqfyBATnePj9Q/pypkje0Nj26mQJ8TOBQutCRAJbr2ZFAeDjgRx5EAJU/+8txiyVF97fbVRViw==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-makefile/-/dict-makefile-1.0.4.tgz", + "integrity": "sha512-E4hG/c0ekPqUBvlkrVvzSoAA+SsDA9bLi4xSV3AXHTVru7Y2bVVGMPtpfF+fI3zTkww/jwinprcU1LSohI3ylw==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-markdown": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/@cspell/dict-markdown/-/dict-markdown-2.0.7.tgz", - "integrity": "sha512-F9SGsSOokFn976DV4u/1eL4FtKQDSgJHSZ3+haPRU5ki6OEqojxKa8hhj4AUrtNFpmBaJx/WJ4YaEzWqG7hgqg==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/@cspell/dict-markdown/-/dict-markdown-2.0.8.tgz", + "integrity": "sha512-GCzfae+PLw9MjdgOO0OB67zguNfhiLnaZX1glCNJ6G1ZWqfeC9eBOxrAR3BkFXoBY0cvDSjIP037QXFEfCgeTg==", "dev": true, "license": "MIT", "peerDependencies": { - "@cspell/dict-css": "^4.0.16", - "@cspell/dict-html": "^4.0.10", + "@cspell/dict-css": "^4.0.17", + "@cspell/dict-html": "^4.0.11", "@cspell/dict-html-symbol-entities": "^4.0.3", - "@cspell/dict-typescript": "^3.1.11" + "@cspell/dict-typescript": "^3.1.12" } }, "node_modules/@cspell/dict-monkeyc": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@cspell/dict-monkeyc/-/dict-monkeyc-1.0.9.tgz", - "integrity": "sha512-Jvf6g5xlB4+za3ThvenYKREXTEgzx5gMUSzrAxIiPleVG4hmRb/GBSoSjtkGaibN3XxGx5x809gSTYCA/IHCpA==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@cspell/dict-monkeyc/-/dict-monkeyc-1.0.10.tgz", + "integrity": "sha512-7RTGyKsTIIVqzbvOtAu6Z/lwwxjGRtY5RkKPlXKHEoEAgIXwfDxb5EkVwzGQwQr8hF/D3HrdYbRT8MFBfsueZw==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-node": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@cspell/dict-node/-/dict-node-5.0.5.tgz", - "integrity": "sha512-7NbCS2E8ZZRZwlLrh2sA0vAk9n1kcTUiRp/Nia8YvKaItGXLfxYqD2rMQ3HpB1kEutal6hQLVic3N2Yi1X7AaA==", + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/@cspell/dict-node/-/dict-node-5.0.6.tgz", + "integrity": "sha512-CEbhPCpxGvRNByGolSBTrXXW2rJA4bGqZuTx1KKO85mwR6aadeOmUE7xf/8jiCkXSy+qvr9aJeh+jlfXcsrziQ==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-npm": { - "version": "5.1.18", - "resolved": "https://registry.npmjs.org/@cspell/dict-npm/-/dict-npm-5.1.18.tgz", - "integrity": "sha512-/Nukl+DSxtEWSlb8svWFSpJVctAsM9SP+f5Q1n+qdDcXNKMb1bUCo/d3QZPwyOhuMjDawnsGBUAfp+iq7Mw83Q==", + "version": "5.1.22", + "resolved": "https://registry.npmjs.org/@cspell/dict-npm/-/dict-npm-5.1.22.tgz", + "integrity": "sha512-fZBTn8QHr8pAv1/I14CmdDWpVkovCfYpSYiGfV1SZkOjrsKLzPxsP84eaP3RijbFtYj3GMplVN27FR3H5oHfiw==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-php": { - "version": "4.0.13", - "resolved": "https://registry.npmjs.org/@cspell/dict-php/-/dict-php-4.0.13.tgz", - "integrity": "sha512-P6sREMZkhElzz/HhXAjahnICYIqB/HSGp1EhZh+Y6IhvC15AzgtDP8B8VYCIsQof6rPF1SQrFwunxOv8H1e2eg==", + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/@cspell/dict-php/-/dict-php-4.0.14.tgz", + "integrity": "sha512-7zur8pyncYZglxNmqsRycOZ6inpDoVd4yFfz1pQRe5xaRWMiK3Km4n0/X/1YMWhh3e3Sl/fQg5Axb2hlN68t1g==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-powershell": { - "version": "5.0.13", - "resolved": "https://registry.npmjs.org/@cspell/dict-powershell/-/dict-powershell-5.0.13.tgz", - "integrity": "sha512-0qdj0XZIPmb77nRTynKidRJKTU0Fl+10jyLbAhFTuBWKMypVY06EaYFnwhsgsws/7nNX8MTEQuewbl9bWFAbsg==", + "version": "5.0.14", + "resolved": "https://registry.npmjs.org/@cspell/dict-powershell/-/dict-powershell-5.0.14.tgz", + "integrity": "sha512-ktjjvtkIUIYmj/SoGBYbr3/+CsRGNXGpvVANrY0wlm/IoGlGywhoTUDYN0IsGwI2b8Vktx3DZmQkfb3Wo38jBA==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-public-licenses": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/@cspell/dict-public-licenses/-/dict-public-licenses-2.0.11.tgz", - "integrity": "sha512-rR5KjRUSnVKdfs5G+gJ4oIvQvm8+NJ6cHWY2N+GE69/FSGWDOPHxulCzeGnQU/c6WWZMSimG9o49i9r//lUQyA==", + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/@cspell/dict-public-licenses/-/dict-public-licenses-2.0.12.tgz", + "integrity": "sha512-obreJMVbz8ZrXyc60PcS/B2FwXaO3AWPO2x50zrI/n4UDuBr/UdPb6M1q++6c08n+151I35GEx52xRFiToSg4g==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-python": { - "version": "4.2.13", - "resolved": "https://registry.npmjs.org/@cspell/dict-python/-/dict-python-4.2.13.tgz", - "integrity": "sha512-mZIcmo9qif8LkJ6N/lqTZawcOk2kVTcuWIUOSbMcjyomO0XZ7iWz15TfONyr03Ea/l7o5ULV+MZ4vx76bAUb7w==", + "version": "4.2.14", + "resolved": "https://registry.npmjs.org/@cspell/dict-python/-/dict-python-4.2.14.tgz", + "integrity": "sha512-NZ/rsTH5gqTlEwbSg0vn5b1TsyzrUvA6ykwCVCwsVDdlQAS82cyDsF9JqHp8S4d6PFykmkfSxtAXYyOUr0KCbg==", "dev": true, "license": "MIT", "dependencies": { - "@cspell/dict-data-science": "^2.0.5" + "@cspell/dict-data-science": "^2.0.6" } }, "node_modules/@cspell/dict-r": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@cspell/dict-r/-/dict-r-2.0.4.tgz", - "integrity": "sha512-cBpRsE/U0d9BRhiNRMLMH1PpWgw+N+1A2jumgt1if9nBGmQw4MUpg2u9I0xlFVhstTIdzXiLXMxP45cABuiUeQ==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@cspell/dict-r/-/dict-r-2.0.5.tgz", + "integrity": "sha512-CpZvA/6Ps/vCaR5c+2tL1dGU7ZlIFMp+lUamamHGG1ZIc0+j+16Tb1+9oksEf7k8LCI/F5Io4uIJ+0NezaY8Rg==", "dev": true, "license": "MIT" }, @@ -2920,65 +2924,65 @@ "license": "MIT" }, "node_modules/@cspell/dict-rust": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/@cspell/dict-rust/-/dict-rust-4.0.10.tgz", - "integrity": "sha512-6o5C8566VGTTctgcwfF3Iy7314W0oMlFFSQOadQ0OEdJ9Z9ERX/PDimrzP3LGuOrvhtEFoK8pj+BLnunNwRNrw==", + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/@cspell/dict-rust/-/dict-rust-4.0.11.tgz", + "integrity": "sha512-OGWDEEzm8HlkSmtD8fV3pEcO2XBpzG2XYjgMCJCRwb2gRKvR+XIm6Dlhs04N/K2kU+iH8bvrqNpM8fS/BFl0uw==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-scala": { - "version": "5.0.6", - "resolved": "https://registry.npmjs.org/@cspell/dict-scala/-/dict-scala-5.0.6.tgz", - "integrity": "sha512-tl0YWAfjUVb4LyyE4JIMVE8DlLzb1ecHRmIWc4eT6nkyDqQgHKzdHsnusxFEFMVLIQomgSg0Zz6hJ5S1E4W4ww==", + "version": "5.0.7", + "resolved": "https://registry.npmjs.org/@cspell/dict-scala/-/dict-scala-5.0.7.tgz", + "integrity": "sha512-yatpSDW/GwulzO3t7hB5peoWwzo+Y3qTc0pO24Jf6f88jsEeKmDeKkfgPbYuCgbE4jisGR4vs4+jfQZDIYmXPA==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-software-terms": { - "version": "4.1.20", - "resolved": "https://registry.npmjs.org/@cspell/dict-software-terms/-/dict-software-terms-4.1.20.tgz", - "integrity": "sha512-ma51njqbk9ZKzZF9NpCZpZ+c50EwR5JTJ2LEXlX0tX+ExVbKpthhlDLhT2+mkUh5Zvj+CLf5F9z0qB4+X3re/w==", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@cspell/dict-software-terms/-/dict-software-terms-4.2.2.tgz", + "integrity": "sha512-cgteXRzx2W/Ug7QSdFJrVxLES7krrZEjZ9J6sXRWOsVYFpgu2Gup8NKmjKOZ8NTnCjHQFrMnbmKdv56q9Kwixw==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-sql": { - "version": "2.1.8", - "resolved": "https://registry.npmjs.org/@cspell/dict-sql/-/dict-sql-2.1.8.tgz", - "integrity": "sha512-dJRE4JV1qmXTbbGm6WIcg1knmR6K5RXnQxF4XHs5HA3LAjc/zf77F95i5LC+guOGppVF6Hdl66S2UyxT+SAF3A==", + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@cspell/dict-sql/-/dict-sql-2.1.9.tgz", + "integrity": "sha512-dyVtWGUs79SihmxzoXXOpA2mRipQhzZOy5mrRTZvMp3HE7Y5vM1ag/Di8+QCtjYD6l7MjVjp0CxkKp1U7PBpbw==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-svelte": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@cspell/dict-svelte/-/dict-svelte-1.0.5.tgz", - "integrity": "sha512-sseHlcXOqWE4Ner9sg8KsjxwSJ2yssoJNqFHR9liWVbDV+m7kBiUtn2EB690TihzVsEmDr/0Yxrbb5Bniz70mA==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@cspell/dict-svelte/-/dict-svelte-1.0.6.tgz", + "integrity": "sha512-8LAJHSBdwHCoKCSy72PXXzz7ulGROD0rP1CQ0StOqXOOlTUeSFaJJlxNYjlONgd2c62XBQiN2wgLhtPN+1Zv7Q==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-swift": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@cspell/dict-swift/-/dict-swift-2.0.4.tgz", - "integrity": "sha512-CsFF0IFAbRtYNg0yZcdaYbADF5F3DsM8C4wHnZefQy8YcHP/qjAF/GdGfBFBLx+XSthYuBlo2b2XQVdz3cJZBw==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@cspell/dict-swift/-/dict-swift-2.0.5.tgz", + "integrity": "sha512-3lGzDCwUmnrfckv3Q4eVSW3sK3cHqqHlPprFJZD4nAqt23ot7fic5ALR7J4joHpvDz36nHX34TgcbZNNZOC/JA==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-terraform": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/@cspell/dict-terraform/-/dict-terraform-1.0.6.tgz", - "integrity": "sha512-Sqm5vGbXuI9hCFcr4w6xWf4Y25J9SdleE/IqfM6RySPnk8lISEmVdax4k6+Kinv9qaxyvnIbUUN4WFLWcBPQAg==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@cspell/dict-terraform/-/dict-terraform-1.0.8.tgz", + "integrity": "sha512-YR2v2iDtuzEIwOWAlV9V8pdnrIQud6wHQOhuk3oqR3PS0rkAd6dkWrS0Ce2gbZY7AHHxQ2jvJ66pOjAdIDXbtA==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-typescript": { - "version": "3.1.11", - "resolved": "https://registry.npmjs.org/@cspell/dict-typescript/-/dict-typescript-3.1.11.tgz", - "integrity": "sha512-FwvK5sKbwrVpdw0e9+1lVTl8FPoHYvfHRuQRQz2Ql5XkC0gwPPkpoyD1zYImjIyZRoYXk3yp9j8ss4iz7A7zoQ==", + "version": "3.1.12", + "resolved": "https://registry.npmjs.org/@cspell/dict-typescript/-/dict-typescript-3.1.12.tgz", + "integrity": "sha512-gQxryTuRrRW3whM7gASetOTcPVsDGxfVn/MoSX507rcsFdZTnX18+M6D4iE0sUtranF1MWscGPIm6J2gfL3Zxw==", "dev": true, "license": "MIT" }, "node_modules/@cspell/dict-vue": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@cspell/dict-vue/-/dict-vue-3.0.3.tgz", - "integrity": "sha512-akmYbrgAGumqk1xXALtDJcEcOMYBYMnkjpmGzH13Ozhq1mkPF4VgllFQlm1xYde+BUKNnzMgPEzxrL2qZllgYA==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-vue/-/dict-vue-3.0.4.tgz", + "integrity": "sha512-0dPtI0lwHcAgSiQFx8CzvqjdoXROcH+1LyqgROCpBgppommWpVhbQ0eubnKotFEXgpUCONVkeZJ6Ql8NbTEu+w==", "dev": true, "license": "MIT" }, @@ -6886,9 +6890,9 @@ "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" }, "node_modules/@types/node": { - "version": "22.10.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.2.tgz", - "integrity": "sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==", + "version": "22.10.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.5.tgz", + "integrity": "sha512-F8Q+SeGimwOo86fiovQh8qiXfFEh2/ocYv7tU5pJ3EXMSSxk1Joj5wefpFK2fHTf/N6HKGSxIDBT9f3gCxXPkQ==", "license": "MIT", "dependencies": { "undici-types": "~6.20.0" @@ -8686,10 +8690,11 @@ } }, "node_modules/chalk": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", - "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", + "integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==", "dev": true, + "license": "MIT", "engines": { "node": "^12.17.0 || ^14.13 || >=16.0.0" }, @@ -9081,13 +9086,13 @@ } }, "node_modules/commitlint": { - "version": "19.6.0", - "resolved": "https://registry.npmjs.org/commitlint/-/commitlint-19.6.0.tgz", - "integrity": "sha512-0gOMRBSpnCw3Su0rfVeDqCe4ck/fkhGGC9UxVDeSyyCemFXs4U3BDuwMWvYcw4qsEAkPuDjQNoU8KWyPtHBq/w==", + "version": "19.6.1", + "resolved": "https://registry.npmjs.org/commitlint/-/commitlint-19.6.1.tgz", + "integrity": "sha512-tU4or+Y2fDXepCZ44o8guEB9uwrRp4if4VupGH1CR+bsVS2zX6Gia4dndA7UPx8cWWw1tvRRJu5keA7RqfXf3w==", "dev": true, "license": "MIT", "dependencies": { - "@commitlint/cli": "^19.6.0", + "@commitlint/cli": "^19.6.1", "@commitlint/types": "^19.5.0" }, "bin": { @@ -9358,6 +9363,7 @@ "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-9.0.0.tgz", "integrity": "sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==", "dev": true, + "license": "MIT", "dependencies": { "env-paths": "^2.2.1", "import-fresh": "^3.3.0", @@ -9380,20 +9386,21 @@ } }, "node_modules/cosmiconfig-typescript-loader": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/cosmiconfig-typescript-loader/-/cosmiconfig-typescript-loader-5.0.0.tgz", - "integrity": "sha512-+8cK7jRAReYkMwMiG+bxhcNKiHJDM6bR9FD/nGBXOWdMLuYawjF5cGrtLilJ+LGd3ZjCXnJjR5DkfWPoIVlqJA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/cosmiconfig-typescript-loader/-/cosmiconfig-typescript-loader-6.1.0.tgz", + "integrity": "sha512-tJ1w35ZRUiM5FeTzT7DtYWAFFv37ZLqSRkGi2oeCK1gPhvaWjkAtfXvLmvE1pRfxxp9aQo6ba/Pvg1dKj05D4g==", "dev": true, + "license": "MIT", "dependencies": { - "jiti": "^1.19.1" + "jiti": "^2.4.1" }, "engines": { - "node": ">=v16" + "node": ">=v18" }, "peerDependencies": { "@types/node": "*", - "cosmiconfig": ">=8.2", - "typescript": ">=4" + "cosmiconfig": ">=9", + "typescript": ">=5" } }, "node_modules/crc-32": { @@ -12219,9 +12226,9 @@ "dev": true }, "node_modules/fast-equals": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-5.0.1.tgz", - "integrity": "sha512-WF1Wi8PwwSY7/6Kx0vKXtw8RwuSGoM1bvDaJbu7MxDlR1vovZjIAKrnzyrThgAjm6JDTu0fVgWXDlMGspodfoQ==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-5.2.0.tgz", + "integrity": "sha512-3VpaQYf+CDFdRQfgsb+3vY7XaKjM35WCMoQTTE8h4S/eUkHzyJFOOA/gATYgoLejy4FBrEQD/sXe5Auk4cW/AQ==", "dev": true, "license": "MIT", "engines": { @@ -12974,6 +12981,7 @@ "resolved": "https://registry.npmjs.org/global-directory/-/global-directory-4.0.1.tgz", "integrity": "sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==", "dev": true, + "license": "MIT", "dependencies": { "ini": "4.1.1" }, @@ -13512,6 +13520,7 @@ "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.1.0.tgz", "integrity": "sha512-I6fiaX09Xivtk+THaMfAwnA3MVA5Big1WHF1Dfx9hFuvNIWpXnorlkzhcQf6ehrqQiiZECRt1poOAkPmer3ruw==", "dev": true, + "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/wooorm" @@ -13561,6 +13570,7 @@ "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.1.tgz", "integrity": "sha512-QQnnxNyfvmHFIsj7gkPcYymR8Jdw/o7mp5ZFihxn6h8Ci6fh3Dx4E1gPjpQEpIuPo9XVNY/ZUwh4BPMjGyL01g==", "dev": true, + "license": "ISC", "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } @@ -15942,12 +15952,13 @@ } }, "node_modules/jiti": { - "version": "1.21.6", - "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.6.tgz", - "integrity": "sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.2.tgz", + "integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==", "dev": true, + "license": "MIT", "bin": { - "jiti": "bin/jiti.js" + "jiti": "lib/jiti-cli.mjs" } }, "node_modules/jpeg-js": { @@ -16428,13 +16439,13 @@ "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==" }, "node_modules/lint-staged": { - "version": "15.2.11", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-15.2.11.tgz", - "integrity": "sha512-Ev6ivCTYRTGs9ychvpVw35m/bcNDuBN+mnTeObCL5h+boS5WzBEC6LHI4I9F/++sZm1m+J2LEiy0gxL/R9TBqQ==", + "version": "15.3.0", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-15.3.0.tgz", + "integrity": "sha512-vHFahytLoF2enJklgtOtCtIjZrKD/LoxlaUusd5nh7dWv/dkKQJY74ndFSzxCdv7g0ueGg1ORgTSt4Y9LPZn9A==", "dev": true, "license": "MIT", "dependencies": { - "chalk": "~5.3.0", + "chalk": "~5.4.1", "commander": "~12.1.0", "debug": "~4.4.0", "execa": "~8.0.1", @@ -16723,6 +16734,19 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/lint-staged/node_modules/yaml": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz", + "integrity": "sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/listr2": { "version": "3.14.0", "resolved": "https://registry.npmjs.org/listr2/-/listr2-3.14.0.tgz", @@ -16849,7 +16873,8 @@ "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz", "integrity": "sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/lodash.once": { "version": "4.1.1", @@ -16884,7 +16909,8 @@ "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", "integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/lodash.upperfirst": { "version": "4.3.1", @@ -21344,21 +21370,21 @@ } }, "node_modules/tldts": { - "version": "6.1.69", - "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.69.tgz", - "integrity": "sha512-Oh/CqRQ1NXNY7cy9NkTPUauOWiTro0jEYZTioGbOmcQh6EC45oribyIMJp0OJO3677r13tO6SKdWoGZUx2BDFw==", + "version": "6.1.71", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.71.tgz", + "integrity": "sha512-LQIHmHnuzfZgZWAf2HzL83TIIrD8NhhI0DVxqo9/FdOd4ilec+NTNZOlDZf7EwrTNoutccbsHjvWHYXLAtvxjw==", "license": "MIT", "dependencies": { - "tldts-core": "^6.1.69" + "tldts-core": "^6.1.71" }, "bin": { "tldts": "bin/cli.js" } }, "node_modules/tldts-core": { - "version": "6.1.69", - "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.69.tgz", - "integrity": "sha512-nygxy9n2PBUFQUtAXAc122gGo+04/j5qr5TGQFZTHafTKYvmARVXt2cA5rgero2/dnXUfkdPtiJoKmrd3T+wdA==", + "version": "6.1.71", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.71.tgz", + "integrity": "sha512-LRbChn2YRpic1KxY+ldL1pGXN/oVvKfCVufwfVzEQdFYNo39uF7AJa/WXdo+gYO7PTvdfkCPCed6Hkvz/kR7jg==", "license": "MIT" }, "node_modules/tmp": { @@ -22355,9 +22381,9 @@ "dev": true }, "node_modules/yaml": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz", - "integrity": "sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.0.tgz", + "integrity": "sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==", "dev": true, "license": "ISC", "bin": { diff --git a/src/api/.keystone/config.js b/src/api/.keystone/config.js index 468d6376a8..456a719fb0 100644 --- a/src/api/.keystone/config.js +++ b/src/api/.keystone/config.js @@ -578,7 +578,6 @@ var DEFAULT_RESOLVERS = [ 'updateAccount', // misc 'countries', - 'page', ]; var CUSTOM_RESOLVERS = [ // account @@ -606,8 +605,10 @@ var CUSTOM_RESOLVERS = [ 'submitApplication', // feedback 'createFeedbackAndSendEmail', + // countries and currencies 'getApimCisCountries', 'getApimCurrencies', + 'getCountriesAndCurrencies', ]; if (isDevEnvironment) { CUSTOM_RESOLVERS.push( @@ -651,6 +652,9 @@ var VERSION_3 = { ...VERSION_2, VERSION_NUMBER: '3', REQUESTED_CREDIT_LIMIT_REQUIRED: true, + SMALL_EXPORT_BUILDER: { + MAXIMUM_BUYER_WILL_OWE: 25e3, + }, }; var VERSIONS = [VERSION_1, VERSION_2, VERSION_3]; var versions_default = VERSIONS; @@ -869,6 +873,7 @@ var EXTERNAL_API_MAPPINGS = { var EXTERNAL_API_ENDPOINTS = { APIM_MDM: { CURRENCY: '/currencies', + CURRENCY_EXCHANGE: '/currencies/exchange', INDUSTRY_SECTORS: '/sector-industries', MARKETS: '/markets', }, @@ -1093,7 +1098,12 @@ var EMAIL_TEMPLATE_IDS = { APPLICATION: { SUBMISSION: { EXPORTER: { - CONFIRMATION: '2e9084e2-d871-4be7-85d0-0ccc1961b148', + CONFIRMATION: { + SINGLE_OR_MULTIPLE_CONTRACT_POLICY: '2e9084e2-d871-4be7-85d0-0ccc1961b148', + MULTIPLE_CONTRACT_POLICY: { + ELIGIBLE_FOR_SMALL_EXPORT_BUILDER_CONFIRMATION: '7ee4729d-53ba4729-af50-f733870914de', + }, + }, SEND_DOCUMENTS: { TRADING_HISTORY: '1ae4d77e-58d6-460e-99c0-b62bf08d8c52', ANTI_BRIBERY: '002e43e3-ca78-4b9c-932f-6833014bb1e4', @@ -1112,6 +1122,7 @@ var EMAIL_TEMPLATE_IDS = { FEEDBACK: { INSURANCE: '4d3d7944-e894-4527-aee6-692038c84107', }, + UNABLE_TO_DETERMINE_TEMPLATE_ID: 'UNABLE_TO_DETERMINE_TEMPLATE_ID', }; var FEEDBACK = { VERY_SATISFIED: 'verySatisfied', @@ -1227,7 +1238,7 @@ var updateInactiveApplicationsJob = { var inactive_application_cron_job_default = updateInactiveApplicationsJob; // cron/application/email-submission-deadline-reminder-cron-job.ts -var import_dotenv8 = __toESM(require('dotenv')); +var import_dotenv9 = __toESM(require('dotenv')); // helpers/get-start-and-end-time-of-date/index.ts var { @@ -1310,7 +1321,7 @@ var mapApplicationSubmissionDeadlineVariables = (application2) => { var map_application_submission_deadline_variables_default = mapApplicationSubmissionDeadlineVariables; // emails/index.ts -var import_dotenv7 = __toESM(require('dotenv')); +var import_dotenv8 = __toESM(require('dotenv')); // integrations/notify/index.ts var import_dotenv5 = __toESM(require('dotenv')); @@ -1426,6 +1437,205 @@ var reactivateAccountLink = async (urlOrigin, emailAddress, name, reactivationHa } }; +// helpers/policy-type/index.ts +var isSinglePolicyType = (policyType) => policyType === FIELD_VALUES.POLICY_TYPE.SINGLE; +var isMultiplePolicyType = (policyType) => policyType === FIELD_VALUES.POLICY_TYPE.MULTIPLE; + +// integrations/APIM/index.ts +var import_axios = __toESM(require('axios')); +var import_dotenv6 = __toESM(require('dotenv')); +import_dotenv6.default.config(); +var { APIM_MDM_URL, APIM_MDM_KEY, APIM_MDM_VALUE } = process.env; +var { APIM_MDM } = EXTERNAL_API_ENDPOINTS; +var APIM = { + getCisCountries: async () => { + try { + console.info('Calling APIM - CIS countries'); + const response = await (0, import_axios.default)({ + method: 'get', + url: `${APIM_MDM_URL}${APIM_MDM.MARKETS}`, + headers: { + 'Content-Type': 'application/json', + [String(APIM_MDM_KEY)]: APIM_MDM_VALUE, + }, + validateStatus(status) { + const acceptableStatus = [200]; + return acceptableStatus.includes(status); + }, + }); + if (response.data && response.status === 200) { + return { + success: true, + data: response.data, + }; + } + return { + success: false, + }; + } catch (error) { + console.error('Error calling APIM - CIS countries %o', error); + throw new Error(`Calling APIM - CIS countries ${error}`); + } + }, + getCurrencies: async () => { + try { + console.info('Calling APIM - currencies'); + const response = await (0, import_axios.default)({ + method: 'get', + url: `${APIM_MDM_URL}${APIM_MDM.CURRENCY}`, + headers: { + 'Content-Type': 'application/json', + [String(APIM_MDM_KEY)]: APIM_MDM_VALUE, + }, + validateStatus(status) { + const acceptableStatus = [200]; + return acceptableStatus.includes(status); + }, + }); + if (response.data && response.status === 200) { + return { + success: true, + data: response.data, + }; + } + return { + success: false, + }; + } catch (error) { + console.error('Error calling APIM - currencies %o', error); + throw new Error(`Calling APIM - currencies ${error}`); + } + }, + getCurrenciesExchange: async (source, target) => { + try { + console.info('Calling APIM - currencies exchange'); + const response = await (0, import_axios.default)({ + method: 'get', + url: `${APIM_MDM_URL}${APIM_MDM.CURRENCY_EXCHANGE}`, + headers: { + 'Content-Type': 'application/json', + [String(APIM_MDM_KEY)]: APIM_MDM_VALUE, + }, + params: { source, target }, + validateStatus(status) { + const acceptableStatus = [200]; + return acceptableStatus.includes(status); + }, + }); + if (response.data && response.status === 200) { + return { + success: true, + data: response.data, + }; + } + return { + success: false, + }; + } catch (error) { + console.error('Error calling APIM - currencies exchange %o', error); + throw new Error(`Calling APIM - currencies exchange ${error}`); + } + }, +}; +var APIM_default = APIM; + +// helpers/get-APIM-currencies-exchange-rate/index.ts +var get = async (source, target) => { + try { + console.info('Getting currency exchange rate from APIM - %s to %s (getApimCurrencyExchangeRate helper)', source, target); + const response = await APIM_default.getCurrenciesExchange(source, target); + if (response.success && response.data) { + const [currency] = response.data; + const { midPrice: exchangeRate } = currency; + if (source !== GBP) { + const fixed = Number(1 / exchangeRate).toFixed(2); + return Number(fixed); + } + return exchangeRate; + } + return 0; + } catch (error) { + console.error('Error Getting currency exchange rate from APIM - %s to %s (getApimCurrencyExchangeRate helper) %o', source, target, error); + throw new Error(`Getting currency exchange rate from APIM - %s to %s (getApimCurrencyExchangeRate helper) ${error}`); + } +}; +var apimCurrencyExchangeRate = { + get, +}; +var get_APIM_currencies_exchange_rate_default = apimCurrencyExchangeRate; + +// helpers/round-number/index.ts +var roundNumber = (number) => Math.round(number); +var round_number_default = roundNumber; + +// emails/application/get-submitted-confirmation-template-id/multiple-policy-type/index.ts +var { + LATEST_VERSION: { SMALL_EXPORT_BUILDER }, +} = APPLICATION; +var { + APPLICATION: { + SUBMISSION: { + EXPORTER: { CONFIRMATION }, + }, + }, + UNABLE_TO_DETERMINE_TEMPLATE_ID, +} = EMAIL_TEMPLATE_IDS; +var get2 = async (policyType, policyCurrencyCode, maximumBuyerWillOwe) => { + try { + console.info('Getting submitted confirmation template ID for a multiple policy type (multiplePolicyTypeTemplateId helper)'); + if (isMultiplePolicyType(policyType)) { + let maximumBuyerWillOweInGbp = maximumBuyerWillOwe; + if (policyCurrencyCode !== GBP) { + const source = GBP; + const target = String(policyCurrencyCode); + const exchangeRate = await get_APIM_currencies_exchange_rate_default.get(source, target); + maximumBuyerWillOweInGbp = round_number_default(maximumBuyerWillOwe / exchangeRate); + } + const threshold = Number(SMALL_EXPORT_BUILDER?.MAXIMUM_BUYER_WILL_OWE); + const eligibileForSmallExportBuilder = maximumBuyerWillOweInGbp <= threshold; + if (eligibileForSmallExportBuilder) { + return CONFIRMATION.MULTIPLE_CONTRACT_POLICY.ELIGIBLE_FOR_SMALL_EXPORT_BUILDER_CONFIRMATION; + } + return CONFIRMATION.SINGLE_OR_MULTIPLE_CONTRACT_POLICY; + } + return UNABLE_TO_DETERMINE_TEMPLATE_ID; + } catch (error) { + console.error('Error Getting submitted confirmation template ID for a multiple policy type (multiplePolicyTypeTemplateId helper) %o', error); + throw new Error(`Getting submitted confirmation template ID for a multiple policy type (multiplePolicyTypeTemplateId helper) ${error}`); + } +}; +var multiplePolicyTypeTemplateId = { + get: get2, +}; +var multiple_policy_type_default = multiplePolicyTypeTemplateId; + +// emails/application/get-submitted-confirmation-template-id/index.ts +var { + APPLICATION: { + SUBMISSION: { + EXPORTER: { CONFIRMATION: CONFIRMATION2 }, + }, + }, + UNABLE_TO_DETERMINE_TEMPLATE_ID: UNABLE_TO_DETERMINE_TEMPLATE_ID2, +} = EMAIL_TEMPLATE_IDS; +var getSubmittedConfirmationTemplateId = async (policy) => { + try { + console.info('Getting submitted confirmation template ID (getSubmittedConfirmationTemplateId helper)'); + const { maximumBuyerWillOwe, policyCurrencyCode, policyType } = policy; + if (isSinglePolicyType(policyType)) { + return CONFIRMATION2.SINGLE_OR_MULTIPLE_CONTRACT_POLICY; + } + if (isMultiplePolicyType(policyType) && maximumBuyerWillOwe) { + return await multiple_policy_type_default.get(policyType, String(policyCurrencyCode), maximumBuyerWillOwe); + } + return UNABLE_TO_DETERMINE_TEMPLATE_ID2; + } catch (error) { + console.error('Error Getting submitted confirmation template ID (getSubmittedConfirmationTemplateId helper) %o', error); + throw new Error(`Getting submitted confirmation template ID (getSubmittedConfirmationTemplateId helper) ${error}`); + } +}; +var get_submitted_confirmation_template_id_default = getSubmittedConfirmationTemplateId; + // file-system/index.ts var import_fs = require('fs'); var import_path = __toESM(require('path')); @@ -1483,12 +1693,13 @@ var application = { * application.submittedEmail * Send "application submitted" email to an account * @param {ApplicationSubmissionEmailVariables} ApplicationSubmissionEmailVariables + * @param {ApplicationPolicy} policy: Application policy * @returns {Promise} callNotify response */ - submittedEmail: async (variables) => { + submittedEmail: async (variables, policy) => { try { console.info('Sending application submitted email to application owner or provided business contact'); - const templateId = EMAIL_TEMPLATE_IDS.APPLICATION.SUBMISSION.EXPORTER.CONFIRMATION; + const templateId = await get_submitted_confirmation_template_id_default(policy); const { emailAddress } = variables; const response = await callNotify(templateId, emailAddress, variables); return response; @@ -1539,14 +1750,14 @@ var documentsEmail = async (variables, templateId) => { }; // emails/insurance-feedback-email/index.ts -var import_dotenv6 = __toESM(require('dotenv')); +var import_dotenv7 = __toESM(require('dotenv')); // helpers/map-feedback-satisfaction/index.ts var mapFeedbackSatisfaction = (satisfaction) => FEEDBACK.EMAIL_TEXT[satisfaction]; var map_feedback_satisfaction_default = mapFeedbackSatisfaction; // emails/insurance-feedback-email/index.ts -import_dotenv6.default.config(); +import_dotenv7.default.config(); var insuranceFeedbackEmail = async (variables) => { try { console.info('Sending insurance feedback email'); @@ -1584,7 +1795,7 @@ var submissionDeadlineEmail = async (emailAddress, submissionDeadlineEmailVariab }; // emails/index.ts -import_dotenv7.default.config(); +import_dotenv8.default.config(); var sendEmail = { confirmEmailAddress, accessCodeEmail, @@ -1645,7 +1856,7 @@ var applicationSubmissionDeadlineEmail = async (context) => { var send_email_application_submission_deadline_default = applicationSubmissionDeadlineEmail; // cron/application/email-submission-deadline-reminder-cron-job.ts -import_dotenv8.default.config(); +import_dotenv9.default.config(); var { CRON_SCHEDULE_SUBMISSION_DEADLINE_REMINDER_EMAIL } = process.env; var sendEmailApplicationSubmissionDeadlineJob = { cronExpression: String(CRON_SCHEDULE_SUBMISSION_DEADLINE_REMINDER_EMAIL), @@ -2809,11 +3020,16 @@ var typeDefs = ` referenceNumber: Int } + type Country { + isoCode: String! + name: String! + } + type MappedCisCountry { isoCode: String! name: String shortTermCover: Boolean - riskCategory: String + esraClassification: String nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean canGetAQuoteOffline: Boolean @@ -2835,6 +3051,13 @@ var typeDefs = ` allCurrencies: [MappedCurrency] } + type GetCountriesAndCurrenciesResponse { + countries: [Country] + supportedCurrencies: [MappedCurrency] + alternativeCurrencies: [MappedCurrency] + allCurrencies: [MappedCurrency] + } + type Owner { id: String firstName: String @@ -3047,9 +3270,6 @@ var typeDefs = ` token: String! ): AccountPasswordResetTokenResponse - """ get CIS countries from APIM """ - getApimCisCountries: [MappedCisCountry] - """ get companies house information """ getCompaniesHouseInformation( companiesHouseNumber: String! @@ -3073,6 +3293,9 @@ var typeDefs = ` """ get currencies from APIM """ getApimCurrencies: GetApimCurrencyResponse + + """ get countries and currencies """ + getCountriesAndCurrencies: GetCountriesAndCurrenciesResponse } `; var type_defs_default = typeDefs; @@ -4064,7 +4287,7 @@ var sendEmailPasswordResetLink = async (root, variables, context) => { }; } } catch (error) { - console.error('Error blocking account $O', error); + console.error('Error blocking account %o', error); return { success: false }; } } @@ -4084,7 +4307,7 @@ var sendEmailPasswordResetLink = async (root, variables, context) => { } return { success: false }; } catch (error) { - console.error('Error checking account and sending password reset email (sendEmailPasswordResetLink mutation) $O', error); + console.error('Error checking account and sending password reset email (sendEmailPasswordResetLink mutation) %o', error); throw new Error(`Checking account and sending password reset email (sendEmailPasswordResetLink mutation) ${error}`); } }; @@ -6115,34 +6338,33 @@ var get_application_submitted_email_template_ids_default = getApplicationSubmitt var send4 = async (application2, xlsxPath) => { try { const { referenceNumber, owner, company, buyer, policy, policyContact } = application2; + const { requestedStartDate } = policy; const { email } = owner; const sharedEmailVars = { referenceNumber, buyerName: replace_character_codes_with_characters_default(String(buyer.companyOrOrganisationName)), buyerLocation: buyer.country?.name, companyName: replace_character_codes_with_characters_default(company.companyName), - requestedStartDate: format_date_default(policy.requestedStartDate), + requestedStartDate: format_date_default(requestedStartDate), }; const sendOwnerEmailVars = { ...sharedEmailVars, - buyerName: replace_character_codes_with_characters_default(String(buyer.companyOrOrganisationName)), name: replace_character_codes_with_characters_default(get_full_name_string_default(owner)), emailAddress: email, }; const sendContactEmailVars = { ...sharedEmailVars, - buyerName: replace_character_codes_with_characters_default(String(buyer.companyOrOrganisationName)), name: replace_character_codes_with_characters_default(get_full_name_string_default(policyContact)), emailAddress: policyContact.email, }; console.info('Sending application submitted email to application account owner: %s', sendOwnerEmailVars.emailAddress); - const accountSubmittedResponse = await emails_default.application.submittedEmail(sendOwnerEmailVars); + const accountSubmittedResponse = await emails_default.application.submittedEmail(sendOwnerEmailVars, policy); if (!accountSubmittedResponse?.success) { throw new Error('Sending application submitted email to owner/account'); } if (!policyContact.isSameAsOwner) { console.info('Sending application submitted email to policy contact email: %s', sendContactEmailVars.emailAddress); - const contactSubmittedResponse = await emails_default.application.submittedEmail(sendContactEmailVars); + const contactSubmittedResponse = await emails_default.application.submittedEmail(sendContactEmailVars, policy); if (!contactSubmittedResponse?.success) { throw new Error('Sending application submitted email to contact'); } @@ -6180,7 +6402,7 @@ var applicationSubmittedEmails = { var send_application_submitted_emails_default = applicationSubmittedEmails; // generate-xlsx/index.ts -var import_dotenv9 = __toESM(require('dotenv')); +var import_dotenv10 = __toESM(require('dotenv')); var import_exceljs = __toESM(require('exceljs')); // constants/XLSX-CONFIG/SECTION_NAMES/index.ts @@ -6254,6 +6476,7 @@ var LINKS = { BRIBERY_ACT_2010_GUIDANCE: 'https://www.justice.gov.uk/downloads/legislation/bribery-act-2010-guidance.pdf', ICO_MAKE_A_COMPLAINT: 'https://ico.org.uk/make-a-complaint', COMPANIES_HOUSE: 'https://find-and-update.company-information.service.gov.uk', + SMALL_EXPORT_BUILDER: 'Small Export Builder', }, }; @@ -6279,7 +6502,7 @@ var { HAS_COMPANIES_HOUSE_NUMBER, } = insurance_default.ELIGIBILITY; var { COMPANY_NAME } = insurance_default.COMPANIES_HOUSE; -var THRESHOLD = format_currency_default(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE, 0); +var THRESHOLD = format_currency_default(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE); var ELIGIBILITY_FIELDS = { [BUYER_COUNTRY]: { SUMMARY: { @@ -6505,9 +6728,12 @@ var { } = insurance_default; var { MAX_COVER_PERIOD_MONTHS } = ELIGIBILITY; var { + LATEST_VERSION: { SMALL_EXPORT_BUILDER: SMALL_EXPORT_BUILDER2 }, POLICY: { TOTAL_MONTHS_OF_COVER }, } = APPLICATION; var { POLICY: POLICY_FORM_TITLES } = FORM_TITLES; +var maxBuyerWillOweThreshold = Number(SMALL_EXPORT_BUILDER2?.MAXIMUM_BUYER_WILL_OWE); +var SMALL_EXPORT_BUILDER_THRESHOLD = format_currency_default(maxBuyerWillOweThreshold, GBP_CURRENCY_CODE); var POLICY_FIELDS = { [POLICY_TYPE3]: { ID: POLICY_TYPE3, @@ -6615,6 +6841,13 @@ var POLICY_FIELDS = { LABEL: 'Estimate the maximum amount your buyer will owe you at any single point during this time', HINT: { FOR_EXAMPLE: 'For example, your total sales might be \xA3250,000 but the maximum the buyer will owe you at any single point is \xA3100,000.', + INITIAL_CREDIT_LIMIT: { + INTRO: `If your initial credit limit request is ${SMALL_EXPORT_BUILDER_THRESHOLD} or less you could be eligible for the`, + LINK: { + TEXT: 'Small Export Builder.', + HREF: LINKS.EXTERNAL.SMALL_EXPORT_BUILDER, + }, + }, NO_DECIMALS: 'Enter a whole number. Do not enter decimals.', }, SUMMARY: { @@ -7435,10 +7668,6 @@ var mapKeyInformation = (application2) => { }; var map_key_information_default = mapKeyInformation; -// helpers/policy-type/index.ts -var isSinglePolicyType = (policyType) => policyType === FIELD_VALUES.POLICY_TYPE.SINGLE; -var isMultiplePolicyType = (policyType) => policyType === FIELD_VALUES.POLICY_TYPE.MULTIPLE; - // generate-xlsx/map-application-to-XLSX/map-policy/map-intro/map-policy-type/index.ts var { POLICY_TYPE: { ABBREVIATED }, @@ -8427,54 +8656,82 @@ var XLSX_ROW_INDEXES = { }; var INDEXES_default = XLSX_ROW_INDEXES; -// generate-xlsx/styled-columns/index.ts -var { LARGE_ADDITIONAL_COLUMN_HEIGHT, ADDITIONAL_TITLE_COLUMN_HEIGHT, FONT_SIZE } = XLSX_CONFIG; -var { APPLICATION_INFORMATION: APPLICATION_INFORMATION2 } = SECTION_NAMES_default; -var worksheetRowHeights = (rowIndexes, worksheet, sheetName) => { - const modifiedWorksheet = worksheet; - modifiedWorksheet.getRow(1).height = ADDITIONAL_TITLE_COLUMN_HEIGHT; - const isInformationSheet = sheetName === APPLICATION_INFORMATION2; - if (isInformationSheet) { - modifiedWorksheet.getRow(8).height = ADDITIONAL_TITLE_COLUMN_HEIGHT; - modifiedWorksheet.getRow(13).height = ADDITIONAL_TITLE_COLUMN_HEIGHT; - } - rowIndexes.forEach((rowIndex) => { - modifiedWorksheet.getRow(rowIndex).height = LARGE_ADDITIONAL_COLUMN_HEIGHT; - }); - return modifiedWorksheet; +// constants/XLSX-CONFIG/INDEXES/APPLICATION_INFORMATION/index.ts +var APPLICATION_INFORMATION_INDEXES = { + EXPORTER_CONTACT_DETAILS: 8, + KEY_INFORMATION: 13, }; -var styledColumns = (application2, worksheet, sheetName) => { - let modifiedWorksheet = worksheet; - modifiedWorksheet.eachRow((row, rowNumber) => { +var APPLICATION_INFORMATION_default = APPLICATION_INFORMATION_INDEXES; + +// generate-xlsx/styled-columns/is-title-row/index.ts +var { APPLICATION_INFORMATION: APPLICATION_INFORMATION2 } = SECTION_NAMES_default; +var { EXPORTER_CONTACT_DETAILS, KEY_INFORMATION } = APPLICATION_INFORMATION_default; +var isTitleRow = (sheetName, rowNumber) => { + const isInfoSheet = sheetName === APPLICATION_INFORMATION2; + const isInfoTitle = isInfoSheet && (rowNumber === EXPORTER_CONTACT_DETAILS || rowNumber === KEY_INFORMATION); + const result = rowNumber === 1 || isInfoTitle; + return result; +}; +var is_title_row_default = isTitleRow; + +// generate-xlsx/styled-columns/modify-row-styles/index.ts +var { FONT_SIZE } = XLSX_CONFIG; +var modifyRowStyles = (worksheet, sheetName) => { + worksheet.eachRow((row, rowNumber) => { row.eachCell((cell, colNumber) => { const modifiedRow = row; modifiedRow.getCell(colNumber).alignment = { vertical: 'top', wrapText: true, }; - const isInformationSheet = sheetName === APPLICATION_INFORMATION2; - const isInformationTitleOne = isInformationSheet && rowNumber === 8; - const isInformationTitleTwo = isInformationSheet && rowNumber === 13; - const isInformationTitle = isInformationTitleOne || isInformationTitleTwo; - const isTitleRow = rowNumber === 1 || isInformationTitle; + const isATitleRow = is_title_row_default(sheetName, rowNumber); modifiedRow.getCell(colNumber).font = { - bold: Boolean(isTitleRow), - size: isTitleRow ? FONT_SIZE.TITLE : FONT_SIZE.DEFAULT, + bold: isATitleRow, + size: isATitleRow ? FONT_SIZE.TITLE : FONT_SIZE.DEFAULT, }; }); }); + return worksheet; +}; +var modify_row_styles_default = modifyRowStyles; + +// generate-xlsx/styled-columns/modify-row-heights/index.ts +var { LARGE_ADDITIONAL_COLUMN_HEIGHT, ADDITIONAL_TITLE_COLUMN_HEIGHT } = XLSX_CONFIG; +var { APPLICATION_INFORMATION: APPLICATION_INFORMATION3 } = SECTION_NAMES_default; +var { EXPORTER_CONTACT_DETAILS: EXPORTER_CONTACT_DETAILS2, KEY_INFORMATION: KEY_INFORMATION2 } = APPLICATION_INFORMATION_default; +var modifyRowHeights = (rowIndexes, worksheet, sheetName) => { + const modifiedWorksheet = worksheet; + modifiedWorksheet.getRow(1).height = ADDITIONAL_TITLE_COLUMN_HEIGHT; + if (sheetName === APPLICATION_INFORMATION3) { + modifiedWorksheet.getRow(EXPORTER_CONTACT_DETAILS2).height = ADDITIONAL_TITLE_COLUMN_HEIGHT; + modifiedWorksheet.getRow(KEY_INFORMATION2).height = ADDITIONAL_TITLE_COLUMN_HEIGHT; + } + rowIndexes.forEach((rowIndex) => { + modifiedWorksheet.getRow(rowIndex).height = LARGE_ADDITIONAL_COLUMN_HEIGHT; + }); + return modifiedWorksheet; +}; +var modify_row_heights_default = modifyRowHeights; + +// generate-xlsx/styled-columns/index.ts +var getAdditionalRowHeightIndexes = (application2, sheetName) => { let INDEXES = []; if (INDEXES_default[sheetName]) { const sheetIndexes = INDEXES_default[sheetName](application2); INDEXES = Object.values(sheetIndexes); } - modifiedWorksheet = worksheetRowHeights(INDEXES, modifiedWorksheet, sheetName); - return modifiedWorksheet; + return INDEXES; +}; +var styledColumns = (application2, worksheet, sheetName) => { + const withRowStyles = modify_row_styles_default(worksheet, sheetName); + const indexes = getAdditionalRowHeightIndexes(application2, sheetName); + const withRowHeights = modify_row_heights_default(indexes, withRowStyles, sheetName); + return withRowHeights; }; var styled_columns_default = styledColumns; // generate-xlsx/index.ts -import_dotenv9.default.config(); +import_dotenv10.default.config(); var { EXCELJS_PROTECTION_PASSWORD } = process.env; var XLSX2 = (application2, countries) => { try { @@ -8887,74 +9144,6 @@ var getAccountPasswordResetToken = async (root, variables, context) => { }; var get_account_password_reset_token_default = getAccountPasswordResetToken; -// integrations/APIM/index.ts -var import_axios = __toESM(require('axios')); -var import_dotenv10 = __toESM(require('dotenv')); -import_dotenv10.default.config(); -var { APIM_MDM_URL, APIM_MDM_KEY, APIM_MDM_VALUE } = process.env; -var { APIM_MDM } = EXTERNAL_API_ENDPOINTS; -var APIM = { - getCisCountries: async () => { - try { - console.info('Calling APIM - CIS countries'); - const response = await (0, import_axios.default)({ - method: 'get', - url: `${APIM_MDM_URL}${APIM_MDM.MARKETS}`, - headers: { - 'Content-Type': 'application/json', - [String(APIM_MDM_KEY)]: APIM_MDM_VALUE, - }, - validateStatus(status) { - const acceptableStatus = [200]; - return acceptableStatus.includes(status); - }, - }); - if (response.data && response.status === 200) { - return { - success: true, - data: response.data, - }; - } - return { - success: false, - }; - } catch (error) { - console.error('Error calling APIM - CIS countries %o', error); - throw new Error(`Calling APIM - CIS countries ${error}`); - } - }, - getCurrencies: async () => { - try { - console.info('Calling APIM - currencies'); - const response = await (0, import_axios.default)({ - method: 'get', - url: `${APIM_MDM_URL}${APIM_MDM.CURRENCY}`, - headers: { - 'Content-Type': 'application/json', - [String(APIM_MDM_KEY)]: APIM_MDM_VALUE, - }, - validateStatus(status) { - const acceptableStatus = [200]; - return acceptableStatus.includes(status); - }, - }); - if (response.data && response.status === 200) { - return { - success: true, - data: response.data, - }; - } - return { - success: false, - }; - } catch (error) { - console.error('Error calling APIM - currencies %o', error); - throw new Error(`Calling APIM - currencies ${error}`); - } - }, -}; -var APIM_default = APIM; - // helpers/filter-cis-entries/index.ts var filterCisEntries = (arr, invalidEntries, entityPropertyName) => { const filtered = arr.filter((obj) => !invalidEntries.includes(obj[entityPropertyName])); @@ -8962,9 +9151,9 @@ var filterCisEntries = (arr, invalidEntries, entityPropertyName) => { }; var filter_cis_entries_default = filterCisEntries; -// helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.ts +// helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.ts var { CIS } = EXTERNAL_API_DEFINITIONS; -var mapRiskCategory = (str) => { +var mapEsraClassification = (str) => { if (str === CIS.RISK.STANDARD) { return EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; } @@ -8976,7 +9165,17 @@ var mapRiskCategory = (str) => { } return null; }; -var map_risk_category_default = mapRiskCategory; +var map_esra_classification_default = mapEsraClassification; + +// helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.ts +var { CIS: CIS2 } = EXTERNAL_API_DEFINITIONS; +var mapNbiIssueAvailable = (str) => { + if (str === CIS2.NBI_ISSUE_AVAILABLE.YES) { + return true; + } + return false; +}; +var map_NBI_issue_available_default = mapNbiIssueAvailable; // helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts var { @@ -8998,19 +9197,9 @@ var mapShortTermCoverAvailable = (str) => { }; var map_short_term_cover_available_default = mapShortTermCoverAvailable; -// helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.ts -var { CIS: CIS2 } = EXTERNAL_API_DEFINITIONS; -var mapNbiIssueAvailable = (str) => { - if (str === CIS2.NBI_ISSUE_AVAILABLE.YES) { - return true; - } - return false; -}; -var map_NBI_issue_available_default = mapNbiIssueAvailable; - // helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts -var canGetAQuoteOnline = (country) => { - if (country.riskCategory && country.shortTermCover && country.nbiIssueAvailable) { +var canGetAQuoteOnline = ({ shortTermCover, nbiIssueAvailable, esraClassification }) => { + if (esraClassification && shortTermCover && nbiIssueAvailable) { return true; } return false; @@ -9018,8 +9207,8 @@ var canGetAQuoteOnline = (country) => { var can_get_a_quote_online_default = canGetAQuoteOnline; // helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts -var canGetAQuoteByEmail = (country) => { - if (country.riskCategory && country.shortTermCover && !country.nbiIssueAvailable) { +var canGetAQuoteByEmail = ({ shortTermCover, nbiIssueAvailable, esraClassification }) => { + if (shortTermCover && !nbiIssueAvailable && esraClassification) { return true; } return false; @@ -9027,8 +9216,8 @@ var canGetAQuoteByEmail = (country) => { var can_get_a_quote_by_email_default = canGetAQuoteByEmail; // helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts -var cannotGetAQuote = (country) => { - if (!country.riskCategory || (!country.shortTermCover && !country.nbiIssueAvailable)) { +var cannotGetAQuote = ({ shortTermCover, nbiIssueAvailable, esraClassification }) => { + if (!esraClassification || (!shortTermCover && !nbiIssueAvailable)) { return true; } return false; @@ -9036,8 +9225,8 @@ var cannotGetAQuote = (country) => { var cannot_get_a_quote_default = cannotGetAQuote; // helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts -var canApplyForInsuranceOnline = (shortTermCover, riskCategory) => { - if (riskCategory && shortTermCover) { +var canApplyForInsuranceOnline = (shortTermCover, esraClassification) => { + if (shortTermCover && esraClassification) { return true; } return false; @@ -9066,20 +9255,24 @@ var noInsuranceSupportAvailable = (marketRiskAppetitePublicDesc) => marketRiskAp var no_insurance_support_default = noInsuranceSupportAvailable; // helpers/map-CIS-countries/map-CIS-country/index.ts -var mapCisCountry = (country) => { +var mapCisCountry = (cisCountry) => { + const { marketName, isoCode } = cisCountry; + const esraClassification = map_esra_classification_default(cisCountry.ESRAClassificationDesc); + const nbiIssueAvailable = map_NBI_issue_available_default(cisCountry.NBIIssue); + const shortTermCover = map_short_term_cover_available_default(cisCountry.shortTermCoverAvailabilityDesc); const mapped = { - name: country.marketName, - isoCode: country.isoCode, - riskCategory: map_risk_category_default(country.ESRAClassificationDesc), - shortTermCover: map_short_term_cover_available_default(country.shortTermCoverAvailabilityDesc), - nbiIssueAvailable: map_NBI_issue_available_default(country.NBIIssue), + name: marketName, + esraClassification, + isoCode, + nbiIssueAvailable, + shortTermCover, }; - mapped.canGetAQuoteOnline = can_get_a_quote_online_default(mapped); - mapped.canGetAQuoteOffline = can_apply_offline_default(country.shortTermCoverAvailabilityDesc); - mapped.canGetAQuoteByEmail = can_get_a_quote_by_email_default(mapped); - mapped.cannotGetAQuote = cannot_get_a_quote_default(mapped); - mapped.canApplyForInsuranceOnline = can_apply_for_insurance_online_default(mapped.shortTermCover, mapped.riskCategory); - mapped.noInsuranceSupport = no_insurance_support_default(country.marketRiskAppetitePublicDesc); + mapped.canGetAQuoteOnline = can_get_a_quote_online_default({ shortTermCover, nbiIssueAvailable, esraClassification }); + mapped.canGetAQuoteOffline = can_apply_offline_default(cisCountry.shortTermCoverAvailabilityDesc); + mapped.canGetAQuoteByEmail = can_get_a_quote_by_email_default({ shortTermCover, nbiIssueAvailable, esraClassification }); + mapped.cannotGetAQuote = cannot_get_a_quote_default({ shortTermCover, nbiIssueAvailable, esraClassification }); + mapped.canApplyForInsuranceOnline = can_apply_for_insurance_online_default(shortTermCover, esraClassification); + mapped.noInsuranceSupport = no_insurance_support_default(cisCountry.marketRiskAppetitePublicDesc); return mapped; }; var map_CIS_country_default = mapCisCountry; @@ -9101,22 +9294,44 @@ var mapCisCountries = (countries) => { }; var map_CIS_countries_default = mapCisCountries; -// custom-resolvers/queries/get-APIM-CIS-countries/index.ts -var getApimCisCountries = async () => { +// helpers/get-APIM-CIS-countries/index.ts +var get3 = async () => { try { - console.info('Getting and mapping CIS countries from APIM'); + console.info('Getting and mapping CIS countries from APIM (apimCisCountries helper)'); const response = await APIM_default.getCisCountries(); if (response.data) { const mapped = map_CIS_countries_default(response.data); - return mapped; + return { + success: true, + countries: mapped, + }; } return { success: false }; } catch (error) { - console.error('Error Getting and mapping CIS countries from APIM %o', error); - throw new Error(`Getting and mapping CIS countries from APIM ${error}`); + console.error('Error Getting and mapping CIS countries from APIM (apimCisCountries helper) %o', error); + throw new Error(`Getting and mapping CIS countries from APIM (apimCisCountries helper) ${error}`); } }; -var get_APIM_CIS_countries_default = getApimCisCountries; +var apimCisCountries = { + get: get3, +}; +var get_APIM_CIS_countries_default = apimCisCountries; + +// custom-resolvers/queries/get-APIM-CIS-countries/index.ts +var getApimCisCountriesQuery = async () => { + try { + console.info('Getting CIS countries from APIM'); + const response = await get_APIM_CIS_countries_default.get(); + if (response.success) { + return response.countries; + } + return []; + } catch (error) { + console.error('Error Getting CIS countries from APIM %o', error); + throw new Error(`Getting CIS countries from APIM ${error}`); + } +}; +var get_APIM_CIS_countries_default2 = getApimCisCountriesQuery; // helpers/map-currencies/index.ts var { CIS: CIS5 } = EXTERNAL_API_DEFINITIONS; @@ -9140,28 +9355,70 @@ var mapCurrencies = (currencies, alternativeCurrencies) => { }; var map_currencies_default = mapCurrencies; -// custom-resolvers/queries/get-APIM-currencies/index.ts -var getApimCurrencies = async () => { +// helpers/get-APIM-currencies/index.ts +var get4 = async () => { try { - console.info('Getting and mapping currencies from APIM'); + console.info('Getting and mapping currencies from APIM (apimCurrencies helper)'); const response = await APIM_default.getCurrencies(); if (response.data) { const supportedCurrencies = map_currencies_default(response.data, false); const alternativeCurrencies = map_currencies_default(response.data, true); const allCurrencies = [...supportedCurrencies, ...alternativeCurrencies]; return { + success: true, supportedCurrencies, alternativeCurrencies, allCurrencies, }; } return { success: false }; + } catch (error) { + console.error('Error Getting and mapping currencies from APIM (apimCurrencies helper) %o', error); + throw new Error(`Getting and mapping currencies from APIM (apimCurrencies helper) ${error}`); + } +}; +var apimCurrencies = { + get: get4, +}; +var get_APIM_currencies_default = apimCurrencies; + +// custom-resolvers/queries/get-APIM-currencies/index.ts +var getApimCurrenciesQuery = async () => { + try { + console.info('Getting and mapping currencies from APIM'); + const response = await get_APIM_currencies_default.get(); + if (response.success) { + return response; + } + return {}; } catch (error) { console.error('Error Getting and mapping currencies from APIM %o', error); throw new Error(`Getting and mapping currencies from APIM ${error}`); } }; -var get_APIM_currencies_default = getApimCurrencies; +var get_APIM_currencies_default2 = getApimCurrenciesQuery; + +// custom-resolvers/queries/get-countries-and-currencies/index.ts +var getCountriesAndCurrencies = async (root, variables, context) => { + try { + console.info('Getting countries and currencies (getCountriesAndCurrencies resolver)'); + const [countries, currenciesResponse] = await Promise.all([await get_countries_default(context), await get_APIM_currencies_default.get()]); + if (!currenciesResponse.success) { + throw new Error('Getting currencies (getCountriesAndCurrencies resolver)'); + } + const { allCurrencies, alternativeCurrencies, supportedCurrencies } = currenciesResponse; + return { + countries, + allCurrencies, + alternativeCurrencies, + supportedCurrencies, + }; + } catch (error) { + console.error('Error getting countries and currencies (getCountriesAndCurrencies resolver) %o', error); + throw new Error(`Getting countries and currencies (getCountriesAndCurrencies resolver) ${error}`); + } +}; +var get_countries_and_currencies_default = getCountriesAndCurrencies; // helpers/remove-white-space/index.ts var removeWhiteSpace = (string) => string.replace(' ', ''); @@ -9536,8 +9793,9 @@ var customResolvers = { }, Query: { getAccountPasswordResetToken: get_account_password_reset_token_default, - getApimCisCountries: get_APIM_CIS_countries_default, - getApimCurrencies: get_APIM_currencies_default, + getApimCisCountries: get_APIM_CIS_countries_default2, + getApimCurrencies: get_APIM_currencies_default2, + getCountriesAndCurrencies: get_countries_and_currencies_default, getCompaniesHouseInformation: get_companies_house_information_default, getApplicationByReferenceNumber: get_application_by_reference_number_default2, getOrdnanceSurveyAddress: get_ordnance_survey_address_default, diff --git a/src/api/constants/XLSX-CONFIG/INDEXES/APPLICATION_INFORMATION/index.test.ts b/src/api/constants/XLSX-CONFIG/INDEXES/APPLICATION_INFORMATION/index.test.ts new file mode 100644 index 0000000000..caa5a45ee1 --- /dev/null +++ b/src/api/constants/XLSX-CONFIG/INDEXES/APPLICATION_INFORMATION/index.test.ts @@ -0,0 +1,12 @@ +import APPLICATION_INFORMATION_INDEXES from '.'; + +describe('api/constants/XLSX-CONFIG/INDEXES/APPLICATION_INFORMATION', () => { + it('should return an object with indexes', () => { + const expected = { + EXPORTER_CONTACT_DETAILS: 8, + KEY_INFORMATION: 13, + }; + + expect(APPLICATION_INFORMATION_INDEXES).toEqual(expected); + }); +}); diff --git a/src/api/constants/XLSX-CONFIG/INDEXES/APPLICATION_INFORMATION/index.ts b/src/api/constants/XLSX-CONFIG/INDEXES/APPLICATION_INFORMATION/index.ts new file mode 100644 index 0000000000..640a21e1b9 --- /dev/null +++ b/src/api/constants/XLSX-CONFIG/INDEXES/APPLICATION_INFORMATION/index.ts @@ -0,0 +1,10 @@ +/** + * APPLICATION_INFORMATION + * Default indexes for the "Application information" XLSX worksheet. + */ +const APPLICATION_INFORMATION_INDEXES = { + EXPORTER_CONTACT_DETAILS: 8, + KEY_INFORMATION: 13, +}; + +export default APPLICATION_INFORMATION_INDEXES; diff --git a/src/api/constants/XLSX-CONFIG/INDEXES/index.ts b/src/api/constants/XLSX-CONFIG/INDEXES/index.ts index 3559adff79..df0b56c8e2 100644 --- a/src/api/constants/XLSX-CONFIG/INDEXES/index.ts +++ b/src/api/constants/XLSX-CONFIG/INDEXES/index.ts @@ -10,6 +10,13 @@ const { EXPORTER_BUSINESS, POLICY, BUYER, EXPORT_CONTRACT } = SECTION_NAMES; /** * XLSX_ROW_INDEXES * Generate row indexes for each worksheet in the XLSX. + * If a row requires some additional row height - for example, for a multi-line address field, + * The row's index should be listed in the relevant section below. + * No other indexes need to be listed. + * NOTE: The APPLICATION_INFORMATION section indexes are intentionally excluded from here, + * because it does NOT require additional heights. + * - The APPLICATION_INFORMATION indexes are consumed in another area for other, non-height styling purposes. + * - The APPLICATION_INFORMATION has some unique requirements unlike all other sections. * @returns {Object} */ const XLSX_ROW_INDEXES = { diff --git a/src/api/constants/allowed-graphql-resolvers/index.ts b/src/api/constants/allowed-graphql-resolvers/index.ts index 2531424ae6..b67450de9a 100644 --- a/src/api/constants/allowed-graphql-resolvers/index.ts +++ b/src/api/constants/allowed-graphql-resolvers/index.ts @@ -38,7 +38,6 @@ const DEFAULT_RESOLVERS = [ // misc 'countries', - 'page', ]; /** @@ -74,8 +73,10 @@ const CUSTOM_RESOLVERS = [ // feedback 'createFeedbackAndSendEmail', + // countries and currencies 'getApimCisCountries', 'getApimCurrencies', + 'getCountriesAndCurrencies', ]; /** diff --git a/src/api/constants/application/get-application-definition/index.ts b/src/api/constants/application/get-application-definition/index.ts index 2141348f79..1dc6d8d314 100644 --- a/src/api/constants/application/get-application-definition/index.ts +++ b/src/api/constants/application/get-application-definition/index.ts @@ -4,6 +4,7 @@ import { ApplicationVersion } from '../../../types'; /** * getApplicationDefinition * Get the latest application config + * @param {String} versionNumber: Application version number * @returns {Object} Latest application config */ const getApplicationDefinition = (versionNumber: string): ApplicationVersion => { diff --git a/src/api/constants/application/versions/index.test.ts b/src/api/constants/application/versions/index.test.ts index a032dbf977..52ddd9b004 100644 --- a/src/api/constants/application/versions/index.test.ts +++ b/src/api/constants/application/versions/index.test.ts @@ -29,6 +29,9 @@ describe('api/constants/application/versions', () => { DEFAULT_CURRENCY: GBP, BROKER_ADDRESS_AS_MULTIPLE_FIELDS: false, REQUESTED_CREDIT_LIMIT_REQUIRED: true, + SMALL_EXPORT_BUILDER: { + MAXIMUM_BUYER_WILL_OWE: 25000, + }, }, ]; diff --git a/src/api/constants/application/versions/index.ts b/src/api/constants/application/versions/index.ts index 20e31c23ba..55a5d11f4d 100644 --- a/src/api/constants/application/versions/index.ts +++ b/src/api/constants/application/versions/index.ts @@ -1,7 +1,7 @@ -import { ApplicationVersion } from '../../../types'; import { GBP } from '../../supported-currencies'; +import { ApplicationVersion } from '../../../types'; -const VERSION_1 = { +const VERSION_1: ApplicationVersion = { VERSION_NUMBER: '1', OVER_500K_SUPPORT: false, MAXIMUM_BUYER_CAN_OWE: 500000, @@ -9,28 +9,34 @@ const VERSION_1 = { DEFAULT_FINAL_DESTINATION_KNOWN: true, DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: false, BROKER_ADDRESS_AS_MULTIPLE_FIELDS: true, -} as ApplicationVersion; +}; -const VERSION_2 = { +const VERSION_2: ApplicationVersion = { VERSION_NUMBER: '2', OVER_500K_SUPPORT: true, DEFAULT_FINAL_DESTINATION_KNOWN: null, DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: null, DEFAULT_CURRENCY: GBP, BROKER_ADDRESS_AS_MULTIPLE_FIELDS: false, -} as ApplicationVersion; +}; -const VERSION_3 = { +const VERSION_3: ApplicationVersion = { ...VERSION_2, VERSION_NUMBER: '3', REQUESTED_CREDIT_LIMIT_REQUIRED: true, -} as ApplicationVersion; + SMALL_EXPORT_BUILDER: { + MAXIMUM_BUYER_WILL_OWE: 25000, + }, +}; /** * VERSIONS * All possible application versions. - * These versions highlight changes to certain features involving data changes, - * That differ as the service is iterated. + * These versions highlight changes to certain features, involving: + * - Data changes + * - Changes to thresholds + * - Required questions/answers + * These differ as the service is iterated. * This should be manually updated each time a phase of EXIP is started. For example: * - Version number 1: MVP, no support for applications over 500k. * - Version number 2: Support for applications over 500k. @@ -38,6 +44,6 @@ const VERSION_3 = { * - Version number 4: Payments integration * @returns {Array} All application versions */ -const VERSIONS = [VERSION_1, VERSION_2, VERSION_3] as Array; +const VERSIONS: Array = [VERSION_1, VERSION_2, VERSION_3]; export default VERSIONS; diff --git a/src/api/constants/external-apis.ts b/src/api/constants/external-apis.ts index 005f719c96..7e6ebfbe19 100644 --- a/src/api/constants/external-apis.ts +++ b/src/api/constants/external-apis.ts @@ -51,6 +51,7 @@ export const EXTERNAL_API_MAPPINGS = { export const EXTERNAL_API_ENDPOINTS = { APIM_MDM: { CURRENCY: '/currencies', + CURRENCY_EXCHANGE: '/currencies/exchange', INDUSTRY_SECTORS: '/sector-industries', MARKETS: '/markets', }, diff --git a/src/api/constants/index.ts b/src/api/constants/index.ts index 893331028b..035af7db59 100644 --- a/src/api/constants/index.ts +++ b/src/api/constants/index.ts @@ -210,7 +210,12 @@ export const EMAIL_TEMPLATE_IDS = { APPLICATION: { SUBMISSION: { EXPORTER: { - CONFIRMATION: '2e9084e2-d871-4be7-85d0-0ccc1961b148', + CONFIRMATION: { + SINGLE_OR_MULTIPLE_CONTRACT_POLICY: '2e9084e2-d871-4be7-85d0-0ccc1961b148', + MULTIPLE_CONTRACT_POLICY: { + ELIGIBLE_FOR_SMALL_EXPORT_BUILDER_CONFIRMATION: '7ee4729d-53ba4729-af50-f733870914de', + }, + }, SEND_DOCUMENTS: { TRADING_HISTORY: '1ae4d77e-58d6-460e-99c0-b62bf08d8c52', ANTI_BRIBERY: '002e43e3-ca78-4b9c-932f-6833014bb1e4', @@ -229,6 +234,7 @@ export const EMAIL_TEMPLATE_IDS = { FEEDBACK: { INSURANCE: '4d3d7944-e894-4527-aee6-692038c84107', }, + UNABLE_TO_DETERMINE_TEMPLATE_ID: 'UNABLE_TO_DETERMINE_TEMPLATE_ID', }; export const FEEDBACK = { diff --git a/src/api/content-strings/fields/insurance/eligibility/index.ts b/src/api/content-strings/fields/insurance/eligibility/index.ts index 056bf32be9..a08d156215 100644 --- a/src/api/content-strings/fields/insurance/eligibility/index.ts +++ b/src/api/content-strings/fields/insurance/eligibility/index.ts @@ -16,7 +16,7 @@ const { const { COMPANY_NAME } = FIELD_IDS.COMPANIES_HOUSE; -const THRESHOLD = formatCurrency(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE, 0); +const THRESHOLD = formatCurrency(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE); export const ELIGIBILITY_FIELDS = { [BUYER_COUNTRY]: { diff --git a/src/api/content-strings/fields/insurance/policy/index.ts b/src/api/content-strings/fields/insurance/policy/index.ts index 61fe79c29d..d440691f81 100644 --- a/src/api/content-strings/fields/insurance/policy/index.ts +++ b/src/api/content-strings/fields/insurance/policy/index.ts @@ -1,6 +1,8 @@ -import { APPLICATION, ELIGIBILITY, FIELD_VALUES, MAXIMUM_CHARACTERS } from '../../../../constants'; +import { APPLICATION, ELIGIBILITY, FIELD_VALUES, GBP_CURRENCY_CODE, MAXIMUM_CHARACTERS } from '../../../../constants'; import INSURANCE_FIELD_IDS from '../../../../constants/field-ids/insurance'; import { FORM_TITLES } from '../../../form-titles'; +import { LINKS } from '../../../links'; +import formatCurrency from '../../../../helpers/format-currency'; const { ACCOUNT: { EMAIL }, @@ -27,12 +29,18 @@ const { } = INSURANCE_FIELD_IDS; const { MAX_COVER_PERIOD_MONTHS } = ELIGIBILITY; + const { + LATEST_VERSION: { SMALL_EXPORT_BUILDER }, POLICY: { TOTAL_MONTHS_OF_COVER }, } = APPLICATION; const { POLICY: POLICY_FORM_TITLES } = FORM_TITLES; +const maxBuyerWillOweThreshold = Number(SMALL_EXPORT_BUILDER?.MAXIMUM_BUYER_WILL_OWE); + +const SMALL_EXPORT_BUILDER_THRESHOLD = formatCurrency(maxBuyerWillOweThreshold, GBP_CURRENCY_CODE); + export const POLICY_FIELDS = { [POLICY_TYPE]: { ID: POLICY_TYPE, @@ -140,6 +148,13 @@ export const POLICY_FIELDS = { LABEL: 'Estimate the maximum amount your buyer will owe you at any single point during this time', HINT: { FOR_EXAMPLE: 'For example, your total sales might be £250,000 but the maximum the buyer will owe you at any single point is £100,000.', + INITIAL_CREDIT_LIMIT: { + INTRO: `If your initial credit limit request is ${SMALL_EXPORT_BUILDER_THRESHOLD} or less you could be eligible for the`, + LINK: { + TEXT: 'Small Export Builder.', + HREF: LINKS.EXTERNAL.SMALL_EXPORT_BUILDER, + }, + }, NO_DECIMALS: 'Enter a whole number. Do not enter decimals.', }, SUMMARY: { diff --git a/src/api/content-strings/links.ts b/src/api/content-strings/links.ts index 17278f383b..7ba0f19442 100644 --- a/src/api/content-strings/links.ts +++ b/src/api/content-strings/links.ts @@ -18,5 +18,6 @@ export const LINKS = { BRIBERY_ACT_2010_GUIDANCE: 'https://www.justice.gov.uk/downloads/legislation/bribery-act-2010-guidance.pdf', ICO_MAKE_A_COMPLAINT: 'https://ico.org.uk/make-a-complaint', COMPANIES_HOUSE: 'https://find-and-update.company-information.service.gov.uk', + SMALL_EXPORT_BUILDER: 'Small Export Builder', }, }; diff --git a/src/api/custom-resolvers/index.ts b/src/api/custom-resolvers/index.ts index cc012e95a3..0af28906f7 100644 --- a/src/api/custom-resolvers/index.ts +++ b/src/api/custom-resolvers/index.ts @@ -24,6 +24,7 @@ import { getAccountPasswordResetToken, getApimCisCountries, getApimCurrencies, + getCountriesAndCurrencies, getCompaniesHouseInformation, getApplicationByReferenceNumber, getOrdnanceSurveyAddress, @@ -64,6 +65,7 @@ const customResolvers = { getAccountPasswordResetToken, getApimCisCountries, getApimCurrencies, + getCountriesAndCurrencies, getCompaniesHouseInformation, getApplicationByReferenceNumber, getOrdnanceSurveyAddress, diff --git a/src/api/custom-resolvers/mutations/account-password-reset/index.ts b/src/api/custom-resolvers/mutations/account-password-reset/index.ts index de5376ea2b..bc60eed774 100644 --- a/src/api/custom-resolvers/mutations/account-password-reset/index.ts +++ b/src/api/custom-resolvers/mutations/account-password-reset/index.ts @@ -9,6 +9,13 @@ import update from '../../../helpers/update-account'; import { dateIsInThePast } from '../../../helpers/date'; import { Account, AccountPasswordResetVariables, Context } from '../../../types'; +/** + * accountPasswordReset + * @param {Object} root: GraphQL root variables + * @param {AccountPasswordResetVariables} variables: GraphQL variables for the accountPasswordReset mutation + * @param {Context} context: KeystoneJS context API + * @returns {Promise} Object with success flag + */ const accountPasswordReset = async (root: any, variables: AccountPasswordResetVariables, context: Context) => { console.info('Resetting account password'); diff --git a/src/api/custom-resolvers/mutations/account-sign-in/index.ts b/src/api/custom-resolvers/mutations/account-sign-in/index.ts index ca24871437..d6a4e3c129 100644 --- a/src/api/custom-resolvers/mutations/account-sign-in/index.ts +++ b/src/api/custom-resolvers/mutations/account-sign-in/index.ts @@ -22,7 +22,7 @@ import { Account, AccountSignInVariables, AccountSignInResponse, Context } from * @param {Object} root: GraphQL root variables * @param {Object} variables: GraphQL variables for the AccountSignIn mutation * @param {Context} context: KeystoneJS context API - * @returns {Promise} Object with success flag + * @returns {Promise} Object with success flag */ const accountSignIn = async (root: any, variables: AccountSignInVariables, context: Context): Promise => { try { diff --git a/src/api/custom-resolvers/mutations/create-an-application/index.ts b/src/api/custom-resolvers/mutations/create-an-application/index.ts index a2f1d3dd2c..799a33ca3f 100644 --- a/src/api/custom-resolvers/mutations/create-an-application/index.ts +++ b/src/api/custom-resolvers/mutations/create-an-application/index.ts @@ -9,7 +9,7 @@ import { CreateAnApplicationVariables, Context } from '../../../types'; * @param {Object} root: GraphQL root variables * @param {CreateAnApplicationVariables} GraphQL variables for the createAnApplication mutation * @param {Context} context: KeystoneJS context API - * @returns {Promise} Object with success flag and application + * @returns {Promise} Object with success flag and application */ const createAnApplication = async (root: any, variables: CreateAnApplicationVariables, context: Context) => { console.info('Creating application for user %s', variables.accountId); diff --git a/src/api/custom-resolvers/mutations/create-feedback/index.ts b/src/api/custom-resolvers/mutations/create-feedback/index.ts index b9c91bb324..13f2973de4 100644 --- a/src/api/custom-resolvers/mutations/create-feedback/index.ts +++ b/src/api/custom-resolvers/mutations/create-feedback/index.ts @@ -7,7 +7,7 @@ import { Context, InsuranceFeedbackVariables } from '../../../types'; * @param {Object} root: GraphQL root variables * @param {Object} variables: GraphQL variables for the createInsuranceFeedback mutation * @param {Context} context: KeystoneJS context API - * @returns {Promise} with success true or false and response + * @returns {Promise} with success true or false and response */ const createFeedback = async (root: any, variables: InsuranceFeedbackVariables, context: Context) => { console.info('Creating feedback'); @@ -26,7 +26,7 @@ const createFeedback = async (root: any, variables: InsuranceFeedbackVariables, // sends email with relevant fields const emailResponse = await sendEmail.insuranceFeedbackEmail(feedback); - // only if data added to db and email has successfully been sent - then return success as true + // only if data added to db and email has successfully been sent - then return success=true if (response && emailResponse?.success) { return { ...response, diff --git a/src/api/custom-resolvers/mutations/create-many-applications/index.ts b/src/api/custom-resolvers/mutations/create-many-applications/index.ts index f324af0dd5..041284135e 100644 --- a/src/api/custom-resolvers/mutations/create-many-applications/index.ts +++ b/src/api/custom-resolvers/mutations/create-many-applications/index.ts @@ -21,7 +21,7 @@ import { CreateManyApplicationsVariables, Context, ObjectType } from '../../../t * @param {Object} root: GraphQL root variables * @param {CreateManyApplicationsVariables} GraphQL variables for the createManyApplications mutation * @param {Context} context: KeystoneJS context API - * @returns {Promise} Object with success flag and applications array + * @returns {Promise} Object with success flag and applications array */ const createManyApplications = async (root: any, variables: CreateManyApplicationsVariables, context: Context) => { console.info('Creating many applications'); diff --git a/src/api/custom-resolvers/mutations/delete-an-account/index.ts b/src/api/custom-resolvers/mutations/delete-an-account/index.ts index 377f247c07..591b5e31b5 100644 --- a/src/api/custom-resolvers/mutations/delete-an-account/index.ts +++ b/src/api/custom-resolvers/mutations/delete-an-account/index.ts @@ -12,7 +12,7 @@ import { Account, AccountDeletionVariables, AuthenticationRetry, Context } from * @param {Object} root: GraphQL root variables * @param {Object} variables: GraphQL variables for the DeleteAnAccount mutation * @param {Context} context: KeystoneJS context API - * @returns {Promise} Object with success flag + * @returns {Promise} Object with success flag */ const deleteAnAccount = async (root: any, variables: AccountDeletionVariables, context: Context) => { console.info('Deleting account ', variables.email); diff --git a/src/api/custom-resolvers/mutations/delete-application-by-reference-number/index.ts b/src/api/custom-resolvers/mutations/delete-application-by-reference-number/index.ts index c2eb2f6b02..efb0c12875 100644 --- a/src/api/custom-resolvers/mutations/delete-application-by-reference-number/index.ts +++ b/src/api/custom-resolvers/mutations/delete-application-by-reference-number/index.ts @@ -10,7 +10,7 @@ import { DeleteApplicationByReferenceNumberVariables, SuccessResponse } from '.. * @param {Object} root: GraphQL root variables * @param {Object} variables: GraphQL variables for the DeleteApplicationByReferenceNumber mutation * @param {Context} context: KeystoneJS context API - * @returns {Promise} Object with success flag + * @returns {Promise} Object with success flag */ const deleteApplicationByReferenceNumber = async ( root: any, diff --git a/src/api/custom-resolvers/mutations/send-email-confirm-email-address/index.ts b/src/api/custom-resolvers/mutations/send-email-confirm-email-address/index.ts index 8ef7e006b1..289bbd5fd8 100644 --- a/src/api/custom-resolvers/mutations/send-email-confirm-email-address/index.ts +++ b/src/api/custom-resolvers/mutations/send-email-confirm-email-address/index.ts @@ -6,7 +6,7 @@ import { Context, SendConfirmEmailAddressVariables } from '../../../types'; * @param {Object} root: GraphQL root variables * @param {Object} variables: GraphQL variables for the SendEmailConfirmEmailAddress mutation * @param {Context} context: KeystoneJS context API - * @returns {Promise} Object with success flag / result of sendEmailConfirmEmailAddress + * @returns {Promise} Object with success flag / result of sendEmailConfirmEmailAddress */ const sendEmailConfirmEmailAddressMutation = async (root: any, variables: SendConfirmEmailAddressVariables, context: Context) => { try { diff --git a/src/api/custom-resolvers/mutations/send-email-insurance-feedback/index.ts b/src/api/custom-resolvers/mutations/send-email-insurance-feedback/index.ts index 42dbe8b7a5..140ae0552c 100644 --- a/src/api/custom-resolvers/mutations/send-email-insurance-feedback/index.ts +++ b/src/api/custom-resolvers/mutations/send-email-insurance-feedback/index.ts @@ -6,7 +6,7 @@ import { InsuranceFeedbackVariables, SuccessResponse } from '../../../types'; * - Sends email with feedback from insurance tool * @param {Object} root: GraphQL root variables * @param {Object} variables: GraphQL variables for the insurance feedback - * @returns {Promise} Object with success flag + * @returns {Promise} Object with success flag */ const sendEmailInsuranceFeedback = async (root: any, variables: InsuranceFeedbackVariables): Promise => { try { diff --git a/src/api/custom-resolvers/mutations/send-email-password-reset-link/index.ts b/src/api/custom-resolvers/mutations/send-email-password-reset-link/index.ts index 0c3b28e2be..3366e83321 100644 --- a/src/api/custom-resolvers/mutations/send-email-password-reset-link/index.ts +++ b/src/api/custom-resolvers/mutations/send-email-password-reset-link/index.ts @@ -29,7 +29,7 @@ const { * @param {Object} root: GraphQL root variables * @param {Object} variables: GraphQL variables for the SendEmailPasswordResetLink mutation * @param {Context} context: KeystoneJS context API - * @returns {Promise} Object with success flag + * @returns {Promise} Object with success flag */ const sendEmailPasswordResetLink = async ( root: any, @@ -84,7 +84,7 @@ const sendEmailPasswordResetLink = async ( }; } } catch (error) { - console.error('Error blocking account $O', error); + console.error('Error blocking account %o', error); return { success: false }; } @@ -119,7 +119,7 @@ const sendEmailPasswordResetLink = async ( return { success: false }; } catch (error) { - console.error('Error checking account and sending password reset email (sendEmailPasswordResetLink mutation) $O', error); + console.error('Error checking account and sending password reset email (sendEmailPasswordResetLink mutation) %o', error); throw new Error(`Checking account and sending password reset email (sendEmailPasswordResetLink mutation) ${error}`); } diff --git a/src/api/custom-resolvers/mutations/send-email-reactivate-account-link/index.ts b/src/api/custom-resolvers/mutations/send-email-reactivate-account-link/index.ts index cb3b1565bd..e99e7e7158 100644 --- a/src/api/custom-resolvers/mutations/send-email-reactivate-account-link/index.ts +++ b/src/api/custom-resolvers/mutations/send-email-reactivate-account-link/index.ts @@ -7,7 +7,7 @@ import { AccountSendEmailReactivateLinkVariables, AccountSendEmailReactivateLink * @param {Object} root: GraphQL root variables * @param {Object} variables: GraphQL variables for the SendReactivateAccountEmail mutation * @param {Context} context: KeystoneJS context API - * @returns {Promise} Object with success flag + * @returns {Promise} Object with success flag */ const sendEmailReactivateAccountLink = async ( root: any, diff --git a/src/api/custom-resolvers/mutations/submit-application/index.ts b/src/api/custom-resolvers/mutations/submit-application/index.ts index 184e636f8a..f06d7a506c 100644 --- a/src/api/custom-resolvers/mutations/submit-application/index.ts +++ b/src/api/custom-resolvers/mutations/submit-application/index.ts @@ -16,7 +16,7 @@ import { SubmitApplicationVariables, SuccessResponse } from '../../../types'; * @param {Object} root: GraphQL root variables * @param {Object} variables: GraphQL variables for the SubmitApplication mutation * @param {Context} context: KeystoneJS context API - * @returns {Promise} Object with success flag + * @returns {Promise} Object with success flag */ const submitApplication = async (root: any, variables: SubmitApplicationVariables, context: Context): Promise => { try { @@ -73,7 +73,7 @@ const submitApplication = async (root: any, variables: SubmitApplicationVariable // generate a XLSX for UKEF underwriting team email const xlsxPath = await generate.XLSX(populatedApplication, countries); - // send all "application submitted" emails + // send all "application submitted" related emails await applicationSubmittedEmails.send(populatedApplication, xlsxPath); return { diff --git a/src/api/custom-resolvers/mutations/update-loss-payee-financial-details-international/index.test.ts b/src/api/custom-resolvers/mutations/update-loss-payee-financial-details-international/index.test.ts index 2ace0b3812..45822a140a 100644 --- a/src/api/custom-resolvers/mutations/update-loss-payee-financial-details-international/index.test.ts +++ b/src/api/custom-resolvers/mutations/update-loss-payee-financial-details-international/index.test.ts @@ -59,7 +59,7 @@ describe('custom-resolvers/update-loss-payee-financial-details-international', ( lossPayeeFinancialDetailsInternationalResponse = await updateLossPayeeFinancialDetailsInternational({}, variables, context); }); - it('should return success as true', () => { + it('should return success=true', () => { const { success } = lossPayeeFinancialDetailsInternationalResponse; expect(success).toEqual(true); diff --git a/src/api/custom-resolvers/mutations/update-loss-payee-financial-details-uk/index.test.ts b/src/api/custom-resolvers/mutations/update-loss-payee-financial-details-uk/index.test.ts index 3214fc2fab..428c1ae4dc 100644 --- a/src/api/custom-resolvers/mutations/update-loss-payee-financial-details-uk/index.test.ts +++ b/src/api/custom-resolvers/mutations/update-loss-payee-financial-details-uk/index.test.ts @@ -44,7 +44,7 @@ describe('custom-resolvers/update-loss-payee-financial-details-uk', () => { lossPayeeFinancialDetailsUkResponse = await updateLossPayeeFinancialDetailsUk({}, variables, context); }); - it('should return success as true', () => { + it('should return success=true', () => { const { success } = lossPayeeFinancialDetailsUkResponse; expect(success).toEqual(true); diff --git a/src/api/custom-resolvers/queries/get-APIM-CIS-countries/index.test.ts b/src/api/custom-resolvers/queries/get-APIM-CIS-countries/index.test.ts index 89f57c1573..a0f5d2f120 100644 --- a/src/api/custom-resolvers/queries/get-APIM-CIS-countries/index.test.ts +++ b/src/api/custom-resolvers/queries/get-APIM-CIS-countries/index.test.ts @@ -1,71 +1,46 @@ -import getApimCisCountries from '.'; -import APIM from '../../../integrations/APIM'; -import mapCisCountries from '../../../helpers/map-CIS-countries'; +import getApimCisCountriesQuery from '.'; +import apimCisCountries from '../../../helpers/get-APIM-CIS-countries'; import mockCisCountriesResponse from '../../../test-mocks/mock-APIM-CIS-countries-response'; -import { mockCisCountries, mockErrorMessage, mockSpyPromiseRejection } from '../../../test-mocks'; +import { mockErrorMessage, mockSpyPromiseRejection } from '../../../test-mocks'; describe('custom-resolvers/get-APIM-CIS-countries', () => { - jest.mock('../../../integrations/APIM'); + jest.mock('../../../helpers/get-APIM-CIS-countries'); - afterAll(() => { - jest.resetAllMocks(); + beforeEach(() => { + apimCisCountries.get = jest.fn(() => Promise.resolve(mockCisCountriesResponse)); }); - describe('when APIM CIS API returns success with data/countries', () => { - beforeEach(() => { - APIM.getCisCountries = jest.fn(() => Promise.resolve(mockCisCountriesResponse)); - }); - - it('should return mapped countries', async () => { - const response = await getApimCisCountries(); - - const mapped = mapCisCountries(mockCisCountries); - - expect(response).toEqual(mapped); - }); + afterAll(() => { + jest.resetAllMocks(); }); - describe('when APIM CIS API returns success as false', () => { - beforeEach(() => { - APIM.getCisCountries = jest.fn(() => Promise.resolve({ success: false })); - }); + it('should return countries from the result of apimCisCountries.get', async () => { + const response = await getApimCisCountriesQuery(); - it('should return object containing success as false', async () => { - const response = await getApimCisCountries(); + const countriesResponse = await apimCisCountries.get(); - const expected = { success: false }; + const expected = countriesResponse.countries; - expect(response).toEqual(expected); - }); + expect(response).toEqual(expected); }); - describe('when APIM CIS API returns empty data object', () => { - beforeEach(() => { - APIM.getCisCountries = jest.fn(() => Promise.resolve({ success: true, data: undefined })); - }); + describe('when apimCisCountries.get returns success=false', () => { + it('should return an empty array', async () => { + apimCisCountries.get = jest.fn(() => Promise.resolve({ ...mockCisCountriesResponse, success: false })); - it('should return object containing success as false', async () => { - const response = await getApimCisCountries(); + const response = await getApimCisCountriesQuery(); - const expected = { success: false }; - - expect(response).toEqual(expected); + expect(response).toEqual([]); }); }); - describe('when APIM CIS API is down', () => { + describe('when there is an error', () => { beforeEach(() => { - APIM.getCisCountries = mockSpyPromiseRejection; + apimCisCountries.get = mockSpyPromiseRejection; }); it('should throw an error', async () => { - try { - await getApimCisCountries(); - } catch (error) { - const expected = new Error(`Getting and mapping CIS countries from APIM ${new Error(mockErrorMessage)}`); - - expect(error).toEqual(expected); - } + await expect(getApimCisCountriesQuery()).rejects.toThrow(`Getting CIS countries from APIM ${new Error(mockErrorMessage)}`); }); }); }); diff --git a/src/api/custom-resolvers/queries/get-APIM-CIS-countries/index.ts b/src/api/custom-resolvers/queries/get-APIM-CIS-countries/index.ts index 58c0e36d8b..ce3250a997 100644 --- a/src/api/custom-resolvers/queries/get-APIM-CIS-countries/index.ts +++ b/src/api/custom-resolvers/queries/get-APIM-CIS-countries/index.ts @@ -1,29 +1,27 @@ -import APIM from '../../../integrations/APIM'; -import mapCisCountries from '../../../helpers/map-CIS-countries'; +import apimCisCountries from '../../../helpers/get-APIM-CIS-countries'; +import { MappedCisCountry } from '../../../types'; /** - * getApimCisCountries + * getApimCisCountriesQuery * Get countries from APIM - * @returns {Promise} APIM response data + * @returns {Promise>} APIM response data */ -const getApimCisCountries = async () => { +const getApimCisCountriesQuery = async (): Promise> => { try { - console.info('Getting and mapping CIS countries from APIM'); + console.info('Getting CIS countries from APIM'); - const response = await APIM.getCisCountries(); + const response = await apimCisCountries.get(); - if (response.data) { - const mapped = mapCisCountries(response.data); - - return mapped; + if (response.success) { + return response.countries; } - return { success: false }; + return []; } catch (error) { - console.error('Error Getting and mapping CIS countries from APIM %o', error); + console.error('Error Getting CIS countries from APIM %o', error); - throw new Error(`Getting and mapping CIS countries from APIM ${error}`); + throw new Error(`Getting CIS countries from APIM ${error}`); } }; -export default getApimCisCountries; +export default getApimCisCountriesQuery; diff --git a/src/api/custom-resolvers/queries/get-APIM-currencies/index.test.ts b/src/api/custom-resolvers/queries/get-APIM-currencies/index.test.ts index 05be472df9..9f08fe6479 100644 --- a/src/api/custom-resolvers/queries/get-APIM-currencies/index.test.ts +++ b/src/api/custom-resolvers/queries/get-APIM-currencies/index.test.ts @@ -1,66 +1,39 @@ import getApimCurrencies from '.'; import APIM from '../../../integrations/APIM'; -import mapCurrencies from '../../../helpers/map-currencies'; +import apimCisCurrencies from '../../../helpers/get-APIM-currencies'; import mockApimCurrenciesResponse from '../../../test-mocks/mock-APIM-currencies-response'; -import { mockCurrencies, mockErrorMessage, mockSpyPromiseRejection } from '../../../test-mocks'; +import { mockErrorMessage, mockSpyPromiseRejection } from '../../../test-mocks'; describe('custom-resolvers/get-APIM-currencies', () => { - jest.mock('../../../integrations/APIM'); + jest.mock('../../../helpers/get-APIM-currencies'); - afterAll(() => { - jest.resetAllMocks(); + beforeEach(() => { + apimCisCurrencies.get = jest.fn(() => Promise.resolve(mockApimCurrenciesResponse)); }); - describe('when APIM currencies API returns success with data/countries', () => { - beforeEach(() => { - APIM.getCurrencies = jest.fn(() => Promise.resolve(mockApimCurrenciesResponse)); - }); - - it('should return an object with mapped countries ', async () => { - const response = await getApimCurrencies(); - - const mappedSupported = mapCurrencies(mockCurrencies, false); - const mappedAlternative = mapCurrencies(mockCurrencies, true); - - const expected = { - supportedCurrencies: mappedSupported, - alternativeCurrencies: mappedAlternative, - allCurrencies: [...mappedSupported, ...mappedAlternative], - }; - - expect(response).toEqual(expected); - }); + afterAll(() => { + jest.resetAllMocks(); }); - describe('when APIM currencies API returns success as false', () => { - beforeEach(() => { - APIM.getCurrencies = jest.fn(() => Promise.resolve({ success: false })); - }); - - it('should return object containing success as false', async () => { - const response = await getApimCurrencies(); + it('should return the result of apimCisCurrencies.get', async () => { + const response = await getApimCurrencies(); - const expected = { success: false }; + const currenciesResponse = await apimCisCurrencies.get(); - expect(response).toEqual(expected); - }); + expect(response).toEqual(currenciesResponse); }); - describe('when APIM currencies API returns empty data object', () => { - beforeEach(() => { - APIM.getCurrencies = jest.fn(() => Promise.resolve({ success: true, data: undefined })); - }); + describe('when apimCisCurrencies.get returns success=false', () => { + it('should return an empty object', async () => { + apimCisCurrencies.get = jest.fn(() => Promise.resolve({ ...mockApimCurrenciesResponse, success: false })); - it('should return object containing success as false', async () => { const response = await getApimCurrencies(); - const expected = { success: false }; - - expect(response).toEqual(expected); + expect(response).toEqual({}); }); }); - describe('when APIM currencies API is down', () => { + describe('when there is an error', () => { beforeEach(() => { APIM.getCurrencies = mockSpyPromiseRejection; }); diff --git a/src/api/custom-resolvers/queries/get-APIM-currencies/index.ts b/src/api/custom-resolvers/queries/get-APIM-currencies/index.ts index efb0b7dcad..b608ae23d2 100644 --- a/src/api/custom-resolvers/queries/get-APIM-currencies/index.ts +++ b/src/api/custom-resolvers/queries/get-APIM-currencies/index.ts @@ -1,30 +1,22 @@ -import APIM from '../../../integrations/APIM'; -import mapCurrencies from '../../../helpers/map-currencies'; +import apimCisCurrencies from '../../../helpers/get-APIM-currencies'; +import { GetApimCurrenciesQueryResponse } from '../../../types'; /** - * getApimCurrencies + * getApimCurrenciesQuery * Get currencies from APIM - * @returns {Promise} APIM response data + * @returns {Promise>} APIM response data */ -const getApimCurrencies = async () => { +const getApimCurrenciesQuery = async (): Promise => { try { console.info('Getting and mapping currencies from APIM'); - const response = await APIM.getCurrencies(); + const response = await apimCisCurrencies.get(); - if (response.data) { - const supportedCurrencies = mapCurrencies(response.data, false); - const alternativeCurrencies = mapCurrencies(response.data, true); - const allCurrencies = [...supportedCurrencies, ...alternativeCurrencies]; - - return { - supportedCurrencies, - alternativeCurrencies, - allCurrencies, - }; + if (response.success) { + return response; } - return { success: false }; + return {}; } catch (error) { console.error('Error Getting and mapping currencies from APIM %o', error); @@ -32,4 +24,4 @@ const getApimCurrencies = async () => { } }; -export default getApimCurrencies; +export default getApimCurrenciesQuery; diff --git a/src/api/custom-resolvers/queries/get-companies-house-information/index.test.ts b/src/api/custom-resolvers/queries/get-companies-house-information/index.test.ts index bcaaf754e8..3bd6e10590 100644 --- a/src/api/custom-resolvers/queries/get-companies-house-information/index.test.ts +++ b/src/api/custom-resolvers/queries/get-companies-house-information/index.test.ts @@ -29,12 +29,12 @@ describe('custom-resolvers/get-companies-house-information', () => { expect(companiesHouse.get).toHaveBeenCalledWith(expected); }); - describe('when companies house API returns success as false', () => { + describe('when companies house API returns success=false', () => { beforeEach(() => { companiesHouse.get = jest.fn(() => Promise.resolve({ success: false, notFound: true })); }); - it('should return object containing success as false', async () => { + it('should return an object containing success=false', async () => { const response = await getCompaniesHouseInformation({}, { companiesHouseNumber: '12345' }); const expected = { @@ -46,12 +46,12 @@ describe('custom-resolvers/get-companies-house-information', () => { }); }); - describe('when companies house API returns empty data object', () => { + describe('when companies house API returns an empty data object', () => { beforeEach(() => { companiesHouse.get = jest.fn(() => Promise.resolve({ success: true, data: undefined })); }); - it('should return object containing success as false', async () => { + it('should return an object containing success=false', async () => { const response = await getCompaniesHouseInformation({}, { companiesHouseNumber: '12345' }); const expected = { success: false }; @@ -65,7 +65,7 @@ describe('custom-resolvers/get-companies-house-information', () => { companiesHouse.get = mockSpyPromiseRejection; }); - it('should return object containing success as false and apiError as true', async () => { + it('should return an object containing success=false and apiError as true', async () => { const response = await getCompaniesHouseInformation({}, { companiesHouseNumber: '12345' }); const expected = { success: false, apiError: true }; @@ -80,7 +80,7 @@ describe('custom-resolvers/get-companies-house-information', () => { industrySectorNames.get = jest.fn(() => Promise.resolve({ success: false })); }); - it('should return object containing success as false and apiError as true', async () => { + it('should return an object containing success=false and apiError as true', async () => { const response = await getCompaniesHouseInformation({}, { companiesHouseNumber: '12345' }); const expected = { success: false, apiError: true }; @@ -95,7 +95,7 @@ describe('custom-resolvers/get-companies-house-information', () => { industrySectorNames.get = jest.fn(() => Promise.resolve({ success: false, apiError: true })); }); - it('should return object containing success as false and apiError as true', async () => { + it('should return an object containing success=false and apiError as true', async () => { const response = await getCompaniesHouseInformation({}, { companiesHouseNumber: '12345' }); const expected = { success: false, apiError: true }; @@ -110,7 +110,7 @@ describe('custom-resolvers/get-companies-house-information', () => { industrySectorNames.get = mockSpyPromiseRejection; }); - it('should return object containing success as false and apiError as true', async () => { + it('should return an object containing success=false and apiError as true', async () => { const response = await getCompaniesHouseInformation({}, { companiesHouseNumber: '12345' }); const expected = { success: false, apiError: true }; @@ -125,7 +125,7 @@ describe('custom-resolvers/get-companies-house-information', () => { industrySectorNames.get = jest.fn(() => Promise.resolve({ success: true, data: mockIndustrySectors })); }); - it('should return object containing success as true and the mapped companies house fields', async () => { + it('should return an object containing success=true and the mapped companies house fields', async () => { const response = await getCompaniesHouseInformation({}, { companiesHouseNumber: '12345' }); const expected = { success: true, ...mapCompaniesHouseFields(mockCompanyAPIResponse, mockIndustrySectors) }; diff --git a/src/api/custom-resolvers/queries/get-companies-house-information/index.ts b/src/api/custom-resolvers/queries/get-companies-house-information/index.ts index 2adae52329..589bde5c58 100644 --- a/src/api/custom-resolvers/queries/get-companies-house-information/index.ts +++ b/src/api/custom-resolvers/queries/get-companies-house-information/index.ts @@ -9,7 +9,6 @@ import { GetCompaniesHouseInformationVariables } from '../../../types'; * Get companies house information * @param {Object} root: GraphQL root variables * @param {Object} variables: GraphQL variables for the GetCompaniesHouseInformation mutation - * @param {Context} context: KeystoneJS context API * @returns {Promise} Object with success flag and mapped companies house response */ const getCompaniesHouseInformation = async (root: any, variables: GetCompaniesHouseInformationVariables) => { diff --git a/src/api/custom-resolvers/queries/get-countries-and-currencies/index.test.ts b/src/api/custom-resolvers/queries/get-countries-and-currencies/index.test.ts new file mode 100644 index 0000000000..ae4032c35b --- /dev/null +++ b/src/api/custom-resolvers/queries/get-countries-and-currencies/index.test.ts @@ -0,0 +1,58 @@ +import { Context } from '.keystone/types'; // eslint-disable-line +import getCountriesAndCurrencies from '.'; +import apimCurrencies from '../../../helpers/get-APIM-currencies'; +import getKeystoneContext from '../../../test-helpers/get-keystone-context'; +import { mockCurrencies, mockApimCurrenciesGetHelperResponse, mockErrorMessage, mockSpyPromiseRejection } from '../../../test-mocks'; + +describe('custom-resolvers/get-countries-and-currencies', () => { + jest.mock('../../../helpers/get-APIM-currencies'); + + let context: Context; + + beforeEach(() => { + context = getKeystoneContext(); + + apimCurrencies.get = jest.fn(() => Promise.resolve(mockApimCurrenciesGetHelperResponse)); + }); + + afterAll(() => { + jest.resetAllMocks(); + }); + + it('should return countries and mapped currencies', async () => { + const response = await getCountriesAndCurrencies({}, {}, context); + + const expectedCountries = await context.db.Country.findMany(); + + const expected = { + countries: expectedCountries, + allCurrencies: mockCurrencies, + alternativeCurrencies: mockCurrencies, + supportedCurrencies: mockCurrencies, + }; + + expect(response).toEqual(expected); + }); + + describe('when apimCurrencies.get returns success=false', () => { + beforeEach(() => { + apimCurrencies.get = jest.fn(() => Promise.resolve({ ...mockApimCurrenciesGetHelperResponse, success: false })); + }); + + it('should throw an error', async () => { + await expect(getCountriesAndCurrencies({}, {}, context)).rejects.toThrow('Getting currencies (getCountriesAndCurrencies resolver)'); + }); + }); + + describe('when there is an error', () => { + beforeEach(() => { + apimCurrencies.get = mockSpyPromiseRejection; + }); + + it('should throw an error', async () => { + await expect(getCountriesAndCurrencies({}, {}, context)).rejects.toThrow( + `Getting countries and currencies (getCountriesAndCurrencies resolver) ${new Error(mockErrorMessage)}`, + ); + }); + }); +}); diff --git a/src/api/custom-resolvers/queries/get-countries-and-currencies/index.ts b/src/api/custom-resolvers/queries/get-countries-and-currencies/index.ts new file mode 100644 index 0000000000..09be3198a8 --- /dev/null +++ b/src/api/custom-resolvers/queries/get-countries-and-currencies/index.ts @@ -0,0 +1,39 @@ +import getCountries from '../../../helpers/get-countries'; +import apimCurrencies from '../../../helpers/get-APIM-currencies'; +import { Context } from '../../../types'; + +/** + * getCountriesAndCurrencies + * - Get countries from our DB. + * - Get and map currencies from APIM. + * @param {Object} root: GraphQL root variables + * @param {Object} variables: GraphQL variables for the getCountriesAndCurrencies query + * @param {Context} context: KeystoneJS context API + * @returns {Promise} APIM countries and currencies + */ +const getCountriesAndCurrencies = async (root: any, variables: object, context: Context) => { + try { + console.info('Getting countries and currencies (getCountriesAndCurrencies resolver)'); + + const [countries, currenciesResponse] = await Promise.all([await getCountries(context), await apimCurrencies.get()]); + + if (!currenciesResponse.success) { + throw new Error('Getting currencies (getCountriesAndCurrencies resolver)'); + } + + const { allCurrencies, alternativeCurrencies, supportedCurrencies } = currenciesResponse; + + return { + countries, + allCurrencies, + alternativeCurrencies, + supportedCurrencies, + }; + } catch (error) { + console.error('Error getting countries and currencies (getCountriesAndCurrencies resolver) %o', error); + + throw new Error(`Getting countries and currencies (getCountriesAndCurrencies resolver) ${error}`); + } +}; + +export default getCountriesAndCurrencies; diff --git a/src/api/custom-resolvers/queries/get-ordnance-survey-address/index.test.ts b/src/api/custom-resolvers/queries/get-ordnance-survey-address/index.test.ts index 8ffce1ef14..b9175b878d 100644 --- a/src/api/custom-resolvers/queries/get-ordnance-survey-address/index.test.ts +++ b/src/api/custom-resolvers/queries/get-ordnance-survey-address/index.test.ts @@ -15,12 +15,12 @@ describe('getOrdnanceSurveyAddress', () => { const { postcode, houseNameOrNumber } = MOCK_OS_ADDRESS_INPUT; - describe('when ordnance survey API returns success as false', () => { + describe('when ordnance survey API returns success=false', () => { beforeEach(() => { ordnanceSurvey.get = jest.fn(() => Promise.resolve({ success: false })); }); - it('should return object containing success as false', async () => { + it('should return an object containing success=false', async () => { const response = await getOrdnanceSurveyAddress({}, { postcode, houseNameOrNumber }); const expected = { success: false }; @@ -29,12 +29,12 @@ describe('getOrdnanceSurveyAddress', () => { }); }); - describe('when ordnance survey API returns empty data object', () => { + describe('when ordnance survey API returns an empty data object', () => { beforeEach(() => { ordnanceSurvey.get = jest.fn(() => Promise.resolve({ success: true, data: undefined })); }); - it('should return object containing success as false', async () => { + it('should return an object containing success=false', async () => { const response = await getOrdnanceSurveyAddress({}, { postcode, houseNameOrNumber }); const expected = { success: false }; @@ -48,7 +48,7 @@ describe('getOrdnanceSurveyAddress', () => { ordnanceSurvey.get = mockSpyPromiseRejection; }); - it('should return object containing success as false and apiError as true', async () => { + it('should return an object containing success=false and apiError as true', async () => { const response = await getOrdnanceSurveyAddress({}, { postcode, houseNameOrNumber }); const expected = { success: false, apiError: true }; @@ -58,7 +58,7 @@ describe('getOrdnanceSurveyAddress', () => { }); describe('when the postcode is invalid', () => { - it('should return object containing success as false and invalidPostcode as true', async () => { + it('should return an object containing success=false and invalidPostcode as true', async () => { const response = await getOrdnanceSurveyAddress({}, { postcode: 'S', houseNameOrNumber }); const expected = { success: false, invalidPostcode: true }; @@ -73,7 +73,7 @@ describe('getOrdnanceSurveyAddress', () => { ordnanceSurvey.get = jest.fn(() => Promise.resolve({ success: true, data: ordnanceSurveyResponse })); }); - it('should return object containing success as true and the mapped address', async () => { + it('should return an object containing success=true and the mapped address', async () => { const response = await getOrdnanceSurveyAddress({}, { postcode, houseNameOrNumber }); const expected = { success: true, addresses: mapAndFilterAddress('10', mockOrdnanceSurveyResponse.results) }; @@ -81,7 +81,7 @@ describe('getOrdnanceSurveyAddress', () => { expect(response).toEqual(expected); }); - it('should return object containing success as false and noAddressesFound as true when house number not found', async () => { + it('should return an object containing success=false and noAddressesFound as true when house number not found', async () => { const response = await getOrdnanceSurveyAddress({}, { postcode, houseNameOrNumber: 'A' }); const expected = { success: false, noAddressesFound: true }; diff --git a/src/api/custom-resolvers/queries/get-ordnance-survey-address/index.ts b/src/api/custom-resolvers/queries/get-ordnance-survey-address/index.ts index 4217b8f3f0..90a58134f4 100644 --- a/src/api/custom-resolvers/queries/get-ordnance-survey-address/index.ts +++ b/src/api/custom-resolvers/queries/get-ordnance-survey-address/index.ts @@ -11,7 +11,6 @@ import removeWhiteSpace from '../../../helpers/remove-white-space'; * Finds address by house name/number * @param {Object} root: GraphQL root variables * @param {Object} variables: GraphQL variables for the getOrdnanceSurveyAddress mutation - postcode and houseNameOrNumber - * @param {Context} context: KeystoneJS context API * @returns {Promise} Object with success flag and addresses in an array */ const getOrdnanceSurveyAddress = async (root: any, variables: OrdnanceSurveyVariables) => { diff --git a/src/api/custom-resolvers/queries/index.ts b/src/api/custom-resolvers/queries/index.ts index b0c3c8aff9..6c8bca3789 100644 --- a/src/api/custom-resolvers/queries/index.ts +++ b/src/api/custom-resolvers/queries/index.ts @@ -1,6 +1,7 @@ import getAccountPasswordResetToken from './get-account-password-reset-token'; import getApimCisCountries from './get-APIM-CIS-countries'; import getApimCurrencies from './get-APIM-currencies'; +import getCountriesAndCurrencies from './get-countries-and-currencies'; import getCompaniesHouseInformation from './get-companies-house-information'; import getApplicationByReferenceNumber from './get-application-by-reference-number'; import getOrdnanceSurveyAddress from './get-ordnance-survey-address'; @@ -10,6 +11,7 @@ export { getAccountPasswordResetToken, getApimCisCountries, getApimCurrencies, + getCountriesAndCurrencies, getCompaniesHouseInformation, getApplicationByReferenceNumber, getOrdnanceSurveyAddress, diff --git a/src/api/custom-schema/type-defs.ts b/src/api/custom-schema/type-defs.ts index 96c8ec8fb8..1cdc5027fe 100644 --- a/src/api/custom-schema/type-defs.ts +++ b/src/api/custom-schema/type-defs.ts @@ -224,11 +224,16 @@ const typeDefs = ` referenceNumber: Int } + type Country { + isoCode: String! + name: String! + } + type MappedCisCountry { isoCode: String! name: String shortTermCover: Boolean - riskCategory: String + esraClassification: String nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean canGetAQuoteOffline: Boolean @@ -250,6 +255,13 @@ const typeDefs = ` allCurrencies: [MappedCurrency] } + type GetCountriesAndCurrenciesResponse { + countries: [Country] + supportedCurrencies: [MappedCurrency] + alternativeCurrencies: [MappedCurrency] + allCurrencies: [MappedCurrency] + } + type Owner { id: String firstName: String @@ -462,9 +474,6 @@ const typeDefs = ` token: String! ): AccountPasswordResetTokenResponse - """ get CIS countries from APIM """ - getApimCisCountries: [MappedCisCountry] - """ get companies house information """ getCompaniesHouseInformation( companiesHouseNumber: String! @@ -488,6 +497,9 @@ const typeDefs = ` """ get currencies from APIM """ getApimCurrencies: GetApimCurrencyResponse + + """ get countries and currencies """ + getCountriesAndCurrencies: GetCountriesAndCurrenciesResponse } `; diff --git a/src/api/emails/application/get-submitted-confirmation-template-id/index.test.ts b/src/api/emails/application/get-submitted-confirmation-template-id/index.test.ts new file mode 100644 index 0000000000..1ce4c53c30 --- /dev/null +++ b/src/api/emails/application/get-submitted-confirmation-template-id/index.test.ts @@ -0,0 +1,96 @@ +import getSubmittedConfirmationTemplateId from '.'; +import { EMAIL_TEMPLATE_IDS, FIELD_VALUES } from '../../../constants'; +import multiplePolicyTypeTemplateId from './multiple-policy-type'; +import { ApplicationPolicy } from '../../../types'; +import { mockSpyPromiseRejection, mockErrorMessage } from '../../../test-mocks'; +import mockApplication, { mockMultiplePolicy } from '../../../test-mocks/mock-application'; + +const { + POLICY_TYPE: { SINGLE, MULTIPLE }, +} = FIELD_VALUES; + +const { + APPLICATION: { + SUBMISSION: { + EXPORTER: { CONFIRMATION }, + }, + }, + UNABLE_TO_DETERMINE_TEMPLATE_ID, +} = EMAIL_TEMPLATE_IDS; + +const mockSingleContractPolicy: ApplicationPolicy = { + ...mockApplication.policy, + policyType: SINGLE, +}; + +const mockMultipleContractPolicy: ApplicationPolicy = { + ...mockMultiplePolicy, + policyType: MULTIPLE, +}; + +describe('emails/application/get-submitted-confirmation-template-id', () => { + jest.mock('./multiple-policy-type'); + + const mockMultiplePolicyTypeTemplateId = CONFIRMATION.MULTIPLE_CONTRACT_POLICY.ELIGIBLE_FOR_SMALL_EXPORT_BUILDER_CONFIRMATION; + + const mockMultiplePolicyTypeTemplateIdSpy = jest.fn(() => Promise.resolve(mockMultiplePolicyTypeTemplateId)); + + beforeEach(() => { + multiplePolicyTypeTemplateId.get = mockMultiplePolicyTypeTemplateIdSpy; + }); + + describe(`when policy type is ${SINGLE}`, () => { + it('should return the correct email template ID', async () => { + const result = await getSubmittedConfirmationTemplateId(mockSingleContractPolicy); + + const expected = CONFIRMATION.SINGLE_OR_MULTIPLE_CONTRACT_POLICY; + + expect(result).toEqual(expected); + }); + }); + + describe(`when policy type is ${MULTIPLE}`, () => { + const mockPolicyData: ApplicationPolicy = mockMultipleContractPolicy; + + const { policyType, policyCurrencyCode, maximumBuyerWillOwe } = mockPolicyData; + + it('should call multiplePolicyTypeTemplateId.get', async () => { + await getSubmittedConfirmationTemplateId(mockPolicyData); + + expect(mockMultiplePolicyTypeTemplateIdSpy).toHaveBeenCalledTimes(1); + + expect(mockMultiplePolicyTypeTemplateIdSpy).toHaveBeenCalledWith(policyType, policyCurrencyCode, maximumBuyerWillOwe); + }); + + it('should return the result of multiplePolicyTypeTemplateId.get', async () => { + const result = await getSubmittedConfirmationTemplateId(mockPolicyData); + + const expected = mockMultiplePolicyTypeTemplateId; + + expect(result).toEqual(expected); + }); + + describe('when multiplePolicyTypeTemplateId.get throws an error', () => { + it('should throw an error', async () => { + multiplePolicyTypeTemplateId.get = mockSpyPromiseRejection; + + await expect(getSubmittedConfirmationTemplateId(mockPolicyData)).rejects.toThrow( + `Getting submitted confirmation template ID (getSubmittedConfirmationTemplateId helper) ${new Error(mockErrorMessage)}`, + ); + }); + }); + }); + + describe('when policy type is not recognised', () => { + it(`should return ${UNABLE_TO_DETERMINE_TEMPLATE_ID}`, async () => { + const mockPolicy = { + ...mockApplication.policy, + policyType: 'invalid-policy-type', + }; + + const result = await getSubmittedConfirmationTemplateId(mockPolicy); + + expect(result).toEqual(UNABLE_TO_DETERMINE_TEMPLATE_ID); + }); + }); +}); diff --git a/src/api/emails/application/get-submitted-confirmation-template-id/index.ts b/src/api/emails/application/get-submitted-confirmation-template-id/index.ts new file mode 100644 index 0000000000..7616330bbe --- /dev/null +++ b/src/api/emails/application/get-submitted-confirmation-template-id/index.ts @@ -0,0 +1,45 @@ +import { EMAIL_TEMPLATE_IDS } from '../../../constants'; +import { isSinglePolicyType, isMultiplePolicyType } from '../../../helpers/policy-type'; +import multiplePolicyTypeTemplateId from './multiple-policy-type'; +import { ApplicationPolicy } from '../../../types'; + +const { + APPLICATION: { + SUBMISSION: { + EXPORTER: { CONFIRMATION }, + }, + }, + UNABLE_TO_DETERMINE_TEMPLATE_ID, +} = EMAIL_TEMPLATE_IDS; + +/** + * getSubmittedConfirmationTemplateId + * Get an email template ID for the "application submitted" email, depending on: + * - The application's policy type. + * - If the "maximum buyer will owe" (in GBP) is below a threshold. + * @param {ApplicationPolicy} policy: Application policy + * @returns {Promise} "Application submitted" template ID + */ +const getSubmittedConfirmationTemplateId = async (policy: ApplicationPolicy): Promise => { + try { + console.info('Getting submitted confirmation template ID (getSubmittedConfirmationTemplateId helper)'); + + const { maximumBuyerWillOwe, policyCurrencyCode, policyType } = policy; + + if (isSinglePolicyType(policyType)) { + return CONFIRMATION.SINGLE_OR_MULTIPLE_CONTRACT_POLICY; + } + + if (isMultiplePolicyType(policyType) && maximumBuyerWillOwe) { + return await multiplePolicyTypeTemplateId.get(policyType, String(policyCurrencyCode), maximumBuyerWillOwe); + } + + return UNABLE_TO_DETERMINE_TEMPLATE_ID; + } catch (error) { + console.error('Error Getting submitted confirmation template ID (getSubmittedConfirmationTemplateId helper) %o', error); + + throw new Error(`Getting submitted confirmation template ID (getSubmittedConfirmationTemplateId helper) ${error}`); + } +}; + +export default getSubmittedConfirmationTemplateId; diff --git a/src/api/emails/application/get-submitted-confirmation-template-id/multiple-policy-type/index.test.ts b/src/api/emails/application/get-submitted-confirmation-template-id/multiple-policy-type/index.test.ts new file mode 100644 index 0000000000..e5719fe704 --- /dev/null +++ b/src/api/emails/application/get-submitted-confirmation-template-id/multiple-policy-type/index.test.ts @@ -0,0 +1,157 @@ +import multiplePolicyTypeTemplateId from '.'; +import { APPLICATION, EMAIL_TEMPLATE_IDS, FIELD_VALUES, GBP, USD } from '../../../../constants'; +import { POLICY as POLICY_FIELD_IDS } from '../../../../constants/field-ids/insurance/policy'; +import apimCurrencyExchangeRate from '../../../../helpers/get-APIM-currencies-exchange-rate'; +import { mockSpyPromiseRejection, mockErrorMessage } from '../../../../test-mocks'; +import { mockMultiplePolicy } from '../../../../test-mocks/mock-application'; +import { mockCurrencyExchange } from '../../../../test-mocks/mock-APIM-currencies-exchange-response'; + +const { + POLICY_TYPE: { MULTIPLE }, +} = FIELD_VALUES; + +const { + EXPORT_VALUE: { + MULTIPLE: { MAXIMUM_BUYER_WILL_OWE }, + }, + CONTRACT_POLICY: { POLICY_CURRENCY_CODE }, +} = POLICY_FIELD_IDS; + +const { + LATEST_VERSION: { SMALL_EXPORT_BUILDER }, +} = APPLICATION; + +const { + APPLICATION: { + SUBMISSION: { + EXPORTER: { CONFIRMATION }, + }, + }, + UNABLE_TO_DETERMINE_TEMPLATE_ID, +} = EMAIL_TEMPLATE_IDS; + +const { policyType, maximumBuyerWillOwe } = mockMultiplePolicy; + +const threshold = Number(SMALL_EXPORT_BUILDER?.MAXIMUM_BUYER_WILL_OWE); + +describe('emails/application/get-submitted-confirmation-template-id/multiple-policy-type', () => { + jest.mock('../../../../helpers/get-APIM-currencies-exchange-rate'); + + const mockApimCurrencyExchangeRateSpy = jest.fn(() => Promise.resolve(mockCurrencyExchange.midPrice)); + + beforeEach(() => { + apimCurrencyExchangeRate.get = mockApimCurrencyExchangeRateSpy; + }); + + describe(`when policy type is ${MULTIPLE}`, () => { + describe(`when ${POLICY_CURRENCY_CODE} is ${GBP}`, () => { + const mockPolicyCurrencyCode = GBP; + + it('should NOT call apimCurrencyExchangeRate.get', async () => { + await multiplePolicyTypeTemplateId.get(policyType, mockPolicyCurrencyCode, maximumBuyerWillOwe); + + expect(mockApimCurrencyExchangeRateSpy).toHaveBeenCalledTimes(0); + }); + + describe(`when ${MAXIMUM_BUYER_WILL_OWE} is below ${SMALL_EXPORT_BUILDER?.MAXIMUM_BUYER_WILL_OWE}`, () => { + it('should return the correct email template ID', async () => { + const mockMaximumBuyerWillOwe = threshold - 1; + + const result = await multiplePolicyTypeTemplateId.get(policyType, mockPolicyCurrencyCode, mockMaximumBuyerWillOwe); + + const expected = CONFIRMATION.MULTIPLE_CONTRACT_POLICY.ELIGIBLE_FOR_SMALL_EXPORT_BUILDER_CONFIRMATION; + + expect(result).toEqual(expected); + }); + }); + + describe(`when ${MAXIMUM_BUYER_WILL_OWE} is equal to ${SMALL_EXPORT_BUILDER?.MAXIMUM_BUYER_WILL_OWE}`, () => { + it('should return the correct email template ID', async () => { + const mockMaximumBuyerWillOwe = threshold; + + const result = await multiplePolicyTypeTemplateId.get(policyType, mockPolicyCurrencyCode, mockMaximumBuyerWillOwe); + + const expected = CONFIRMATION.MULTIPLE_CONTRACT_POLICY.ELIGIBLE_FOR_SMALL_EXPORT_BUILDER_CONFIRMATION; + + expect(result).toEqual(expected); + }); + }); + + describe(`when ${MAXIMUM_BUYER_WILL_OWE} is over ${SMALL_EXPORT_BUILDER?.MAXIMUM_BUYER_WILL_OWE}`, () => { + it('should return the correct email template ID', async () => { + const mockMaximumBuyerWillOwe = threshold + 1; + + const result = await multiplePolicyTypeTemplateId.get(policyType, mockPolicyCurrencyCode, mockMaximumBuyerWillOwe); + + const expected = CONFIRMATION.SINGLE_OR_MULTIPLE_CONTRACT_POLICY; + + expect(result).toEqual(expected); + }); + }); + }); + + describe(`when ${POLICY_CURRENCY_CODE} is NOT ${GBP}`, () => { + const mockPolicyCurrencyCode = USD; + + it('should call apimCurrencyExchangeRate.get', async () => { + await multiplePolicyTypeTemplateId.get(policyType, mockPolicyCurrencyCode, maximumBuyerWillOwe); + + expect(mockApimCurrencyExchangeRateSpy).toHaveBeenCalledTimes(1); + + expect(mockApimCurrencyExchangeRateSpy).toHaveBeenCalledWith(GBP, mockPolicyCurrencyCode); + }); + + describe(`when ${MAXIMUM_BUYER_WILL_OWE} in ${GBP} is below ${SMALL_EXPORT_BUILDER?.MAXIMUM_BUYER_WILL_OWE}`, () => { + it('should return the correct email template ID', async () => { + apimCurrencyExchangeRate.get = jest.fn(() => Promise.resolve(1)); + + const mockMaximumBuyerWillOwe = threshold - 1; + + const result = await multiplePolicyTypeTemplateId.get(policyType, mockPolicyCurrencyCode, mockMaximumBuyerWillOwe); + + const expected = CONFIRMATION.MULTIPLE_CONTRACT_POLICY.ELIGIBLE_FOR_SMALL_EXPORT_BUILDER_CONFIRMATION; + + expect(result).toEqual(expected); + }); + }); + + describe(`when ${MAXIMUM_BUYER_WILL_OWE} in ${GBP} is over ${SMALL_EXPORT_BUILDER?.MAXIMUM_BUYER_WILL_OWE}`, () => { + it('should return the correct email template ID', async () => { + /** + * Mock return an exchange rate of zero. + * This allows us to easily create a mock MAXIMUM_BUYER_WILL_OWE that is just above the threshold. + */ + apimCurrencyExchangeRate.get = jest.fn(() => Promise.resolve(0)); + + const mockMaximumBuyerWillOwe = threshold + 1; + + const result = await multiplePolicyTypeTemplateId.get(policyType, mockPolicyCurrencyCode, mockMaximumBuyerWillOwe); + + const expected = CONFIRMATION.SINGLE_OR_MULTIPLE_CONTRACT_POLICY; + + expect(result).toEqual(expected); + }); + }); + + describe('when apimCurrencyExchangeRate.get throws an error', () => { + it('should throw an error', async () => { + apimCurrencyExchangeRate.get = mockSpyPromiseRejection; + + await expect(multiplePolicyTypeTemplateId.get(policyType, mockPolicyCurrencyCode, maximumBuyerWillOwe)).rejects.toThrow( + `Getting submitted confirmation template ID for a multiple policy type (multiplePolicyTypeTemplateId helper) ${new Error(mockErrorMessage)}`, + ); + }); + }); + }); + }); + + describe(`when policy type is not ${MULTIPLE}`, () => { + it(`should return ${UNABLE_TO_DETERMINE_TEMPLATE_ID}`, async () => { + const mockPolicyType = 'invalid-policy-type'; + + const result = await multiplePolicyTypeTemplateId.get(mockPolicyType, GBP, maximumBuyerWillOwe); + + expect(result).toEqual(UNABLE_TO_DETERMINE_TEMPLATE_ID); + }); + }); +}); diff --git a/src/api/emails/application/get-submitted-confirmation-template-id/multiple-policy-type/index.ts b/src/api/emails/application/get-submitted-confirmation-template-id/multiple-policy-type/index.ts new file mode 100644 index 0000000000..9ce59935a4 --- /dev/null +++ b/src/api/emails/application/get-submitted-confirmation-template-id/multiple-policy-type/index.ts @@ -0,0 +1,66 @@ +import { APPLICATION, EMAIL_TEMPLATE_IDS, GBP } from '../../../../constants'; +import { isMultiplePolicyType } from '../../../../helpers/policy-type'; +import apimCurrencyExchangeRate from '../../../../helpers/get-APIM-currencies-exchange-rate'; +import roundNumber from '../../../../helpers/round-number'; + +const { + LATEST_VERSION: { SMALL_EXPORT_BUILDER }, +} = APPLICATION; + +const { + APPLICATION: { + SUBMISSION: { + EXPORTER: { CONFIRMATION }, + }, + }, + UNABLE_TO_DETERMINE_TEMPLATE_ID, +} = EMAIL_TEMPLATE_IDS; + +/** + * get + * Get an email template ID for the "application submitted" email, for a multiple policy type. + * @param {String} policyType: Policy type + * @param {String} policyCurrencyCode: Policy currency code + * @param {Number} maximumBuyerWillOwe: Maximum buyer will owe + * @returns {Promise} "Application submitted" template ID + */ +const get = async (policyType: string, policyCurrencyCode: string, maximumBuyerWillOwe: number) => { + try { + console.info('Getting submitted confirmation template ID for a multiple policy type (multiplePolicyTypeTemplateId helper)'); + + if (isMultiplePolicyType(policyType)) { + let maximumBuyerWillOweInGbp = maximumBuyerWillOwe; + + if (policyCurrencyCode !== GBP) { + const source = GBP; + const target = String(policyCurrencyCode); + + const exchangeRate = await apimCurrencyExchangeRate.get(source, target); + + maximumBuyerWillOweInGbp = roundNumber(maximumBuyerWillOwe / exchangeRate); + } + + const threshold = Number(SMALL_EXPORT_BUILDER?.MAXIMUM_BUYER_WILL_OWE); + + const eligibileForSmallExportBuilder = maximumBuyerWillOweInGbp <= threshold; + + if (eligibileForSmallExportBuilder) { + return CONFIRMATION.MULTIPLE_CONTRACT_POLICY.ELIGIBLE_FOR_SMALL_EXPORT_BUILDER_CONFIRMATION; + } + + return CONFIRMATION.SINGLE_OR_MULTIPLE_CONTRACT_POLICY; + } + + return UNABLE_TO_DETERMINE_TEMPLATE_ID; + } catch (error) { + console.error('Error Getting submitted confirmation template ID for a multiple policy type (multiplePolicyTypeTemplateId helper) %o', error); + + throw new Error(`Getting submitted confirmation template ID for a multiple policy type (multiplePolicyTypeTemplateId helper) ${error}`); + } +}; + +const multiplePolicyTypeTemplateId = { + get, +}; + +export default multiplePolicyTypeTemplateId; diff --git a/src/api/emails/application/index.test.ts b/src/api/emails/application/index.test.ts index 5a3e6928d8..240b6809b5 100644 --- a/src/api/emails/application/index.test.ts +++ b/src/api/emails/application/index.test.ts @@ -1,6 +1,7 @@ import application from '.'; import notify from '../../integrations/notify'; import { EMAIL_TEMPLATE_IDS } from '../../constants'; +import getSubmittedConfirmationTemplateId from './get-submitted-confirmation-template-id'; import getFullNameString from '../../helpers/get-full-name-string'; import fileSystem from '../../file-system'; import { mockAccount, mockApplication, mockCompany, mockBuyer, mockSendEmailResponse, mockErrorMessage, mockSpyPromiseRejection } from '../../test-mocks'; @@ -16,7 +17,7 @@ describe('emails/application', () => { const unlinkSpy = jest.fn(() => Promise.resolve(true)); const { email } = mockAccount; - const { referenceNumber } = mockApplication; + const { referenceNumber, policy } = mockApplication; const { companyName } = mockCompany; const { companyOrOrganisationName } = mockBuyer; @@ -32,9 +33,7 @@ describe('emails/application', () => { const mockFilePath = '/path-to-file'; - describe('account', () => { - const templateId = EMAIL_TEMPLATE_IDS.APPLICATION.SUBMISSION.EXPORTER.CONFIRMATION; - + describe('application', () => { beforeEach(() => { jest.clearAllMocks(); @@ -46,10 +45,12 @@ describe('emails/application', () => { test('it should call notify.sendEmail and return the response', async () => { notify.sendEmail = sendEmailSpy; - const result = await application.submittedEmail(variables); + const result = await application.submittedEmail(variables, policy); + + const expectedTemplateId = await getSubmittedConfirmationTemplateId(policy); expect(sendEmailSpy).toHaveBeenCalledTimes(1); - expect(sendEmailSpy).toHaveBeenCalledWith(templateId, email, variables); + expect(sendEmailSpy).toHaveBeenCalledWith(expectedTemplateId, email, variables); const expected = mockSendEmailResponse; @@ -63,7 +64,7 @@ describe('emails/application', () => { test('should throw an error', async () => { try { - await application.submittedEmail(variables); + await application.submittedEmail(variables, policy); } catch (error) { const expected = new Error( `Sending application submitted email to to application owner or provided business contact Error: Sending email ${new Error(mockErrorMessage)}`, diff --git a/src/api/emails/application/index.ts b/src/api/emails/application/index.ts index 79ecdce40c..48bd06710a 100644 --- a/src/api/emails/application/index.ts +++ b/src/api/emails/application/index.ts @@ -1,20 +1,21 @@ -import { EMAIL_TEMPLATE_IDS } from '../../constants'; +import getSubmittedConfirmationTemplateId from './get-submitted-confirmation-template-id'; import fileSystem from '../../file-system'; import { callNotify } from '../call-notify'; -import { ApplicationSubmissionEmailVariables, EmailResponse } from '../../types'; +import { ApplicationPolicy, ApplicationSubmissionEmailVariables, EmailResponse } from '../../types'; const application = { /** * application.submittedEmail * Send "application submitted" email to an account * @param {ApplicationSubmissionEmailVariables} ApplicationSubmissionEmailVariables + * @param {ApplicationPolicy} policy: Application policy * @returns {Promise} callNotify response */ - submittedEmail: async (variables: ApplicationSubmissionEmailVariables): Promise => { + submittedEmail: async (variables: ApplicationSubmissionEmailVariables, policy: ApplicationPolicy): Promise => { try { console.info('Sending application submitted email to application owner or provided business contact'); - const templateId = EMAIL_TEMPLATE_IDS.APPLICATION.SUBMISSION.EXPORTER.CONFIRMATION; + const templateId = await getSubmittedConfirmationTemplateId(policy); const { emailAddress } = variables; diff --git a/src/api/emails/send-application-submitted-emails/index.test.ts b/src/api/emails/send-application-submitted-emails/index.test.ts index 5b681c6640..a62d7f8063 100644 --- a/src/api/emails/send-application-submitted-emails/index.test.ts +++ b/src/api/emails/send-application-submitted-emails/index.test.ts @@ -66,14 +66,12 @@ describe('emails/send-email-application-submitted', () => { expectedSendOwnerEmailVars = { ...sharedEmailVars, emailAddress: email, - buyerName: replaceCharacterCodesWithCharacters(String(buyer.companyOrOrganisationName)), name: replaceCharacterCodesWithCharacters(getFullNameString(owner)), } as ApplicationSubmissionEmailVariables; expectedContactSendEmailVars = { ...sharedEmailVars, emailAddress: policyContact.email, - buyerName: replaceCharacterCodesWithCharacters(String(buyer.companyOrOrganisationName)), name: replaceCharacterCodesWithCharacters(getFullNameString(policyContact)), } as ApplicationSubmissionEmailVariables; }); @@ -83,7 +81,7 @@ describe('emails/send-email-application-submitted', () => { await sendApplicationSubmittedEmails.send(application, mockXlsxPath); expect(applicationSubmittedEmailSpy).toHaveBeenCalledTimes(1); - expect(applicationSubmittedEmailSpy).toHaveBeenCalledWith(expectedSendOwnerEmailVars); + expect(applicationSubmittedEmailSpy).toHaveBeenCalledWith(expectedSendOwnerEmailVars, application.policy); }); test('it should call sendEmail.application.applicationSubmittedEmail with the correct template ID', async () => { @@ -118,8 +116,8 @@ describe('emails/send-email-application-submitted', () => { await sendApplicationSubmittedEmails.send(application, mockXlsxPath); expect(applicationSubmittedEmailSpy).toHaveBeenCalledTimes(2); - expect(applicationSubmittedEmailSpy).toHaveBeenCalledWith(expectedSendOwnerEmailVars); - expect(applicationSubmittedEmailSpy).toHaveBeenCalledWith(expectedContactSendEmailVars); + expect(applicationSubmittedEmailSpy).toHaveBeenCalledWith(expectedSendOwnerEmailVars, application.policy); + expect(applicationSubmittedEmailSpy).toHaveBeenCalledWith(expectedContactSendEmailVars, application.policy); }); test('it should call sendEmail.application.submittedEmail with the correct template ID', async () => { diff --git a/src/api/emails/send-application-submitted-emails/index.ts b/src/api/emails/send-application-submitted-emails/index.ts index 515131ed05..0706c30bbd 100644 --- a/src/api/emails/send-application-submitted-emails/index.ts +++ b/src/api/emails/send-application-submitted-emails/index.ts @@ -10,31 +10,33 @@ import { SuccessResponse, ApplicationSubmissionEmailVariables, Application } fro * Send "application submitted" emails * @param {Application} application * @param {String} xlsxPath: Path to XLSX file for underwriting team email - * @returns {Promise} Object with success flag and emailRecipient + * @returns {Promise} Object with success flag and emailRecipient */ const send = async (application: Application, xlsxPath: string): Promise => { try { const { referenceNumber, owner, company, buyer, policy, policyContact } = application; - // generate email variables + const { requestedStartDate } = policy; + const { email } = owner; - // shared variables for sending email + /** + * Shared email variables for all emails + */ const sharedEmailVars = { referenceNumber, buyerName: replaceCharacterCodesWithCharacters(String(buyer.companyOrOrganisationName)), buyerLocation: buyer.country?.name, companyName: replaceCharacterCodesWithCharacters(company.companyName), - requestedStartDate: formatDate(policy.requestedStartDate), + requestedStartDate: formatDate(requestedStartDate), }; /** * Email variables for sending email to: - * the application owner of application + * the owner of the application */ const sendOwnerEmailVars = { ...sharedEmailVars, - buyerName: replaceCharacterCodesWithCharacters(String(buyer.companyOrOrganisationName)), name: replaceCharacterCodesWithCharacters(getFullNameString(owner)), emailAddress: email, } as ApplicationSubmissionEmailVariables; @@ -45,14 +47,13 @@ const send = async (application: Application, xlsxPath: string): Promise { - const mockSheetName = 'mock sheet name'; + const { mockWorksheet, mockSheetName } = createMockWorksheet(); - const workbook = new ExcelJS.Workbook(); + describe('getAdditionalRowHeightIndexes', () => { + describe('when a provided sheetName is in XLSX_ROW_INDEXES', () => { + it('should return index values', () => { + const result = getAdditionalRowHeightIndexes(mockApplication, mockSheetName); - const worksheet = workbook.addWorksheet(mockSheetName); + const sheetIndexes = XLSX_ROW_INDEXES[mockSheetName](mockApplication); - describe('worksheetRowHeights', () => { - it('should add column heights to particular columns', async () => { - const mockIndexes = [5, 6]; + const expected = Object.values(sheetIndexes); - const result = worksheetRowHeights(mockIndexes, worksheet); + expect(result).toEqual(expected); + }); + }); - result.eachRow((row, rowNumber) => { - if (rowNumber === 1) { - expect(row.height).toEqual(ADDITIONAL_TITLE_COLUMN_HEIGHT); - } else if (mockIndexes.includes(rowNumber)) { - expect(row.height).toEqual(LARGE_ADDITIONAL_COLUMN_HEIGHT); - } + describe('when a provided sheetName is NOT in XLSX_ROW_INDEXES', () => { + it('should return an empty array', () => { + const result = getAdditionalRowHeightIndexes(mockApplication, 'invalid sheet name'); + + expect(result).toEqual([]); }); }); }); describe('styledColumns', () => { - it('should add custom `alignment` and font size properties to each column', async () => { - const result = styledColumns(mockApplication, worksheet, mockSheetName); - - result.eachRow((row, rowNumber) => { - const isHeaderRow = rowNumber === 1; - - if (isHeaderRow) { - row.eachCell((cell, colNumber) => { - const cellData = row.getCell(colNumber); - - expect(cellData.font.bold).toEqual(true); - expect(cellData.font.size).toEqual(FONT_SIZE.TITLE); - }); - } else { - row.eachCell((cell, colNumber) => { - const cellData = row.getCell(colNumber); - - expect(cellData.font.bold).toEqual(false); - expect(cellData.font.size).toEqual(FONT_SIZE.DEFAULT); - }); - } - }); + it('should return a modified worksheet', async () => { + const result = styledColumns(mockApplication, mockWorksheet, mockSheetName); + + const modifiedRowStyles = modifyRowStyles(mockWorksheet, mockSheetName); + + const indexes = getAdditionalRowHeightIndexes(mockApplication, mockSheetName); + + const expected = modifyRowHeights(indexes, modifiedRowStyles, mockSheetName); + + expect(result).toEqual(expected); }); }); }); diff --git a/src/api/generate-xlsx/styled-columns/index.ts b/src/api/generate-xlsx/styled-columns/index.ts index c5c2419a67..cc813d121d 100644 --- a/src/api/generate-xlsx/styled-columns/index.ts +++ b/src/api/generate-xlsx/styled-columns/index.ts @@ -1,38 +1,29 @@ -import { Row, Worksheet } from 'exceljs'; -import { XLSX_CONFIG } from '../../constants'; +import { Worksheet } from 'exceljs'; import XLSX_ROW_INDEXES from '../../constants/XLSX-CONFIG/INDEXES'; -import SECTION_NAMES from '../../constants/XLSX-CONFIG/SECTION_NAMES'; +import modifyRowStyles from './modify-row-styles'; +import modifyRowHeights from './modify-row-heights'; import { Application } from '../../types'; -const { LARGE_ADDITIONAL_COLUMN_HEIGHT, ADDITIONAL_TITLE_COLUMN_HEIGHT, FONT_SIZE } = XLSX_CONFIG; - -const { APPLICATION_INFORMATION } = SECTION_NAMES; +// TODO: unit test for getAdditionalRowHeightIndexes /** - * worksheetRowHeights - * Add custom heights to certain worksheet cells - * @param {Array} rowIndexes: Row indexes - * @param {ExcelJS.Worksheet} worksheet: ExcelJS worksheet - * @param {String} ExcelJS sheetName: worksheet name - * @returns {ExcelJS.Worksheet} ExcelJS worksheet + * getAdditionalRowHeightIndexes + * Get some specific row indexes for the XLSX. + * These indexes are then used for styling purposes. + * @param {Application} application + * @param {String} sheetName: ExcelJS worksheet name + * @returns {Array} Row indexes */ -export const worksheetRowHeights = (rowIndexes: Array, worksheet: Worksheet, sheetName: string) => { - const modifiedWorksheet = worksheet; - - modifiedWorksheet.getRow(1).height = ADDITIONAL_TITLE_COLUMN_HEIGHT; +export const getAdditionalRowHeightIndexes = (application: Application, sheetName: string) => { + let INDEXES = [] as Array; - const isInformationSheet = sheetName === APPLICATION_INFORMATION; + if (XLSX_ROW_INDEXES[sheetName]) { + const sheetIndexes = XLSX_ROW_INDEXES[sheetName](application); - if (isInformationSheet) { - modifiedWorksheet.getRow(8).height = ADDITIONAL_TITLE_COLUMN_HEIGHT; - modifiedWorksheet.getRow(13).height = ADDITIONAL_TITLE_COLUMN_HEIGHT; + INDEXES = Object.values(sheetIndexes); } - rowIndexes.forEach((rowIndex) => { - modifiedWorksheet.getRow(rowIndex).height = LARGE_ADDITIONAL_COLUMN_HEIGHT; - }); - - return modifiedWorksheet; + return INDEXES; }; /** @@ -44,43 +35,13 @@ export const worksheetRowHeights = (rowIndexes: Array, worksheet: Worksh * @returns {ExcelJS.Worksheet} ExcelJS worksheet */ const styledColumns = (application: Application, worksheet: Worksheet, sheetName: string) => { - let modifiedWorksheet = worksheet; - - modifiedWorksheet.eachRow((row: Row, rowNumber: number) => { - row.eachCell((cell, colNumber) => { - const modifiedRow = row; + const withRowStyles = modifyRowStyles(worksheet, sheetName); - modifiedRow.getCell(colNumber).alignment = { - vertical: 'top', - wrapText: true, - }; - - const isInformationSheet = sheetName === APPLICATION_INFORMATION; - const isInformationTitleOne = isInformationSheet && rowNumber === 8; - const isInformationTitleTwo = isInformationSheet && rowNumber === 13; - - const isInformationTitle = isInformationTitleOne || isInformationTitleTwo; - - const isTitleRow = rowNumber === 1 || isInformationTitle; - - modifiedRow.getCell(colNumber).font = { - bold: Boolean(isTitleRow), - size: isTitleRow ? FONT_SIZE.TITLE : FONT_SIZE.DEFAULT, - }; - }); - }); - - let INDEXES = [] as Array; - - if (XLSX_ROW_INDEXES[sheetName]) { - const sheetIndexes = XLSX_ROW_INDEXES[sheetName](application); - - INDEXES = Object.values(sheetIndexes); - } + const indexes = getAdditionalRowHeightIndexes(application, sheetName); - modifiedWorksheet = worksheetRowHeights(INDEXES, modifiedWorksheet, sheetName); + const withRowHeights = modifyRowHeights(indexes, withRowStyles, sheetName); - return modifiedWorksheet; + return withRowHeights; }; export default styledColumns; diff --git a/src/api/generate-xlsx/styled-columns/is-title-row/index.test.ts b/src/api/generate-xlsx/styled-columns/is-title-row/index.test.ts new file mode 100644 index 0000000000..b2d699a252 --- /dev/null +++ b/src/api/generate-xlsx/styled-columns/is-title-row/index.test.ts @@ -0,0 +1,56 @@ +import isTitleRow from '.'; +import SECTION_NAMES from '../../../constants/XLSX-CONFIG/SECTION_NAMES'; +import APPLICATION_INFORMATION_INDEXES from '../../../constants/XLSX-CONFIG/INDEXES/APPLICATION_INFORMATION'; + +const { APPLICATION_INFORMATION } = SECTION_NAMES; +const { EXPORTER_CONTACT_DETAILS, KEY_INFORMATION } = APPLICATION_INFORMATION_INDEXES; + +describe('api/generate-xlsx/styled-columns/is-title-row', () => { + describe(`when the sheetName is ${APPLICATION_INFORMATION}`, () => { + const mockSheetName = APPLICATION_INFORMATION; + + describe(`when rowNumber=${EXPORTER_CONTACT_DETAILS}`, () => { + it('should return true', () => { + const result = isTitleRow(mockSheetName, EXPORTER_CONTACT_DETAILS); + + expect(result).toEqual(true); + }); + }); + + describe(`when rowNumber=${KEY_INFORMATION}`, () => { + it('should return true', () => { + const result = isTitleRow(mockSheetName, KEY_INFORMATION); + + expect(result).toEqual(true); + }); + }); + + describe('when rowNumber is NOT 8 or 13', () => { + it('should return false', () => { + const result = isTitleRow(mockSheetName, 5); + + expect(result).toEqual(false); + }); + }); + }); + + describe(`when the sheetName is NOT ${APPLICATION_INFORMATION}`, () => { + const mockSheetName = 'Mock sheet name'; + + describe('when rowNumber=1', () => { + it('should return true', () => { + const result = isTitleRow(mockSheetName, 1); + + expect(result).toEqual(true); + }); + }); + + describe('when rowNumber is NOT 1', () => { + it('should return false', () => { + const result = isTitleRow(mockSheetName, 5); + + expect(result).toEqual(false); + }); + }); + }); +}); diff --git a/src/api/generate-xlsx/styled-columns/is-title-row/index.ts b/src/api/generate-xlsx/styled-columns/is-title-row/index.ts new file mode 100644 index 0000000000..1596a4e2d9 --- /dev/null +++ b/src/api/generate-xlsx/styled-columns/is-title-row/index.ts @@ -0,0 +1,24 @@ +import SECTION_NAMES from '../../../constants/XLSX-CONFIG/SECTION_NAMES'; +import APPLICATION_INFORMATION_INDEXES from '../../../constants/XLSX-CONFIG/INDEXES/APPLICATION_INFORMATION'; + +const { APPLICATION_INFORMATION } = SECTION_NAMES; +const { EXPORTER_CONTACT_DETAILS, KEY_INFORMATION } = APPLICATION_INFORMATION_INDEXES; + +/** + * isTitleRow + * Check if a row is a title row. + * @param {String} sheetName: ExcelJS worksheet name + * @param {Integer} rowNumber: Row number + * @returns {Boolean} + */ +const isTitleRow = (sheetName: string, rowNumber: number) => { + const isInfoSheet = sheetName === APPLICATION_INFORMATION; + + const isInfoTitle = isInfoSheet && (rowNumber === EXPORTER_CONTACT_DETAILS || rowNumber === KEY_INFORMATION); + + const result = rowNumber === 1 || isInfoTitle; + + return result; +}; + +export default isTitleRow; diff --git a/src/api/generate-xlsx/styled-columns/modify-row-heights/index.test.ts b/src/api/generate-xlsx/styled-columns/modify-row-heights/index.test.ts new file mode 100644 index 0000000000..98c757181e --- /dev/null +++ b/src/api/generate-xlsx/styled-columns/modify-row-heights/index.test.ts @@ -0,0 +1,41 @@ +import modifyRowHeights from '.'; +import { XLSX_CONFIG } from '../../../constants'; +import SECTION_NAMES from '../../../constants/XLSX-CONFIG/SECTION_NAMES'; +import APPLICATION_INFORMATION_INDEXES from '../../../constants/XLSX-CONFIG/INDEXES/APPLICATION_INFORMATION'; +import createMockWorksheet from '../../../test-mocks/create-mock-worksheet'; + +const { LARGE_ADDITIONAL_COLUMN_HEIGHT, ADDITIONAL_TITLE_COLUMN_HEIGHT } = XLSX_CONFIG; + +const { APPLICATION_INFORMATION } = SECTION_NAMES; + +const { EXPORTER_CONTACT_DETAILS, KEY_INFORMATION } = APPLICATION_INFORMATION_INDEXES; + +describe('api/generate-xlsx/styled-columns/modify-row-heights', () => { + const { mockWorksheet } = createMockWorksheet(); + + const mockSheetName = APPLICATION_INFORMATION; + + it('should add column heights to particular columns', async () => { + const mockIndexes = [5, 6]; + + const result = modifyRowHeights(mockIndexes, mockWorksheet, mockSheetName); + + result.eachRow((row, rowNumber) => { + if (rowNumber === 1) { + expect(row.height).toEqual(ADDITIONAL_TITLE_COLUMN_HEIGHT); + } + + if (rowNumber === EXPORTER_CONTACT_DETAILS) { + expect(row.height).toEqual(ADDITIONAL_TITLE_COLUMN_HEIGHT); + } + + if (rowNumber === KEY_INFORMATION) { + expect(row.height).toEqual(ADDITIONAL_TITLE_COLUMN_HEIGHT); + } + + if (mockIndexes.includes(rowNumber)) { + expect(row.height).toEqual(LARGE_ADDITIONAL_COLUMN_HEIGHT); + } + }); + }); +}); diff --git a/src/api/generate-xlsx/styled-columns/modify-row-heights/index.ts b/src/api/generate-xlsx/styled-columns/modify-row-heights/index.ts new file mode 100644 index 0000000000..645b9ef62c --- /dev/null +++ b/src/api/generate-xlsx/styled-columns/modify-row-heights/index.ts @@ -0,0 +1,37 @@ +import { Worksheet } from 'exceljs'; +import { XLSX_CONFIG } from '../../../constants'; +import SECTION_NAMES from '../../../constants/XLSX-CONFIG/SECTION_NAMES'; +import APPLICATION_INFORMATION_INDEXES from '../../../constants/XLSX-CONFIG/INDEXES/APPLICATION_INFORMATION'; + +const { LARGE_ADDITIONAL_COLUMN_HEIGHT, ADDITIONAL_TITLE_COLUMN_HEIGHT } = XLSX_CONFIG; + +const { APPLICATION_INFORMATION } = SECTION_NAMES; + +const { EXPORTER_CONTACT_DETAILS, KEY_INFORMATION } = APPLICATION_INFORMATION_INDEXES; + +/** + * modifyRowHeights + * Add custom heights to certain worksheet rows + * @param {Array} rowIndexes: Row indexes + * @param {ExcelJS.Worksheet} worksheet: ExcelJS worksheet + * @param {String} ExcelJS sheetName: worksheet name + * @returns {ExcelJS.Worksheet} Modified ExcelJS worksheet + */ +const modifyRowHeights = (rowIndexes: Array, worksheet: Worksheet, sheetName: string) => { + const modifiedWorksheet = worksheet; + + modifiedWorksheet.getRow(1).height = ADDITIONAL_TITLE_COLUMN_HEIGHT; + + if (sheetName === APPLICATION_INFORMATION) { + modifiedWorksheet.getRow(EXPORTER_CONTACT_DETAILS).height = ADDITIONAL_TITLE_COLUMN_HEIGHT; + modifiedWorksheet.getRow(KEY_INFORMATION).height = ADDITIONAL_TITLE_COLUMN_HEIGHT; + } + + rowIndexes.forEach((rowIndex) => { + modifiedWorksheet.getRow(rowIndex).height = LARGE_ADDITIONAL_COLUMN_HEIGHT; + }); + + return modifiedWorksheet; +}; + +export default modifyRowHeights; diff --git a/src/api/generate-xlsx/styled-columns/modify-row-styles/index.test.ts b/src/api/generate-xlsx/styled-columns/modify-row-styles/index.test.ts new file mode 100644 index 0000000000..d2c6d1f2f6 --- /dev/null +++ b/src/api/generate-xlsx/styled-columns/modify-row-styles/index.test.ts @@ -0,0 +1,34 @@ +import modifyRowStyles from '.'; +import { XLSX_CONFIG } from '../../../constants'; +import isTitleRow from '../is-title-row'; +import createMockWorksheet from '../../../test-mocks/create-mock-worksheet'; + +const { FONT_SIZE } = XLSX_CONFIG; + +describe('api/generate-xlsx/styled-columns/modify-row-styles', () => { + const { mockWorksheet, mockSheetName } = createMockWorksheet(); + + it('should add custom `alignment` and font size properties to each column', async () => { + const result = modifyRowStyles(mockWorksheet, mockSheetName); + + result.eachRow((row, rowNumber) => { + const isATitleRow = isTitleRow(mockSheetName, rowNumber); + + if (isATitleRow) { + row.eachCell((cell, colNumber) => { + const cellData = row.getCell(colNumber); + + expect(cellData.font.bold).toEqual(true); + expect(cellData.font.size).toEqual(FONT_SIZE.TITLE); + }); + } else { + row.eachCell((cell, colNumber) => { + const cellData = row.getCell(colNumber); + + expect(cellData.font.bold).toEqual(false); + expect(cellData.font.size).toEqual(FONT_SIZE.DEFAULT); + }); + } + }); + }); +}); diff --git a/src/api/generate-xlsx/styled-columns/modify-row-styles/index.ts b/src/api/generate-xlsx/styled-columns/modify-row-styles/index.ts new file mode 100644 index 0000000000..d2b25900fc --- /dev/null +++ b/src/api/generate-xlsx/styled-columns/modify-row-styles/index.ts @@ -0,0 +1,36 @@ +import { Row, Worksheet } from 'exceljs'; +import { XLSX_CONFIG } from '../../../constants'; +import isTitleRow from '../is-title-row'; + +const { FONT_SIZE } = XLSX_CONFIG; + +/** + * modifyRowStyles + * Add row styles to certain worksheet rows + * @param {ExcelJS.Worksheet} worksheet: ExcelJS worksheet + * @param {String} ExcelJS sheetName: worksheet name + * @returns {ExcelJS.Worksheet} Modified ExcelJS worksheet + */ +const modifyRowStyles = (worksheet: Worksheet, sheetName: string) => { + worksheet.eachRow((row: Row, rowNumber: number) => { + row.eachCell((cell, colNumber) => { + const modifiedRow = row; + + modifiedRow.getCell(colNumber).alignment = { + vertical: 'top', + wrapText: true, + }; + + const isATitleRow = isTitleRow(sheetName, rowNumber); + + modifiedRow.getCell(colNumber).font = { + bold: isATitleRow, + size: isATitleRow ? FONT_SIZE.TITLE : FONT_SIZE.DEFAULT, + }; + }); + }); + + return worksheet; +}; + +export default modifyRowStyles; diff --git a/src/api/helpers/get-APIM-CIS-countries/index.test.ts b/src/api/helpers/get-APIM-CIS-countries/index.test.ts new file mode 100644 index 0000000000..08254161cb --- /dev/null +++ b/src/api/helpers/get-APIM-CIS-countries/index.test.ts @@ -0,0 +1,74 @@ +import apimCisCountries from '.'; +import APIM from '../../integrations/APIM'; +import mapCisCountries from '../map-CIS-countries'; +import mockCisCountriesResponse from '../../test-mocks/mock-APIM-CIS-countries-response'; +import { mockCisCountries, mockErrorMessage, mockSpyPromiseRejection } from '../../test-mocks'; + +describe('helpers/get-APIM-CIS-countries', () => { + jest.mock('../../integrations/APIM'); + + afterAll(() => { + jest.resetAllMocks(); + }); + + describe('when APIM CIS API returns success with data/countries', () => { + beforeEach(() => { + APIM.getCisCountries = jest.fn(() => Promise.resolve(mockCisCountriesResponse)); + }); + + it('should return mapped countries', async () => { + const response = await apimCisCountries.get(); + + const expected = { + success: true, + countries: mapCisCountries(mockCisCountries), + }; + + expect(response).toEqual(expected); + }); + }); + + describe('when APIM CIS API returns success=false', () => { + beforeEach(() => { + APIM.getCisCountries = jest.fn(() => Promise.resolve({ success: false })); + }); + + it('should return an object containing success=false', async () => { + const response = await apimCisCountries.get(); + + const expected = { success: false }; + + expect(response).toEqual(expected); + }); + }); + + describe('when APIM CIS API returns an empty data object', () => { + beforeEach(() => { + APIM.getCisCountries = jest.fn(() => Promise.resolve({ success: true, data: undefined })); + }); + + it('should return an object containing success=false', async () => { + const response = await apimCisCountries.get(); + + const expected = { success: false }; + + expect(response).toEqual(expected); + }); + }); + + describe('when APIM CIS API is down', () => { + beforeEach(() => { + APIM.getCisCountries = mockSpyPromiseRejection; + }); + + it('should throw an error', async () => { + try { + await apimCisCountries.get(); + } catch (error) { + const expected = new Error(`Getting and mapping CIS countries from APIM (apimCisCountries helper) ${new Error(mockErrorMessage)}`); + + expect(error).toEqual(expected); + } + }); + }); +}); diff --git a/src/api/helpers/get-APIM-CIS-countries/index.ts b/src/api/helpers/get-APIM-CIS-countries/index.ts new file mode 100644 index 0000000000..153bde1c8e --- /dev/null +++ b/src/api/helpers/get-APIM-CIS-countries/index.ts @@ -0,0 +1,37 @@ +import APIM from '../../integrations/APIM'; +import mapCisCountries from '../map-CIS-countries'; +import { GetApimCisCountriesHelperResponse } from '../../types'; + +/** + * get + * Get and map countries from APIM + * @returns {Promise} + */ +const get = async (): Promise => { + try { + console.info('Getting and mapping CIS countries from APIM (apimCisCountries helper)'); + + const response = await APIM.getCisCountries(); + + if (response.data) { + const mapped = mapCisCountries(response.data); + + return { + success: true, + countries: mapped, + } as GetApimCisCountriesHelperResponse; + } + + return { success: false }; + } catch (error) { + console.error('Error Getting and mapping CIS countries from APIM (apimCisCountries helper) %o', error); + + throw new Error(`Getting and mapping CIS countries from APIM (apimCisCountries helper) ${error}`); + } +}; + +const apimCisCountries = { + get, +}; + +export default apimCisCountries; diff --git a/src/api/helpers/get-APIM-currencies-exchange-rate/index.test.ts b/src/api/helpers/get-APIM-currencies-exchange-rate/index.test.ts new file mode 100644 index 0000000000..eabe4479a1 --- /dev/null +++ b/src/api/helpers/get-APIM-currencies-exchange-rate/index.test.ts @@ -0,0 +1,78 @@ +import apimCurrencyExchangeRate from '.'; +import { GBP, USD } from '../../constants'; +import APIM from '../../integrations/APIM'; +import mockApimCurrenciesExchangeResponse, { mockCurrencyExchange } from '../../test-mocks/mock-APIM-currencies-exchange-response'; +import { mockErrorMessage, mockSpyPromiseRejection } from '../../test-mocks'; + +const mockSource = GBP; +const mockTarget = USD; + +describe('custom-resolvers/get-APIM-currencies-exchange-rate', () => { + jest.mock('../../integrations/APIM'); + + afterAll(() => { + jest.resetAllMocks(); + }); + + describe('when APIM currencies exchange API returns success with data/currencies', () => { + beforeEach(() => { + APIM.getCurrenciesExchange = jest.fn(() => Promise.resolve(mockApimCurrenciesExchangeResponse)); + }); + + describe(`when the provided source is ${GBP}`, () => { + it('should return an exchange rate ', async () => { + const response = await apimCurrencyExchangeRate.get(GBP, mockTarget); + + const expected = mockCurrencyExchange.midPrice; + + expect(response).toEqual(expected); + }); + }); + + describe(`when the provided source is NOT ${GBP}`, () => { + it('should return an exchange rate ', async () => { + const response = await apimCurrencyExchangeRate.get(USD, mockTarget); + + const expected = Number(Number(1 / mockCurrencyExchange.midPrice).toFixed(2)); + + expect(response).toEqual(expected); + }); + }); + }); + + describe('when APIM currencies exchange API returns success=false', () => { + beforeEach(() => { + APIM.getCurrenciesExchange = jest.fn(() => Promise.resolve({ success: false })); + }); + + it('should return 0', async () => { + const response = await apimCurrencyExchangeRate.get(mockSource, mockTarget); + + expect(response).toEqual(0); + }); + }); + + describe('when APIM currencies exchange API returns an empty data object', () => { + beforeEach(() => { + APIM.getCurrenciesExchange = jest.fn(() => Promise.resolve({ success: true, data: undefined })); + }); + + it('should return 0', async () => { + const response = await apimCurrencyExchangeRate.get(mockSource, mockTarget); + + expect(response).toEqual(0); + }); + }); + + describe('when APIM currencies exchange API is down', () => { + beforeEach(() => { + APIM.getCurrenciesExchange = mockSpyPromiseRejection; + }); + + it('should throw an error', async () => { + await expect(apimCurrencyExchangeRate.get(mockSource, mockTarget)).rejects.toThrow( + `Getting currency exchange rate from APIM - %s to %s (getApimCurrencyExchangeRate helper) ${new Error(mockErrorMessage)}`, + ); + }); + }); +}); diff --git a/src/api/helpers/get-APIM-currencies-exchange-rate/index.ts b/src/api/helpers/get-APIM-currencies-exchange-rate/index.ts new file mode 100644 index 0000000000..39de7b20f5 --- /dev/null +++ b/src/api/helpers/get-APIM-currencies-exchange-rate/index.ts @@ -0,0 +1,48 @@ +import { GBP } from '../../constants'; +import APIM from '../../integrations/APIM'; + +/** + * get + * Get a currency exchange rate from APIM + * @param {String} source: Currency exchange rate source. + * @param {String} target: Currency exchange rate target. + * @returns {Promise} APIM response data + */ +const get = async (source: string, target: string): Promise => { + try { + console.info('Getting currency exchange rate from APIM - %s to %s (getApimCurrencyExchangeRate helper)', source, target); + + const response = await APIM.getCurrenciesExchange(source, target); + + if (response.success && response.data) { + const [currency] = response.data; + + const { midPrice: exchangeRate } = currency; + + /** + * NOTE: At the time of writing, + * APIM only supports the source as GBP or USD. + * Therefore, we have to do the following for e.g "NON-GBP => GBP" + */ + if (source !== GBP) { + const fixed = Number(1 / exchangeRate).toFixed(2); + + return Number(fixed); + } + + return exchangeRate; + } + + return 0; + } catch (error) { + console.error('Error Getting currency exchange rate from APIM - %s to %s (getApimCurrencyExchangeRate helper) %o', source, target, error); + + throw new Error(`Getting currency exchange rate from APIM - %s to %s (getApimCurrencyExchangeRate helper) ${error}`); + } +}; + +const apimCurrencyExchangeRate = { + get, +}; + +export default apimCurrencyExchangeRate; diff --git a/src/api/helpers/get-APIM-currencies/index.test.ts b/src/api/helpers/get-APIM-currencies/index.test.ts new file mode 100644 index 0000000000..17d30d8e46 --- /dev/null +++ b/src/api/helpers/get-APIM-currencies/index.test.ts @@ -0,0 +1,79 @@ +import apimCurrencies from '.'; +import APIM from '../../integrations/APIM'; +import mapCurrencies from '../map-currencies'; +import mockApimCurrenciesResponse from '../../test-mocks/mock-APIM-currencies-response'; +import { mockCurrencies, mockErrorMessage, mockSpyPromiseRejection } from '../../test-mocks'; + +describe('custom-resolvers/get-APIM-currencies', () => { + jest.mock('../../integrations/APIM'); + + afterAll(() => { + jest.resetAllMocks(); + }); + + describe('when APIM currencies API returns success with data/currencies', () => { + beforeEach(() => { + APIM.getCurrencies = jest.fn(() => Promise.resolve(mockApimCurrenciesResponse)); + }); + + it('should return an object with mapped currencies ', async () => { + const response = await apimCurrencies.get(); + + const mappedSupported = mapCurrencies(mockCurrencies, false); + const mappedAlternative = mapCurrencies(mockCurrencies, true); + + const expected = { + success: true, + supportedCurrencies: mappedSupported, + alternativeCurrencies: mappedAlternative, + allCurrencies: [...mappedSupported, ...mappedAlternative], + }; + + expect(response).toEqual(expected); + }); + }); + + describe('when APIM currencies API returns success=false', () => { + beforeEach(() => { + APIM.getCurrencies = jest.fn(() => Promise.resolve({ success: false })); + }); + + it('should return an object containing success=false', async () => { + const response = await apimCurrencies.get(); + + const expected = { success: false }; + + expect(response).toEqual(expected); + }); + }); + + describe('when APIM currencies API returns an empty data object', () => { + beforeEach(() => { + APIM.getCurrencies = jest.fn(() => Promise.resolve({ success: true, data: undefined })); + }); + + it('should return an object containing success=false', async () => { + const response = await apimCurrencies.get(); + + const expected = { success: false }; + + expect(response).toEqual(expected); + }); + }); + + describe('when APIM currencies API is down', () => { + beforeEach(() => { + APIM.getCurrencies = mockSpyPromiseRejection; + }); + + it('should throw an error', async () => { + try { + await apimCurrencies.get(); + } catch (error) { + const expected = new Error(`Getting and mapping currencies from APIM (apimCurrencies helper) ${new Error(mockErrorMessage)}`); + + expect(error).toEqual(expected); + } + }); + }); +}); diff --git a/src/api/helpers/get-APIM-currencies/index.ts b/src/api/helpers/get-APIM-currencies/index.ts new file mode 100644 index 0000000000..8c323b52b0 --- /dev/null +++ b/src/api/helpers/get-APIM-currencies/index.ts @@ -0,0 +1,41 @@ +import APIM from '../../integrations/APIM'; +import mapCurrencies from '../map-currencies'; +import { GetApimCurrenciesHelperResponse } from '../../types'; + +/** + * get + * Get and map currencies from APIM + * @returns {Promise} APIM response data + */ +const get = async (): Promise => { + try { + console.info('Getting and mapping currencies from APIM (apimCurrencies helper)'); + + const response = await APIM.getCurrencies(); + + if (response.data) { + const supportedCurrencies = mapCurrencies(response.data, false); + const alternativeCurrencies = mapCurrencies(response.data, true); + const allCurrencies = [...supportedCurrencies, ...alternativeCurrencies]; + + return { + success: true, + supportedCurrencies, + alternativeCurrencies, + allCurrencies, + } as GetApimCurrenciesHelperResponse; + } + + return { success: false }; + } catch (error) { + console.error('Error Getting and mapping currencies from APIM (apimCurrencies helper) %o', error); + + throw new Error(`Getting and mapping currencies from APIM (apimCurrencies helper) ${error}`); + } +}; + +const apimCurrencies = { + get, +}; + +export default apimCurrencies; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts index bfa53a4be2..4a1a6846c4 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.test.ts @@ -7,44 +7,44 @@ const { }, } = EXTERNAL_API_DEFINITIONS; -const mockRiskCategory = VERY_HIGH; +const mockEsraClassification = VERY_HIGH; describe('helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online', () => { - describe('when a country has a riskCategory and shortTermCover of true', () => { + describe('when shortTermCover=true, esraClassification is provided', () => { it('should return true', () => { - const shortTermCover = true; - - const result = canApplyForInsuranceOnline(shortTermCover, mockRiskCategory); + const result = canApplyForInsuranceOnline(true, mockEsraClassification); expect(result).toEqual(true); }); }); - describe('when a country has a riskCategory and shortTermCover is false', () => { + describe('when shortTermCover=false, esraClassification is null', () => { it('should return false', () => { - const shortTermCover = false; - - const result = canApplyForInsuranceOnline(shortTermCover, mockRiskCategory); + const result = canApplyForInsuranceOnline(false, null); expect(result).toEqual(false); }); }); - describe('when a country does not have a riskCategory and shortTermCover of true', () => { + describe('when shortTermCover=false, esraClassification is an empty string', () => { it('should return false', () => { - const shortTermCover = true; - - const result = canApplyForInsuranceOnline(shortTermCover); + const result = canApplyForInsuranceOnline(false, ''); expect(result).toEqual(false); }); }); - describe('when a country does not have a riskCategory and shortTermCover is false', () => { + describe('when shortTermCover=true, esraClassification is null', () => { it('should return false', () => { - const shortTermCover = false; + const result = canApplyForInsuranceOnline(true, null); + + expect(result).toEqual(false); + }); + }); - const result = canApplyForInsuranceOnline(shortTermCover); + describe('when shortTermCover=true, esraClassification is an empty string', () => { + it('should return false', () => { + const result = canApplyForInsuranceOnline(true, ''); expect(result).toEqual(false); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts index ce27d98dd0..d7197c0af2 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-apply-for-insurance-online/index.ts @@ -9,12 +9,12 @@ * - CILC * - Refer * - Unlisted - * @param {Boolean} shortTermCover: Boolean value of shortTermCover. - * @param {String} riskCategory: Country risk category. + * @param {Boolean} shortTermCover: Short term cover flag. + * @param {String} esraClassification: ESRA classification. * @returns {Boolean} */ -export const canApplyForInsuranceOnline = (shortTermCover: boolean, riskCategory?: string) => { - if (riskCategory && shortTermCover) { +const canApplyForInsuranceOnline = (shortTermCover: boolean, esraClassification: string | null) => { + if (shortTermCover && esraClassification) { return true; } diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.test.ts index ff57cb7bf4..8514fb7e28 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.test.ts @@ -1,62 +1,48 @@ import canGetAQuoteByEmail from '.'; import { EXTERNAL_API_MAPPINGS } from '../../../../constants'; -import mockCountries from '../../../../test-mocks/mock-countries'; -import { MappedCisCountry } from '../../../../types'; const { CIS: { RISK }, } = EXTERNAL_API_MAPPINGS; -const validMockCountry = { - ...mockCountries[0], - riskCategory: RISK.STANDARD, - shortTermCover: true, - nbiIssueAvailable: false, -} as MappedCisCountry; +const mockEsraClassification = RISK.STANDARD; describe('helpers/map-cis-countries/map-cis-country/can-get-a-quote-by-email', () => { - describe('when a country has true riskCategory, shortTermCover and no nbiIssueAvailable', () => { + describe('when shortTermCover=true, nbiIssueAvailable=false, esraClassification is provided', () => { it('should return true', () => { - const result = canGetAQuoteByEmail(validMockCountry); + const result = canGetAQuoteByEmail({ shortTermCover: true, nbiIssueAvailable: false, esraClassification: mockEsraClassification }); expect(result).toEqual(true); }); }); - describe('when a country does not have riskCategory', () => { + describe('when shortTermCover=true, nbiIssueAvailable=false, esraClassification is null', () => { it('should return false', () => { - const mockCountry = { - ...validMockCountry, - riskCategory: undefined, - } as MappedCisCountry; - - const result = canGetAQuoteByEmail(mockCountry); + const result = canGetAQuoteByEmail({ shortTermCover: true, nbiIssueAvailable: false, esraClassification: null }); expect(result).toEqual(false); }); }); - describe('when a country does not have shortTermCover', () => { + describe('when shortTermCover=true, nbiIssueAvailable=false, esraClassification is an empty string', () => { it('should return false', () => { - const mockCountry = { - ...validMockCountry, - shortTermCover: false, - } as MappedCisCountry; - - const result = canGetAQuoteByEmail(mockCountry); + const result = canGetAQuoteByEmail({ shortTermCover: true, nbiIssueAvailable: false, esraClassification: '' }); expect(result).toEqual(false); }); }); - describe('when a country has nbiIssueAvailable', () => { + describe('when shortTermCover=false, nbiIssueAvailable=false, esraClassification is provided', () => { it('should return false', () => { - const mockCountry = { - ...validMockCountry, - nbiIssueAvailable: true, - } as MappedCisCountry; + const result = canGetAQuoteByEmail({ shortTermCover: false, nbiIssueAvailable: false, esraClassification: mockEsraClassification }); - const result = canGetAQuoteByEmail(mockCountry); + expect(result).toEqual(false); + }); + }); + + describe('when shortTermCover=true, nbiIssueAvailable=true, esraClassification is provided', () => { + it('should return false', () => { + const result = canGetAQuoteByEmail({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: mockEsraClassification }); expect(result).toEqual(false); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts index a856b562aa..77d3366588 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-by-email/index.ts @@ -1,13 +1,16 @@ -import { MappedCisCountry } from '../../../../types'; +import { MapCisCountryParams } from '../../../../types'; /** * canGetAQuoteByEmail * Check if a country is able to get a quote by email - * @param {MappedCisCountry} Mapped CIS Country + * @param {MapCisCountryParams} + * @param {Boolean} shortTermCover: Short term cover flag. + * @param {Boolean} nbiIssueAvailable: NBI flag. + * @param {String} esraClassification: ESRA classification. * @returns {Boolean} */ -export const canGetAQuoteByEmail = (country: MappedCisCountry) => { - if (country.riskCategory && country.shortTermCover && !country.nbiIssueAvailable) { +const canGetAQuoteByEmail = ({ shortTermCover, nbiIssueAvailable, esraClassification }: MapCisCountryParams) => { + if (shortTermCover && !nbiIssueAvailable && esraClassification) { return true; } diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.test.ts index 2d01411acc..7329eea7cd 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.test.ts @@ -1,62 +1,48 @@ import canGetAQuoteOnline from '.'; import { EXTERNAL_API_MAPPINGS } from '../../../../constants'; -import mockCountries from '../../../../test-mocks/mock-countries'; -import { MappedCisCountry } from '../../../../types'; const { CIS: { RISK }, } = EXTERNAL_API_MAPPINGS; -const validMockCountry = { - ...mockCountries[0], - riskCategory: RISK.STANDARD, - shortTermCover: true, - nbiIssueAvailable: true, -} as MappedCisCountry; +const mockEsraClassification = RISK.STANDARD; describe('helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online', () => { - describe('when a country has true riskCategory, shortTermCover and nbiIssueAvailable', () => { + describe('when shortTermCover=true, nbiIssueAvailable=true, esraClassification is provided', () => { it('should return true', () => { - const result = canGetAQuoteOnline(validMockCountry); + const result = canGetAQuoteOnline({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: mockEsraClassification }); expect(result).toEqual(true); }); }); - describe('when a country does not have riskCategory', () => { + describe('when shortTermCover=true, nbiIssueAvailable=true, esraClassification is null', () => { it('should return false', () => { - const mockCountry = { - ...validMockCountry, - riskCategory: undefined, - } as MappedCisCountry; - - const result = canGetAQuoteOnline(mockCountry); + const result = canGetAQuoteOnline({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: null }); expect(result).toEqual(false); }); }); - describe('when a country does not have shortTermCover', () => { + describe('when shortTermCover=true, nbiIssueAvailable=true, esraClassification is an empty string', () => { it('should return false', () => { - const mockCountry = { - ...validMockCountry, - shortTermCover: false, - } as MappedCisCountry; - - const result = canGetAQuoteOnline(mockCountry); + const result = canGetAQuoteOnline({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: '' }); expect(result).toEqual(false); }); }); - describe('when a country does not have nbiIssueAvailable', () => { + describe('when shortTermCover=false, nbiIssueAvailable=true, esraClassification is provided', () => { it('should return false', () => { - const mockCountry = { - ...validMockCountry, - nbiIssueAvailable: false, - } as MappedCisCountry; + const result = canGetAQuoteOnline({ shortTermCover: false, nbiIssueAvailable: true, esraClassification: mockEsraClassification }); - const result = canGetAQuoteOnline(mockCountry); + expect(result).toEqual(false); + }); + }); + + describe('when shortTermCover=true, nbiIssueAvailable=false, esraClassification is provided', () => { + it('should return false', () => { + const result = canGetAQuoteOnline({ shortTermCover: true, nbiIssueAvailable: false, esraClassification: mockEsraClassification }); expect(result).toEqual(false); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts index 82f540bcc8..1bc5e7d721 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/can-get-a-quote-online/index.ts @@ -1,13 +1,16 @@ -import { MappedCisCountry } from '../../../../types'; +import { MapCisCountryParams } from '../../../../types'; /** * canGetAQuoteOnline * Check if a country is able to get a quote online - * @param {MappedCisCountry} Mapped CIS Country + * @param {MapCisCountryParams} + * @param {Boolean} shortTermCover: Short term cover flag. + * @param {Boolean} nbiIssueAvailable: NBI flag. + * @param {String} esraClassification: ESRA classification. * @returns {Boolean} */ -export const canGetAQuoteOnline = (country: MappedCisCountry) => { - if (country.riskCategory && country.shortTermCover && country.nbiIssueAvailable) { +const canGetAQuoteOnline = ({ shortTermCover, nbiIssueAvailable, esraClassification }: MapCisCountryParams) => { + if (esraClassification && shortTermCover && nbiIssueAvailable) { return true; } diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.test.ts index dd592d9d1e..3e879fb932 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.test.ts @@ -1,57 +1,32 @@ import cannotGetAQuote from '.'; -import mockCountries from '../../../../test-mocks/mock-countries'; -import { MappedCisCountry } from '../../../../types'; +import { EXTERNAL_API_MAPPINGS } from '../../../../constants'; -const mockCountryCannotGetAQuote = { - ...mockCountries[0], - shortTermCover: false, - nbiIssueAvailable: false, -} as MappedCisCountry; +const { + CIS: { RISK }, +} = EXTERNAL_API_MAPPINGS; -describe('helpers/map-cis-countries/map-cis-country/cannot-get-a-quote', () => { - describe('when country does not have riskCategory, shortTermCover and nbiIssueAvailable', () => { - it('should return true', () => { - const result = cannotGetAQuote(mockCountryCannotGetAQuote); +const mockEsraClassification = RISK.STANDARD; - expect(result).toEqual(true); - }); - }); - - describe('when country does not have riskCategory, but has shortTermCover and nbiIssueAvailable', () => { +describe('helpers/map-cis-countries/map-cis-country/cannot-get-a-quote', () => { + describe('when country has shortTermCover=false, nbiIssueAvailable=false and no esraClassification', () => { it('should return true', () => { - const mockCountry = { - ...mockCountryCannotGetAQuote, - shortTermCover: true, - nbiIssueAvailable: true, - }; - const result = cannotGetAQuote(mockCountry); + const result = cannotGetAQuote({ shortTermCover: false, nbiIssueAvailable: false, esraClassification: null }); expect(result).toEqual(true); }); }); - describe('when country has riskCategory, but not shortTermCover and nbiIssueAvailable', () => { + describe('when country has shortTermCover=false, nbiIssueAvailable=false and has a esraClassification', () => { it('should return true', () => { - const mockCountry = { - ...mockCountryCannotGetAQuote, - riskCategory: 'Mock', - }; - const result = cannotGetAQuote(mockCountry); + const result = cannotGetAQuote({ shortTermCover: false, nbiIssueAvailable: false, esraClassification: mockEsraClassification }); expect(result).toEqual(true); }); }); - describe('when country has riskCategory, shortTermCover and nbiIssueAvailable', () => { + describe('when country has shortTermCover=true, nbiIssueAvailable=true and has a esraClassification', () => { it('should return false', () => { - const mockCountry = { - ...mockCountryCannotGetAQuote, - riskCategory: 'Mock', - shortTermCover: true, - nbiIssueAvailable: true, - }; - - const result = cannotGetAQuote(mockCountry); + const result = cannotGetAQuote({ shortTermCover: true, nbiIssueAvailable: true, esraClassification: mockEsraClassification }); expect(result).toEqual(false); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts index 175898f568..d2b37edd89 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/cannot-get-a-quote/index.ts @@ -1,13 +1,16 @@ -import { MappedCisCountry } from '../../../../types'; +import { MapCisCountryParams } from '../../../../types'; /** * cannotGetAQuote * Check if a country cannot get a quote online or offline - * @param {MappedCisCountry} Country from CIS API + * @param {MapCisCountryParams} + * @param {Boolean} shortTermCover: Short term cover flag. + * @param {Boolean} nbiIssueAvailable: NBI flag. + * @param {String} esraClassification: ESRA classification. * @returns {Boolean} */ -export const cannotGetAQuote = (country: MappedCisCountry) => { - if (!country.riskCategory || (!country.shortTermCover && !country.nbiIssueAvailable)) { +const cannotGetAQuote = ({ shortTermCover, nbiIssueAvailable, esraClassification }: MapCisCountryParams) => { + if (!esraClassification || (!shortTermCover && !nbiIssueAvailable)) { return true; } diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts index 7b8c318ebd..c891e56b48 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.test.ts @@ -1,11 +1,11 @@ import mapCisCountry from '.'; -import mapRiskCategory from './map-risk-category'; +import mapEsraClassification from './map-esra-classification'; import mapShortTermCoverAvailable from './map-short-term-cover-available'; import mapNbiIssueAvailable from './map-NBI-issue-available'; import canGetAQuoteOnline from './can-get-a-quote-online'; import canGetAQuoteByEmail from './can-get-a-quote-by-email'; import cannotGetAQuote from './cannot-get-a-quote'; -import applyForInsuranceOnline from './can-apply-for-insurance-online'; +import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; import canApplyOffline from './can-apply-offline'; import noInsuranceSupportAvailable from './no-insurance-support'; import { EXTERNAL_API_DEFINITIONS, EXTERNAL_API_MAPPINGS } from '../../../constants'; @@ -20,7 +20,7 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { const mockCountryBase = { ...initialMockCountry, marketName: initialMockCountry.marketName, - riskCategory: EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD, + esraClassification: EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD, isoCode: initialMockCountry.isoCode, shortTermCoverAvailabilityDesc: CIS.SHORT_TERM_COVER_AVAILABLE.ILC, marketRiskAppetitePublicDesc: CIS.NO_COVER, @@ -29,26 +29,29 @@ describe('helpers/map-CIS-countries/map-CIS-country', () => { it('should return an object', () => { const result = mapCisCountry(mockCountryBase); + const esraClassification = mapEsraClassification(mockCountryBase.ESRAClassificationDesc); + const shortTermCover = mapShortTermCoverAvailable(mockCountryBase.shortTermCoverAvailabilityDesc); + const nbiIssueAvailable = mapNbiIssueAvailable(mockCountryBase.NBIIssue); + const mapped = { name: mockCountryBase.marketName, isoCode: mockCountryBase.isoCode, - riskCategory: mapRiskCategory(mockCountryBase.ESRAClassificationDesc), - shortTermCover: mapShortTermCoverAvailable(mockCountryBase.shortTermCoverAvailabilityDesc), - nbiIssueAvailable: mapNbiIssueAvailable(mockCountryBase.NBIIssue), + esraClassification, + shortTermCover, + nbiIssueAvailable, canGetAQuoteOnline: false, canGetAQuoteOffline: false, canGetAQuoteByEmail: false, cannotGetAQuote: false, - canApplyForInsuranceOnline: false, noInsuranceSupport: false, } as MappedCisCountry; - mapped.canGetAQuoteOnline = canGetAQuoteOnline(mapped); + mapped.canGetAQuoteOnline = canGetAQuoteOnline({ shortTermCover, nbiIssueAvailable, esraClassification }); mapped.canGetAQuoteOffline = canApplyOffline(mockCountryBase.shortTermCoverAvailabilityDesc); - mapped.canGetAQuoteByEmail = canGetAQuoteByEmail(mapped); - mapped.cannotGetAQuote = cannotGetAQuote(mapped); + mapped.canGetAQuoteByEmail = canGetAQuoteByEmail({ shortTermCover, nbiIssueAvailable, esraClassification }); + mapped.cannotGetAQuote = cannotGetAQuote({ shortTermCover, nbiIssueAvailable, esraClassification }); - mapped.canApplyForInsuranceOnline = applyForInsuranceOnline(mapped.shortTermCover); + mapped.canApplyForInsuranceOnline = canApplyForInsuranceOnline(mapped.shortTermCover, esraClassification); mapped.noInsuranceSupport = noInsuranceSupportAvailable(mockCountryBase.marketRiskAppetitePublicDesc); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts index 55fbe71033..8203caaf1b 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/index.ts @@ -1,10 +1,10 @@ -import mapRiskCategory from './map-risk-category'; -import mapShortTermCoverAvailable from './map-short-term-cover-available'; +import mapEsraClassification from './map-esra-classification'; import mapNbiIssueAvailable from './map-NBI-issue-available'; +import mapShortTermCoverAvailable from './map-short-term-cover-available'; import canGetAQuoteOnline from './can-get-a-quote-online'; import canGetAQuoteByEmail from './can-get-a-quote-by-email'; import cannotGetAQuote from './cannot-get-a-quote'; -import applyForInsuranceOnline from './can-apply-for-insurance-online'; +import canApplyForInsuranceOnline from './can-apply-for-insurance-online'; import canApplyOffline from './can-apply-offline'; import noInsuranceSupportAvailable from './no-insurance-support'; import { CisCountry, MappedCisCountry } from '../../../types'; @@ -15,23 +15,32 @@ import { CisCountry, MappedCisCountry } from '../../../types'; * @param {CisCountry} CIS Country * @returns {MappedCisCountry} Mapped country */ -export const mapCisCountry = (country: CisCountry): MappedCisCountry => { +export const mapCisCountry = (cisCountry: CisCountry): MappedCisCountry => { + const { marketName, isoCode } = cisCountry; + + const esraClassification = mapEsraClassification(cisCountry.ESRAClassificationDesc); + const nbiIssueAvailable = mapNbiIssueAvailable(cisCountry.NBIIssue); + const shortTermCover = mapShortTermCoverAvailable(cisCountry.shortTermCoverAvailabilityDesc); + const mapped = { - name: country.marketName, - isoCode: country.isoCode, - riskCategory: mapRiskCategory(country.ESRAClassificationDesc), - shortTermCover: mapShortTermCoverAvailable(country.shortTermCoverAvailabilityDesc), - nbiIssueAvailable: mapNbiIssueAvailable(country.NBIIssue), + name: marketName, + esraClassification, + isoCode, + nbiIssueAvailable, + shortTermCover, } as MappedCisCountry; - mapped.canGetAQuoteOnline = canGetAQuoteOnline(mapped); - mapped.canGetAQuoteOffline = canApplyOffline(country.shortTermCoverAvailabilityDesc); - mapped.canGetAQuoteByEmail = canGetAQuoteByEmail(mapped); - mapped.cannotGetAQuote = cannotGetAQuote(mapped); + mapped.canGetAQuoteOnline = canGetAQuoteOnline({ shortTermCover, nbiIssueAvailable, esraClassification }); + + mapped.canGetAQuoteOffline = canApplyOffline(cisCountry.shortTermCoverAvailabilityDesc); + + mapped.canGetAQuoteByEmail = canGetAQuoteByEmail({ shortTermCover, nbiIssueAvailable, esraClassification }); + + mapped.cannotGetAQuote = cannotGetAQuote({ shortTermCover, nbiIssueAvailable, esraClassification }); - mapped.canApplyForInsuranceOnline = applyForInsuranceOnline(mapped.shortTermCover, mapped.riskCategory); + mapped.canApplyForInsuranceOnline = canApplyForInsuranceOnline(shortTermCover, esraClassification); - mapped.noInsuranceSupport = noInsuranceSupportAvailable(country.marketRiskAppetitePublicDesc); + mapped.noInsuranceSupport = noInsuranceSupportAvailable(cisCountry.marketRiskAppetitePublicDesc); return mapped; }; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.ts index f8be363855..244908cbd5 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/map-NBI-issue-available/index.ts @@ -8,7 +8,7 @@ const { CIS } = EXTERNAL_API_DEFINITIONS; * @param {String} NBI flag * @returns {Boolean} */ -export const mapNbiIssueAvailable = (str: string): boolean => { +const mapNbiIssueAvailable = (str: string): boolean => { if (str === CIS.NBI_ISSUE_AVAILABLE.YES) { return true; } diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.test.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.test.ts similarity index 73% rename from src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.test.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.test.ts index 812a1919e1..f8c666ca2c 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.test.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.test.ts @@ -1,14 +1,14 @@ -import mapRiskCategory from '.'; +import mapEsraClassification from '.'; import { EXTERNAL_API_DEFINITIONS, EXTERNAL_API_MAPPINGS } from '../../../../constants'; const { CIS } = EXTERNAL_API_DEFINITIONS; -describe('helpers/map-cis-countries/map-cis-country/map-risk-category', () => { +describe('helpers/map-cis-countries/map-cis-country/map-esra-classification', () => { describe(`when the risk is '${CIS.RISK.STANDARD}'`, () => { it('should return simplified string', () => { const str = CIS.RISK.STANDARD; - const result = mapRiskCategory(str); + const result = mapEsraClassification(str); const expected = EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; @@ -20,7 +20,7 @@ describe('helpers/map-cis-countries/map-cis-country/map-risk-category', () => { it('should return the string', () => { const str = CIS.RISK.HIGH; - const result = mapRiskCategory(str); + const result = mapEsraClassification(str); expect(result).toEqual(str); }); @@ -30,7 +30,7 @@ describe('helpers/map-cis-countries/map-cis-country/map-risk-category', () => { it('should return the string', () => { const str = CIS.RISK.VERY_HIGH; - const result = mapRiskCategory(str); + const result = mapEsraClassification(str); expect(result).toEqual(str); }); @@ -39,7 +39,7 @@ describe('helpers/map-cis-countries/map-cis-country/map-risk-category', () => { it('should return null', () => { const str = 'None'; - const result = mapRiskCategory(str); + const result = mapEsraClassification(str); expect(result).toBeNull(); }); diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.ts similarity index 60% rename from src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.ts rename to src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.ts index a6da4db6e7..322610f701 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/map-risk-category/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/map-esra-classification/index.ts @@ -2,12 +2,12 @@ import { EXTERNAL_API_DEFINITIONS, EXTERNAL_API_MAPPINGS } from '../../../../con const { CIS } = EXTERNAL_API_DEFINITIONS; /** - * mapRiskCategory - * Transform a countries risk category to a consistent string + * mapEsraClassification + * Transform a country's ESRAClassificationDesc field into a consistent string * @param {String} Risk category - * @returns {String} Consistent risk category + * @returns {String} Consistent ESRA classification */ -export const mapRiskCategory = (str: string) => { +const mapEsraClassification = (str: string): string | null => { if (str === CIS.RISK.STANDARD) { return EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; } @@ -23,4 +23,4 @@ export const mapRiskCategory = (str: string) => { return null; }; -export default mapRiskCategory; +export default mapEsraClassification; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts index 44e565531d..c4aa5dd5d7 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/map-short-term-cover-available/index.ts @@ -10,7 +10,7 @@ const { * @param {String} Risk category * @returns {Boolean} */ -export const mapShortTermCoverAvailable = (str: string): boolean => { +const mapShortTermCoverAvailable = (str: string): boolean => { switch (str) { case SHORT_TERM_COVER_AVAILABLE.YES: return true; diff --git a/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts b/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts index 30a6376333..2cfe3134ea 100644 --- a/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts +++ b/src/api/helpers/map-CIS-countries/map-CIS-country/no-insurance-support/index.ts @@ -8,6 +8,6 @@ const { NO_COVER } = EXTERNAL_API_DEFINITIONS.CIS; * @param {String} marketRiskAppetitePublicDesc market risk appetite definition from CIS API. * @returns {Boolean} */ -export const noInsuranceSupportAvailable = (marketRiskAppetitePublicDesc: string) => marketRiskAppetitePublicDesc === NO_COVER; +const noInsuranceSupportAvailable = (marketRiskAppetitePublicDesc: string) => marketRiskAppetitePublicDesc === NO_COVER; export default noInsuranceSupportAvailable; diff --git a/src/api/helpers/map-currencies/index.ts b/src/api/helpers/map-currencies/index.ts index 6c6e3fd4c0..1c3d1e5cdb 100644 --- a/src/api/helpers/map-currencies/index.ts +++ b/src/api/helpers/map-currencies/index.ts @@ -11,7 +11,7 @@ const { CIS } = EXTERNAL_API_DEFINITIONS; * @param {Array} Array of all possible currencies * @returns {Array} Array of currencies that EXIP supports */ -export const getSupportedCurrencies = (currencies: Array) => { +export const getSupportedCurrencies = (currencies: Array): Array => { const supported = currencies.filter((currency) => SUPPORTED_CURRENCIES.find((currencyCode: string) => currency.isoCode === currencyCode)); return supported; @@ -23,7 +23,7 @@ export const getSupportedCurrencies = (currencies: Array) => { * @param {Array} Array of all possible currencies * @returns {Array} Array of alternate currencies */ -export const getAlternativeCurrencies = (currencies: Array) => { +export const getAlternativeCurrencies = (currencies: Array): Array => { const alternate = currencies.filter((currency) => !SUPPORTED_CURRENCIES.includes(currency.isoCode)); return alternate; @@ -40,7 +40,7 @@ export const getAlternativeCurrencies = (currencies: Array) => { * @param {Boolean} alternativeCurrencies if alternate currencies should be returned * @returns {Array} Array supported currencies */ -const mapCurrencies = (currencies: Array, alternativeCurrencies: boolean) => { +const mapCurrencies = (currencies: Array, alternativeCurrencies: boolean): Array => { let currenciesArray = filterCisEntries(currencies, CIS.INVALID_CURRENCIES, 'name') as Array; if (!alternativeCurrencies) { diff --git a/src/api/helpers/round-number/index.test.ts b/src/api/helpers/round-number/index.test.ts new file mode 100644 index 0000000000..937c9e13c7 --- /dev/null +++ b/src/api/helpers/round-number/index.test.ts @@ -0,0 +1,13 @@ +import roundNumber from '.'; + +describe('roundNumber', () => { + it('should return a rounded number', () => { + const number = 1234; + + const result = roundNumber(number); + + const expected = Math.round(number); + + expect(result).toEqual(expected); + }); +}); diff --git a/src/api/helpers/round-number/index.ts b/src/api/helpers/round-number/index.ts new file mode 100644 index 0000000000..9aeeed7d16 --- /dev/null +++ b/src/api/helpers/round-number/index.ts @@ -0,0 +1,9 @@ +/** + * roundNumber + * Round a number to the nearest integer + * @param {Number} number + * @returns {Number} + */ +const roundNumber = (number: number) => Math.round(number); + +export default roundNumber; diff --git a/src/api/helpers/update-inactive-applications/index.test.ts b/src/api/helpers/update-inactive-applications/index.test.ts index 9c54dbea3e..83c8cec3a2 100644 --- a/src/api/helpers/update-inactive-applications/index.test.ts +++ b/src/api/helpers/update-inactive-applications/index.test.ts @@ -26,7 +26,7 @@ describe('helpers/update-inactive-applications', () => { }); describe(`successfully updates inactive application to ${ABANDONED}`, () => { - it('should return success as true', async () => { + it('should return success=true', async () => { const { success } = await updateInactiveApplications(context); expect(success).toEqual(true); diff --git a/src/api/helpers/update-unverified-accounts/index.test.ts b/src/api/helpers/update-unverified-accounts/index.test.ts index 767f8f9b74..808dcaefbc 100644 --- a/src/api/helpers/update-unverified-accounts/index.test.ts +++ b/src/api/helpers/update-unverified-accounts/index.test.ts @@ -23,7 +23,7 @@ describe('helpers/update-unverified-accounts', () => { }); describe(`successfully updates unverified accounts' "isInactive" status to true`, () => { - it('should return success as true', async () => { + it('should return success=true', async () => { const { success } = await updateUnverifiedAccounts(context); expect(success).toEqual(true); diff --git a/src/api/integrations/APIM/index.test.ts b/src/api/integrations/APIM/index.test.ts index d08ebdb334..9dc8da48e3 100644 --- a/src/api/integrations/APIM/index.test.ts +++ b/src/api/integrations/APIM/index.test.ts @@ -2,67 +2,162 @@ import dotenv from 'dotenv'; import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import APIM from '.'; -import { EXTERNAL_API_ENDPOINTS } from '../../constants'; -import { mockCisCountries } from '../../test-mocks'; +import { EXTERNAL_API_ENDPOINTS, GBP, USD } from '../../constants'; +import { mockCisCountries, mockCurrencies } from '../../test-mocks'; dotenv.config(); const { APIM_MDM_URL } = process.env; const { APIM_MDM } = EXTERNAL_API_ENDPOINTS; -const url = `${APIM_MDM_URL}${APIM_MDM.MARKETS}`; - describe('integrations/APIM', () => { - describe('when a 200 status and data is returned', () => { - test('it should return success=true and data', async () => { - const mock = new MockAdapter(axios); + describe('getCisCountries', () => { + const url = `${APIM_MDM_URL}${APIM_MDM.MARKETS}`; + + describe('when a 200 status and data is returned', () => { + test('it should return success=true and data', async () => { + const mock = new MockAdapter(axios); + + const mockResponseData = mockCisCountries; + + mock.onGet(url).reply(200, mockResponseData); + + const result = await APIM.getCisCountries(); - const mockResponseData = mockCisCountries; + const expected = { + success: true, + data: mockResponseData, + }; - mock.onGet(url).reply(200, mockResponseData); + expect(result).toEqual(expected); + }); + }); + + describe('when no data is returned', () => { + test('it should return success=false', async () => { + const mock = new MockAdapter(axios); + + mock.onGet(url).reply(200); - const result = await APIM.getCisCountries(); + const result = await APIM.getCisCountries(); - const expected = { - success: true, - data: mockResponseData, - }; + const expected = { + success: false, + }; - expect(result).toEqual(expected); + expect(result).toEqual(expected); + }); + }); + + describe('when a 200 status is not returned', () => { + test('it should throw an error', async () => { + const mock = new MockAdapter(axios); + + mock.onGet(url).reply(500); + + await expect(APIM.getCisCountries()).rejects.toThrow('Calling APIM - CIS countries'); + }); }); }); - describe('when no data is returned', () => { - test('it should return success=false', async () => { - const mock = new MockAdapter(axios); + describe('getCurrencies', () => { + const url = `${APIM_MDM_URL}${APIM_MDM.CURRENCY}`; + + describe('when a 200 status and data is returned', () => { + test('it should return success=true and data', async () => { + const mock = new MockAdapter(axios); - mock.onGet(url).reply(200); + const mockResponseData = mockCurrencies; - const result = await APIM.getCisCountries(); + mock.onGet(url).reply(200, mockResponseData); - const expected = { - success: false, - }; + const result = await APIM.getCurrencies(); - expect(result).toEqual(expected); + const expected = { + success: true, + data: mockResponseData, + }; + + expect(result).toEqual(expected); + }); + }); + + describe('when no data is returned', () => { + test('it should return success=false', async () => { + const mock = new MockAdapter(axios); + + mock.onGet(url).reply(200); + + const result = await APIM.getCurrencies(); + + const expected = { + success: false, + }; + + expect(result).toEqual(expected); + }); + }); + + describe('when a 200 status is not returned', () => { + test('it should throw an error', async () => { + const mock = new MockAdapter(axios); + + mock.onGet(url).reply(500); + + await expect(APIM.getCurrencies()).rejects.toThrow('Calling APIM - currencies'); + }); }); }); - describe('when a 200 status is not returned', () => { - test('it should throw an error', async () => { - const mock = new MockAdapter(axios); + describe('getCurrenciesExchange', () => { + const url = `${APIM_MDM_URL}${APIM_MDM.CURRENCY_EXCHANGE}`; + + const mockSource = GBP; + const mockTarget = USD; + + describe('when a 200 status and data is returned', () => { + test('it should return success=true and data', async () => { + const mock = new MockAdapter(axios); + + const mockResponseData = mockCurrencies; + + mock.onGet(url).reply(200, mockResponseData); - mock.onGet(url).reply(500); + const result = await APIM.getCurrenciesExchange(mockSource, mockTarget); + + const expected = { + success: true, + data: mockResponseData, + }; + + expect(result).toEqual(expected); + }); + }); + + describe('when no data is returned', () => { + test('it should return success=false', async () => { + const mock = new MockAdapter(axios); + + mock.onGet(url).reply(200); + + const result = await APIM.getCurrenciesExchange(mockSource, mockTarget); + + const expected = { + success: false, + }; + + expect(result).toEqual(expected); + }); + }); - try { - await APIM.getCisCountries(); - } catch (error) { - const expected = 'Calling APIM - CIS countries'; + describe('when a 200 status is not returned', () => { + test('it should throw an error', async () => { + const mock = new MockAdapter(axios); - const errorAssertion = String(error).includes(expected); + mock.onGet(url).reply(500); - expect(errorAssertion).toEqual(true); - } + await expect(APIM.getCurrenciesExchange(mockSource, mockTarget)).rejects.toThrow('Calling APIM - currencies exchange'); + }); }); }); }); diff --git a/src/api/integrations/APIM/index.ts b/src/api/integrations/APIM/index.ts index 2c3e1233b1..2d39487023 100644 --- a/src/api/integrations/APIM/index.ts +++ b/src/api/integrations/APIM/index.ts @@ -1,7 +1,7 @@ import axios from 'axios'; import dotenv from 'dotenv'; import { EXTERNAL_API_ENDPOINTS } from '../../constants'; -import { GetApimCisCountriesResponse, GetApimCurrenciesResponse } from '../../types'; +import { GetApimCisCountriesResponse, GetApimCurrenciesResponse, GetApimCurrenciesExchangeResponse } from '../../types'; dotenv.config(); @@ -81,6 +81,40 @@ const APIM = { throw new Error(`Calling APIM - currencies ${error}`); } }, + getCurrenciesExchange: async (source: string, target: string): Promise => { + try { + console.info('Calling APIM - currencies exchange'); + + const response = await axios({ + method: 'get', + url: `${APIM_MDM_URL}${APIM_MDM.CURRENCY_EXCHANGE}`, + headers: { + 'Content-Type': 'application/json', + [String(APIM_MDM_KEY)]: APIM_MDM_VALUE, + }, + params: { source, target }, + validateStatus(status) { + const acceptableStatus = [200]; + return acceptableStatus.includes(status); + }, + }); + + if (response.data && response.status === 200) { + return { + success: true, + data: response.data, + }; + } + + return { + success: false, + }; + } catch (error) { + console.error('Error calling APIM - currencies exchange %o', error); + + throw new Error(`Calling APIM - currencies exchange ${error}`); + } + }, }; export default APIM; diff --git a/src/api/integrations/companies-house/index.ts b/src/api/integrations/companies-house/index.ts index 9929d88104..c78fc4da83 100644 --- a/src/api/integrations/companies-house/index.ts +++ b/src/api/integrations/companies-house/index.ts @@ -33,7 +33,6 @@ const companiesHouse = { }; } - // if no data in response or status is not 200 then return success as false if (!response.data || response.status !== 200) { return { success: false, diff --git a/src/api/integrations/ordnance-survey/index.ts b/src/api/integrations/ordnance-survey/index.ts index 337761e36a..80c43ce6b0 100644 --- a/src/api/integrations/ordnance-survey/index.ts +++ b/src/api/integrations/ordnance-survey/index.ts @@ -25,7 +25,6 @@ const ordnanceSurvey = { }, }); - // if no data in response or status is not 200 then return success as false if (!response?.data?.results || response.status !== 200) { return { success: false, diff --git a/src/api/schema.graphql b/src/api/schema.graphql index 789bcf660c..2a7dec1d2d 100644 --- a/src/api/schema.graphql +++ b/src/api/schema.graphql @@ -2464,8 +2464,8 @@ input BuyerTradingHistoryCreateInput { type Country { id: ID! - isoCode: String - name: String + isoCode: String! + name: String! } input CountryWhereUniqueInput { @@ -3411,9 +3411,6 @@ type Query { """ verify an account's password reset token """ verifyAccountPasswordResetToken(token: String!): AccountPasswordResetTokenResponse - """ get CIS countries from APIM """ - getApimCisCountries: [MappedCisCountry] - """ get companies house information """ getCompaniesHouseInformation(companiesHouseNumber: String!): CompaniesHouseResponse @@ -3423,8 +3420,14 @@ type Query { """ get Ordnance Survey address """ getOrdnanceSurveyAddress(postcode: String!, houseNameOrNumber: String!): OrdnanceSurveyResponse + """ get CIS countries from APIM """ + getApimCisCountries: [MappedCisCountry] + """ get currencies from APIM """ getApimCurrencies: GetApimCurrencyResponse + + """ get countries and currencies """ + getCountriesAndCurrencies: GetCountriesAndCurrenciesResponse } union AuthenticatedItem = User @@ -3742,7 +3745,7 @@ type MappedCisCountry { isoCode: String! name: String shortTermCover: Boolean - riskCategory: String + esraClassification: String nbiIssueAvailable: Boolean canGetAQuoteOnline: Boolean canGetAQuoteOffline: Boolean @@ -3764,6 +3767,13 @@ type GetApimCurrencyResponse { allCurrencies: [MappedCurrency] } +type GetCountriesAndCurrenciesResponse { + countries: [Country] + supportedCurrencies: [MappedCurrency] + alternativeCurrencies: [MappedCurrency] + allCurrencies: [MappedCurrency] +} + type Owner { id: String firstName: String diff --git a/src/api/test-mocks/create-mock-worksheet.ts b/src/api/test-mocks/create-mock-worksheet.ts new file mode 100644 index 0000000000..81124a1eb0 --- /dev/null +++ b/src/api/test-mocks/create-mock-worksheet.ts @@ -0,0 +1,45 @@ +import ExcelJS, { Worksheet } from 'exceljs'; +import SECTION_NAMES from '../constants/XLSX-CONFIG/SECTION_NAMES'; +import HEADER_COLUMNS from '../generate-xlsx/header-columns'; +import mapApplicationToXLSX from '../generate-xlsx/map-application-to-XLSX'; +import { mockApplicationMinimalBrokerBuyerAndCompany as mockApplication } from '.'; +import mockCountries from './mock-countries'; + +const { EXPORTER_BUSINESS } = SECTION_NAMES; + +/** + * createMockWorksheet + * Create a mock ExcelJS worksheet + * @returns {ExcelJS.Worksheet} + */ +export const createMockWorksheet = () => { + const workbook = new ExcelJS.Workbook(); + + const xlsxData = mapApplicationToXLSX(mockApplication, mockCountries); + + const sheetNames = Object.values(SECTION_NAMES); + + const mockWorksheets = [] as Array; + + sheetNames.forEach((sheetName) => { + const worksheet = workbook.addWorksheet(sheetName); + + worksheet.columns = HEADER_COLUMNS(sheetName); + + xlsxData[sheetName].forEach((row) => { + worksheet.addRow(row); + }); + + mockWorksheets.push(worksheet); + }); + + const [mockWorksheet] = mockWorksheets; + const mockSheetName = EXPORTER_BUSINESS; + + return { + mockWorksheet, + mockSheetName, + }; +}; + +export default createMockWorksheet; diff --git a/src/api/test-mocks/index.ts b/src/api/test-mocks/index.ts index e9b7fbe8a9..00c48baf24 100644 --- a/src/api/test-mocks/index.ts +++ b/src/api/test-mocks/index.ts @@ -1,6 +1,7 @@ import { Request, Response } from 'express'; import { ACCOUNT, APPLICATION, FIELD_IDS, TOTAL_CONTRACT_VALUE } from '../constants'; import encryptPassword from '../helpers/encrypt-password'; +import mapCisCountries from '../helpers/map-CIS-countries'; import application, { mockExportContractAgentFullyPopulated } from './mock-application'; import buyer from './mock-buyer'; import cisCountries from './mock-CIS-countries'; @@ -8,7 +9,7 @@ import currencies from './mock-currencies'; import company, { companyScenarios } from './mock-company'; import companySicCode from './mock-company-sic-code'; import nominatedLossPayee from './mock-nominated-loss-payee'; -import { Account } from '../types'; +import { Account, GetApimCisCountriesHelperResponse, GetApimCurrenciesHelperResponse } from '../types'; const { ACCOUNT: { PASSWORD_RESET_HASH }, @@ -114,6 +115,8 @@ export const mockApplicationMultiplePolicyTotalContractValueOverThreshold = { export const mockCisCountries = cisCountries; +export const mockMappedCisCountries = mapCisCountries(mockCisCountries); + export const mockCompany = company; export const mockCompanySicCode = companySicCode; export const mockCompanyScenarios = companyScenarios; @@ -165,8 +168,20 @@ export const mockCountries = [ }, ]; +export const mockApimCisCountriesGetHelperResponse = { + countries: mockMappedCisCountries, + success: true, +} as GetApimCisCountriesHelperResponse; + export const mockCurrencies = currencies; +export const mockApimCurrenciesGetHelperResponse = { + allCurrencies: mockCurrencies, + alternativeCurrencies: mockCurrencies, + supportedCurrencies: mockCurrencies, + success: true, +} as GetApimCurrenciesHelperResponse; + export const mockApplicationDeclaration = { agreeToConfidentiality: true, agreeToAntiBribery: true, diff --git a/src/api/test-mocks/mock-APIM-currencies-exchange-response.ts b/src/api/test-mocks/mock-APIM-currencies-exchange-response.ts new file mode 100644 index 0000000000..99d51162c1 --- /dev/null +++ b/src/api/test-mocks/mock-APIM-currencies-exchange-response.ts @@ -0,0 +1,23 @@ +import { CurrencyExchange, GetApimCurrenciesExchangeResponse } from '../types'; + +export const mockCurrencyExchange: CurrencyExchange = { + id: 389789, + sourceCurrencyId: 12, + targetCurrencyId: 37, + currencyPair: 'GBP-USD X-RATE', + bidPrice: 1.2768, + askPrice: 1.2769, + lastPrice: 1.2768, + midPrice: 1.27685, + created: '2024-07-03T16:31:34.000Z', + updated: '2024-07-03T16:31:34.000Z', + effectiveFrom: '2024-07-03T00:00:00.000Z', + effectiveTo: '9999-12-31T00:00:00.000Z', +}; + +const mockApimCurrenciesExchangeResponse = { + success: true, + data: [mockCurrencyExchange], +} as GetApimCurrenciesExchangeResponse; + +export default mockApimCurrenciesExchangeResponse; diff --git a/src/api/test-mocks/mock-application.ts b/src/api/test-mocks/mock-application.ts index bc17fad2e0..849a2e4241 100644 --- a/src/api/test-mocks/mock-application.ts +++ b/src/api/test-mocks/mock-application.ts @@ -32,9 +32,11 @@ export const mockApplicationEligibility = { }; const mockGenericPolicy = { + id: 'clfv9uv6v00csoqz2pm7nftfy', requestedStartDate: new Date(date.setMonth(month + 1)), policyCurrencyCode: GBP, jointlyInsuredParty: { + policyId: 'clfv9uv6v00csoqz2pm7nftfy', id: 'clfv9uv6v00csoqz2pm7nftfx', requested: false, }, @@ -46,10 +48,12 @@ export const mockSinglePolicy = { contractCompletionDate: new Date(date.setMonth(month + 3)), totalValueOfContract: 1500, needPreCreditPeriodCover: false, + requestedCreditLimit: 865, }; export const mockMultiplePolicy = { ...mockGenericPolicy, + policyId: mockGenericPolicy.id, policyType: APPLICATION.POLICY_TYPE.MULTIPLE, totalMonthsOfCover: 5, totalSalesToBuyer: 1500, diff --git a/src/api/test-mocks/mock-currencies.ts b/src/api/test-mocks/mock-currencies.ts index 1eec1081ea..6dab6d00c6 100644 --- a/src/api/test-mocks/mock-currencies.ts +++ b/src/api/test-mocks/mock-currencies.ts @@ -25,6 +25,6 @@ export const USD = { isoCode: 'USD', }; -const mockCurrencies = [EUR, HKD, JPY, GBP, USD] as Array; +const mockCurrencies: Array = [EUR, HKD, JPY, GBP, USD]; export default mockCurrencies; diff --git a/src/api/types/application-types/index.ts b/src/api/types/application-types/index.ts index bcc991f7fe..17912bd0dd 100644 --- a/src/api/types/application-types/index.ts +++ b/src/api/types/application-types/index.ts @@ -255,9 +255,9 @@ export interface ApplicationJointlyInsuredParty extends Relationship { } export interface ApplicationPolicy extends Relationship { - policyType?: string; + policyType: string; requestedStartDate: Date; - contractCompletionDate: Date; + contractCompletionDate?: Date; totalValueOfContract?: number; needPreCreditPeriodCover?: boolean; creditPeriodWithBuyer?: string; @@ -266,6 +266,7 @@ export interface ApplicationPolicy extends Relationship { totalSalesToBuyer?: number; maximumBuyerWillOwe?: number; jointlyInsuredParty: ApplicationJointlyInsuredParty; + requestedCreditLimit?: number; } export interface ApplicationPolicyContact extends Relationship { @@ -315,6 +316,10 @@ export interface ApplicationSubmissionEmailVariables { buyerLocation: string; } +interface ApplicationVersionSmallExportBuilder { + MAXIMUM_BUYER_WILL_OWE: number; +} + export interface ApplicationVersion { VERSION_NUMBER: string; OVER_500K_SUPPORT: boolean; @@ -325,6 +330,7 @@ export interface ApplicationVersion { DEFAULT_CURRENCY?: string; BROKER_ADDRESS_AS_MULTIPLE_FIELDS: boolean; REQUESTED_CREDIT_LIMIT_REQUIRED?: boolean; + SMALL_EXPORT_BUILDER?: ApplicationVersionSmallExportBuilder; } export interface SectionReview extends Relationship { diff --git a/src/api/types/country/index.ts b/src/api/types/country/index.ts index 06f84eb260..69ee3e51d6 100644 --- a/src/api/types/country/index.ts +++ b/src/api/types/country/index.ts @@ -1,4 +1,4 @@ -import { Currency } from '../currency'; +import { SuccessResponse } from '../generic'; import { Relationship } from '../relationship'; export interface CisCountry { @@ -8,13 +8,11 @@ export interface CisCountry { ESRAClassificationDesc: string; NBIIssue: string; marketRiskAppetitePublicDesc: string; - riskCategory?: string; } export interface Country extends Relationship { name: string; isoCode: string; - riskCategory?: string; shortTermCover?: boolean; nbiIssueAvailable?: boolean; canGetAQuoteOnline?: boolean; @@ -25,21 +23,11 @@ export interface Country extends Relationship { noInsuranceSupport?: boolean; } -export interface GetApimCisCountriesResponse { - success: boolean; - data?: [CisCountry]; -} - -export interface GetApimCurrenciesResponse { - success: boolean; - data?: [Currency]; -} - export interface MappedCisCountry { name: string; isoCode: string; shortTermCover: boolean; - riskCategory?: string; + esraClassification?: string; nbiIssueAvailable: boolean; canGetAQuoteOnline: boolean; canGetAQuoteOffline: boolean; @@ -48,3 +36,11 @@ export interface MappedCisCountry { canApplyForInsuranceOnline: boolean; noInsuranceSupport: boolean; } + +export interface GetApimCisCountriesResponse extends SuccessResponse { + data?: [CisCountry]; +} + +export interface GetApimCisCountriesHelperResponse extends SuccessResponse { + countries: [MappedCisCountry]; +} diff --git a/src/api/types/currency/index.ts b/src/api/types/currency/index.ts index 0f61b2bb43..81ee49753f 100644 --- a/src/api/types/currency/index.ts +++ b/src/api/types/currency/index.ts @@ -1,4 +1,41 @@ +import { SuccessResponse } from '../generic'; + export interface Currency { name: string; isoCode: string; } + +export interface GetApimCurrenciesResponse extends SuccessResponse { + data?: [Currency]; +} + +export interface GetApimCurrenciesHelperResponse extends SuccessResponse { + supportedCurrencies?: [Currency]; + alternativeCurrencies?: [Currency]; + allCurrencies?: [Currency]; +} + +export interface GetApimCurrenciesQueryResponse { + supportedCurrencies?: [Currency]; + alternativeCurrencies?: [Currency]; + allCurrencies?: [Currency]; +} + +export interface CurrencyExchange { + id: number; + sourceCurrencyId: number; + targetCurrencyId: number; + currencyPair: string; + bidPrice: number; + askPrice: number; + lastPrice: number; + midPrice: number; + created: string; + updated: string; + effectiveFrom: string; + effectiveTo: string; +} + +export interface GetApimCurrenciesExchangeResponse extends SuccessResponse { + data?: [CurrencyExchange]; +} diff --git a/src/api/types/generic/index.ts b/src/api/types/generic/index.ts index 19d1c6ea93..719906bd5a 100644 --- a/src/api/types/generic/index.ts +++ b/src/api/types/generic/index.ts @@ -9,5 +9,5 @@ export interface ConnectObj { } export interface SuccessResponse { - success: boolean; + success?: boolean; } diff --git a/src/api/types/helpers/index.ts b/src/api/types/helpers/index.ts index a586b8321a..8f8adcb331 100644 --- a/src/api/types/helpers/index.ts +++ b/src/api/types/helpers/index.ts @@ -2,3 +2,9 @@ export interface MapYesNoFieldParams { answer?: boolean | null; defaultValue?: string; } + +export interface MapCisCountryParams { + shortTermCover: boolean; + nbiIssueAvailable: boolean; + esraClassification?: string | null; +} diff --git a/src/ui/server/api/keystone/get-countries-and-currencies/index.ts b/src/ui/server/api/keystone/get-countries-and-currencies/index.ts new file mode 100644 index 0000000000..f6af936aca --- /dev/null +++ b/src/ui/server/api/keystone/get-countries-and-currencies/index.ts @@ -0,0 +1,33 @@ +import apollo from '../../../graphql/apollo'; +import { ApolloResponse } from '../../../../types'; +import getCountriesAndCurrenciesQuery from '../../../graphql/queries/countries-and-currencies'; + +const getCountriesAndCurrencies = async () => { + try { + console.info('Getting countries and currencies'); + + const response = (await apollo('POST', getCountriesAndCurrenciesQuery, {})) as ApolloResponse; + + if (response.errors) { + console.error('GraphQL error getting countries and currencies %o', response.errors); + } + + if (response?.networkError?.result?.errors) { + console.error('GraphQL network error getting countries and currencies %o', response.networkError.result.errors); + } + + if (response?.data?.getCountriesAndCurrencies) { + return response.data.getCountriesAndCurrencies; + } + + console.error('Error with GraphQL getCountriesAndCurrenciesQuery %o', response); + + throw new Error('Getting country'); + } catch (error) { + console.error('Error getting countries and currencies %o', error); + + throw new Error('Getting country'); + } +}; + +export default getCountriesAndCurrencies; diff --git a/src/ui/server/api/keystone/index.ts b/src/ui/server/api/keystone/index.ts index ea167bca94..b4c9b717e9 100644 --- a/src/ui/server/api/keystone/index.ts +++ b/src/ui/server/api/keystone/index.ts @@ -3,9 +3,9 @@ import APIM from './APIM'; import application from './application'; import applications from './applications'; import countries from './countries'; +import getCountriesAndCurrencies from './get-countries-and-currencies'; import getCompaniesHouseInformation from './get-companies-house-information'; import getOrdnanceSurveyAddress from './get-ordnance-survey-address'; -import page from './page'; import feedback from './feedback'; const keystone = { @@ -14,9 +14,9 @@ const keystone = { application, applications, countries, + getCountriesAndCurrencies, getCompaniesHouseInformation, getOrdnanceSurveyAddress, - page, feedback, }; diff --git a/src/ui/server/api/keystone/page/index.ts b/src/ui/server/api/keystone/page/index.ts deleted file mode 100644 index 014e252e87..0000000000 --- a/src/ui/server/api/keystone/page/index.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { ApolloResponse } from '../../../../types'; -import apollo from '../../../graphql/apollo'; -import pageQuery from '../../../graphql/queries/page'; - -const page = { - get: async (pageId: string) => { - try { - console.info('Getting page data'); - - const queryParams = { - id: pageId, - }; - - const response = (await apollo('GET', pageQuery, queryParams)) as ApolloResponse; - - if (response.errors) { - console.error('GraphQL error querying keystone page %o', response.errors); - } - - if (response?.networkError?.result?.errors) { - console.error('GraphQL network error querying keystone page %o', response.networkError.result.errors); - } - - if (response?.data?.page) { - return response.data.page; - } - - console.error('Error with GraphQL pageQuery %o', response); - - throw new Error('Getting page data'); - } catch (error) { - console.error('Error getting page data %o', error); - - throw new Error('Getting page data'); - } - }, -}; - -export default page; diff --git a/src/ui/server/constants/application/get-application-definition/index.test.ts b/src/ui/server/constants/application/get-application-definition/index.test.ts new file mode 100644 index 0000000000..f075fbc418 --- /dev/null +++ b/src/ui/server/constants/application/get-application-definition/index.test.ts @@ -0,0 +1,26 @@ +import getApplicationDefinition from '.'; +import VERSIONS from '../versions'; + +describe('constants/application/get-application-definition', () => { + it('should return the application definition from the provided version number', () => { + const result = getApplicationDefinition('1'); + + const [expected] = VERSIONS; + + expect(result).toEqual(expected); + + expect(result.VERSION_NUMBER).toEqual('1'); + }); + + describe('when no application definition is found', () => { + it('should throw an error', () => { + try { + getApplicationDefinition('123456'); + } catch (error) { + const expected = new Error('Unable to find latest application version'); + + expect(error).toEqual(expected); + } + }); + }); +}); diff --git a/src/ui/server/constants/application/get-application-definition/index.ts b/src/ui/server/constants/application/get-application-definition/index.ts new file mode 100644 index 0000000000..acc75dbc83 --- /dev/null +++ b/src/ui/server/constants/application/get-application-definition/index.ts @@ -0,0 +1,22 @@ +import VERSIONS from '../versions'; +import { ApplicationVersion } from '../../../../types'; + +/** + * getApplicationDefinition + * Get the latest application config + * @param {String} versionNumber: Application version number + * @returns {Object} Latest application config + */ +const getApplicationDefinition = (versionNumber: string): ApplicationVersion => { + const applicationDefinition = VERSIONS.find((VERSION) => VERSION.VERSION_NUMBER === versionNumber); + + if (applicationDefinition) { + return applicationDefinition; + } + + console.error('Unable to find latest application version'); + + throw new Error('Unable to find latest application version'); +}; + +export default getApplicationDefinition; diff --git a/src/ui/server/constants/application/index.ts b/src/ui/server/constants/application/index.ts index cc309815d4..944b6b8be9 100644 --- a/src/ui/server/constants/application/index.ts +++ b/src/ui/server/constants/application/index.ts @@ -1,9 +1,14 @@ +import getApplicationDefinition from './get-application-definition'; +import VERSIONS from './versions'; import LATEST_VERSION_NUMBER from './versions/latest'; +const LATEST_VERSION = getApplicationDefinition(LATEST_VERSION_NUMBER); + export const APPLY = 'Apply'; export const APPLICATION = { - LATEST_VERSION: { LATEST_VERSION_NUMBER }, + LATEST_VERSION, + LATEST_VERSION_NUMBER, DEAL_TYPE: 'EXIP', SUBMISSION_COUNT_DEFAULT: 0, SUBMISSION_DEADLINE_IN_MONTHS: 1, @@ -38,4 +43,5 @@ export const APPLICATION = { }, }, }, + VERSIONS, }; diff --git a/src/ui/server/constants/application/versions/index.ts b/src/ui/server/constants/application/versions/index.ts index 74ac2dc22d..bd1fca8190 100644 --- a/src/ui/server/constants/application/versions/index.ts +++ b/src/ui/server/constants/application/versions/index.ts @@ -1,33 +1,49 @@ +import { GBP } from '../../supported-currencies'; import { ApplicationVersion } from '../../../../types'; +const VERSION_1: ApplicationVersion = { + VERSION_NUMBER: '1', + OVER_500K_SUPPORT: false, + MAXIMUM_BUYER_CAN_OWE: 500000, + TOTAL_VALUE_OF_CONTRACT: 500000, + DEFAULT_FINAL_DESTINATION_KNOWN: true, + DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: false, + BROKER_ADDRESS_AS_MULTIPLE_FIELDS: true, +}; + +const VERSION_2: ApplicationVersion = { + VERSION_NUMBER: '2', + OVER_500K_SUPPORT: true, + DEFAULT_FINAL_DESTINATION_KNOWN: null, + DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: null, + DEFAULT_CURRENCY: GBP, + BROKER_ADDRESS_AS_MULTIPLE_FIELDS: false, +}; + +const VERSION_3: ApplicationVersion = { + ...VERSION_2, + VERSION_NUMBER: '3', + REQUESTED_CREDIT_LIMIT_REQUIRED: true, + SMALL_EXPORT_BUILDER: { + MAXIMUM_BUYER_WILL_OWE: 25000, + }, +}; + /** * VERSIONS * All possible application versions. - * During each phase of EXIP that contains major feature/data changes or additions, - * the application version number should be changed. - * For example: + * These versions highlight changes to certain features, involving: + * - Data changes + * - Changes to thresholds + * - Required questions/answers + * These differ as the service is iterated. + * This should be manually updated each time a phase of EXIP is started. For example: * - Version number 1: MVP, no support for applications over 500k. * - Version number 2: Support for applications over 500k. - * - Version number 3: File uploads - * - Version number 4: Address lookup - * - Version number 5: Payments integration + * - Version number 3: Design and content iterations. 1x new database field. + * - Version number 4: Payments integration * @returns {Array} All application versions */ -const VERSIONS = [ - { - VERSION_NUMBER: '1', - OVER_500K_SUPPORT: false, - MAXIMUM_BUYER_CAN_OWE: 500000, - TOTAL_VALUE_OF_CONTRACT: 500000, - DEFAULT_FINAL_DESTINATION_KNOWN: true, - DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: false, - }, - { - VERSION_NUMBER: '2', - OVER_500K_SUPPORT: true, - DEFAULT_FINAL_DESTINATION_KNOWN: null, - DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: null, - }, -] as Array; +const VERSIONS: Array = [VERSION_1, VERSION_2, VERSION_3]; export default VERSIONS; diff --git a/src/ui/server/constants/application/versions/latest.ts b/src/ui/server/constants/application/versions/latest.ts index 394ea58772..13fa72ad26 100644 --- a/src/ui/server/constants/application/versions/latest.ts +++ b/src/ui/server/constants/application/versions/latest.ts @@ -1,14 +1,19 @@ +import VERSIONS from '.'; + /** * LATEST_VERSION_NUMBER * Latest application version number. - * This should be manually updated each time a phase of EXIP is started. For example: - * - Version number 1: MVP - no support for applications over 500k. + * During each phase of EXIP that contains major feature/data changes or additions, + * the application version number should be changed. + * For example: + * - Version number 1: MVP - No support for applications over 500k. * - Version number 2: "No PDF" - Support for applications over 500k. - * - Version number 3: File uploads - * - Version number 4: Address lookup - * - Version number 5: Payments integration + * - Version number 3: "No PDF" design and content iterations. 1x new database field. + * - Version number 4: File uploads + * - Version number 5: Address lookup + * - Version number 6: Payments integration * @returns {String} Latest application version number */ -const LATEST_VERSION_NUMBER = '1'; +const LATEST_VERSION_NUMBER = VERSIONS[VERSIONS.length - 1].VERSION_NUMBER; export default LATEST_VERSION_NUMBER; diff --git a/src/ui/server/content-strings/error-messages.ts b/src/ui/server/content-strings/error-messages.ts index 377d0c5b66..e8c6af74e7 100644 --- a/src/ui/server/content-strings/error-messages.ts +++ b/src/ui/server/content-strings/error-messages.ts @@ -9,7 +9,7 @@ type ErrorMessage = { [key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any }; -const THRESHOLD = formatCurrency(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE, 0); +const THRESHOLD = formatCurrency(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE); export const ERROR_MESSAGES = { THERE_IS_A_PROBLEM: 'There is a problem', diff --git a/src/ui/server/content-strings/fields/insurance/eligibility/index.ts b/src/ui/server/content-strings/fields/insurance/eligibility/index.ts index d32ebfaad0..b71b4ed700 100644 --- a/src/ui/server/content-strings/fields/insurance/eligibility/index.ts +++ b/src/ui/server/content-strings/fields/insurance/eligibility/index.ts @@ -3,7 +3,7 @@ import { COVER_PERIOD, TOTAL_CONTRACT_VALUE, GBP_CURRENCY_CODE } from '../../../ import { LINKS } from '../../../links'; import formatCurrency from '../../../../helpers/format-currency'; -const THRESHOLD = formatCurrency(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE, 0); +const THRESHOLD = formatCurrency(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE); const { BUYER_COUNTRY, HAS_MINIMUM_UK_GOODS_OR_SERVICES } = INSURANCE_FIELD_IDS.ELIGIBILITY; diff --git a/src/ui/server/content-strings/fields/insurance/policy/index.ts b/src/ui/server/content-strings/fields/insurance/policy/index.ts index 9fb4c44d8a..deceb898a9 100644 --- a/src/ui/server/content-strings/fields/insurance/policy/index.ts +++ b/src/ui/server/content-strings/fields/insurance/policy/index.ts @@ -1,6 +1,8 @@ -import { APPLICATION, ELIGIBILITY, FIELD_VALUES, MAXIMUM_CHARACTERS } from '../../../../constants'; +import { APPLICATION, ELIGIBILITY, FIELD_VALUES, GBP_CURRENCY_CODE, MAXIMUM_CHARACTERS } from '../../../../constants'; import INSURANCE_FIELD_IDS from '../../../../constants/field-ids/insurance'; import { FORM_TITLES } from '../../../form-titles'; +import { LINKS } from '../../../links'; +import formatCurrency from '../../../../helpers/format-currency'; const { ACCOUNT: { EMAIL }, @@ -27,12 +29,18 @@ const { } = INSURANCE_FIELD_IDS; const { MAX_COVER_PERIOD_MONTHS } = ELIGIBILITY; + const { + LATEST_VERSION: { SMALL_EXPORT_BUILDER }, POLICY: { TOTAL_MONTHS_OF_COVER }, } = APPLICATION; const { POLICY: POLICY_FORM_TITLES } = FORM_TITLES; +const maxBuyerWillOweThreshold = Number(SMALL_EXPORT_BUILDER?.MAXIMUM_BUYER_WILL_OWE); + +const SMALL_EXPORT_BUILDER_THRESHOLD = formatCurrency(maxBuyerWillOweThreshold, GBP_CURRENCY_CODE); + export const POLICY_FIELDS = { [POLICY_TYPE]: { ID: POLICY_TYPE, @@ -140,6 +148,13 @@ export const POLICY_FIELDS = { LABEL: 'Estimate the maximum amount your buyer will owe you at any single point during this time', HINT: { FOR_EXAMPLE: 'For example, your total sales might be £250,000 but the maximum the buyer will owe you at any single point is £100,000.', + INITIAL_CREDIT_LIMIT: { + INTRO: `If your initial credit limit request is ${SMALL_EXPORT_BUILDER_THRESHOLD} or less you could be eligible for the`, + LINK: { + TEXT: 'Small Export Builder.', + HREF: LINKS.EXTERNAL.SMALL_EXPORT_BUILDER, + }, + }, NO_DECIMALS: 'Enter a whole number. Do not enter decimals.', }, SUMMARY: { diff --git a/src/ui/server/content-strings/links.ts b/src/ui/server/content-strings/links.ts index 615b3ff46c..ef54027875 100644 --- a/src/ui/server/content-strings/links.ts +++ b/src/ui/server/content-strings/links.ts @@ -31,5 +31,6 @@ export const LINKS = { BRIBERY_ACT_2010_GUIDANCE: 'https://assets.publishing.service.gov.uk/media/5d80cfc3ed915d51e9aff85a/bribery-act-2010-guidance.pdf', ICO_MAKE_A_COMPLAINT: 'https://ico.org.uk/make-a-complaint', COMPANIES_HOUSE: 'https://find-and-update.company-information.service.gov.uk', + SMALL_EXPORT_BUILDER: 'Small Export Builder', }, }; diff --git a/src/ui/server/content-strings/pages/insurance/eligibility/index.ts b/src/ui/server/content-strings/pages/insurance/eligibility/index.ts index 102b44920b..8e8bff2d0c 100644 --- a/src/ui/server/content-strings/pages/insurance/eligibility/index.ts +++ b/src/ui/server/content-strings/pages/insurance/eligibility/index.ts @@ -3,7 +3,7 @@ import { ACTIONS } from '../../../actions'; import { LINKS } from '../../../links'; import formatCurrency from '../../../../helpers/format-currency'; -const THRESHOLD = formatCurrency(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE, 0); +const THRESHOLD = formatCurrency(TOTAL_CONTRACT_VALUE.AMOUNT_250K, GBP_CURRENCY_CODE); const CHECK_IF_ELIGIBLE = { PAGE_TITLE: 'Check you can apply for credit insurance for your export', diff --git a/src/ui/server/controllers/insurance/business/company-details/index.ts b/src/ui/server/controllers/insurance/business/company-details/index.ts index fcd80debbb..2724d0c770 100644 --- a/src/ui/server/controllers/insurance/business/company-details/index.ts +++ b/src/ui/server/controllers/insurance/business/company-details/index.ts @@ -43,6 +43,11 @@ export const FIELD_IDS = [HAS_DIFFERENT_TRADING_NAME, HAS_DIFFERENT_TRADING_ADDR const IS_APPLICATION_SUMMARY_LIST = true; +/** + * pageVariables + * Page fields and "save and go back" URL + * @returns {Object} Page variables + */ const pageVariables = (referenceNumber: number) => ({ SAVE_AND_BACK_URL: `${INSURANCE_ROOT}/${referenceNumber}${COMPANY_DETAILS_SAVE_AND_BACK}`, DIFFERENT_COMPANIES_HOUSE_NUMBER_URL: `${INSURANCE_ROOT}/${referenceNumber}${COMPANY_DETAILS_ROOT}`, diff --git a/src/ui/server/controllers/insurance/business/company-details/save-and-back/index.ts b/src/ui/server/controllers/insurance/business/company-details/save-and-back/index.ts index 3514263381..2343f46dde 100644 --- a/src/ui/server/controllers/insurance/business/company-details/save-and-back/index.ts +++ b/src/ui/server/controllers/insurance/business/company-details/save-and-back/index.ts @@ -8,13 +8,15 @@ import { Request, Response } from '../../../../../../types'; const { INSURANCE_ROOT, EXPORTER_BUSINESS: EXPORTER_BUSINESS_ROUTES, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = ROUTES.INSURANCE; -const { COMPANY_DETAILS: COMPANY_DETAILS_ROUTE, COMPANY_DETAILS_SAVE_AND_BACK } = EXPORTER_BUSINESS_ROUTES; +const { COMPANY_DETAILS_SAVE_AND_BACK } = EXPORTER_BUSINESS_ROUTES; +/** + * pageVariables + * Page fields and "save and go back" URL + * @returns {Object} Page variables + */ const pageVariables = (referenceNumber: number) => ({ - POST_ROUTES: { - COMPANY_DETAILS: `${INSURANCE_ROOT}/${referenceNumber}${COMPANY_DETAILS_ROUTE}`, - SAVE_AND_BACK_URL: `${INSURANCE_ROOT}/${referenceNumber}${COMPANY_DETAILS_SAVE_AND_BACK}`, - }, + SAVE_AND_BACK_URL: `${INSURANCE_ROOT}/${referenceNumber}${COMPANY_DETAILS_SAVE_AND_BACK}`, FIELDS: BUSINESS_FIELD_IDS, }); diff --git a/src/ui/server/controllers/insurance/business/nature-of-business/index.test.ts b/src/ui/server/controllers/insurance/business/nature-of-business/index.test.ts index 78aba303e4..54b0991bb3 100644 --- a/src/ui/server/controllers/insurance/business/nature-of-business/index.test.ts +++ b/src/ui/server/controllers/insurance/business/nature-of-business/index.test.ts @@ -24,14 +24,8 @@ const { PROBLEM_WITH_SERVICE, } = ROUTES.INSURANCE; -const { - NATURE_OF_BUSINESS_ROOT, - TURNOVER_CURRENCY_ROOT, - NATURE_OF_BUSINESS_SAVE_AND_BACK, - CHECK_YOUR_ANSWERS, - NATURE_OF_BUSINESS_CHANGE, - NATURE_OF_BUSINESS_CHECK_AND_CHANGE, -} = EXPORTER_BUSINESS_ROUTES; +const { TURNOVER_CURRENCY_ROOT, NATURE_OF_BUSINESS_SAVE_AND_BACK, CHECK_YOUR_ANSWERS, NATURE_OF_BUSINESS_CHANGE, NATURE_OF_BUSINESS_CHECK_AND_CHANGE } = + EXPORTER_BUSINESS_ROUTES; const { NATURE_OF_YOUR_BUSINESS: NATURE_OF_YOUR_BUSINESS_FIELDS } = EXPORTER_BUSINESS_FIELDS; @@ -81,10 +75,7 @@ describe('controllers/insurance/business/nature-of-business', () => { ...NATURE_OF_YOUR_BUSINESS_FIELDS[EMPLOYEES_UK], }, }, - POST_ROUTES: { - NATURE_OF_BUSINESS: `${INSURANCE_ROOT}/${referenceNumber}${NATURE_OF_BUSINESS_ROOT}`, - SAVE_AND_BACK_URL: `${INSURANCE_ROOT}/${referenceNumber}${NATURE_OF_BUSINESS_SAVE_AND_BACK}`, - }, + SAVE_AND_BACK_URL: `${INSURANCE_ROOT}/${referenceNumber}${NATURE_OF_BUSINESS_SAVE_AND_BACK}`, }; expect(result).toEqual(expected); diff --git a/src/ui/server/controllers/insurance/business/nature-of-business/index.ts b/src/ui/server/controllers/insurance/business/nature-of-business/index.ts index 4a04d0c7ab..c96ae83216 100644 --- a/src/ui/server/controllers/insurance/business/nature-of-business/index.ts +++ b/src/ui/server/controllers/insurance/business/nature-of-business/index.ts @@ -28,10 +28,15 @@ const { PROBLEM_WITH_SERVICE, } = ROUTES.INSURANCE; -const { NATURE_OF_BUSINESS_ROOT, NATURE_OF_BUSINESS_SAVE_AND_BACK, CHECK_YOUR_ANSWERS, TURNOVER_CURRENCY_ROOT } = EXPORTER_BUSINESS_ROUTES; +const { NATURE_OF_BUSINESS_SAVE_AND_BACK, CHECK_YOUR_ANSWERS, TURNOVER_CURRENCY_ROOT } = EXPORTER_BUSINESS_ROUTES; const { NATURE_OF_YOUR_BUSINESS: NATURE_OF_YOUR_BUSINESS_FIELDS } = EXPORTER_BUSINESS_FIELDS; +/** + * pageVariables + * Page fields and "save and go back" URL + * @returns {Object} Page variables + */ const pageVariables = (referenceNumber: number) => ({ FIELDS: { GOODS_OR_SERVICES: { @@ -47,10 +52,7 @@ const pageVariables = (referenceNumber: number) => ({ ...NATURE_OF_YOUR_BUSINESS_FIELDS[EMPLOYEES_UK], }, }, - POST_ROUTES: { - NATURE_OF_BUSINESS: `${INSURANCE_ROOT}/${referenceNumber}${NATURE_OF_BUSINESS_ROOT}`, - SAVE_AND_BACK_URL: `${INSURANCE_ROOT}/${referenceNumber}${NATURE_OF_BUSINESS_SAVE_AND_BACK}`, - }, + SAVE_AND_BACK_URL: `${INSURANCE_ROOT}/${referenceNumber}${NATURE_OF_BUSINESS_SAVE_AND_BACK}`, }); /** diff --git a/src/ui/server/controllers/insurance/business/turnover-currency/save-and-back/index.ts b/src/ui/server/controllers/insurance/business/turnover-currency/save-and-back/index.ts index 6cebab86ff..5e21b2c091 100644 --- a/src/ui/server/controllers/insurance/business/turnover-currency/save-and-back/index.ts +++ b/src/ui/server/controllers/insurance/business/turnover-currency/save-and-back/index.ts @@ -46,7 +46,7 @@ export const post = async (req: Request, res: Response) => { return res.redirect(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); } catch (error) { - console.error('Error updating application - business - turnover currency (save and back) %O', error); + console.error('Error updating application - business - turnover currency (save and back) %o', error); return res.redirect(PROBLEM_WITH_SERVICE); } diff --git a/src/ui/server/controllers/insurance/check-your-answers/export-contract/index.test.ts b/src/ui/server/controllers/insurance/check-your-answers/export-contract/index.test.ts index d38be89a05..105a2acd2a 100644 --- a/src/ui/server/controllers/insurance/check-your-answers/export-contract/index.test.ts +++ b/src/ui/server/controllers/insurance/check-your-answers/export-contract/index.test.ts @@ -17,10 +17,7 @@ import { mockRes, referenceNumber, mockApplication, - mockCountries, - mockCurrencies, - mockCurrenciesEmptyResponse, - mockCurrenciesResponse, + mockCountriesAndCurrencies, mockSpyPromise, mockSpyPromiseRejection, } from '../../../../test-mocks'; @@ -46,6 +43,8 @@ const { awardMethod, } = exportContract; +const { allCurrencies, countries } = mockCountriesAndCurrencies; + describe('controllers/insurance/check-your-answers/export-contract', () => { jest.mock('../save-data'); @@ -56,19 +55,17 @@ describe('controllers/insurance/check-your-answers/export-contract', () => { let req: Request; let res: Response; - let getCountriesSpy = jest.fn(() => Promise.resolve(mockCountries)); - let getCurrenciesSpy = jest.fn(() => Promise.resolve(mockCurrenciesResponse)); + let getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve(mockCountriesAndCurrencies)); beforeEach(() => { req = mockReq(); res = mockRes(); - api.keystone.countries.getAll = getCountriesSpy; - api.keystone.APIM.getCurrencies = getCurrenciesSpy; + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; }); describe('FIELD_ID', () => { - it('should have the correct FIELD_ID', () => { + it('should have the correct ID', () => { const expected = CHECK_YOUR_ANSWERS_FIELD_IDS.EXPORT_CONTRACT; expect(FIELD_ID).toEqual(expected); @@ -96,16 +93,10 @@ describe('controllers/insurance/check-your-answers/export-contract', () => { }); describe('get', () => { - it('should call api.keystone.countries.getAll', async () => { - await get(req, res); - - expect(getCountriesSpy).toHaveBeenCalledTimes(1); - }); - - it('should call api.keystone.APIM.getCurrencies', async () => { + it('should call api.keystone.getCountriesAndCurrencies', async () => { await get(req, res); - expect(getCurrenciesSpy).toHaveBeenCalledTimes(1); + expect(getCountriesAndCurrenciesSpy).toHaveBeenCalledTimes(1); }); it('should render template', async () => { @@ -117,8 +108,8 @@ describe('controllers/insurance/check-your-answers/export-contract', () => { exportContract, totalContractValueOverThreshold, referenceNumber, - countries: mockCountries, - currencies: mockCurrencies, + countries, + currencies: allCurrencies, checkAndChange, }); @@ -160,55 +151,44 @@ describe('controllers/insurance/check-your-answers/export-contract', () => { }); }); - describe('when the get countries API call fails', () => { - beforeEach(() => { - getCountriesSpy = mockSpyPromiseRejection; - api.keystone.countries.getAll = getCountriesSpy; - }); - - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await get(req, res); - - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); - }); - }); - - describe('when the get countries response does not return a populated array', () => { - beforeEach(() => { - getCountriesSpy = jest.fn(() => Promise.resolve([])); - api.keystone.countries.getAll = getCountriesSpy; - }); + describe('api error handling', () => { + describe('when the currencies and countries API call fails', () => { + beforeEach(() => { + getCountriesAndCurrenciesSpy = mockSpyPromiseRejection; + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; + }); - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await get(req, res); + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await get(req, res); - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); }); - }); - describe('when the get currencies API call fails', () => { - beforeEach(() => { - getCurrenciesSpy = mockSpyPromiseRejection; - api.keystone.APIM.getCurrencies = getCurrenciesSpy; - }); + describe('when the get currencies and countries response does not return populated allCurrencies', () => { + beforeEach(() => { + getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve({ ...mockCountriesAndCurrencies, allCurrencies: [] })); + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; + }); - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await get(req, res); + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await get(req, res); - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); }); - }); - describe('when the get currencies response does not return a populated array', () => { - beforeEach(() => { - getCurrenciesSpy = jest.fn(() => Promise.resolve(mockCurrenciesEmptyResponse)); - api.keystone.APIM.getCurrencies = getCurrenciesSpy; - }); + describe('when the get currencies and countries response does not return populated countries', () => { + beforeEach(() => { + getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve({ ...mockCountriesAndCurrencies, countries: [] })); + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; + }); - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await get(req, res); + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await get(req, res); - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); }); }); }); diff --git a/src/ui/server/controllers/insurance/check-your-answers/export-contract/index.ts b/src/ui/server/controllers/insurance/check-your-answers/export-contract/index.ts index 72b4117f16..bdf7bbdac5 100644 --- a/src/ui/server/controllers/insurance/check-your-answers/export-contract/index.ts +++ b/src/ui/server/controllers/insurance/check-your-answers/export-contract/index.ts @@ -66,9 +66,7 @@ export const get = async (req: Request, res: Response) => { const checkAndChange = true; - const countries = await api.keystone.countries.getAll(); - - const { allCurrencies } = await api.keystone.APIM.getCurrencies(); + const { allCurrencies, countries } = await api.keystone.getCountriesAndCurrencies(); if (!isPopulatedArray(countries) || !isPopulatedArray(allCurrencies)) { return res.redirect(PROBLEM_WITH_SERVICE); diff --git a/src/ui/server/controllers/insurance/check-your-answers/policy/index.test.ts b/src/ui/server/controllers/insurance/check-your-answers/policy/index.test.ts index 8876b00baa..395495a844 100644 --- a/src/ui/server/controllers/insurance/check-your-answers/policy/index.test.ts +++ b/src/ui/server/controllers/insurance/check-your-answers/policy/index.test.ts @@ -16,11 +16,8 @@ import { mockReq, mockRes, mockApplication, - mockCurrencies, - mockCurrenciesResponse, - mockCurrenciesEmptyResponse, mockContact, - mockCountries, + mockCountriesAndCurrencies, mockNominatedLossPayee, referenceNumber, mockSpyPromise, @@ -40,6 +37,8 @@ const { const { policy, exportContract } = mockApplication; +const { allCurrencies, countries } = mockCountriesAndCurrencies; + describe('controllers/insurance/check-your-answers/policy', () => { jest.mock('../save-data'); @@ -50,19 +49,17 @@ describe('controllers/insurance/check-your-answers/policy', () => { let req: Request; let res: Response; - let getCurrenciesSpy = jest.fn(() => Promise.resolve(mockCurrenciesResponse)); - let getCountriesSpy = jest.fn(() => Promise.resolve(mockCountries)); + let getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve(mockCountriesAndCurrencies)); beforeEach(() => { req = mockReq(); res = mockRes(); - api.keystone.APIM.getCurrencies = getCurrenciesSpy; - api.keystone.countries.getAll = getCountriesSpy; + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; }); describe('FIELD_ID', () => { - it('should have the correct FIELD_ID', () => { + it('should have the correct ID', () => { const expected = CHECK_YOUR_ANSWERS_FIELD_IDS.POLICY; expect(FIELD_ID).toEqual(expected); @@ -107,8 +104,8 @@ describe('controllers/insurance/check-your-answers/policy', () => { broker: mockBroker, nominatedLossPayee: mockNominatedLossPayee, referenceNumber, - currencies: mockCurrencies, - countries: mockCountries, + currencies: allCurrencies, + countries, checkAndChange, }); @@ -136,16 +133,10 @@ describe('controllers/insurance/check-your-answers/policy', () => { expect(res.render).toHaveBeenCalledWith(TEMPLATE, expectedVariables); }); - it('should call api.keystone.countries.getAll', async () => { - await get(req, res); - - expect(getCountriesSpy).toHaveBeenCalledTimes(1); - }); - - it('should call api.keystone.APIM.getCurrencies', async () => { + it('should call api.keystone.getCountriesAndCurrencies', async () => { await get(req, res); - expect(getCurrenciesSpy).toHaveBeenCalledTimes(1); + expect(getCountriesAndCurrenciesSpy).toHaveBeenCalledTimes(1); }); describe('when there is no application', () => { @@ -161,23 +152,10 @@ describe('controllers/insurance/check-your-answers/policy', () => { }); describe('api error handling', () => { - describe('when the get currencies API call fails', () => { - beforeEach(() => { - getCurrenciesSpy = mockSpyPromiseRejection; - api.keystone.APIM.getCurrencies = getCurrenciesSpy; - }); - - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await get(req, res); - - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); - }); - }); - - describe('when the get currencies response does not return a populated array', () => { + describe('when the currencies and countries API call fails', () => { beforeEach(() => { - getCurrenciesSpy = jest.fn(() => Promise.resolve(mockCurrenciesEmptyResponse)); - api.keystone.APIM.getCurrencies = getCurrenciesSpy; + getCountriesAndCurrenciesSpy = mockSpyPromiseRejection; + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; }); it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { @@ -187,10 +165,10 @@ describe('controllers/insurance/check-your-answers/policy', () => { }); }); - describe('when the get countries API call fails', () => { + describe('when the get currencies and countries response does not return populated allCurrencies', () => { beforeEach(() => { - getCountriesSpy = mockSpyPromiseRejection; - api.keystone.countries.getAll = getCountriesSpy; + getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve({ ...mockCountriesAndCurrencies, allCurrencies: [] })); + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; }); it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { @@ -200,10 +178,10 @@ describe('controllers/insurance/check-your-answers/policy', () => { }); }); - describe('when the get countries response does not return a populated array', () => { + describe('when the get currencies and countries response does not return populated countries', () => { beforeEach(() => { - getCountriesSpy = jest.fn(() => Promise.resolve([])); - api.keystone.countries.getAll = getCountriesSpy; + getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve({ ...mockCountriesAndCurrencies, countries: [] })); + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; }); it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { diff --git a/src/ui/server/controllers/insurance/check-your-answers/policy/index.ts b/src/ui/server/controllers/insurance/check-your-answers/policy/index.ts index 2764bc1134..5cec04d004 100644 --- a/src/ui/server/controllers/insurance/check-your-answers/policy/index.ts +++ b/src/ui/server/controllers/insurance/check-your-answers/policy/index.ts @@ -59,8 +59,7 @@ export const get = async (req: Request, res: Response) => { const { policyType } = policy; const { isUsingBroker } = broker; - const { allCurrencies } = await api.keystone.APIM.getCurrencies(); - const countries = await api.keystone.countries.getAll(); + const { allCurrencies, countries } = await api.keystone.getCountriesAndCurrencies(); if (!isPopulatedArray(allCurrencies) || !isPopulatedArray(countries)) { return res.redirect(PROBLEM_WITH_SERVICE); diff --git a/src/ui/server/controllers/insurance/check-your-answers/your-business/index.test.ts b/src/ui/server/controllers/insurance/check-your-answers/your-business/index.test.ts index 99c4483062..5a9174199e 100644 --- a/src/ui/server/controllers/insurance/check-your-answers/your-business/index.test.ts +++ b/src/ui/server/controllers/insurance/check-your-answers/your-business/index.test.ts @@ -41,7 +41,7 @@ describe('controllers/insurance/check-your-answers/your-business', () => { }); describe('FIELD_ID', () => { - it('should have the correct FIELD_ID', () => { + it('should have the correct ID', () => { const expected = FIELD_IDS.CHECK_YOUR_ANSWERS.EXPORTER_BUSINESS; expect(FIELD_ID).toEqual(expected); diff --git a/src/ui/server/controllers/insurance/check-your-answers/your-buyer/index.test.ts b/src/ui/server/controllers/insurance/check-your-answers/your-buyer/index.test.ts index ba714df041..cccaccdba7 100644 --- a/src/ui/server/controllers/insurance/check-your-answers/your-buyer/index.test.ts +++ b/src/ui/server/controllers/insurance/check-your-answers/your-buyer/index.test.ts @@ -39,7 +39,7 @@ describe('controllers/insurance/check-your-answers/your-buyer', () => { }); describe('FIELD_ID', () => { - it('should have the correct FIELD_ID', () => { + it('should have the correct ID', () => { const expected = FIELD_IDS.CHECK_YOUR_ANSWERS.BUYER; expect(FIELD_ID).toEqual(expected); diff --git a/src/ui/server/controllers/insurance/export-contract/agent-charges/index.test.ts b/src/ui/server/controllers/insurance/export-contract/agent-charges/index.test.ts index b6c16ea2c8..40f40600fc 100644 --- a/src/ui/server/controllers/insurance/export-contract/agent-charges/index.test.ts +++ b/src/ui/server/controllers/insurance/export-contract/agent-charges/index.test.ts @@ -20,9 +20,7 @@ import { mockReq, mockRes, mockApplication, - mockCountries, - mockCurrencies, - mockCurrenciesResponse, + mockCountriesAndCurrencies, mockExportContractAgentServiceCharge, mockSpyPromiseRejection, referenceNumber, @@ -36,8 +34,6 @@ const { }, } = APPLICATION; -const { supportedCurrencies } = mockCurrenciesResponse; - const { INSURANCE_ROOT, PROBLEM_WITH_SERVICE, @@ -71,22 +67,23 @@ const { const currencyCode = agent.service.charge[FIXED_SUM_CURRENCY_CODE]; +const { allCurrencies, countries } = mockCountriesAndCurrencies; + describe('controllers/insurance/export-contract/agent-charges', () => { let req: Request; let res: Response; jest.mock('../map-and-save/export-contract-agent-service-charge'); - let getCountriesSpy = jest.fn(() => Promise.resolve(mockCountries)); - let getCurrenciesSpy = jest.fn(() => Promise.resolve(mockCurrenciesResponse)); + let getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve(mockCountriesAndCurrencies)); + mapAndSave.exportContractAgentServiceCharge = jest.fn(() => Promise.resolve(true)); beforeEach(() => { req = mockReq(); res = mockRes(); - api.keystone.countries.getAll = getCountriesSpy; - api.keystone.APIM.getCurrencies = getCurrenciesSpy; + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; }); afterAll(() => { @@ -115,9 +112,9 @@ describe('controllers/insurance/export-contract/agent-charges', () => { describe('pageVariables', () => { it('should have correct properties', () => { - const result = pageVariables(referenceNumber, mockCurrencies, currencyCode); + const result = pageVariables(referenceNumber, allCurrencies, currencyCode); - const currency = getCurrencyByCode(mockCurrencies, currencyCode); + const currency = getCurrencyByCode(allCurrencies, currencyCode); const expected = { FIELDS: { @@ -151,16 +148,10 @@ describe('controllers/insurance/export-contract/agent-charges', () => { }); describe('get', () => { - it('should call api.keystone.countries.getAll', async () => { + it('should call api.keystone.getCountriesAndCurrencies', async () => { await get(req, res); - expect(getCountriesSpy).toHaveBeenCalledTimes(1); - }); - - it('should call api.keystone.currencies.getAll', async () => { - await get(req, res); - - expect(getCurrenciesSpy).toHaveBeenCalledTimes(1); + expect(getCountriesAndCurrenciesSpy).toHaveBeenCalledTimes(1); }); it('should render template', async () => { @@ -171,10 +162,10 @@ describe('controllers/insurance/export-contract/agent-charges', () => { PAGE_CONTENT_STRINGS, BACK_LINK: req.headers.referer, }), - ...pageVariables(referenceNumber, supportedCurrencies, currencyCode), + ...pageVariables(referenceNumber, allCurrencies, currencyCode), userName: getUserNameFromSession(req.session.user), application: mapApplicationToFormFields(mockApplication), - countries: mapCountries(mockCountries, agent.service.charge[PAYABLE_COUNTRY_CODE]), + countries: mapCountries(countries, agent.service.charge[PAYABLE_COUNTRY_CODE]), CONDITIONAL_PERCENTAGE_HTML, }; @@ -193,55 +184,44 @@ describe('controllers/insurance/export-contract/agent-charges', () => { }); }); - describe('when the get countries API call fails', () => { - beforeEach(() => { - getCountriesSpy = mockSpyPromiseRejection; - api.keystone.countries.getAll = getCountriesSpy; - }); - - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await get(req, res); - - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); - }); - }); - - describe('when the get countries response does not return a populated array', () => { - beforeEach(() => { - getCountriesSpy = jest.fn(() => Promise.resolve([])); - api.keystone.countries.getAll = getCountriesSpy; - }); + describe('api error handling', () => { + describe('when the currencies and countries API call fails', () => { + beforeEach(() => { + getCountriesAndCurrenciesSpy = mockSpyPromiseRejection; + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; + }); - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await get(req, res); + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await get(req, res); - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); }); - }); - describe('when the get currencies API call fails', () => { - beforeEach(() => { - getCurrenciesSpy = mockSpyPromiseRejection; - api.keystone.APIM.getCurrencies = getCurrenciesSpy; - }); + describe('when the get currencies and countries response does not return populated allCurrencies', () => { + beforeEach(() => { + getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve({ ...mockCountriesAndCurrencies, allCurrencies: [] })); + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; + }); - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await get(req, res); + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await get(req, res); - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); }); - }); - describe('when the get currencies response does not return a populated array', () => { - beforeEach(() => { - getCurrenciesSpy = jest.fn(() => Promise.resolve({ ...mockCurrenciesResponse, supportedCurrencies: [] })); - api.keystone.APIM.getCurrencies = getCurrenciesSpy; - }); + describe('when the get currencies and countries response does not return populated countries', () => { + beforeEach(() => { + getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve({ ...mockCountriesAndCurrencies, countries: [] })); + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; + }); - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await get(req, res); + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await get(req, res); - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); }); }); }); @@ -264,18 +244,16 @@ describe('controllers/insurance/export-contract/agent-charges', () => { }; beforeEach(() => { - getCountriesSpy = jest.fn(() => Promise.resolve(mockCountries)); - getCurrenciesSpy = jest.fn(() => Promise.resolve(mockCurrenciesResponse)); + getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve(mockCountriesAndCurrencies)); - api.keystone.countries.getAll = getCountriesSpy; - api.keystone.APIM.getCurrencies = getCurrenciesSpy; + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; }); describe('when there are validation errors', () => { - it('should call api.keystone.countries.getAll', async () => { + it('should call api.keystone.getCountriesAndCurrencies', async () => { await post(req, res); - expect(getCountriesSpy).toHaveBeenCalledTimes(1); + expect(getCountriesAndCurrenciesSpy).toHaveBeenCalledTimes(1); }); it('should render template with validation errors and submitted values', async () => { @@ -291,65 +269,54 @@ describe('controllers/insurance/export-contract/agent-charges', () => { PAGE_CONTENT_STRINGS, BACK_LINK: req.headers.referer, }), - ...pageVariables(referenceNumber, supportedCurrencies, currencyCode), + ...pageVariables(referenceNumber, allCurrencies, currencyCode), userName: getUserNameFromSession(req.session.user), application: mapApplicationToFormFields(mockApplication), - countries: mapCountries(mockCountries, payload[PAYABLE_COUNTRY_CODE]), + countries: mapCountries(countries, payload[PAYABLE_COUNTRY_CODE]), CONDITIONAL_PERCENTAGE_HTML, submittedValues: sanitiseData(payload), validationErrors, }); }); - describe('when the get countries API call fails', () => { - beforeEach(() => { - getCountriesSpy = mockSpyPromiseRejection; - api.keystone.countries.getAll = getCountriesSpy; - }); + describe('api error handling', () => { + describe('when the currencies and countries API call fails', () => { + beforeEach(() => { + getCountriesAndCurrenciesSpy = mockSpyPromiseRejection; + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; + }); - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await post(req, res); + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await get(req, res); - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); }); - }); - describe('when the get countries API call does not return a populated array', () => { - beforeEach(() => { - getCountriesSpy = jest.fn(() => Promise.resolve([])); - api.keystone.countries.getAll = getCountriesSpy; - }); + describe('when the get currencies and countries response does not return populated allCurrencies', () => { + beforeEach(() => { + getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve({ ...mockCountriesAndCurrencies, allCurrencies: [] })); + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; + }); - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await post(req, res); + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await get(req, res); - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); }); - }); - - describe('when the get currencies API call fails', () => { - beforeEach(() => { - getCurrenciesSpy = mockSpyPromiseRejection; - api.keystone.APIM.getCurrencies = getCurrenciesSpy; - }); - - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await get(req, res); - - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); - }); - }); - describe('when the get currencies response does not return a populated array', () => { - beforeEach(() => { - getCurrenciesSpy = jest.fn(() => Promise.resolve({ ...mockCurrenciesResponse, allCurrencies: [] })); - api.keystone.APIM.getCurrencies = getCurrenciesSpy; - }); + describe('when the get currencies and countries response does not return populated countries', () => { + beforeEach(() => { + getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve({ ...mockCountriesAndCurrencies, countries: [] })); + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; + }); - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await get(req, res); + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await get(req, res); - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); + }); }); }); }); @@ -359,16 +326,10 @@ describe('controllers/insurance/export-contract/agent-charges', () => { req.body = validBody; }); - it('should NOT call api.keystone.countries.getAll', async () => { - await post(req, res); - - expect(getCountriesSpy).toHaveBeenCalledTimes(0); - }); - - it('should NOT call api.keystone.APIM.getCurrencies', async () => { + it('should NOT call api.keystone.getCountriesAndCurrencies', async () => { await post(req, res); - expect(getCurrenciesSpy).toHaveBeenCalledTimes(0); + expect(getCountriesAndCurrenciesSpy).toHaveBeenCalledTimes(0); }); it('should call mapAndSave.exportContractAgentServiceCharge with data from constructPayload function and application', async () => { diff --git a/src/ui/server/controllers/insurance/export-contract/agent-charges/index.ts b/src/ui/server/controllers/insurance/export-contract/agent-charges/index.ts index 10edb340b6..77b59f44e7 100644 --- a/src/ui/server/controllers/insurance/export-contract/agent-charges/index.ts +++ b/src/ui/server/controllers/insurance/export-contract/agent-charges/index.ts @@ -113,8 +113,7 @@ export const get = async (req: Request, res: Response) => { } = application; try { - const countries = await api.keystone.countries.getAll(); - const { allCurrencies } = await api.keystone.APIM.getCurrencies(); + const { allCurrencies, countries } = await api.keystone.getCountriesAndCurrencies(); if (!isPopulatedArray(countries) || !isPopulatedArray(allCurrencies)) { return res.redirect(PROBLEM_WITH_SERVICE); @@ -163,8 +162,7 @@ export const post = async (req: Request, res: Response) => { if (validationErrors) { try { - const countries = await api.keystone.countries.getAll(); - const { allCurrencies } = await api.keystone.APIM.getCurrencies(); + const { allCurrencies, countries } = await api.keystone.getCountriesAndCurrencies(); if (!isPopulatedArray(countries) || !isPopulatedArray(allCurrencies)) { return res.redirect(PROBLEM_WITH_SERVICE); diff --git a/src/ui/server/controllers/insurance/export-contract/agent/index.test.ts b/src/ui/server/controllers/insurance/export-contract/agent/index.test.ts index eb35071b11..e9a3c3ffd1 100644 --- a/src/ui/server/controllers/insurance/export-contract/agent/index.test.ts +++ b/src/ui/server/controllers/insurance/export-contract/agent/index.test.ts @@ -47,7 +47,7 @@ describe('controllers/insurance/export-contract/agent', () => { }); describe('FIELD_ID', () => { - it('should have the correct FIELD_ID', () => { + it('should have the correct ID', () => { expect(FIELD_ID).toEqual(USING_AGENT); }); }); diff --git a/src/ui/server/controllers/insurance/export-contract/declined-by-private-market/index.test.ts b/src/ui/server/controllers/insurance/export-contract/declined-by-private-market/index.test.ts index 88913fd45a..d14765799e 100644 --- a/src/ui/server/controllers/insurance/export-contract/declined-by-private-market/index.test.ts +++ b/src/ui/server/controllers/insurance/export-contract/declined-by-private-market/index.test.ts @@ -54,7 +54,7 @@ describe('controllers/insurance/export-contract/declined-by-private-market', () }); describe('FIELD_ID', () => { - it('should have the correct FIELD_ID', () => { + it('should have the correct ID', () => { expect(FIELD_ID).toEqual(DECLINED_DESCRIPTION); }); }); diff --git a/src/ui/server/controllers/insurance/export-contract/how-will-you-get-paid/index.test.ts b/src/ui/server/controllers/insurance/export-contract/how-will-you-get-paid/index.test.ts index 43b91c58d9..aab6444242 100644 --- a/src/ui/server/controllers/insurance/export-contract/how-will-you-get-paid/index.test.ts +++ b/src/ui/server/controllers/insurance/export-contract/how-will-you-get-paid/index.test.ts @@ -93,7 +93,7 @@ describe('controllers/insurance/export-contract/how-will-you-get-paid', () => { }); describe('FIELD_ID', () => { - it('should have the correct FIELD_ID', () => { + it('should have the correct ID', () => { expect(FIELD_ID).toEqual(PAYMENT_TERMS_DESCRIPTION); }); }); diff --git a/src/ui/server/controllers/insurance/export-contract/private-market/index.test.ts b/src/ui/server/controllers/insurance/export-contract/private-market/index.test.ts index 2869cdb6bc..1d51b816d2 100644 --- a/src/ui/server/controllers/insurance/export-contract/private-market/index.test.ts +++ b/src/ui/server/controllers/insurance/export-contract/private-market/index.test.ts @@ -55,7 +55,7 @@ describe('controllers/insurance/export-contract/private-market', () => { }); describe('FIELD_ID', () => { - it('should have the correct FIELD_ID', () => { + it('should have the correct ID', () => { expect(FIELD_ID).toEqual(ATTEMPTED); }); }); diff --git a/src/ui/server/controllers/insurance/feedback/feedback-form/index.ts b/src/ui/server/controllers/insurance/feedback/feedback-form/index.ts index 9ae1d5c935..be38e077dc 100644 --- a/src/ui/server/controllers/insurance/feedback/feedback-form/index.ts +++ b/src/ui/server/controllers/insurance/feedback/feedback-form/index.ts @@ -21,6 +21,11 @@ export const TEMPLATE = FEEDBACK_TEMPLATE; export const FIELD_IDS = [SATISFACTION, IMPROVEMENT, OTHER_COMMENTS]; +/** + * pageVariables + * Page fields + * @returns {Object} Page variables + */ const pageVariables = () => ({ FIELDS: { SATISFACTION: { diff --git a/src/ui/server/controllers/insurance/policy/check-your-answers/index.test.ts b/src/ui/server/controllers/insurance/policy/check-your-answers/index.test.ts index 563ef69f6a..852de85a38 100644 --- a/src/ui/server/controllers/insurance/policy/check-your-answers/index.test.ts +++ b/src/ui/server/controllers/insurance/policy/check-your-answers/index.test.ts @@ -13,11 +13,8 @@ import { mockReq, mockRes, mockApplication, - mockCurrencies, mockContact, - mockCountries, - mockCurrenciesResponse, - mockCurrenciesEmptyResponse, + mockCountriesAndCurrencies, mockNominatedLossPayee, mockSpyPromiseRejection, referenceNumber, @@ -30,19 +27,19 @@ const { POLICY } = FIELD_IDS.INSURANCE; const { policy, exportContract } = mockApplication; +const { allCurrencies, countries } = mockCountriesAndCurrencies; + describe('controllers/insurance/policy/check-your-answers', () => { let req: Request; let res: Response; - let getCurrenciesSpy = jest.fn(() => Promise.resolve(mockCurrenciesResponse)); - let getCountriesSpy = jest.fn(() => Promise.resolve(mockCountries)); + let getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve(mockCountriesAndCurrencies)); beforeEach(() => { req = mockReq(); res = mockRes(); - api.keystone.APIM.getCurrencies = getCurrenciesSpy; - api.keystone.countries.getAll = getCountriesSpy; + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; }); afterAll(() => { @@ -69,16 +66,10 @@ describe('controllers/insurance/policy/check-your-answers', () => { }); describe('get', () => { - it('should call api.keystone.countries.getAll', async () => { - await get(req, res); - - expect(getCountriesSpy).toHaveBeenCalledTimes(1); - }); - - it('should call api.keystone.APIM.getCurrencies', async () => { + it('should call api.keystone.getCountriesAndCurrencies', async () => { await get(req, res); - expect(getCurrenciesSpy).toHaveBeenCalledTimes(1); + expect(getCountriesAndCurrenciesSpy).toHaveBeenCalledTimes(1); }); it('should render template', async () => { @@ -95,8 +86,8 @@ describe('controllers/insurance/policy/check-your-answers', () => { broker: mockBroker, nominatedLossPayee: mockNominatedLossPayee, referenceNumber, - currencies: mockCurrencies, - countries: mockCountries, + currencies: allCurrencies, + countries, }); const expectedVariables = { @@ -126,10 +117,10 @@ describe('controllers/insurance/policy/check-your-answers', () => { }); describe('api error handling', () => { - describe('when the get currencies API call fails', () => { + describe('when the currencies and countries API call fails', () => { beforeEach(() => { - getCurrenciesSpy = mockSpyPromiseRejection; - api.keystone.APIM.getCurrencies = getCurrenciesSpy; + getCountriesAndCurrenciesSpy = mockSpyPromiseRejection; + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; }); it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { @@ -139,10 +130,10 @@ describe('controllers/insurance/policy/check-your-answers', () => { }); }); - describe('when the get currencies response does not return a populated array', () => { + describe('when the get currencies and countries response does not return populated allCurrencies', () => { beforeEach(() => { - getCurrenciesSpy = jest.fn(() => Promise.resolve(mockCurrenciesEmptyResponse)); - api.keystone.APIM.getCurrencies = getCurrenciesSpy; + getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve({ ...mockCountriesAndCurrencies, allCurrencies: [] })); + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; }); it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { @@ -152,10 +143,10 @@ describe('controllers/insurance/policy/check-your-answers', () => { }); }); - describe('when the get countries API call fails', () => { + describe('when the get currencies and countries response does not return populated countries', () => { beforeEach(() => { - getCountriesSpy = mockSpyPromiseRejection; - api.keystone.countries.getAll = getCountriesSpy; + getCountriesAndCurrenciesSpy = jest.fn(() => Promise.resolve({ ...mockCountriesAndCurrencies, countries: [] })); + api.keystone.getCountriesAndCurrencies = getCountriesAndCurrenciesSpy; }); it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { diff --git a/src/ui/server/controllers/insurance/policy/check-your-answers/index.ts b/src/ui/server/controllers/insurance/policy/check-your-answers/index.ts index aa90b6f322..2053df2211 100644 --- a/src/ui/server/controllers/insurance/policy/check-your-answers/index.ts +++ b/src/ui/server/controllers/insurance/policy/check-your-answers/index.ts @@ -44,8 +44,7 @@ export const get = async (req: Request, res: Response) => { const { referenceNumber, policy, exportContract, policyContact, broker, nominatedLossPayee } = application; try { - const { allCurrencies } = await api.keystone.APIM.getCurrencies(); - const countries = await api.keystone.countries.getAll(); + const { allCurrencies, countries } = await api.keystone.getCountriesAndCurrencies(); if (!isPopulatedArray(allCurrencies) || !isPopulatedArray(countries)) { return res.redirect(PROBLEM_WITH_SERVICE); diff --git a/src/ui/server/controllers/insurance/your-buyer/buyer-financial-information/index.ts b/src/ui/server/controllers/insurance/your-buyer/buyer-financial-information/index.ts index c9264de122..c1c9a15ab5 100644 --- a/src/ui/server/controllers/insurance/your-buyer/buyer-financial-information/index.ts +++ b/src/ui/server/controllers/insurance/your-buyer/buyer-financial-information/index.ts @@ -38,9 +38,9 @@ export const PAGE_CONTENT_STRINGS = PAGES.INSURANCE.YOUR_BUYER.BUYER_FINANCIAL_I /** * pageVariables - * returns pageVariables for buyer-financial information + * Page fields and "save and go back" URL * @param {Number} referenceNumber: Application reference number - * @returns {Object} pageVariables + * @returns {Object} Page variables */ export const pageVariables = (referenceNumber: number) => ({ FIELD_ID: HAS_BUYER_FINANCIAL_ACCOUNTS, diff --git a/src/ui/server/controllers/insurance/your-buyer/failed-to-pay-on-time/index.ts b/src/ui/server/controllers/insurance/your-buyer/failed-to-pay-on-time/index.ts index a1b978a80a..7266db6600 100644 --- a/src/ui/server/controllers/insurance/your-buyer/failed-to-pay-on-time/index.ts +++ b/src/ui/server/controllers/insurance/your-buyer/failed-to-pay-on-time/index.ts @@ -28,9 +28,10 @@ export const TEMPLATE = TEMPLATES.SHARED_PAGES.SINGLE_RADIO; export const PAGE_CONTENT_STRINGS = PAGES.INSURANCE.YOUR_BUYER.FAILED_PAYMENTS; /** - * pageVariables for failed-to-pay-on-time page + * pageVariables + * Page fields and "save and go back" URL * @param {Number} referenceNumber: Application reference number - * @returns {Object} pageVariables + * @returns {Object} Page variables */ export const pageVariables = (referenceNumber: number) => ({ FIELD_ID, diff --git a/src/ui/server/controllers/insurance/your-buyer/outstanding-or-overdue-payments/index.ts b/src/ui/server/controllers/insurance/your-buyer/outstanding-or-overdue-payments/index.ts index 8ff537bd53..a87a6c12dc 100644 --- a/src/ui/server/controllers/insurance/your-buyer/outstanding-or-overdue-payments/index.ts +++ b/src/ui/server/controllers/insurance/your-buyer/outstanding-or-overdue-payments/index.ts @@ -43,7 +43,7 @@ export const TEMPLATE = TEMPLATES.INSURANCE.YOUR_BUYER.OUTSTANDING_OR_OVERDUE_PA export const PAGE_CONTENT_STRINGS = PAGES.INSURANCE.YOUR_BUYER.OUTSTANDING_OR_OVERDUE_PAYMENTS; /** - * pageVariables for outstanding-or-overdue page + * Page fields and "save and go back" URL * @param {Number} referenceNumber: Application reference number * @param {Array} currencies: Currencies * @param {String} currencyCode: Provided currency code diff --git a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-high-risk.test.ts b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-high-risk.test.ts index 46f5eca1f6..e967d8f52a 100644 --- a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-high-risk.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-high-risk.test.ts @@ -11,10 +11,11 @@ describe('server/generate-quote/get-premium-rate', () => { }; describe('multiple policy - high risk', () => { - const riskCategory = EXTERNAL_API_MAPPINGS.CIS.RISK.HIGH; + const esraClassification = EXTERNAL_API_MAPPINGS.CIS.RISK.HIGH; + const mock = { ...mockBase, - riskCategory, + esraClassification, creditPeriodInMonths: 1, }; @@ -24,7 +25,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.creditPeriodInMonths + 1, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.creditPeriodInMonths + 1, mock.insuredFor); expect(result).toEqual(expected); @@ -40,7 +41,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.creditPeriodInMonths + 1, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.creditPeriodInMonths + 1, mock.insuredFor); expect(result).toEqual(expected); diff --git a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-standard-risk.test.ts b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-standard-risk.test.ts index 6326a3cd0e..5582dd3fcc 100644 --- a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-standard-risk.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-standard-risk.test.ts @@ -11,10 +11,11 @@ describe('server/generate-quote/get-premium-rate', () => { }; describe('multiple policy - standard risk', () => { - const riskCategory = EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; + const esraClassification = EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; + const mock = { ...mockBase, - riskCategory, + esraClassification, creditPeriodInMonths: 1, }; @@ -24,7 +25,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.creditPeriodInMonths + 1, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.creditPeriodInMonths + 1, mock.insuredFor); expect(result).toEqual(expected); @@ -40,7 +41,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.creditPeriodInMonths + 1, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.creditPeriodInMonths + 1, mock.insuredFor); expect(result).toEqual(expected); diff --git a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-very-high-risk.test.ts b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-very-high-risk.test.ts index e9de048325..bea014d7c9 100644 --- a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-very-high-risk.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-multi-policy-very-high-risk.test.ts @@ -11,10 +11,11 @@ describe('server/generate-quote/get-premium-rate', () => { }; describe('multiple policy - very high risk', () => { - const riskCategory = EXTERNAL_API_MAPPINGS.CIS.RISK.VERY_HIGH; + const esraClassification = EXTERNAL_API_MAPPINGS.CIS.RISK.VERY_HIGH; + const mock = { ...mockBase, - riskCategory, + esraClassification, creditPeriodInMonths: 1, }; @@ -24,7 +25,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.creditPeriodInMonths + 1, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.creditPeriodInMonths + 1, mock.insuredFor); expect(result).toEqual(expected); @@ -40,7 +41,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.creditPeriodInMonths + 1, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.creditPeriodInMonths + 1, mock.insuredFor); expect(result).toEqual(expected); diff --git a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-high-risk.test.ts b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-high-risk.test.ts index 741accb185..07e6c8f3f1 100644 --- a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-high-risk.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-high-risk.test.ts @@ -17,10 +17,11 @@ describe('server/generate-quote/get-premium-rate', () => { }; describe('single policy - high risk', () => { - const riskCategory = EXTERNAL_API_MAPPINGS.CIS.RISK.HIGH; + const esraClassification = EXTERNAL_API_MAPPINGS.CIS.RISK.HIGH; + const mock = { ...mockBase, - riskCategory, + esraClassification, policyLengthInMonths: 2, }; @@ -30,7 +31,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -46,7 +47,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -62,7 +63,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -78,7 +79,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -94,7 +95,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -110,7 +111,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -126,7 +127,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -142,7 +143,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); diff --git a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-standard-risk.test.ts b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-standard-risk.test.ts index 4dec48ad30..16b244c0db 100644 --- a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-standard-risk.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-standard-risk.test.ts @@ -17,10 +17,11 @@ describe('server/generate-quote/get-premium-rate', () => { }; describe('single policy - standard risk', () => { - const riskCategory = EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; + const esraClassification = EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD; + const mock = { ...mockBase, - riskCategory, + esraClassification, policyLengthInMonths: 2, }; @@ -30,7 +31,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -46,7 +47,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -62,7 +63,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -78,7 +79,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -94,7 +95,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -110,7 +111,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -126,7 +127,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -142,7 +143,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); diff --git a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-very-high.test.ts b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-very-high.test.ts index 83680211e9..a8d530871f 100644 --- a/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-very-high.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/get-premium-rate-single-policy-very-high.test.ts @@ -17,10 +17,11 @@ describe('server/generate-quote/get-premium-rate', () => { }; describe('single policy - very high risk', () => { - const riskCategory = EXTERNAL_API_MAPPINGS.CIS.RISK.VERY_HIGH; + const esraClassification = EXTERNAL_API_MAPPINGS.CIS.RISK.VERY_HIGH; + const mock = { ...mockBase, - riskCategory, + esraClassification, policyLengthInMonths: 2, }; @@ -30,7 +31,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -46,7 +47,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -62,7 +63,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -78,7 +79,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -94,7 +95,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -110,7 +111,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -126,7 +127,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); @@ -142,7 +143,7 @@ describe('server/generate-quote/get-premium-rate', () => { }); it('should return a premium rate from pricing grid', () => { - const { result, expected } = getResultAndExpected(mock.policyType, mock.riskCategory, mock.policyLengthInMonths, mock.insuredFor); + const { result, expected } = getResultAndExpected(mock.policyType, mock.esraClassification, mock.policyLengthInMonths, mock.insuredFor); expect(result).toEqual(expected); diff --git a/src/ui/server/generate-quote/get-premium-rate/index.test.ts b/src/ui/server/generate-quote/get-premium-rate/index.test.ts index e9e654bea3..319367545b 100644 --- a/src/ui/server/generate-quote/get-premium-rate/index.test.ts +++ b/src/ui/server/generate-quote/get-premium-rate/index.test.ts @@ -33,18 +33,28 @@ const getAvailableCover = (policyType: string, risk: string, coverMonths: number PRICING_GRID[policyType][risk].find((month: PricingGridMonth) => month.months === coverMonths); describe('server/generate-quote/get-premium-rate', () => { - it('returns a number', () => { - const mock = { - policyType: FIELD_VALUES.POLICY_TYPE.MULTIPLE, - insuredFor: 80, - riskCategory: EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD, - totalMonths: 2, - }; + const mock = { + policyType: FIELD_VALUES.POLICY_TYPE.MULTIPLE, + insuredFor: 80, + esraClassification: EXTERNAL_API_MAPPINGS.CIS.RISK.STANDARD, + totalMonths: 2, + }; - const result = getPremiumRate(mock.policyType, mock.riskCategory, mock.totalMonths, mock.insuredFor); + it('returns a number', () => { + const result = getPremiumRate(mock.policyType, mock.esraClassification, mock.totalMonths, mock.insuredFor); expect(typeof result).toEqual('number'); }); + + describe('when the mapping fails', () => { + it('should throw an error', () => { + const invalidEsraClassification = 'invalid classification'; + + expect(() => getPremiumRate(mock.policyType, invalidEsraClassification, mock.totalMonths, mock.insuredFor)).toThrow( + new Error(`Getting premium rate TypeError: Cannot read properties of undefined (reading 'find')`), + ); + }); + }); }); export { getResultAndExpected, getAvailableCover }; diff --git a/src/ui/server/generate-quote/get-premium-rate/index.ts b/src/ui/server/generate-quote/get-premium-rate/index.ts index 676c86a487..82475b9243 100644 --- a/src/ui/server/generate-quote/get-premium-rate/index.ts +++ b/src/ui/server/generate-quote/get-premium-rate/index.ts @@ -16,26 +16,34 @@ const PRICING_GRID_MAP = { /** * getPremiumRate - * @param {String} Type of policy - * @param {Number} Risk category - * @param {Number} Length of the policy in months - * @param {Number} Percentage of the export that will be insured + * @param {String} policyType: Type of policy + * @param {String | null} esraClassification: ESRA classification + * @param {Number} totalMonths: Length of the policy in months + * @param {Number} insuredFor: Percentage of the export that will be insured * @returns {Number} Premium rate percentage */ -const getPremiumRate = (policyType: string, riskCategory: string, totalMonths: number, insuredFor: number): number => { - const policyTypeKey = PRICING_GRID_MAP.POLICY_TYPE[policyType]; +const getPremiumRate = (policyType: string, esraClassification: string, totalMonths: number, insuredFor: number): number => { + try { + console.info('Getting premium rate'); - const riskCategoryKey = PRICING_GRID_MAP.RISK_CATEGORY[riskCategory]; + const policyTypeKey = PRICING_GRID_MAP.POLICY_TYPE[policyType]; - const pricingGrid: any = PRICING_GRID as PricingGrid; + const esraClassificationKey = PRICING_GRID_MAP.RISK_CATEGORY[esraClassification]; - const risk = pricingGrid[policyTypeKey][riskCategoryKey]; + const pricingGrid: PricingGrid = PRICING_GRID; - const pricingGridMonth = risk.find((month: PricingGridMonth) => month.months === totalMonths); + const risk = pricingGrid[policyTypeKey][esraClassificationKey]; - const rateObj = pricingGridMonth.rates.find((rate: PricingGridRate) => rate.insuredFor === insuredFor); + const pricingGridMonth = risk.find((month: PricingGridMonth) => month.months === totalMonths); - return rateObj.premiumRate; + const rateObj = pricingGridMonth.rates.find((rate: PricingGridRate) => rate.insuredFor === insuredFor); + + return rateObj.premiumRate; + } catch (error) { + console.error('Error getting premium rate %o', error); + + throw new Error(`Getting premium rate ${error}`); + } }; export { PRICING_GRID_MAP, getPremiumRate }; diff --git a/src/ui/server/generate-quote/index.test.ts b/src/ui/server/generate-quote/index.test.ts index 391c1efe57..d91bfbe5d4 100644 --- a/src/ui/server/generate-quote/index.test.ts +++ b/src/ui/server/generate-quote/index.test.ts @@ -21,6 +21,7 @@ describe('server/generate-quote/index', () => { }; const result = getContractValue(mockSubmittedData); + const expected = { [CONTRACT_VALUE]: mockSubmittedData[CONTRACT_VALUE], }; @@ -37,6 +38,7 @@ describe('server/generate-quote/index', () => { }; const result = getContractValue(mockSubmittedData); + const expected = { [MAX_AMOUNT_OWED]: mockSubmittedData[MAX_AMOUNT_OWED], }; @@ -64,6 +66,7 @@ describe('server/generate-quote/index', () => { }; const result = getInsuredFor(mockSubmittedData.quoteEligibility); + const expected = Number(getPercentageOfNumber(80, 1234)); expect(result).toEqual(expected); @@ -81,6 +84,7 @@ describe('server/generate-quote/index', () => { }; const result = getInsuredFor(mockSubmittedData.quoteEligibility); + const expected = Number(getPercentageOfNumber(80, 5678)); expect(result).toEqual(expected); @@ -161,7 +165,7 @@ describe('server/generate-quote/index', () => { const expectedPremiumRate = getPremiumRate( mockSubmittedData.quoteEligibility[POLICY_TYPE], - mockSubmittedData.quoteEligibility[BUYER_COUNTRY].riskCategory, + mockSubmittedData.quoteEligibility[BUYER_COUNTRY].esraClassification, expectedTotalMonths, mockPercentageOfCover, ); diff --git a/src/ui/server/generate-quote/index.ts b/src/ui/server/generate-quote/index.ts index 65aaa2e6bd..902597ed6b 100644 --- a/src/ui/server/generate-quote/index.ts +++ b/src/ui/server/generate-quote/index.ts @@ -99,32 +99,40 @@ const calculateEstimatedCost = (premiumRate: number, contractValue: number) => N * @returns {Object} Quote with premium rate and estimated cost */ const generateQuote = (submittedData: SubmittedData): Quote => { - const contractValue = getContractValue(submittedData.quoteEligibility); + try { + console.info('Generating quote'); + + const contractValue = getContractValue(submittedData.quoteEligibility); + + const mapped = { + ...contractValue, + percentageOfCover: submittedData.quoteEligibility[PERCENTAGE_OF_COVER], + insuredFor: getInsuredFor(submittedData.quoteEligibility), + buyerCountry: submittedData.quoteEligibility[BUYER_COUNTRY], + currency: submittedData.quoteEligibility[CURRENCY], + creditPeriodInMonths: submittedData.quoteEligibility[CREDIT_PERIOD], + policyType: submittedData.quoteEligibility[POLICY_TYPE], + policyLength: submittedData.quoteEligibility[POLICY_LENGTH], + }; - const mapped = { - ...contractValue, - percentageOfCover: submittedData.quoteEligibility[PERCENTAGE_OF_COVER], - insuredFor: getInsuredFor(submittedData.quoteEligibility), - buyerCountry: submittedData.quoteEligibility[BUYER_COUNTRY], - currency: submittedData.quoteEligibility[CURRENCY], - creditPeriodInMonths: submittedData.quoteEligibility[CREDIT_PERIOD], - policyType: submittedData.quoteEligibility[POLICY_TYPE], - policyLength: submittedData.quoteEligibility[POLICY_LENGTH], - }; + const totalMonths = getTotalMonths(mapped[POLICY_TYPE], mapped[POLICY_LENGTH], mapped[CREDIT_PERIOD]); - const totalMonths = getTotalMonths(mapped[POLICY_TYPE], mapped[POLICY_LENGTH], mapped[CREDIT_PERIOD]); + const premiumRate = getPremiumRate(mapped[POLICY_TYPE], mapped[BUYER_COUNTRY].esraClassification, totalMonths, mapped[PERCENTAGE_OF_COVER]); - const premiumRate = getPremiumRate(mapped[POLICY_TYPE], mapped[BUYER_COUNTRY].riskCategory, totalMonths, mapped[PERCENTAGE_OF_COVER]); + const [contractValueAmount] = Object.values(contractValue); - const [contractValueAmount] = Object.values(contractValue); + const quote = { + ...mapped, + premiumRatePercentage: premiumRate, + estimatedCost: calculateEstimatedCost(premiumRate, contractValueAmount), + }; - const quote = { - ...mapped, - premiumRatePercentage: premiumRate, - estimatedCost: calculateEstimatedCost(premiumRate, contractValueAmount), - }; + return quote; + } catch (error) { + console.error('Error generating quote %o', error); - return quote; + throw new Error(`Generating quote ${error}`); + } }; export { getContractValue, getInsuredFor, getTotalMonths, calculateEstimatedCost, generateQuote }; diff --git a/src/ui/server/graphql/queries/APIM/CIS-countries.ts b/src/ui/server/graphql/queries/APIM/CIS-countries.ts index f0e8506ca8..f155b38aac 100644 --- a/src/ui/server/graphql/queries/APIM/CIS-countries.ts +++ b/src/ui/server/graphql/queries/APIM/CIS-countries.ts @@ -5,7 +5,7 @@ const getApimCisCountries = gql` getApimCisCountries { isoCode name - riskCategory + esraClassification canGetAQuoteOnline canGetAQuoteOffline canGetAQuoteByEmail diff --git a/src/ui/server/graphql/queries/countries-and-currencies.ts b/src/ui/server/graphql/queries/countries-and-currencies.ts new file mode 100644 index 0000000000..ab04b0f1f6 --- /dev/null +++ b/src/ui/server/graphql/queries/countries-and-currencies.ts @@ -0,0 +1,26 @@ +import gql from 'graphql-tag'; + +const getCountriesAndCurrencies = gql` + query getCountriesAndCurrencies { + getCountriesAndCurrencies { + countries { + isoCode + name + } + supportedCurrencies { + isoCode + name + } + alternativeCurrencies { + isoCode + name + } + allCurrencies { + isoCode + name + } + } + } +`; + +export default getCountriesAndCurrencies; diff --git a/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.test.ts b/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.test.ts index bbee7391f2..2f8eb6bce1 100644 --- a/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.test.ts +++ b/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.test.ts @@ -25,7 +25,7 @@ describe('server/helpers/mappings/map-submitted-eligibility-country', () => { [BUYER_COUNTRY]: { name: mappedCountry.name, isoCode: mappedCountry.isoCode, - riskCategory: mappedCountry.riskCategory, + esraClassification: mappedCountry.esraClassification, canApplyOnline: countryCanGetAQuoteOnline.canGetAQuoteOnline, }, }; @@ -51,7 +51,7 @@ describe('server/helpers/mappings/map-submitted-eligibility-country', () => { [BUYER_COUNTRY]: { name: mappedCountry.name, isoCode: mappedCountry.isoCode, - riskCategory: mappedCountry.riskCategory, + esraClassification: mappedCountry.esraClassification, canApplyOnline: countryCanApplyForInsuranceOnline.canApplyForInsuranceOnline, }, }; diff --git a/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.ts b/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.ts index f7cf2ecfc5..a89a0848c4 100644 --- a/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.ts +++ b/src/ui/server/helpers/mappings/map-submitted-eligibility-country/index.ts @@ -12,13 +12,13 @@ const { * @returns {Object} Object with BUYER_COUNTRY object, country fields and canApplyOnline flag */ const mapSubmittedEligibilityCountry = (country: Country) => { - const { name, isoCode, riskCategory } = country; + const { name, isoCode, esraClassification } = country; const mapped = { [BUYER_COUNTRY]: { name, isoCode, - riskCategory, + esraClassification, canApplyOnline: country.canGetAQuoteOnline || country.canApplyForInsuranceOnline, }, }; diff --git a/src/ui/server/helpers/page-variables/core/index.test.ts b/src/ui/server/helpers/page-variables/core/index.test.ts index 69811c64e2..d8d6eb1b77 100644 --- a/src/ui/server/helpers/page-variables/core/index.test.ts +++ b/src/ui/server/helpers/page-variables/core/index.test.ts @@ -64,6 +64,7 @@ describe('server/helpers/page-variables/core', () => { ATTRIBUTES, DATA_CY: { HEADING: 'heading', + HEADING_CAPTION: 'heading-caption', BACK_LINK: 'back-link', INTRO: 'intro', }, @@ -101,6 +102,7 @@ describe('server/helpers/page-variables/core', () => { ATTRIBUTES, DATA_CY: { HEADING: 'heading', + HEADING_CAPTION: 'heading-caption', BACK_LINK: 'back-link', INTRO: 'intro', }, @@ -138,6 +140,7 @@ describe('server/helpers/page-variables/core', () => { ATTRIBUTES, DATA_CY: { HEADING: 'heading', + HEADING_CAPTION: 'heading-caption', BACK_LINK: 'back-link', INTRO: 'intro', }, @@ -176,6 +179,7 @@ describe('server/helpers/page-variables/core', () => { ATTRIBUTES, DATA_CY: { HEADING: 'heading', + HEADING_CAPTION: 'heading-caption', BACK_LINK: 'back-link', INTRO: 'intro', }, @@ -214,6 +218,7 @@ describe('server/helpers/page-variables/core', () => { ATTRIBUTES, DATA_CY: { HEADING: 'heading', + HEADING_CAPTION: 'heading-caption', BACK_LINK: 'back-link', INTRO: 'intro', }, diff --git a/src/ui/server/helpers/page-variables/core/index.ts b/src/ui/server/helpers/page-variables/core/index.ts index 5d6645e59d..77480fd1c5 100644 --- a/src/ui/server/helpers/page-variables/core/index.ts +++ b/src/ui/server/helpers/page-variables/core/index.ts @@ -74,6 +74,7 @@ const corePageVariables = ({ PAGE_CONTENT_STRINGS, BACK_LINK, ORIGINAL_URL, USE_ ATTRIBUTES, DATA_CY: { HEADING: 'heading', + HEADING_CAPTION: 'heading-caption', BACK_LINK: 'back-link', INTRO: 'intro', }, diff --git a/src/ui/server/shared-validation/phone-number/index.test.ts b/src/ui/server/shared-validation/phone-number/index.test.ts index a7957b1ed4..163f7d8bea 100644 --- a/src/ui/server/shared-validation/phone-number/index.test.ts +++ b/src/ui/server/shared-validation/phone-number/index.test.ts @@ -10,49 +10,49 @@ describe('shared-validation/phone-number', () => { const errorMessage = 'incorrect format'; describe('with errors', () => { - it(`should display error when phone number is ${INVALID_PHONE_NUMBERS.EMERGENCY_NUMBER}`, () => { + it(`should return an error when phone number is ${INVALID_PHONE_NUMBERS.EMERGENCY_NUMBER}`, () => { const result = validatePhoneNumber(INVALID_PHONE_NUMBERS.EMERGENCY_NUMBER, fieldId, errorMessage, errors); const expected = generateValidationErrors(fieldId, errorMessage); expect(result).toEqual(expected); }); - it('should display error when landline number is too long', () => { + it('should return an error when landline number is too long', () => { const result = validatePhoneNumber(INVALID_PHONE_NUMBERS.LANDLINE_LONG, fieldId, errorMessage, errors); const expected = generateValidationErrors(fieldId, errorMessage); expect(result).toEqual(expected); }); - it('should display error when landline number is too short', () => { + it('should return an error when landline number is too short', () => { const result = validatePhoneNumber(INVALID_PHONE_NUMBERS.LANDLINE_SHORT, fieldId, errorMessage, errors); const expected = generateValidationErrors(fieldId, errorMessage); expect(result).toEqual(expected); }); - it('should display error when mobile number is too long', () => { + it('should return an error when mobile number is too long', () => { const result = validatePhoneNumber(INVALID_PHONE_NUMBERS.MOBILE_LONG, fieldId, errorMessage, errors); const expected = generateValidationErrors(fieldId, errorMessage); expect(result).toEqual(expected); }); - it('should display error when number has letters in it', () => { + it('should return an error when number has letters in it', () => { const result = validatePhoneNumber(INVALID_PHONE_NUMBERS.LANDLINE_LETTER, fieldId, errorMessage, errors); const expected = generateValidationErrors(fieldId, errorMessage); expect(result).toEqual(expected); }); - it('should display error when number has special characters in it', () => { + it('should return an error when number has special characters in it', () => { const result = validatePhoneNumber(INVALID_PHONE_NUMBERS.LANDLINE_SPECIAL_CHAR, fieldId, errorMessage, errors); const expected = generateValidationErrors(fieldId, errorMessage); expect(result).toEqual(expected); }); - it('should display error entering international number', () => { + it('should return an error entering international number', () => { let result = validatePhoneNumber(INVALID_PHONE_NUMBERS.INTERNATIONAL, fieldId, errorMessage, errors); let expected = generateValidationErrors(fieldId, errorMessage); @@ -69,28 +69,28 @@ describe('shared-validation/phone-number', () => { expect(result).toEqual(expected); }); - it('should display error entering just 2 digits', () => { + it('should return an error entering just 2 digits', () => { const result = validatePhoneNumber(INVALID_PHONE_NUMBERS.TOO_SHORT, fieldId, errorMessage, errors); const expected = generateValidationErrors(fieldId, errorMessage); expect(result).toEqual(expected); }); - it('should display error entering just 2 digits with a special character', () => { + it('should return an error entering just 2 digits with a special character', () => { const result = validatePhoneNumber(INVALID_PHONE_NUMBERS.TOO_SHORT_SPECIAL_CHAR, fieldId, errorMessage, errors); const expected = generateValidationErrors(fieldId, errorMessage); expect(result).toEqual(expected); }); - it('should display error entering mobile number with a special character', () => { + it('should return an error entering mobile number with a special character', () => { const result = validatePhoneNumber(INVALID_PHONE_NUMBERS.MOBILE_SPECIAL_CHAR, fieldId, errorMessage, errors); const expected = generateValidationErrors(fieldId, errorMessage); expect(result).toEqual(expected); }); - it('should display error entering mobile number which is above 191 characters', () => { + it('should return an error entering mobile number which is above 191 characters', () => { const result = validatePhoneNumber(INVALID_PHONE_NUMBERS.ABOVE_MAX_CHARS, fieldId, errorMessage, errors); const expected = generateValidationErrors(fieldId, errorMessage); diff --git a/src/ui/server/test-mocks/index.ts b/src/ui/server/test-mocks/index.ts index 8cb499fbc7..65e7b14551 100644 --- a/src/ui/server/test-mocks/index.ts +++ b/src/ui/server/test-mocks/index.ts @@ -6,6 +6,7 @@ import mockAnswers from './mock-answers'; import mockSession from './mock-session'; import mockQuote from './mock-quote'; import mockCountries from './mock-countries'; +import mockCountriesAndCurrencies from './mock-countries-and-currencies'; import mockCurrencies, { EUR, HKD, JPY, GBP, USD, mockCurrenciesResponse, mockCurrenciesEmptyResponse } from './mock-currencies'; import mockCompaniesHouseResponse from './mock-companies-house-response'; import mockCompany from './mock-company'; @@ -156,6 +157,7 @@ export { mockBuyerRelationship, mockBuyerTradingHistory, mockCountries, + mockCountriesAndCurrencies, mockCompaniesHouseResponse, mockCompany, mockCreateApplicationResponse, diff --git a/src/ui/server/test-mocks/mock-application.ts b/src/ui/server/test-mocks/mock-application.ts index baf9172910..2115199452 100644 --- a/src/ui/server/test-mocks/mock-application.ts +++ b/src/ui/server/test-mocks/mock-application.ts @@ -189,7 +189,7 @@ export const mockApplicationDeclaration = { const mockApplication = { id: 'clacdgc630000kdoqn7wcgrz1', referenceNumber, - version: APPLICATION.LATEST_VERSION.LATEST_VERSION_NUMBER, + version: APPLICATION.LATEST_VERSION_NUMBER, createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), dealType: APPLICATION.DEAL_TYPE, diff --git a/src/ui/server/test-mocks/mock-countries-and-currencies.ts b/src/ui/server/test-mocks/mock-countries-and-currencies.ts new file mode 100644 index 0000000000..3a2b7f802b --- /dev/null +++ b/src/ui/server/test-mocks/mock-countries-and-currencies.ts @@ -0,0 +1,9 @@ +import { mockCurrenciesResponse } from './mock-currencies'; +import mockCountries from './mock-countries'; + +const mockCountriesAndCurrencies = { + ...mockCurrenciesResponse, + countries: mockCountries, +}; + +export default mockCountriesAndCurrencies; diff --git a/src/ui/server/test-mocks/mock-countries.ts b/src/ui/server/test-mocks/mock-countries.ts index 980366f7e5..300b0b402a 100644 --- a/src/ui/server/test-mocks/mock-countries.ts +++ b/src/ui/server/test-mocks/mock-countries.ts @@ -26,7 +26,7 @@ const mockCountries = [ name: 'Abu Dhabi', ...baseCountry, isoCode: 'XAD', - riskCategory: RISK.STANDARD, + esraClassification: RISK.STANDARD, shortTermCover: false, canGetAQuoteOnline: false, canApplyForInsuranceOnline: false, @@ -35,7 +35,7 @@ const mockCountries = [ { name: 'Algeria', isoCode: 'DZA', - riskCategory: RISK.STANDARD, + esraClassification: RISK.STANDARD, ...baseCountry, }, /** @@ -46,7 +46,7 @@ const mockCountries = [ { name: 'Egypt', isoCode: 'EGY', - riskCategory: RISK.VERY_HIGH, + esraClassification: RISK.VERY_HIGH, ...baseCountry, canGetAQuoteOnline: false, canGetAQuoteByEmail: true, @@ -58,7 +58,7 @@ const mockCountries = [ { name: 'Gabon', isoCode: 'GAB', - riskCategory: RISK.VERY_HIGH, + esraClassification: RISK.VERY_HIGH, ...baseCountry, canGetAQuoteOnline: false, canApplyForInsuranceOnline: false, @@ -72,7 +72,7 @@ const mockCountries = [ name: 'Gibraltar', isoCode: 'GIB', ...baseCountry, - riskCategory: RISK.STANDARD, + esraClassification: RISK.STANDARD, canGetAQuoteOnline: false, canGetAQuoteOffline: false, canApplyForInsuranceOnline: false, @@ -88,7 +88,7 @@ const mockCountries = [ name: 'France', isoCode: 'FRA', ...baseCountry, - riskCategory: RISK.STANDARD, + esraClassification: RISK.STANDARD, canGetAQuoteOnline: true, canGetAQuoteOffline: true, canApplyForInsuranceOnline: true, diff --git a/src/ui/templates/insurance/check-your-answers/check-your-answers.njk b/src/ui/templates/insurance/check-your-answers/check-your-answers.njk index 1f7c14cd5c..2a6f4f08ac 100644 --- a/src/ui/templates/insurance/check-your-answers/check-your-answers.njk +++ b/src/ui/templates/insurance/check-your-answers/check-your-answers.njk @@ -34,7 +34,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/declarations/anti-bribery.njk b/src/ui/templates/insurance/declarations/anti-bribery.njk index d1c9c0c37a..13b4ab902d 100644 --- a/src/ui/templates/insurance/declarations/anti-bribery.njk +++ b/src/ui/templates/insurance/declarations/anti-bribery.njk @@ -27,7 +27,7 @@ }) }} {% endif %} - {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/declarations/confidentiality.njk b/src/ui/templates/insurance/declarations/confidentiality.njk index 5d625dc1ed..06fc2998b3 100644 --- a/src/ui/templates/insurance/declarations/confidentiality.njk +++ b/src/ui/templates/insurance/declarations/confidentiality.njk @@ -27,7 +27,7 @@ }) }} {% endif %} - {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/eligibility/check-your-answers.njk b/src/ui/templates/insurance/eligibility/check-your-answers.njk index 45680499ab..0d0443a076 100644 --- a/src/ui/templates/insurance/eligibility/check-your-answers.njk +++ b/src/ui/templates/insurance/eligibility/check-your-answers.njk @@ -21,7 +21,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

{{ govukSummaryList({ diff --git a/src/ui/templates/insurance/export-contract/about-goods-or-services.njk b/src/ui/templates/insurance/export-contract/about-goods-or-services.njk index 5f90c0a06d..1d6b63f2a6 100644 --- a/src/ui/templates/insurance/export-contract/about-goods-or-services.njk +++ b/src/ui/templates/insurance/export-contract/about-goods-or-services.njk @@ -28,7 +28,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/export-contract/agent-charges.njk b/src/ui/templates/insurance/export-contract/agent-charges.njk index dba0a5530d..17c061b556 100644 --- a/src/ui/templates/insurance/export-contract/agent-charges.njk +++ b/src/ui/templates/insurance/export-contract/agent-charges.njk @@ -29,7 +29,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/export-contract/agent-details.njk b/src/ui/templates/insurance/export-contract/agent-details.njk index b0ece5ce46..fc013458cd 100644 --- a/src/ui/templates/insurance/export-contract/agent-details.njk +++ b/src/ui/templates/insurance/export-contract/agent-details.njk @@ -30,7 +30,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/export-contract/agent-service.njk b/src/ui/templates/insurance/export-contract/agent-service.njk index 12faffafa8..e459f6718b 100644 --- a/src/ui/templates/insurance/export-contract/agent-service.njk +++ b/src/ui/templates/insurance/export-contract/agent-service.njk @@ -28,7 +28,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/export-contract/check-your-answers.njk b/src/ui/templates/insurance/export-contract/check-your-answers.njk index d3d9cd602d..eda4346e2e 100644 --- a/src/ui/templates/insurance/export-contract/check-your-answers.njk +++ b/src/ui/templates/insurance/export-contract/check-your-answers.njk @@ -19,7 +19,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/export-contract/declined-by-private-market.njk b/src/ui/templates/insurance/export-contract/declined-by-private-market.njk index 2a0f629b58..eee79408a9 100644 --- a/src/ui/templates/insurance/export-contract/declined-by-private-market.njk +++ b/src/ui/templates/insurance/export-contract/declined-by-private-market.njk @@ -27,7 +27,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/export-contract/how-much-the-agent-is-charging.njk b/src/ui/templates/insurance/export-contract/how-much-the-agent-is-charging.njk index ebcb976492..421bafaa0d 100644 --- a/src/ui/templates/insurance/export-contract/how-much-the-agent-is-charging.njk +++ b/src/ui/templates/insurance/export-contract/how-much-the-agent-is-charging.njk @@ -28,7 +28,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/export-contract/how-was-the-contract-awarded.njk b/src/ui/templates/insurance/export-contract/how-was-the-contract-awarded.njk index d250e78237..b48c21185d 100644 --- a/src/ui/templates/insurance/export-contract/how-was-the-contract-awarded.njk +++ b/src/ui/templates/insurance/export-contract/how-was-the-contract-awarded.njk @@ -26,7 +26,7 @@ }) }} {% endif %} - + {{ CONTENT_STRINGS.HEADING_CAPTION }} diff --git a/src/ui/templates/insurance/export-contract/how-will-you-get-paid.njk b/src/ui/templates/insurance/export-contract/how-will-you-get-paid.njk index 3d8556f052..d944fda147 100644 --- a/src/ui/templates/insurance/export-contract/how-will-you-get-paid.njk +++ b/src/ui/templates/insurance/export-contract/how-will-you-get-paid.njk @@ -27,7 +27,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/policy/broker-confirm-address.njk b/src/ui/templates/insurance/policy/broker-confirm-address.njk index 82f46ceb20..6b71c2d981 100644 --- a/src/ui/templates/insurance/policy/broker-confirm-address.njk +++ b/src/ui/templates/insurance/policy/broker-confirm-address.njk @@ -24,7 +24,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/policy/broker-details.njk b/src/ui/templates/insurance/policy/broker-details.njk index bed1bec279..110feb50e3 100644 --- a/src/ui/templates/insurance/policy/broker-details.njk +++ b/src/ui/templates/insurance/policy/broker-details.njk @@ -34,7 +34,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/policy/check-your-answers.njk b/src/ui/templates/insurance/policy/check-your-answers.njk index d3d9cd602d..eda4346e2e 100644 --- a/src/ui/templates/insurance/policy/check-your-answers.njk +++ b/src/ui/templates/insurance/policy/check-your-answers.njk @@ -19,7 +19,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/policy/different-name-on-policy.njk b/src/ui/templates/insurance/policy/different-name-on-policy.njk index 714eded5af..1951bf2269 100644 --- a/src/ui/templates/insurance/policy/different-name-on-policy.njk +++ b/src/ui/templates/insurance/policy/different-name-on-policy.njk @@ -36,7 +36,7 @@
- + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/policy/loss-payee-details.njk b/src/ui/templates/insurance/policy/loss-payee-details.njk index 92502ad4e4..142c55f20c 100644 --- a/src/ui/templates/insurance/policy/loss-payee-details.njk +++ b/src/ui/templates/insurance/policy/loss-payee-details.njk @@ -36,7 +36,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/policy/loss-payee-financial-details-international.njk b/src/ui/templates/insurance/policy/loss-payee-financial-details-international.njk index 975de5a1a0..8be0f9151a 100644 --- a/src/ui/templates/insurance/policy/loss-payee-financial-details-international.njk +++ b/src/ui/templates/insurance/policy/loss-payee-financial-details-international.njk @@ -32,7 +32,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/policy/loss-payee-financial-details-uk.njk b/src/ui/templates/insurance/policy/loss-payee-financial-details-uk.njk index a9675e4c5f..ac91a32a14 100644 --- a/src/ui/templates/insurance/policy/loss-payee-financial-details-uk.njk +++ b/src/ui/templates/insurance/policy/loss-payee-financial-details-uk.njk @@ -32,7 +32,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/policy/multiple-contract-policy-export-value.njk b/src/ui/templates/insurance/policy/multiple-contract-policy-export-value.njk index ad71793fdb..244297588a 100644 --- a/src/ui/templates/insurance/policy/multiple-contract-policy-export-value.njk +++ b/src/ui/templates/insurance/policy/multiple-contract-policy-export-value.njk @@ -27,7 +27,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }} {{ CURRENCY_NAME }}

@@ -57,8 +57,21 @@ {% set MAXIMUM_HINT = FIELDS.MAXIMUM_BUYER_WILL_OWE.HINT %} {% set maximumBuyerWillOweHintHtml %} -

{{ MAXIMUM_HINT.FOR_EXAMPLE }}

-

{{ MAXIMUM_HINT.NO_DECIMALS }}

+ +
+
+ +

{{ MAXIMUM_HINT.FOR_EXAMPLE }}

+ +

+ {{ MAXIMUM_HINT.INITIAL_CREDIT_LIMIT.INTRO }}  + {{ MAXIMUM_HINT.INITIAL_CREDIT_LIMIT.LINK.TEXT }} +

+ +

{{ MAXIMUM_HINT.NO_DECIMALS }}

+ +
+
{% endset %} {{ monetaryValueInput.render({ diff --git a/src/ui/templates/insurance/policy/multiple-contract-policy.njk b/src/ui/templates/insurance/policy/multiple-contract-policy.njk index 27ecf5d568..dd46cf27f9 100644 --- a/src/ui/templates/insurance/policy/multiple-contract-policy.njk +++ b/src/ui/templates/insurance/policy/multiple-contract-policy.njk @@ -29,7 +29,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/policy/name-on-policy.njk b/src/ui/templates/insurance/policy/name-on-policy.njk index a00e96ffe7..72c3c85783 100644 --- a/src/ui/templates/insurance/policy/name-on-policy.njk +++ b/src/ui/templates/insurance/policy/name-on-policy.njk @@ -29,7 +29,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/policy/other-company-details.njk b/src/ui/templates/insurance/policy/other-company-details.njk index 5886bd40ba..79ae1c02f6 100644 --- a/src/ui/templates/insurance/policy/other-company-details.njk +++ b/src/ui/templates/insurance/policy/other-company-details.njk @@ -32,7 +32,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/policy/single-contract-policy-total-contract-value.njk b/src/ui/templates/insurance/policy/single-contract-policy-total-contract-value.njk index d5a88bb5e3..34e3a3d459 100644 --- a/src/ui/templates/insurance/policy/single-contract-policy-total-contract-value.njk +++ b/src/ui/templates/insurance/policy/single-contract-policy-total-contract-value.njk @@ -29,7 +29,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/policy/single-contract-policy.njk b/src/ui/templates/insurance/policy/single-contract-policy.njk index 3db2a5dfb9..6b67873abb 100644 --- a/src/ui/templates/insurance/policy/single-contract-policy.njk +++ b/src/ui/templates/insurance/policy/single-contract-policy.njk @@ -29,7 +29,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/policy/type-of-policy.njk b/src/ui/templates/insurance/policy/type-of-policy.njk index 49d7c727e3..479e46f010 100644 --- a/src/ui/templates/insurance/policy/type-of-policy.njk +++ b/src/ui/templates/insurance/policy/type-of-policy.njk @@ -33,7 +33,7 @@
{% set legendHtml %} - {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/your-business/alternative-trading-address.njk b/src/ui/templates/insurance/your-business/alternative-trading-address.njk index ce61b7152f..6a943f2a28 100644 --- a/src/ui/templates/insurance/your-business/alternative-trading-address.njk +++ b/src/ui/templates/insurance/your-business/alternative-trading-address.njk @@ -31,7 +31,7 @@
- + {{ CONTENT_STRINGS.HEADING_CAPTION }}
diff --git a/src/ui/templates/insurance/your-business/check-your-answers.njk b/src/ui/templates/insurance/your-business/check-your-answers.njk index 2b49e677b3..295b4fdd23 100644 --- a/src/ui/templates/insurance/your-business/check-your-answers.njk +++ b/src/ui/templates/insurance/your-business/check-your-answers.njk @@ -19,7 +19,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/your-business/company-details.njk b/src/ui/templates/insurance/your-business/company-details.njk index b05c673ac5..58bba66da8 100644 --- a/src/ui/templates/insurance/your-business/company-details.njk +++ b/src/ui/templates/insurance/your-business/company-details.njk @@ -35,7 +35,7 @@
- + {{ CONTENT_STRINGS.HEADING_CAPTION }} diff --git a/src/ui/templates/insurance/your-business/nature-of-your-business.njk b/src/ui/templates/insurance/your-business/nature-of-your-business.njk index d94d8bf2ef..41ae0a3610 100644 --- a/src/ui/templates/insurance/your-business/nature-of-your-business.njk +++ b/src/ui/templates/insurance/your-business/nature-of-your-business.njk @@ -34,7 +34,7 @@
- + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

@@ -97,7 +97,7 @@ {{ formButtons.render({ contentStrings: CONTENT_STRINGS.BUTTONS, - saveAndBackUrl: POST_ROUTES.SAVE_AND_BACK_URL + saveAndBackUrl: SAVE_AND_BACK_URL }) }}
diff --git a/src/ui/templates/insurance/your-business/turnover.njk b/src/ui/templates/insurance/your-business/turnover.njk index 4f7df80478..8d5b240b9a 100644 --- a/src/ui/templates/insurance/your-business/turnover.njk +++ b/src/ui/templates/insurance/your-business/turnover.njk @@ -37,7 +37,7 @@
- + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/your-buyer/check-your-answers.njk b/src/ui/templates/insurance/your-buyer/check-your-answers.njk index 1ad7b45af7..036803bd11 100644 --- a/src/ui/templates/insurance/your-buyer/check-your-answers.njk +++ b/src/ui/templates/insurance/your-buyer/check-your-answers.njk @@ -20,7 +20,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/your-buyer/company-or-organisation.njk b/src/ui/templates/insurance/your-buyer/company-or-organisation.njk index 57c2292506..8aac1dde2a 100644 --- a/src/ui/templates/insurance/your-buyer/company-or-organisation.njk +++ b/src/ui/templates/insurance/your-buyer/company-or-organisation.njk @@ -29,7 +29,7 @@
- {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/insurance/your-buyer/outstanding-or-overdue-payments.njk b/src/ui/templates/insurance/your-buyer/outstanding-or-overdue-payments.njk index 1a4c47f850..5e107aee74 100644 --- a/src/ui/templates/insurance/your-buyer/outstanding-or-overdue-payments.njk +++ b/src/ui/templates/insurance/your-buyer/outstanding-or-overdue-payments.njk @@ -35,7 +35,7 @@
- + {{ CONTENT_STRINGS.HEADING_CAPTION }} diff --git a/src/ui/templates/insurance/your-buyer/trading-history.njk b/src/ui/templates/insurance/your-buyer/trading-history.njk index 10c5719ef3..adf93d3d01 100644 --- a/src/ui/templates/insurance/your-buyer/trading-history.njk +++ b/src/ui/templates/insurance/your-buyer/trading-history.njk @@ -37,7 +37,7 @@
- + {{ CONTENT_STRINGS.HEADING_CAPTION }} diff --git a/src/ui/templates/shared-pages/currency.njk b/src/ui/templates/shared-pages/currency.njk index 0ec0c02652..66d313a607 100644 --- a/src/ui/templates/shared-pages/currency.njk +++ b/src/ui/templates/shared-pages/currency.njk @@ -35,7 +35,7 @@
- + {{ CONTENT_STRINGS.HEADING_CAPTION }} diff --git a/src/ui/templates/shared-pages/declaration.njk b/src/ui/templates/shared-pages/declaration.njk index cf627ac649..42e1592f4b 100644 --- a/src/ui/templates/shared-pages/declaration.njk +++ b/src/ui/templates/shared-pages/declaration.njk @@ -26,7 +26,7 @@ }) }} {% endif %} - {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }}

{{ CONTENT_STRINGS.PAGE_TITLE }}

diff --git a/src/ui/templates/shared-pages/single-radio.njk b/src/ui/templates/shared-pages/single-radio.njk index 2a7d733e62..8000013dc4 100644 --- a/src/ui/templates/shared-pages/single-radio.njk +++ b/src/ui/templates/shared-pages/single-radio.njk @@ -33,7 +33,7 @@ {% set submittedAnswer = submittedValues[FIELD_ID] or applicationAnswer %} {% endif %} - {{ CONTENT_STRINGS.HEADING_CAPTION }} + {{ CONTENT_STRINGS.HEADING_CAPTION }} diff --git a/src/ui/types/application.ts b/src/ui/types/application.ts index 610ee11634..e1ce67aa92 100644 --- a/src/ui/types/application.ts +++ b/src/ui/types/application.ts @@ -263,6 +263,7 @@ interface ApplicationPolicy { totalSalesToBuyer?: number; maximumBuyerWillOwe?: number; jointlyInsuredParty: ApplicationJointlyInsuredParty; + requestedCreditLimit?: number; } interface Application extends ApplicationCore { @@ -290,13 +291,21 @@ interface ApplicationFlatCore extends ApplicationCore, InsuranceEligibilityCore, type ApplicationFlat = ApplicationFlatCore & ApplicationPolicy & ApplicationBroker & ApplicationCompany & ApplicationDeclaration; +interface ApplicationVersionSmallExportBuilder { + MAXIMUM_BUYER_WILL_OWE: number; +} + interface ApplicationVersion { VERSION_NUMBER: string; OVER_500K_SUPPORT: boolean; - MAXIMUM_BUYER_CAN_OWE: number; - TOTAL_VALUE_OF_CONTRACT: number; - DEFAULT_FINAL_DESTINATION_KNOWN: boolean; - DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: boolean; + MAXIMUM_BUYER_CAN_OWE?: number; + TOTAL_VALUE_OF_CONTRACT?: number; + DEFAULT_FINAL_DESTINATION_KNOWN: boolean | null; + DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: boolean | null; + DEFAULT_CURRENCY?: string; + BROKER_ADDRESS_AS_MULTIPLE_FIELDS: boolean; + REQUESTED_CREDIT_LIMIT_REQUIRED?: boolean; + SMALL_EXPORT_BUILDER?: ApplicationVersionSmallExportBuilder; } export { diff --git a/src/ui/types/country.d.ts b/src/ui/types/country.d.ts index 12cb54e958..09be7ddc94 100644 --- a/src/ui/types/country.d.ts +++ b/src/ui/types/country.d.ts @@ -2,7 +2,7 @@ interface Country { id?: string; name: string; isoCode: string; - riskCategory: string; + esraClassification?: string; selected?: boolean; value: string; canGetAQuoteOnline: boolean; diff --git a/src/ui/types/page-variables.d.ts b/src/ui/types/page-variables.d.ts index d31c7fc387..ee621514f0 100644 --- a/src/ui/types/page-variables.d.ts +++ b/src/ui/types/page-variables.d.ts @@ -16,6 +16,7 @@ interface PageVariablesContentStrings { interface PageVariablesDataCy { HEADING: string; + HEADING_CAPTION: string; BACK_LINK: string; INTRO: string; }