Skip to content

Commit

Permalink
feat(EMS-3548): no pdf - post data migration - company data (#2680)
Browse files Browse the repository at this point in the history
* feat(EMS-3548): no pdf - post data migration - conditional companies house number

* feat(EMS-3548): add missing documentation

* feat(EMS-3548): api unit test coverage

* feat(EMS-3548): improve e2e test coverage

* feat(EMS-3548): fix typos

* feat(EMS-3548): update test.yml
  • Loading branch information
ttbarnes authored Jul 4, 2024
1 parent 56b4c1e commit 74a046f
Show file tree
Hide file tree
Showing 35 changed files with 1,260 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ jobs:
"your-business/alternative-trading-address/**/*.spec.js",
"your-business/change-your-answers/**/*.spec.js",
"your-business/check-your-answers/**/*.spec.js",
"your-business/companies-house-number/*.spec.js",
"your-business/company-details/**/*.spec.js",
"your-business/credit-control/**/*.spec.js",
"your-business/nature-of-business/**/*.spec.js",
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/constants/routes/insurance/business.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const EXPORTER_BUSINESS = {
COMPANY_DETAILS_CHANGE: `${COMPANY_DETAILS_ROOT}/change`,
COMPANY_DETAILS_CHECK_AND_CHANGE: `${COMPANY_DETAILS_ROOT}/check-and-change`,
COMPANY_DETAILS_SAVE_AND_BACK: `${COMPANY_DETAILS_ROOT}/save-and-back`,
ENTER_COMPANIES_HOUSE_NUMBER: `${ROOT}/enter-companies-house-number`,
ALTERNATIVE_TRADING_ADDRESS_ROOT,
ALTERNATIVE_TRADING_ADDRESS_CHANGE: `${ALTERNATIVE_TRADING_ADDRESS_ROOT}/change`,
ALTERNATIVE_TRADING_ADDRESS_CHECK_AND_CHANGE: `${ALTERNATIVE_TRADING_ADDRESS_ROOT}/check-and-change`,
Expand Down
8 changes: 2 additions & 6 deletions e2e-tests/content-strings/pages/insurance/business/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@ export const ROOT = {
INTRO: 'In this section, we want to understand more about your business and the types of products or services you export.',
LIST: {
INTRO: "We'll ask you to tell us:",
ITEMS: [
'what your estimated annual turnover is for this year',
'if you have any credit management processes',
],
ITEMS: ['what your estimated annual turnover is for this year', 'if you have any credit management processes'],
},
OUTRO: 'It should only take a few minutes to complete.',
};

export const COMPANIES_HOUSE_NUMBER = {
export const ENTER_COMPANIES_HOUSE_NUMBER = {
...SHARED,
PAGE_TITLE: 'Enter your Companies House registration number (CRN)',
NO_COMPANIES_HOUSE_NUMBER: 'I do not have a UK Companies House registration number',
};

export const COMPANY_DETAILS = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import partials from '../../../../../../partials';
import { field as fieldSelector } from '../../../../../../pages/shared';
import { PAGES } from '../../../../../../content-strings';
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';
import { INSURANCE_FIELD_IDS } from '../../../../../../constants/field-ids/insurance';

const {
ROOT,
EXPORTER_BUSINESS: { ENTER_COMPANIES_HOUSE_NUMBER },
} = INSURANCE_ROUTES;

const CONTENT_STRINGS = PAGES.INSURANCE.EXPORTER_BUSINESS.ENTER_COMPANIES_HOUSE_NUMBER;

const {
ELIGIBILITY: { COMPANIES_HOUSE_NUMBER: FIELD_ID },
} = INSURANCE_FIELD_IDS;

const field = fieldSelector(FIELD_ID);

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

context(
'Insurance - Your business - Enter Companies House number - As an Exporter, I want to enter my Companies House number, So that I can apply for credit insurance with UKEF',
() => {
let referenceNumber;
let url;

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

cy.startYourBusinessSection({});

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

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}${ENTER_COMPANIES_HOUSE_NUMBER}`,
backLink: `${ROOT}/${referenceNumber}${ENTER_COMPANIES_HOUSE_NUMBER}#`,
});
});

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

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

it(`should render a ${FIELD_ID} input`, () => {
field.input().should('exist');
});
});
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
import { field as fieldSelector } from '../../../../../../pages/shared';
import { ERROR_MESSAGES } from '../../../../../../content-strings';
import {
COMPANIES_HOUSE_NUMBER as VALID_COMPANIES_HOUSE_NUMBER,
COMPANIES_HOUSE_NUMBER_NO_LEADING_ZERO,
COMPANIES_HOUSE_NUMBER_EMPTY,
COMPANIES_HOUSE_NUMBER_TOO_SHORT,
COMPANIES_HOUSE_NUMBER_WITH_SPECIAL_CHARACTERS,
COMPANIES_HOUSE_NUMBER_WITH_SPACES,
COMPANIES_HOUSE_NUMBER_NO_FINANCIAL_YEAR_END_DATE,
COMPANIES_HOUSE_NUMBER_NOT_FOUND,
} from '../../../../../../constants';
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';
import { INSURANCE_FIELD_IDS } from '../../../../../../constants/field-ids/insurance';

const {
ROOT,
EXPORTER_BUSINESS: { ENTER_COMPANIES_HOUSE_NUMBER, COMPANY_DETAILS },
} = INSURANCE_ROUTES;

const COMPANIES_HOUSE_ERRORS = ERROR_MESSAGES.INSURANCE.ELIGIBILITY;

