diff --git a/e2e-tests/commands/shared-commands/click-events/click-start-new-application-button.js b/e2e-tests/commands/shared-commands/click-events/click-start-new-application-button.js new file mode 100644 index 0000000000..0f5567a5bf --- /dev/null +++ b/e2e-tests/commands/shared-commands/click-events/click-start-new-application-button.js @@ -0,0 +1,11 @@ +import partials from '../../../partials'; + +/** + * clickStartNewApplicationButton + * Click the "start new application" button + */ +const clickStartNewApplicationButton = () => { + partials.startNewApplicationButton().click(); +}; + +export default clickStartNewApplicationButton; diff --git a/e2e-tests/commands/shared-commands/click-events/index.js b/e2e-tests/commands/shared-commands/click-events/index.js index 4c5f120267..0a70482cdd 100644 --- a/e2e-tests/commands/shared-commands/click-events/index.js +++ b/e2e-tests/commands/shared-commands/click-events/index.js @@ -11,6 +11,8 @@ Cypress.Commands.add('clickYesRadioInput', require('./click-yes-radio-input')); Cypress.Commands.add('clickProvideAlternativeCurrencyLink', require('./click-provide-alternative-currency-link')); Cypress.Commands.add('clickAlternativeCurrencyRadioOption', require('./click-alternative-currency-radio-option')); +Cypress.Commands.add('clickStartNewApplicationButton', require('./click-start-new-application-button')); + Cypress.Commands.add('clickTaskBusiness', require('./tasks/click-task-business')); Cypress.Commands.add('clickTaskBuyer', require('./tasks/click-task-buyer')); Cypress.Commands.add('clickTaskPolicy', require('./tasks/click-task-policy')); diff --git a/e2e-tests/content-strings/pages/insurance/business/index.js b/e2e-tests/content-strings/pages/insurance/business/index.js index 847feb80f0..3d554297e1 100644 --- a/e2e-tests/content-strings/pages/insurance/business/index.js +++ b/e2e-tests/content-strings/pages/insurance/business/index.js @@ -30,15 +30,6 @@ export const COMPANY_DETAILS = { DIFFERENT_TRADING_NAME_HINT: 'Your official trading name will still be on the policy.', }; -export const CONTACT = { - ...SHARED, - PAGE_TITLE: 'Your contact details', - CONTACT_DETAILS: { - LEGEND: 'Contact details', - HINT: 'This will be the name on the contract policy', - }, -}; - export const ALTERNATIVE_TRADING_ADDRESS = { ...SHARED, PAGE_TITLE: 'Alternative trading address', diff --git a/e2e-tests/insurance/cypress/e2e/journeys/account/sign-in/enter-code/account-sign-in-create-code-dashboard-or-application-redirect.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/account/sign-in/enter-code/account-sign-in-create-code-dashboard-or-application-redirect.spec.js index 4e32d85baf..0a5167a84e 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/account/sign-in/enter-code/account-sign-in-create-code-dashboard-or-application-redirect.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/account/sign-in/enter-code/account-sign-in-create-code-dashboard-or-application-redirect.spec.js @@ -1,5 +1,4 @@ import header from '../../../../../../../partials/header'; -import dashboardPage from '../../../../../../../pages/insurance/dashboard'; context( 'Insurance - Account - Sign in - I want to go straight to my application if there is exactly one application in progress or the dashboard otherwise', @@ -43,7 +42,7 @@ context( // go to all applications for user cy.clickHeaderApplicationsLink(); // click on start new application page - dashboardPage.startNewApplicationButton().click(); + cy.clickStartNewApplicationButton(); // complete eligibility questions cy.submitInsuranceEligibilityAnswersHappyPath(); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/complete-eligibility-answers-for-a-second-time.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/complete-eligibility-answers-for-a-second-time.spec.js index 054fd6e1db..f193f8df8e 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/complete-eligibility-answers-for-a-second-time.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/complete-eligibility-answers-for-a-second-time.spec.js @@ -1,4 +1,3 @@ -import dashboardPage from '../../../../pages/insurance/dashboard'; import { autoCompleteField, field } from '../../../../pages/shared'; import { ROUTES, FIELD_IDS } from '../../../../constants'; @@ -28,7 +27,7 @@ context('Insurance - Eligibility - start and complete for a second time after cr cy.clickHeaderApplicationsLink(); - dashboardPage.startNewApplicationButton().click(); + cy.clickStartNewApplicationButton(); cy.assertUrl(exporterLocationUrl); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-create-a-new-application.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-create-a-new-application.spec.js index 7958839af1..fe1d42b6e5 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-create-a-new-application.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-create-a-new-application.spec.js @@ -1,4 +1,3 @@ -import dashboardPage from '../../../../../pages/insurance/dashboard'; import { INSURANCE_ROUTES } from '../../../../../constants/routes/insurance'; const { ROOT: INSURANCE_ROOT, ALL_SECTIONS } = INSURANCE_ROUTES; @@ -14,7 +13,7 @@ context('Insurance - Dashboard - Start new application button - As an Exporter, cy.clickHeaderApplicationsLink(); - dashboardPage.startNewApplicationButton().click(); + cy.clickStartNewApplicationButton(); cy.submitInsuranceEligibilityAnswersHappyPath(); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-multiple-applications.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-multiple-applications.spec.js index f0cc3403e1..4293032006 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-multiple-applications.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-multiple-applications.spec.js @@ -36,7 +36,7 @@ context('Insurance - Dashboard - new application', () => { let secondReferenceNumber; before(() => { - dashboardPage.startNewApplicationButton().click(); + cy.clickStartNewApplicationButton(); cy.submitInsuranceEligibilityAnswersFromExporterLocationHappyPath({}); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-no-applications.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-no-applications.spec.js index 1ed720e123..b3aa0f34dc 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-no-applications.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard-no-applications.spec.js @@ -1,4 +1,5 @@ import dashboardPage from '../../../../../pages/insurance/dashboard'; +import partials from '../../../../../partials'; import { PAGES } from '../../../../../content-strings'; import { INSURANCE_ROUTES } from '../../../../../constants/routes/insurance'; @@ -43,18 +44,16 @@ context('Insurance - Dashboard - no applications', () => { }); it('should render `start new application` link', () => { - const selector = dashboardPage.startNewApplicationButton(); - const expected = { href: ELIGIBILITY.EXPORTER_LOCATION, copy: CONTENT_STRINGS.START_NEW_APPLICATION.TEXT, }; - cy.checkLink(selector, expected.href, expected.copy); + cy.checkLink(partials.startNewApplicationButton(), expected.href, expected.copy); }); it(`should redirect to ${ELIGIBILITY.EXPORTER_LOCATION}`, () => { - dashboardPage.startNewApplicationButton().click(); + cy.clickStartNewApplicationButton(); const expectedUrl = `${baseUrl}${ELIGIBILITY.EXPORTER_LOCATION}`; @@ -65,7 +64,7 @@ context('Insurance - Dashboard - no applications', () => { describe('when starting and completing insurance eligibility via the `start new` button ', () => { it('should create a new application and render in the dashboard', () => { cy.navigateToDashboardUrl(); - dashboardPage.startNewApplicationButton().click(); + cy.clickStartNewApplicationButton(); cy.submitInsuranceEligibilityAnswersHappyPath(); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard.spec.js index 1304efeae5..7da65b994e 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/dashboard/dashboard.spec.js @@ -1,4 +1,5 @@ import dashboardPage from '../../../../../pages/insurance/dashboard'; +import partials from '../../../../../partials'; import { DEFAULT, PAGES, BUTTONS } from '../../../../../content-strings'; import { ROUTES } from '../../../../../constants'; import { INSURANCE_FIELD_IDS } from '../../../../../constants/field-ids/insurance'; @@ -161,14 +162,12 @@ context( }); it('should render', () => { - const element = dashboardPage.startNewApplicationButton(); - const expected = { href: expectedUrl, text: BUTTONS.START_A_NEW_APPLICATION, }; - cy.checkLink(element, expected.href, expected.text); + cy.checkLink(partials.startNewApplicationButton(), expected.href, expected.text); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/eligible-to-apply-online/eligible-to-apply-online-already-signed-in-with-eligibility-answers.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/eligible-to-apply-online/eligible-to-apply-online-already-signed-in-with-eligibility-answers.spec.js index 7f551d4877..061b6149c0 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/eligibility/eligible-to-apply-online/eligible-to-apply-online-already-signed-in-with-eligibility-answers.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/eligibility/eligible-to-apply-online/eligible-to-apply-online-already-signed-in-with-eligibility-answers.spec.js @@ -1,4 +1,3 @@ -import dashboardPage from '../../../../../../pages/insurance/dashboard'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; const { ROOT, ALL_SECTIONS } = INSURANCE_ROUTES; @@ -12,7 +11,7 @@ context( before(() => { cy.completeSignInAndGoToDashboard().then(() => { // start new application/eligibility flow - dashboardPage.startNewApplicationButton().click(); + cy.clickStartNewApplicationButton(); cy.submitInsuranceEligibilityAnswersFromExporterLocationHappyPath({}); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/header-authenticated-insurance-eligibility.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/header-authenticated-insurance-eligibility.spec.js index 3ca86cc3e9..e99aaa82f8 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/header-authenticated-insurance-eligibility.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/header-authenticated-insurance-eligibility.spec.js @@ -1,5 +1,3 @@ -import dashboardPage from '../../../../pages/insurance/dashboard'; - context('Insurance - header - authenticated - complete insurance eligibility', () => { let referenceNumber; @@ -11,7 +9,7 @@ context('Insurance - header - authenticated - complete insurance eligibility', ( cy.clickHeaderApplicationsLink(); // start a new application - dashboardPage.startNewApplicationButton().click(); + cy.clickStartNewApplicationButton(); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/submit-name-fields-with-special-characters/submit-name-fields-with-special-characters-header-and-page-fields.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/submit-name-fields-with-special-characters/submit-name-fields-with-special-characters-header-and-page-fields.spec.js index 53f1cb78e7..4b1a87f023 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/submit-name-fields-with-special-characters/submit-name-fields-with-special-characters-header-and-page-fields.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/submit-name-fields-with-special-characters/submit-name-fields-with-special-characters-header-and-page-fields.spec.js @@ -1,6 +1,5 @@ import { INSURANCE_FIELD_IDS } from '../../../../../constants/field-ids/insurance'; import { field } from '../../../../../pages/shared'; -import dashboardPage from '../../../../../pages/insurance/dashboard'; import partials from '../../../../../partials'; import mockAccount from '../../../../../fixtures/account'; import mockNameWithSpecialCharacters from '../../../../../fixtures/name-with-special-characters'; @@ -51,7 +50,7 @@ context('Insurance - Name fields - Header and page fields should render special cy.navigateToDashboardUrl(); - dashboardPage.startNewApplicationButton().click(); + cy.clickStartNewApplicationButton(); cy.submitInsuranceEligibilityAnswersFromExporterLocationHappyPath({}); diff --git a/e2e-tests/pages/insurance/dashboard/index.js b/e2e-tests/pages/insurance/dashboard/index.js index f46c2d1af0..5e87b49f13 100644 --- a/e2e-tests/pages/insurance/dashboard/index.js +++ b/e2e-tests/pages/insurance/dashboard/index.js @@ -1,6 +1,5 @@ const dashboardPage = { noApplications: () => cy.get('[data-cy="no-applications"]'), - startNewApplicationButton: () => cy.get('[data-cy="start-new-application-button"]'), getAQuoteButton: () => cy.get('[data-cy="get-a-quote-button"]'), table: { headers: { diff --git a/e2e-tests/partials/index.js b/e2e-tests/partials/index.js index acddf3f0e7..4e5fb4650a 100644 --- a/e2e-tests/partials/index.js +++ b/e2e-tests/partials/index.js @@ -27,6 +27,7 @@ const partials = { provideAlternativeCurrencyLink: () => cy.get('[data-cy="provide-alternative-currency-link"]'), privateMarketWhyDescription, skipLink: () => cy.get('[data-cy="skip-link"]'), + startNewApplicationButton: () => cy.get('[data-cy="start-new-application-button"]'), ukGoodsOrServicesCalculateDescription, ukGoodsOrServicesDescription, }; diff --git a/src/api/.keystone/config.js b/src/api/.keystone/config.js index 3846722854..7b892ba9b5 100644 --- a/src/api/.keystone/config.js +++ b/src/api/.keystone/config.js @@ -7252,16 +7252,13 @@ var map_exporter_contact_details_default = mapExporterContactDetails; // generate-xlsx/map-application-to-XLSX/helpers/map-yes-no-field/index.ts var { YES, NO } = FIELD_VALUES; -var mapYesNoField = ({ answer, defaultValue }) => { +var mapYesNoField = ({ answer }) => { if (answer === false) { return NO; } if (answer === true) { return YES; } - if (defaultValue) { - return defaultValue; - } return DEFAULT.EMPTY; }; var map_yes_no_field_default = mapYesNoField; diff --git a/src/api/generate-xlsx/map-application-to-XLSX/helpers/map-yes-no-field/index.test.ts b/src/api/generate-xlsx/map-application-to-XLSX/helpers/map-yes-no-field/index.test.ts index 822513624b..82b4dd7478 100644 --- a/src/api/generate-xlsx/map-application-to-XLSX/helpers/map-yes-no-field/index.test.ts +++ b/src/api/generate-xlsx/map-application-to-XLSX/helpers/map-yes-no-field/index.test.ts @@ -21,17 +21,7 @@ describe('api/generate-xlsx/map-application-to-xlsx/helpers/map-yes-no-field', ( }); }); - describe('when value is undefined and a default value is passed', () => { - it('should return the default value', () => { - const mockDefaultValue = 'Mock default value'; - - const response = mapYesNoField({ defaultValue: mockDefaultValue }); - - expect(response).toEqual(mockDefaultValue); - }); - }); - - describe('when value is "undefined"', () => { + describe('when value is undefined', () => { it(`should return ${DEFAULT.EMPTY}`, () => { const response = mapYesNoField({}); diff --git a/src/api/generate-xlsx/map-application-to-XLSX/helpers/map-yes-no-field/index.ts b/src/api/generate-xlsx/map-application-to-XLSX/helpers/map-yes-no-field/index.ts index b53f44d356..58457935ec 100644 --- a/src/api/generate-xlsx/map-application-to-XLSX/helpers/map-yes-no-field/index.ts +++ b/src/api/generate-xlsx/map-application-to-XLSX/helpers/map-yes-no-field/index.ts @@ -8,10 +8,9 @@ const { YES, NO } = FIELD_VALUES; * mapYesNoField * Map a "true" or "false" field to Yes/No * @param {Boolean} answer: The boolean answer to map into a yes/no string. - * @param {String} defaultValue: Custom default value. * @returns {String} "Yes/No" or DEFAULT.EMPTY */ -const mapYesNoField = ({ answer, defaultValue }: MapYesNoFieldParams): string => { +const mapYesNoField = ({ answer }: MapYesNoFieldParams): string => { if (answer === false) { return NO; } @@ -20,10 +19,6 @@ const mapYesNoField = ({ answer, defaultValue }: MapYesNoFieldParams): string => return YES; } - if (defaultValue) { - return defaultValue; - } - return DEFAULT.EMPTY; }; diff --git a/src/api/test-helpers/applications.ts b/src/api/test-helpers/applications.ts index 11e1231dde..f3ab17a037 100644 --- a/src/api/test-helpers/applications.ts +++ b/src/api/test-helpers/applications.ts @@ -104,7 +104,7 @@ const update = async ({ context, applicationId, data }: TestHelperApplicationUpd /** * deleteAll test helper - * Get all accounts and delete them. + * Get all applications and delete them. * @param {Context} context: KeystoneJS context API * @returns {Array} Accounts that have been deleted */ diff --git a/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/email.ts b/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/email.ts index 898bc92500..5522f71161 100644 --- a/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/email.ts +++ b/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/email.ts @@ -18,7 +18,7 @@ const { * Check submitted form data for errors with the email field * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * @param {Object} errors: Errors from previous validation errors * @returns {ValidationErrors} */ const emailRules = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/first-name.ts b/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/first-name.ts index 365b0cf1c2..5f69d16060 100644 --- a/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/first-name.ts +++ b/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/first-name.ts @@ -18,7 +18,7 @@ const { * Check submitted form data for errors with the first name field * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * @param {Object} errors: Errors from previous validation errors * @returns {ValidationErrors} */ const firstNameRules = (formBody: RequestBody, errors: object) => nameValidation(formBody, FIELD_ID, ERROR_MESSAGE, errors); diff --git a/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/last-name.ts b/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/last-name.ts index 761ac8bf2e..1210f5895e 100644 --- a/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/last-name.ts +++ b/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/last-name.ts @@ -18,7 +18,7 @@ const { * Check submitted form data for errors with the last name field * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * @param {Object} errors: Errors from previous validation errors * @returns {ValidationErrors} nameValidation */ const lastNameRules = (formBody: RequestBody, errors: object) => nameValidation(formBody, FIELD_ID, ERROR_MESSAGE, errors); diff --git a/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/password.ts b/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/password.ts index 148ddfdd46..62dfde078e 100644 --- a/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/password.ts +++ b/src/ui/server/controllers/insurance/account/create/your-details/validation/rules/password.ts @@ -18,7 +18,7 @@ const { * Check submitted form data for errors with the password field * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * @param {Object} errors: Errors from previous validation errors * @returns {ValidationErrors} */ const passwordRules = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/account/password-reset/new-password/validation/rules/password.ts b/src/ui/server/controllers/insurance/account/password-reset/new-password/validation/rules/password.ts index 148ddfdd46..62dfde078e 100644 --- a/src/ui/server/controllers/insurance/account/password-reset/new-password/validation/rules/password.ts +++ b/src/ui/server/controllers/insurance/account/password-reset/new-password/validation/rules/password.ts @@ -18,7 +18,7 @@ const { * Check submitted form data for errors with the password field * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * @param {Object} errors: Errors from previous validation errors * @returns {ValidationErrors} */ const passwordRules = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/account/password-reset/validation/rules/email.ts b/src/ui/server/controllers/insurance/account/password-reset/validation/rules/email.ts index 6de4ca1a1e..2adc4d35ec 100644 --- a/src/ui/server/controllers/insurance/account/password-reset/validation/rules/email.ts +++ b/src/ui/server/controllers/insurance/account/password-reset/validation/rules/email.ts @@ -15,7 +15,7 @@ const { * emailRules * Returns emailValidation * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * @param {Object} errors: Errors from previous validation errors * @returns {ValidationErrors} */ const emailRules = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/account/sign-in/enter-code/validation/rules/access-code.ts b/src/ui/server/controllers/insurance/account/sign-in/enter-code/validation/rules/access-code.ts index 5b89a49faf..f57ebe1e4a 100644 --- a/src/ui/server/controllers/insurance/account/sign-in/enter-code/validation/rules/access-code.ts +++ b/src/ui/server/controllers/insurance/account/sign-in/enter-code/validation/rules/access-code.ts @@ -13,7 +13,7 @@ const { * accessCodeRules * Returns the result of emptyFieldValidation * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * @param {Object} errors: Errors from previous validation errors * @returns {ValidationErrors} */ const accessCodeRules = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.INCORRECT, errors); diff --git a/src/ui/server/controllers/insurance/account/sign-in/validation/rules/email.ts b/src/ui/server/controllers/insurance/account/sign-in/validation/rules/email.ts index 97ca825dcf..2b26d651d6 100644 --- a/src/ui/server/controllers/insurance/account/sign-in/validation/rules/email.ts +++ b/src/ui/server/controllers/insurance/account/sign-in/validation/rules/email.ts @@ -23,7 +23,7 @@ const { * 3) Check if an email is below the minimum length via maxLengthValidation. * If all of the conditions are met, empty errors are returned (via maxLengthValidation). * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * @param {Object} errors: Errors from previous validation errors * @returns {ValidationErrors} emailAndPasswordValidation | maxLengthValidation */ const emailRules = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/account/sign-in/validation/rules/password.ts b/src/ui/server/controllers/insurance/account/sign-in/validation/rules/password.ts index 3f0dfbbdc3..11601b2290 100644 --- a/src/ui/server/controllers/insurance/account/sign-in/validation/rules/password.ts +++ b/src/ui/server/controllers/insurance/account/sign-in/validation/rules/password.ts @@ -12,7 +12,7 @@ const { PASSWORD: FIELD_ID } = FIELD_IDS; * This ensures that a validation error is returned for both EMIL and PASSWORD, * to indicate to a user that the credentials are invalid. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * @param {Object} errors: Errors from previous validation errors * @returns {Function} emailAndPasswordValidation */ const passwordRules = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/business/alternative-trading-address/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/business/alternative-trading-address/save-and-back/index.test.ts index 71ea2df924..b8899b1a0b 100644 --- a/src/ui/server/controllers/insurance/business/alternative-trading-address/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/business/alternative-trading-address/save-and-back/index.test.ts @@ -4,7 +4,7 @@ import { FIELD_IDS } from '..'; import { ROUTES } from '../../../../../constants'; import BUSINESS_FIELD_IDS from '../../../../../constants/field-ids/insurance/business'; import mapAndSave from '../../map-and-save/company-different-trading-address'; -import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; import { Request, Response } from '../../../../../../types'; const { @@ -40,7 +40,7 @@ describe('controllers/insurance/business/alternative-trading-address/save-and-ba await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.companyDifferentTradingAddress once with data from constructPayload', async () => { @@ -66,7 +66,7 @@ describe('controllers/insurance/business/alternative-trading-address/save-and-ba await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should not call mapAndSave.companyDifferentTradingAddress', async () => { diff --git a/src/ui/server/controllers/insurance/business/company-details/save-and-back/index.POST-save-and-back.test.ts b/src/ui/server/controllers/insurance/business/company-details/save-and-back/index.POST-save-and-back.test.ts index c063efbdcb..bdbb6c71ee 100644 --- a/src/ui/server/controllers/insurance/business/company-details/save-and-back/index.POST-save-and-back.test.ts +++ b/src/ui/server/controllers/insurance/business/company-details/save-and-back/index.POST-save-and-back.test.ts @@ -6,7 +6,7 @@ import constructPayload from '../../../../../helpers/construct-payload'; import mapAndSave from '../../map-and-save/company-details'; import api from '../../../../../api'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockApplication, mockCompany, mockPhoneNumbers, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockCompany, mockPhoneNumbers, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { YOUR_COMPANY: { HAS_DIFFERENT_TRADING_NAME, TRADING_ADDRESS, PHONE_NUMBER }, @@ -55,7 +55,7 @@ describe('controllers/insurance/business/companies-details', () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.companyDetails once', async () => { @@ -73,7 +73,7 @@ describe('controllers/insurance/business/companies-details', () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.companyDetails once with the data from constructPayload function and company', async () => { diff --git a/src/ui/server/controllers/insurance/business/credit-control/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/business/credit-control/save-and-back/index.test.ts index bbdc4076b4..084aa129df 100644 --- a/src/ui/server/controllers/insurance/business/credit-control/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/business/credit-control/save-and-back/index.test.ts @@ -4,7 +4,7 @@ import { FIELD_ID } from '..'; import { ROUTES } from '../../../../../constants'; import mapAndSave from '../../map-and-save/business'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = ROUTES.INSURANCE; @@ -37,7 +37,7 @@ describe('controllers/insurance/business/credit-control/save-and-back', () => { it('should redirect to all sections page', async () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.business once with data from constructPayload', async () => { @@ -61,7 +61,7 @@ describe('controllers/insurance/business/credit-control/save-and-back', () => { it('should redirect to all sections page', async () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should NOT call mapAndSave.business', async () => { diff --git a/src/ui/server/controllers/insurance/business/nature-of-business/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/business/nature-of-business/save-and-back/index.test.ts index 755b68a541..0db126c873 100644 --- a/src/ui/server/controllers/insurance/business/nature-of-business/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/business/nature-of-business/save-and-back/index.test.ts @@ -5,7 +5,7 @@ import { ROUTES } from '../../../../../constants'; import BUSINESS_FIELD_IDS from '../../../../../constants/field-ids/insurance/business'; import mapAndSave from '../../map-and-save/business'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockApplication, mockBusinessNatureOfBusiness, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockBusinessNatureOfBusiness, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { NATURE_OF_YOUR_BUSINESS: { YEARS_EXPORTING, EMPLOYEES_UK }, @@ -38,7 +38,7 @@ describe('controllers/insurance/business/nature-of-business/save-and-back', () = await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.business once with data from constructPayload', async () => { @@ -66,7 +66,7 @@ describe('controllers/insurance/business/nature-of-business/save-and-back', () = await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.business once', async () => { diff --git a/src/ui/server/controllers/insurance/business/turnover-currency/validation/rules/alternative-currency.ts b/src/ui/server/controllers/insurance/business/turnover-currency/validation/rules/alternative-currency.ts index 8707e86c17..4b8ef6d4c4 100644 --- a/src/ui/server/controllers/insurance/business/turnover-currency/validation/rules/alternative-currency.ts +++ b/src/ui/server/controllers/insurance/business/turnover-currency/validation/rules/alternative-currency.ts @@ -17,7 +17,7 @@ const { * alternativeCurrencyRule * Returns alternativeCurrencyValidation for the ALTERNATIVE_CURRENCY_CODE field. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * @param {Object} errors: Errors from previous validation errors * @returns {ValidationErrors} */ const alternativeCurrencyRule = (formBody: RequestBody, errors: object) => alternativeCurrencyValidation(formBody, errors, ERROR_MESSAGE.IS_EMPTY); diff --git a/src/ui/server/controllers/insurance/business/turnover-currency/validation/rules/currency.ts b/src/ui/server/controllers/insurance/business/turnover-currency/validation/rules/currency.ts index 8a74182a3e..ebb30f04b4 100644 --- a/src/ui/server/controllers/insurance/business/turnover-currency/validation/rules/currency.ts +++ b/src/ui/server/controllers/insurance/business/turnover-currency/validation/rules/currency.ts @@ -18,7 +18,7 @@ const { * Check submitted form data to see if a currency radio is selected * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * @param {Object} errors: Errors from previous validation errors * @returns {ValidationErrors} */ const currencyRule = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/server/controllers/insurance/business/turnover/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/business/turnover/save-and-back/index.test.ts index 30fbb0aa07..26a6ee99e6 100644 --- a/src/ui/server/controllers/insurance/business/turnover/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/business/turnover/save-and-back/index.test.ts @@ -4,7 +4,7 @@ import { ROUTES } from '../../../../../constants'; import BUSINESS_FIELD_IDS from '../../../../../constants/field-ids/insurance/business'; import constructPayload from '../../../../../helpers/construct-payload'; import mapAndSave from '../../map-and-save/turnover'; -import { mockReq, mockRes, mockApplication, mockBusinessTurnover, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockBusinessTurnover, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; import { Request, Response } from '../../../../../../types'; const { @@ -37,7 +37,7 @@ describe('controllers/insurance/business/turnover/save-and-back', () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.turnover once with the data from constructPayload function', async () => { @@ -65,7 +65,7 @@ describe('controllers/insurance/business/turnover/save-and-back', () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.turnover once', async () => { diff --git a/src/ui/server/controllers/insurance/check-your-answers/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/check-your-answers/save-and-back/index.test.ts index 13147f284b..cf07047164 100644 --- a/src/ui/server/controllers/insurance/check-your-answers/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/check-your-answers/save-and-back/index.test.ts @@ -5,7 +5,7 @@ import constructPayload from '../../../../helpers/construct-payload'; import stripEmptyFormFields from '../../../../helpers/strip-empty-form-fields'; import save from '../save-data'; import { Request, Response } from '../../../../../types'; -import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection } from '../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection, referenceNumber } from '../../../../test-mocks'; const { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = INSURANCE_ROUTES; @@ -49,7 +49,7 @@ describe('controllers/insurance/check-your-answers/save-and-back', () => { it('should redirect to all sections page', async () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); describe('when there is no application', () => { diff --git a/src/ui/server/controllers/insurance/complete-other-sections/index.test.ts b/src/ui/server/controllers/insurance/complete-other-sections/index.test.ts index 6e5780e8b9..ca41683663 100644 --- a/src/ui/server/controllers/insurance/complete-other-sections/index.test.ts +++ b/src/ui/server/controllers/insurance/complete-other-sections/index.test.ts @@ -4,7 +4,7 @@ import { ROUTES, TEMPLATES } from '../../../constants'; import insuranceCorePageVariables from '../../../helpers/page-variables/core/insurance'; import getUserNameFromSession from '../../../helpers/get-user-name-from-session'; import { Request, Response } from '../../../../types'; -import { mockReq, mockRes } from '../../../test-mocks'; +import { mockReq, mockRes, referenceNumber } from '../../../test-mocks'; const { INSURANCE: { INSURANCE_ROOT, ALL_SECTIONS }, @@ -35,7 +35,7 @@ describe('controllers/insurance/all-sections', () => { BACK_LINK: req.headers.referer, }), userName: getUserNameFromSession(req.session.user), - TASK_LIST_URL: `${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`, + TASK_LIST_URL: `${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`, }; expect(res.render).toHaveBeenCalledWith(TEMPLATE, expectedVariables); diff --git a/src/ui/server/controllers/insurance/export-contract/about-goods-or-services/validation/rules/description.ts b/src/ui/server/controllers/insurance/export-contract/about-goods-or-services/validation/rules/description.ts index 07f612f2c4..58339dc6b6 100644 --- a/src/ui/server/controllers/insurance/export-contract/about-goods-or-services/validation/rules/description.ts +++ b/src/ui/server/controllers/insurance/export-contract/about-goods-or-services/validation/rules/description.ts @@ -25,7 +25,7 @@ export const MAXIMUM = 1000; * Check submitted form data for errors with the description field * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * @param {Object} errors: Errors from previous validation errors * @returns {ValidationErrors} */ const descriptionRules = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/export-contract/about-goods-or-services/validation/rules/final-destination.ts b/src/ui/server/controllers/insurance/export-contract/about-goods-or-services/validation/rules/final-destination.ts index ba4d0b9eda..00570f684b 100644 --- a/src/ui/server/controllers/insurance/export-contract/about-goods-or-services/validation/rules/final-destination.ts +++ b/src/ui/server/controllers/insurance/export-contract/about-goods-or-services/validation/rules/final-destination.ts @@ -20,7 +20,7 @@ const { * If FINAL_DESTINATION_KNOWN is true, return emptyFieldValidation for the FINAL_DESTINATION field. * Otherwise, return FINAL_DESTINATION for the FINAL_DESTINATION_KNOWN field. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * @param {Object} errors: Errors from previous validation errors * @returns {ValidationErrors} */ const finalDestinationRules = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/export-contract/agent-charges/alternative-currency/validation/rules/alternative-currency.ts b/src/ui/server/controllers/insurance/export-contract/agent-charges/alternative-currency/validation/rules/alternative-currency.ts index 79a3bd653d..8d93f0dff7 100644 --- a/src/ui/server/controllers/insurance/export-contract/agent-charges/alternative-currency/validation/rules/alternative-currency.ts +++ b/src/ui/server/controllers/insurance/export-contract/agent-charges/alternative-currency/validation/rules/alternative-currency.ts @@ -19,7 +19,7 @@ const { * alternativeCurrencyRule * Returns alternativeCurrencyValidation for the ALTERNATIVE_CURRENCY_CODE field. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const alternativeCurrencyRule = (formBody: RequestBody, errors: object) => alternativeCurrencyValidation(formBody, errors, ERROR_MESSAGE.IS_EMPTY); diff --git a/src/ui/server/controllers/insurance/export-contract/agent-charges/alternative-currency/validation/rules/currency.ts b/src/ui/server/controllers/insurance/export-contract/agent-charges/alternative-currency/validation/rules/currency.ts index 6c669b2072..0f3174f426 100644 --- a/src/ui/server/controllers/insurance/export-contract/agent-charges/alternative-currency/validation/rules/currency.ts +++ b/src/ui/server/controllers/insurance/export-contract/agent-charges/alternative-currency/validation/rules/currency.ts @@ -20,7 +20,7 @@ const { * Check submitted form data to see if currency radio is selected * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const currencyRule = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/server/controllers/insurance/export-contract/agent-service/index.test.ts b/src/ui/server/controllers/insurance/export-contract/agent-service/index.test.ts index 713c60b88c..1cc456c7b7 100644 --- a/src/ui/server/controllers/insurance/export-contract/agent-service/index.test.ts +++ b/src/ui/server/controllers/insurance/export-contract/agent-service/index.test.ts @@ -12,7 +12,7 @@ import generateValidationErrors from './validation'; import mapAndSave from '../map-and-save/export-contract-agent-service'; import { sanitiseData } from '../../../../helpers/sanitise-data'; import { Request, Response } from '../../../../../types'; -import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection } from '../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection, referenceNumber } from '../../../../test-mocks'; const { INSURANCE_ROOT, @@ -33,8 +33,6 @@ const { AGENT_SERVICE: { IS_CHARGING, SERVICE_DESCRIPTION }, } = EXPORT_CONTRACT_FIELD_IDS; -const { referenceNumber } = mockApplication; - describe('controllers/insurance/export-contract/agent-service', () => { let req: Request; let res: Response; @@ -221,7 +219,7 @@ describe('controllers/insurance/export-contract/agent-service', () => { await post(req, res); - const expected = `${INSURANCE_ROOT}/${req.params.referenceNumber}${AGENT_CHARGES}`; + const expected = `${INSURANCE_ROOT}/${referenceNumber}${AGENT_CHARGES}`; expect(res.redirect).toHaveBeenCalledWith(expected); }); diff --git a/src/ui/server/controllers/insurance/export-contract/how-was-the-contract-awarded/validation/rules/award-method.ts b/src/ui/server/controllers/insurance/export-contract/how-was-the-contract-awarded/validation/rules/award-method.ts index d15a1bb8e0..19ca66fcb2 100644 --- a/src/ui/server/controllers/insurance/export-contract/how-was-the-contract-awarded/validation/rules/award-method.ts +++ b/src/ui/server/controllers/insurance/export-contract/how-was-the-contract-awarded/validation/rules/award-method.ts @@ -19,7 +19,7 @@ const { * awardMethodRule * Returns emptyFieldValidation for the AWARD_METHOD field. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const awardMethodRule = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGES_OBJECT.IS_EMPTY, errors); diff --git a/src/ui/server/controllers/insurance/export-contract/how-was-the-contract-awarded/validation/rules/other-award-method.ts b/src/ui/server/controllers/insurance/export-contract/how-was-the-contract-awarded/validation/rules/other-award-method.ts index 3c10fa71dc..3a21f2ab58 100644 --- a/src/ui/server/controllers/insurance/export-contract/how-was-the-contract-awarded/validation/rules/other-award-method.ts +++ b/src/ui/server/controllers/insurance/export-contract/how-was-the-contract-awarded/validation/rules/other-award-method.ts @@ -20,7 +20,7 @@ const { * otherAwardMethodRule * if AWARD_METHOD is "OTHER", return providedAndMaxLength for the OTHER_AWARD_METHOD field. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const otherAwardMethodRule = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/policy/another-company/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/policy/another-company/save-and-back/index.test.ts index ee1358b44d..8c23f2fd0f 100644 --- a/src/ui/server/controllers/insurance/policy/another-company/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/policy/another-company/save-and-back/index.test.ts @@ -4,7 +4,7 @@ import { ROUTES } from '../../../../../constants'; import constructPayload from '../../../../../helpers/construct-payload'; import mapAndSave from '../../map-and-save/jointly-insured-party'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = ROUTES.INSURANCE; @@ -35,7 +35,7 @@ describe('controllers/insurance/policy/another-company/save-and-back', () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.jointlyInsuredParty once with data from constructPayload function', async () => { @@ -61,7 +61,7 @@ describe('controllers/insurance/policy/another-company/save-and-back', () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should NOT call mapAndSave.jointlyInsuredParty', async () => { diff --git a/src/ui/server/controllers/insurance/policy/broker-details/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/policy/broker-details/save-and-back/index.test.ts index 2f1026ae65..dde8f0d46a 100644 --- a/src/ui/server/controllers/insurance/policy/broker-details/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/policy/broker-details/save-and-back/index.test.ts @@ -6,7 +6,7 @@ import generateValidationErrors from '../validation'; import mapAndSave from '../../map-and-save/broker'; import { FIELD_IDS } from '..'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { USING_BROKER } = POLICY_FIELD_IDS; @@ -39,7 +39,7 @@ describe('controllers/insurance/policy/broker-details/save-and-back', () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.broker once with data from constructPayload function', async () => { @@ -64,7 +64,7 @@ describe('controllers/insurance/policy/broker-details/save-and-back', () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.broker once', async () => { diff --git a/src/ui/server/controllers/insurance/policy/broker/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/policy/broker/save-and-back/index.test.ts index de524997d0..e93984edce 100644 --- a/src/ui/server/controllers/insurance/policy/broker/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/policy/broker/save-and-back/index.test.ts @@ -6,7 +6,7 @@ import constructPayload from '../../../../../helpers/construct-payload'; import generateValidationErrors from '../../../../../shared-validation/yes-no-radios-form'; import mapAndSave from '../../map-and-save/broker'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { USING_BROKER } = POLICY_FIELD_IDS; @@ -39,7 +39,7 @@ describe('controllers/insurance/policy/broker/save-and-back', () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.broker once with data from constructPayload function', async () => { @@ -64,7 +64,7 @@ describe('controllers/insurance/policy/broker/save-and-back', () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.broker once', async () => { diff --git a/src/ui/server/controllers/insurance/policy/loss-payee-details/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/policy/loss-payee-details/save-and-back/index.test.ts index 5d3112878b..cd9eb9bf7d 100644 --- a/src/ui/server/controllers/insurance/policy/loss-payee-details/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/policy/loss-payee-details/save-and-back/index.test.ts @@ -6,7 +6,7 @@ import constructPayload from '../../../../../helpers/construct-payload'; import generateValidationErrors from '../validation'; import mapAndSave from '../../map-and-save/loss-payee'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { LOSS_PAYEE_DETAILS: { NAME }, @@ -41,7 +41,7 @@ describe('controllers/insurance/policy/loss-payee-details/save-and-back', () => await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.lossPayee once with data from constructPayload function', async () => { @@ -66,7 +66,7 @@ describe('controllers/insurance/policy/loss-payee-details/save-and-back', () => await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.lossPayee once', async () => { diff --git a/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-international/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-international/save-and-back/index.test.ts index d7143a6944..fa1dfd9ffb 100644 --- a/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-international/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-international/save-and-back/index.test.ts @@ -5,7 +5,14 @@ import constructPayload from '../../../../../helpers/construct-payload'; import generateValidationErrors from '../validation'; import mapAndSave from '../../map-and-save/loss-payee-financial-details-international'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockApplication, mockLossPayeeFinancialDetailsInternational, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { + mockReq, + mockRes, + mockApplication, + mockLossPayeeFinancialDetailsInternational, + mockSpyPromiseRejection, + referenceNumber, +} from '../../../../../test-mocks'; const { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = ROUTES.INSURANCE; @@ -34,7 +41,7 @@ describe('controllers/insurance/policy/loss-payee-financial-details-internationa await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.lossPayeeFinancialDetailsInternational once with data from constructPayload function', async () => { @@ -59,7 +66,7 @@ describe('controllers/insurance/policy/loss-payee-financial-details-internationa await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.lossPayeeFinancialDetailsInternational once', async () => { diff --git a/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-uk/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-uk/save-and-back/index.test.ts index 2866dff54f..7de90ac07c 100644 --- a/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-uk/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-uk/save-and-back/index.test.ts @@ -5,7 +5,7 @@ import constructPayload from '../../../../../helpers/construct-payload'; import generateValidationErrors from '../validation'; import mapAndSave from '../../map-and-save/loss-payee-financial-details-uk'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockApplication, mockLossPayeeFinancialDetailsUk, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockLossPayeeFinancialDetailsUk, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = ROUTES.INSURANCE; @@ -34,7 +34,7 @@ describe('controllers/insurance/policy/loss-payee-financial-details-uk/save-and- await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.lossPayeeFinancialDetailsUk once with data from constructPayload function', async () => { @@ -59,7 +59,7 @@ describe('controllers/insurance/policy/loss-payee-financial-details-uk/save-and- await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.lossPayeeFinancialDetailsUk once', async () => { diff --git a/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-uk/validation/rules/account-number.ts b/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-uk/validation/rules/account-number.ts index 0af5ae75ed..0167ba4fa6 100644 --- a/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-uk/validation/rules/account-number.ts +++ b/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-uk/validation/rules/account-number.ts @@ -17,7 +17,7 @@ export const MINIMUM = Number(MINIMUM_CHARACTERS.ACCOUNT_NUMBER); * Check submitted form data for errors for the account number field * Returns numberAboveMinimumValidation if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {Object} numberMinimumMaximumLength errors */ const accountNumberRules = (formBody: RequestBody, errors: object) => diff --git a/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-uk/validation/rules/sort-code.ts b/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-uk/validation/rules/sort-code.ts index 45201a71ac..3d4d84c9cf 100644 --- a/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-uk/validation/rules/sort-code.ts +++ b/src/ui/server/controllers/insurance/policy/loss-payee-financial-details-uk/validation/rules/sort-code.ts @@ -13,7 +13,7 @@ const { [FIELD_ID]: ERROR_MESSAGES_OBJECT } = ERROR_MESSAGES.INSURANCE.POLICY; * Check submitted form data for errors for the sort code field * Returns numberHyphenSpacesOnlyValidation if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {Object} numberHyphenSpacesOnlyValidation errors */ const sortCodeRules = (formBody: RequestBody, errors: object) => diff --git a/src/ui/server/controllers/insurance/policy/loss-payee/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/policy/loss-payee/save-and-back/index.test.ts index 4e20b9cfd0..0d2284390b 100644 --- a/src/ui/server/controllers/insurance/policy/loss-payee/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/policy/loss-payee/save-and-back/index.test.ts @@ -6,7 +6,7 @@ import constructPayload from '../../../../../helpers/construct-payload'; import generateValidationErrors from '../../../../../shared-validation/yes-no-radios-form'; import mapAndSave from '../../map-and-save/loss-payee'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { LOSS_PAYEE: { IS_APPOINTED }, @@ -41,7 +41,7 @@ describe('controllers/insurance/policy/loss-payee/save-and-back', () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.lossPayee once with data from constructPayload function', async () => { @@ -66,7 +66,7 @@ describe('controllers/insurance/policy/loss-payee/save-and-back', () => { await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.lossPayee once', async () => { diff --git a/src/ui/server/controllers/insurance/policy/multiple-contract-policy/export-value/validation/rules/maximum-buyer-will-owe.ts b/src/ui/server/controllers/insurance/policy/multiple-contract-policy/export-value/validation/rules/maximum-buyer-will-owe.ts index f3c980be80..5694ab410c 100644 --- a/src/ui/server/controllers/insurance/policy/multiple-contract-policy/export-value/validation/rules/maximum-buyer-will-owe.ts +++ b/src/ui/server/controllers/insurance/policy/multiple-contract-policy/export-value/validation/rules/maximum-buyer-will-owe.ts @@ -28,7 +28,7 @@ export const MINIMUM = 1; * Check submitted form data for errors with the maximum buyer will owe field * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const maximumBuyerWillOweRules = (formBody: RequestBody, errors: object) => diff --git a/src/ui/server/controllers/insurance/policy/multiple-contract-policy/export-value/validation/rules/total-sales-to-buyer.ts b/src/ui/server/controllers/insurance/policy/multiple-contract-policy/export-value/validation/rules/total-sales-to-buyer.ts index e569a270fc..463c4123d3 100644 --- a/src/ui/server/controllers/insurance/policy/multiple-contract-policy/export-value/validation/rules/total-sales-to-buyer.ts +++ b/src/ui/server/controllers/insurance/policy/multiple-contract-policy/export-value/validation/rules/total-sales-to-buyer.ts @@ -28,7 +28,7 @@ export const MINIMUM = 1; * Check submitted form data for errors with the total sales to buyer field * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const totalSalesToBuyerRules = (formBody: RequestBody, errors: object) => diff --git a/src/ui/server/controllers/insurance/policy/multiple-contract-policy/index.test.ts b/src/ui/server/controllers/insurance/policy/multiple-contract-policy/index.test.ts index c9250bb558..a19c569d37 100644 --- a/src/ui/server/controllers/insurance/policy/multiple-contract-policy/index.test.ts +++ b/src/ui/server/controllers/insurance/policy/multiple-contract-policy/index.test.ts @@ -1,4 +1,4 @@ -import { pageVariables, TEMPLATE, FIELD_IDS, totalMonthsOfCoverOptions, get, post } from '.'; +import { pageVariables, TEMPLATE, FIELD_IDS, get, post } from '.'; import { GBP_CURRENCY_CODE, TEMPLATES } from '../../../../constants'; import { INSURANCE_ROUTES } from '../../../../constants/routes/insurance'; import INSURANCE_FIELD_IDS from '../../../../constants/field-ids/insurance'; @@ -129,14 +129,6 @@ describe('controllers/insurance/policy/multiple-contract-policy', () => { }); }); - describe('totalMonthsOfCoverOptions', () => { - it('should have the correct array of months', () => { - const expected = FIELDS.CONTRACT_POLICY.MULTIPLE[TOTAL_MONTHS_OF_COVER].OPTIONS; - - expect(totalMonthsOfCoverOptions).toEqual(expected); - }); - }); - describe('FIELD_IDS', () => { it('should have the correct FIELD_IDS', () => { const expected = [ diff --git a/src/ui/server/controllers/insurance/policy/multiple-contract-policy/index.ts b/src/ui/server/controllers/insurance/policy/multiple-contract-policy/index.ts index bf91b5e5dd..3e33190d2f 100644 --- a/src/ui/server/controllers/insurance/policy/multiple-contract-policy/index.ts +++ b/src/ui/server/controllers/insurance/policy/multiple-contract-policy/index.ts @@ -85,8 +85,6 @@ export const FIELD_IDS = [ ALTERNATIVE_CURRENCY_CODE, ]; -export const totalMonthsOfCoverOptions = FIELDS.CONTRACT_POLICY.MULTIPLE[TOTAL_MONTHS_OF_COVER].OPTIONS; - /** * get * Render the Multiple contract policy page diff --git a/src/ui/server/controllers/insurance/policy/multiple-contract-policy/validation/rules/total-months-of-cover.ts b/src/ui/server/controllers/insurance/policy/multiple-contract-policy/validation/rules/total-months-of-cover.ts index d766ff0dff..67d04f425c 100644 --- a/src/ui/server/controllers/insurance/policy/multiple-contract-policy/validation/rules/total-months-of-cover.ts +++ b/src/ui/server/controllers/insurance/policy/multiple-contract-policy/validation/rules/total-months-of-cover.ts @@ -32,7 +32,7 @@ export const MAXIMUM = APPLICATION.POLICY.TOTAL_MONTHS_OF_COVER; * totalMonthsOfCoverRules * Returns the result of emptyFieldValidation * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const totalMonthsOfCoverRules = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/policy/name-on-policy/validation/rules/name-on-policy.ts b/src/ui/server/controllers/insurance/policy/name-on-policy/validation/rules/name-on-policy.ts index d1f1a5194b..c9b0c8ffb0 100644 --- a/src/ui/server/controllers/insurance/policy/name-on-policy/validation/rules/name-on-policy.ts +++ b/src/ui/server/controllers/insurance/policy/name-on-policy/validation/rules/name-on-policy.ts @@ -21,7 +21,7 @@ const { * nameOnPolicyRule * Returns the result of emptyFieldValidation * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const nameOnPolicyRule = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/server/controllers/insurance/policy/name-on-policy/validation/rules/position.ts b/src/ui/server/controllers/insurance/policy/name-on-policy/validation/rules/position.ts index b21dcad694..0edc51a519 100644 --- a/src/ui/server/controllers/insurance/policy/name-on-policy/validation/rules/position.ts +++ b/src/ui/server/controllers/insurance/policy/name-on-policy/validation/rules/position.ts @@ -27,7 +27,7 @@ const MAXIMUM = Number(NAME_ON_POLICY[FIELD_ID].MAXIMUM); * Returns the result of emptyFieldValidation if SAME_NAME is selected * else returns provided errors object * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const positionRule = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/policy/other-company-details/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/policy/other-company-details/save-and-back/index.test.ts index 81c8040955..e4537349ad 100644 --- a/src/ui/server/controllers/insurance/policy/other-company-details/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/policy/other-company-details/save-and-back/index.test.ts @@ -4,7 +4,7 @@ import { ROUTES } from '../../../../../constants/routes'; import constructPayload from '../../../../../helpers/construct-payload'; import mapAndSave from '../../map-and-save/jointly-insured-party'; import generateValidationErrors from '../validation'; -import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; import { Request, Response } from '../../../../../../types'; const { INSURANCE_ROOT, ALL_SECTIONS, PROBLEM_WITH_SERVICE } = ROUTES.INSURANCE; @@ -44,7 +44,7 @@ describe('controllers/insurance/policy/other-company-details/save-and-back', () }); it('should redirect to all sections page', () => { - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.jointlyInsuredParty once with data from constructPayload function', () => { @@ -70,7 +70,7 @@ describe('controllers/insurance/policy/other-company-details/save-and-back', () }); it('should redirect to all sections page', () => { - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.jointlyInsuredParty once with data from constructPayload function and validation errors', () => { diff --git a/src/ui/server/controllers/insurance/policy/pre-credit-period/validation/rules/credit-period-with-buyer-description.ts b/src/ui/server/controllers/insurance/policy/pre-credit-period/validation/rules/credit-period-with-buyer-description.ts index 92dc704434..0f973dd254 100644 --- a/src/ui/server/controllers/insurance/policy/pre-credit-period/validation/rules/credit-period-with-buyer-description.ts +++ b/src/ui/server/controllers/insurance/policy/pre-credit-period/validation/rules/credit-period-with-buyer-description.ts @@ -19,7 +19,7 @@ const { * Returns the result of emptyFieldValidation if NEED_PRE_CREDIT_PERIOD is true * else returns provided errors object * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const creditPeriodWithBuyerRule = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/policy/pre-credit-period/validation/rules/pre-credit-period.ts b/src/ui/server/controllers/insurance/policy/pre-credit-period/validation/rules/pre-credit-period.ts index daae45514f..a1d8096e3f 100644 --- a/src/ui/server/controllers/insurance/policy/pre-credit-period/validation/rules/pre-credit-period.ts +++ b/src/ui/server/controllers/insurance/policy/pre-credit-period/validation/rules/pre-credit-period.ts @@ -17,7 +17,7 @@ const { * preCreditPeriodRule * Returns the result of emptyFieldValidation * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const preCreditPeriodRule = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/server/controllers/insurance/policy/single-contract-policy/total-contract-value/validation/rules/total-contract-value.ts b/src/ui/server/controllers/insurance/policy/single-contract-policy/total-contract-value/validation/rules/total-contract-value.ts index bdf20debe6..22d185938f 100644 --- a/src/ui/server/controllers/insurance/policy/single-contract-policy/total-contract-value/validation/rules/total-contract-value.ts +++ b/src/ui/server/controllers/insurance/policy/single-contract-policy/total-contract-value/validation/rules/total-contract-value.ts @@ -29,7 +29,7 @@ const { * Check submitted form data for errors with the total contract value field * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const totalContractValueRules = (formBody: RequestBody, errors: object) => diff --git a/src/ui/server/controllers/insurance/policy/single-contract-policy/validation/rules/contract-completion-date.ts b/src/ui/server/controllers/insurance/policy/single-contract-policy/validation/rules/contract-completion-date.ts index 5dfafd773d..a7489c3401 100644 --- a/src/ui/server/controllers/insurance/policy/single-contract-policy/validation/rules/contract-completion-date.ts +++ b/src/ui/server/controllers/insurance/policy/single-contract-policy/validation/rules/contract-completion-date.ts @@ -46,7 +46,7 @@ const getDateInputValues = (formBody: RequestBody) => ({ * Check submitted form data for errors with the requested start date field * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const contractCompletionDateRules = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/your-buyer/alternative-currency/validation/rules/alternative-currency.ts b/src/ui/server/controllers/insurance/your-buyer/alternative-currency/validation/rules/alternative-currency.ts index 20eef1013f..4c95998d62 100644 --- a/src/ui/server/controllers/insurance/your-buyer/alternative-currency/validation/rules/alternative-currency.ts +++ b/src/ui/server/controllers/insurance/your-buyer/alternative-currency/validation/rules/alternative-currency.ts @@ -17,7 +17,7 @@ const { * alternativeCurrencyRule * Returns alternativeCurrencyValidation for the ALTERNATIVE_CURRENCY_CODE field. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const alternativeCurrencyRule = (formBody: RequestBody, errors: object) => alternativeCurrencyValidation(formBody, errors, ERROR_MESSAGE.IS_EMPTY); diff --git a/src/ui/server/controllers/insurance/your-buyer/alternative-currency/validation/rules/currency.ts b/src/ui/server/controllers/insurance/your-buyer/alternative-currency/validation/rules/currency.ts index 1b6e70e5ba..fa812f66d7 100644 --- a/src/ui/server/controllers/insurance/your-buyer/alternative-currency/validation/rules/currency.ts +++ b/src/ui/server/controllers/insurance/your-buyer/alternative-currency/validation/rules/currency.ts @@ -18,7 +18,7 @@ const { * Check submitted form data to see if currency radio is selected * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const currencyRule = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/server/controllers/insurance/your-buyer/buyer-financial-information/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/your-buyer/buyer-financial-information/save-and-back/index.test.ts index a0cd4d762e..3639862156 100644 --- a/src/ui/server/controllers/insurance/your-buyer/buyer-financial-information/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/your-buyer/buyer-financial-information/save-and-back/index.test.ts @@ -6,7 +6,7 @@ import BUYER_FIELD_IDS from '../../../../../constants/field-ids/insurance/your-b import constructPayload from '../../../../../helpers/construct-payload'; import generateValidationErrors from '../validation'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { HAS_BUYER_FINANCIAL_ACCOUNTS } = BUYER_FIELD_IDS; @@ -39,7 +39,7 @@ describe('controllers/insurance/your-buyer/buyer-financial-information/save-and- await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.buyerRelationship once with data from constructPayload function', async () => { @@ -62,7 +62,7 @@ describe('controllers/insurance/your-buyer/buyer-financial-information/save-and- await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.buyerRelationship once with data from constructPayload function', async () => { diff --git a/src/ui/server/controllers/insurance/your-buyer/buyer-financial-information/validation/rules/buyer-financial-information.ts b/src/ui/server/controllers/insurance/your-buyer/buyer-financial-information/validation/rules/buyer-financial-information.ts index 09f6a81ede..9e0e8c83e1 100644 --- a/src/ui/server/controllers/insurance/your-buyer/buyer-financial-information/validation/rules/buyer-financial-information.ts +++ b/src/ui/server/controllers/insurance/your-buyer/buyer-financial-information/validation/rules/buyer-financial-information.ts @@ -16,7 +16,7 @@ const { * Check submitted form data to see if buyer financial information field radio is selected * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const buyerFinancialInformationRule = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/server/controllers/insurance/your-buyer/company-or-organisation/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/your-buyer/company-or-organisation/save-and-back/index.test.ts index 2e7aabc963..59cced345b 100644 --- a/src/ui/server/controllers/insurance/your-buyer/company-or-organisation/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/your-buyer/company-or-organisation/save-and-back/index.test.ts @@ -6,7 +6,7 @@ import INSURANCE_FIELD_IDS from '../../../../../constants/field-ids/insurance'; import constructPayload from '../../../../../helpers/construct-payload'; import generateValidationErrors from '../validation'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockBuyer, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockBuyer, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { COMPANY_OR_ORGANISATION: { NAME }, @@ -40,7 +40,7 @@ describe('controllers/insurance/your-buyer/company-or-organisation/save-and-back await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.yourBuyer once with data from constructPayload function', async () => { @@ -65,7 +65,7 @@ describe('controllers/insurance/your-buyer/company-or-organisation/save-and-back await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.yourBuyer once with data from constructPayload function', async () => { diff --git a/src/ui/server/controllers/insurance/your-buyer/company-or-organisation/validation/rules/website.ts b/src/ui/server/controllers/insurance/your-buyer/company-or-organisation/validation/rules/website.ts index 388b2f7409..d591475d9f 100644 --- a/src/ui/server/controllers/insurance/your-buyer/company-or-organisation/validation/rules/website.ts +++ b/src/ui/server/controllers/insurance/your-buyer/company-or-organisation/validation/rules/website.ts @@ -22,7 +22,7 @@ const { * Check submitted form data for errors with the website field * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const websiteRule = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/your-buyer/connection-with-buyer/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/your-buyer/connection-with-buyer/save-and-back/index.test.ts index ce03c8c1be..f07adfbef6 100644 --- a/src/ui/server/controllers/insurance/your-buyer/connection-with-buyer/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/your-buyer/connection-with-buyer/save-and-back/index.test.ts @@ -6,7 +6,7 @@ import INSURANCE_FIELD_IDS from '../../../../../constants/field-ids/insurance'; import constructPayload from '../../../../../helpers/construct-payload'; import generateValidationErrors from '../validation'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockBuyer, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockBuyer, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { CONNECTION_WITH_BUYER, CONNECTION_WITH_BUYER_DESCRIPTION } = INSURANCE_FIELD_IDS.YOUR_BUYER; @@ -42,7 +42,7 @@ describe('controllers/insurance/your-buyer/connection-with-buyer/save-and-back', await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.yourBuyer once with data from constructPayload function', async () => { @@ -65,7 +65,7 @@ describe('controllers/insurance/your-buyer/connection-with-buyer/save-and-back', await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.yourBuyer once with data from constructPayload function', async () => { diff --git a/src/ui/server/controllers/insurance/your-buyer/connection-with-buyer/validation/rules/connection-with-buyer-description.ts b/src/ui/server/controllers/insurance/your-buyer/connection-with-buyer/validation/rules/connection-with-buyer-description.ts index c027d2de5e..c7c779c913 100644 --- a/src/ui/server/controllers/insurance/your-buyer/connection-with-buyer/validation/rules/connection-with-buyer-description.ts +++ b/src/ui/server/controllers/insurance/your-buyer/connection-with-buyer/validation/rules/connection-with-buyer-description.ts @@ -21,7 +21,7 @@ const { * Returns generateValidationErrors if input is empty. * Returns inputValidation if field is not empty * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const connectionWithBuyerDescriptionRule = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/your-buyer/connection-with-buyer/validation/rules/connection-with-buyer.ts b/src/ui/server/controllers/insurance/your-buyer/connection-with-buyer/validation/rules/connection-with-buyer.ts index 048c4abd91..cb20f02e1b 100644 --- a/src/ui/server/controllers/insurance/your-buyer/connection-with-buyer/validation/rules/connection-with-buyer.ts +++ b/src/ui/server/controllers/insurance/your-buyer/connection-with-buyer/validation/rules/connection-with-buyer.ts @@ -20,7 +20,7 @@ const { * Check submitted form data to see if connected to buyer field radio is selected * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const connectionWithBuyerRule = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/server/controllers/insurance/your-buyer/credit-insurance-cover/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/your-buyer/credit-insurance-cover/save-and-back/index.test.ts index 716f2c7c7d..de1def19e9 100644 --- a/src/ui/server/controllers/insurance/your-buyer/credit-insurance-cover/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/your-buyer/credit-insurance-cover/save-and-back/index.test.ts @@ -6,7 +6,7 @@ import BUYER_FIELD_IDS from '../../../../../constants/field-ids/insurance/your-b import constructPayload from '../../../../../helpers/construct-payload'; import generateValidationErrors from '../validation'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER, PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER } = BUYER_FIELD_IDS; @@ -39,7 +39,7 @@ describe('controllers/insurance/your-buyer/credit-insurance-information/save-and await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.buyerRelationship once with data from constructPayload function', async () => { @@ -62,7 +62,7 @@ describe('controllers/insurance/your-buyer/credit-insurance-information/save-and await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.buyerRelationship once with data from constructPayload function', async () => { diff --git a/src/ui/server/controllers/insurance/your-buyer/credit-insurance-cover/validation/rules/credit-insurance-cover-description.ts b/src/ui/server/controllers/insurance/your-buyer/credit-insurance-cover/validation/rules/credit-insurance-cover-description.ts index c8e2666d33..b9725c7270 100644 --- a/src/ui/server/controllers/insurance/your-buyer/credit-insurance-cover/validation/rules/credit-insurance-cover-description.ts +++ b/src/ui/server/controllers/insurance/your-buyer/credit-insurance-cover/validation/rules/credit-insurance-cover-description.ts @@ -18,7 +18,7 @@ const { * Returns generateValidationErrors if input is empty. * Returns inputValidation if field is not empty * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const creditInsuranceCoverDescriptionRule = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/your-buyer/credit-insurance-cover/validation/rules/credit-insurance-cover.ts b/src/ui/server/controllers/insurance/your-buyer/credit-insurance-cover/validation/rules/credit-insurance-cover.ts index 0885313db2..9837b7f794 100644 --- a/src/ui/server/controllers/insurance/your-buyer/credit-insurance-cover/validation/rules/credit-insurance-cover.ts +++ b/src/ui/server/controllers/insurance/your-buyer/credit-insurance-cover/validation/rules/credit-insurance-cover.ts @@ -20,7 +20,7 @@ const { * Check submitted form data to see if credit insurance cover field radio is selected * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const creditInsuranceCoverRule = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/server/controllers/insurance/your-buyer/traded-with-buyer/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/your-buyer/traded-with-buyer/save-and-back/index.test.ts index 2bf5d105ff..8e86486585 100644 --- a/src/ui/server/controllers/insurance/your-buyer/traded-with-buyer/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/your-buyer/traded-with-buyer/save-and-back/index.test.ts @@ -6,7 +6,7 @@ import constructPayload from '../../../../../helpers/construct-payload'; import generateValidationErrors from '../validation'; import mapAndSave from '../../map-and-save/buyer-trading-history'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockBuyer, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockBuyer, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { CONNECTION_WITH_BUYER, TRADED_WITH_BUYER } = INSURANCE_FIELD_IDS.YOUR_BUYER; @@ -40,7 +40,7 @@ describe('controllers/insurance/your-buyer/working-with-buyer/save-and-back', () await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.yourBuyer once with data from constructPayload function', async () => { @@ -65,7 +65,7 @@ describe('controllers/insurance/your-buyer/working-with-buyer/save-and-back', () await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.yourBuyer once with data from constructPayload function', async () => { diff --git a/src/ui/server/controllers/insurance/your-buyer/traded-with-buyer/validation/rules/traded-with-buyer.ts b/src/ui/server/controllers/insurance/your-buyer/traded-with-buyer/validation/rules/traded-with-buyer.ts index 16fd5edef7..91f9fb43eb 100644 --- a/src/ui/server/controllers/insurance/your-buyer/traded-with-buyer/validation/rules/traded-with-buyer.ts +++ b/src/ui/server/controllers/insurance/your-buyer/traded-with-buyer/validation/rules/traded-with-buyer.ts @@ -20,7 +20,7 @@ const { * Check submitted form data to see if traded with buyer field radio is selected * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const tradedWithBuyerRule = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/server/controllers/insurance/your-buyer/trading-history/save-and-back/index.test.ts b/src/ui/server/controllers/insurance/your-buyer/trading-history/save-and-back/index.test.ts index 88e64e6663..ce9ab45399 100644 --- a/src/ui/server/controllers/insurance/your-buyer/trading-history/save-and-back/index.test.ts +++ b/src/ui/server/controllers/insurance/your-buyer/trading-history/save-and-back/index.test.ts @@ -6,7 +6,7 @@ import constructPayload from '../../../../../helpers/construct-payload'; import generateValidationErrors from '../validation'; import mapAndSave from '../../map-and-save/buyer-trading-history'; import { Request, Response } from '../../../../../../types'; -import { mockReq, mockRes, mockSpyPromiseRejection } from '../../../../../test-mocks'; +import { mockReq, mockRes, mockSpyPromiseRejection, referenceNumber } from '../../../../../test-mocks'; const { OUTSTANDING_PAYMENTS, FAILED_PAYMENTS, TOTAL_AMOUNT_OVERDUE } = INSURANCE_FIELD_IDS.YOUR_BUYER; @@ -40,7 +40,7 @@ describe('controllers/insurance/your-buyer/trading-history/save-and-back', () => await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.buyerTradingHistory once with data from constructPayload function', async () => { @@ -63,7 +63,7 @@ describe('controllers/insurance/your-buyer/trading-history/save-and-back', () => await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${req.params.referenceNumber}${ALL_SECTIONS}`); + expect(res.redirect).toHaveBeenCalledWith(`${INSURANCE_ROOT}/${referenceNumber}${ALL_SECTIONS}`); }); it('should call mapAndSave.yourBuyer once with data from constructPayload function', async () => { diff --git a/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/amount-overdue.ts b/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/amount-overdue.ts index cfc625853a..315d1fbd72 100644 --- a/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/amount-overdue.ts +++ b/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/amount-overdue.ts @@ -18,7 +18,7 @@ export const MINIMUM = 1; * Check submitted form data for errors with the amount overdue field * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const amountOverdueRules = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/failed-payments.ts b/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/failed-payments.ts index ca3f2d431d..100b7e13d3 100644 --- a/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/failed-payments.ts +++ b/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/failed-payments.ts @@ -20,7 +20,7 @@ const { * Check submitted form data to see if failed payments field radio is selected * Returns emptyFieldValidation if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const failedPaymentsRule = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/outstanding-payments.ts b/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/outstanding-payments.ts index a3f8e09f30..f1ae1710cf 100644 --- a/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/outstanding-payments.ts +++ b/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/outstanding-payments.ts @@ -20,7 +20,7 @@ const { * Check submitted form data to see if outstanding payments field radio is selected * Returns emptyFieldValidation if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const outstandingPaymentsRule = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/total-outstanding.ts b/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/total-outstanding.ts index 0ba85ea658..cb737b187e 100644 --- a/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/total-outstanding.ts +++ b/src/ui/server/controllers/insurance/your-buyer/trading-history/validation/rules/total-outstanding.ts @@ -18,7 +18,7 @@ export const MINIMUM = 1; * Check submitted form data for errors with the total outstanding field * Returns generateValidationErrors if there are any errors. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const totalOutstandingRules = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/quote/policy-type/validation/rules/policy-type.ts b/src/ui/server/controllers/quote/policy-type/validation/rules/policy-type.ts index 7a80cfe505..313623b718 100644 --- a/src/ui/server/controllers/quote/policy-type/validation/rules/policy-type.ts +++ b/src/ui/server/controllers/quote/policy-type/validation/rules/policy-type.ts @@ -11,7 +11,7 @@ const ERROR_MESSAGE = ERROR_MESSAGES.ELIGIBILITY[FIELD_ID]; * policyTypeRules * Check if the policy type is a valid type and not empty * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const policyTypeRules = (formBody: RequestBody, errors: object) => { diff --git a/src/ui/server/controllers/quote/tell-us-about-your-policy/validation/rules/currency.ts b/src/ui/server/controllers/quote/tell-us-about-your-policy/validation/rules/currency.ts index 7f8cf04d30..f71988761f 100644 --- a/src/ui/server/controllers/quote/tell-us-about-your-policy/validation/rules/currency.ts +++ b/src/ui/server/controllers/quote/tell-us-about-your-policy/validation/rules/currency.ts @@ -10,7 +10,7 @@ const ERROR_MESSAGE = ERROR_MESSAGES.ELIGIBILITY[FIELD_ID]; * currencyRules * Returns the result of emptyFieldValidation * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const currencyRules = (formBody: RequestBody, errors: object): ValidationErrors => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/server/controllers/quote/tell-us-about-your-policy/validation/rules/percentage-of-cover.ts b/src/ui/server/controllers/quote/tell-us-about-your-policy/validation/rules/percentage-of-cover.ts index 9302567854..a9b4cf01d2 100644 --- a/src/ui/server/controllers/quote/tell-us-about-your-policy/validation/rules/percentage-of-cover.ts +++ b/src/ui/server/controllers/quote/tell-us-about-your-policy/validation/rules/percentage-of-cover.ts @@ -13,7 +13,7 @@ const ERROR_MESSAGE = ERROR_MESSAGES.ELIGIBILITY[FIELD_ID]; * percentageOfCoverRules * Returns the result of emptyFieldValidation * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const percentageOfCoverRules = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/server/helpers/mappings/map-yes-alternate-field.test.ts b/src/ui/server/helpers/mappings/map-yes-alternate-field.test.ts index 58d6ea77b7..5331506523 100644 --- a/src/ui/server/helpers/mappings/map-yes-alternate-field.test.ts +++ b/src/ui/server/helpers/mappings/map-yes-alternate-field.test.ts @@ -25,7 +25,7 @@ describe('server/helpers/mappings/map-yes-alternate-field', () => { }); }); - describe('when value is "undefined"', () => { + describe('when value is undefined', () => { it(`should return ${DEFAULT.EMPTY}`, () => { const response = mapYesAlternateField(); diff --git a/src/ui/server/helpers/mappings/map-yes-no-field.test.ts b/src/ui/server/helpers/mappings/map-yes-no-field.test.ts index d998811322..ee64fadc5b 100644 --- a/src/ui/server/helpers/mappings/map-yes-no-field.test.ts +++ b/src/ui/server/helpers/mappings/map-yes-no-field.test.ts @@ -23,7 +23,7 @@ describe('server/helpers/mappings/mapYesNoField', () => { }); }); - describe('when value is "undefined"', () => { + describe('when value is undefined', () => { it(`should return ${DEFAULT.EMPTY}`, () => { const response = mapYesNoField(); diff --git a/src/ui/server/shared-validation/alternative-currency/index.ts b/src/ui/server/shared-validation/alternative-currency/index.ts index e76c4fbd05..f289ba323a 100644 --- a/src/ui/server/shared-validation/alternative-currency/index.ts +++ b/src/ui/server/shared-validation/alternative-currency/index.ts @@ -12,7 +12,7 @@ const { * Check if CURRENCY_CODE is ALTERNATIVE_CURRENCY_CODE. * If so, return emptyFieldValidation for the ALTERNATIVE_CURRENCY_CODE field. * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const alternativeCurrencyValidation = (formBody: RequestBody, errors: object, errorMessage: string) => { diff --git a/src/ui/server/shared-validation/email-and-password-incorrect/index.ts b/src/ui/server/shared-validation/email-and-password-incorrect/index.ts index 8f067c3bf6..23cb510d0b 100644 --- a/src/ui/server/shared-validation/email-and-password-incorrect/index.ts +++ b/src/ui/server/shared-validation/email-and-password-incorrect/index.ts @@ -12,7 +12,7 @@ const { /** * emailAndPasswordIncorrectValidationErrors * Return "incorrect" validation errors for both EMAIL and PASSWORD fields. - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const emailAndPasswordIncorrectValidationErrors = (errors: ValidationErrors) => { diff --git a/src/ui/server/shared-validation/policy-alternative-currency-code/index.ts b/src/ui/server/shared-validation/policy-alternative-currency-code/index.ts index a9ca9fe014..80abafaa99 100644 --- a/src/ui/server/shared-validation/policy-alternative-currency-code/index.ts +++ b/src/ui/server/shared-validation/policy-alternative-currency-code/index.ts @@ -19,7 +19,7 @@ const { * policyAlternativeCurrencyCodeRule * Returns the result of emptyFieldValidation * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const policyAlternativeCurrencyCodeRule = (formBody: RequestBody, errors: object) => alternativeCurrencyValidation(formBody, errors, ERROR_MESSAGE.IS_EMPTY); diff --git a/src/ui/server/shared-validation/policy-currency-code/index.ts b/src/ui/server/shared-validation/policy-currency-code/index.ts index eb18402d00..e07ee38cc2 100644 --- a/src/ui/server/shared-validation/policy-currency-code/index.ts +++ b/src/ui/server/shared-validation/policy-currency-code/index.ts @@ -19,7 +19,7 @@ const { * policyCurrencyCodeRules * Returns the result of emptyFieldValidation * @param {RequestBody} formBody: Form body - * @param {Object} Errors object from previous validation errors + * * @param {Object} errors: Errors from previous validation errors errors * @returns {ValidationErrors} */ const policyCurrencyCodeRules = (formBody: RequestBody, errors: object) => emptyFieldValidation(formBody, FIELD_ID, ERROR_MESSAGE.IS_EMPTY, errors); diff --git a/src/ui/templates/components/address-field-input.njk b/src/ui/templates/components/address-field-input.njk deleted file mode 100644 index 401fe9a4c0..0000000000 --- a/src/ui/templates/components/address-field-input.njk +++ /dev/null @@ -1,20 +0,0 @@ -{% import './text-input.njk' as textInput %} - -{% macro render(params) %} - - {% set id = params.id %} - {% set label = params.label %} - {% set application = params.application %} - {% set validationErrors = params.validationErrors %} - {% set submittedValues = params.submittedValues %} - - {{ textInput.render({ - id: id, - labelText: label, - labelClasses: "govuk-body govuk-!-font-weight-bold", - inputClasses: "govuk-input--width-20", - value: submittedValues[id] or application[id], - errorMessage: validationErrors.errorList[id] - }) }} - -{% endmacro %} diff --git a/src/ui/templates/components/address-fields.njk b/src/ui/templates/components/address-fields.njk deleted file mode 100644 index d62ec6383a..0000000000 --- a/src/ui/templates/components/address-fields.njk +++ /dev/null @@ -1,55 +0,0 @@ -{% from "govuk/components/input/macro.njk" import govukInput %} -{% import './address-field-input.njk' as addressFieldInput %} - -{% macro render(params) %} - - {% set ADDRESS_LINE_ONE_FIELD = params.addressLineOne %} - {% set ADDRESS_LINE_TWO_FIELD = params.addressLineTwo %} - {% set COUNTY_FIELD = params.country %} - {% set TOWN_FIELD = params.town %} - {% set POSTCODE_FIELD = params.postcode %} - {% set validationErrors = params.validationErrors %} - {% set application = params.application %} - {% set submittedValues = params.submittedValues %} - - {{ addressFieldInput.render({ - id: ADDRESS_LINE_ONE_FIELD.ID, - label: ADDRESS_LINE_ONE_FIELD.LABEL, - submittedValues: submittedValues, - application: application, - validationErrors: validationErrors - }) }} - - {{ addressFieldInput.render({ - id: ADDRESS_LINE_TWO_FIELD.ID, - label: ADDRESS_LINE_TWO_FIELD.LABEL, - submittedValues: submittedValues, - application: application, - validationErrors: validationErrors - }) }} - - {{ addressFieldInput.render({ - id: TOWN_FIELD.ID, - label: TOWN_FIELD.LABEL, - submittedValues: submittedValues, - application: application, - validationErrors: validationErrors - }) }} - - {{ addressFieldInput.render({ - id: COUNTY_FIELD.ID, - label: COUNTY_FIELD.LABEL, - submittedValues: submittedValues, - application: application, - validationErrors: validationErrors - }) }} - - {{ addressFieldInput.render({ - id: POSTCODE_FIELD.ID, - label: POSTCODE_FIELD.LABEL, - submittedValues: submittedValues, - application: application, - validationErrors: validationErrors - }) }} - -{% endmacro %} diff --git a/src/ui/templates/insurance/your-business/contact.njk b/src/ui/templates/insurance/your-business/contact.njk deleted file mode 100644 index 980fe0fc2c..0000000000 --- a/src/ui/templates/insurance/your-business/contact.njk +++ /dev/null @@ -1,121 +0,0 @@ -{% extends 'index.njk' %} -{% from "govuk/components/back-link/macro.njk" import govukBackLink %} -{% from 'govuk/components/error-summary/macro.njk' import govukErrorSummary %} -{% from "govuk/components/input/macro.njk" import govukInput %} -{% from "govuk/components/hint/macro.njk" import govukHint %} -{% from "govuk/components/fieldset/macro.njk" import govukFieldset %} -{% import '../../components/text-input.njk' as textInput %} -{% import '../../components/form-buttons.njk' as formButtons %} -{% import '../../components/fieldset-legend.njk' as fieldsetLegend %} - -{% block pageTitle %} - {{ CONTENT_STRINGS.PAGE_TITLE }} -{% endblock %} - -{% block content %} - - {{ govukBackLink({ - text: CONTENT_STRINGS.LINKS.BACK, - href: BACK_LINK, - attributes: { - "data-cy": DATA_CY.BACK_LINK - } - }) }} - - {% if validationErrors.summary %} - {{ govukErrorSummary({ - titleText: CONTENT_STRINGS.ERROR_MESSAGES.THERE_IS_A_PROBLEM, - errorList: validationErrors.summary, - attributes: { - 'data-cy': 'error-summary' - } - }) }} - {% endif %} - -