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-4011-4022): policy - change your answers - broker address #3482

Merged
merged 21 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8d76df1
feat(EMS-4011-4120): policy - change your answers - broker address
ttbarnes Jan 14, 2025
64d59aa
feat(EMS-4011-4120): policy - change your answers - broker address
ttbarnes Jan 15, 2025
d9209a9
Merge branch 'main-broker-address-lookup' into feat/EMS-4011-4120
ttbarnes Jan 15, 2025
f35c5fa
chore(EMS-4011-4120): update e2e tests
ttbarnes Jan 15, 2025
ede128e
feat(EMS-4011-4120): policy - change your answers - broker based in uk
ttbarnes Jan 15, 2025
40dd366
chore(e2e): align test descriptions
ttbarnes Jan 15, 2025
982525c
feat(EMS-4011-4120): update e2e tests
ttbarnes Jan 15, 2025
0ef8e38
feat(EMS-4011-4120): update 'different address ur' to handle change r…
ttbarnes Jan 15, 2025
b6f6752
fix(EMS-4011): broker summary list address field mapping
ttbarnes Jan 15, 2025
96aa3b8
feat(EMS-4011-4120): fix typos
ttbarnes Jan 15, 2025
34b37ff
chore(mocks): update ui mock broker data
ttbarnes Jan 16, 2025
ef8183d
chore(docs): remove unnecessary comments
ttbarnes Jan 16, 2025
c50e245
Merge branch 'main-broker-address-lookup' into feat/EMS-4011-4120
ttbarnes Jan 20, 2025
ec5c2e7
feat(EMS-4011-4120): address todo comments
ttbarnes Jan 20, 2025
221f2f6
Merge branch 'main-broker-address-lookup' into feat/EMS-4011-4120
ttbarnes Jan 20, 2025
673cc5b
feat(EMS-4011-4120): update e2e test
ttbarnes Jan 20, 2025
8da7921
feat(EMS-4011-4120): create brokerDetailsDataChangeFlags helper function
ttbarnes Jan 20, 2025
1fac12a
feat(EMS-4011-4120): address todo comment
ttbarnes Jan 20, 2025
1a018f9
feat(EMS-4011-4120): refactor/extract broker details redirection logic
ttbarnes Jan 21, 2025
10c8d6c
chore(EMS-4011): fix linting issue
ttbarnes Jan 21, 2025
c4887d3
feat(EMS-4011-4120): minor code edits
ttbarnes Jan 21, 2025
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
1 change: 0 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
"venv",
"VNET",
"vnets",
"WOGAN",
"XLSX",
"eg9qxlqw4edxa8b5mwbybsrfp",
"mzwp337piamg1mei7fqh1o73s",
Expand Down
30 changes: 19 additions & 11 deletions e2e-tests/commands/insurance/check-policy-summary-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,29 +233,37 @@ const checkPolicySummaryList = {

cy.assertSummaryListRow(summaryList, fieldId, expectedKey, expectedValue, expectedChangeLinkText);
},
[BROKER_ADDRESSES.SELECT_THE_ADDRESS]: () => {
[BROKER_ADDRESSES.SELECT_THE_ADDRESS]: ({ shouldRender = true, expectedValue = EXPECTED_TREASURY_SINGLE_LINE_STRING }) => {
const fieldId = BROKER_ADDRESSES.SELECT_THE_ADDRESS;

const expectedKey = FIELDS.BROKER_ADDRESSES[fieldId].SUMMARY.TITLE;
if (shouldRender) {
const expectedKey = FIELDS.BROKER_ADDRESSES[fieldId].SUMMARY.TITLE;

const row = summaryList.field(fieldId);
const row = summaryList.field(fieldId);

cy.checkText(row.key(), expectedKey);
cy.checkText(row.key(), expectedKey);

row.value().contains(EXPECTED_TREASURY_SINGLE_LINE_STRING);
row.value().contains(expectedValue);

const expectedLineBreaks = 4;
const expectedLineBreaks = 4;

cy.assertLength(row.valueHtmlLineBreak(), expectedLineBreaks);
cy.assertLength(row.valueHtmlLineBreak(), expectedLineBreaks);
} else {
cy.assertSummaryListRowDoesNotExist(summaryList, fieldId);
}
},
[BROKER_MANUAL_ADDRESS.FULL_ADDRESS]: () => {
[BROKER_MANUAL_ADDRESS.FULL_ADDRESS]: ({ shouldRender = true }) => {
const fieldId = BROKER_MANUAL_ADDRESS.FULL_ADDRESS;

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

const expectedValue = application.BROKER[fieldId];
const expectedValue = application.BROKER[fieldId];

cy.assertSummaryListRow(summaryList, fieldId, expectedKey, expectedValue, expectedChangeLinkText);
cy.assertSummaryListRow(summaryList, fieldId, expectedKey, expectedValue, expectedChangeLinkText);
} else {
cy.assertSummaryListRowDoesNotExist(summaryList, fieldId);
}
},
[BROKER_DETAILS.EMAIL]: () => {
const fieldId = BROKER_DETAILS.NAME;
Expand Down
2 changes: 2 additions & 0 deletions e2e-tests/constants/routes/insurance/policy/broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const BROKER_ROUTES = {
BROKER_ADDRESSES_CHANGE: `${BROKER_ADDRESSES_ROOT}/change`,
BROKER_ADDRESSES_CHECK_AND_CHANGE: `${BROKER_ADDRESSES_ROOT}/check-and-change`,
BROKER_CONFIRM_ADDRESS_ROOT,
BROKER_CONFIRM_ADDRESS_CHANGE: `${BROKER_CONFIRM_ADDRESS_ROOT}/change`,
BROKER_CONFIRM_ADDRESS_CHECK_AND_CHANGE: `${BROKER_CONFIRM_ADDRESS_ROOT}/check-and-change`,
BROKER_ZERO_ADDRESSES_ROOT,
BROKER_MANUAL_ADDRESS_ROOT,
BROKER_MANUAL_ADDRESS_SAVE_AND_BACK: `${BROKER_MANUAL_ADDRESS_ROOT}/save-and-back`,
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/fixtures/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const application = {
[USING_BROKER]: true,
[NAME]: 'Mock broker name',
[EMAIL]: Cypress.env('GOV_NOTIFY_EMAIL_RECIPIENT_1'),
[BROKER_FULL_ADDRESS]: 'Mock broker address',
[BROKER_FULL_ADDRESS]: 'Mock full broker address',
[BUILDING_NUMBER_OR_NAME]: '1',
[POSTCODE]: VALID_POSTCODES.WITH_SPACE,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { APPLICATION } from '../../../../../../../constants';

context(
'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',
'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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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',
'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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { APPLICATION, BUILDING_NAMES, VALID_POSTCODES } from '../../../../../../../constants';

context(
'Insurance - submit an application - Multiple policy type with a broker - based in UK - Building as a name - 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 - Building as a name - 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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { APPLICATION, VALID_POSTCODES } from '../../../../../../../constants';

context(
'Insurance - submit an application - Multiple policy type with a broker - based in UK - Building as a number - 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 - Building as a number - 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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
context(
'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',
'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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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',
'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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BUILDING_NAMES, VALID_POSTCODES } from '../../../../../../../constants';

context(
'Insurance - submit an application - Single policy type with a broker - based in UK - Building as a name - 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 - Building as a name - 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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { VALID_POSTCODES } from '../../../../../../../constants';

context(
'Insurance - submit an application - Single policy type with a broker - based in UK - Building as a number - 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 - Building as a number - 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ context('Insurance - Change your answers - Policy - Broker - No to yes - As an e
summaryList.field(FIELD_ID).changeLink().click();

cy.completeAndSubmitBrokerForm({ usingBroker: true });
cy.completeAndSubmitBrokerDetailsForm({ usingBroker: true });
cy.completeAndSubmitBrokerDetailsForm({});

cy.assertChangeAnswersPageUrl({ referenceNumber, route: TYPE_OF_POLICY, fieldId: FIELD_ID });
});

it(`should render new ${FIELD_ID} answer and broker details fields`, () => {
checkSummaryList[FIELD_ID]({ usingBroker: true });
checkSummaryList.BROKER[NAME]({});
checkSummaryList.BROKER[NAME]();

// TODO: EMS-3975
// checkSummaryList.BROKER[FULL_ADDRESS]();
// checkSummaryList.BROKER[FULL_ADDRESS]({});

checkSummaryList.BROKER[EMAIL]();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {

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

context('Insurance - Check your answers - Policy - Multiple contract policy - Broker - based in UK - Summary List', () => {
context('Insurance - Check your answers - Policy - Multiple contract policy - Broker - Based in UK - Summary List', () => {
let url;
let referenceNumber;

Expand Down Expand Up @@ -54,11 +54,11 @@ context('Insurance - Check your answers - Policy - Multiple contract policy - Br
});

it(`should render a ${NAME} summary list row`, () => {
checkSummaryList.BROKER[NAME]({});
checkSummaryList.BROKER[NAME]();
});

it(`should render a ${SELECT_THE_ADDRESS} summary list row`, () => {
checkSummaryList.BROKER[SELECT_THE_ADDRESS]();
checkSummaryList.BROKER[SELECT_THE_ADDRESS]({});
});

it(`should render a ${EMAIL} summary list row`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {

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

context('Insurance - Check your answers - Policy - Multiple contract policy - Broker - not based in UK - Summary List', () => {
context('Insurance - Check your answers - Policy - Multiple contract policy - Broker - Not based in UK - Summary List', () => {
let url;
let referenceNumber;

Expand Down Expand Up @@ -44,6 +44,6 @@ context('Insurance - Check your answers - Policy - Multiple contract policy - Br
});

it(`should render a ${FULL_ADDRESS} summary list row`, () => {
checkSummaryList.BROKER[FULL_ADDRESS]();
checkSummaryList.BROKER[FULL_ADDRESS]({});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {

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

context('Insurance - Check your answers - Policy - Single contract policy - Broker - not based in UK - Summary List', () => {
context('Insurance - Check your answers - Policy - Single contract policy - Broker - Not based in UK - Summary List', () => {
let url;
let referenceNumber;

Expand Down Expand Up @@ -54,11 +54,11 @@ context('Insurance - Check your answers - Policy - Single contract policy - Brok
});

it(`should render a ${NAME} summary list row`, () => {
checkSummaryList.BROKER[NAME]({});
checkSummaryList.BROKER[NAME]();
});

it(`should render a ${SELECT_THE_ADDRESS} summary list row`, () => {
checkSummaryList.BROKER[SELECT_THE_ADDRESS]();
checkSummaryList.BROKER[SELECT_THE_ADDRESS]({});
});

it(`should render a ${EMAIL} summary list row`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {

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

context('Insurance - Check your answers - Policy - Single contract policy - Broker - not based in UK - Summary List', () => {
context('Insurance - Check your answers - Policy - Single contract policy - Broker - Not based in UK - Summary List', () => {
let url;
let referenceNumber;

Expand Down Expand Up @@ -54,11 +54,11 @@ context('Insurance - Check your answers - Policy - Single contract policy - Brok
});

it(`should render a ${NAME} summary list row`, () => {
checkSummaryList.BROKER[NAME]({});
checkSummaryList.BROKER[NAME]();
});

it(`should render a ${FULL_ADDRESS} summary list row`, () => {
checkSummaryList.BROKER[FULL_ADDRESS]();
checkSummaryList.BROKER[FULL_ADDRESS]({});
});

it(`should render a ${EMAIL} summary list row`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { summaryList } from '../../../../../../../pages/shared';
import { POLICY as POLICY_FIELD_IDS } from '../../../../../../../constants/field-ids/insurance/policy';
import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insurance';
import checkSummaryList from '../../../../../../../commands/insurance/check-policy-summary-list';

const {
USING_BROKER,
BROKER_DETAILS: { NAME, EMAIL },
BROKER_ADDRESSES: { SELECT_THE_ADDRESS },
BROKER_MANUAL_ADDRESS: { FULL_ADDRESS },
} = POLICY_FIELD_IDS;

const {
ROOT,
POLICY: { BROKER_CONFIRM_ADDRESS_CHANGE, CHECK_YOUR_ANSWERS },
} = INSURANCE_ROUTES;

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

context(
'Insurance - Policy - Change your answers - Broker address - Based in UK to Not based in UK - As an exporter, I want to change my answers to the broker section',
() => {
let referenceNumber;
let checkYourAnswersUrl;

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

cy.completePolicySection({ usingBroker: true, brokerIsBasedInUk: true });

checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`;
});
});

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

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

describe('when clicking the `change` link', () => {
it(`should redirect to ${BROKER_CONFIRM_ADDRESS_CHANGE}`, () => {
cy.navigateToUrl(checkYourAnswersUrl);

summaryList.field(SELECT_THE_ADDRESS).changeLink().click();

cy.assertChangeAnswersPageUrl({ referenceNumber, route: BROKER_CONFIRM_ADDRESS_CHANGE, fieldId: SELECT_THE_ADDRESS });
});
});

describe('after changing the answer from no to yes and completing (now required) non UK broker address field', () => {
beforeEach(() => {
cy.navigateToUrl(checkYourAnswersUrl);
});

it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => {
summaryList.field(NAME).changeLink().click();

cy.completeAndSubmitBrokerDetailsForm({ isBasedInUk: false });
cy.completeAndSubmitBrokerManualAddressForm({});

cy.assertChangeAnswersPageUrl({ referenceNumber, route: CHECK_YOUR_ANSWERS, fieldId: NAME });
});

it(`should render the new ${FULL_ADDRESS} answer and related fields`, () => {
checkSummaryList[USING_BROKER]({ usingBroker: true });
checkSummaryList.BROKER[NAME]();
checkSummaryList.BROKER[EMAIL]();

checkSummaryList.BROKER[FULL_ADDRESS]({ shouldRender: true });
});

it(`should NOT render ${SELECT_THE_ADDRESS} field`, () => {
checkSummaryList.BROKER[SELECT_THE_ADDRESS]({ shouldRender: false });
});
});
},
);
Loading
Loading