diff --git a/e2e-tests/commands/insurance/assert-companies-house-summary-list.js b/e2e-tests/commands/insurance/assert-companies-house-summary-list.js index 375e29551d..27d228b6c5 100644 --- a/e2e-tests/commands/insurance/assert-companies-house-summary-list.js +++ b/e2e-tests/commands/insurance/assert-companies-house-summary-list.js @@ -1,6 +1,6 @@ import { format } from 'date-fns'; import { summaryList } from '../../pages/shared'; -import { COMPANIES_HOUSE_NUMBER, DATE_FORMAT } from '../../constants'; +import { COMPANIES_HOUSE_NUMBER, COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME, DATE_FORMAT } from '../../constants'; import { INSURANCE_FIELD_IDS } from '../../constants/field-ids/insurance'; import { FIELDS } from '../../content-strings'; import mockCompanies from '../../fixtures/companies'; @@ -23,10 +23,14 @@ const assertCompaniesHouseSummaryList = { cy.checkText(summaryList.field(COMPANY_NUMBER).value(), mockCompany[COMPANY_NUMBER]); }, - name: () => { + name: ({ differentCompanyWithSpecialCharacters = false }) => { cy.checkText(summaryList.field(COMPANY_NAME).key(), FIELDS[COMPANY_NAME].SUMMARY.TITLE); - cy.checkText(summaryList.field(COMPANY_NAME).value(), mockCompany[COMPANY_NAME]); + if (differentCompanyWithSpecialCharacters) { + cy.checkText(summaryList.field(COMPANY_NAME).value(), mockCompanies[COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME][COMPANY_NAME]); + } else { + cy.checkText(summaryList.field(COMPANY_NAME).value(), mockCompany[COMPANY_NAME]); + } }, address: () => { cy.checkText(summaryList.field(COMPANY_ADDRESS).key(), FIELDS[COMPANY_ADDRESS].SUMMARY.TITLE); diff --git a/e2e-tests/commands/insurance/check-your-answers-eligibility-summary-list.js b/e2e-tests/commands/insurance/check-your-answers-eligibility-summary-list.js index 0828c49af6..b010d313a4 100644 --- a/e2e-tests/commands/insurance/check-your-answers-eligibility-summary-list.js +++ b/e2e-tests/commands/insurance/check-your-answers-eligibility-summary-list.js @@ -1,8 +1,9 @@ -import { FIELD_IDS, FIELD_VALUES } from '../../constants'; +import { FIELD_IDS, FIELD_VALUES, COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME } from '../../constants'; import { summaryList } from '../../pages/shared'; import { FIELDS_ELIGIBILITY as FIELDS } from '../../content-strings/fields/insurance/eligibility'; import application, { country } from '../../fixtures/application'; import getSummaryListField from './get-summary-list-field'; +import mockCompanies from '../../fixtures/companies'; const { COMPANY } = application; @@ -19,7 +20,7 @@ const { const { COMPANY_NAME } = FIELD_IDS.INSURANCE.COMPANIES_HOUSE; -const checkYourAnswersEligibilitySummaryList = ({ +const checkYourAnswersEligibilitySummaryList = { [BUYER_COUNTRY]: () => { const fieldId = BUYER_COUNTRY; @@ -68,19 +69,28 @@ const checkYourAnswersEligibilitySummaryList = ({ cy.assertSummaryListRow(summaryList, fieldId, expectedKey, expectedValue, expectedChangeLinkText); }, - [COMPANY_NAME]: () => { + [COMPANY_NAME]: ({ differentCompanyWithSpecialCharacters = false }) => { const fieldId = COMPANY_NAME; const { expectedKey } = getSummaryListField(fieldId, FIELDS); - const expectedValue = COMPANY[COMPANY_NAME]; + + let expectedValue = COMPANY[COMPANY_NAME]; + + if (differentCompanyWithSpecialCharacters) { + expectedValue = mockCompanies[COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME][COMPANY_NAME]; + } cy.assertSummaryListRow(summaryList, fieldId, expectedKey, expectedValue); }, - [COMPANIES_HOUSE_NUMBER]: () => { + [COMPANIES_HOUSE_NUMBER]: ({ differentCompanyWithSpecialCharacters = false }) => { const fieldId = COMPANIES_HOUSE_NUMBER; const { expectedKey, expectedChangeLinkText } = getSummaryListField(fieldId, FIELDS); - const expectedValue = COMPANY[COMPANIES_HOUSE_NUMBER]; + let expectedValue = COMPANY[COMPANIES_HOUSE_NUMBER]; + + if (differentCompanyWithSpecialCharacters) { + expectedValue = mockCompanies[COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME][COMPANIES_HOUSE_NUMBER]; + } cy.assertSummaryListRow(summaryList, fieldId, expectedKey, expectedValue, expectedChangeLinkText); }, @@ -92,6 +102,6 @@ const checkYourAnswersEligibilitySummaryList = ({ cy.assertSummaryListRow(summaryList, fieldId, expectedKey, expectedValue, expectedChangeLinkText); }, -}); +}; export default checkYourAnswersEligibilitySummaryList; diff --git a/e2e-tests/commands/insurance/complete-and-submit-all-insurance-eligibility-answers.js b/e2e-tests/commands/insurance/complete-and-submit-all-insurance-eligibility-answers.js index 1bfc685c40..693bbae5a3 100644 --- a/e2e-tests/commands/insurance/complete-and-submit-all-insurance-eligibility-answers.js +++ b/e2e-tests/commands/insurance/complete-and-submit-all-insurance-eligibility-answers.js @@ -1,15 +1,17 @@ import completeAndSubmitBuyerCountryForm from '../forms'; +import { COMPANIES_HOUSE_NUMBER } from '../../constants/examples'; /** * completeAndSubmitAllInsuranceEligibilityAnswers * completes and submits insurance eligibility answers until the check your answers page + * @param {String} companyNumber: companies house number - defaults to COMPANIES_HOUSE_NUMBER */ -const completeAndSubmitAllInsuranceEligibilityAnswers = () => { +const completeAndSubmitAllInsuranceEligibilityAnswers = ({ companyNumber = COMPANIES_HOUSE_NUMBER }) => { cy.completeStartForm(); cy.completeCheckIfEligibleForm(); cy.completeExporterLocationForm(); cy.completeCompaniesHouseNumberForm(); - cy.completeAndSubmitCompaniesHouseSearchForm({}); + cy.completeAndSubmitCompaniesHouseSearchForm({ companyNumber }); cy.completeEligibilityCompanyDetailsForm(); completeAndSubmitBuyerCountryForm({}); cy.completeAndSubmitTotalValueInsuredForm({}); diff --git a/e2e-tests/constants/examples/companies-house-number-examples.js b/e2e-tests/constants/examples/companies-house-number-examples.js index ad9febbf23..32c9fac2d9 100644 --- a/e2e-tests/constants/examples/companies-house-number-examples.js +++ b/e2e-tests/constants/examples/companies-house-number-examples.js @@ -1,4 +1,5 @@ export const COMPANIES_HOUSE_NUMBER = '08989898'; +export const COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME = '00947741'; export const COMPANIES_HOUSE_NUMBER_NO_LEADING_ZERO = '8989898'; export const COMPANIES_HOUSE_NUMBER_WITH_SPACES = ' 08989898 '; export const COMPANIES_HOUSE_NUMBER_MULTIPLE_SIC_CODES = '01003142'; diff --git a/e2e-tests/fixtures/companies.js b/e2e-tests/fixtures/companies.js index 6491eb8d2e..fdc4ce7268 100644 --- a/e2e-tests/fixtures/companies.js +++ b/e2e-tests/fixtures/companies.js @@ -1,5 +1,6 @@ import { COMPANIES_HOUSE_NUMBER, + COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME, COMPANIES_HOUSE_NUMBER_NO_SIC_CODE, COMPANIES_HOUSE_NUMBER_MULTIPLE_SIC_CODES, COMPANIES_HOUSE_NUMBER_NO_FINANCIAL_YEAR_END_DATE, @@ -38,12 +39,18 @@ const baseCompany = { [FINANCIAL_YEAR_END_DATE]: '2023-07-31T00:00:00.000Z', }; +const companyNameSpecialCharacter = { + [COMPANY_NUMBER]: COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME, + [COMPANY_NAME]: 'STEVENS, FOX & CO. LIMITED', +}; + const mockCompanies = { [COMPANIES_HOUSE_NUMBER]: { ...baseCompany, companyNumber: COMPANIES_HOUSE_NUMBER, [FINANCIAL_YEAR_END_DATE]: baseCompany[FINANCIAL_YEAR_END_DATE], }, + [COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME]: companyNameSpecialCharacter, [COMPANIES_HOUSE_NUMBER_NO_SIC_CODE]: { ...baseCompany, companyNumber: COMPANIES_HOUSE_NUMBER_NO_SIC_CODE, @@ -54,12 +61,7 @@ const mockCompanies = { ...baseCompany, companyNumber: COMPANIES_HOUSE_NUMBER_MULTIPLE_SIC_CODES, [FINANCIAL_YEAR_END_DATE]: baseCompany[FINANCIAL_YEAR_END_DATE], - sicCodes: [ - mockSicCodes[1].code, - mockSicCodes[2].code, - mockSicCodes[3].code, - mockSicCodes[4].code, - ], + sicCodes: [mockSicCodes[1].code, mockSicCodes[2].code, mockSicCodes[3].code, mockSicCodes[4].code], industrySectorNames: [ mockSicCodes[1][INDUSTRY_SECTOR_NAME], mockSicCodes[2][INDUSTRY_SECTOR_NAME], diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-buyer-country.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-buyer-country.spec.js index 68692132db..6fa7ae6b8d 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-buyer-country.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-buyer-country.spec.js @@ -16,66 +16,69 @@ const oldCountry = country.NAME; const newCountry = XAD.NAME; const baseUrl = Cypress.config('baseUrl'); -context('Insurance - Eligibility - Change your answers - Buyer country - As an exporter, I want to change my answers to the eligibility buyer country section', () => { - const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; +context( + 'Insurance - Eligibility - Change your answers - Buyer country - As an exporter, I want to change my answers to the eligibility buyer country section', + () => { + const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; - before(() => { - cy.navigateToUrl(START); + before(() => { + cy.navigateToUrl(START); - cy.completeAndSubmitAllInsuranceEligibilityAnswers(); + cy.completeAndSubmitAllInsuranceEligibilityAnswers({}); - cy.assertUrl(url); - }); + cy.assertUrl(url); + }); - beforeEach(() => { - cy.saveSession(); - }); + beforeEach(() => { + cy.saveSession(); + }); - const fieldId = BUYER_COUNTRY; + const fieldId = BUYER_COUNTRY; - describe('when clicking the `change` link', () => { - it(`should redirect to ${BUYER_COUNTRY_CHANGE}`, () => { - cy.navigateToUrl(url); + describe('when clicking the `change` link', () => { + it(`should redirect to ${BUYER_COUNTRY_CHANGE}`, () => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.assertChangeAnswersPageUrl({ route: BUYER_COUNTRY_CHANGE, fieldId, isInsuranceEligibility: true }); + cy.assertChangeAnswersPageUrl({ route: BUYER_COUNTRY_CHANGE, fieldId, isInsuranceEligibility: true }); + }); }); - }); - describe('form submission without changing the answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission without changing the answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.clickSubmitButton(); - }); + cy.clickSubmitButton(); + }); - it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { - cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); - }); + it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { + cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + }); - it('should render the same answer', () => { - cy.assertSummaryListRowValue(summaryList, fieldId, oldCountry); + it('should render the same answer', () => { + cy.assertSummaryListRowValue(summaryList, fieldId, oldCountry); + }); }); - }); - describe('form submission with a new answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission with a new answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - completeAndSubmitBuyerCountryForm({ countryName: newCountry }); - }); + completeAndSubmitBuyerCountryForm({ countryName: newCountry }); + }); - it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { - cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); - }); + it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { + cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + }); - it('should render the new answer', () => { - cy.assertSummaryListRowValue(summaryList, fieldId, newCountry); + it('should render the new answer', () => { + cy.assertSummaryListRowValue(summaryList, fieldId, newCountry); + }); }); - }); -}); + }, +); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-companies-house-search.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-companies-house-search.spec.js index bbc9194f7b..3ec95de471 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-companies-house-search.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-companies-house-search.spec.js @@ -18,82 +18,85 @@ const newCompanyNumber = COMPANIES_HOUSE_NUMBER_NO_FINANCIAL_YEAR_END_DATE; const newCompanyName = mockCompanies[COMPANIES_HOUSE_NUMBER_NO_FINANCIAL_YEAR_END_DATE][COMPANY_NAME]; const baseUrl = Cypress.config('baseUrl'); -context('Insurance - Eligibility - Change your answers - Companies house search - As an exporter, I want to change my answers to the eligibility Companies house search section', () => { - const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; +context( + 'Insurance - Eligibility - Change your answers - Companies house search - As an exporter, I want to change my answers to the eligibility Companies house search section', + () => { + const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; - before(() => { - cy.navigateToUrl(START); + before(() => { + cy.navigateToUrl(START); - cy.completeAndSubmitAllInsuranceEligibilityAnswers(); + cy.completeAndSubmitAllInsuranceEligibilityAnswers({}); - cy.assertUrl(url); - }); + cy.assertUrl(url); + }); - beforeEach(() => { - cy.saveSession(); - }); + beforeEach(() => { + cy.saveSession(); + }); - const fieldId = COMPANIES_HOUSE_NUMBER_FIELD_ID; + const fieldId = COMPANIES_HOUSE_NUMBER_FIELD_ID; - describe('when clicking the `change` link', () => { - it(`should redirect to ${ENTER_COMPANIES_HOUSE_NUMBER_CHANGE}`, () => { - cy.navigateToUrl(url); + describe('when clicking the `change` link', () => { + it(`should redirect to ${ENTER_COMPANIES_HOUSE_NUMBER_CHANGE}`, () => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.assertChangeAnswersPageUrl({ route: ENTER_COMPANIES_HOUSE_NUMBER_CHANGE, fieldId, isInsuranceEligibility: true }); + cy.assertChangeAnswersPageUrl({ route: ENTER_COMPANIES_HOUSE_NUMBER_CHANGE, fieldId, isInsuranceEligibility: true }); + }); }); - }); - describe('form submission without changing the answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission without changing the answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.clickSubmitButton(); - }); + cy.clickSubmitButton(); + }); - it(`should redirect to ${COMPANY_DETAILS_CHANGE}`, () => { - cy.assertChangeAnswersPageUrl({ route: COMPANY_DETAILS_CHANGE, fieldId, isInsuranceEligibility: true }); - }); + it(`should redirect to ${COMPANY_DETAILS_CHANGE}`, () => { + cy.assertChangeAnswersPageUrl({ route: COMPANY_DETAILS_CHANGE, fieldId, isInsuranceEligibility: true }); + }); - it(`should redirect to ${CHECK_YOUR_ANSWERS} when company details continue button pressed`, () => { - cy.submitAndAssertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); - }); + it(`should redirect to ${CHECK_YOUR_ANSWERS} when company details continue button pressed`, () => { + cy.submitAndAssertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + }); - it(`should render the original answer for ${COMPANIES_HOUSE_NUMBER_FIELD_ID}`, () => { - cy.submitAndAssertSummaryListRowValue(summaryList, fieldId, oldCompanyNumber); - }); + it(`should render the original answer for ${COMPANIES_HOUSE_NUMBER_FIELD_ID}`, () => { + cy.submitAndAssertSummaryListRowValue(summaryList, fieldId, oldCompanyNumber); + }); - it(`should render the original answer for ${COMPANY_NAME}`, () => { - cy.submitAndAssertSummaryListRowValue(summaryList, COMPANY_NAME, oldCompanyName); + it(`should render the original answer for ${COMPANY_NAME}`, () => { + cy.submitAndAssertSummaryListRowValue(summaryList, COMPANY_NAME, oldCompanyName); + }); }); - }); - describe('form submission with a new answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission with a new answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.completeAndSubmitCompaniesHouseSearchForm({ companyNumber: newCompanyNumber }); - }); + cy.completeAndSubmitCompaniesHouseSearchForm({ companyNumber: newCompanyNumber }); + }); - it(`should redirect to ${COMPANY_DETAILS_CHANGE}`, () => { - cy.assertChangeAnswersPageUrl({ route: COMPANY_DETAILS_CHANGE, fieldId, isInsuranceEligibility: true }); - }); + it(`should redirect to ${COMPANY_DETAILS_CHANGE}`, () => { + cy.assertChangeAnswersPageUrl({ route: COMPANY_DETAILS_CHANGE, fieldId, isInsuranceEligibility: true }); + }); - it(`should redirect to ${CHECK_YOUR_ANSWERS} when company details continue button pressed`, () => { - cy.submitAndAssertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); - }); + it(`should redirect to ${CHECK_YOUR_ANSWERS} when company details continue button pressed`, () => { + cy.submitAndAssertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + }); - it(`should render the new answer for ${COMPANIES_HOUSE_NUMBER_FIELD_ID}`, () => { - cy.submitAndAssertSummaryListRowValue(summaryList, fieldId, newCompanyNumber); - }); + it(`should render the new answer for ${COMPANIES_HOUSE_NUMBER_FIELD_ID}`, () => { + cy.submitAndAssertSummaryListRowValue(summaryList, fieldId, newCompanyNumber); + }); - it(`should render the new answer for ${COMPANY_NAME}`, () => { - cy.submitAndAssertSummaryListRowValue(summaryList, COMPANY_NAME, newCompanyName); + it(`should render the new answer for ${COMPANY_NAME}`, () => { + cy.submitAndAssertSummaryListRowValue(summaryList, COMPANY_NAME, newCompanyName); + }); }); - }); -}); + }, +); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-cover-period.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-cover-period.spec.js index dfadb7476a..7fb848f9ac 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-cover-period.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-cover-period.spec.js @@ -11,58 +11,61 @@ const { const baseUrl = Cypress.config('baseUrl'); -context('Insurance - Eligibility - Change your answers - Cover period - As an exporter, I want to change my answers to the eligibility cover period section', () => { - const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; +context( + 'Insurance - Eligibility - Change your answers - Cover period - As an exporter, I want to change my answers to the eligibility cover period section', + () => { + const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; - before(() => { - cy.navigateToUrl(START); + before(() => { + cy.navigateToUrl(START); - cy.completeAndSubmitAllInsuranceEligibilityAnswers(); + cy.completeAndSubmitAllInsuranceEligibilityAnswers({}); - cy.assertUrl(url); - }); + cy.assertUrl(url); + }); - beforeEach(() => { - cy.saveSession(); - }); + beforeEach(() => { + cy.saveSession(); + }); - const fieldId = COVER_PERIOD; + const fieldId = COVER_PERIOD; - describe('when clicking the `change` link', () => { - it(`should redirect to ${COVER_PERIOD_CHANGE}`, () => { - cy.navigateToUrl(url); + describe('when clicking the `change` link', () => { + it(`should redirect to ${COVER_PERIOD_CHANGE}`, () => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.assertChangeAnswersPageUrl({ route: COVER_PERIOD_CHANGE, fieldId, isInsuranceEligibility: true }); + cy.assertChangeAnswersPageUrl({ route: COVER_PERIOD_CHANGE, fieldId, isInsuranceEligibility: true }); + }); }); - }); - describe('form submission without changing the answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission without changing the answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.clickSubmitButton(); - }); + cy.clickSubmitButton(); + }); - it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { - cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { + cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + }); }); - }); - describe('form submission with a new answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission with a new answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.completeCoverPeriodForm({ underThreshold: false }); - }); + cy.completeCoverPeriodForm({ underThreshold: false }); + }); - it(`should redirect to ${LONG_TERM_COVER}`, () => { - cy.assertChangeAnswersPageUrl({ route: LONG_TERM_COVER, fieldId, isInsuranceEligibility: true }); + it(`should redirect to ${LONG_TERM_COVER}`, () => { + cy.assertChangeAnswersPageUrl({ route: LONG_TERM_COVER, fieldId, isInsuranceEligibility: true }); + }); }); - }); -}); + }, +); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-end-buyer.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-end-buyer.spec.js index 47ee6223cc..0494807b4e 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-end-buyer.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-end-buyer.spec.js @@ -17,7 +17,7 @@ context('Insurance - Eligibility - Change your answers - End buyer - As an expor before(() => { cy.navigateToUrl(START); - cy.completeAndSubmitAllInsuranceEligibilityAnswers(); + cy.completeAndSubmitAllInsuranceEligibilityAnswers({}); cy.assertUrl(url); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-exporter-location.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-exporter-location.spec.js index 9302906d71..f1e3d08c9a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-exporter-location.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-exporter-location.spec.js @@ -11,59 +11,62 @@ const { const baseUrl = Cypress.config('baseUrl'); -context('Insurance - Eligibility - Change your answers - Exporter location - As an exporter, I want to change my answers to the eligibility exporter location section', () => { - const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; +context( + 'Insurance - Eligibility - Change your answers - Exporter location - As an exporter, I want to change my answers to the eligibility exporter location section', + () => { + const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; - before(() => { - cy.navigateToUrl(START); + before(() => { + cy.navigateToUrl(START); - cy.completeAndSubmitAllInsuranceEligibilityAnswers(); + cy.completeAndSubmitAllInsuranceEligibilityAnswers({}); - cy.assertUrl(url); - }); + cy.assertUrl(url); + }); - beforeEach(() => { - cy.saveSession(); - }); + beforeEach(() => { + cy.saveSession(); + }); - const fieldId = VALID_EXPORTER_LOCATION; + const fieldId = VALID_EXPORTER_LOCATION; - describe('when clicking the `change` link', () => { - it(`should redirect to ${EXPORTER_LOCATION_CHANGE}`, () => { - cy.navigateToUrl(url); + describe('when clicking the `change` link', () => { + it(`should redirect to ${EXPORTER_LOCATION_CHANGE}`, () => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.assertChangeAnswersPageUrl({ route: EXPORTER_LOCATION_CHANGE, fieldId, isInsuranceEligibility: true }); + cy.assertChangeAnswersPageUrl({ route: EXPORTER_LOCATION_CHANGE, fieldId, isInsuranceEligibility: true }); + }); }); - }); - describe('form submission without changing the answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission without changing the answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.clickSubmitButton(); - }); + cy.clickSubmitButton(); + }); - it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { - cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { + cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + }); }); - }); - describe('form submission with a new answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission with a new answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.clickNoRadioInput(); - cy.clickSubmitButton(); - }); + cy.clickNoRadioInput(); + cy.clickSubmitButton(); + }); - it(`should redirect to ${CANNOT_APPLY}`, () => { - cy.assertChangeAnswersPageUrl({ route: CANNOT_APPLY, fieldId, isInsuranceEligibility: true }); + it(`should redirect to ${CANNOT_APPLY}`, () => { + cy.assertChangeAnswersPageUrl({ route: CANNOT_APPLY, fieldId, isInsuranceEligibility: true }); + }); }); - }); -}); + }, +); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-has-companies-house-number.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-has-companies-house-number.spec.js index 606d1d297d..ce49c4449b 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-has-companies-house-number.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-has-companies-house-number.spec.js @@ -11,59 +11,62 @@ const { const baseUrl = Cypress.config('baseUrl'); -context('Insurance - Eligibility - Change your answers - Has companies house number - As an exporter, I want to change my answers to the eligibility Has companies house number section', () => { - const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; +context( + 'Insurance - Eligibility - Change your answers - Has companies house number - As an exporter, I want to change my answers to the eligibility Has companies house number section', + () => { + const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; - before(() => { - cy.navigateToUrl(START); + before(() => { + cy.navigateToUrl(START); - cy.completeAndSubmitAllInsuranceEligibilityAnswers(); + cy.completeAndSubmitAllInsuranceEligibilityAnswers({}); - cy.assertUrl(url); - }); + cy.assertUrl(url); + }); - beforeEach(() => { - cy.saveSession(); - }); + beforeEach(() => { + cy.saveSession(); + }); - const fieldId = HAS_COMPANIES_HOUSE_NUMBER; + const fieldId = HAS_COMPANIES_HOUSE_NUMBER; - describe('when clicking the `change` link', () => { - it(`should redirect to ${COMPANIES_HOUSE_NUMBER_CHANGE}`, () => { - cy.navigateToUrl(url); + describe('when clicking the `change` link', () => { + it(`should redirect to ${COMPANIES_HOUSE_NUMBER_CHANGE}`, () => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.assertChangeAnswersPageUrl({ route: COMPANIES_HOUSE_NUMBER_CHANGE, fieldId, isInsuranceEligibility: true }); + cy.assertChangeAnswersPageUrl({ route: COMPANIES_HOUSE_NUMBER_CHANGE, fieldId, isInsuranceEligibility: true }); + }); }); - }); - describe('form submission without changing the answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission without changing the answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.clickSubmitButton(); - }); + cy.clickSubmitButton(); + }); - it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { - cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { + cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + }); }); - }); - describe('form submission with a new answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission with a new answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.clickNoRadioInput(); - cy.clickSubmitButton(); - }); + cy.clickNoRadioInput(); + cy.clickSubmitButton(); + }); - it(`should redirect to ${NO_COMPANIES_HOUSE_NUMBER}`, () => { - cy.assertChangeAnswersPageUrl({ route: NO_COMPANIES_HOUSE_NUMBER, fieldId, isInsuranceEligibility: true }); + it(`should redirect to ${NO_COMPANIES_HOUSE_NUMBER}`, () => { + cy.assertChangeAnswersPageUrl({ route: NO_COMPANIES_HOUSE_NUMBER, fieldId, isInsuranceEligibility: true }); + }); }); - }); -}); + }, +); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-total-value-insured.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-total-value-insured.spec.js index e47d207395..116350ab20 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-total-value-insured.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-total-value-insured.spec.js @@ -12,63 +12,66 @@ const { const baseUrl = Cypress.config('baseUrl'); -context('Insurance - Eligibility - Change your answers - Total contract value - As an exporter, I want to change my answers to the eligibility total contract value section', () => { - const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; +context( + 'Insurance - Eligibility - Change your answers - Total contract value - As an exporter, I want to change my answers to the eligibility total contract value section', + () => { + const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; - before(() => { - cy.navigateToUrl(START); + before(() => { + cy.navigateToUrl(START); - cy.completeAndSubmitAllInsuranceEligibilityAnswers(); + cy.completeAndSubmitAllInsuranceEligibilityAnswers({}); - cy.assertUrl(url); - }); + cy.assertUrl(url); + }); - beforeEach(() => { - cy.saveSession(); - }); + beforeEach(() => { + cy.saveSession(); + }); - const fieldId = TOTAL_CONTRACT_VALUE; - const expectedValue = FIELDS[fieldId].SUMMARY.ABOVE; + const fieldId = TOTAL_CONTRACT_VALUE; + const expectedValue = FIELDS[fieldId].SUMMARY.ABOVE; - describe('when clicking the `change` link', () => { - it(`should redirect to ${TOTAL_VALUE_INSURED_CHANGE}`, () => { - cy.navigateToUrl(url); + describe('when clicking the `change` link', () => { + it(`should redirect to ${TOTAL_VALUE_INSURED_CHANGE}`, () => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.assertChangeAnswersPageUrl({ route: TOTAL_VALUE_INSURED_CHANGE, fieldId, isInsuranceEligibility: true }); + cy.assertChangeAnswersPageUrl({ route: TOTAL_VALUE_INSURED_CHANGE, fieldId, isInsuranceEligibility: true }); + }); }); - }); - describe('form submission without changing the answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission without changing the answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.clickSubmitButton(); - }); + cy.clickSubmitButton(); + }); - it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { - cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { + cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + }); }); - }); - describe('form submission with a new answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission with a new answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.completeAndSubmitTotalValueInsuredForm({ underThreshold: false }); - }); + cy.completeAndSubmitTotalValueInsuredForm({ underThreshold: false }); + }); - it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { - cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); - }); + it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { + cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + }); - it('should render the new answer', () => { - cy.assertSummaryListRowValue(summaryList, fieldId, expectedValue); + it('should render the new answer', () => { + cy.assertSummaryListRowValue(summaryList, fieldId, expectedValue); + }); }); - }); -}); + }, +); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-uk-goods-or-services.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-uk-goods-or-services.spec.js index 744f56c6f3..e957c7dd8d 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-uk-goods-or-services.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/change-your-answers/change-your-answers-uk-goods-or-services.spec.js @@ -11,59 +11,62 @@ const { const baseUrl = Cypress.config('baseUrl'); -context('Insurance - Eligibility - Change your answers - UK goods or services - As an exporter, I want to change my answers to the eligibility UK goods or services section', () => { - const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; +context( + 'Insurance - Eligibility - Change your answers - UK goods or services - As an exporter, I want to change my answers to the eligibility UK goods or services section', + () => { + const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; - before(() => { - cy.navigateToUrl(START); + before(() => { + cy.navigateToUrl(START); - cy.completeAndSubmitAllInsuranceEligibilityAnswers(); + cy.completeAndSubmitAllInsuranceEligibilityAnswers({}); - cy.assertUrl(url); - }); + cy.assertUrl(url); + }); - beforeEach(() => { - cy.saveSession(); - }); + beforeEach(() => { + cy.saveSession(); + }); - const fieldId = HAS_MINIMUM_UK_GOODS_OR_SERVICES; + const fieldId = HAS_MINIMUM_UK_GOODS_OR_SERVICES; - describe('when clicking the `change` link', () => { - it(`should redirect to ${UK_GOODS_OR_SERVICES_CHANGE}`, () => { - cy.navigateToUrl(url); + describe('when clicking the `change` link', () => { + it(`should redirect to ${UK_GOODS_OR_SERVICES_CHANGE}`, () => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.assertChangeAnswersPageUrl({ route: UK_GOODS_OR_SERVICES_CHANGE, fieldId, isInsuranceEligibility: true }); + cy.assertChangeAnswersPageUrl({ route: UK_GOODS_OR_SERVICES_CHANGE, fieldId, isInsuranceEligibility: true }); + }); }); - }); - describe('form submission without changing the answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission without changing the answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.clickSubmitButton(); - }); + cy.clickSubmitButton(); + }); - it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { - cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => { + cy.assertChangeAnswersPageUrl({ route: CHECK_YOUR_ANSWERS, fieldId, isInsuranceEligibility: true }); + }); }); - }); - describe('form submission with a new answer', () => { - beforeEach(() => { - cy.navigateToUrl(url); + describe('form submission with a new answer', () => { + beforeEach(() => { + cy.navigateToUrl(url); - summaryList.field(fieldId).changeLink().click(); + summaryList.field(fieldId).changeLink().click(); - cy.clickNoRadioInput(); - cy.clickSubmitButton(); - }); + cy.clickNoRadioInput(); + cy.clickSubmitButton(); + }); - it(`should redirect to ${CANNOT_APPLY}`, () => { - cy.assertChangeAnswersPageUrl({ route: CANNOT_APPLY, fieldId, isInsuranceEligibility: true }); + it(`should redirect to ${CANNOT_APPLY}`, () => { + cy.assertChangeAnswersPageUrl({ route: CANNOT_APPLY, fieldId, isInsuranceEligibility: true }); + }); }); - }); -}); + }, +); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/check-your-answers/eligibility-check-your-answers-company-name-special-characters.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/check-your-answers/eligibility-check-your-answers-company-name-special-characters.spec.js new file mode 100644 index 0000000000..788e59eb4e --- /dev/null +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/check-your-answers/eligibility-check-your-answers-company-name-special-characters.spec.js @@ -0,0 +1,35 @@ +import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; +import { INSURANCE_FIELD_IDS } from '../../../../../../constants/field-ids/insurance'; +import { COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME } from '../../../../../../constants/examples'; +import checkSummaryList from '../../../../../../commands/insurance/check-your-answers-eligibility-summary-list'; + +const { + START, + ELIGIBILITY: { CHECK_YOUR_ANSWERS }, +} = INSURANCE_ROUTES; + +const { COMPANIES_HOUSE_NUMBER } = INSURANCE_FIELD_IDS.ELIGIBILITY; + +const { COMPANY_NAME } = INSURANCE_FIELD_IDS.COMPANIES_HOUSE; + +const baseUrl = Cypress.config('baseUrl'); + +context('Insurance - Eligibility - Check your answers - company name with special characters', () => { + const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; + + beforeEach(() => { + cy.navigateToUrl(START); + + cy.completeAndSubmitAllInsuranceEligibilityAnswers({ companyNumber: COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME }); + + cy.assertUrl(url); + }); + + it(`should render a ${COMPANIES_HOUSE_NUMBER} summary list row`, () => { + checkSummaryList[COMPANIES_HOUSE_NUMBER]({ differentCompanyWithSpecialCharacters: true }); + }); + + it(`should render a ${COMPANY_NAME} summary list row with special characters`, () => { + checkSummaryList[COMPANY_NAME]({ differentCompanyWithSpecialCharacters: true }); + }); +}); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/check-your-answers/eligibility-check-your-answers-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/check-your-answers/eligibility-check-your-answers-page.spec.js index a140860d90..06ec2ce856 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/check-your-answers/eligibility-check-your-answers-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/check-your-answers/eligibility-check-your-answers-page.spec.js @@ -8,9 +8,7 @@ const CONTENT_STRINGS = PAGES.INSURANCE.ELIGIBILITY.CHECK_YOUR_ANSWERS; const { START, - ELIGIBILITY: { - END_BUYER, CHECK_YOUR_ANSWERS, ELIGIBLE_TO_APPLY_ONLINE, - }, + ELIGIBILITY: { END_BUYER, CHECK_YOUR_ANSWERS, ELIGIBLE_TO_APPLY_ONLINE }, } = INSURANCE_ROUTES; const { @@ -28,78 +26,81 @@ const { COMPANY_NAME } = INSURANCE_FIELD_IDS.COMPANIES_HOUSE; const baseUrl = Cypress.config('baseUrl'); -context('Insurance - Eligibility - as an exporter, I want to confirm my selection for the eligibility section of my export insurance application, So that UKEF can accurately process my credit insurance application.', () => { - const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; +context( + 'Insurance - Eligibility - as an exporter, I want to confirm my selection for the eligibility section of my export insurance application, So that UKEF can accurately process my credit insurance application.', + () => { + const url = `${baseUrl}${CHECK_YOUR_ANSWERS}`; - beforeEach(() => { - cy.navigateToUrl(START); + beforeEach(() => { + cy.navigateToUrl(START); - cy.completeAndSubmitAllInsuranceEligibilityAnswers(); + cy.completeAndSubmitAllInsuranceEligibilityAnswers({}); - cy.assertUrl(url); - }); + cy.assertUrl(url); + }); - it('renders core page elements', () => { - cy.corePageChecks({ - pageTitle: CONTENT_STRINGS.PAGE_TITLE, - currentHref: CHECK_YOUR_ANSWERS, - backLink: END_BUYER, - assertAuthenticatedHeader: false, - submitButtonCopy: BUTTONS.CONFIRM_AND_CONTINUE, + it('renders core page elements', () => { + cy.corePageChecks({ + pageTitle: CONTENT_STRINGS.PAGE_TITLE, + currentHref: CHECK_YOUR_ANSWERS, + backLink: END_BUYER, + assertAuthenticatedHeader: false, + submitButtonCopy: BUTTONS.CONFIRM_AND_CONTINUE, + }); }); - }); - it('renders a warning text', () => { - warning().contains(CONTENT_STRINGS.WARNING); - }); + it('renders a warning text', () => { + warning().contains(CONTENT_STRINGS.WARNING); + }); - it('renders a cannot change responses text', () => { - cy.checkText(body(), CONTENT_STRINGS.CANNOT_CHANGE); - }); + it('renders a cannot change responses text', () => { + cy.checkText(body(), CONTENT_STRINGS.CANNOT_CHANGE); + }); - it(`should render a ${VALID_EXPORTER_LOCATION} summary list row`, () => { - checkSummaryList[VALID_EXPORTER_LOCATION](); - }); + it(`should render a ${VALID_EXPORTER_LOCATION} summary list row`, () => { + checkSummaryList[VALID_EXPORTER_LOCATION](); + }); - it(`should render a ${HAS_COMPANIES_HOUSE_NUMBER} summary list row`, () => { - checkSummaryList[HAS_COMPANIES_HOUSE_NUMBER](); - }); + it(`should render a ${HAS_COMPANIES_HOUSE_NUMBER} summary list row`, () => { + checkSummaryList[HAS_COMPANIES_HOUSE_NUMBER](); + }); - it(`should render a ${COMPANIES_HOUSE_NUMBER} summary list row`, () => { - checkSummaryList[COMPANIES_HOUSE_NUMBER](); - }); + it(`should render a ${COMPANIES_HOUSE_NUMBER} summary list row`, () => { + checkSummaryList[COMPANIES_HOUSE_NUMBER]({}); + }); - it(`should render a ${COMPANY_NAME} summary list row`, () => { - checkSummaryList[COMPANY_NAME](); - }); + it(`should render a ${COMPANY_NAME} summary list row`, () => { + checkSummaryList[COMPANY_NAME]({}); + }); - it(`should render a ${BUYER_COUNTRY} summary list row`, () => { - checkSummaryList[BUYER_COUNTRY](); - }); + it(`should render a ${BUYER_COUNTRY} summary list row`, () => { + checkSummaryList[BUYER_COUNTRY](); + }); - it(`should render a ${TOTAL_CONTRACT_VALUE} summary list row`, () => { - checkSummaryList[TOTAL_CONTRACT_VALUE](); - }); + it(`should render a ${TOTAL_CONTRACT_VALUE} summary list row`, () => { + checkSummaryList[TOTAL_CONTRACT_VALUE](); + }); - it(`should render a ${COVER_PERIOD} summary list row`, () => { - checkSummaryList[COVER_PERIOD](); - }); + it(`should render a ${COVER_PERIOD} summary list row`, () => { + checkSummaryList[COVER_PERIOD](); + }); - it(`should render a ${HAS_MINIMUM_UK_GOODS_OR_SERVICES} summary list row`, () => { - checkSummaryList[HAS_MINIMUM_UK_GOODS_OR_SERVICES](); - }); + it(`should render a ${HAS_MINIMUM_UK_GOODS_OR_SERVICES} summary list row`, () => { + checkSummaryList[HAS_MINIMUM_UK_GOODS_OR_SERVICES](); + }); - it(`should render a ${HAS_END_BUYER} summary list row`, () => { - checkSummaryList[HAS_END_BUYER](); - }); + it(`should render a ${HAS_END_BUYER} summary list row`, () => { + checkSummaryList[HAS_END_BUYER](); + }); - describe('form submission', () => { - it(`should redirect to ${ELIGIBLE_TO_APPLY_ONLINE}`, () => { - cy.clickSubmitButton(); + describe('form submission', () => { + it(`should redirect to ${ELIGIBLE_TO_APPLY_ONLINE}`, () => { + cy.clickSubmitButton(); - const expectedUrl = `${baseUrl}${ELIGIBLE_TO_APPLY_ONLINE}`; + const expectedUrl = `${baseUrl}${ELIGIBLE_TO_APPLY_ONLINE}`; - cy.assertUrl(expectedUrl); + cy.assertUrl(expectedUrl); + }); }); - }); -}); + }, +); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details-company-name-special-characters.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details-company-name-special-characters.spec.js new file mode 100644 index 0000000000..7e62b64928 --- /dev/null +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details-company-name-special-characters.spec.js @@ -0,0 +1,41 @@ +import { COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME } from '../../../../../../constants/examples'; +import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; +import assertCompaniesHouseSummaryList from '../../../../../../commands/insurance/assert-companies-house-summary-list'; + +const { + START, + ELIGIBILITY: { COMPANY_DETAILS }, +} = INSURANCE_ROUTES; + +const baseUrl = Cypress.config('baseUrl'); + +context( + 'Insurance - Eligibility - Companies details page - Company name with special characters - I want to check if I can use online service to apply for UKEF Export Insurance Policy', + () => { + const url = `${baseUrl}${COMPANY_DETAILS}`; + + before(() => { + cy.navigateToUrl(START); + + cy.completeStartForm(); + cy.completeCheckIfEligibleForm(); + cy.completeExporterLocationForm(); + cy.completeCompaniesHouseNumberForm(); + cy.completeAndSubmitCompaniesHouseSearchForm({ + companyNumber: COMPANIES_HOUSE_NUMBER_SPECIAL_CHARACTERS_NAME, + }); + + cy.assertUrl(url); + }); + + beforeEach(() => { + cy.saveSession(); + + cy.navigateToUrl(url); + }); + + it('should render `company name` key and value', () => { + assertCompaniesHouseSummaryList.name({ differentCompanyWithSpecialCharacters: true }); + }); + }, +); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details.spec.js index 311a0dcc32..1a09636a04 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/company-details/company-details.spec.js @@ -8,11 +8,7 @@ const CONTENT_STRINGS = PAGES.INSURANCE.ELIGIBILITY.COMPANY_DETAILS; const { START, - ELIGIBILITY: { - BUYER_COUNTRY, - COMPANY_DETAILS, - ENTER_COMPANIES_HOUSE_NUMBER, - }, + ELIGIBILITY: { BUYER_COUNTRY, COMPANY_DETAILS, ENTER_COMPANIES_HOUSE_NUMBER }, } = INSURANCE_ROUTES; const baseUrl = Cypress.config('baseUrl'); @@ -60,7 +56,7 @@ context('Insurance - Eligibility - Companies details page - I want to check if I }); it('should render `company name` key and value', () => { - assertCompaniesHouseSummaryList.name(); + assertCompaniesHouseSummaryList.name({}); }); it('should render `company address` key and value', () => { @@ -77,11 +73,7 @@ context('Insurance - Eligibility - Companies details page - I want to check if I }); it('should render `enter different companies house number` link', () => { - cy.checkLink( - companyDetailsPage.differentCompaniesHouseNumberLink(), - ENTER_COMPANIES_HOUSE_NUMBER, - CONTENT_STRINGS.DIFFERENT_COMPANIES_HOUSE_NUMBER, - ); + cy.checkLink(companyDetailsPage.differentCompaniesHouseNumberLink(), ENTER_COMPANIES_HOUSE_NUMBER, CONTENT_STRINGS.DIFFERENT_COMPANIES_HOUSE_NUMBER); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-page.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-page.spec.js index ecb4082366..86a712ad51 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-page.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/your-business/company-details/company-details-page.spec.js @@ -1,10 +1,7 @@ import { companyDetails } from '../../../../../../pages/your-business'; import partials from '../../../../../../partials'; import { - body, - field, - yesRadioInput, - noRadioInput, + body, field, yesRadioInput, noRadioInput, } from '../../../../../../pages/shared'; import { PAGES } from '../../../../../../content-strings'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; @@ -13,10 +10,7 @@ import assertCompaniesHouseSummaryList from '../../../../../../commands/insuranc const { ROOT, - EXPORTER_BUSINESS: { - ROOT: EXPORTER_BUSINESS_ROOT, - COMPANY_DETAILS_ROOT, - }, + EXPORTER_BUSINESS: { ROOT: EXPORTER_BUSINESS_ROOT, COMPANY_DETAILS_ROOT }, } = INSURANCE_ROUTES; const CONTENT_STRINGS = PAGES.INSURANCE.EXPORTER_BUSINESS.COMPANY_DETAILS; @@ -24,134 +18,133 @@ const CONTENT_STRINGS = PAGES.INSURANCE.EXPORTER_BUSINESS.COMPANY_DETAILS; const { EXPORTER_BUSINESS: { YOUR_COMPANY: { - TRADING_ADDRESS, - HAS_DIFFERENT_TRADING_NAME, - WEBSITE, - PHONE_NUMBER, - DIFFERENT_TRADING_NAME, + TRADING_ADDRESS, HAS_DIFFERENT_TRADING_NAME, WEBSITE, PHONE_NUMBER, DIFFERENT_TRADING_NAME, }, }, } = INSURANCE_FIELD_IDS; const baseUrl = Cypress.config('baseUrl'); -context('Insurance - Your business - Company details page - As an Exporter I want to my companies details So that I can apply for UKEF Export Insurance policy', () => { - let referenceNumber; - let url; +context( + 'Insurance - Your business - Company details page - As an Exporter I want to my companies details So that I can apply for UKEF Export Insurance policy', + () => { + let referenceNumber; + let url; - before(() => { - cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { - referenceNumber = refNumber; + before(() => { + cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { + referenceNumber = refNumber; - cy.startYourBusinessSection({}); + cy.startYourBusinessSection({}); - url = `${baseUrl}${ROOT}/${referenceNumber}${COMPANY_DETAILS_ROOT}`; + url = `${baseUrl}${ROOT}/${referenceNumber}${COMPANY_DETAILS_ROOT}`; - 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}${COMPANY_DETAILS_ROOT}`, - backLink: `${ROOT}/${referenceNumber}${EXPORTER_BUSINESS_ROOT}`, - lightHouseThresholds: { - 'best-practices': 93, - }, + cy.assertUrl(url); + }); }); - }); - describe('page tests', () => { beforeEach(() => { - cy.navigateToUrl(url); + cy.saveSession(); }); - it('renders a heading caption', () => { - cy.checkText(partials.headingCaption(), CONTENT_STRINGS.HEADING_CAPTION); + after(() => { + cy.deleteApplication(referenceNumber); }); - it('should render body text', () => { - cy.checkText(body(), CONTENT_STRINGS.BODY); + it('renders core page elements', () => { + cy.corePageChecks({ + pageTitle: CONTENT_STRINGS.PAGE_TITLE, + currentHref: `${ROOT}/${referenceNumber}${COMPANY_DETAILS_ROOT}`, + backLink: `${ROOT}/${referenceNumber}${EXPORTER_BUSINESS_ROOT}`, + lightHouseThresholds: { + 'best-practices': 93, + }, + }); }); - describe('companies house summary list', () => { - it('should render `company number` key and value', () => { - assertCompaniesHouseSummaryList.number(); + describe('page tests', () => { + beforeEach(() => { + cy.navigateToUrl(url); }); - it('should render `company name` key and value', () => { - assertCompaniesHouseSummaryList.name(); + it('renders a heading caption', () => { + cy.checkText(partials.headingCaption(), CONTENT_STRINGS.HEADING_CAPTION); }); - it('should render `company address` key and value', () => { - assertCompaniesHouseSummaryList.address(); + it('should render body text', () => { + cy.checkText(body(), CONTENT_STRINGS.BODY); }); - it('should render `company incorporated` key and value', () => { - assertCompaniesHouseSummaryList.incorporated(); - }); + describe('companies house summary list', () => { + it('should render `company number` key and value', () => { + assertCompaniesHouseSummaryList.number(); + }); - it('should render `company SIC codes` key and value', () => { - assertCompaniesHouseSummaryList.sicCodes(); + it('should render `company name` key and value', () => { + assertCompaniesHouseSummaryList.name({}); + }); + + it('should render `company address` key and value', () => { + assertCompaniesHouseSummaryList.address(); + }); + + it('should render `company incorporated` key and value', () => { + assertCompaniesHouseSummaryList.incorporated(); + }); + + it('should render `company SIC codes` key and value', () => { + assertCompaniesHouseSummaryList.sicCodes(); + }); }); - }); - it('should display the trading name radios', () => { - cy.checkText(companyDetails[HAS_DIFFERENT_TRADING_NAME].label(), CONTENT_STRINGS.HAS_DIFFERENT_TRADING_NAME); + it('should display the trading name radios', () => { + cy.checkText(companyDetails[HAS_DIFFERENT_TRADING_NAME].label(), CONTENT_STRINGS.HAS_DIFFERENT_TRADING_NAME); - cy.checkRadioInputYesAriaLabel(CONTENT_STRINGS.HAS_DIFFERENT_TRADING_NAME); + cy.checkRadioInputYesAriaLabel(CONTENT_STRINGS.HAS_DIFFERENT_TRADING_NAME); - cy.checkRadioInputNoAriaLabel(CONTENT_STRINGS.HAS_DIFFERENT_TRADING_NAME); - }); + cy.checkRadioInputNoAriaLabel(CONTENT_STRINGS.HAS_DIFFERENT_TRADING_NAME); + }); - it(`should NOT display conditional ${DIFFERENT_TRADING_NAME} input without selecting the trading name "yes" radio`, () => { - field(DIFFERENT_TRADING_NAME).input().should('not.be.visible'); - }); + it(`should NOT display conditional ${DIFFERENT_TRADING_NAME} input without selecting the trading name "yes" radio`, () => { + field(DIFFERENT_TRADING_NAME).input().should('not.be.visible'); + }); - it(`should display conditional ${DIFFERENT_TRADING_NAME} input when selecting the trading name "yes" radio`, () => { - cy.clickYesRadioInput(); + it(`should display conditional ${DIFFERENT_TRADING_NAME} input when selecting the trading name "yes" radio`, () => { + cy.clickYesRadioInput(); - field(DIFFERENT_TRADING_NAME).input().should('be.visible'); + field(DIFFERENT_TRADING_NAME).input().should('be.visible'); - cy.checkText(field(DIFFERENT_TRADING_NAME).label(), CONTENT_STRINGS.DIFFERENT_TRADING_NAME); - cy.checkText(field(DIFFERENT_TRADING_NAME).hint(), CONTENT_STRINGS.DIFFERENT_TRADING_NAME_HINT); - }); + cy.checkText(field(DIFFERENT_TRADING_NAME).label(), CONTENT_STRINGS.DIFFERENT_TRADING_NAME); + cy.checkText(field(DIFFERENT_TRADING_NAME).hint(), CONTENT_STRINGS.DIFFERENT_TRADING_NAME_HINT); + }); - it('should display the trading address radios', () => { - cy.checkText(companyDetails[TRADING_ADDRESS].label(), CONTENT_STRINGS.TRADING_ADDRESS); + it('should display the trading address radios', () => { + cy.checkText(companyDetails[TRADING_ADDRESS].label(), CONTENT_STRINGS.TRADING_ADDRESS); - cy.checkAriaLabel(yesRadioInput().eq(1), `${CONTENT_STRINGS.TRADING_ADDRESS} Yes`); + cy.checkAriaLabel(yesRadioInput().eq(1), `${CONTENT_STRINGS.TRADING_ADDRESS} Yes`); - cy.checkAriaLabel(noRadioInput().eq(1), `${CONTENT_STRINGS.TRADING_ADDRESS} No`); - }); + cy.checkAriaLabel(noRadioInput().eq(1), `${CONTENT_STRINGS.TRADING_ADDRESS} No`); + }); - it('should display the company website text input', () => { - cy.checkText(field(WEBSITE).label(), CONTENT_STRINGS.WEBSITE); + it('should display the company website text input', () => { + cy.checkText(field(WEBSITE).label(), CONTENT_STRINGS.WEBSITE); - field(WEBSITE).input().should('exist'); - cy.checkAriaLabel(field(WEBSITE).input(), CONTENT_STRINGS.WEBSITE); - }); + field(WEBSITE).input().should('exist'); + cy.checkAriaLabel(field(WEBSITE).input(), CONTENT_STRINGS.WEBSITE); + }); - it('should display the phone number text input', () => { - cy.checkText(field(PHONE_NUMBER).label(), CONTENT_STRINGS.PHONE_NUMBER); + it('should display the phone number text input', () => { + cy.checkText(field(PHONE_NUMBER).label(), CONTENT_STRINGS.PHONE_NUMBER); - cy.checkText(field(PHONE_NUMBER).hint(), CONTENT_STRINGS.PHONE_NUMBER_HINT); + cy.checkText(field(PHONE_NUMBER).hint(), CONTENT_STRINGS.PHONE_NUMBER_HINT); - field(PHONE_NUMBER).input().should('exist'); - cy.checkAriaLabel(field(PHONE_NUMBER).input(), CONTENT_STRINGS.PHONE_NUMBER); - }); + field(PHONE_NUMBER).input().should('exist'); + cy.checkAriaLabel(field(PHONE_NUMBER).input(), CONTENT_STRINGS.PHONE_NUMBER); + }); - it('renders a `save and back` button', () => { - cy.assertSaveAndBackButton(); + it('renders a `save and back` button', () => { + cy.assertSaveAndBackButton(); + }); }); - }); -}); + }, +); diff --git a/src/ui/server/helpers/update-submitted-data/insurance/index.test.ts b/src/ui/server/helpers/update-submitted-data/insurance/index.test.ts index cd0fe09142..e7b4ee6fb8 100644 --- a/src/ui/server/helpers/update-submitted-data/insurance/index.test.ts +++ b/src/ui/server/helpers/update-submitted-data/insurance/index.test.ts @@ -16,10 +16,35 @@ describe('server/helpers/update-submitted-data/insurance', () => { const result = updateSubmittedData(mockFormData, mockExistingData); - const expected = sanitiseData({ + const sanitisedFormData = sanitiseData(mockFormData); + + const expected = { ...mockExistingData, - ...mockFormData, - }); + ...sanitisedFormData, + }; + + expect(result).toEqual(expected); + }); + }); + + describe('when there is existing data which has a special character', () => { + it('should return an object with existing and new, sanitised form data and should not sanitise the existing data', () => { + const mockFormData = { + a: true, + } as RequestBody; + + const mockExistingData = { + mock: '&', + } as SubmittedDataInsuranceEligibility; + + const result = updateSubmittedData(mockFormData, mockExistingData); + + const sanitisedFormData = sanitiseData(mockFormData); + + const expected = { + ...mockExistingData, + ...sanitisedFormData, + }; expect(result).toEqual(expected); }); diff --git a/src/ui/server/helpers/update-submitted-data/insurance/index.ts b/src/ui/server/helpers/update-submitted-data/insurance/index.ts index d4b4e12e93..ebc1191a0e 100644 --- a/src/ui/server/helpers/update-submitted-data/insurance/index.ts +++ b/src/ui/server/helpers/update-submitted-data/insurance/index.ts @@ -10,14 +10,15 @@ import { RequestBody, SubmittedDataInsuranceEligibility } from '../../../../type * @returns {Object} Mapped and sanitised data */ const updateSubmittedData = (formData: RequestBody, existingData?: SubmittedDataInsuranceEligibility): SubmittedDataInsuranceEligibility => { - const modifiedData = { + // only sanitise the new form data + const sanitisedFormData = sanitiseData(formData); + + const data = { ...existingData, - ...formData, + ...sanitisedFormData, }; - const sanitised = sanitiseData(modifiedData); - - return sanitised; + return data; }; export { updateSubmittedData };