Skip to content

Commit

Permalink
fix(EMS-3530): no PDF - Pure number in text field (#2673)
Browse files Browse the repository at this point in the history
* fix(EMS-3530): fixed issue with text fields going to problem with service page

* fix(EMS-3530): lint fix

* fix(EMS-3530): lint fix and added to test.yml

---------

Co-authored-by: Zain Kassam <zkassam@ukexportfinance.gov.uk>
  • Loading branch information
Zainzzkk and Zain Kassam authored Jul 4, 2024
1 parent 74a046f commit adaea21
Show file tree
Hide file tree
Showing 10 changed files with 256 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ jobs:
"submit-name-fields-with-special-characters/**/*.spec.js",
"submit-textarea-fields-with-new-line-characters/**/*.spec.js",
"submit-textarea-fields-with-special-characters/**/*.spec.js",
"submit-textarea-fields-with-a-pure-number/**/*.spec.js",
"task-list/**/*.spec.js",
"your-business/alternative-trading-address/**/*.spec.js",
"your-business/change-your-answers/**/*.spec.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ const { REQUESTED_JOINTLY_INSURED_PARTY: FIXTURES } = application;
/**
* completeAndSubmitOtherCompanyDetailsForm
* Complete and submit the "Other company details" form
* @param {String} companyName: input for the COMPANY_NAME field
*/
const completeAndSubmitOtherCompanyDetailsForm = () => {
cy.keyboardInput(field(COMPANY_NAME).input(), FIXTURES[COMPANY_NAME]);
const completeAndSubmitOtherCompanyDetailsForm = ({ companyName = FIXTURES[COMPANY_NAME] }) => {
cy.keyboardInput(field(COMPANY_NAME).input(), companyName);
cy.keyboardInput(autoCompleteField(COUNTRY_CODE).input(), FIXTURES[COUNTRY_CODE]);
cy.keyboardInput(field(COMPANY_NUMBER).input(), FIXTURES[COMPANY_NUMBER]);

Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/commands/insurance/complete-policy-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const completePolicySection = ({
cy.completeAndSubmitAnotherCompanyForm({ otherCompanyInvolved });

if (otherCompanyInvolved) {
cy.completeAndSubmitOtherCompanyDetailsForm();
cy.completeAndSubmitOtherCompanyDetailsForm({});
}

cy.completeAndSubmitBrokerForm({ usingBroker });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ context(`Insurance - Policy - Other company details page - Changing ${REQUESTED}
beforeEach(() => {
cy.navigateToUrl(url);

cy.completeAndSubmitOtherCompanyDetailsForm();
cy.completeAndSubmitOtherCompanyDetailsForm({});

/**
* Go back to the "other company"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ context(`Insurance - Policy - Other company details page - ${story}`, () => {
it(`should redirect to ${BROKER_ROOT}`, () => {
cy.navigateToUrl(url);

cy.completeAndSubmitOtherCompanyDetailsForm();
cy.completeAndSubmitOtherCompanyDetailsForm({});

cy.assertUrl(brokerUrl);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ const { REQUESTED_JOINTLY_INSURED_PARTY: FIXTURES } = application;

const {
ROOT,
POLICY: {
OTHER_COMPANY_DETAILS,
},
POLICY: { OTHER_COMPANY_DETAILS },
} = INSURANCE_ROUTES;

const {
Expand Down Expand Up @@ -91,7 +89,7 @@ context('Insurance - Policy - Other company details page - Save and back', () =>
it('should redirect to `all sections` and retain the `insurance policy` task status as `in progress`', () => {
cy.navigateToUrl(url);

cy.completeAndSubmitOtherCompanyDetailsForm();
cy.completeAndSubmitOtherCompanyDetailsForm({});

cy.clickSaveAndBackButton();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
import { INSURANCE_ROUTES } from '../../../../../constants/routes/insurance';
import { INSURANCE_FIELD_IDS } from '../../../../../constants/field-ids/insurance';
import { field } from '../../../../../pages/shared';

const {
ROOT,
YOUR_BUYER: { CONNECTION_WITH_BUYER },
EXPORT_CONTRACT: { AGENT_SERVICE, HOW_WILL_YOU_GET_PAID },
POLICY: {
BROKER_DETAILS_ROOT, PRE_CREDIT_PERIOD, LOSS_PAYEE_DETAILS_ROOT, OTHER_COMPANY_DETAILS,
},
} = INSURANCE_ROUTES;

const {
EXPORT_CONTRACT: {
HOW_WILL_YOU_GET_PAID: { PAYMENT_TERMS_DESCRIPTION },
AGENT_SERVICE: { SERVICE_DESCRIPTION },
},
YOUR_BUYER: { CONNECTION_WITH_BUYER_DESCRIPTION },
POLICY: {
BROKER_DETAILS: { NAME: BROKER_NAME, FULL_ADDRESS },
CREDIT_PERIOD_WITH_BUYER,
REQUESTED_JOINTLY_INSURED_PARTY: { COMPANY_NAME },
FINANCIAL_ADDRESS,
},
} = INSURANCE_FIELD_IDS;

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

const numberString = '1';

context('Insurance - Textarea fields - Textarea fields should be able to submit after entering a pure number', () => {
let referenceNumber;
let connectionToTheBuyerUrl;
let agentServiceUrl;
let howWillYouGetPaidUrl;
let brokerDetailsUrl;
let preCreditPeriodUrl;
let lossPayeeDetailsUrl;
let otherCompanyUrl;

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

connectionToTheBuyerUrl = `${baseUrl}${ROOT}/${referenceNumber}${CONNECTION_WITH_BUYER}`;
agentServiceUrl = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_SERVICE}`;
howWillYouGetPaidUrl = `${baseUrl}${ROOT}/${referenceNumber}${HOW_WILL_YOU_GET_PAID}`;
brokerDetailsUrl = `${baseUrl}${ROOT}/${referenceNumber}${BROKER_DETAILS_ROOT}`;
preCreditPeriodUrl = `${baseUrl}${ROOT}/${referenceNumber}${PRE_CREDIT_PERIOD}`;
lossPayeeDetailsUrl = `${baseUrl}${ROOT}/${referenceNumber}${LOSS_PAYEE_DETAILS_ROOT}`;
otherCompanyUrl = `${baseUrl}${ROOT}/${referenceNumber}${OTHER_COMPANY_DETAILS}`;
});
});

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

describe(CONNECTION_WITH_BUYER_DESCRIPTION, () => {
describe('when submitting the textarea field with a pure number and going back to the page', () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(connectionToTheBuyerUrl);

cy.completeAndSubmitConnectionWithTheBuyerForm({
hasConnectionToBuyer: true,
description: numberString,
});

cy.clickBackLink();
});

it('should render the pure number exactly as it was submitted', () => {
cy.checkTextareaValue({
fieldId: CONNECTION_WITH_BUYER_DESCRIPTION,
expectedValue: numberString,
});
});
});
});

