From c606a36ea6dfdeb60babf6afa3defdbc1118ae64 Mon Sep 17 00:00:00 2001 From: Tony Barnes Date: Wed, 8 Jan 2025 13:14:11 +0000 Subject: [PATCH] feat(EMS-3979): broker details - task list logic (#3325) * feat(EMS-3979): broker details - task list logic * feat(EMS-3979): update required policy fields * chore(e2e): remove irrelevant flag from e2e tests * feat(EMS-3979): fix typo * feat(EMS-3979): fix typo * feat(EMS-3979): fix completePolicySection command * feat(EMS-3979): task list updates * chore(EMS-3979): tidy up * chore(EMS-3979): temporarily disable e2e test * chore(EMS-3979): add missing fields to prepare application required fields * chore(EMS-3979): fix typo --- ...mplete-and-submit-broker-addresses-form.js | 12 +++ .../complete-and-submit-broker-form.js | 2 +- .../complete-and-submit-loss-payee-form.js | 2 +- .../complete-broker-addresses-form.js | 19 ++++ .../insurance/complete-buyer-section.js | 2 +- .../insurance/complete-declarations.js | 2 +- .../insurance/complete-policy-section.js | 19 +++- ...pplication-section-multiple-policy-type.js | 3 + ...-application-section-single-policy-type.js | 3 + ...plete-sign-in-and-submit-an-application.js | 6 +- ...submit-buyer-financial-information-form.js | 2 +- ...d-submit-connection-with-the-buyer-form.js | 2 +- ...plete-and-submit-traded-with-buyer-form.js | 2 +- ...mplete-buyer-financial-information-form.js | 2 +- ...complete-connection-with-the-buyer-form.js | 2 +- .../complete-traded-with-buyer-form.js | 2 +- .../field-ids/insurance/policy/index.js | 14 ++- ...licy-type-business-fully-populated.spec.js | 1 - ...policy-type-policy-fully-populated.spec.js | 1 + ...licy-type-with-broker-based-in-uk.spec.js} | 3 +- ...y-type-with-broker-not-based-in-uk.spec.js | 34 +++++++ ...ltiple-policy-type-fully-populated.spec.js | 1 + ...licy-type-business-fully-populated.spec.js | 1 - ...policy-type-policy-fully-populated.spec.js | 1 + ...licy-type-with-broker-based-in-uk.spec.js} | 7 +- ...y-type-with-broker-not-based-in-uk.spec.js | 31 ++++++ ...single-policy-type-fully-populated.spec.js | 1 + ...ur-answers-change-broker-no-to-yes.spec.js | 3 +- .../support/application/policy/index.js | 2 + src/api/.keystone/config.js | 26 ++--- .../allowed-graphql-resolvers/index.ts | 2 +- .../field-ids/insurance/policy/index.ts | 14 ++- .../field-ids/insurance/policy/index.ts | 14 ++- .../insurance/all-sections/index.test.ts | 3 +- .../insurance/all-sections/index.ts | 3 +- .../queries/ordnance-survey-address.ts | 2 +- .../flatten-application-data/index.test.ts | 24 +---- .../helpers/flatten-application-data/index.ts | 29 +----- .../map-broker/index.test.ts | 96 +++++++++++++++++++ .../map-broker/index.ts | 57 +++++++++++ .../required-fields/policy/index.test.ts | 23 ++++- .../helpers/required-fields/policy/index.ts | 27 ++++-- .../prepare-application/index.test.ts | 9 ++ .../prepare-application/index.ts | 9 ++ .../generate-groups-and-tasks/index.test.ts | 4 +- .../generate-groups-and-tasks/index.ts | 3 + .../prepare-application.test.ts | 4 +- .../prepare-application.ts | 3 + src/ui/types/application.ts | 1 + src/ui/types/task-list.ts | 1 + 50 files changed, 431 insertions(+), 105 deletions(-) create mode 100644 e2e-tests/commands/insurance/complete-and-submit-broker-addresses-form.js create mode 100644 e2e-tests/commands/insurance/complete-broker-addresses-form.js rename e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/{submit-an-application-multiple-policy-type-with-broker.spec.js => submit-an-application-multiple-policy-type-with-broker-based-in-uk.spec.js} (81%) create mode 100644 e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-with-broker-not-based-in-uk.spec.js rename e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/{submit-an-application-single-policy-type-with-broker.spec.js => submit-an-application-single-policy-type-with-broker-based-in-uk.spec.js} (67%) create mode 100644 e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-with-broker-not-based-in-uk.spec.js create mode 100644 src/ui/server/helpers/flatten-application-data/map-broker/index.test.ts create mode 100644 src/ui/server/helpers/flatten-application-data/map-broker/index.ts diff --git a/e2e-tests/commands/insurance/complete-and-submit-broker-addresses-form.js b/e2e-tests/commands/insurance/complete-and-submit-broker-addresses-form.js new file mode 100644 index 0000000000..931c3ae247 --- /dev/null +++ b/e2e-tests/commands/insurance/complete-and-submit-broker-addresses-form.js @@ -0,0 +1,12 @@ +/** + * completeAndSubmitBrokerAddressesForm + * Complete and submit "broker addresses" form + * @param {String} optionValue: Address option value + */ +const completeAndSubmitBrokerAddressesForm = ({ optionValue }) => { + cy.completeBrokerAddressesForm({ optionValue }); + + cy.clickSubmitButton(); +}; + +export default completeAndSubmitBrokerAddressesForm; diff --git a/e2e-tests/commands/insurance/complete-and-submit-broker-form.js b/e2e-tests/commands/insurance/complete-and-submit-broker-form.js index 56a67afe85..4f94a4f81a 100644 --- a/e2e-tests/commands/insurance/complete-and-submit-broker-form.js +++ b/e2e-tests/commands/insurance/complete-and-submit-broker-form.js @@ -1,7 +1,7 @@ /** * completeAndSubmitBrokerForm * Complete and submit "using broker" form - * @param {Boolean} usingBroker: Should submit "yes" or "no" to "using a broker". Defaults to "no". + * @param {Boolean} usingBroker: Should submit "yes" or "no" to "using a broker". Defaults to false. */ const completeAndSubmitBrokerForm = ({ usingBroker = false }) => { if (usingBroker) { diff --git a/e2e-tests/commands/insurance/complete-and-submit-loss-payee-form.js b/e2e-tests/commands/insurance/complete-and-submit-loss-payee-form.js index 6f9ac7c988..7af28c9095 100644 --- a/e2e-tests/commands/insurance/complete-and-submit-loss-payee-form.js +++ b/e2e-tests/commands/insurance/complete-and-submit-loss-payee-form.js @@ -1,7 +1,7 @@ /** * completeAndSubmitLossPayeeForm * Complete and submit "loss payee" form - * @param {Boolean} isAppointingLossPayee: Should submit "yes" or "no" to "appointing a loss payee". Defaults to "no". + * @param {Boolean} isAppointingLossPayee: Should submit "yes" or "no" to "appointing a loss payee". Defaults to false. */ const completeAndSubmitLossPayeeForm = ({ isAppointingLossPayee = false }) => { if (isAppointingLossPayee) { diff --git a/e2e-tests/commands/insurance/complete-broker-addresses-form.js b/e2e-tests/commands/insurance/complete-broker-addresses-form.js new file mode 100644 index 0000000000..9316f495d7 --- /dev/null +++ b/e2e-tests/commands/insurance/complete-broker-addresses-form.js @@ -0,0 +1,19 @@ +import { radios } from '../../pages/shared'; +import { POLICY as POLICY_FIELD_IDS } from '../../constants/field-ids/insurance/policy'; + +const { + BROKER_ADDRESSES: { SELECT_THE_ADDRESS: FIELD_ID }, +} = POLICY_FIELD_IDS; + +/** + * completeBrokerAddressesForm + * Complete "broker addresses" form + * @param {String} optionValue: Address option value + */ +const completeBrokerAddressesForm = ({ optionValue = 'BRITISH BROADCASTING CORPORATION WOGAN HOUSE PORTLAND PLACE' }) => { + const optionId = `${FIELD_ID}-${optionValue}`; + + radios(optionId).option.label().click(); +}; + +export default completeBrokerAddressesForm; diff --git a/e2e-tests/commands/insurance/complete-buyer-section.js b/e2e-tests/commands/insurance/complete-buyer-section.js index 055d458ff8..6b4cde3bd0 100644 --- a/e2e-tests/commands/insurance/complete-buyer-section.js +++ b/e2e-tests/commands/insurance/complete-buyer-section.js @@ -2,7 +2,7 @@ * completeBuyerSection * Complete the "Buyer" section * @param {Boolean} viaTaskList: Start the "buyer" section from the task list. - * @param {Boolean} hasConnectionToBuyer: Should submit "yes" to "have connection to buyer" radio. Defaults to "no". + * @param {Boolean} hasConnectionToBuyer: Should submit "yes" to "have connection to buyer" radio. Defaults to false. * @param {Boolean} exporterHasTradedWithBuyer: Submit "yes" to "have traded with buyer before" in the "working with buyer" form. * @param {Boolean} outstandingPayments: Exporter has outstanding payments with the buyer * @param {Boolean} failedToPay: Buyer has failed to pay the exporter on the time diff --git a/e2e-tests/commands/insurance/complete-declarations.js b/e2e-tests/commands/insurance/complete-declarations.js index bc7c361ce5..7564700894 100644 --- a/e2e-tests/commands/insurance/complete-declarations.js +++ b/e2e-tests/commands/insurance/complete-declarations.js @@ -4,7 +4,7 @@ import { FIELD_VALUES } from '../../constants'; * completeDeclarations * Runs through the full declarations journey * @param {Object} Object with flags on how to complete specific declaration forms. - * - exportingWithCodeOfConduct: Should submit "yes" in the "exporting with code of conduct" form. Defaults to "yes". + * - exportingWithCodeOfConduct: Should submit "yes" in the "exporting with code of conduct" form. Defaults to true. */ const completeDeclarations = ({ hasAntiBriberyCodeOfConduct = true, exportingWithCodeOfConduct = true }) => { cy.clickTaskDeclarationsAndSubmit(); diff --git a/e2e-tests/commands/insurance/complete-policy-section.js b/e2e-tests/commands/insurance/complete-policy-section.js index 6b69314828..1e60465052 100644 --- a/e2e-tests/commands/insurance/complete-policy-section.js +++ b/e2e-tests/commands/insurance/complete-policy-section.js @@ -12,9 +12,10 @@ const { POLICY_TYPE } = APPLICATION; * @param {Boolean} alternativeCurrency: Select the "alternative currency" option * @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 - * @param {Boolean} otherCompanyInvolved: If "another company to be insured" is on - defaults to false - * @param {Boolean} isAppointingLossPayee: Should submit "yes" or "no" to "appointing a loss payee". Defaults to "no". + * @param {Boolean} usingBroker: If "using broker" - defaults to false + * @param {Boolean} brokerIsBasedInUk: Broker is based in the UK - defaults to false + * @param {Boolean} otherCompanyInvolved: Should submit "yes" to "another company to be insured". Defaults to false. + * @param {Boolean} isAppointingLossPayee: Should submit "yes" or "no" to "appointing a loss payee". Defaults to false. * @param {Boolean} lossPayeeIsLocatedInUK: Should submit "UK" to "loss payee details". Defaults to false. * @param {Boolean} submitCheckYourAnswers: Click policy "check your answers" submit button */ @@ -27,6 +28,7 @@ const completePolicySection = ({ sameName = true, needPreCreditPeriod = false, usingBroker = false, + brokerIsBasedInUk = false, otherCompanyInvolved = false, isAppointingLossPayee = false, lossPayeeIsLocatedInUK = false, @@ -69,9 +71,16 @@ const completePolicySection = ({ cy.completeAndSubmitBrokerForm({ usingBroker }); if (usingBroker) { - cy.completeAndSubmitBrokerDetailsForm({}); + cy.completeAndSubmitBrokerDetailsForm({ isBasedInUk: brokerIsBasedInUk }); - cy.completeAndSubmitBrokerManualAddressForm({}); + if (brokerIsBasedInUk) { + cy.completeAndSubmitBrokerAddressesForm({}); + + // submit the "confirm broker address" form + cy.clickSubmitButton(); + } else { + cy.completeAndSubmitBrokerManualAddressForm({}); + } } cy.completeAndSubmitLossPayeeForm({ isAppointingLossPayee }); 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..17af3f490b 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 @@ -41,6 +41,7 @@ const { POLICY_TYPE } = APPLICATION; * @param {Boolean} submitCheckYourAnswers: Should click each section's "check your answers" submit button. * @param {Boolean} totalContractValueOverThreshold: If total contract value in eligibility should be over threshold. * @param {Boolean} usingBroker: Should submit "yes" or "no" to "using a broker". + * @param {Boolean} brokerIsBasedInUk: Should submit "yes or "no" to "broker is based in the UK". */ const completePrepareApplicationMultiplePolicyType = ({ agentChargeMethodFixedSum = false, @@ -78,6 +79,7 @@ const completePrepareApplicationMultiplePolicyType = ({ totalContractValueOverThreshold = false, submitCheckYourAnswers = true, usingBroker = false, + brokerIsBasedInUk = false, }) => { cy.completeBusinessSection({ differentTradingName, @@ -106,6 +108,7 @@ const completePrepareApplicationMultiplePolicyType = ({ policyValueOverMvpMaximum, submitCheckYourAnswers, usingBroker, + brokerIsBasedInUk, otherCompanyInvolved, needPreCreditPeriod, isAppointingLossPayee, diff --git a/e2e-tests/commands/insurance/complete-prepare-application-section-single-policy-type.js b/e2e-tests/commands/insurance/complete-prepare-application-section-single-policy-type.js index 48b187c7e2..36d0462fbf 100644 --- a/e2e-tests/commands/insurance/complete-prepare-application-section-single-policy-type.js +++ b/e2e-tests/commands/insurance/complete-prepare-application-section-single-policy-type.js @@ -41,6 +41,7 @@ const { POLICY_TYPE } = FIELD_VALUES; * @param {Boolean} submitCheckYourAnswers: Should click each section's "check your answers" submit button. * @param {Boolean} totalContractValueOverThreshold: If total contract value in eligibility should be over threshold. * @param {Boolean} usingBroker: Should submit "yes" or "no" to "using a broker". + * @param {Boolean} brokerIsBasedInUk: Should submit "yes or "no" to "broker is based in the UK". */ const completePrepareApplicationSinglePolicyType = ({ agentChargeMethodFixedSum = false, @@ -78,6 +79,7 @@ const completePrepareApplicationSinglePolicyType = ({ totalContractValueOverThreshold = false, submitCheckYourAnswers = true, usingBroker = false, + brokerIsBasedInUk = false, }) => { cy.completeBusinessSection({ differentTradingName, @@ -106,6 +108,7 @@ const completePrepareApplicationSinglePolicyType = ({ policyValueOverMvpMaximum, submitCheckYourAnswers, usingBroker, + brokerIsBasedInUk, otherCompanyInvolved, needPreCreditPeriod, isAppointingLossPayee, 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..1b448f445a 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 @@ -35,11 +35,12 @@ import completeSignInAndGoToApplication from './account/complete-sign-in-and-go- * @param {Boolean} isUsingAgent: Should submit "yes" to "using an agent" form. * @param {Boolean} lossPayeeIsLocatedInUK: Should submit "UK" to "loss payee details". * @param {Boolean} needPreCreditPeriod: If the user needs a pre-credit period. - * @param {Boolean} otherCompanyInvolved: If "another company to be insured" is on. + * @param {Boolean} otherCompanyInvolved: Should submit "yes" to "another company to be insured". * @param {Boolean} policyValueOverMvpMaximum: Should submit an application with the value over the MVP maximum amount. * @param {Boolean} submitCheckYourAnswers: Should click each section's "check your answers" submit button. * @param {Boolean} totalContractValueOverThreshold: If total contract value in eligibility should be over threshold. * @param {Boolean} usingBroker: Should submit "yes" or "no" to "using a broker". + * @param {Boolean} brokerIsBasedInUk: Should submit "yes or "no" to "broker is based in the UK". * @return {String} Application reference number */ const completeSignInAndSubmitAnApplication = ({ @@ -76,6 +77,7 @@ const completeSignInAndSubmitAnApplication = ({ policyValueOverMvpMaximum = false, totalContractValueOverThreshold = false, usingBroker = false, + brokerIsBasedInUk = false, }) => { completeSignInAndGoToApplication({ companyNumber, @@ -113,6 +115,7 @@ const completeSignInAndSubmitAnApplication = ({ referenceNumber, totalContractValueOverThreshold, usingBroker, + brokerIsBasedInUk, }); } else { cy.completePrepareApplicationSinglePolicyType({ @@ -145,6 +148,7 @@ const completeSignInAndSubmitAnApplication = ({ referenceNumber, totalContractValueOverThreshold, usingBroker, + brokerIsBasedInUk, }); } cy.completeAndSubmitCheckYourAnswers(); diff --git a/e2e-tests/commands/insurance/your-buyer/complete-and-submit-buyer-financial-information-form.js b/e2e-tests/commands/insurance/your-buyer/complete-and-submit-buyer-financial-information-form.js index e5eb844303..bde9ad9640 100644 --- a/e2e-tests/commands/insurance/your-buyer/complete-and-submit-buyer-financial-information-form.js +++ b/e2e-tests/commands/insurance/your-buyer/complete-and-submit-buyer-financial-information-form.js @@ -2,7 +2,7 @@ * completeAndSubmitBuyerFinancialInformationForm * Completes and submits the "buyer financial information" form. * @param {Object} Object with flags on how to complete the form. - * - exporterHasBuyerFinancialAccounts: Should submit "yes" to "buyer financial information" radio. Defaults to "no". + * - exporterHasBuyerFinancialAccounts: Should submit "yes" to "buyer financial information" radio. Defaults to false. */ const completeAndSubmitBuyerFinancialInformationForm = ({ exporterHasBuyerFinancialAccounts = false }) => { cy.completeBuyerFinancialInformationForm({ exporterHasBuyerFinancialAccounts }); diff --git a/e2e-tests/commands/insurance/your-buyer/complete-and-submit-connection-with-the-buyer-form.js b/e2e-tests/commands/insurance/your-buyer/complete-and-submit-connection-with-the-buyer-form.js index 39e80caa97..c26243544a 100644 --- a/e2e-tests/commands/insurance/your-buyer/complete-and-submit-connection-with-the-buyer-form.js +++ b/e2e-tests/commands/insurance/your-buyer/complete-and-submit-connection-with-the-buyer-form.js @@ -1,7 +1,7 @@ /** * completeAndSubmitConnectionWithTheBuyerForm * Complete and submit the "connection with the buyer" form. - * @param {Boolean} hasConnectionToBuyer: Should submit "yes" to "have connection to buyer" radio. Defaults to "no". + * @param {Boolean} hasConnectionToBuyer: Should submit "yes" to "have connection to buyer" radio. Defaults to false. * @param {String} description: "Connection with buyer" description. */ const completeAndSubmitConnectionWithTheBuyerForm = ({ hasConnectionToBuyer = false, description }) => { diff --git a/e2e-tests/commands/insurance/your-buyer/complete-and-submit-traded-with-buyer-form.js b/e2e-tests/commands/insurance/your-buyer/complete-and-submit-traded-with-buyer-form.js index 7f37e3171a..ecbe65c0d5 100644 --- a/e2e-tests/commands/insurance/your-buyer/complete-and-submit-traded-with-buyer-form.js +++ b/e2e-tests/commands/insurance/your-buyer/complete-and-submit-traded-with-buyer-form.js @@ -2,7 +2,7 @@ * completeAndSubmitConnectionToTheBuyerForm * Completes and submits the "traded with buyer" form. * @param {Object} Object with flags on how to complete the form. - * - exporterHasTradedWithBuyer: Should submit "yes" to "traded with buyer" radio. Defaults to "no". + * - exporterHasTradedWithBuyer: Should submit "yes" to "traded with buyer" radio. Defaults to false. */ const completeAndSubmitTradedWithBuyerForm = ({ exporterHasTradedWithBuyer = false }) => { cy.completeTradedWithBuyerForm({ exporterHasTradedWithBuyer }); diff --git a/e2e-tests/commands/insurance/your-buyer/complete-buyer-financial-information-form.js b/e2e-tests/commands/insurance/your-buyer/complete-buyer-financial-information-form.js index 92549a8525..bd6d573447 100644 --- a/e2e-tests/commands/insurance/your-buyer/complete-buyer-financial-information-form.js +++ b/e2e-tests/commands/insurance/your-buyer/complete-buyer-financial-information-form.js @@ -2,7 +2,7 @@ * completeBuyerFinancialInformationForm * Completes the "buyer financial information" form. * @param {Object} Object with flags on how to complete the form. - * - exporterHasBuyerFinancialAccounts: Should submit "yes" to "buyer financial information" radio. Defaults to "no". + * - exporterHasBuyerFinancialAccounts: Should submit "yes" to "buyer financial information" radio. Defaults to false. */ const completeBuyerFinancialInformationForm = ({ exporterHasBuyerFinancialAccounts = false }) => { if (exporterHasBuyerFinancialAccounts) { diff --git a/e2e-tests/commands/insurance/your-buyer/complete-connection-with-the-buyer-form.js b/e2e-tests/commands/insurance/your-buyer/complete-connection-with-the-buyer-form.js index ed426f7c66..2fd6e118c6 100644 --- a/e2e-tests/commands/insurance/your-buyer/complete-connection-with-the-buyer-form.js +++ b/e2e-tests/commands/insurance/your-buyer/complete-connection-with-the-buyer-form.js @@ -7,7 +7,7 @@ const { CONNECTION_WITH_BUYER_DESCRIPTION } = INSURANCE_FIELD_IDS.YOUR_BUYER; /** * completeConnectionWithTheBuyerForm * Complete the "connection with the buyer" form. - * @param {Boolean} hasConnectionToBuyer: Should submit "yes" to "have connection to buyer" radio. Defaults to "no". + * @param {Boolean} hasConnectionToBuyer: Should submit "yes" to "have connection to buyer" radio. Defaults to false. * @param {String} description: "Connection with buyer" description. */ const completeConnectionWithTheBuyerForm = ({ hasConnectionToBuyer = false, description = application.BUYER[CONNECTION_WITH_BUYER_DESCRIPTION] }) => { diff --git a/e2e-tests/commands/insurance/your-buyer/complete-traded-with-buyer-form.js b/e2e-tests/commands/insurance/your-buyer/complete-traded-with-buyer-form.js index 248059fc73..3f823ae5e0 100644 --- a/e2e-tests/commands/insurance/your-buyer/complete-traded-with-buyer-form.js +++ b/e2e-tests/commands/insurance/your-buyer/complete-traded-with-buyer-form.js @@ -2,7 +2,7 @@ * completeTradedWithBuyerForm * Completes the "traded with buyer" form. * @param {Object} Object with flags on how to complete the form. - * - exporterHasTradedWithBuyer: Should submit "yes" to "traded with buyer" radio. Defaults to "no". + * - exporterHasTradedWithBuyer: Should submit "yes" to "traded with buyer" radio. Defaults to false. */ const completeTradedWithBuyerForm = ({ exporterHasTradedWithBuyer = false }) => { if (exporterHasTradedWithBuyer) { diff --git a/e2e-tests/constants/field-ids/insurance/policy/index.js b/e2e-tests/constants/field-ids/insurance/policy/index.js index b31ec0a0b7..3ab98720cd 100644 --- a/e2e-tests/constants/field-ids/insurance/policy/index.js +++ b/e2e-tests/constants/field-ids/insurance/policy/index.js @@ -60,16 +60,26 @@ export const POLICY = { BROKER_DETAILS: { NAME: 'name', EMAIL: SHARED.EMAIL, - BROKER_EMAIL: 'broker.email', IS_BASED_IN_UK: 'isBasedInUk', - POSTCODE: 'postcode', BUILDING_NUMBER_OR_NAME: 'buildingNumberOrName', + ADDRESS_LINE_1: 'addressLine1', + ADDRESS_LINE_2: 'addressLine2', + TOWN: 'town', + COUNTY: 'county', + POSTCODE: 'postcode', + BROKER_NAME: 'broker.name', + BROKER_EMAIL: 'broker.email', + BROKER_BUILDING_NUMBER_OR_NAME: 'broker.buildingNumberOrName', + BROKER_ADDRESS_LINE_1: 'broker.addressLine1', + BROKER_ADDRESS_LINE_2: 'broker.addressLine2', + BROKER_POSTCODE: 'broker.postcode', }, BROKER_ADDRESSES: { SELECT_THE_ADDRESS: 'selectTheAddress', }, BROKER_MANUAL_ADDRESS: { FULL_ADDRESS: 'fullAddress', + BROKER_FULL_ADDRESS: 'broker.fullAddress', }, LOSS_PAYEE: { IS_APPOINTED: 'isAppointed', diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/business-conditions/submit-an-application-multiple-policy-type-business-fully-populated.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/business-conditions/submit-an-application-multiple-policy-type-business-fully-populated.spec.js index 2332483b9a..666b2322ea 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/business-conditions/submit-an-application-multiple-policy-type-business-fully-populated.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/business-conditions/submit-an-application-multiple-policy-type-business-fully-populated.spec.js @@ -9,7 +9,6 @@ context('Insurance - submit an application - Multiple policy - fully populated b differentTradingName: true, differentTradingAddress: true, policyType: APPLICATION.POLICY_TYPE.MULTIPLE, - usingBroker: true, }).then((refNumber) => { referenceNumber = refNumber; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-policy-fully-populated.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-policy-fully-populated.spec.js index 077fa773f5..84adecb7b3 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-policy-fully-populated.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-policy-fully-populated.spec.js @@ -13,6 +13,7 @@ context('Insurance - submit an application - Multiple policy type - fully popula totalContractValueOverThreshold: true, hasHadCreditInsuranceCoverWithBuyer: true, usingBroker: true, + brokerIsBasedInUk: true, }).then((refNumber) => { referenceNumber = refNumber; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-with-broker.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-with-broker-based-in-uk.spec.js similarity index 81% rename from e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-with-broker.spec.js rename to e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-with-broker-based-in-uk.spec.js index 6e1e755537..4cccefb1a9 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-with-broker.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-with-broker-based-in-uk.spec.js @@ -1,7 +1,7 @@ import { APPLICATION } from '../../../../../../../constants'; context( - 'Insurance - submit an application - Multiple policy type with a broker - As an Exporter, I want to submit my completed credit insurance application, So that UKEF can process and make a decision on my application', + 'Insurance - submit an application - Multiple policy type with a broker - based in UK - 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; @@ -9,6 +9,7 @@ context( cy.completeSignInAndSubmitAnApplication({ policyType: APPLICATION.POLICY_TYPE.MULTIPLE, usingBroker: true, + brokerIsBasedInUk: true, }).then((refNumber) => { referenceNumber = refNumber; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-with-broker-not-based-in-uk.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-with-broker-not-based-in-uk.spec.js new file mode 100644 index 0000000000..53a7f7246c --- /dev/null +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/policy-conditions/submit-an-application-multiple-policy-type-with-broker-not-based-in-uk.spec.js @@ -0,0 +1,34 @@ +import { APPLICATION } from '../../../../../../../constants'; + +context( + 'Insurance - submit an application - Multiple policy type with a broker - not based in UK - 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, + usingBroker: true, + brokerIsBasedInUk: false, + }).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/submit-an-application-multiple-policy-type-fully-populated.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/submit-an-application-multiple-policy-type-fully-populated.spec.js index 2666c4d6d3..a5e81cdf40 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/submit-an-application-multiple-policy-type-fully-populated.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/multiple-policy-type/submit-an-application-multiple-policy-type-fully-populated.spec.js @@ -16,6 +16,7 @@ context( exportingWithCodeOfConduct: true, policyValueOverMvpMaximum: true, usingBroker: true, + brokerIsBasedInUk: true, otherCompanyInvolved: true, differentPolicyContact: true, needPreCreditPeriod: true, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/business-conditions/submit-an-application-single-policy-type-business-fully-populated.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/business-conditions/submit-an-application-single-policy-type-business-fully-populated.spec.js index b8735d68a8..3f8df9c0bf 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/business-conditions/submit-an-application-single-policy-type-business-fully-populated.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/business-conditions/submit-an-application-single-policy-type-business-fully-populated.spec.js @@ -6,7 +6,6 @@ context('Insurance - submit an application - Single policy - fully populated bus alternativeCurrencyTurnover: true, differentTradingName: true, differentTradingAddress: true, - usingBroker: true, }).then((refNumber) => { referenceNumber = refNumber; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-policy-fully-populated.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-policy-fully-populated.spec.js index 49d06f3c26..85e91d4d47 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-policy-fully-populated.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-policy-fully-populated.spec.js @@ -10,6 +10,7 @@ context('Insurance - submit an application - Single policy type - fully populate totalContractValueOverThreshold: true, hasHadCreditInsuranceCoverWithBuyer: true, usingBroker: true, + brokerIsBasedInUk: true, }).then((refNumber) => { referenceNumber = refNumber; }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-with-broker.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-with-broker-based-in-uk.spec.js similarity index 67% rename from e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-with-broker.spec.js rename to e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-with-broker-based-in-uk.spec.js index 19fdb399e6..c087bf6d38 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-with-broker.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-with-broker-based-in-uk.spec.js @@ -1,10 +1,13 @@ context( - 'Insurance - submit an application - Single policy type with a broker - As an Exporter, I want to submit my completed credit insurance application, So that UKEF can process and make a decision on my application', + 'Insurance - submit an application - Single policy type with a broker - based in UK - 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({ usingBroker: true }).then((refNumber) => { + cy.completeSignInAndSubmitAnApplication({ + usingBroker: true, + brokerIsBasedInUk: true, + }).then((refNumber) => { referenceNumber = refNumber; }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-with-broker-not-based-in-uk.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-with-broker-not-based-in-uk.spec.js new file mode 100644 index 0000000000..cdbfbb8a3e --- /dev/null +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/policy-conditions/submit-an-application-single-policy-type-with-broker-not-based-in-uk.spec.js @@ -0,0 +1,31 @@ +context( + 'Insurance - submit an application - Single policy type with a broker - not based in UK - 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({ + usingBroker: true, + brokerIsBasedInUk: false, + }).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/single-policy-type/submit-an-application-single-policy-type-fully-populated.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/submit-an-application-single-policy-type-fully-populated.spec.js index dc659bdb83..7beacd3eeb 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/submit-an-application-single-policy-type-fully-populated.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/application-submission/single-policy-type/submit-an-application-single-policy-type-fully-populated.spec.js @@ -13,6 +13,7 @@ context( exportingWithCodeOfConduct: true, policyValueOverMvpMaximum: true, usingBroker: true, + brokerIsBasedInUk: true, otherCompanyInvolved: true, differentPolicyContact: true, needPreCreditPeriod: true, diff --git a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/policy/change-your-answers/broker/change-your-answers-change-broker-no-to-yes.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/policy/change-your-answers/broker/change-your-answers-change-broker-no-to-yes.spec.js index 6f580d077b..c9f07e3be8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/policy/change-your-answers/broker/change-your-answers-change-broker-no-to-yes.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/policy/change-your-answers/broker/change-your-answers-change-broker-no-to-yes.spec.js @@ -61,7 +61,8 @@ context('Insurance - Change your answers - Policy - Broker - No to yes - As an e }); }); - describe('after changing the answer from no to yes and completing (now required) broker details fields', () => { + // TODO: EMS-4028, EMS-4029 + describe.skip('after changing the answer from no to yes and completing (now required) broker details fields', () => { beforeEach(() => { cy.navigateToUrl(url); }); diff --git a/e2e-tests/insurance/cypress/support/application/policy/index.js b/e2e-tests/insurance/cypress/support/application/policy/index.js index 38e0fde4c6..fbfe8365b8 100644 --- a/e2e-tests/insurance/cypress/support/application/policy/index.js +++ b/e2e-tests/insurance/cypress/support/application/policy/index.js @@ -28,6 +28,8 @@ Cypress.Commands.add('completeAndSubmitOtherCompanyDetailsForm', require('../../ Cypress.Commands.add('completeAndSubmitBrokerForm', require('../../../../../commands/insurance/complete-and-submit-broker-form')); Cypress.Commands.add('completeBrokerDetailsForm', require('../../../../../commands/insurance/complete-broker-details-form')); Cypress.Commands.add('completeAndSubmitBrokerDetailsForm', require('../../../../../commands/insurance/complete-and-submit-broker-details-form')); +Cypress.Commands.add('completeBrokerAddressesForm', require('../../../../../commands/insurance/complete-broker-addresses-form')); +Cypress.Commands.add('completeAndSubmitBrokerAddressesForm', require('../../../../../commands/insurance/complete-and-submit-broker-addresses-form')); Cypress.Commands.add('completeBrokerManualAddressForm', require('../../../../../commands/insurance/complete-broker-manual-address-form')); Cypress.Commands.add('completeAndSubmitBrokerManualAddressForm', require('../../../../../commands/insurance/complete-and-submit-broker-manual-address-form')); Cypress.Commands.add('completeAndSubmitLossPayeeForm', require('../../../../../commands/insurance/complete-and-submit-loss-payee-form')); diff --git a/src/api/.keystone/config.js b/src/api/.keystone/config.js index b0e8ed9529..b788b6461f 100644 --- a/src/api/.keystone/config.js +++ b/src/api/.keystone/config.js @@ -346,16 +346,26 @@ var POLICY = { BROKER_DETAILS: { NAME: 'name', EMAIL: shared_default.EMAIL, - BROKER_EMAIL: 'broker.email', IS_BASED_IN_UK: 'isBasedInUk', - POSTCODE: 'postcode', BUILDING_NUMBER_OR_NAME: 'buildingNumberOrName', + ADDRESS_LINE_1: 'addressLine1', + ADDRESS_LINE_2: 'addressLine2', + TOWN: 'town', + COUNTY: 'county', + POSTCODE: 'postcode', + BROKER_NAME: 'broker.name', + BROKER_EMAIL: 'broker.email', + BROKER_BUILDING_NUMBER_OR_NAME: 'broker.buildingNumberOrName', + BROKER_ADDRESS_LINE_1: 'broker.addressLine1', + BROKER_ADDRESS_LINE_2: 'broker.addressLine2', + BROKER_POSTCODE: 'broker.postcode', }, BROKER_ADDRESSES: { SELECT_THE_ADDRESS: 'selectTheAddress', }, BROKER_MANUAL_ADDRESS: { FULL_ADDRESS: 'fullAddress', + BROKER_FULL_ADDRESS: 'broker.fullAddress', }, LOSS_PAYEE: { IS_APPOINTED: 'isAppointed', @@ -610,7 +620,7 @@ var CUSTOM_RESOLVERS = [ 'deleteApplicationByReferenceNumber', 'getApplicationByReferenceNumber', 'getCompaniesHouseInformation', - 'getOrdnanceSurveyAddress', + 'getOrdnanceSurveyAddresses', 'submitApplication', // feedback 'createFeedbackAndSendEmail', @@ -6767,16 +6777,6 @@ var POLICY_FIELDS = { MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS, }, }, - BROKER_MANUAL_ADDRESS: { - [FULL_ADDRESS]: { - LABEL: "Broker's address", - SUMMARY: { - TITLE: "Broker's address", - FORM_TITLE: POLICY_FORM_TITLES.BROKER, - }, - MAXIMUM: MAXIMUM_CHARACTERS.FULL_ADDRESS, - }, - }, LOSS_PAYEE: { [IS_APPOINTED]: { HINT: { diff --git a/src/api/constants/allowed-graphql-resolvers/index.ts b/src/api/constants/allowed-graphql-resolvers/index.ts index 31f8451e50..3b230f7685 100644 --- a/src/api/constants/allowed-graphql-resolvers/index.ts +++ b/src/api/constants/allowed-graphql-resolvers/index.ts @@ -68,7 +68,7 @@ const CUSTOM_RESOLVERS = [ 'deleteApplicationByReferenceNumber', 'getApplicationByReferenceNumber', 'getCompaniesHouseInformation', - 'getOrdnanceSurveyAddress', + 'getOrdnanceSurveyAddresses', 'submitApplication', // feedback diff --git a/src/api/constants/field-ids/insurance/policy/index.ts b/src/api/constants/field-ids/insurance/policy/index.ts index b31ec0a0b7..3ab98720cd 100644 --- a/src/api/constants/field-ids/insurance/policy/index.ts +++ b/src/api/constants/field-ids/insurance/policy/index.ts @@ -60,16 +60,26 @@ export const POLICY = { BROKER_DETAILS: { NAME: 'name', EMAIL: SHARED.EMAIL, - BROKER_EMAIL: 'broker.email', IS_BASED_IN_UK: 'isBasedInUk', - POSTCODE: 'postcode', BUILDING_NUMBER_OR_NAME: 'buildingNumberOrName', + ADDRESS_LINE_1: 'addressLine1', + ADDRESS_LINE_2: 'addressLine2', + TOWN: 'town', + COUNTY: 'county', + POSTCODE: 'postcode', + BROKER_NAME: 'broker.name', + BROKER_EMAIL: 'broker.email', + BROKER_BUILDING_NUMBER_OR_NAME: 'broker.buildingNumberOrName', + BROKER_ADDRESS_LINE_1: 'broker.addressLine1', + BROKER_ADDRESS_LINE_2: 'broker.addressLine2', + BROKER_POSTCODE: 'broker.postcode', }, BROKER_ADDRESSES: { SELECT_THE_ADDRESS: 'selectTheAddress', }, BROKER_MANUAL_ADDRESS: { FULL_ADDRESS: 'fullAddress', + BROKER_FULL_ADDRESS: 'broker.fullAddress', }, LOSS_PAYEE: { IS_APPOINTED: 'isAppointed', diff --git a/src/ui/server/constants/field-ids/insurance/policy/index.ts b/src/ui/server/constants/field-ids/insurance/policy/index.ts index b31ec0a0b7..3ab98720cd 100644 --- a/src/ui/server/constants/field-ids/insurance/policy/index.ts +++ b/src/ui/server/constants/field-ids/insurance/policy/index.ts @@ -60,16 +60,26 @@ export const POLICY = { BROKER_DETAILS: { NAME: 'name', EMAIL: SHARED.EMAIL, - BROKER_EMAIL: 'broker.email', IS_BASED_IN_UK: 'isBasedInUk', - POSTCODE: 'postcode', BUILDING_NUMBER_OR_NAME: 'buildingNumberOrName', + ADDRESS_LINE_1: 'addressLine1', + ADDRESS_LINE_2: 'addressLine2', + TOWN: 'town', + COUNTY: 'county', + POSTCODE: 'postcode', + BROKER_NAME: 'broker.name', + BROKER_EMAIL: 'broker.email', + BROKER_BUILDING_NUMBER_OR_NAME: 'broker.buildingNumberOrName', + BROKER_ADDRESS_LINE_1: 'broker.addressLine1', + BROKER_ADDRESS_LINE_2: 'broker.addressLine2', + BROKER_POSTCODE: 'broker.postcode', }, BROKER_ADDRESSES: { SELECT_THE_ADDRESS: 'selectTheAddress', }, BROKER_MANUAL_ADDRESS: { FULL_ADDRESS: 'fullAddress', + BROKER_FULL_ADDRESS: 'broker.fullAddress', }, LOSS_PAYEE: { IS_APPOINTED: 'isAppointed', diff --git a/src/ui/server/controllers/insurance/all-sections/index.test.ts b/src/ui/server/controllers/insurance/all-sections/index.test.ts index 653832cb1d..a11edec4d9 100644 --- a/src/ui/server/controllers/insurance/all-sections/index.test.ts +++ b/src/ui/server/controllers/insurance/all-sections/index.test.ts @@ -54,7 +54,7 @@ describe('controllers/insurance/all-sections', () => { }, } = exportContract; - const { isUsingBroker } = broker; + const { isUsingBroker, isBasedInUk: brokerIsBasedInUk } = broker; const { hasDifferentTradingName } = company; const { hasAntiBriberyCodeOfConduct } = declaration; const { buyerTradingHistory, relationship } = buyer; @@ -70,6 +70,7 @@ describe('controllers/insurance/all-sections', () => { finalDestinationKnown, jointlyInsuredParty.requested, isUsingBroker, + brokerIsBasedInUk, isAppointingLossPayee, lossPayeeIsLocatedInUk, lossPayeeIsLocatedInternationally, diff --git a/src/ui/server/controllers/insurance/all-sections/index.ts b/src/ui/server/controllers/insurance/all-sections/index.ts index f4d42f38b8..681461da14 100644 --- a/src/ui/server/controllers/insurance/all-sections/index.ts +++ b/src/ui/server/controllers/insurance/all-sections/index.ts @@ -46,7 +46,7 @@ export const get = (req: Request, res: Response) => { }, } = exportContract; - const { isUsingBroker } = broker; + const { isUsingBroker, isBasedInUk: brokerIsBasedInUk } = broker; const { hasDifferentTradingName } = company; const { hasAntiBriberyCodeOfConduct } = declaration; const { buyerTradingHistory, relationship } = buyer; @@ -62,6 +62,7 @@ export const get = (req: Request, res: Response) => { finalDestinationKnown, jointlyInsuredParty.requested, isUsingBroker, + brokerIsBasedInUk, isAppointingLossPayee, lossPayeeIsLocatedInUk, lossPayeeIsLocatedInternationally, diff --git a/src/ui/server/graphql/queries/ordnance-survey-address.ts b/src/ui/server/graphql/queries/ordnance-survey-address.ts index 04ba7807aa..342eff6401 100644 --- a/src/ui/server/graphql/queries/ordnance-survey-address.ts +++ b/src/ui/server/graphql/queries/ordnance-survey-address.ts @@ -2,7 +2,7 @@ import gql from 'graphql-tag'; const ordnanceSurveyAddressesQuery = gql` query getOrdnanceSurveyAddresses($postcode: String!, $houseNameOrNumber: String!) { - getOrdnanceSurveyAddress(postcode: $postcode, houseNameOrNumber: $houseNameOrNumber) { + getOrdnanceSurveyAddresses(postcode: $postcode, houseNameOrNumber: $houseNameOrNumber) { success addresses { addressLine1 diff --git a/src/ui/server/helpers/flatten-application-data/index.test.ts b/src/ui/server/helpers/flatten-application-data/index.test.ts index 147c913f86..3a348fed72 100644 --- a/src/ui/server/helpers/flatten-application-data/index.test.ts +++ b/src/ui/server/helpers/flatten-application-data/index.test.ts @@ -1,21 +1,19 @@ -import flattenApplicationData, { mapBroker, mapExportContractAgentDetails, mapPolicyContact, mapNominatedLossPayee } from '.'; +import flattenApplicationData, { mapExportContractAgentDetails, mapPolicyContact, mapNominatedLossPayee } from '.'; import INSURANCE_FIELD_IDS from '../../constants/field-ids/insurance'; +import mapBroker from './map-broker'; import getTrueAndFalseAnswers from '../get-true-and-false-answers'; import { mockApplication, referenceNumber } from '../../test-mocks'; const { POLICY: { NAME_ON_POLICY: { IS_SAME_AS_OWNER, POSITION, POLICY_CONTACT_EMAIL }, - USING_BROKER, - BROKER_DETAILS: { NAME, BROKER_EMAIL }, - BROKER_MANUAL_ADDRESS: { FULL_ADDRESS }, FINANCIAL_ADDRESS, LOSS_PAYEE: { IS_APPOINTED }, LOSS_PAYEE_DETAILS: { LOSS_PAYEE_NAME, IS_LOCATED_INTERNATIONALLY, IS_LOCATED_IN_UK }, LOSS_PAYEE_FINANCIAL_ADDRESS, }, EXPORT_CONTRACT: { - AGENT_DETAILS: { AGENT_NAME, AGENT_FULL_ADDRESS, AGENT_COUNTRY_CODE, COUNTRY_CODE }, + AGENT_DETAILS: { AGENT_NAME, AGENT_FULL_ADDRESS, AGENT_COUNTRY_CODE, COUNTRY_CODE, FULL_ADDRESS, NAME }, }, ACCOUNT: { FIRST_NAME, LAST_NAME, EMAIL }, } = INSURANCE_FIELD_IDS; @@ -26,22 +24,6 @@ const { nominatedLossPayee, policy, policyContact, sectionReview } = mockApplica const { buyerTradingHistory, contact, relationship } = mockApplication.buyer; describe('server/helpers/flatten-application-data', () => { - describe('mapBroker', () => { - it('should return mapped broker IDs', () => { - const result = mapBroker(broker); - - const expected = { - id: broker.id, - [USING_BROKER]: broker[USING_BROKER], - [NAME]: broker[NAME], - [BROKER_EMAIL]: broker[EMAIL], - [FULL_ADDRESS]: broker[FULL_ADDRESS], - }; - - expect(result).toEqual(expected); - }); - }); - describe('mapExportContractAgentDetails', () => { it('should return mapped export contract agent IDs', () => { const result = mapExportContractAgentDetails(exportContract.agent); diff --git a/src/ui/server/helpers/flatten-application-data/index.ts b/src/ui/server/helpers/flatten-application-data/index.ts index 96dd21ffc1..5990e7e5ab 100644 --- a/src/ui/server/helpers/flatten-application-data/index.ts +++ b/src/ui/server/helpers/flatten-application-data/index.ts @@ -1,45 +1,22 @@ import getTrueAndFalseAnswers from '../get-true-and-false-answers'; import INSURANCE_FIELD_IDS from '../../constants/field-ids/insurance'; -import { - Application, - ApplicationBroker, - ApplicationExportContractAgent, - ApplicationFlat, - ApplicationNominatedLossPayee, - ApplicationPolicyContact, -} from '../../../types'; +import mapBroker from './map-broker'; +import { Application, ApplicationExportContractAgent, ApplicationFlat, ApplicationNominatedLossPayee, ApplicationPolicyContact } from '../../../types'; const { POLICY: { NAME_ON_POLICY: { IS_SAME_AS_OWNER, POSITION, POLICY_CONTACT_EMAIL }, - USING_BROKER, - BROKER_DETAILS: { NAME, BROKER_EMAIL }, - BROKER_MANUAL_ADDRESS: { FULL_ADDRESS }, FINANCIAL_ADDRESS, LOSS_PAYEE: { IS_APPOINTED }, LOSS_PAYEE_DETAILS: { LOSS_PAYEE_NAME, IS_LOCATED_INTERNATIONALLY, IS_LOCATED_IN_UK }, LOSS_PAYEE_FINANCIAL_ADDRESS, }, EXPORT_CONTRACT: { - AGENT_DETAILS: { AGENT_NAME, AGENT_FULL_ADDRESS, AGENT_COUNTRY_CODE, COUNTRY_CODE }, + AGENT_DETAILS: { AGENT_NAME, AGENT_FULL_ADDRESS, AGENT_COUNTRY_CODE, COUNTRY_CODE, FULL_ADDRESS, NAME }, }, ACCOUNT: { FIRST_NAME, LAST_NAME, EMAIL }, } = INSURANCE_FIELD_IDS; -/** - * mapBroker - * Map the broke to avoid clashes with other name and email fields. - * @param {ApplicationBroker} broker - * @returns {Object} ApplicationBroker with slightly different field IDs - */ -export const mapBroker = (broker: ApplicationBroker) => ({ - id: broker.id, - [USING_BROKER]: broker[USING_BROKER], - [NAME]: broker[NAME], - [BROKER_EMAIL]: broker[EMAIL], - [FULL_ADDRESS]: broker[FULL_ADDRESS], -}); - /** * mapExportContractAgentDetails * Map the agent to avoid clashes with other address fields. diff --git a/src/ui/server/helpers/flatten-application-data/map-broker/index.test.ts b/src/ui/server/helpers/flatten-application-data/map-broker/index.test.ts new file mode 100644 index 0000000000..9370c84eb8 --- /dev/null +++ b/src/ui/server/helpers/flatten-application-data/map-broker/index.test.ts @@ -0,0 +1,96 @@ +import mapBroker from '.'; +import { POLICY as POLICY_FIELD_IDS } from '../../../constants/field-ids/insurance/policy'; +import { mockApplication } from '../../../test-mocks'; + +const { + USING_BROKER, + BROKER_DETAILS: { + NAME, + EMAIL, + IS_BASED_IN_UK, + BUILDING_NUMBER_OR_NAME, + ADDRESS_LINE_1, + ADDRESS_LINE_2, + POSTCODE, + BROKER_NAME, + BROKER_EMAIL, + BROKER_BUILDING_NUMBER_OR_NAME, + BROKER_ADDRESS_LINE_1, + BROKER_ADDRESS_LINE_2, + BROKER_POSTCODE, + }, + BROKER_MANUAL_ADDRESS: { BROKER_FULL_ADDRESS, FULL_ADDRESS }, +} = POLICY_FIELD_IDS; + +const { broker } = mockApplication; + +describe('server/helpers/flatten-application-data/map-broker', () => { + describe(`when ${USING_BROKER} is true`, () => { + describe(`when ${IS_BASED_IN_UK} is true`, () => { + const mockBroker = { + ...broker, + [USING_BROKER]: true, + [IS_BASED_IN_UK]: true, + }; + + it('should return mapped broker IDs', () => { + const result = mapBroker(mockBroker); + + const expected = { + id: mockBroker.id, + [USING_BROKER]: mockBroker[USING_BROKER], + [IS_BASED_IN_UK]: mockBroker[IS_BASED_IN_UK], + [BROKER_NAME]: mockBroker[NAME], + [BROKER_EMAIL]: mockBroker[EMAIL], + [BROKER_BUILDING_NUMBER_OR_NAME]: mockBroker[BUILDING_NUMBER_OR_NAME], + [BROKER_ADDRESS_LINE_1]: mockBroker[ADDRESS_LINE_1], + [BROKER_ADDRESS_LINE_2]: mockBroker[ADDRESS_LINE_2], + [BROKER_POSTCODE]: mockBroker[POSTCODE], + }; + + expect(result).toEqual(expected); + }); + }); + + describe(`when ${IS_BASED_IN_UK} is false`, () => { + const mockBroker = { + ...broker, + [USING_BROKER]: true, + [IS_BASED_IN_UK]: false, + }; + + it('should return mapped broker IDs', () => { + const result = mapBroker(mockBroker); + + const expected = { + id: mockBroker.id, + [USING_BROKER]: mockBroker[USING_BROKER], + [IS_BASED_IN_UK]: mockBroker[IS_BASED_IN_UK], + [BROKER_NAME]: mockBroker[NAME], + [BROKER_EMAIL]: mockBroker[EMAIL], + [BROKER_FULL_ADDRESS]: mockBroker[FULL_ADDRESS], + }; + + expect(result).toEqual(expected); + }); + }); + }); + + describe(`when ${USING_BROKER} is false`, () => { + it('should return mapped broker IDs', () => { + const mockBroker = { + ...broker, + [USING_BROKER]: false, + }; + + const result = mapBroker(mockBroker); + + const expected = { + id: mockBroker.id, + [USING_BROKER]: mockBroker[USING_BROKER], + }; + + expect(result).toEqual(expected); + }); + }); +}); diff --git a/src/ui/server/helpers/flatten-application-data/map-broker/index.ts b/src/ui/server/helpers/flatten-application-data/map-broker/index.ts new file mode 100644 index 0000000000..5c3ef056f5 --- /dev/null +++ b/src/ui/server/helpers/flatten-application-data/map-broker/index.ts @@ -0,0 +1,57 @@ +import { POLICY as POLICY_FIELD_IDS } from '../../../constants/field-ids/insurance/policy'; +import { ApplicationBroker } from '../../../../types'; + +const { + USING_BROKER, + BROKER_DETAILS: { + NAME, + EMAIL, + IS_BASED_IN_UK, + BUILDING_NUMBER_OR_NAME, + ADDRESS_LINE_1, + ADDRESS_LINE_2, + POSTCODE, + BROKER_NAME, + BROKER_EMAIL, + BROKER_BUILDING_NUMBER_OR_NAME, + BROKER_ADDRESS_LINE_1, + BROKER_ADDRESS_LINE_2, + BROKER_POSTCODE, + }, + BROKER_MANUAL_ADDRESS: { BROKER_FULL_ADDRESS, FULL_ADDRESS }, +} = POLICY_FIELD_IDS; + +/** + * mapBroker + * Map the broker to avoid clashes with other fields with the same name + * e.g name, email, address fields. + * @param {ApplicationBroker} broker + * @returns {Object} ApplicationBroker with slightly different field IDs + */ +const mapBroker = (broker: ApplicationBroker) => { + const { isUsingBroker, isBasedInUk } = broker; + + const mapped = { + id: broker.id, + [USING_BROKER]: isUsingBroker, + }; + + if (isUsingBroker) { + mapped[IS_BASED_IN_UK] = isBasedInUk; + mapped[BROKER_NAME] = broker[NAME]; + mapped[BROKER_EMAIL] = broker[EMAIL]; + + if (isBasedInUk) { + mapped[BROKER_BUILDING_NUMBER_OR_NAME] = broker[BUILDING_NUMBER_OR_NAME]; + mapped[BROKER_ADDRESS_LINE_1] = broker[ADDRESS_LINE_1]; + mapped[BROKER_ADDRESS_LINE_2] = broker[ADDRESS_LINE_2]; + mapped[BROKER_POSTCODE] = broker[POSTCODE]; + } else { + mapped[BROKER_FULL_ADDRESS] = broker[FULL_ADDRESS]; + } + } + + return mapped; +}; + +export default mapBroker; diff --git a/src/ui/server/helpers/required-fields/policy/index.test.ts b/src/ui/server/helpers/required-fields/policy/index.test.ts index 50b6b559c5..28e4e41106 100644 --- a/src/ui/server/helpers/required-fields/policy/index.test.ts +++ b/src/ui/server/helpers/required-fields/policy/index.test.ts @@ -9,7 +9,8 @@ const { POLICY_TYPE } = FIELD_VALUES; const { REQUESTED_START_DATE, POLICY_CURRENCY_CODE } = SHARED_CONTRACT_POLICY; const { - BROKER_DETAILS: { NAME, BROKER_EMAIL }, + BROKER_DETAILS: { BROKER_NAME, BROKER_EMAIL, BROKER_ADDRESS_LINE_1, BROKER_ADDRESS_LINE_2, BROKER_POSTCODE }, + BROKER_MANUAL_ADDRESS: { BROKER_FULL_ADDRESS }, CONTRACT_POLICY: { SINGLE: { CONTRACT_COMPLETION_DATE, REQUESTED_CREDIT_LIMIT, TOTAL_CONTRACT_VALUE }, MULTIPLE: { TOTAL_MONTHS_OF_COVER }, @@ -116,13 +117,27 @@ describe('server/helpers/required-fields/policy', () => { }); describe('getBrokerTasks', () => { - describe('when isUsingBroker is true', () => { + describe('when isUsingBroker is true, brokerIsBasedInUk is false', () => { it('should return multiple field ids in an array', () => { const isUsingBrokerFlag = true; + const brokerIsBasedInUkFlag = false; - const result = getBrokerTasks(isUsingBrokerFlag); + const result = getBrokerTasks(isUsingBrokerFlag, brokerIsBasedInUkFlag); + + const expected = [BROKER_NAME, BROKER_EMAIL, BROKER_FULL_ADDRESS]; + + expect(result).toEqual(expected); + }); + }); + + describe('when isUsingBroker is true, brokerIsBasedInUk is true', () => { + it('should return multiple field ids in an array', () => { + const isUsingBrokerFlag = true; + const brokerIsBasedInUkFlag = true; + + const result = getBrokerTasks(isUsingBrokerFlag, brokerIsBasedInUkFlag); - const expected = [NAME, BROKER_EMAIL]; + const expected = [BROKER_NAME, BROKER_EMAIL, BROKER_ADDRESS_LINE_1, BROKER_ADDRESS_LINE_2, BROKER_POSTCODE]; expect(result).toEqual(expected); }); diff --git a/src/ui/server/helpers/required-fields/policy/index.ts b/src/ui/server/helpers/required-fields/policy/index.ts index a57e4bbf6c..158e867066 100644 --- a/src/ui/server/helpers/required-fields/policy/index.ts +++ b/src/ui/server/helpers/required-fields/policy/index.ts @@ -5,7 +5,8 @@ import { isSinglePolicyType, isMultiplePolicyType } from '../../policy-type'; const { REQUESTED_START_DATE, POLICY_CURRENCY_CODE } = SHARED_CONTRACT_POLICY; const { - BROKER_DETAILS: { NAME, BROKER_EMAIL }, + BROKER_DETAILS: { BROKER_NAME, BROKER_EMAIL, BROKER_ADDRESS_LINE_1, BROKER_ADDRESS_LINE_2, BROKER_POSTCODE }, + BROKER_MANUAL_ADDRESS: { BROKER_FULL_ADDRESS }, CONTRACT_POLICY: { SINGLE: { CONTRACT_COMPLETION_DATE, REQUESTED_CREDIT_LIMIT, TOTAL_CONTRACT_VALUE }, MULTIPLE: { TOTAL_MONTHS_OF_COVER }, @@ -72,17 +73,23 @@ export const getJointlyInsuredPartyTasks = (jointlyInsuredParty?: boolean) => { * getBrokerTasks * Get "Broker" tasks depending on the isUsingBroker field * @param {Boolean} isUsingBroker: "Is using broker" flag + * @param {Boolean} brokerIsBasedInUk: "Broker is based in the UK" flag * @returns {Array} Array of tasks */ -export const getBrokerTasks = (isUsingBroker?: boolean) => { +export const getBrokerTasks = (isUsingBroker?: boolean, brokerIsBasedInUk?: boolean) => { + let tasks: Array = []; + if (isUsingBroker) { - // TODO: EMS-3979 - // return [NAME, BROKER_EMAIL, FULL_ADDRESS]; + tasks = [BROKER_NAME, BROKER_EMAIL]; - return [NAME, BROKER_EMAIL]; + if (brokerIsBasedInUk) { + tasks = [...tasks, BROKER_ADDRESS_LINE_1, BROKER_ADDRESS_LINE_2, BROKER_POSTCODE]; + } else { + tasks = [...tasks, BROKER_FULL_ADDRESS]; + } } - return []; + return tasks; }; /** @@ -113,6 +120,7 @@ interface RequiredFields { policyType?: string; jointlyInsuredParty?: boolean; isUsingBroker?: boolean; + brokerIsBasedInUk?: boolean; isAppointingLossPayee?: boolean; lossPayeeIsLocatedInUk?: boolean; lossPayeeIsLocatedInternationally?: boolean; @@ -124,12 +132,17 @@ interface RequiredFields { * @param {Boolean} finalDestinationKnown: "Final destination known" * @param {Boolean} jointlyInsuredParty: "Jointly insured party" flag * @param {Boolean} isUsingBroker: "Is using broker" + * @param {Boolean} brokerIsBasedInUk: "Broker is based in the UK" flag + * @param {Boolean} isAppointingLossPayee: "Is using loss payee" flag + * @param {Boolean} lossPayeeIsLocatedInUk: "Loss payee is located in the UK" flag + * @param {Boolean} lossPayeeIsLocatedInternationally: "Loss payee is located internationally" flag * @returns {Array} Required field IDs */ const requiredFields = ({ policyType, jointlyInsuredParty, isUsingBroker, + brokerIsBasedInUk, isAppointingLossPayee, lossPayeeIsLocatedInUk, lossPayeeIsLocatedInternationally, @@ -145,7 +158,7 @@ const requiredFields = ({ POLICY_CONTACT_EMAIL, POSITION, USING_BROKER, - ...getBrokerTasks(isUsingBroker), + ...getBrokerTasks(isUsingBroker, brokerIsBasedInUk), ...lossPayeeTasks(isAppointingLossPayee, lossPayeeIsLocatedInUk, lossPayeeIsLocatedInternationally), ]; diff --git a/src/ui/server/helpers/required-fields/prepare-application/index.test.ts b/src/ui/server/helpers/required-fields/prepare-application/index.test.ts index d25031f626..2710aab36d 100644 --- a/src/ui/server/helpers/required-fields/prepare-application/index.test.ts +++ b/src/ui/server/helpers/required-fields/prepare-application/index.test.ts @@ -21,6 +21,10 @@ const { POLICY: { TYPE_OF_POLICY: { POLICY_TYPE }, USING_BROKER, + BROKER_DETAILS: { IS_BASED_IN_UK }, + REQUESTED_JOINTLY_INSURED_PARTY: { REQUESTED }, + LOSS_PAYEE: { IS_APPOINTED }, + LOSS_PAYEE_DETAILS: { IS_LOCATED_IN_UK, IS_LOCATED_INTERNATIONALLY }, }, YOUR_BUYER: { CONNECTION_WITH_BUYER, OUTSTANDING_PAYMENTS, TRADED_WITH_BUYER, HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER }, } = INSURANCE_FIELD_IDS; @@ -36,7 +40,12 @@ describe('server/helpers/required-fields/section-review', () => { ...requiredEligibilityFields(), ...requiredPolicyFields({ policyType: flatApplicationData[POLICY_TYPE], + jointlyInsuredParty: flatApplicationData[REQUESTED], isUsingBroker: flatApplicationData[USING_BROKER], + brokerIsBasedInUk: flatApplicationData[IS_BASED_IN_UK], + isAppointingLossPayee: flatApplicationData[IS_APPOINTED], + lossPayeeIsLocatedInUk: flatApplicationData[IS_LOCATED_IN_UK], + lossPayeeIsLocatedInternationally: flatApplicationData[IS_LOCATED_INTERNATIONALLY], }), ...requiredExportContractFields({ finalDestinationKnown: flatApplicationData[FINAL_DESTINATION_KNOWN], diff --git a/src/ui/server/helpers/required-fields/prepare-application/index.ts b/src/ui/server/helpers/required-fields/prepare-application/index.ts index e351ef9c14..99f4fbf37d 100644 --- a/src/ui/server/helpers/required-fields/prepare-application/index.ts +++ b/src/ui/server/helpers/required-fields/prepare-application/index.ts @@ -19,6 +19,10 @@ const { POLICY: { TYPE_OF_POLICY: { POLICY_TYPE }, USING_BROKER, + BROKER_DETAILS: { IS_BASED_IN_UK }, + REQUESTED_JOINTLY_INSURED_PARTY: { REQUESTED }, + LOSS_PAYEE: { IS_APPOINTED }, + LOSS_PAYEE_DETAILS: { IS_LOCATED_IN_UK, IS_LOCATED_INTERNATIONALLY }, }, YOUR_BUYER: { CONNECTION_WITH_BUYER, OUTSTANDING_PAYMENTS, TRADED_WITH_BUYER, HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER }, } = INSURANCE_FIELD_IDS; @@ -32,7 +36,12 @@ const requiredFields = (application: ApplicationFlat): Array => [ ...requiredEligibilityFields(), ...requiredPolicyFields({ policyType: application[POLICY_TYPE], + jointlyInsuredParty: application[REQUESTED], isUsingBroker: application[USING_BROKER], + brokerIsBasedInUk: application[IS_BASED_IN_UK], + isAppointingLossPayee: application[IS_APPOINTED], + lossPayeeIsLocatedInUk: application[IS_LOCATED_IN_UK], + lossPayeeIsLocatedInternationally: application[IS_LOCATED_INTERNATIONALLY], }), ...requiredExportContractFields({ finalDestinationKnown: application[FINAL_DESTINATION_KNOWN], diff --git a/src/ui/server/helpers/task-list/generate-groups-and-tasks/index.test.ts b/src/ui/server/helpers/task-list/generate-groups-and-tasks/index.test.ts index a14886e9b3..a420eb8b88 100644 --- a/src/ui/server/helpers/task-list/generate-groups-and-tasks/index.test.ts +++ b/src/ui/server/helpers/task-list/generate-groups-and-tasks/index.test.ts @@ -10,7 +10,7 @@ const { INITIAL_CHECKS, PREPARE_APPLICATION, SUBMIT_APPLICATION } = TASKS.LIST; describe('server/helpers/task-list/generate-groups-and-tasks', () => { const { - broker: { isUsingBroker }, + broker: { isUsingBroker, isBasedInUk: brokerIsBasedInUk }, buyer: { relationship: { exporterIsConnectedWithBuyer, exporterHasPreviousCreditInsuranceWithBuyer }, buyerTradingHistory: { exporterHasTradedWithBuyer, outstandingPayments }, @@ -46,6 +46,7 @@ describe('server/helpers/task-list/generate-groups-and-tasks', () => { finalDestinationKnown, jointlyInsuredParty.requested, isUsingBroker, + brokerIsBasedInUk, isAppointingLossPayee, lossPayeeIsLocatedInUk, lossPayeeIsLocatedInInternationally, @@ -80,6 +81,7 @@ describe('server/helpers/task-list/generate-groups-and-tasks', () => { finalDestinationKnown, jointlyInsuredParty: jointlyInsuredParty.requested, isUsingBroker, + brokerIsBasedInUk, isAppointingLossPayee, lossPayeeIsLocatedInUk, hasDifferentTradingName, diff --git a/src/ui/server/helpers/task-list/generate-groups-and-tasks/index.ts b/src/ui/server/helpers/task-list/generate-groups-and-tasks/index.ts index d98f18a406..24734c7fbe 100644 --- a/src/ui/server/helpers/task-list/generate-groups-and-tasks/index.ts +++ b/src/ui/server/helpers/task-list/generate-groups-and-tasks/index.ts @@ -14,6 +14,7 @@ const { INITIAL_CHECKS, PREPARE_APPLICATION, SUBMIT_APPLICATION } = TASKS.LIST; * @param {Boolean} finalDestinationKnown: "Final destination known" flag * @param {Boolean} jointlyInsuredParty: "Jointly insured party" flag * @param {Boolean} isUsingBroker: "Is using broker" flag + * @param {Boolean} brokerIsBasedInUk: "Broker is based in the UK" flag * @param {Boolean} isAppointingLossPayee: "Is using loss payee" flag * @param {Boolean} lossPayeeIsLocatedInUk: "Loss payee is located in the UK" flag * @param {Boolean} lossPayeeIsLocatedInternationally: "Loss payee is located internationally" flag @@ -37,6 +38,7 @@ const generateGroupsAndTasks = ( finalDestinationKnown?: boolean, jointlyInsuredParty?: boolean, isUsingBroker?: boolean, + brokerIsBasedInUk?: boolean, isAppointingLossPayee?: boolean, lossPayeeIsLocatedInUk?: boolean, lossPayeeIsLocatedInternationally?: boolean, @@ -74,6 +76,7 @@ const generateGroupsAndTasks = ( finalDestinationKnown, jointlyInsuredParty, isUsingBroker, + brokerIsBasedInUk, isAppointingLossPayee, lossPayeeIsLocatedInUk, lossPayeeIsLocatedInternationally, diff --git a/src/ui/server/helpers/task-list/generate-groups-and-tasks/prepare-application.test.ts b/src/ui/server/helpers/task-list/generate-groups-and-tasks/prepare-application.test.ts index 049cb45b95..691ae0f84b 100644 --- a/src/ui/server/helpers/task-list/generate-groups-and-tasks/prepare-application.test.ts +++ b/src/ui/server/helpers/task-list/generate-groups-and-tasks/prepare-application.test.ts @@ -23,7 +23,7 @@ const { PREPARE_APPLICATION } = TASKS.LIST; describe('server/helpers/task-list/prepare-application', () => { const { - broker: { isUsingBroker }, + broker: { isUsingBroker, isBasedInUk: brokerIsBasedInUk }, buyer: { relationship: { exporterIsConnectedWithBuyer, exporterHasPreviousCreditInsuranceWithBuyer }, buyerTradingHistory: { exporterHasTradedWithBuyer, outstandingPayments }, @@ -70,6 +70,7 @@ describe('server/helpers/task-list/prepare-application', () => { finalDestinationKnown, jointlyInsuredParty: jointlyInsuredParty.requested, isUsingBroker, + brokerIsBasedInUk, isAppointingLossPayee, lossPayeeIsLocatedInUk, lossPayeeIsLocatedInternationally, @@ -118,6 +119,7 @@ describe('server/helpers/task-list/prepare-application', () => { policyType, jointlyInsuredParty: jointlyInsuredParty.requested, isUsingBroker, + brokerIsBasedInUk, isAppointingLossPayee, lossPayeeIsLocatedInUk, lossPayeeIsLocatedInternationally, diff --git a/src/ui/server/helpers/task-list/generate-groups-and-tasks/prepare-application.ts b/src/ui/server/helpers/task-list/generate-groups-and-tasks/prepare-application.ts index 617db042ed..d0f842b933 100644 --- a/src/ui/server/helpers/task-list/generate-groups-and-tasks/prepare-application.ts +++ b/src/ui/server/helpers/task-list/generate-groups-and-tasks/prepare-application.ts @@ -24,6 +24,7 @@ const { PREPARE_APPLICATION } = TASKS.LIST; * @param {Array} otherGroups: Task list groups * @param {String} policyType: Application "Policy type" * @param {Boolean} isUsingBroker: "Is using broker" flag + * @param {Boolean} brokerIsBasedInUk: "Broker is based in the UK" flag * @param {Boolean} isAppointingLossPayee: "Is using loss payee" flag * @param {Boolean} lossPayeeIsLocatedInUk: "Loss payee is located in the UK" flag * @param {Boolean} lossPayeeIsLocatedInternationally: "Loss payee is located internationally" flag @@ -41,6 +42,7 @@ const createPrepareApplicationTasks = ({ finalDestinationKnown, jointlyInsuredParty, isUsingBroker, + brokerIsBasedInUk, isAppointingLossPayee, lossPayeeIsLocatedInUk, lossPayeeIsLocatedInternationally, @@ -92,6 +94,7 @@ const createPrepareApplicationTasks = ({ policyType, jointlyInsuredParty, isUsingBroker, + brokerIsBasedInUk, isAppointingLossPayee, lossPayeeIsLocatedInUk, lossPayeeIsLocatedInternationally, diff --git a/src/ui/types/application.ts b/src/ui/types/application.ts index 4bb346818d..da52c9e899 100644 --- a/src/ui/types/application.ts +++ b/src/ui/types/application.ts @@ -125,6 +125,7 @@ interface ApplicationBusiness { interface ApplicationBroker { id: string; isUsingBroker?: boolean; + isBasedInUk?: boolean; name?: string; addressLine1?: string; addressLine2?: string; diff --git a/src/ui/types/task-list.ts b/src/ui/types/task-list.ts index f972974b75..0cfd0ad8fc 100644 --- a/src/ui/types/task-list.ts +++ b/src/ui/types/task-list.ts @@ -37,6 +37,7 @@ interface CreatePrepareApplicationTasksParams { finalDestinationKnown?: boolean; jointlyInsuredParty?: boolean; isUsingBroker?: boolean; + brokerIsBasedInUk?: boolean; isAppointingLossPayee?: boolean; lossPayeeIsLocatedInUk?: boolean; lossPayeeIsLocatedInternationally?: boolean;