Skip to content

Commit

Permalink
fix(EMS-3268): no PDF - policy - check your answers - redirect (#2505)
Browse files Browse the repository at this point in the history
* fix(EMS-3268): no pdf - policy - check your answers - redirect

* fix(EMS-3268): linting issues

* fix(EMS-3268): fix/update e2e tests
  • Loading branch information
ttbarnes authored Jun 4, 2024
1 parent 3c5b5a1 commit 65b4808
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ const completePrepareApplicationMultiplePolicyType = ({
});

cy.completeExportContractSection({
viaTaskList: false,
totalContractValueOverThreshold,
attemptedPrivateMarketCover,
isUsingAgent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ const completePrepareApplicationSinglePolicyType = ({
});

cy.completeExportContractSection({
viaTaskList: false,
totalContractValueOverThreshold,
attemptedPrivateMarketCover,
isUsingAgent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { headingCaption } from '../../../../../../pages/shared';
import {
BUTTONS,
PAGES,
} from '../../../../../../content-strings';
import { BUTTONS, PAGES } from '../../../../../../content-strings';
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';

const {
ROOT,
POLICY: {
CHECK_YOUR_ANSWERS,
LOSS_PAYEE_ROOT,
},
EXPORT_CONTRACT,
POLICY: { CHECK_YOUR_ANSWERS, LOSS_PAYEE_ROOT },
} = INSURANCE_ROUTES;

const CONTENT_STRINGS = PAGES.INSURANCE.POLICY.CHECK_YOUR_ANSWERS;
Expand Down Expand Up @@ -62,13 +55,12 @@ context('Insurance - Policy - Check your answers - As an exporter, I want to che
});

describe('form submission', () => {
it(`should redirect to ${EXPORT_CONTRACT.ROOT}`, () => {
it('should redirect to `all sections`', () => {
cy.navigateToUrl(url);

cy.clickSubmitButton();

const expectedUrl = `${baseUrl}${ROOT}/${referenceNumber}${EXPORT_CONTRACT.ROOT}`;
cy.assertUrl(expectedUrl);
cy.assertAllSectionsUrl(referenceNumber);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { FIELD_VALUES, ROUTES } from '../../../../../constants';

const {
INSURANCE: {
ROOT: INSURANCE_ROOT,
ALL_SECTIONS,
},
INSURANCE: { ROOT: INSURANCE_ROOT, ALL_SECTIONS },
} = ROUTES;

const policyType = FIELD_VALUES.POLICY_TYPE.MULTIPLE;
Expand All @@ -31,11 +28,9 @@ context('Insurance - Policy - Complete the entire section as a multiple contract

/**
* Submit the "Policy - check your answers" form,
* This proceeds to the next part of the flow - "Export contract - start"
* From here, we can get back to the "All sections" page.
* This proceeds to the next part of the flow - "All sections"
*/
cy.clickSubmitButton();
cy.clickAllSectionsLink();
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { INSURANCE_ROUTES } from '../../../../../constants/routes/insurance';

const {
ROOT: INSURANCE_ROOT,
ALL_SECTIONS,
} = INSURANCE_ROUTES;
const { ROOT: INSURANCE_ROOT, ALL_SECTIONS } = INSURANCE_ROUTES;

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

Expand All @@ -27,11 +24,9 @@ context('Insurance - Policy - Complete the entire section as a single contract p

/**
* Submit the "Policy - check your answers" form,
* This proceeds to the next part of the flow - "Export contract - start"
* From here, we can get back to the "All sections" page.
* This proceeds to the next part of the flow - "All sections"
*/
cy.clickSubmitButton();
cy.clickAllSectionsLink();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from '../../../../test-mocks';
import { mockBroker } from '../../../../test-mocks/mock-application';

const { INSURANCE_ROOT, ALL_SECTIONS, EXPORT_CONTRACT, PROBLEM_WITH_SERVICE } = INSURANCE_ROUTES;
const { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = INSURANCE_ROUTES;

const { POLICY } = FIELD_IDS.INSURANCE;

Expand Down Expand Up @@ -165,10 +165,10 @@ describe('controllers/insurance/policy/check-your-answers', () => {
});

describe('post', () => {
it(`should redirect to ${EXPORT_CONTRACT.ROOT}`, () => {
it(`should redirect to ${ALL_SECTIONS}`, () => {
post(req, res);

const expected = `${INSURANCE_ROOT}/${referenceNumber}${EXPORT_CONTRACT.ROOT}`;
const expected = `${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`;

expect(res.redirect).toHaveBeenCalledWith(expected);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import mapApplicationToFormFields from '../../../../helpers/mappings/map-applica
import { policySummaryLists } from '../../../../helpers/summary-lists/policy';
import { Request, Response } from '../../../../../types';

const { INSURANCE_ROOT, ALL_SECTIONS, EXPORT_CONTRACT, PROBLEM_WITH_SERVICE } = INSURANCE_ROUTES;
const { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = INSURANCE_ROUTES;

const { POLICY } = FIELD_IDS.INSURANCE;

Expand Down Expand Up @@ -79,5 +79,5 @@ export const get = async (req: Request, res: Response) => {
export const post = (req: Request, res: Response) => {
const { referenceNumber } = req.params;

return res.redirect(`${INSURANCE_ROOT}/${referenceNumber}${EXPORT_CONTRACT.ROOT}`);
return res.redirect(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`);
};

0 comments on commit 65b4808

Please sign in to comment.