describe(SERVICE_DESCRIPTION, () => {
describe('when submitting the textarea field with a pure number and going back to the page', () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(agentServiceUrl);

cy.completeAndSubmitAgentServiceForm({
serviceDescription: numberString,
});

cy.clickBackLink();
});

it('should render the pure number exactly as it was submitted', () => {
cy.checkTextareaValue({
fieldId: SERVICE_DESCRIPTION,
expectedValue: numberString,
});
});
});
});

describe(PAYMENT_TERMS_DESCRIPTION, () => {
describe('when submitting the textarea field with a pure number and going back to the page', () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(howWillYouGetPaidUrl);

cy.completeAndSubmitHowYouWillGetPaidForm({ paymentTermsDescription: numberString });

cy.clickBackLink();
});

it('should render the pure number exactly as it was submitted', () => {
cy.checkTextareaValue({
fieldId: PAYMENT_TERMS_DESCRIPTION,
expectedValue: numberString,
});
});
});
});

describe(`${BROKER_NAME} and ${FULL_ADDRESS}`, () => {
describe('when submitting the textarea field with a pure number and going back to the page', () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(brokerDetailsUrl);

cy.completeAndSubmitBrokerDetailsForm({
name: numberString,
fullAddress: numberString,
});

cy.clickBackLink();
});

it('should render the pure number exactly as it was submitted', () => {
cy.checkValue(field(BROKER_NAME), numberString);

cy.checkTextareaValue({
fieldId: FULL_ADDRESS,
expectedValue: numberString,
});
});
});
});

describe(CREDIT_PERIOD_WITH_BUYER, () => {
describe('when submitting the textarea field with a pure number and going back to the page', () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(preCreditPeriodUrl);

cy.completeAndSubmitPreCreditPeriodForm({
needPreCreditPeriod: true,
description: numberString,
});

cy.clickBackLink();
});

it('should render the pure number exactly as it was submitted', () => {
cy.checkTextareaValue({
fieldId: CREDIT_PERIOD_WITH_BUYER,
expectedValue: numberString,
});
});
});
});

describe(FINANCIAL_ADDRESS, () => {
describe('when submitting the textarea field with a pure number and going back to the page', () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(lossPayeeDetailsUrl);

cy.completeAndSubmitLossPayeeDetailsForm({});
cy.completeAndSubmitLossPayeeFinancialDetailsUkForm({ financialAddress: numberString });

cy.clickBackLink();
});

it('should render the pure number exactly as it was submitted', () => {
cy.checkTextareaValue({
fieldId: FINANCIAL_ADDRESS,
expectedValue: numberString,
});
});
});
});

