Skip to content

Commit

Permalink
fix(EMS-3348-3402): no PDF - check your answers - export contract - s…
Browse files Browse the repository at this point in the history
…ubmit button (#2502)

* fix(EMS-3348-3402): no pdf - check your answers - export contract - submit button

* fix(EMS-3348-3402): no pdf - check your answers - export contract - submit button
  • Loading branch information
ttbarnes authored Jun 4, 2024
1 parent 30756c8 commit 7011ab9
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 84 deletions.
1 change: 0 additions & 1 deletion e2e-tests/constants/routes/insurance/check-your-answers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ export const CHECK_YOUR_ANSWERS = {
YOUR_BUYER: YOUR_BUYER_ROOT,
YOUR_BUYER_SAVE_AND_BACK: `${YOUR_BUYER_ROOT}/save-and-back`,
EXPORT_CONTRACT: EXPORT_CONTRACT_ROOT,
EXPORT_CONTRACT_SAVE_AND_BACK: `${EXPORT_CONTRACT_ROOT}/save-and-back`,
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';
const {
ROOT: INSURANCE_ROOT,
ALL_SECTIONS,
CHECK_YOUR_ANSWERS: {
EXPORT_CONTRACT,
TYPE_OF_POLICY,
},
CHECK_YOUR_ANSWERS: { EXPORT_CONTRACT, TYPE_OF_POLICY },
} = INSURANCE_ROUTES;

const CONTENT_STRINGS = PAGES.INSURANCE.CHECK_YOUR_ANSWERS.YOUR_EXPORT_CONTRACT;
Expand All @@ -20,76 +17,76 @@ const task = taskList.submitApplication.tasks.checkAnswers;

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

context('Insurance - Change your answers - Export contract - As an exporter, I want to be able to review my input for the export contract again, So that I can do a final review of the information I previously input before submitting my application', () => {
let referenceNumber;
let url;
context(
'Insurance - Change your answers - Export contract - As an exporter, I want to be able to review my input for the export contract again, So that I can do a final review of the information I previously input before submitting my application',
() => {
let referenceNumber;
let url;

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

cy.completePrepareApplicationSinglePolicyType({ referenceNumber });
cy.completePrepareApplicationSinglePolicyType({ referenceNumber });

task.link().click();
task.link().click();

// To get past previous "Check your answers" pages
cy.completeAndSubmitMultipleCheckYourAnswers({ count: 3 });
// To get past previous "Check your answers" pages
cy.completeAndSubmitMultipleCheckYourAnswers({ count: 3 });

url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${EXPORT_CONTRACT}`;
url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${EXPORT_CONTRACT}`;

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

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

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

it('renders core page elements', () => {
cy.corePageChecks({
pageTitle: CONTENT_STRINGS.PAGE_TITLE,
currentHref: `${INSURANCE_ROOT}/${referenceNumber}${EXPORT_CONTRACT}`,
backLink: `${INSURANCE_ROOT}/${referenceNumber}${TYPE_OF_POLICY}`,
submitButtonCopy: BUTTONS.CONFIRM_AND_CONTINUE,
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 a `save and back` button', () => {
cy.assertSaveAndBackButton();
it('renders core page elements', () => {
cy.corePageChecks({
pageTitle: CONTENT_STRINGS.PAGE_TITLE,
currentHref: `${INSURANCE_ROOT}/${referenceNumber}${EXPORT_CONTRACT}`,
backLink: `${INSURANCE_ROOT}/${referenceNumber}${TYPE_OF_POLICY}`,
submitButtonCopy: BUTTONS.SAVE_AND_BACK,
assertSaveAndBackButtonDoesNotExist: true,
});
});
});

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

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

const expectedUrl = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`;
cy.assertUrl(expectedUrl);
it('renders a heading caption', () => {
cy.checkText(headingCaption(), CONTENT_STRINGS.HEADING_CAPTION);
});
});

describe('when going back to the all sections page', () => {
beforeEach(() => {
cy.navigateToAllSectionsUrl(referenceNumber);
describe('form submission', () => {
it(`should redirect to ${ALL_SECTIONS}`, () => {
cy.navigateToUrl(url);

cy.clickSubmitButton();

const expectedUrl = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`;
cy.assertUrl(expectedUrl);
});

it('should change the status of task `check your answers` to `completed`', () => {
cy.checkTaskCheckAnswersStatusIsComplete();
describe('when going back to the all sections page', () => {
beforeEach(() => {
cy.navigateToAllSectionsUrl(referenceNumber);
});

it('should change the status of task `check your answers` to `completed`', () => {
cy.checkTaskCheckAnswersStatusIsComplete();
});
});
});
});
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ export const CHECK_YOUR_ANSWERS = {
YOUR_BUYER: YOUR_BUYER_ROOT,
YOUR_BUYER_SAVE_AND_BACK: `${YOUR_BUYER_ROOT}/save-and-back`,
EXPORT_CONTRACT: EXPORT_CONTRACT_ROOT,
EXPORT_CONTRACT_SAVE_AND_BACK: `${EXPORT_CONTRACT_ROOT}/save-and-back`,
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FIELD_ID, pageVariables, get, post, TEMPLATE } from '.';
import { PAGES } from '../../../../content-strings';
import { BUTTONS, PAGES } from '../../../../content-strings';
import { ROUTES, TEMPLATES } from '../../../../constants';
import CHECK_YOUR_ANSWERS_FIELD_IDS from '../../../../constants/field-ids/insurance/check-your-answers';
import { CHECK_YOUR_ANSWERS_FIELDS as FIELDS } from '../../../../content-strings/fields/insurance/check-your-answers';
Expand All @@ -15,12 +15,7 @@ import { mockReq, mockRes, referenceNumber, mockApplication, mockCountries } fro
const CHECK_YOUR_ANSWERS_TEMPLATE = TEMPLATES.INSURANCE.CHECK_YOUR_ANSWERS;

const {
INSURANCE: {
INSURANCE_ROOT,
ALL_SECTIONS,
CHECK_YOUR_ANSWERS: { EXPORT_CONTRACT_SAVE_AND_BACK },
PROBLEM_WITH_SERVICE,
},
INSURANCE: { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE },
} = ROUTES;

const { exportContract, totalContractValueOverThreshold } = mockApplication;
Expand Down Expand Up @@ -60,17 +55,15 @@ describe('controllers/insurance/check-your-answers/export-contract', () => {

describe('pageVariables', () => {
it('should have correct properties', () => {
const result = pageVariables(referenceNumber);

const expected = {
FIELD: {
ID: FIELD_ID,
...FIELDS[FIELD_ID],
},
SAVE_AND_BACK_URL: `${INSURANCE_ROOT}/${referenceNumber}${EXPORT_CONTRACT_SAVE_AND_BACK}`,
SUBMIT_BUTTON_COPY: BUTTONS.SAVE_AND_BACK,
};

expect(result).toEqual(expected);
expect(pageVariables).toEqual(expected);
});
});

Expand Down Expand Up @@ -111,7 +104,7 @@ describe('controllers/insurance/check-your-answers/export-contract', () => {
BACK_LINK: req.headers.referer,
}),
userName: getUserNameFromSession(req.session.user),
...pageVariables(referenceNumber),
...pageVariables,
status,
SUMMARY_LISTS: summaryList,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PAGES } from '../../../../content-strings';
import { BUTTONS, PAGES } from '../../../../content-strings';
import { ROUTES, TEMPLATES } from '../../../../constants';
import FIELD_IDS from '../../../../constants/field-ids/insurance';
import { CHECK_YOUR_ANSWERS_FIELDS as FIELDS } from '../../../../content-strings/fields/insurance/check-your-answers';
Expand All @@ -15,27 +15,21 @@ export const TEMPLATE = TEMPLATES.INSURANCE.CHECK_YOUR_ANSWERS;
export const FIELD_ID = FIELD_IDS.CHECK_YOUR_ANSWERS.EXPORT_CONTRACT;

const {
INSURANCE: {
INSURANCE_ROOT,
ALL_SECTIONS,
CHECK_YOUR_ANSWERS: { EXPORT_CONTRACT_SAVE_AND_BACK },
PROBLEM_WITH_SERVICE,
},
INSURANCE: { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE },
} = ROUTES;

/**
* pageVariables
* Page fields and "save and go back" URL
* @param {Number} Application reference number
* Page fields and SUBMIT_BUTTON_COPY
* @returns {Object} Page variables
*/
export const pageVariables = (referenceNumber: number) => ({
export const pageVariables = {
FIELD: {
ID: FIELD_ID,
...FIELDS[FIELD_ID],
},
SAVE_AND_BACK_URL: `${INSURANCE_ROOT}/${referenceNumber}${EXPORT_CONTRACT_SAVE_AND_BACK}`,
});
SUBMIT_BUTTON_COPY: BUTTONS.SAVE_AND_BACK,
};

/**
* get
Expand Down Expand Up @@ -89,7 +83,7 @@ export const get = async (req: Request, res: Response) => {
BACK_LINK: req.headers.referer,
}),
userName: getUserNameFromSession(req.session.user),
...pageVariables(referenceNumber),
...pageVariables,
status,
SUMMARY_LISTS: summaryList,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@

<div class="govuk-button-group">
{{ submitButton.render({
text: CONTENT_STRINGS.BUTTONS.CONFIRM_AND_CONTINUE
text: SUBMIT_BUTTON_COPY or CONTENT_STRINGS.BUTTONS.CONFIRM_AND_CONTINUE
}) }}

{% if eligibility %}

<a class="govuk-button govuk-button--secondary" href="{{ START_NEW_APPLICATION }}" data-cy="save-and-back-button">{{ CONTENT_STRINGS.CHANGE_ANSWERS }}</a>

{% else %}
{% elif SAVE_AND_BACK_URL %}

{{ govukButton({
text: CONTENT_STRINGS.BUTTONS.SAVE_AND_BACK,
Expand Down

0 comments on commit 7011ab9

Please sign in to comment.