Skip to content

Commit

Permalink
chore(tech): fix typo, improve test coverage for confirm email E2E te…
Browse files Browse the repository at this point in the history
…st (#510)
  • Loading branch information
ttbarnes authored May 31, 2023
1 parent e22f536 commit c9804ef
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ context('Insurance - Account - Create - Resend confirm email page - Go back to c
expectedUrl = `${Cypress.config('baseUrl')}${CONFIRM_EMAIL}?id=${account.id}`;

cy.url().should('eq', expectedUrl);

cy.assertConfirmEmailPageContent(account.id);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ const havingProblemsSection = {
requestNewLink: (accountId) => {
cy.checkText(confirmEmailPage.havingProblems.requestNew.youCan(), YOU_CAN);

cy.checkText(confirmEmailPage.havingProblems.requestNew.link(), LINK.TEXT);

const expected = `${LINK.HREF}?id=${accountId}`;
confirmEmailPage.havingProblems.requestNew.link().should('have.attr', 'href', expected);
cy.checkLink(
confirmEmailPage.havingProblems.requestNew.link(),
`${LINK.HREF}?id=${accountId}`,
LINK.TEXT,
);

cy.checkText(confirmEmailPage.havingProblems.requestNew.ifNotReceived(), IF_NOT_RECEIVED);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RequestBody } from '../../../../../../types';
import { FIELD_IDS } from '../../../../../constants';
import mapSubmittedData from '.';
import { mockExporterNatureOfBusiness } from '../../../../../test-mocks';
import { mockBusinessNatureOfBusiness } from '../../../../../test-mocks';
import { stripCommas } from '../../../../../helpers/string';

const { EXPORTER_BUSINESS } = FIELD_IDS.INSURANCE;
Expand All @@ -12,7 +12,7 @@ describe('controllers/insurance/business/nature-of-business/map-submitted-data',
it('should return the formBody with the commas replaced', () => {
const mockBody = {
_csrf: '1234',
...mockExporterNatureOfBusiness,
...mockBusinessNatureOfBusiness,
} as RequestBody;

const response = mapSubmittedData(mockBody);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request, Response } from '../../../../../../types';
import { post } from '.';
import { FIELD_IDS, ROUTES } from '../../../../../constants';
import { mockReq, mockRes, mockApplication, mockExporterNatureOfBusiness } from '../../../../../test-mocks';
import { mockReq, mockRes, mockApplication, mockBusinessNatureOfBusiness } from '../../../../../test-mocks';
import mapAndSave from '../../map-and-save';

const {
Expand Down Expand Up @@ -34,7 +34,7 @@ describe('controllers/insurance/business/nature-of-business/save-and-back', () =
describe('when there are no validation errors', () => {
it('should redirect to all sections page', async () => {
req.body = {
...mockExporterNatureOfBusiness,
...mockBusinessNatureOfBusiness,
};

await post(req, res);
Expand All @@ -44,7 +44,7 @@ describe('controllers/insurance/business/nature-of-business/save-and-back', () =

it('should call mapAndSave.natureOfBusiness once', async () => {
req.body = {
...mockExporterNatureOfBusiness,
...mockBusinessNatureOfBusiness,
};

await post(req, res);
Expand Down
4 changes: 2 additions & 2 deletions src/ui/server/test-mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import mockApplications from './mock-applications';
import mockUrlOrigin from './mock-url-origin';
import mockPhoneNumbers from './mock-phone-numbers';
import mockSicCodes from './mock-sic-codes';
import mockExporterNatureOfBusiness from './mock-business-nature-of-business';
import mockBusinessNatureOfBusiness from './mock-business-nature-of-business';
import mockBusinessTurnover from './mock-business-turnover';
import mockBroker from './mock-broker';
import mockBuyer from './mock-buyer';
Expand Down Expand Up @@ -81,7 +81,7 @@ export {
mockCompany,
mockCurrencies,
mockDeclarations,
mockExporterNatureOfBusiness,
mockBusinessNatureOfBusiness,
mockBusinessTurnover,
mockInsuranceFeedback,
mockNext,
Expand Down
4 changes: 2 additions & 2 deletions src/ui/server/test-mocks/mock-business-nature-of-business.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Business } from '../../types';

const mockExporterNatureOfBusiness = {
const mockBusinessNatureOfBusiness = {
goodsOrServicesSupplied: 'ABC',
totalYearsExporting: '2,0',
totalEmployeesInternational: '1,000',
totalEmployeesUK: '4,00',
} as Business;

export default mockExporterNatureOfBusiness;
export default mockBusinessNatureOfBusiness;

0 comments on commit c9804ef

Please sign in to comment.