Skip to content

Commit

Permalink
Merge branch 'main-broker-address-lookup' into feat/EMS-4054
Browse files Browse the repository at this point in the history
  • Loading branch information
ttbarnes committed Jan 15, 2025
2 parents 0ef15e4 + 6f3b9d8 commit adc1e89
Show file tree
Hide file tree
Showing 29 changed files with 504 additions and 131 deletions.
30 changes: 20 additions & 10 deletions e2e-tests/commands/insurance/check-policy-summary-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const {
NAME_ON_POLICY: { NAME, POSITION },
USING_BROKER,
BROKER_DETAILS,
BROKER_ADDRESSES,
BROKER_MANUAL_ADDRESS,
REQUESTED_JOINTLY_INSURED_PARTY: { REQUESTED, COMPANY_NAME, COMPANY_NUMBER, COUNTRY_CODE },
LOSS_PAYEE: { IS_APPOINTED: LOSS_PAYEE_IS_APPOINTED },
LOSS_PAYEE_DETAILS: { NAME: LOSS_PAYEE_NAME },
Expand Down Expand Up @@ -231,22 +233,30 @@ const checkPolicySummaryList = {

cy.assertSummaryListRow(summaryList, fieldId, expectedKey, expectedValue, expectedChangeLinkText);
},
// TODO: EMS-4011
// [BROKER_DETAILS.FULL_ADDRESS]: () => {
// const fieldId = BROKER_DETAILS.FULL_ADDRESS;
[BROKER_ADDRESSES.SELECT_THE_ADDRESS]: () => {
const fieldId = BROKER_ADDRESSES.SELECT_THE_ADDRESS;

// const expectedKey = FIELDS.BROKER_DETAILS[fieldId].SUMMARY.TITLE;
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_SINGLE_LINE_STRING);
row.value().contains(EXPECTED_SINGLE_LINE_STRING);

// const expectedLineBreaks = 3;
const expectedLineBreaks = 3;

// cy.assertLength(row.valueHtmlLineBreak(), expectedLineBreaks);
// },
cy.assertLength(row.valueHtmlLineBreak(), expectedLineBreaks);
},
[BROKER_MANUAL_ADDRESS.FULL_ADDRESS]: () => {
const fieldId = BROKER_MANUAL_ADDRESS.FULL_ADDRESS;

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

const expectedValue = application.BROKER[fieldId];

cy.assertSummaryListRow(summaryList, fieldId, expectedKey, expectedValue, expectedChangeLinkText);
},
[BROKER_DETAILS.EMAIL]: () => {
const fieldId = BROKER_DETAILS.NAME;

Expand Down
4 changes: 4 additions & 0 deletions e2e-tests/constants/routes/insurance/policy/broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ const BROKER_ROUTES = {
BROKER_DETAILS_CHECK_AND_CHANGE: `${BROKER_DETAILS_ROOT}/check-and-change`,
BROKER_ADDRESSES_ROOT,
BROKER_ADDRESSES_SAVE_AND_BACK: `${BROKER_ADDRESSES_ROOT}/save-and-back`,
BROKER_ADDRESSES_CHANGE: `${BROKER_ADDRESSES_ROOT}/change`,
BROKER_ADDRESSES_CHECK_AND_CHANGE: `${BROKER_ADDRESSES_ROOT}/check-and-change`,
BROKER_CONFIRM_ADDRESS_ROOT,
BROKER_ZERO_ADDRESSES_ROOT,
BROKER_MANUAL_ADDRESS_ROOT,
BROKER_MANUAL_ADDRESS_SAVE_AND_BACK: `${BROKER_MANUAL_ADDRESS_ROOT}/save-and-back`,
BROKER_MANUAL_ADDRESS_CHANGE: `${BROKER_MANUAL_ADDRESS_ROOT}/change`,
BROKER_MANUAL_ADDRESS_CHECK_AND_CHANGE: `${BROKER_MANUAL_ADDRESS_ROOT}/check-and-change`,
};

export default BROKER_ROUTES;
4 changes: 4 additions & 0 deletions e2e-tests/content-strings/fields/insurance/policy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ export const POLICY_FIELDS = {
BROKER_ADDRESSES: {
[SELECT_THE_ADDRESS]: {
LABEL: 'Select the address',
SUMMARY: {
TITLE: "Broker's address",
FORM_TITLE: POLICY_FORM_TITLES.BROKER,
},
},
},
BROKER_MANUAL_ADDRESS: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const {

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

const baseUrl = Cypress.config('baseUrl');
Expand Down Expand Up @@ -56,8 +57,7 @@ context('Insurance - Check your answers - Policy - Multiple contract policy - Wi
checkSummaryList.BROKER[NAME]({});
});

// TODO: EMS-4011
it.skip(`should render a ${FULL_ADDRESS} summary list row`, () => {
it(`should render a ${FULL_ADDRESS} summary list row`, () => {
checkSummaryList.BROKER[FULL_ADDRESS]();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const {

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

const baseUrl = Cypress.config('baseUrl');
Expand Down Expand Up @@ -56,8 +57,7 @@ context('Insurance - Check your answers - Policy - Single contract policy - With
checkSummaryList.BROKER[NAME]({});
});

// TODO: EMS-3976
it.skip(`should render a ${FULL_ADDRESS} summary list row`, () => {
it(`should render a ${FULL_ADDRESS} summary list row`, () => {
checkSummaryList.BROKER[FULL_ADDRESS]();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,100 +15,100 @@ const {

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

const { BROKER_MANUAL_ADDRESS: FIELD_STRINGS } = FIELDS;

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

context('Insurance - Policy - Broker manual address page - As an exporter, ... TODO', () => {
let referenceNumber;
let url;
let lossPayeeUrl;
context(
"Insurance - Policy - Broker manual address page - As an exporter, I want to provide UKEF with my broker's details So that UKEF can communicate with the broker as needed whilst processing my application",
() => {
let referenceNumber;
let url;
let lossPayeeUrl;

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

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

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

// TODO: EMS-3973 - remove this
cy.navigateToUrl(url);

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

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

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

it('renders core page elements', () => {
cy.corePageChecks({
pageTitle: CONTENT_STRINGS.PAGE_TITLE,
currentHref: `${ROOT}/${referenceNumber}${BROKER_MANUAL_ADDRESS_ROOT}`,
backLink: `${ROOT}/${referenceNumber}${BROKER_MANUAL_ADDRESS_ROOT}#`,
cy.assertUrl(url);
});
});
});

describe('page tests', () => {
beforeEach(() => {
cy.navigateToUrl(url);
cy.saveSession();
});

it('renders a heading caption', () => {
cy.checkText(headingCaption(), CONTENT_STRINGS.HEADING_CAPTION);
after(() => {
cy.deleteApplication(referenceNumber);
});

it('renders intro text', () => {
cy.checkIntroText(CONTENT_STRINGS.INTRO);
it('renders core page elements', () => {
cy.corePageChecks({
pageTitle: CONTENT_STRINGS.PAGE_TITLE,
currentHref: `${ROOT}/${referenceNumber}${BROKER_MANUAL_ADDRESS_ROOT}`,
backLink: `${ROOT}/${referenceNumber}${BROKER_DETAILS_ROOT}`,
});
});

it('renders `broker name` text', () => {
cy.checkText(brokerManualAddressPage.brokerName(), application.BROKER[NAME]);
});
describe('page tests', () => {
beforeEach(() => {
cy.navigateToUrl(url);
});

it(`renders ${FIELD_ID} textarea`, () => {
const fieldId = FIELD_ID;
const fieldStrings = FIELD_STRINGS[fieldId];
it('renders a heading caption', () => {
cy.checkText(headingCaption(), CONTENT_STRINGS.HEADING_CAPTION);
});

cy.assertTextareaRendering({
fieldId,
expectedLabel: fieldStrings.LABEL,
maximumCharacters: fieldStrings.MAXIMUM,
it('renders intro text', () => {
cy.checkIntroText(CONTENT_STRINGS.INTRO);
});
});
});

describe('form submission', () => {
beforeEach(() => {
cy.navigateToUrl(url);
it('renders `broker name` text', () => {
cy.checkText(brokerManualAddressPage.brokerName(), application.BROKER[NAME]);
});

it(`renders ${FIELD_ID} textarea`, () => {
const fieldId = FIELD_ID;
const fieldStrings = FIELD_STRINGS[fieldId];

cy.assertTextareaRendering({
fieldId,
expectedLabel: fieldStrings.LABEL,
maximumCharacters: fieldStrings.MAXIMUM,
});
});
});

it(`should redirect to ${LOSS_PAYEE_ROOT} page`, () => {
cy.completeAndSubmitBrokerManualAddressForm({});
describe('form submission', () => {
beforeEach(() => {
cy.navigateToUrl(url);
});

it(`should redirect to ${LOSS_PAYEE_ROOT} page`, () => {
cy.completeAndSubmitBrokerManualAddressForm({});

cy.assertUrl(lossPayeeUrl);
cy.assertUrl(lossPayeeUrl);
});
});
});

describe('when going back to the page', () => {
it('should have the submitted value', () => {
cy.navigateToUrl(url);
describe('when going back to the page', () => {
it('should have the submitted value', () => {
cy.navigateToUrl(url);

cy.checkTextareaValue({
fieldId: FIELD_ID,
expectedValue: application.BROKER[FIELD_ID],
cy.checkTextareaValue({
fieldId: FIELD_ID,
expectedValue: application.BROKER[FIELD_ID],
});
});
});
});
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ context('Insurance - Policy - Broker manual address page - Save and back', () =>
referenceNumber = refNumber;

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

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

// TODO: EMS-3973 - remove this
cy.navigateToUrl(url);

cy.assertUrl(url);
});
});
Expand Down Expand Up @@ -76,8 +73,12 @@ context('Insurance - Policy - Broker manual address page - Save and back', () =>
});

it('should have the originally submitted answer selected when going back to the page after submission', () => {
// TODO: EMS-3973 - remove this, use cy.clickSubmitButtonMultipleTimes instead.
cy.navigateToUrl(url);
cy.navigateToAllSectionsUrl(referenceNumber);

cy.startInsurancePolicySection({});

// go through 8 policy forms.
cy.clickSubmitButtonMultipleTimes({ count: 8 });

cy.checkTextareaValue({
fieldId: FIELD_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ context('Insurance - Policy - Broker manual address page - validation', () => {
referenceNumber = refNumber;

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

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

// TODO: EMS-3973 - remove this
cy.navigateToUrl(url);

cy.assertUrl(url);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ const assertFullyPopulatedExportContractSummaryListRows = ({ agentChargeMethodFi
checkSummaryList[NAME]({ shouldRender: true });
});

// TODO: EMS-4011
it.skip(`should render a ${FULL_ADDRESS} summary list row`, () => {
it(`should render a ${FULL_ADDRESS} summary list row`, () => {
checkSummaryList[FULL_ADDRESS]({ shouldRender: true });
});

Expand Down
4 changes: 4 additions & 0 deletions src/api/.keystone/config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/api/content-strings/fields/insurance/policy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ export const POLICY_FIELDS = {
BROKER_ADDRESSES: {
[SELECT_THE_ADDRESS]: {
LABEL: 'Select the address',
SUMMARY: {
TITLE: "Broker's address",
FORM_TITLE: POLICY_FORM_TITLES.BROKER,
},
},
},
BROKER_MANUAL_ADDRESS: {
Expand Down
4 changes: 4 additions & 0 deletions src/ui/server/constants/routes/insurance/policy/broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ const BROKER_ROUTES = {
BROKER_DETAILS_CHECK_AND_CHANGE: `${BROKER_DETAILS_ROOT}/check-and-change`,
BROKER_ADDRESSES_ROOT,
BROKER_ADDRESSES_SAVE_AND_BACK: `${BROKER_ADDRESSES_ROOT}/save-and-back`,
BROKER_ADDRESSES_CHANGE: `${BROKER_ADDRESSES_ROOT}/change`,
BROKER_ADDRESSES_CHECK_AND_CHANGE: `${BROKER_ADDRESSES_ROOT}/check-and-change`,
BROKER_CONFIRM_ADDRESS_ROOT,
BROKER_ZERO_ADDRESSES_ROOT,
BROKER_MANUAL_ADDRESS_ROOT,
BROKER_MANUAL_ADDRESS_SAVE_AND_BACK: `${BROKER_MANUAL_ADDRESS_ROOT}/save-and-back`,
BROKER_MANUAL_ADDRESS_CHANGE: `${BROKER_MANUAL_ADDRESS_ROOT}/change`,
BROKER_MANUAL_ADDRESS_CHECK_AND_CHANGE: `${BROKER_MANUAL_ADDRESS_ROOT}/check-and-change`,
};

export default BROKER_ROUTES;
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ export const POLICY_FIELDS = {
BROKER_ADDRESSES: {
[SELECT_THE_ADDRESS]: {
LABEL: 'Select the address',
SUMMARY: {
TITLE: "Broker's address",
FORM_TITLE: POLICY_FORM_TITLES.BROKER,
},
},
},
BROKER_MANUAL_ADDRESS: {
Expand Down
Loading

0 comments on commit adc1e89

Please sign in to comment.