Skip to content

Commit

Permalink
feat(EMS-3979): broker details - task list logic (#3325)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ttbarnes authored Jan 8, 2025
1 parent c192bfb commit c606a36
Show file tree
Hide file tree
Showing 50 changed files with 431 additions and 105 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
19 changes: 19 additions & 0 deletions e2e-tests/commands/insurance/complete-broker-addresses-form.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion e2e-tests/commands/insurance/complete-buyer-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/commands/insurance/complete-declarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
19 changes: 14 additions & 5 deletions e2e-tests/commands/insurance/complete-policy-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -27,6 +28,7 @@ const completePolicySection = ({
sameName = true,
needPreCreditPeriod = false,
usingBroker = false,
brokerIsBasedInUk = false,
otherCompanyInvolved = false,
isAppointingLossPayee = false,
lossPayeeIsLocatedInUK = false,
Expand Down Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -78,6 +79,7 @@ const completePrepareApplicationMultiplePolicyType = ({
totalContractValueOverThreshold = false,
submitCheckYourAnswers = true,
usingBroker = false,
brokerIsBasedInUk = false,
}) => {
cy.completeBusinessSection({
differentTradingName,
Expand Down Expand Up @@ -106,6 +108,7 @@ const completePrepareApplicationMultiplePolicyType = ({
policyValueOverMvpMaximum,
submitCheckYourAnswers,
usingBroker,
brokerIsBasedInUk,
otherCompanyInvolved,
needPreCreditPeriod,
isAppointingLossPayee,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -78,6 +79,7 @@ const completePrepareApplicationSinglePolicyType = ({
totalContractValueOverThreshold = false,
submitCheckYourAnswers = true,
usingBroker = false,
brokerIsBasedInUk = false,
}) => {
cy.completeBusinessSection({
differentTradingName,
Expand Down Expand Up @@ -106,6 +108,7 @@ const completePrepareApplicationSinglePolicyType = ({
policyValueOverMvpMaximum,
submitCheckYourAnswers,
usingBroker,
brokerIsBasedInUk,
otherCompanyInvolved,
needPreCreditPeriod,
isAppointingLossPayee,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ({
Expand Down Expand Up @@ -76,6 +77,7 @@ const completeSignInAndSubmitAnApplication = ({
policyValueOverMvpMaximum = false,
totalContractValueOverThreshold = false,
usingBroker = false,
brokerIsBasedInUk = false,
}) => {
completeSignInAndGoToApplication({
companyNumber,
Expand Down Expand Up @@ -113,6 +115,7 @@ const completeSignInAndSubmitAnApplication = ({
referenceNumber,
totalContractValueOverThreshold,
usingBroker,
brokerIsBasedInUk,
});
} else {
cy.completePrepareApplicationSinglePolicyType({
Expand Down Expand Up @@ -145,6 +148,7 @@ const completeSignInAndSubmitAnApplication = ({
referenceNumber,
totalContractValueOverThreshold,
usingBroker,
brokerIsBasedInUk,
});
}
cy.completeAndSubmitCheckYourAnswers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 12 additions & 2 deletions e2e-tests/constants/field-ids/insurance/policy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
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;

before(() => {
cy.completeSignInAndSubmitAnApplication({
policyType: APPLICATION.POLICY_TYPE.MULTIPLE,
usingBroker: true,
brokerIsBasedInUk: true,
}).then((refNumber) => {
referenceNumber = refNumber;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ context(
exportingWithCodeOfConduct: true,
policyValueOverMvpMaximum: true,
usingBroker: true,
brokerIsBasedInUk: true,
otherCompanyInvolved: true,
differentPolicyContact: true,
needPreCreditPeriod: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
});
});
Expand Down
Loading

0 comments on commit c606a36

Please sign in to comment.