Skip to content

Commit

Permalink
feat(EMS-4141): broker address lookup - manual entry (#3494)
Browse files Browse the repository at this point in the history
* feat(EMS-4141): broker address lookup - enter manually

* feat(EMS-4141): fix/update e2e tests

* chore(e2e): fix typo

* feat(EMS-4141): additional e2e test coverage

* chore(e2e): dry click/assert enter address manually commands

* feat(EMS-4141): update xlsx mapping

* chore(e2e): address todo comment

* feat(EMS-4141): update broker summary list mapping

* feat(EMS-4141): update broker controllers 'manual address' urls

* feat(EMS-4141): update broker controllers 'manual address' urls

* feat(EMS-4141): improve e2e coverage

* chore(docs): improve documentation

* feat(EMS-4141): remove todo comment

* feat(EMS-4141): fix/update e2e test

* feat(EMS-4141): update broker submitted data mapping issue

* feat(EMS-4141): fix/update/improve e2e test coverage
  • Loading branch information
ttbarnes authored Jan 24, 2025
1 parent b07cb96 commit 4dee04f
Show file tree
Hide file tree
Showing 55 changed files with 905 additions and 259 deletions.
12 changes: 10 additions & 2 deletions e2e-tests/commands/insurance/complete-policy-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const { POLICY_TYPE } = APPLICATION;
* @param {Boolean} usingBroker: If "using broker" - defaults to false
* @param {Boolean} brokerIsBasedInUk: Broker is based in the UK - defaults to false
* @param {Boolean} multipleBrokerAddressesAvailable: Multiple broker addresses are available from Ordnance Survey
* @param {Boolean} provideBrokerAddressManually: Provide a broker address manually, instead of selecting a result from Ordnance Survey
* @param {String} brokerBuildingNumberOrName: Broker building name or number
* @param {String} brokerPostcode: Broker postcode
* @param {Boolean} otherCompanyInvolved: Should submit "yes" to "another company to be insured". Defaults to false.
Expand All @@ -33,6 +34,7 @@ const completePolicySection = ({
usingBroker = false,
brokerIsBasedInUk = false,
multipleBrokerAddressesAvailable = false,
provideBrokerAddressManually = false,
brokerBuildingNumberOrName,
brokerPostcode,
otherCompanyInvolved = false,
Expand Down Expand Up @@ -88,8 +90,14 @@ const completePolicySection = ({
cy.completeAndSubmitBrokerAddressesForm({});
}

// submit the "confirm broker address" form
cy.clickSubmitButton();
if (provideBrokerAddressManually) {
cy.clickEnterAddressManuallyLink();

cy.completeAndSubmitBrokerManualAddressForm({});
} else {
// submit the "confirm broker address" form
cy.clickSubmitButton();
}
} else {
cy.completeAndSubmitBrokerManualAddressForm({});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const { POLICY_TYPE } = APPLICATION;
* @param {String} brokerBuildingNumberOrName: Broker building name or number.
* @param {String} brokerPostcode: Broker postcode.
* @param {Boolean} multipleBrokerAddressesAvailable: Multiple broker addresses are available from Ordnance Survey.
* @param {Boolean} provideBrokerAddressManually: Provide a broker address manually, instead of selecting a result from Ordnance Survey
*/
const completePrepareApplicationMultiplePolicyType = ({
agentChargeMethodFixedSum = false,
Expand Down Expand Up @@ -86,6 +87,7 @@ const completePrepareApplicationMultiplePolicyType = ({
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
provideBrokerAddressManually,
}) => {
cy.completeBusinessSection({
differentTradingName,
Expand Down Expand Up @@ -118,6 +120,7 @@ const completePrepareApplicationMultiplePolicyType = ({
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
provideBrokerAddressManually,
otherCompanyInvolved,
needPreCreditPeriod,
isAppointingLossPayee,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const { POLICY_TYPE } = FIELD_VALUES;
* @param {String} brokerBuildingNumberOrName: Broker building name or number.
* @param {String} brokerPostcode: Broker postcode.
* @param {Boolean} multipleBrokerAddressesAvailable: Multiple broker addresses are available from Ordnance Survey.
* @param {Boolean} provideBrokerAddressManually: Provide a broker address manually, instead of selecting a result from Ordnance Survey
*/
const completePrepareApplicationSinglePolicyType = ({
agentChargeMethodFixedSum = false,
Expand Down Expand Up @@ -86,6 +87,7 @@ const completePrepareApplicationSinglePolicyType = ({
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
provideBrokerAddressManually,
}) => {
cy.completeBusinessSection({
differentTradingName,
Expand Down Expand Up @@ -118,6 +120,7 @@ const completePrepareApplicationSinglePolicyType = ({
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
provideBrokerAddressManually,
otherCompanyInvolved,
needPreCreditPeriod,
isAppointingLossPayee,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import completeSignInAndGoToApplication from './account/complete-sign-in-and-go-
* @param {String} brokerBuildingNumberOrName: Broker building name or number.
* @param {String} brokerPostcode: Broker postcode.
* @param {Boolean} multipleBrokerAddressesAvailable: Multiple broker addresses are available from Ordnance Survey.
* @param {Boolean} provideBrokerAddressManually: Provide a broker address manually, instead of selecting a result from Ordnance Survey
* @return {String} Application reference number
*/
const completeSignInAndSubmitAnApplication = ({
Expand Down Expand Up @@ -84,6 +85,7 @@ const completeSignInAndSubmitAnApplication = ({
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
provideBrokerAddressManually,
}) => {
completeSignInAndGoToApplication({
companyNumber,
Expand Down Expand Up @@ -125,6 +127,7 @@ const completeSignInAndSubmitAnApplication = ({
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
provideBrokerAddressManually,
});
} else {
cy.completePrepareApplicationSinglePolicyType({
Expand Down Expand Up @@ -161,6 +164,7 @@ const completeSignInAndSubmitAnApplication = ({
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
provideBrokerAddressManually,
});
}
cy.completeAndSubmitCheckYourAnswers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const completeAndSubmitPolicyForms = ({

steps.push({ name: 'brokerConfirmAddress', action: () => cy.clickSubmitButton() });
} else {
cy.completeAndSubmitBrokerManualAddressForm({});
steps.push({ name: 'brokerManualAddress', action: () => cy.completeAndSubmitBrokerManualAddressForm({}) });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ const baseUrl = Cypress.config('baseUrl');
* assertEnterAddressManuallyLink
* Check the "enter address manually" link and redirection
* @param {Number} referenceNumber: Application reference number
* @param {Number} expectedText: Expected link text
*/
const assertEnterAddressManuallyLink = ({ referenceNumber }) => {
const assertEnterAddressManuallyLink = ({ referenceNumber, expectedText = LINKS.ENTER_ADDRESS_MANUALLY }) => {
const expectedRoute = `${ROOT}/${referenceNumber}${BROKER_MANUAL_ADDRESS_ROOT}`;

cy.checkLink(enterAddressManuallyLink(), expectedRoute, LINKS.ENTER_ADDRESS_MANUALLY);
cy.checkLink(enterAddressManuallyLink(), expectedRoute, expectedText);

enterAddressManuallyLink().click();
cy.clickEnterAddressManuallyLink();

const expectedUrl = `${baseUrl}${expectedRoute}`;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { enterAddressManuallyLink } from '../../../partials/insurance';

/**
* clickEnterAddressManuallyLink
* Click the "enter manually" link in the "zero addresses" page.
*/
const clickEnterAddressManuallyLink = () => {
enterAddressManuallyLink().click();
};

export default clickEnterAddressManuallyLink;

This file was deleted.

2 changes: 1 addition & 1 deletion e2e-tests/commands/shared-commands/click-events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Cypress.Commands.add('clickYesRadioInput', require('./click-yes-radio-input'));

Cypress.Commands.add('clickAlternativeCurrencyRadioOption', require('./click-alternative-currency-radio-option'));

Cypress.Commands.add('clickZeroAddressesEntryManuallyLink', require('./click-zero-addresses-enter-manually-link'));
Cypress.Commands.add('clickEnterAddressManuallyLink', require('./click-enter-address-manually-link'));

Cypress.Commands.add('clickFooterAccessibilityStatementLink', require('./click-footer-accessibility-statement-link'));
Cypress.Commands.add('clickFooterCookiesLink', require('./click-footer-cookies-link'));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { APPLICATION, BUILDING_NAMES, VALID_POSTCODES } from '../../../../../../../constants';

context(
'Insurance - submit an application - Multiple policy type with a broker - Based in UK - Manual address - 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,
brokerPostcode: VALID_POSTCODES.WITH_SPACE,
brokerBuildingNumberOrName: BUILDING_NAMES.TREASURY,
provideBrokerAddressManually: true,
}).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 the application in a `submitted` state in the dashboard', () => {
cy.assertDashboardApplicationSubmitted(referenceNumber);
});
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { BUILDING_NAMES, VALID_POSTCODES } from '../../../../../../../constants';

context(
'Insurance - submit an application - Single policy type with a broker - Based in UK - Manual address - 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: true,
brokerPostcode: VALID_POSTCODES.WITH_SPACE,
brokerBuildingNumberOrName: BUILDING_NAMES.TREASURY,
provideBrokerAddressManually: true,
}).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 the application in a `submitted` state in the dashboard', () => {
cy.assertDashboardApplicationSubmitted(referenceNumber);
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {

const {
ROOT,
POLICY: { BROKER_MANUAL_ADDRESS_ROOT, BROKER_ZERO_ADDRESSES_ROOT, LOSS_PAYEE_ROOT },
POLICY: { BROKER_DETAILS_ROOT, BROKER_MANUAL_ADDRESS_ROOT, LOSS_PAYEE_ROOT },
} = INSURANCE_ROUTES;

const { BROKER_MANUAL_ADDRESS: FIELD_STRINGS } = FIELDS;
Expand All @@ -37,12 +37,10 @@ context(
cy.completeAndSubmitPolicyForms({
stopSubmittingAfter: 'brokerDetails',
usingBroker: true,
isBasedInUk: true,
isBasedInUk: false,
buildingNumberOrName: '123456789',
});

cy.clickZeroAddressesEntryManuallyLink();

url = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_MANUAL_ADDRESS_ROOT}`;
lossPayeeUrl = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_ROOT}`;

Expand All @@ -62,7 +60,7 @@ context(
cy.corePageChecks({
pageTitle: CONTENT_STRINGS.PAGE_TITLE,
currentHref: `${ROOT}/${referenceNumber}${BROKER_MANUAL_ADDRESS_ROOT}`,
backLink: `${ROOT}/${referenceNumber}${BROKER_ZERO_ADDRESSES_ROOT}`,
backLink: `${ROOT}/${referenceNumber}${BROKER_DETAILS_ROOT}`,
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { field } from '../../../../../../pages/shared';
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';
import { POLICY as POLICY_FIELD_IDS } from '../../../../../../constants/field-ids/insurance/policy';
import application from '../../../../../../fixtures/application';

const {
BROKER_MANUAL_ADDRESS: { FULL_ADDRESS: FIELD_ID },
} = POLICY_FIELD_IDS;

const {
ROOT,
POLICY: { BROKER_MANUAL_ADDRESS_ROOT },
} = INSURANCE_ROUTES;

const baseUrl = Cypress.config('baseUrl');

context('Insurance - Policy - Broker manual address page - Based in UK - Save and back', () => {
let referenceNumber;
let url;

before(() => {
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
referenceNumber = refNumber;

// go to the page we want to test.
cy.completeAndSubmitPolicyForms({
stopSubmittingAfter: 'brokerDetails',
usingBroker: true,
isBasedInUk: true,
buildingNumberOrName: '123456789',
});

cy.clickEnterAddressManuallyLink();

url = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_MANUAL_ADDRESS_ROOT}`;

cy.assertUrl(url);
});
});

beforeEach(() => {
cy.saveSession();
});

after(() => {
cy.deleteApplication(referenceNumber);
});

describe('when submitting an empty form via `save and go back` button', () => {
beforeEach(() => {
cy.navigateToUrl(url);

cy.clickSaveAndBackButton();
});

it('should redirect to `all sections`', () => {
cy.assertAllSectionsUrl(referenceNumber);
});

it('should retain the `insurance policy` task status as `in progress`', () => {
cy.checkTaskPolicyStatusIsInProgress();
});
});

describe('when submitting an answer and submitting the form via `save and go back` button', () => {
beforeEach(() => {
cy.navigateToUrl(url);

// submit the form via 'save and go back' button
cy.keyboardInput(field(FIELD_ID).textarea(), application.BROKER[FIELD_ID]);

cy.clickSaveAndBackButton();
});

it('should redirect to `all sections`', () => {
cy.assertAllSectionsUrl(referenceNumber);
});

it('should retain the `insurance policy` task status as `in progress`', () => {
cy.checkTaskPolicyStatusIsInProgress();
});
});
});
Loading

0 comments on commit 4dee04f

Please sign in to comment.