describe(COMPANY_NAME, () => {
describe('when submitting the textarea field with a pure number and going back to the page', () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(otherCompanyUrl);

cy.completeAndSubmitOtherCompanyDetailsForm({ companyName: numberString });

cy.clickBackLink();
});

it('should render the pure number exactly as it was submitted', () => {
cy.checkValue(field(COMPANY_NAME), numberString);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import mapApplicationSubmissionDeadlineVariables from '../../map-application-submission-deadline-variables';
import sendEmail from '../../../emails';
import { Application, EmailResponse } from '../../../types';
import { Application } from '../../../types';

/**
* send
Expand All @@ -17,7 +17,7 @@ const send = async (applications: Array<Application>) => {
const variables = mapApplicationSubmissionDeadlineVariables(application);

return sendEmail.submissionDeadlineEmail(variables.email, variables);
}) as Array<Promise<EmailResponse>>;
});

const promises = await Promise.all(mapped);

Expand Down
15 changes: 14 additions & 1 deletion src/ui/server/helpers/sanitise-data/sanitise-value/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ const {
EXPORT_CONTRACT: {
ABOUT_GOODS_OR_SERVICES: { DESCRIPTION },
AGENT_CHARGES: { FIXED_SUM_AMOUNT, PERCENTAGE_CHARGE },
HOW_WILL_YOU_GET_PAID: { PAYMENT_TERMS_DESCRIPTION },
AGENT_SERVICE: { SERVICE_DESCRIPTION },
},
POLICY: {
BROKER_DETAILS: { NAME: BROKER_NAME },
BROKER_DETAILS: { NAME: BROKER_NAME, FULL_ADDRESS },
LOSS_PAYEE_FINANCIAL_UK: { ACCOUNT_NUMBER, SORT_CODE },
LOSS_PAYEE_FINANCIAL_INTERNATIONAL: { IBAN, BIC_SWIFT_CODE },
CREDIT_PERIOD_WITH_BUYER,
REQUESTED_JOINTLY_INSURED_PARTY: { COMPANY_NAME },
FINANCIAL_ADDRESS,
},
YOUR_BUYER: {
COMPANY_OR_ORGANISATION: { NAME, REGISTRATION_NUMBER, ADDRESS, WEBSITE },
CONNECTION_WITH_BUYER_DESCRIPTION,
},
} = INSURANCE_FIELD_IDS;

Expand All @@ -47,6 +53,13 @@ describe('server/helpers/sanitise-data/sanitise-value', () => {
PERCENTAGE_TURNOVER,
FIXED_SUM_AMOUNT,
PERCENTAGE_CHARGE,
CONNECTION_WITH_BUYER_DESCRIPTION,
CREDIT_PERIOD_WITH_BUYER,
COMPANY_NAME,
FULL_ADDRESS,
FINANCIAL_ADDRESS,
PAYMENT_TERMS_DESCRIPTION,
SERVICE_DESCRIPTION,
];

expect(STRING_NUMBER_FIELDS).toEqual(expected);
Expand Down
15 changes: 14 additions & 1 deletion src/ui/server/helpers/sanitise-data/sanitise-value/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ const {
EXPORT_CONTRACT: {
ABOUT_GOODS_OR_SERVICES: { DESCRIPTION },
AGENT_CHARGES: { FIXED_SUM_AMOUNT, PERCENTAGE_CHARGE },
HOW_WILL_YOU_GET_PAID: { PAYMENT_TERMS_DESCRIPTION },
AGENT_SERVICE: { SERVICE_DESCRIPTION },
},
POLICY: {
BROKER_DETAILS: { NAME: BROKER_NAME },
BROKER_DETAILS: { NAME: BROKER_NAME, FULL_ADDRESS },
LOSS_PAYEE_FINANCIAL_UK: { ACCOUNT_NUMBER, SORT_CODE },
LOSS_PAYEE_FINANCIAL_INTERNATIONAL: { IBAN, BIC_SWIFT_CODE },
CREDIT_PERIOD_WITH_BUYER,
REQUESTED_JOINTLY_INSURED_PARTY: { COMPANY_NAME },
FINANCIAL_ADDRESS,
},
YOUR_BUYER: {
COMPANY_OR_ORGANISATION: { NAME, REGISTRATION_NUMBER, ADDRESS, WEBSITE },
CONNECTION_WITH_BUYER_DESCRIPTION,
},
} = INSURANCE_FIELD_IDS;

Expand Down Expand Up @@ -55,6 +61,13 @@ export const STRING_NUMBER_FIELDS = [
PERCENTAGE_TURNOVER,
FIXED_SUM_AMOUNT,
PERCENTAGE_CHARGE,
CONNECTION_WITH_BUYER_DESCRIPTION,
CREDIT_PERIOD_WITH_BUYER,
COMPANY_NAME,
FULL_ADDRESS,
FINANCIAL_ADDRESS,
PAYMENT_TERMS_DESCRIPTION,
SERVICE_DESCRIPTION,
];

/**
Expand Down

0 comments on commit adaea21

Please sign in to comment.