Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(EMS-3631): declarations - Declaration versioning in constants #2802

Merged
merged 7 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,42 @@

## [2.16.0](https://github.com/UK-Export-Finance/exip/compare/v2.15.0...v2.16.0) (2024-07-24)


### Features

* **EMS-3536-3540:** remove 'how your data will be used' declaration ([#2789](https://github.com/UK-Export-Finance/exip/issues/2789)) ([9efa559](https://github.com/UK-Export-Finance/exip/commit/9efa5599a9b784eeee96d4f9f536f4b96231a7b1))
- **EMS-3536-3540:** remove 'how your data will be used' declaration ([#2789](https://github.com/UK-Export-Finance/exip/issues/2789)) ([9efa559](https://github.com/UK-Export-Finance/exip/commit/9efa5599a9b784eeee96d4f9f536f4b96231a7b1))

## [2.15.0](https://github.com/UK-Export-Finance/exip/compare/v2.14.0...v2.15.0) (2024-07-23)


### Features

* **EMS-3535:** changes to anti-bribery and corruption definitions ([#2778](https://github.com/UK-Export-Finance/exip/issues/2778)) ([9ec9d20](https://github.com/UK-Export-Finance/exip/commit/9ec9d201026e62c8eb7262a3785419d55f3c2fc1))
- **EMS-3535:** changes to anti-bribery and corruption definitions ([#2778](https://github.com/UK-Export-Finance/exip/issues/2778)) ([9ec9d20](https://github.com/UK-Export-Finance/exip/commit/9ec9d201026e62c8eb7262a3785419d55f3c2fc1))

## [2.14.0](https://github.com/UK-Export-Finance/exip/compare/v2.13.0...v2.14.0) (2024-07-22)


### Features

* **EMS-3610:** changed wording for export contract agent question ([4dd6ed9](https://github.com/UK-Export-Finance/exip/commit/4dd6ed9b7566d515d36338fec15aa56416c609c7))
- **EMS-3610:** changed wording for export contract agent question ([4dd6ed9](https://github.com/UK-Export-Finance/exip/commit/4dd6ed9b7566d515d36338fec15aa56416c609c7))

## [2.13.0](https://github.com/UK-Export-Finance/exip/compare/v2.12.2...v2.13.0) (2024-07-19)


### Features

* **EMS-3606:** added missing environment variables ([5b1fccd](https://github.com/UK-Export-Finance/exip/commit/5b1fccdaf24693c4756d638d0003b521e5815899))
- **EMS-3606:** added missing environment variables ([5b1fccd](https://github.com/UK-Export-Finance/exip/commit/5b1fccdaf24693c4756d638d0003b521e5815899))

## [2.12.2](https://github.com/UK-Export-Finance/exip/compare/v2.12.1...v2.12.2) (2024-07-18)


### Bug Fixes

* **EMS-3604:** no PDF - Anti-bribery code of conduct - Incorrect link ([#2768](https://github.com/UK-Export-Finance/exip/issues/2768)) ([331cc7b](https://github.com/UK-Export-Finance/exip/commit/331cc7bfe59741d669079d68e1f595401d76fe80))
- **EMS-3604:** no PDF - Anti-bribery code of conduct - Incorrect link ([#2768](https://github.com/UK-Export-Finance/exip/issues/2768)) ([331cc7b](https://github.com/UK-Export-Finance/exip/commit/331cc7bfe59741d669079d68e1f595401d76fe80))

## [2.12.1](https://github.com/UK-Export-Finance/exip/compare/v2.12.0...v2.12.1) (2024-07-17)


### Bug Fixes

* **DTFS2-7284:** fixed private endpoint ([f23e285](https://github.com/UK-Export-Finance/exip/commit/f23e285be2b2a25a50c02d02f141907fe2f33454))
* **EM-2186:** fixed conditional deployment ([41d5d4c](https://github.com/UK-Export-Finance/exip/commit/41d5d4cb9615d8afd7b3aec22a41fc8f1bc43d4e))
* **EMS-2186:** removed * from flag ([8f7721f](https://github.com/UK-Export-Finance/exip/commit/8f7721f29bb450e2684fb8403d0a4f5b9e14fce4))
* **EMS-2186:** removed purge protection ([ac65a2e](https://github.com/UK-Export-Finance/exip/commit/ac65a2e023ced9a73f12bf78142b307a5a0fc725))
- **DTFS2-7284:** fixed private endpoint ([f23e285](https://github.com/UK-Export-Finance/exip/commit/f23e285be2b2a25a50c02d02f141907fe2f33454))
- **EM-2186:** fixed conditional deployment ([41d5d4c](https://github.com/UK-Export-Finance/exip/commit/41d5d4cb9615d8afd7b3aec22a41fc8f1bc43d4e))
- **EMS-2186:** removed \* from flag ([8f7721f](https://github.com/UK-Export-Finance/exip/commit/8f7721f29bb450e2684fb8403d0a4f5b9e14fce4))
- **EMS-2186:** removed purge protection ([ac65a2e](https://github.com/UK-Export-Finance/exip/commit/ac65a2e023ced9a73f12bf78142b307a5a0fc725))

## [2.12.0](https://github.com/UK-Export-Finance/exip/compare/v2.11.2...v2.12.0) (2024-07-16)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import getLatestDeclarationVersion, { getDeclarationContentStringsByVersionId } 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 } =
DECLARATIONS;

describe('server/constants/declarations/get-latest-declarations', () => {
describe('getDeclarationContentStringsByVersionId', () => {
it('should find content strings by version', () => {
const result = getDeclarationContentStringsByVersionId(CONFIDENTIALITY, VERSIONS[1].CONFIDENTIALITY);

const [expected] = CONFIDENTIALITY.VERSIONS;

expect(result).toEqual(expected);
});
});

describe('getLatestDeclarationVersion', () => {
it('should return the latest declaration versions', () => {
const result = getLatestDeclarationVersion();

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],
};

expect(result).toEqual(expected);
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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 } =
DECLARATIONS;

/**
* 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 getDeclarationContentStringsByVersionId = (contentStrings: ObjectType, versionNumber: string) =>
contentStrings.VERSIONS.find((strings: ObjectType) => strings.VERSION === versionNumber);

/**
* getLatestDeclarationsVersion
* gets the latest declaration versions for each declaration section
* populates an object with the content strings for that version
* @returns {Object} contentStrings for the latest version of declarations
*/
const getLatestDeclarationsVersion = () => {
const latestDeclarationVersions = VERSIONS[VERSIONS.length - 1];

return {
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: getDeclarationContentStringsByVersionId(
CONFIRMATION_AND_ACKNOWLEDGEMENTS,
latestDeclarationVersions.CONFIRMATION_AND_ACKNOWLEDGEMENTS,
),
};
};

export default getLatestDeclarationsVersion;
13 changes: 13 additions & 0 deletions src/ui/server/constants/declarations/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import VERSIONS from './versions';
import getLatestDeclarationVersion from './get-latest-declarations';

/**
* 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 = {
VERSIONS,
LATEST_DECLARATIONS: getLatestDeclarationVersion(),
};
25 changes: 25 additions & 0 deletions src/ui/server/constants/declarations/versions/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import VERSIONS from '.';

describe('server/constants/declarations/versions', () => {
it('should return an array of versions', () => {
const expected = [
{
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',
},
];

expect(VERSIONS).toEqual(expected);
});
});
27 changes: 27 additions & 0 deletions src/ui/server/constants/declarations/versions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ApplicationDeclarationVersion } from '../../../../types';

/**
* VERSIONS
* All possible declaration versions.
* This should be manually updated each time declarations are updated
* @returns {Array<ApplicationDeclarationVersion>} All declaration versions
*/
const VERSIONS = [
{
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',
},
] as Array<ApplicationDeclarationVersion>;

export default VERSIONS;
1 change: 1 addition & 0 deletions src/ui/server/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/ui/server/content-strings/links.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ROUTES } from '../constants';
import { ROUTES } from '../constants/routes';

export const LINKS = {
ADD: 'Add',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ 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?',
HINT: {
INTRO: 'If no, your attention is drawn to',
LINK: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ 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?',
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ 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`,
OPTION: {
TEXT: `${HAVE_READ_AND_AGREED} the anti-bribery and corruption declaration`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ 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`,
OPTION: {
TEXT: `${HAVE_READ_AND_AGREED} the confirmation and acknowledgements`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { SHARED, CONFIRM_READ_AND_AGREE, HAVE_READ_AND_AGREED } from '../shared';

export const HOW_YOUR_DATA_WILL_BE_USED = {
...SHARED,
PAGE_TITLE: '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`,
VALUE: true,
},
},
],
};
10 changes: 10 additions & 0 deletions src/ui/types/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ interface ApplicationVersion {
DEFAULT_NEED_PRE_CREDIT_PERIOD_COVER: boolean;
}

interface ApplicationDeclarationVersion {
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 {
Application,
ApplicationBusiness,
Expand All @@ -309,6 +318,7 @@ export {
ApplicationPolicyContact,
ApplicationSectionReview,
ApplicationDeclaration,
ApplicationDeclarationVersion,
Zainzzkk marked this conversation as resolved.
Show resolved Hide resolved
ApplicationVersion,
ApplicationOwner,
};
4 changes: 4 additions & 0 deletions src/ui/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
ApplicationPolicy,
ApplicationPolicyContact,
ApplicationPrivateMarket,
ApplicationDeclarationVersion,
ApplicationVersion,
ApplicationOwner,
} from './application';
Expand Down Expand Up @@ -84,6 +85,7 @@ import {
} from './page-variables';
import { InsuranceFeedbackVariables } from './feedback';
import { SanitiseValueObjParams } from './sanitise-value';
import { ObjectType } from './object';

export {
Account,
Expand Down Expand Up @@ -112,6 +114,7 @@ export {
ApplicationPolicy,
ApplicationPolicyContact,
ApplicationPrivateMarket,
ApplicationDeclarationVersion,
ApplicationVersion,
ApplicationByReferenceNumberVariables,
ApolloResponse,
Expand All @@ -137,6 +140,7 @@ export {
InsuranceFeedbackVariables,
Next,
Object,
ObjectType,
PageContentStrings,
PageVariablesContentStrings,
PricingGrid,
Expand Down
5 changes: 5 additions & 0 deletions src/ui/types/object.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type ObjectType = {
[key: string]: any;
};

export { ObjectType };
Loading