Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(EMS-4054): broker addresses - single address redirection #3475

Merged
merged 13 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { ORDNANCE_SURVEY_EXAMPLES } from '../../constants';
import { radios } from '../../pages/shared';
import { POLICY as POLICY_FIELD_IDS } from '../../constants/field-ids/insurance/policy';

const { TREASURY } = ORDNANCE_SURVEY_EXAMPLES;

const {
BROKER_ADDRESSES: { SELECT_THE_ADDRESS: FIELD_ID },
} = POLICY_FIELD_IDS;
Expand All @@ -10,7 +13,7 @@ const {
* Complete "broker addresses" form
* @param {String} optionValue: Address option value
*/
const completeBrokerAddressesForm = ({ optionValue = '1 H M TREASURY HORSE GUARDS ROAD' }) => {
const completeBrokerAddressesForm = ({ optionValue = `${TREASURY.ADDRESS_LINE_1} ${TREASURY.ADDRESS_LINE_2}` }) => {
const optionDataCy = `${FIELD_ID}-${optionValue}`;

radios(optionDataCy).option.label().click();
Expand Down
6 changes: 5 additions & 1 deletion e2e-tests/commands/insurance/complete-policy-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const { POLICY_TYPE } = APPLICATION;
* @param {Boolean} needPreCreditPeriod: If the user needs a pre-credit period - defaults to false
* @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 {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 @@ -31,6 +32,7 @@ const completePolicySection = ({
needPreCreditPeriod = false,
usingBroker = false,
brokerIsBasedInUk = false,
multipleBrokerAddressesAvailable = false,
brokerBuildingNumberOrName,
brokerPostcode,
otherCompanyInvolved = false,
Expand Down Expand Up @@ -82,7 +84,9 @@ const completePolicySection = ({
});

if (brokerIsBasedInUk) {
cy.completeAndSubmitBrokerAddressesForm({});
if (multipleBrokerAddressesAvailable) {
cy.completeAndSubmitBrokerAddressesForm({});
}

// submit the "confirm broker address" form
cy.clickSubmitButton();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const { POLICY_TYPE } = APPLICATION;
* @param {Boolean} brokerIsBasedInUk: Should submit "yes or "no" to "broker is based in the UK".
* @param {String} brokerBuildingNumberOrName: Broker building name or number.
* @param {String} brokerPostcode: Broker postcode.
* @param {Boolean} multipleBrokerAddressesAvailable: Multiple broker addresses are available from Ordnance Survey.
*/
const completePrepareApplicationMultiplePolicyType = ({
agentChargeMethodFixedSum = false,
Expand Down Expand Up @@ -84,6 +85,7 @@ const completePrepareApplicationMultiplePolicyType = ({
brokerIsBasedInUk = false,
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
}) => {
cy.completeBusinessSection({
differentTradingName,
Expand Down Expand Up @@ -115,6 +117,7 @@ const completePrepareApplicationMultiplePolicyType = ({
brokerIsBasedInUk,
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
otherCompanyInvolved,
needPreCreditPeriod,
isAppointingLossPayee,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const { POLICY_TYPE } = FIELD_VALUES;
* @param {Boolean} brokerIsBasedInUk: Should submit "yes or "no" to "broker is based in the UK".
* @param {String} brokerBuildingNumberOrName: Broker building name or number.
* @param {String} brokerPostcode: Broker postcode.
* @param {Boolean} multipleBrokerAddressesAvailable: Multiple broker addresses are available from Ordnance Survey.
*/
const completePrepareApplicationSinglePolicyType = ({
agentChargeMethodFixedSum = false,
Expand Down Expand Up @@ -84,6 +85,7 @@ const completePrepareApplicationSinglePolicyType = ({
brokerIsBasedInUk = false,
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
}) => {
cy.completeBusinessSection({
differentTradingName,
Expand Down Expand Up @@ -115,6 +117,7 @@ const completePrepareApplicationSinglePolicyType = ({
brokerIsBasedInUk,
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
otherCompanyInvolved,
needPreCreditPeriod,
isAppointingLossPayee,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import completeSignInAndGoToApplication from './account/complete-sign-in-and-go-
* @param {Boolean} brokerIsBasedInUk: Should submit "yes or "no" to "broker is based in the UK".
* @param {String} brokerBuildingNumberOrName: Broker building name or number.
* @param {String} brokerPostcode: Broker postcode.
* @param {Boolean} multipleBrokerAddressesAvailable: Multiple broker addresses are available from Ordnance Survey.
* @return {String} Application reference number
*/
const completeSignInAndSubmitAnApplication = ({
Expand Down Expand Up @@ -82,6 +83,7 @@ const completeSignInAndSubmitAnApplication = ({
brokerIsBasedInUk = false,
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
}) => {
completeSignInAndGoToApplication({
companyNumber,
Expand Down Expand Up @@ -122,6 +124,7 @@ const completeSignInAndSubmitAnApplication = ({
brokerIsBasedInUk,
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
});
} else {
cy.completePrepareApplicationSinglePolicyType({
Expand Down Expand Up @@ -157,6 +160,7 @@ const completeSignInAndSubmitAnApplication = ({
brokerIsBasedInUk,
brokerBuildingNumberOrName,
brokerPostcode,
multipleBrokerAddressesAvailable,
});
}
cy.completeAndSubmitCheckYourAnswers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const { SINGLE } = APPLICATION.POLICY_TYPE;
* @param {Boolean} isBasedInUk: Broker is based in the UK
* @param {String} postcode: Broker postcode
* @param {String} buildingNumberOrName: Broker building name or number
* @param {Boolean} multipleBrokerAddressesAvailable: Multiple broker addresses are available from Ordnance Survey
*/
const completeAndSubmitPolicyForms = ({
stopSubmittingAfter,
Expand All @@ -32,6 +33,7 @@ const completeAndSubmitPolicyForms = ({
isBasedInUk = true,
postcode,
buildingNumberOrName,
multipleBrokerAddressesAvailable,
}) => {
cy.startInsurancePolicySection({});

Expand Down Expand Up @@ -60,9 +62,13 @@ const completeAndSubmitPolicyForms = ({
steps.push({ name: 'brokerDetails', action: () => cy.completeAndSubmitBrokerDetailsForm({ isBasedInUk, postcode, buildingNumberOrName }) });

if (isBasedInUk) {
steps.push({ name: 'brokerAddresses', action: () => cy.completeAndSubmitBrokerAddressesForm({ isBasedInUk }) });
if (multipleBrokerAddressesAvailable) {
steps.push({ name: 'brokerAddresses', action: () => cy.completeAndSubmitBrokerAddressesForm({ isBasedInUk }) });
}

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

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

/**
* clickZeroAddressesEnterManuallyLink
* Click the "enter manually" link in the "zero addresses" page.
*/
const clickZeroAddressesEnterManuallyLink = () => {
brokerZeroAddressesPage.outro.enterManuallyLink().click();
};

export default clickZeroAddressesEnterManuallyLink;
2 changes: 2 additions & 0 deletions e2e-tests/commands/shared-commands/click-events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ 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('clickFooterAccessibilityStatementLink', require('./click-footer-accessibility-statement-link'));
Cypress.Commands.add('clickFooterCookiesLink', require('./click-footer-cookies-link'));

Expand Down
11 changes: 11 additions & 0 deletions e2e-tests/constants/examples/address-lookup-input-examples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const ADDRESS_LOOKUP_INPUT_EXAMPLES = {
TREASURY: {
POSTCODE: 'SW1A 2HQ',
BUILDING_NUMBER: '1',
BUILDING_NAME: 'H M Treasury',
},
WESTMINSTER_BRIDGE_STREET: {
POSTCODE: 'SW1A 2JR',
BUILDING_NAME: 'Westminster',
},
};
1 change: 1 addition & 0 deletions e2e-tests/constants/examples/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './address-lookup-input-examples';
export * from './building-names';
export * from './company-details-examples';
export * from './companies-house-number-examples';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { ORDNANCE_SURVEY_EXAMPLES } from './ordnance-survey-examples';

const { TREASURY } = ORDNANCE_SURVEY_EXAMPLES;
const { TREASURY, WESTMINSTER_BRIDGE_STREET } = ORDNANCE_SURVEY_EXAMPLES;

const { UNDERGROUND_STATION } = WESTMINSTER_BRIDGE_STREET;

export const EXPECTED_TREASURY_SINGLE_LINE_STRING = `${TREASURY.ADDRESS_LINE_1}${TREASURY.ADDRESS_LINE_2}${TREASURY.TOWN}${TREASURY.POSTCODE}`;
export const EXPECTED_TREASURY_MULTI_LINE_STRING = `${TREASURY.ADDRESS_LINE_1}\n${TREASURY.ADDRESS_LINE_2}\n${TREASURY.TOWN}\n${TREASURY.POSTCODE}`;

export const EXPECTED_UNDERGROUND_STATION_SINGLE_LINE_STRING = `${UNDERGROUND_STATION.ADDRESS_LINE_1}${UNDERGROUND_STATION.ADDRESS_LINE_2}${UNDERGROUND_STATION.TOWN}${UNDERGROUND_STATION.POSTCODE}`;
export const EXPECTED_UNDERGROUND_STATION_MULTI_LINE_STRING = `${UNDERGROUND_STATION.ADDRESS_LINE_1}\n${UNDERGROUND_STATION.ADDRESS_LINE_2}\n${UNDERGROUND_STATION.TOWN}\n${UNDERGROUND_STATION.POSTCODE}`;
8 changes: 8 additions & 0 deletions e2e-tests/constants/examples/ordnance-survey-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ export const ORDNANCE_SURVEY_EXAMPLES = {
TOWN: 'LONDON',
POSTCODE: 'SW1A 2HQ',
},
WESTMINSTER_BRIDGE_STREET: {
UNDERGROUND_STATION: {
ADDRESS_LINE_1: 'LONDON UNDERGROUND LTD WESTMINSTER STATION',
ADDRESS_LINE_2: 'BRIDGE STREET',
TOWN: 'LONDON',
POSTCODE: 'SW1A 2JR',
},
},
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { errorSummaryListItems, errorSummaryListItemLinks } from '../../../../../../partials';
import { field as fieldSelector, intro, radios } from '../../../../../../pages/shared';
import { brokerAddressesPage } from '../../../../../../pages/insurance/policy';
import { ADDRESS_LOOKUP_INPUT_EXAMPLES, ORDNANCE_SURVEY_EXAMPLES } from '../../../../../../constants';
import { ERROR_MESSAGES, PAGES } from '../../../../../../content-strings';
import { POLICY_FIELDS as FIELDS } from '../../../../../../content-strings/fields/insurance/policy';
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';
import { POLICY as POLICY_FIELD_IDS } from '../../../../../../constants/field-ids/insurance/policy';

const { WESTMINSTER_BRIDGE_STREET } = ADDRESS_LOOKUP_INPUT_EXAMPLES;
const { UNDERGROUND_STATION } = ORDNANCE_SURVEY_EXAMPLES.WESTMINSTER_BRIDGE_STREET;

const {
PAGE_TITLE,
INTRO: { ADDRESS, FOUND_FOR, SEPARATOR, SEARCH_AGAIN },
INTRO: { ADDRESSES, FOUND_FOR, SEPARATOR, SEARCH_AGAIN },
} = PAGES.INSURANCE.POLICY.BROKER_ADDRESSES;

const {
Expand All @@ -26,7 +30,7 @@ const baseUrl = Cypress.config('baseUrl');

const field = fieldSelector(FIELD_ID);

const optionValue = '1 H M TREASURY HORSE GUARDS ROAD';
const optionValue = `${UNDERGROUND_STATION.ADDRESS_LINE_1} ${UNDERGROUND_STATION.ADDRESS_LINE_2}`;

const optionDataCy = `${FIELD_ID}-${optionValue}`;

Expand All @@ -42,7 +46,13 @@ context(
referenceNumber = refNumber;

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

url = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_ADDRESSES_ROOT}`;
brokerConfirmAddressUrl = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_CONFIRM_ADDRESS_ROOT}`;
Expand Down Expand Up @@ -76,10 +86,10 @@ context(
intro()
.invoke('text')
.then((text) => {
expect(text.trim()).includes(`1 ${ADDRESS} ${FOUND_FOR} `);
expect(text.trim()).includes('SW1A 2HQ');
expect(text.trim()).includes(`2 ${ADDRESSES} ${FOUND_FOR} `);
expect(text.trim()).includes(WESTMINSTER_BRIDGE_STREET.POSTCODE);
expect(text.trim()).includes(` ${SEPARATOR} `);
expect(text.trim()).includes('1.');
expect(text.trim()).includes(`${WESTMINSTER_BRIDGE_STREET.BUILDING_NAME}.`);
expect(text.trim()).includes(SEARCH_AGAIN);
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { radios } from '../../../../../../pages/shared';
import { ADDRESS_LOOKUP_INPUT_EXAMPLES, ORDNANCE_SURVEY_EXAMPLES } from '../../../../../../constants';
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';
import { POLICY as POLICY_FIELD_IDS } from '../../../../../../constants/field-ids/insurance/policy';

const { WESTMINSTER_BRIDGE_STREET } = ADDRESS_LOOKUP_INPUT_EXAMPLES;
const { UNDERGROUND_STATION } = ORDNANCE_SURVEY_EXAMPLES.WESTMINSTER_BRIDGE_STREET;

const {
BROKER_ADDRESSES: { SELECT_THE_ADDRESS: FIELD_ID },
} = POLICY_FIELD_IDS;
Expand All @@ -13,7 +17,7 @@ const {

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

const optionValue = '1 H M TREASURY HORSE GUARDS ROAD';
const optionValue = `${UNDERGROUND_STATION.ADDRESS_LINE_1} ${UNDERGROUND_STATION.ADDRESS_LINE_2}`;

context('Insurance - Policy - Broker addresses page - Save and back', () => {
let referenceNumber;
Expand All @@ -24,7 +28,13 @@ context('Insurance - Policy - Broker addresses page - Save and back', () => {
referenceNumber = refNumber;

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

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

Expand Down
Loading
Loading