Skip to content

Commit eaddd5e

Browse files
committed
Merge branch 'main-broker-address-lookup' into chore/EMS-4062-4099
2 parents b81b9a4 + 8ca0408 commit eaddd5e

File tree

69 files changed

+1915
-818
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1915
-818
lines changed

e2e-tests/commands/insurance/check-policy-summary-list.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,17 @@ const checkPolicySummaryList = {
252252
cy.assertSummaryListRowDoesNotExist(summaryList, fieldId);
253253
}
254254
},
255-
[BROKER_MANUAL_ADDRESS.FULL_ADDRESS]: ({ shouldRender = true }) => {
255+
[BROKER_MANUAL_ADDRESS.FULL_ADDRESS]: ({ shouldRender = true, value }) => {
256256
const fieldId = BROKER_MANUAL_ADDRESS.FULL_ADDRESS;
257257

258258
if (shouldRender) {
259259
const { expectedKey, expectedChangeLinkText } = getSummaryListField(fieldId, FIELDS.BROKER_MANUAL_ADDRESS);
260260

261-
const expectedValue = application.BROKER[fieldId];
261+
let expectedValue = application.BROKER[fieldId];
262+
263+
if (value) {
264+
expectedValue = value;
265+
}
262266

263267
cy.assertSummaryListRow(summaryList, fieldId, expectedKey, expectedValue, expectedChangeLinkText);
264268
} else {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { useDifferentAddressLink } from '../../../partials/insurance';
2+
3+
/**
4+
* clickUseDifferentAddressLink
5+
* Click the "enter manually" link in the "zero addresses" page.
6+
*/
7+
const clickUseDifferentAddressLink = () => {
8+
useDifferentAddressLink().click();
9+
};
10+
11+
export default clickUseDifferentAddressLink;

e2e-tests/commands/shared-commands/click-events/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Cypress.Commands.add('clickYesRadioInput', require('./click-yes-radio-input'));
1111
Cypress.Commands.add('clickAlternativeCurrencyRadioOption', require('./click-alternative-currency-radio-option'));
1212

1313
Cypress.Commands.add('clickEnterAddressManuallyLink', require('./click-enter-address-manually-link'));
14+
Cypress.Commands.add('clickUseDifferentAddressLink', require('./click-use-different-address-link'));
1415

1516
Cypress.Commands.add('clickFooterAccessibilityStatementLink', require('./click-footer-accessibility-statement-link'));
1617
Cypress.Commands.add('clickFooterCookiesLink', require('./click-footer-cookies-link'));

e2e-tests/constants/examples/ordnance-survey-examples.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@ export const ORDNANCE_SURVEY_EXAMPLES = {
1212
TOWN: 'LONDON',
1313
POSTCODE: 'SW1A 2JR',
1414
},
15+
W_H_SMITH: {
16+
ADDRESS_LINE_1: 'W H SMITH LTD WESTMINSTER STATION',
17+
ADDRESS_LINE_2: 'BRIDGE STREET',
18+
TOWN: 'LONDON',
19+
POSTCODE: 'SW1A 2JR',
20+
},
1521
},
1622
};

e2e-tests/insurance/cypress/e2e/journeys/check-your-answers/policy/change-your-answers/broker/change-your-answers-change-broker.spec.js

Lines changed: 0 additions & 239 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { summaryList } from '../../../../../../../../pages/shared';
2+
import { POLICY as POLICY_FIELD_IDS } from '../../../../../../../../constants/field-ids/insurance/policy';
3+
import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance';
4+
import checkSummaryList from '../../../../../../../../commands/insurance/check-policy-summary-list';
5+
6+
const {
7+
USING_BROKER,
8+
BROKER_DETAILS: { NAME, EMAIL },
9+
BROKER_ADDRESSES: { SELECT_THE_ADDRESS },
10+
BROKER_MANUAL_ADDRESS: { FULL_ADDRESS },
11+
} = POLICY_FIELD_IDS;
12+
13+
const {
14+
ROOT,
15+
CHECK_YOUR_ANSWERS: { TYPE_OF_POLICY },
16+
POLICY: { BROKER_CONFIRM_ADDRESS_CHECK_AND_CHANGE },
17+
} = INSURANCE_ROUTES;
18+
19+
const baseUrl = Cypress.config('baseUrl');
20+
21+
context(
22+
'Insurance - Change your answers - Policy - Broker - Broker address - Based in UK to Not based in UK - As an exporter, I want to change my answers to the broker section',
23+
() => {
24+
let referenceNumber;
25+
let checkYourAnswersUrl;
26+
27+
before(() => {
28+
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
29+
referenceNumber = refNumber;
30+
31+
cy.completePrepareApplicationSinglePolicyType({
32+
usingBroker: true,
33+
brokerIsBasedInUk: true,
34+
});
35+
36+
cy.clickTaskCheckAnswers();
37+
38+
// To get past previous "Check your answers" pages
39+
cy.completeAndSubmitMultipleCheckYourAnswers({ count: 2 });
40+
41+
checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${TYPE_OF_POLICY}`;
42+
});
43+
});
44+
45+
beforeEach(() => {
46+
cy.saveSession();
47+
});
48+
49+
after(() => {
50+
cy.deleteApplication(referenceNumber);
51+
});
52+
53+
describe('when clicking the `change` link', () => {
54+
it(`should redirect to ${BROKER_CONFIRM_ADDRESS_CHECK_AND_CHANGE}`, () => {
55+
cy.navigateToUrl(checkYourAnswersUrl);
56+
57+
summaryList.field(SELECT_THE_ADDRESS).changeLink().click();
58+
59+
cy.assertChangeAnswersPageUrl({ referenceNumber, route: BROKER_CONFIRM_ADDRESS_CHECK_AND_CHANGE, fieldId: SELECT_THE_ADDRESS });
60+
});
61+
});
62+
63+
describe('after changing the answer from no to yes and completing (now required) non UK broker address field', () => {
64+
beforeEach(() => {
65+
cy.navigateToUrl(checkYourAnswersUrl);
66+
});
67+
68+
it(`should redirect to ${TYPE_OF_POLICY}`, () => {
69+
summaryList.field(NAME).changeLink().click();
70+
71+
cy.completeAndSubmitBrokerDetailsForm({ isBasedInUk: false });
72+
cy.completeAndSubmitBrokerManualAddressForm({});
73+
74+
cy.assertChangeAnswersPageUrl({ referenceNumber, route: TYPE_OF_POLICY, fieldId: NAME });
75+
});
76+
77+
it(`should render the new ${FULL_ADDRESS} answer and related fields`, () => {
78+
checkSummaryList[USING_BROKER]({ usingBroker: true });
79+
checkSummaryList.BROKER[NAME]();
80+
checkSummaryList.BROKER[EMAIL]();
81+
82+
checkSummaryList.BROKER[FULL_ADDRESS]({ shouldRender: true });
83+
});
84+
85+
it(`should NOT render ${SELECT_THE_ADDRESS} field`, () => {
86+
checkSummaryList.BROKER[SELECT_THE_ADDRESS]({ shouldRender: false });
87+
});
88+
});
89+
},
90+
);

0 commit comments

Comments
 (0)