const {
ELIGIBILITY: { COMPANIES_HOUSE_NUMBER: FIELD_ID },
} = INSURANCE_FIELD_IDS;

const field = fieldSelector(FIELD_ID);

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

context(
'Insurance - Your business - Enter Companies House number - As an Exporter, I want to enter my Companies House number, So that I can apply for credit insurance with UKEF',
() => {
let referenceNumber;
let url;
let companyNumber;

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

cy.startYourBusinessSection({});

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

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

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

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

describe('form submission', () => {
describe('when submitting an empty form', () => {
beforeEach(() => {
cy.navigateToUrl(url);
});

it('should display the `is empty` error', () => {
cy.submitAndAssertFieldErrors({
field,
value: companyNumber,
expectedErrorMessage: COMPANIES_HOUSE_ERRORS[FIELD_ID].IS_EMPTY,
});
});
});

describe('when the companies house number is blank', () => {
beforeEach(() => {
cy.navigateToUrl(url);

companyNumber = COMPANIES_HOUSE_NUMBER_EMPTY;
});

it('should display the `is empty` error', () => {
cy.submitAndAssertFieldErrors({
field,
value: companyNumber,
expectedErrorMessage: COMPANIES_HOUSE_ERRORS[FIELD_ID].IS_EMPTY,
});
});
});

describe('when the companies house number is too short', () => {
beforeEach(() => {
cy.navigateToUrl(url);

companyNumber = COMPANIES_HOUSE_NUMBER_TOO_SHORT;
});

it('should display the `incorrect format` error', () => {
cy.submitAndAssertFieldErrors({
field,
value: companyNumber,
expectedErrorMessage: COMPANIES_HOUSE_ERRORS[FIELD_ID].INCORRECT_FORMAT,
});
});
});

describe('when the companies house number has special characters', () => {
beforeEach(() => {
cy.navigateToUrl(url);

companyNumber = COMPANIES_HOUSE_NUMBER_WITH_SPECIAL_CHARACTERS;

cy.interceptCompaniesHousePost({ companyNumber });
});

it('should display the `incorrect format` error', () => {
cy.submitAndAssertFieldErrors({
field,
value: companyNumber,
expectedErrorMessage: COMPANIES_HOUSE_ERRORS[FIELD_ID].INCORRECT_FORMAT,
});
});
});

describe('when the companies house number is not found', () => {
beforeEach(() => {
cy.navigateToUrl(url);

companyNumber = COMPANIES_HOUSE_NUMBER_NOT_FOUND;

cy.interceptCompaniesHousePost({ companyNumber });
});

it('should display the `not found` error', () => {
cy.submitAndAssertFieldErrors({
field,
value: companyNumber,
expectedErrorMessage: COMPANIES_HOUSE_ERRORS[FIELD_ID].NOT_FOUND,
});
});
});

describe('when submitting the answer as a valid companies house number', () => {
beforeEach(() => {
cy.navigateToUrl(url);

cy.interceptCompaniesHousePost({ companyNumber });

cy.keyboardInput(field.input(), VALID_COMPANIES_HOUSE_NUMBER);

cy.clickSubmitButton();
});

it(`should redirect to ${COMPANY_DETAILS}`, () => {
const expected = `${baseUrl}${ROOT}/${referenceNumber}${COMPANY_DETAILS}`;

cy.assertUrl(expected);
});
});

describe('when submitting the answer as a valid companies house number, with no leading zero', () => {
beforeEach(() => {
cy.navigateToUrl(url);

cy.interceptCompaniesHousePost({ companyNumber: COMPANIES_HOUSE_NUMBER_NO_LEADING_ZERO });

cy.keyboardInput(field.input(), COMPANIES_HOUSE_NUMBER_NO_LEADING_ZERO);

cy.clickSubmitButton();
});

it(`should redirect to ${COMPANY_DETAILS}`, () => {
const expected = `${baseUrl}${ROOT}/${referenceNumber}${COMPANY_DETAILS}`;

cy.assertUrl(expected);
});
});

describe('when submitting the answer as a valid companies house number, with white spaces', () => {
beforeEach(() => {
cy.navigateToUrl(url);

cy.interceptCompaniesHousePost({ companyNumber: COMPANIES_HOUSE_NUMBER_WITH_SPACES });

cy.keyboardInput(field.input(), COMPANIES_HOUSE_NUMBER_WITH_SPACES);

cy.clickSubmitButton();
});

it(`should redirect to ${COMPANY_DETAILS}`, () => {
const expected = `${baseUrl}${ROOT}/${referenceNumber}${COMPANY_DETAILS}`;

cy.assertUrl(expected);
});
});

describe('when submitting the answer as a valid companies house number, in lowercase', () => {
const lowerCaseCompaniesHouseNumber = COMPANIES_HOUSE_NUMBER_NO_FINANCIAL_YEAR_END_DATE.toLowerCase();

beforeEach(() => {
cy.navigateToUrl(url);

cy.interceptCompaniesHousePost({ companyNumber: lowerCaseCompaniesHouseNumber });

cy.keyboardInput(field.input(), lowerCaseCompaniesHouseNumber);

cy.clickSubmitButton();
});

it(`should redirect to ${COMPANY_DETAILS}`, () => {
const expected = `${baseUrl}${ROOT}/${referenceNumber}${COMPANY_DETAILS}`;

cy.assertUrl(expected);
});
});
});
},
);
41 changes: 41 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.

Loading

0 comments on commit 74a046f

Please sign in to comment.