Skip to content

Commit

Permalink
feat(EMS-4141): fix/update/improve e2e test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ttbarnes committed Jan 23, 2025
1 parent 68cb0ab commit aa9681d
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const {

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

const optionValue = `${UNDERGROUND_STATION.ADDRESS_LINE_1} ${UNDERGROUND_STATION.ADDRESS_LINE_2}`;
Expand Down Expand Up @@ -95,6 +95,39 @@ context(
it(`should NOT render ${FULL_ADDRESS} field`, () => {
checkSummaryList.BROKER[FULL_ADDRESS]({ shouldRender: false });
});

describe(`when going back to ${BROKER_DETAILS_ROOT}`, () => {
beforeEach(() => {
cy.navigateToUrl(checkYourAnswersUrl);

summaryList.field(NAME).changeLink().click();
});

it('should retain the new values', () => {
cy.assertBrokerDetailsFieldValues({
isBasedInUk: true,
expectedPostcode: WESTMINSTER_BRIDGE_STREET.POSTCODE,
expectedBuildingNumberOrName: WESTMINSTER_BRIDGE_STREET.BUILDING_NAME,
});
});
});

describe(`when going to ${BROKER_MANUAL_ADDRESS_ROOT}`, () => {
beforeEach(() => {
cy.navigateToUrl(checkYourAnswersUrl);

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

cy.clickEnterAddressManuallyLink();
});

it(`should have an empty ${FULL_ADDRESS} value`, () => {
cy.checkTextareaValue({
fieldId: FULL_ADDRESS,
expectedValue: '',
});
});
});
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,28 @@ import { ADDRESS_LOOKUP_INPUT_EXAMPLES } from '../../../../../../../constants';
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';
import application from '../../../../../../../fixtures/application';

const { WESTMINSTER_BRIDGE_STREET } = ADDRESS_LOOKUP_INPUT_EXAMPLES;

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

const {
ROOT,
POLICY: { BROKER_ADDRESSES_CHANGE, BROKER_CONFIRM_ADDRESS_CHANGE, BROKER_MANUAL_ADDRESS_CHANGE, CHECK_YOUR_ANSWERS },
POLICY: {
BROKER_ADDRESSES_CHANGE,
BROKER_CONFIRM_ADDRESS_CHANGE,
BROKER_DETAILS_ROOT,
BROKER_MANUAL_ADDRESS_ROOT,
BROKER_MANUAL_ADDRESS_CHANGE,
CHECK_YOUR_ANSWERS,
},
} = INSURANCE_ROUTES;

const baseUrl = Cypress.config('baseUrl');
Expand Down Expand Up @@ -96,6 +105,39 @@ context(
it(`should NOT render ${SELECT_THE_ADDRESS} field`, () => {
checkSummaryList.BROKER[SELECT_THE_ADDRESS]({ shouldRender: false });
});

describe(`when going back to ${BROKER_DETAILS_ROOT}`, () => {
beforeEach(() => {
cy.navigateToUrl(checkYourAnswersUrl);

summaryList.field(NAME).changeLink().click();
});

it(`should retain the new ${IS_BASED_IN_UK} value and have empty address lookup fields`, () => {
cy.assertBrokerDetailsFieldValues({
isBasedInUk: true,
expectedPostcode: '',
expectedBuildingNumberOrName: '',
});
});
});

describe(`when going to ${BROKER_MANUAL_ADDRESS_ROOT}`, () => {
beforeEach(() => {
cy.navigateToUrl(checkYourAnswersUrl);

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

cy.clickEnterAddressManuallyLink();
});

it('should have the submitted value', () => {
cy.checkTextareaValue({
fieldId: FULL_ADDRESS,
expectedValue: application.BROKER[FULL_ADDRESS],
});
});
});
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {

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

const baseUrl = Cypress.config('baseUrl');
Expand Down Expand Up @@ -83,6 +83,35 @@ context(
it(`should NOT render ${FULL_ADDRESS} field`, () => {
checkSummaryList.BROKER[FULL_ADDRESS]({ shouldRender: false });
});

describe(`when going back to ${BROKER_DETAILS_ROOT}`, () => {
beforeEach(() => {
cy.navigateToUrl(checkYourAnswersUrl);

summaryList.field(NAME).changeLink().click();
});

it('should retain the new values', () => {
cy.assertBrokerDetailsFieldValues({ isBasedInUk: true });
});
});

describe(`when going to ${BROKER_MANUAL_ADDRESS_ROOT}`, () => {
beforeEach(() => {
cy.navigateToUrl(checkYourAnswersUrl);

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

cy.clickEnterAddressManuallyLink();
});

it(`should have an empty ${FULL_ADDRESS} value`, () => {
cy.checkTextareaValue({
fieldId: FULL_ADDRESS,
expectedValue: '',
});
});
});
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ import { brokerConfirmAddressPage } from '../../../../../../../pages/insurance/p
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';
import application from '../../../../../../../fixtures/application';

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

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

const baseUrl = Cypress.config('baseUrl');
Expand Down Expand Up @@ -92,6 +94,39 @@ context(
it(`should NOT render ${SELECT_THE_ADDRESS} field`, () => {
checkSummaryList.BROKER[SELECT_THE_ADDRESS]({ shouldRender: false });
});

describe(`when going back to ${BROKER_DETAILS_ROOT}`, () => {
beforeEach(() => {
cy.navigateToUrl(checkYourAnswersUrl);

summaryList.field(NAME).changeLink().click();
});

it(`should retain the new ${IS_BASED_IN_UK} value and have empty address lookup fields`, () => {
cy.assertBrokerDetailsFieldValues({
isBasedInUk: true,
expectedPostcode: '',
expectedBuildingNumberOrName: '',
});
});
});

describe(`when going to ${BROKER_MANUAL_ADDRESS_ROOT}`, () => {
beforeEach(() => {
cy.navigateToUrl(checkYourAnswersUrl);

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

cy.clickEnterAddressManuallyLink();
});

it('should have the submitted value', () => {
cy.checkTextareaValue({
fieldId: FULL_ADDRESS,
expectedValue: application.BROKER[FULL_ADDRESS],
});
});
});
});
},
);

This file was deleted.

0 comments on commit aa9681d

Please sign in to comment.