From 1155d37b04a95c664968153b440c2839e7b51a55 Mon Sep 17 00:00:00 2001 From: Zain Kassam Date: Tue, 23 Jul 2024 16:17:37 +0100 Subject: [PATCH 1/6] chore(EMS-3631): added latest version for declaration in constants --- .../declarations/anti-bribery/index.js | 2 +- .../get-latest-declarations/index.test.ts | 41 +++++++++++++++++++ .../get-latest-declarations/index.ts | 39 ++++++++++++++++++ src/ui/server/constants/declarations/index.ts | 11 +++++ .../declarations/versions/index.test.ts | 28 +++++++++++++ .../constants/declarations/versions/index.ts | 33 +++++++++++++++ .../declarations/versions/latest.test.ts | 7 ++++ .../constants/declarations/versions/latest.ts | 14 +++++++ src/ui/server/constants/index.ts | 1 + src/ui/server/content-strings/links.ts | 2 +- .../anti-bribery-code-of-conduct/index.ts | 3 ++ .../index.ts | 2 + .../declarations/anti-bribery/index.ts | 2 + .../declarations/confidentiality/index.ts | 4 +- .../index.ts | 2 + .../how-your-data-will-be-used/index.ts | 2 + src/ui/types/application.ts | 11 +++++ src/ui/types/index.d.ts | 4 ++ src/ui/types/object.d.ts | 5 +++ 19 files changed, 210 insertions(+), 3 deletions(-) create mode 100644 src/ui/server/constants/declarations/get-latest-declarations/index.test.ts create mode 100644 src/ui/server/constants/declarations/get-latest-declarations/index.ts create mode 100644 src/ui/server/constants/declarations/index.ts create mode 100644 src/ui/server/constants/declarations/versions/index.test.ts create mode 100644 src/ui/server/constants/declarations/versions/index.ts create mode 100644 src/ui/server/constants/declarations/versions/latest.test.ts create mode 100644 src/ui/server/constants/declarations/versions/latest.ts create mode 100644 src/ui/types/object.d.ts diff --git a/e2e-tests/content-strings/pages/insurance/declarations/anti-bribery/index.js b/e2e-tests/content-strings/pages/insurance/declarations/anti-bribery/index.js index 30ce29bf17..6ca6adc5da 100644 --- a/e2e-tests/content-strings/pages/insurance/declarations/anti-bribery/index.js +++ b/e2e-tests/content-strings/pages/insurance/declarations/anti-bribery/index.js @@ -5,7 +5,7 @@ export const ANTI_BRIBERY = { PAGE_TITLE: 'Anti-bribery and corruption', VERSIONS: [ { - VERSION: 2, + VERSION: 1, LABEL: `${CONFIRM_READ_AND_AGREE} the anti-bribery and corruption declaration`, OPTION: { TEXT: `${HAVE_READ_AND_AGREED} the anti-bribery and corruption declaration`, diff --git a/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts b/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts new file mode 100644 index 0000000000..a9f533c0f4 --- /dev/null +++ b/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts @@ -0,0 +1,41 @@ +import getLatestDeclarationVersion, { findLatestVersion } from '.'; +import LATEST_VERSION_NUMBER from '../versions/latest'; +import DECLARATIONS from '../../../content-strings/pages/insurance/declarations'; + +const { + CONFIDENTIALITY, + ANTI_BRIBERY, + ANTI_BRIBERY_CODE_OF_CONDUCT, + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, + CONFIRMATION_AND_ACKNOWLEDGEMENTS, + HOW_YOUR_DATA_WILL_BE_USED, +} = DECLARATIONS; + +describe('server/constants/declarations/get-latest-declaration', () => { + describe('findLatestVersion', () => { + it('should find content strings by version', () => { + const result = findLatestVersion(CONFIDENTIALITY, 'CONFIDENTIALITY'); + + const [expected] = CONFIDENTIALITY.VERSIONS; + + expect(result).toEqual(expected); + }); + }); + + describe('getLatestDeclarationVersion', () => { + it('should return the latest declaration versions', () => { + const result = getLatestDeclarationVersion(LATEST_VERSION_NUMBER); + + const expected = { + CONFIDENTIALITY: CONFIDENTIALITY.VERSIONS[0], + ANTI_BRIBERY: ANTI_BRIBERY.VERSIONS[0], + ANTI_BRIBERY_CODE_OF_CONDUCT: ANTI_BRIBERY_CODE_OF_CONDUCT.VERSIONS[0], + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT.VERSIONS[0], + CONFIRMATION_AND_ACKNOWLEDGEMENTS: CONFIRMATION_AND_ACKNOWLEDGEMENTS.VERSIONS[0], + HOW_YOUR_DATA_WILL_BE_USED: HOW_YOUR_DATA_WILL_BE_USED.VERSIONS[0], + }; + + expect(result).toEqual(expected); + }); + }); +}); diff --git a/src/ui/server/constants/declarations/get-latest-declarations/index.ts b/src/ui/server/constants/declarations/get-latest-declarations/index.ts new file mode 100644 index 0000000000..490b6f879c --- /dev/null +++ b/src/ui/server/constants/declarations/get-latest-declarations/index.ts @@ -0,0 +1,39 @@ +import VERSIONS from '../versions'; +import DECLARATIONS from '../../../content-strings/pages/insurance/declarations'; +import { ObjectType } from '../../../../types'; + +const { + CONFIDENTIALITY, + ANTI_BRIBERY, + ANTI_BRIBERY_CODE_OF_CONDUCT, + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, + CONFIRMATION_AND_ACKNOWLEDGEMENTS, + HOW_YOUR_DATA_WILL_BE_USED, +} = DECLARATIONS; + +export const findLatestVersion = (contentStrings: ObjectType, section: string) => + contentStrings.VERSIONS.find((declarationContentStrings: ObjectType) => contentStrings.VERSION === declarationContentStrings?.[section]); + +const getLatestDeclarationVersion = (versionNumber: string) => { + const latestDeclarationVersion = VERSIONS.find((VERSION) => VERSION.VERSION_NUMBER === versionNumber); + + if (latestDeclarationVersion) { + return { + CONFIDENTIALITY: findLatestVersion(CONFIDENTIALITY, 'CONFIDENTIALITY'), + ANTI_BRIBERY: findLatestVersion(ANTI_BRIBERY, 'ANTI_BRIBERY'), + ANTI_BRIBERY_CODE_OF_CONDUCT: findLatestVersion(ANTI_BRIBERY_CODE_OF_CONDUCT, 'ANTI_BRIBERY_CODE_OF_CONDUCT'), + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: findLatestVersion( + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, + 'ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT', + ), + CONFIRMATION_AND_ACKNOWLEDGEMENTS: findLatestVersion(CONFIRMATION_AND_ACKNOWLEDGEMENTS, 'CONFIRMATION_AND_ACKNOWLEDGEMENTS'), + HOW_YOUR_DATA_WILL_BE_USED: findLatestVersion(HOW_YOUR_DATA_WILL_BE_USED, 'HOW_YOUR_DATA_WILL_BE_USED'), + }; + } + + console.error('Unable to find latest declaration version'); + + throw new Error('Unable to find latest declaration version'); +}; + +export default getLatestDeclarationVersion; diff --git a/src/ui/server/constants/declarations/index.ts b/src/ui/server/constants/declarations/index.ts new file mode 100644 index 0000000000..3facf2441f --- /dev/null +++ b/src/ui/server/constants/declarations/index.ts @@ -0,0 +1,11 @@ +import LATEST_VERSION_NUMBER from './versions/latest'; +import VERSIONS from './versions'; +import getLatestDeclarationVersion from './get-latest-declarations'; + +const LATEST_DECLARATIONS = getLatestDeclarationVersion(LATEST_VERSION_NUMBER); + +export const DECLARATIONS = { + LATEST_VERSION_NUMBER, + VERSIONS, + LATEST_DECLARATIONS, +}; diff --git a/src/ui/server/constants/declarations/versions/index.test.ts b/src/ui/server/constants/declarations/versions/index.test.ts new file mode 100644 index 0000000000..813c0849f3 --- /dev/null +++ b/src/ui/server/constants/declarations/versions/index.test.ts @@ -0,0 +1,28 @@ +import VERSIONS from '.'; + +describe('server/constants/declarations/versions', () => { + it('should return an array of versions', () => { + const expected = [ + { + VERSION_NUMBER: '1', + CONFIDENTIALITY: 1, + ANTI_BRIBERY: 1, + ANTI_BRIBERY_CODE_OF_CONDUCT: 1, + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: 1, + CONFIRMATION_AND_ACKNOWLEDGEMENTS: 1, + HOW_YOUR_DATA_WILL_BE_USED: 1, + }, + { + VERSION_NUMBER: '2', + CONFIDENTIALITY: 1, + ANTI_BRIBERY: 1, + ANTI_BRIBERY_CODE_OF_CONDUCT: 1, + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: 1, + CONFIRMATION_AND_ACKNOWLEDGEMENTS: 1, + HOW_YOUR_DATA_WILL_BE_USED: 1, + }, + ]; + + expect(VERSIONS).toEqual(expected); + }); +}); diff --git a/src/ui/server/constants/declarations/versions/index.ts b/src/ui/server/constants/declarations/versions/index.ts new file mode 100644 index 0000000000..459d3c8482 --- /dev/null +++ b/src/ui/server/constants/declarations/versions/index.ts @@ -0,0 +1,33 @@ +import { ApplicationDeclarationVersion } from '../../../../types'; + +/** + * VERSIONS + * All possible declaration versions. + * This should be manually updated each time a phase of EXIP is started. For example: + * - Version number 1: MVP, no support for applications over 500k. + * - Version number 2: Support for applications over 500k. + * - Version number 3: Payments integration + * @returns {Array} All declaration versions + */ +const VERSIONS = [ + { + VERSION_NUMBER: '1', + CONFIDENTIALITY: 1, + ANTI_BRIBERY: 1, + ANTI_BRIBERY_CODE_OF_CONDUCT: 1, + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: 1, + CONFIRMATION_AND_ACKNOWLEDGEMENTS: 1, + HOW_YOUR_DATA_WILL_BE_USED: 1, + }, + { + VERSION_NUMBER: '2', + CONFIDENTIALITY: 1, + ANTI_BRIBERY: 1, + ANTI_BRIBERY_CODE_OF_CONDUCT: 1, + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: 1, + CONFIRMATION_AND_ACKNOWLEDGEMENTS: 1, + HOW_YOUR_DATA_WILL_BE_USED: 1, + }, +] as Array; + +export default VERSIONS; diff --git a/src/ui/server/constants/declarations/versions/latest.test.ts b/src/ui/server/constants/declarations/versions/latest.test.ts new file mode 100644 index 0000000000..19809bae96 --- /dev/null +++ b/src/ui/server/constants/declarations/versions/latest.test.ts @@ -0,0 +1,7 @@ +import LATEST_VERSION_NUMBER from '.'; + +describe('server/constants/declarations/versions/latest', () => { + it('should return the latest version number', () => { + expect(LATEST_VERSION_NUMBER).toEqual('2'); + }); +}); diff --git a/src/ui/server/constants/declarations/versions/latest.ts b/src/ui/server/constants/declarations/versions/latest.ts new file mode 100644 index 0000000000..91c68fa03f --- /dev/null +++ b/src/ui/server/constants/declarations/versions/latest.ts @@ -0,0 +1,14 @@ +/** + * LATEST_VERSION_NUMBER + * Latest declaration version number. + * This should be manually updated each time a phase of EXIP is started. For example: + * - Version number 1: MVP - no support for applications over 500k. + * - Version number 2: "No PDF" - Support for applications over 500k. + * - Version number 3: File uploads + * - Version number 4: Address lookup + * - Version number 5: Payments integration + * @returns {String} Latest declaration version number + */ +const LATEST_VERSION_NUMBER = '2'; + +export default LATEST_VERSION_NUMBER; diff --git a/src/ui/server/constants/index.ts b/src/ui/server/constants/index.ts index 97ba3dd41a..372127f3e0 100644 --- a/src/ui/server/constants/index.ts +++ b/src/ui/server/constants/index.ts @@ -7,6 +7,7 @@ export * from './cover-period'; export * from './currencies'; export * from './date-format'; export * from './dates'; +export * from './declarations'; export * from './eligibility'; export * from './environments'; export * from './external-apis'; diff --git a/src/ui/server/content-strings/links.ts b/src/ui/server/content-strings/links.ts index fd4e49e800..a7f01fb4c9 100644 --- a/src/ui/server/content-strings/links.ts +++ b/src/ui/server/content-strings/links.ts @@ -1,4 +1,4 @@ -import { ROUTES } from '../constants'; +import { ROUTES } from '../constants/routes'; export const LINKS = { ADD: 'Add', diff --git a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-code-of-conduct/index.ts b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-code-of-conduct/index.ts index ca2b6a9f89..e22e5858e4 100644 --- a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-code-of-conduct/index.ts +++ b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-code-of-conduct/index.ts @@ -8,6 +8,9 @@ export const ANTI_BRIBERY_CODE_OF_CONDUCT = { VERSIONS: [ { VERSION: 1, + ...SHARED, + PAGE_TITLE: + 'Do you have in place a code of conduct and written procedures of the type contemplated by Section(2) of the Bribery Act to discourage and prevent corrupt activity?', HINT: { INTRO: 'If no, your attention is drawn to', LINK: { diff --git a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-exporting-with-code-of-conduct/index.ts b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-exporting-with-code-of-conduct/index.ts index 9b0f35667b..1033846df9 100644 --- a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-exporting-with-code-of-conduct/index.ts +++ b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-exporting-with-code-of-conduct/index.ts @@ -6,6 +6,8 @@ export const ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT = { VERSIONS: [ { VERSION: 1, + ...SHARED, + PAGE_TITLE: 'Will you use your anti-bribery code of conduct to win or carry out the exports you want to insure?', }, ], }; diff --git a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery/index.ts b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery/index.ts index 30ce29bf17..b1ff370c8d 100644 --- a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery/index.ts +++ b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery/index.ts @@ -6,6 +6,8 @@ export const ANTI_BRIBERY = { VERSIONS: [ { VERSION: 2, + ...SHARED, + PAGE_TITLE: 'Anti-bribery and corruption', LABEL: `${CONFIRM_READ_AND_AGREE} the anti-bribery and corruption declaration`, OPTION: { TEXT: `${HAVE_READ_AND_AGREED} the anti-bribery and corruption declaration`, diff --git a/src/ui/server/content-strings/pages/insurance/declarations/confidentiality/index.ts b/src/ui/server/content-strings/pages/insurance/declarations/confidentiality/index.ts index 96f21d3dfc..d742cf3896 100644 --- a/src/ui/server/content-strings/pages/insurance/declarations/confidentiality/index.ts +++ b/src/ui/server/content-strings/pages/insurance/declarations/confidentiality/index.ts @@ -5,7 +5,9 @@ export const CONFIDENTIALITY = { PAGE_TITLE: 'Confidentiality', VERSIONS: [ { - VERSION: 2, + VERSION: 1, + ...SHARED, + PAGE_TITLE: 'Confidentiality', LABEL: `${CONFIRM_READ_AND_AGREE} the confidentiality declaration`, OPTION: { TEXT: `${HAVE_READ_AND_AGREED} the confidentiality declaration`, diff --git a/src/ui/server/content-strings/pages/insurance/declarations/confirmation-and-acknowledgements/index.ts b/src/ui/server/content-strings/pages/insurance/declarations/confirmation-and-acknowledgements/index.ts index 68707f638b..7975d306c7 100644 --- a/src/ui/server/content-strings/pages/insurance/declarations/confirmation-and-acknowledgements/index.ts +++ b/src/ui/server/content-strings/pages/insurance/declarations/confirmation-and-acknowledgements/index.ts @@ -6,6 +6,8 @@ export const CONFIRMATION_AND_ACKNOWLEDGEMENTS = { VERSIONS: [ { VERSION: 1, + ...SHARED, + PAGE_TITLE: 'Confirmation and acknowledgements', LABEL: `${CONFIRM_READ_AND_AGREE} the confirmation and acknowledgements`, OPTION: { TEXT: `${HAVE_READ_AND_AGREED} the confirmation and acknowledgements`, diff --git a/src/ui/server/content-strings/pages/insurance/declarations/how-your-data-will-be-used/index.ts b/src/ui/server/content-strings/pages/insurance/declarations/how-your-data-will-be-used/index.ts index c505b4b486..57304e8b2a 100644 --- a/src/ui/server/content-strings/pages/insurance/declarations/how-your-data-will-be-used/index.ts +++ b/src/ui/server/content-strings/pages/insurance/declarations/how-your-data-will-be-used/index.ts @@ -6,6 +6,8 @@ export const HOW_YOUR_DATA_WILL_BE_USED = { VERSIONS: [ { VERSION: 1, + ...SHARED, + PAGE_TITLE: 'How your data will be used', LABEL: `${CONFIRM_READ_AND_AGREE} how your data will be used`, OPTION: { TEXT: `${HAVE_READ_AND_AGREED} how my data will be used`, diff --git a/src/ui/types/application.ts b/src/ui/types/application.ts index a905e3848b..456106825f 100644 --- a/src/ui/types/application.ts +++ b/src/ui/types/application.ts @@ -284,6 +284,16 @@ interface ApplicationVersion { DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: boolean; } +interface ApplicationDeclarationVersion { + VERSION_NUMBER: string; + CONFIDENTIALITY: number; + ANTI_BRIBERY: number; + ANTI_BRIBERY_CODE_OF_CONDUCT: number; + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: number; + CONFIRMATION_AND_ACKNOWLEDGEMENTS: number; + HOW_YOUR_DATA_WILL_BE_USED: number; +} + export { Application, ApplicationBusiness, @@ -311,5 +321,6 @@ export { ApplicationSectionReview, ApplicationDeclaration, ApplicationVersion, + ApplicationDeclarationVersion, ApplicationOwner, }; diff --git a/src/ui/types/index.d.ts b/src/ui/types/index.d.ts index 95f877a733..845e4d67b5 100644 --- a/src/ui/types/index.d.ts +++ b/src/ui/types/index.d.ts @@ -25,6 +25,7 @@ import { ApplicationPolicyContact, ApplicationPrivateMarket, ApplicationVersion, + ApplicationDeclarationVersion, ApplicationOwner, } from './application'; import { ApplicationByReferenceNumberVariables } from './application-by-reference-number-variables'; @@ -84,6 +85,7 @@ import { } from './page-variables'; import { InsuranceFeedbackVariables } from './feedback'; import { SanitiseValueObjParams } from './sanitise-value'; +import { ObjectType } from './object'; export { Account, @@ -113,6 +115,7 @@ export { ApplicationPolicyContact, ApplicationPrivateMarket, ApplicationVersion, + ApplicationDeclarationVersion, ApplicationByReferenceNumberVariables, ApolloResponse, ApplicationOwner, @@ -137,6 +140,7 @@ export { InsuranceFeedbackVariables, Next, Object, + ObjectType, PageContentStrings, PageVariablesContentStrings, PricingGrid, diff --git a/src/ui/types/object.d.ts b/src/ui/types/object.d.ts new file mode 100644 index 0000000000..6aecd45f65 --- /dev/null +++ b/src/ui/types/object.d.ts @@ -0,0 +1,5 @@ +type ObjectType = { + [key: string]: any; +}; + +export { ObjectType }; From d3e7188a8409dbd82e88968818e24ad600c6bc32 Mon Sep 17 00:00:00 2001 From: Zain Kassam Date: Tue, 23 Jul 2024 17:01:21 +0100 Subject: [PATCH 2/6] chore(EMS-3631): fixed failing test and added documentation --- .../get-latest-declarations/index.test.ts | 3 +- .../get-latest-declarations/index.ts | 30 ++++++++++++++----- src/ui/server/constants/declarations/index.ts | 6 ++++ .../constants/declarations/versions/index.ts | 3 +- .../declarations/versions/latest.test.ts | 2 +- .../constants/declarations/versions/latest.ts | 5 +--- .../declarations/anti-bribery/index.ts | 2 +- 7 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts b/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts index a9f533c0f4..b4133341b0 100644 --- a/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts +++ b/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts @@ -1,5 +1,6 @@ import getLatestDeclarationVersion, { findLatestVersion } from '.'; import LATEST_VERSION_NUMBER from '../versions/latest'; +import VERSIONS from '../versions'; import DECLARATIONS from '../../../content-strings/pages/insurance/declarations'; const { @@ -14,7 +15,7 @@ const { describe('server/constants/declarations/get-latest-declaration', () => { describe('findLatestVersion', () => { it('should find content strings by version', () => { - const result = findLatestVersion(CONFIDENTIALITY, 'CONFIDENTIALITY'); + const result = findLatestVersion(CONFIDENTIALITY, VERSIONS[1].CONFIDENTIALITY); const [expected] = CONFIDENTIALITY.VERSIONS; diff --git a/src/ui/server/constants/declarations/get-latest-declarations/index.ts b/src/ui/server/constants/declarations/get-latest-declarations/index.ts index 490b6f879c..d14c97edb7 100644 --- a/src/ui/server/constants/declarations/get-latest-declarations/index.ts +++ b/src/ui/server/constants/declarations/get-latest-declarations/index.ts @@ -11,23 +11,37 @@ const { HOW_YOUR_DATA_WILL_BE_USED, } = DECLARATIONS; -export const findLatestVersion = (contentStrings: ObjectType, section: string) => - contentStrings.VERSIONS.find((declarationContentStrings: ObjectType) => contentStrings.VERSION === declarationContentStrings?.[section]); +/** + * findLatestVersion + * Finds the latest content strings for a specified declaration section + * @param {ObjectType} declarationContentStrings: Content strings for specified declaration + * @param {number} sectionLatestVersion: latest version for specified section + * @returns {Object} contentStrings: Content strings for specified version of declaration + */ +export const findLatestVersion = (declarationContentStrings: ObjectType, sectionLatestVersion: number) => + declarationContentStrings.VERSIONS.find((contentStrings: ObjectType) => contentStrings.VERSION === sectionLatestVersion); +/** + * getLatestDeclarationVersion + * gets the latest declaration versions for each declaration section + * populates an object with the content strings for that version + * @param {String} versionNumber: latest version for declarations + * @returns {Object} contentStrings for the latest version of declarations + */ const getLatestDeclarationVersion = (versionNumber: string) => { const latestDeclarationVersion = VERSIONS.find((VERSION) => VERSION.VERSION_NUMBER === versionNumber); if (latestDeclarationVersion) { return { - CONFIDENTIALITY: findLatestVersion(CONFIDENTIALITY, 'CONFIDENTIALITY'), - ANTI_BRIBERY: findLatestVersion(ANTI_BRIBERY, 'ANTI_BRIBERY'), - ANTI_BRIBERY_CODE_OF_CONDUCT: findLatestVersion(ANTI_BRIBERY_CODE_OF_CONDUCT, 'ANTI_BRIBERY_CODE_OF_CONDUCT'), + CONFIDENTIALITY: findLatestVersion(CONFIDENTIALITY, latestDeclarationVersion.CONFIDENTIALITY), + ANTI_BRIBERY: findLatestVersion(ANTI_BRIBERY, latestDeclarationVersion.ANTI_BRIBERY), + ANTI_BRIBERY_CODE_OF_CONDUCT: findLatestVersion(ANTI_BRIBERY_CODE_OF_CONDUCT, latestDeclarationVersion.ANTI_BRIBERY_CODE_OF_CONDUCT), ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: findLatestVersion( ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, - 'ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT', + latestDeclarationVersion.ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, ), - CONFIRMATION_AND_ACKNOWLEDGEMENTS: findLatestVersion(CONFIRMATION_AND_ACKNOWLEDGEMENTS, 'CONFIRMATION_AND_ACKNOWLEDGEMENTS'), - HOW_YOUR_DATA_WILL_BE_USED: findLatestVersion(HOW_YOUR_DATA_WILL_BE_USED, 'HOW_YOUR_DATA_WILL_BE_USED'), + CONFIRMATION_AND_ACKNOWLEDGEMENTS: findLatestVersion(CONFIRMATION_AND_ACKNOWLEDGEMENTS, latestDeclarationVersion.CONFIRMATION_AND_ACKNOWLEDGEMENTS), + HOW_YOUR_DATA_WILL_BE_USED: findLatestVersion(HOW_YOUR_DATA_WILL_BE_USED, latestDeclarationVersion.HOW_YOUR_DATA_WILL_BE_USED), }; } diff --git a/src/ui/server/constants/declarations/index.ts b/src/ui/server/constants/declarations/index.ts index 3facf2441f..ff1b353def 100644 --- a/src/ui/server/constants/declarations/index.ts +++ b/src/ui/server/constants/declarations/index.ts @@ -4,6 +4,12 @@ import getLatestDeclarationVersion from './get-latest-declarations'; const LATEST_DECLARATIONS = getLatestDeclarationVersion(LATEST_VERSION_NUMBER); +/** + * DECLARATIONS + * DECLARATION constants - declarations need to be versioned so we have a record of which version a user accepted. + * These constants are used to populate the declarations and to keep a record of the version submitted. + * @returns {Object} Declaration constants + */ export const DECLARATIONS = { LATEST_VERSION_NUMBER, VERSIONS, diff --git a/src/ui/server/constants/declarations/versions/index.ts b/src/ui/server/constants/declarations/versions/index.ts index 459d3c8482..bef28df38e 100644 --- a/src/ui/server/constants/declarations/versions/index.ts +++ b/src/ui/server/constants/declarations/versions/index.ts @@ -6,8 +6,7 @@ import { ApplicationDeclarationVersion } from '../../../../types'; * This should be manually updated each time a phase of EXIP is started. For example: * - Version number 1: MVP, no support for applications over 500k. * - Version number 2: Support for applications over 500k. - * - Version number 3: Payments integration - * @returns {Array} All declaration versions + * @returns {Array} All declaration versions */ const VERSIONS = [ { diff --git a/src/ui/server/constants/declarations/versions/latest.test.ts b/src/ui/server/constants/declarations/versions/latest.test.ts index 19809bae96..9b6fb9cb3f 100644 --- a/src/ui/server/constants/declarations/versions/latest.test.ts +++ b/src/ui/server/constants/declarations/versions/latest.test.ts @@ -1,4 +1,4 @@ -import LATEST_VERSION_NUMBER from '.'; +import LATEST_VERSION_NUMBER from './latest'; describe('server/constants/declarations/versions/latest', () => { it('should return the latest version number', () => { diff --git a/src/ui/server/constants/declarations/versions/latest.ts b/src/ui/server/constants/declarations/versions/latest.ts index 91c68fa03f..7899fce5b9 100644 --- a/src/ui/server/constants/declarations/versions/latest.ts +++ b/src/ui/server/constants/declarations/versions/latest.ts @@ -1,12 +1,9 @@ /** * LATEST_VERSION_NUMBER * Latest declaration version number. - * This should be manually updated each time a phase of EXIP is started. For example: + * This should be manually updated when the declarations for EXIP are updated. For example: * - Version number 1: MVP - no support for applications over 500k. * - Version number 2: "No PDF" - Support for applications over 500k. - * - Version number 3: File uploads - * - Version number 4: Address lookup - * - Version number 5: Payments integration * @returns {String} Latest declaration version number */ const LATEST_VERSION_NUMBER = '2'; diff --git a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery/index.ts b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery/index.ts index b1ff370c8d..c9cbf342f9 100644 --- a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery/index.ts +++ b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery/index.ts @@ -5,7 +5,7 @@ export const ANTI_BRIBERY = { PAGE_TITLE: 'Anti-bribery and corruption', VERSIONS: [ { - VERSION: 2, + VERSION: 1, ...SHARED, PAGE_TITLE: 'Anti-bribery and corruption', LABEL: `${CONFIRM_READ_AND_AGREE} the anti-bribery and corruption declaration`, From 18f30db8aaf165be8d9e74ced87099ae3e36c963 Mon Sep 17 00:00:00 2001 From: Zain Kassam Date: Wed, 24 Jul 2024 10:54:29 +0100 Subject: [PATCH 3/6] chore(EMS-3631): code fixes and refactor --- .../get-latest-declarations/index.test.ts | 5 +-- .../get-latest-declarations/index.ts | 44 ++++++++----------- src/ui/server/constants/declarations/index.ts | 4 +- .../declarations/versions/index.test.ts | 26 +++++------ .../constants/declarations/versions/index.ts | 30 ++++++------- .../declarations/versions/latest.test.ts | 7 --- .../constants/declarations/versions/latest.ts | 11 ----- src/ui/types/application.ts | 15 +++---- src/ui/types/index.d.ts | 4 +- 9 files changed, 56 insertions(+), 90 deletions(-) delete mode 100644 src/ui/server/constants/declarations/versions/latest.test.ts delete mode 100644 src/ui/server/constants/declarations/versions/latest.ts diff --git a/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts b/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts index b4133341b0..17162992ac 100644 --- a/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts +++ b/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts @@ -1,5 +1,4 @@ import getLatestDeclarationVersion, { findLatestVersion } from '.'; -import LATEST_VERSION_NUMBER from '../versions/latest'; import VERSIONS from '../versions'; import DECLARATIONS from '../../../content-strings/pages/insurance/declarations'; @@ -12,7 +11,7 @@ const { HOW_YOUR_DATA_WILL_BE_USED, } = DECLARATIONS; -describe('server/constants/declarations/get-latest-declaration', () => { +describe('server/constants/declarations/get-latest-declarations', () => { describe('findLatestVersion', () => { it('should find content strings by version', () => { const result = findLatestVersion(CONFIDENTIALITY, VERSIONS[1].CONFIDENTIALITY); @@ -25,7 +24,7 @@ describe('server/constants/declarations/get-latest-declaration', () => { describe('getLatestDeclarationVersion', () => { it('should return the latest declaration versions', () => { - const result = getLatestDeclarationVersion(LATEST_VERSION_NUMBER); + const result = getLatestDeclarationVersion(); const expected = { CONFIDENTIALITY: CONFIDENTIALITY.VERSIONS[0], diff --git a/src/ui/server/constants/declarations/get-latest-declarations/index.ts b/src/ui/server/constants/declarations/get-latest-declarations/index.ts index d14c97edb7..754dc71aef 100644 --- a/src/ui/server/constants/declarations/get-latest-declarations/index.ts +++ b/src/ui/server/constants/declarations/get-latest-declarations/index.ts @@ -15,39 +15,33 @@ const { * findLatestVersion * Finds the latest content strings for a specified declaration section * @param {ObjectType} declarationContentStrings: Content strings for specified declaration - * @param {number} sectionLatestVersion: latest version for specified section + * @param {string} latestVersionNumber: latest version for specified section * @returns {Object} contentStrings: Content strings for specified version of declaration */ -export const findLatestVersion = (declarationContentStrings: ObjectType, sectionLatestVersion: number) => - declarationContentStrings.VERSIONS.find((contentStrings: ObjectType) => contentStrings.VERSION === sectionLatestVersion); +export const findLatestVersion = (declarationContentStrings: ObjectType, latestVersionNumber: string) => + declarationContentStrings.VERSIONS.find((contentStrings: ObjectType) => contentStrings.VERSION === latestVersionNumber); /** - * getLatestDeclarationVersion + * getLatestDeclarationsVersion * gets the latest declaration versions for each declaration section * populates an object with the content strings for that version - * @param {String} versionNumber: latest version for declarations * @returns {Object} contentStrings for the latest version of declarations */ -const getLatestDeclarationVersion = (versionNumber: string) => { - const latestDeclarationVersion = VERSIONS.find((VERSION) => VERSION.VERSION_NUMBER === versionNumber); +const getLatestDeclarationsVersion = () => { + // get latest declaration versions + const latestDeclarationVersions = VERSIONS[VERSIONS.length - 1]; - if (latestDeclarationVersion) { - return { - CONFIDENTIALITY: findLatestVersion(CONFIDENTIALITY, latestDeclarationVersion.CONFIDENTIALITY), - ANTI_BRIBERY: findLatestVersion(ANTI_BRIBERY, latestDeclarationVersion.ANTI_BRIBERY), - ANTI_BRIBERY_CODE_OF_CONDUCT: findLatestVersion(ANTI_BRIBERY_CODE_OF_CONDUCT, latestDeclarationVersion.ANTI_BRIBERY_CODE_OF_CONDUCT), - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: findLatestVersion( - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, - latestDeclarationVersion.ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, - ), - CONFIRMATION_AND_ACKNOWLEDGEMENTS: findLatestVersion(CONFIRMATION_AND_ACKNOWLEDGEMENTS, latestDeclarationVersion.CONFIRMATION_AND_ACKNOWLEDGEMENTS), - HOW_YOUR_DATA_WILL_BE_USED: findLatestVersion(HOW_YOUR_DATA_WILL_BE_USED, latestDeclarationVersion.HOW_YOUR_DATA_WILL_BE_USED), - }; - } - - console.error('Unable to find latest declaration version'); - - throw new Error('Unable to find latest declaration version'); + return { + CONFIDENTIALITY: findLatestVersion(CONFIDENTIALITY, latestDeclarationVersions.CONFIDENTIALITY), + ANTI_BRIBERY: findLatestVersion(ANTI_BRIBERY, latestDeclarationVersions.ANTI_BRIBERY), + ANTI_BRIBERY_CODE_OF_CONDUCT: findLatestVersion(ANTI_BRIBERY_CODE_OF_CONDUCT, latestDeclarationVersions.ANTI_BRIBERY_CODE_OF_CONDUCT), + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: findLatestVersion( + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, + latestDeclarationVersions.ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, + ), + CONFIRMATION_AND_ACKNOWLEDGEMENTS: findLatestVersion(CONFIRMATION_AND_ACKNOWLEDGEMENTS, latestDeclarationVersions.CONFIRMATION_AND_ACKNOWLEDGEMENTS), + HOW_YOUR_DATA_WILL_BE_USED: findLatestVersion(HOW_YOUR_DATA_WILL_BE_USED, latestDeclarationVersions.HOW_YOUR_DATA_WILL_BE_USED), + }; }; -export default getLatestDeclarationVersion; +export default getLatestDeclarationsVersion; diff --git a/src/ui/server/constants/declarations/index.ts b/src/ui/server/constants/declarations/index.ts index ff1b353def..c480e9cfcc 100644 --- a/src/ui/server/constants/declarations/index.ts +++ b/src/ui/server/constants/declarations/index.ts @@ -1,8 +1,7 @@ -import LATEST_VERSION_NUMBER from './versions/latest'; import VERSIONS from './versions'; import getLatestDeclarationVersion from './get-latest-declarations'; -const LATEST_DECLARATIONS = getLatestDeclarationVersion(LATEST_VERSION_NUMBER); +const LATEST_DECLARATIONS = getLatestDeclarationVersion(); /** * DECLARATIONS @@ -11,7 +10,6 @@ const LATEST_DECLARATIONS = getLatestDeclarationVersion(LATEST_VERSION_NUMBER); * @returns {Object} Declaration constants */ export const DECLARATIONS = { - LATEST_VERSION_NUMBER, VERSIONS, LATEST_DECLARATIONS, }; diff --git a/src/ui/server/constants/declarations/versions/index.test.ts b/src/ui/server/constants/declarations/versions/index.test.ts index 813c0849f3..6eed91fdbf 100644 --- a/src/ui/server/constants/declarations/versions/index.test.ts +++ b/src/ui/server/constants/declarations/versions/index.test.ts @@ -4,22 +4,20 @@ describe('server/constants/declarations/versions', () => { it('should return an array of versions', () => { const expected = [ { - VERSION_NUMBER: '1', - CONFIDENTIALITY: 1, - ANTI_BRIBERY: 1, - ANTI_BRIBERY_CODE_OF_CONDUCT: 1, - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: 1, - CONFIRMATION_AND_ACKNOWLEDGEMENTS: 1, - HOW_YOUR_DATA_WILL_BE_USED: 1, + CONFIDENTIALITY: '1', + ANTI_BRIBERY: '1', + ANTI_BRIBERY_CODE_OF_CONDUCT: '1', + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: '1', + CONFIRMATION_AND_ACKNOWLEDGEMENTS: '1', + HOW_YOUR_DATA_WILL_BE_USED: '1', }, { - VERSION_NUMBER: '2', - CONFIDENTIALITY: 1, - ANTI_BRIBERY: 1, - ANTI_BRIBERY_CODE_OF_CONDUCT: 1, - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: 1, - CONFIRMATION_AND_ACKNOWLEDGEMENTS: 1, - HOW_YOUR_DATA_WILL_BE_USED: 1, + CONFIDENTIALITY: '1', + ANTI_BRIBERY: '1', + ANTI_BRIBERY_CODE_OF_CONDUCT: '1', + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: '1', + CONFIRMATION_AND_ACKNOWLEDGEMENTS: '1', + HOW_YOUR_DATA_WILL_BE_USED: '1', }, ]; diff --git a/src/ui/server/constants/declarations/versions/index.ts b/src/ui/server/constants/declarations/versions/index.ts index bef28df38e..0392faaca4 100644 --- a/src/ui/server/constants/declarations/versions/index.ts +++ b/src/ui/server/constants/declarations/versions/index.ts @@ -3,29 +3,25 @@ import { ApplicationDeclarationVersion } from '../../../../types'; /** * VERSIONS * All possible declaration versions. - * This should be manually updated each time a phase of EXIP is started. For example: - * - Version number 1: MVP, no support for applications over 500k. - * - Version number 2: Support for applications over 500k. + * This should be manually updated each time declarations are updated * @returns {Array} All declaration versions */ const VERSIONS = [ { - VERSION_NUMBER: '1', - CONFIDENTIALITY: 1, - ANTI_BRIBERY: 1, - ANTI_BRIBERY_CODE_OF_CONDUCT: 1, - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: 1, - CONFIRMATION_AND_ACKNOWLEDGEMENTS: 1, - HOW_YOUR_DATA_WILL_BE_USED: 1, + CONFIDENTIALITY: '1', + ANTI_BRIBERY: '1', + ANTI_BRIBERY_CODE_OF_CONDUCT: '1', + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: '1', + CONFIRMATION_AND_ACKNOWLEDGEMENTS: '1', + HOW_YOUR_DATA_WILL_BE_USED: '1', }, { - VERSION_NUMBER: '2', - CONFIDENTIALITY: 1, - ANTI_BRIBERY: 1, - ANTI_BRIBERY_CODE_OF_CONDUCT: 1, - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: 1, - CONFIRMATION_AND_ACKNOWLEDGEMENTS: 1, - HOW_YOUR_DATA_WILL_BE_USED: 1, + CONFIDENTIALITY: '1', + ANTI_BRIBERY: '1', + ANTI_BRIBERY_CODE_OF_CONDUCT: '1', + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: '1', + CONFIRMATION_AND_ACKNOWLEDGEMENTS: '1', + HOW_YOUR_DATA_WILL_BE_USED: '1', }, ] as Array; diff --git a/src/ui/server/constants/declarations/versions/latest.test.ts b/src/ui/server/constants/declarations/versions/latest.test.ts deleted file mode 100644 index 9b6fb9cb3f..0000000000 --- a/src/ui/server/constants/declarations/versions/latest.test.ts +++ /dev/null @@ -1,7 +0,0 @@ -import LATEST_VERSION_NUMBER from './latest'; - -describe('server/constants/declarations/versions/latest', () => { - it('should return the latest version number', () => { - expect(LATEST_VERSION_NUMBER).toEqual('2'); - }); -}); diff --git a/src/ui/server/constants/declarations/versions/latest.ts b/src/ui/server/constants/declarations/versions/latest.ts deleted file mode 100644 index 7899fce5b9..0000000000 --- a/src/ui/server/constants/declarations/versions/latest.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * LATEST_VERSION_NUMBER - * Latest declaration version number. - * This should be manually updated when the declarations for EXIP are updated. For example: - * - Version number 1: MVP - no support for applications over 500k. - * - Version number 2: "No PDF" - Support for applications over 500k. - * @returns {String} Latest declaration version number - */ -const LATEST_VERSION_NUMBER = '2'; - -export default LATEST_VERSION_NUMBER; diff --git a/src/ui/types/application.ts b/src/ui/types/application.ts index 456106825f..0f67f58861 100644 --- a/src/ui/types/application.ts +++ b/src/ui/types/application.ts @@ -285,13 +285,12 @@ interface ApplicationVersion { } interface ApplicationDeclarationVersion { - VERSION_NUMBER: string; - CONFIDENTIALITY: number; - ANTI_BRIBERY: number; - ANTI_BRIBERY_CODE_OF_CONDUCT: number; - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: number; - CONFIRMATION_AND_ACKNOWLEDGEMENTS: number; - HOW_YOUR_DATA_WILL_BE_USED: number; + CONFIDENTIALITY: string; + ANTI_BRIBERY: string; + ANTI_BRIBERY_CODE_OF_CONDUCT: string; + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: string; + CONFIRMATION_AND_ACKNOWLEDGEMENTS: string; + HOW_YOUR_DATA_WILL_BE_USED: string; } export { @@ -320,7 +319,7 @@ export { ApplicationPolicyContact, ApplicationSectionReview, ApplicationDeclaration, - ApplicationVersion, ApplicationDeclarationVersion, + ApplicationVersion, ApplicationOwner, }; diff --git a/src/ui/types/index.d.ts b/src/ui/types/index.d.ts index 845e4d67b5..e8a5d32a46 100644 --- a/src/ui/types/index.d.ts +++ b/src/ui/types/index.d.ts @@ -24,8 +24,8 @@ import { ApplicationPolicy, ApplicationPolicyContact, ApplicationPrivateMarket, - ApplicationVersion, ApplicationDeclarationVersion, + ApplicationVersion, ApplicationOwner, } from './application'; import { ApplicationByReferenceNumberVariables } from './application-by-reference-number-variables'; @@ -114,8 +114,8 @@ export { ApplicationPolicy, ApplicationPolicyContact, ApplicationPrivateMarket, - ApplicationVersion, ApplicationDeclarationVersion, + ApplicationVersion, ApplicationByReferenceNumberVariables, ApolloResponse, ApplicationOwner, From 0d914274605665cc8ba09a380279cf168ab76768 Mon Sep 17 00:00:00 2001 From: Zain Kassam Date: Wed, 24 Jul 2024 11:08:12 +0100 Subject: [PATCH 4/6] chore(EMS-3631): keep HOW_YOUR_DATA_WILL_BE_USED for audit purposes --- .../get-latest-declarations/index.test.ts | 11 ++--------- .../declarations/get-latest-declarations/index.ts | 11 ++--------- .../constants/declarations/versions/index.test.ts | 1 - .../server/constants/declarations/versions/index.ts | 1 - src/ui/types/application.ts | 2 +- 5 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts b/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts index 17162992ac..8d63b5dc55 100644 --- a/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts +++ b/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts @@ -2,14 +2,8 @@ import getLatestDeclarationVersion, { findLatestVersion } from '.'; import VERSIONS from '../versions'; import DECLARATIONS from '../../../content-strings/pages/insurance/declarations'; -const { - CONFIDENTIALITY, - ANTI_BRIBERY, - ANTI_BRIBERY_CODE_OF_CONDUCT, - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, - CONFIRMATION_AND_ACKNOWLEDGEMENTS, - HOW_YOUR_DATA_WILL_BE_USED, -} = DECLARATIONS; +const { CONFIDENTIALITY, ANTI_BRIBERY, ANTI_BRIBERY_CODE_OF_CONDUCT, ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, CONFIRMATION_AND_ACKNOWLEDGEMENTS } = + DECLARATIONS; describe('server/constants/declarations/get-latest-declarations', () => { describe('findLatestVersion', () => { @@ -32,7 +26,6 @@ describe('server/constants/declarations/get-latest-declarations', () => { ANTI_BRIBERY_CODE_OF_CONDUCT: ANTI_BRIBERY_CODE_OF_CONDUCT.VERSIONS[0], ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT.VERSIONS[0], CONFIRMATION_AND_ACKNOWLEDGEMENTS: CONFIRMATION_AND_ACKNOWLEDGEMENTS.VERSIONS[0], - HOW_YOUR_DATA_WILL_BE_USED: HOW_YOUR_DATA_WILL_BE_USED.VERSIONS[0], }; expect(result).toEqual(expected); diff --git a/src/ui/server/constants/declarations/get-latest-declarations/index.ts b/src/ui/server/constants/declarations/get-latest-declarations/index.ts index 754dc71aef..7292c1e3e8 100644 --- a/src/ui/server/constants/declarations/get-latest-declarations/index.ts +++ b/src/ui/server/constants/declarations/get-latest-declarations/index.ts @@ -2,14 +2,8 @@ import VERSIONS from '../versions'; import DECLARATIONS from '../../../content-strings/pages/insurance/declarations'; import { ObjectType } from '../../../../types'; -const { - CONFIDENTIALITY, - ANTI_BRIBERY, - ANTI_BRIBERY_CODE_OF_CONDUCT, - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, - CONFIRMATION_AND_ACKNOWLEDGEMENTS, - HOW_YOUR_DATA_WILL_BE_USED, -} = DECLARATIONS; +const { CONFIDENTIALITY, ANTI_BRIBERY, ANTI_BRIBERY_CODE_OF_CONDUCT, ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, CONFIRMATION_AND_ACKNOWLEDGEMENTS } = + DECLARATIONS; /** * findLatestVersion @@ -40,7 +34,6 @@ const getLatestDeclarationsVersion = () => { latestDeclarationVersions.ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, ), CONFIRMATION_AND_ACKNOWLEDGEMENTS: findLatestVersion(CONFIRMATION_AND_ACKNOWLEDGEMENTS, latestDeclarationVersions.CONFIRMATION_AND_ACKNOWLEDGEMENTS), - HOW_YOUR_DATA_WILL_BE_USED: findLatestVersion(HOW_YOUR_DATA_WILL_BE_USED, latestDeclarationVersions.HOW_YOUR_DATA_WILL_BE_USED), }; }; diff --git a/src/ui/server/constants/declarations/versions/index.test.ts b/src/ui/server/constants/declarations/versions/index.test.ts index 6eed91fdbf..a4572af441 100644 --- a/src/ui/server/constants/declarations/versions/index.test.ts +++ b/src/ui/server/constants/declarations/versions/index.test.ts @@ -17,7 +17,6 @@ describe('server/constants/declarations/versions', () => { ANTI_BRIBERY_CODE_OF_CONDUCT: '1', ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: '1', CONFIRMATION_AND_ACKNOWLEDGEMENTS: '1', - HOW_YOUR_DATA_WILL_BE_USED: '1', }, ]; diff --git a/src/ui/server/constants/declarations/versions/index.ts b/src/ui/server/constants/declarations/versions/index.ts index 0392faaca4..7983f94088 100644 --- a/src/ui/server/constants/declarations/versions/index.ts +++ b/src/ui/server/constants/declarations/versions/index.ts @@ -21,7 +21,6 @@ const VERSIONS = [ ANTI_BRIBERY_CODE_OF_CONDUCT: '1', ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: '1', CONFIRMATION_AND_ACKNOWLEDGEMENTS: '1', - HOW_YOUR_DATA_WILL_BE_USED: '1', }, ] as Array; diff --git a/src/ui/types/application.ts b/src/ui/types/application.ts index 0ad21ceb57..8ba5ee7f5a 100644 --- a/src/ui/types/application.ts +++ b/src/ui/types/application.ts @@ -289,7 +289,7 @@ interface ApplicationDeclarationVersion { ANTI_BRIBERY_CODE_OF_CONDUCT: string; ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: string; CONFIRMATION_AND_ACKNOWLEDGEMENTS: string; - HOW_YOUR_DATA_WILL_BE_USED: string; + HOW_YOUR_DATA_WILL_BE_USED?: string; } export { From 589b53552d8a7d28ab9744b268dff006413d39dd Mon Sep 17 00:00:00 2001 From: Zain Kassam Date: Wed, 24 Jul 2024 11:19:47 +0100 Subject: [PATCH 5/6] chore(EMS-3631): changed versions to strings --- .../declarations/anti-bribery-code-of-conduct/index.ts | 2 +- .../anti-bribery-exporting-with-code-of-conduct/index.ts | 2 +- .../pages/insurance/declarations/anti-bribery/index.ts | 2 +- .../pages/insurance/declarations/confidentiality/index.ts | 2 +- .../declarations/confirmation-and-acknowledgements/index.ts | 2 +- .../insurance/declarations/how-your-data-will-be-used/index.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-code-of-conduct/index.ts b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-code-of-conduct/index.ts index e22e5858e4..2d76599123 100644 --- a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-code-of-conduct/index.ts +++ b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-code-of-conduct/index.ts @@ -7,7 +7,7 @@ export const ANTI_BRIBERY_CODE_OF_CONDUCT = { 'Do you have in place a code of conduct and written procedures of the type contemplated by Section(2) of the Bribery Act to discourage and prevent corrupt activity?', VERSIONS: [ { - VERSION: 1, + VERSION: '1', ...SHARED, PAGE_TITLE: 'Do you have in place a code of conduct and written procedures of the type contemplated by Section(2) of the Bribery Act to discourage and prevent corrupt activity?', diff --git a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-exporting-with-code-of-conduct/index.ts b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-exporting-with-code-of-conduct/index.ts index 1033846df9..748fdb9387 100644 --- a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-exporting-with-code-of-conduct/index.ts +++ b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery-exporting-with-code-of-conduct/index.ts @@ -5,7 +5,7 @@ export const ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT = { PAGE_TITLE: 'Will you use your anti-bribery code of conduct to win or carry out the exports you want to insure?', VERSIONS: [ { - VERSION: 1, + VERSION: '1', ...SHARED, PAGE_TITLE: 'Will you use your anti-bribery code of conduct to win or carry out the exports you want to insure?', }, diff --git a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery/index.ts b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery/index.ts index c9cbf342f9..e00960e9f9 100644 --- a/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery/index.ts +++ b/src/ui/server/content-strings/pages/insurance/declarations/anti-bribery/index.ts @@ -5,7 +5,7 @@ export const ANTI_BRIBERY = { PAGE_TITLE: 'Anti-bribery and corruption', VERSIONS: [ { - VERSION: 1, + VERSION: '1', ...SHARED, PAGE_TITLE: 'Anti-bribery and corruption', LABEL: `${CONFIRM_READ_AND_AGREE} the anti-bribery and corruption declaration`, diff --git a/src/ui/server/content-strings/pages/insurance/declarations/confidentiality/index.ts b/src/ui/server/content-strings/pages/insurance/declarations/confidentiality/index.ts index d742cf3896..cb317f7eca 100644 --- a/src/ui/server/content-strings/pages/insurance/declarations/confidentiality/index.ts +++ b/src/ui/server/content-strings/pages/insurance/declarations/confidentiality/index.ts @@ -5,7 +5,7 @@ export const CONFIDENTIALITY = { PAGE_TITLE: 'Confidentiality', VERSIONS: [ { - VERSION: 1, + VERSION: '1', ...SHARED, PAGE_TITLE: 'Confidentiality', LABEL: `${CONFIRM_READ_AND_AGREE} the confidentiality declaration`, diff --git a/src/ui/server/content-strings/pages/insurance/declarations/confirmation-and-acknowledgements/index.ts b/src/ui/server/content-strings/pages/insurance/declarations/confirmation-and-acknowledgements/index.ts index 7975d306c7..3e4a9edfb5 100644 --- a/src/ui/server/content-strings/pages/insurance/declarations/confirmation-and-acknowledgements/index.ts +++ b/src/ui/server/content-strings/pages/insurance/declarations/confirmation-and-acknowledgements/index.ts @@ -5,7 +5,7 @@ export const CONFIRMATION_AND_ACKNOWLEDGEMENTS = { PAGE_TITLE: 'Confirmation and acknowledgements', VERSIONS: [ { - VERSION: 1, + VERSION: '1', ...SHARED, PAGE_TITLE: 'Confirmation and acknowledgements', LABEL: `${CONFIRM_READ_AND_AGREE} the confirmation and acknowledgements`, diff --git a/src/ui/server/content-strings/pages/insurance/declarations/how-your-data-will-be-used/index.ts b/src/ui/server/content-strings/pages/insurance/declarations/how-your-data-will-be-used/index.ts index 57304e8b2a..939f6a0e57 100644 --- a/src/ui/server/content-strings/pages/insurance/declarations/how-your-data-will-be-used/index.ts +++ b/src/ui/server/content-strings/pages/insurance/declarations/how-your-data-will-be-used/index.ts @@ -5,7 +5,7 @@ export const HOW_YOUR_DATA_WILL_BE_USED = { PAGE_TITLE: 'How your data will be used', VERSIONS: [ { - VERSION: 1, + VERSION: '1', ...SHARED, PAGE_TITLE: 'How your data will be used', LABEL: `${CONFIRM_READ_AND_AGREE} how your data will be used`, From aa2d22bb450bdc8e37b8be0d6100be32023e6fc7 Mon Sep 17 00:00:00 2001 From: Zain Kassam Date: Wed, 24 Jul 2024 11:34:24 +0100 Subject: [PATCH 6/6] chore(EMS-3631): code improvements --- .../get-latest-declarations/index.test.ts | 6 +++--- .../get-latest-declarations/index.ts | 20 ++++++++++--------- src/ui/server/constants/declarations/index.ts | 4 +--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts b/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts index 8d63b5dc55..71429e7fe4 100644 --- a/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts +++ b/src/ui/server/constants/declarations/get-latest-declarations/index.test.ts @@ -1,4 +1,4 @@ -import getLatestDeclarationVersion, { findLatestVersion } from '.'; +import getLatestDeclarationVersion, { getDeclarationContentStringsByVersionId } from '.'; import VERSIONS from '../versions'; import DECLARATIONS from '../../../content-strings/pages/insurance/declarations'; @@ -6,9 +6,9 @@ const { CONFIDENTIALITY, ANTI_BRIBERY, ANTI_BRIBERY_CODE_OF_CONDUCT, ANTI_BRIBER DECLARATIONS; describe('server/constants/declarations/get-latest-declarations', () => { - describe('findLatestVersion', () => { + describe('getDeclarationContentStringsByVersionId', () => { it('should find content strings by version', () => { - const result = findLatestVersion(CONFIDENTIALITY, VERSIONS[1].CONFIDENTIALITY); + const result = getDeclarationContentStringsByVersionId(CONFIDENTIALITY, VERSIONS[1].CONFIDENTIALITY); const [expected] = CONFIDENTIALITY.VERSIONS; diff --git a/src/ui/server/constants/declarations/get-latest-declarations/index.ts b/src/ui/server/constants/declarations/get-latest-declarations/index.ts index 7292c1e3e8..d58dd1defb 100644 --- a/src/ui/server/constants/declarations/get-latest-declarations/index.ts +++ b/src/ui/server/constants/declarations/get-latest-declarations/index.ts @@ -6,14 +6,14 @@ const { CONFIDENTIALITY, ANTI_BRIBERY, ANTI_BRIBERY_CODE_OF_CONDUCT, ANTI_BRIBER DECLARATIONS; /** - * findLatestVersion + * getDeclarationContentStringsByVersionId * Finds the latest content strings for a specified declaration section * @param {ObjectType} declarationContentStrings: Content strings for specified declaration * @param {string} latestVersionNumber: latest version for specified section * @returns {Object} contentStrings: Content strings for specified version of declaration */ -export const findLatestVersion = (declarationContentStrings: ObjectType, latestVersionNumber: string) => - declarationContentStrings.VERSIONS.find((contentStrings: ObjectType) => contentStrings.VERSION === latestVersionNumber); +export const getDeclarationContentStringsByVersionId = (contentStrings: ObjectType, versionNumber: string) => + contentStrings.VERSIONS.find((strings: ObjectType) => strings.VERSION === versionNumber); /** * getLatestDeclarationsVersion @@ -22,18 +22,20 @@ export const findLatestVersion = (declarationContentStrings: ObjectType, latestV * @returns {Object} contentStrings for the latest version of declarations */ const getLatestDeclarationsVersion = () => { - // get latest declaration versions const latestDeclarationVersions = VERSIONS[VERSIONS.length - 1]; return { - CONFIDENTIALITY: findLatestVersion(CONFIDENTIALITY, latestDeclarationVersions.CONFIDENTIALITY), - ANTI_BRIBERY: findLatestVersion(ANTI_BRIBERY, latestDeclarationVersions.ANTI_BRIBERY), - ANTI_BRIBERY_CODE_OF_CONDUCT: findLatestVersion(ANTI_BRIBERY_CODE_OF_CONDUCT, latestDeclarationVersions.ANTI_BRIBERY_CODE_OF_CONDUCT), - ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: findLatestVersion( + CONFIDENTIALITY: getDeclarationContentStringsByVersionId(CONFIDENTIALITY, latestDeclarationVersions.CONFIDENTIALITY), + ANTI_BRIBERY: getDeclarationContentStringsByVersionId(ANTI_BRIBERY, latestDeclarationVersions.ANTI_BRIBERY), + ANTI_BRIBERY_CODE_OF_CONDUCT: getDeclarationContentStringsByVersionId(ANTI_BRIBERY_CODE_OF_CONDUCT, latestDeclarationVersions.ANTI_BRIBERY_CODE_OF_CONDUCT), + ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT: getDeclarationContentStringsByVersionId( ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, latestDeclarationVersions.ANTI_BRIBERY_EXPORTING_WITH_CODE_OF_CONDUCT, ), - CONFIRMATION_AND_ACKNOWLEDGEMENTS: findLatestVersion(CONFIRMATION_AND_ACKNOWLEDGEMENTS, latestDeclarationVersions.CONFIRMATION_AND_ACKNOWLEDGEMENTS), + CONFIRMATION_AND_ACKNOWLEDGEMENTS: getDeclarationContentStringsByVersionId( + CONFIRMATION_AND_ACKNOWLEDGEMENTS, + latestDeclarationVersions.CONFIRMATION_AND_ACKNOWLEDGEMENTS, + ), }; }; diff --git a/src/ui/server/constants/declarations/index.ts b/src/ui/server/constants/declarations/index.ts index c480e9cfcc..afd55078ed 100644 --- a/src/ui/server/constants/declarations/index.ts +++ b/src/ui/server/constants/declarations/index.ts @@ -1,8 +1,6 @@ import VERSIONS from './versions'; import getLatestDeclarationVersion from './get-latest-declarations'; -const LATEST_DECLARATIONS = getLatestDeclarationVersion(); - /** * DECLARATIONS * DECLARATION constants - declarations need to be versioned so we have a record of which version a user accepted. @@ -11,5 +9,5 @@ const LATEST_DECLARATIONS = getLatestDeclarationVersion(); */ export const DECLARATIONS = { VERSIONS, - LATEST_DECLARATIONS, + LATEST_DECLARATIONS: getLatestDeclarationVersion(), };