From 77bc606079c49d7e532f82ff653b3b99b21a13cf Mon Sep 17 00:00:00 2001 From: Zain Kassam Date: Thu, 25 Jul 2024 11:48:08 +0100 Subject: [PATCH 1/4] feat(EMS-3631): move declarations to content strings from api --- .../declarations/anti-bribery/index.js | 52 +++++++++ .../index.js | 20 ++++ .../anti-bribery/anti-bribery.spec.js | 57 +++++----- .../confidentiality/confidentiality.spec.js | 23 ++-- .../confirmation-and-acknowledgements.spec.js | 34 +++--- .../insurance/declarations/confidentiality.js | 22 ---- .../pages/insurance/declarations/index.js | 3 +- e2e-tests/pages/shared/index.js | 2 + e2e-tests/pages/shared/listPage.js | 17 +++ .../declarations/anti-bribery/index.ts | 52 +++++++++ .../index.ts | 20 ++++ .../declarations/anti-bribery/index.test.ts | 100 ++++-------------- .../declarations/anti-bribery/index.ts | 61 ++++------- .../confidentiality/index.test.ts | 4 +- .../declarations/confidentiality/index.ts | 4 +- .../index.test.ts | 58 +--------- .../index.ts | 59 ++++------- .../index.test.ts | 42 -------- .../index.ts | 26 ----- src/ui/server/test-mocks/index.ts | 2 - src/ui/server/test-mocks/mock-declarations.ts | 76 ------------- .../declarations/declaration-list.njk | 54 ++++++++++ .../components/keystone/document/README.md | 53 ---------- .../keystone/document/blockquote.njk | 34 ------ .../components/keystone/document/index.njk | 54 ---------- .../keystone/document/list-item/child.njk | 50 --------- .../document/list-item/grand-child.njk | 23 ---- .../document/list-item/great-grand-child.njk | 46 -------- .../list-item/great-great-grand-child.njk | 29 ----- .../great-great-great-grand-child.njk | 25 ----- .../keystone/document/list-item/index.njk | 17 --- .../components/keystone/document/list.njk | 41 ------- .../keystone/document/paragraph.njk | 20 ---- .../insurance/declarations/anti-bribery.njk | 10 +- .../declarations/confidentiality.njk | 52 +-------- src/ui/templates/shared-pages/declaration.njk | 11 +- 36 files changed, 351 insertions(+), 902 deletions(-) delete mode 100644 e2e-tests/pages/insurance/declarations/confidentiality.js create mode 100644 e2e-tests/pages/shared/listPage.js delete mode 100644 src/ui/server/helpers/keystone-document-renderer-config/index.test.ts delete mode 100644 src/ui/server/helpers/keystone-document-renderer-config/index.ts delete mode 100644 src/ui/server/test-mocks/mock-declarations.ts create mode 100644 src/ui/templates/components/declarations/declaration-list.njk delete mode 100644 src/ui/templates/components/keystone/document/README.md delete mode 100644 src/ui/templates/components/keystone/document/blockquote.njk delete mode 100644 src/ui/templates/components/keystone/document/index.njk delete mode 100644 src/ui/templates/components/keystone/document/list-item/child.njk delete mode 100644 src/ui/templates/components/keystone/document/list-item/grand-child.njk delete mode 100644 src/ui/templates/components/keystone/document/list-item/great-grand-child.njk delete mode 100644 src/ui/templates/components/keystone/document/list-item/great-great-grand-child.njk delete mode 100644 src/ui/templates/components/keystone/document/list-item/great-great-great-grand-child.njk delete mode 100644 src/ui/templates/components/keystone/document/list-item/index.njk delete mode 100644 src/ui/templates/components/keystone/document/list.njk delete mode 100644 src/ui/templates/components/keystone/document/paragraph.njk 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 932c3d855e..92566bb541 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 @@ -86,6 +86,58 @@ export const ANTI_BRIBERY = { ], }, }, + INTRO: "By submitting this application (also known as a 'proposal') you agree that:", + LIST: [ + { + text: 'neither you nor any of your current Senior Officers appear on a debarment list published by the World Bank Group, the African Development Bank, the Asian Development Bank, the European Bank for Reconstruction and Development or the Inter-American Development Bank (or any successor organisations of the foregoing), of contractors or individuals who are ineligible to tender for, or participate in, any project they fund;', + }, + { + text: 'you have no reason to believe, after having made reasonable enquiries, that any Involved Group Company, Consortium Party or Agent, or any of their current Senior Officers, appear on any such list;', + }, + { + text: 'during the last 5 years neither you nor any of your current Senior Officers or any Group Company have:', + children: [ + { + text: 'been found guilty by any court or competent authority of a Relevant Offence or any offence relating to bribery or corruption under the law of any jurisdiction outside the UK;', + }, + { + text: 'been subject to any administrative sanction (for example, a deferred prosecution agreement or civil forfeiture order) or other similar administrative measure anywhere in the world for contravening any laws which prohibit bribery, including bribery of foreign public officials; or', + }, + { + text: 'admitted to having engaged in any offence or activity as referred to in paragraph (3)(a) above or has admitted to engaging in any other activity which is prohibited under applicable laws relating to bribery or corrupt activity;', + }, + ], + }, + { + text: 'neither you nor any of your current Senior Officers or any Group Company are currently under charge in any court or before any competent authority, or to the best of your knowledge, subject to a formal investigation by public prosecutors on the grounds that you or they have committed an offence of the type listed in paragraph 3(a) above;', + }, + { + text: 'neither you nor any Group Company has: engaged in, any Potential Corrupt Activity or Corrupt Activity in relation to the export contract(s) or any related agreement (which includes any unilateral undertaking as well as any consent or authorisation needed to obtain or perform the export contract(s) but not any subcontract);', + }, + { + text: 'neither you nor any Involved Group Company has any knowledge of any person engaging in any Potential Corrupt Activity or Corrupt Activity in relation to the export contract(s) or any related agreement;', + }, + { + text: 'you have no reason to believe and you do not believe, after having made reasonable enquiries, that:', + children: [ + { + text: 'any Consortium Party or Agent, any of their current Senior Officers has at any time during the last five years engaged in or been subject to any of the events referred to in paragraph (3) above;', + }, + { + text: 'any Consortium Party or Agent or any of their current Senior Officers has at any time during the last five years been subject to any of the events referred to in paragraph (4) above; or', + }, + { + text: 'any Consortium Party or Agent has engaged in any Potential Corrupt Activity or Corrupt Activity in relation to the export contract(s) or any related agreement;', + }, + ], + }, + { + text: 'you have made reasonable enquiries regarding (i) any Consortium Party or Agent and its conduct in relation to the export contract and any related agreement; and (ii) whether any Group Companies, at the date of this Proposal, have had, or are intended to have any material part in the negotiation or supply of the export contract;', + }, + { + text: 'the export contract(s) referred to in this Proposal , and all arrangements connected with its/their financing or procurement, have not been, and will not be, used for the purposes of money laundering (as defined in Part 7 of the Proceeds of Crime Act 2002) or in any other manner that would constitute a Relevant Offence.', + }, + ], }, ], }; diff --git a/e2e-tests/content-strings/pages/insurance/declarations/confirmation-and-acknowledgements/index.js b/e2e-tests/content-strings/pages/insurance/declarations/confirmation-and-acknowledgements/index.js index c1e6b5e226..d5959da878 100644 --- a/e2e-tests/content-strings/pages/insurance/declarations/confirmation-and-acknowledgements/index.js +++ b/e2e-tests/content-strings/pages/insurance/declarations/confirmation-and-acknowledgements/index.js @@ -11,6 +11,26 @@ export const CONFIRMATION_AND_ACKNOWLEDGEMENTS = { TEXT: `${HAVE_READ_AND_AGREED} the confirmation and acknowledgements`, VALUE: true, }, + INTRO: "By submitting this application (also known as a 'proposal') you agree that:", + LIST: [ + { + text: 'you confirm that the information contained in this Proposal and any related discussions or correspondence constitutes a fair presentation of the risk to include all material facts and circumstances; and', + }, + { + text: 'you acknowledge that:', + children: [ + { + text: 'you should contact us or your broker (if applicable) if you are in any doubt as to what constitutes a material fact;', + }, + { + text: 'we will rely on the information, statements and declarations in this Proposal when deciding whether, and on what terms, to issue any policy; and', + }, + { + text: 'you must continue to disclose material facts to us and any changes to material facts after the date of signature of this Proposal until the date cover commences under any policy unless this would, or might reasonably be considered to, constitute the offence of “tipping off” under s.333A of the Proceeds of Crime Act 2002.', + }, + ], + }, + ], }, ], }; diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery.spec.js index 695680b802..b5527739df 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery.spec.js @@ -1,13 +1,10 @@ -import { headingCaption, singleInputField } from '../../../../../../pages/shared'; +import { headingCaption, singleInputField, listPage } from '../../../../../../pages/shared'; import { antiBriberyPage } from '../../../../../../pages/insurance/declarations'; import partials from '../../../../../../partials'; import { PAGES, ERROR_MESSAGES } from '../../../../../../content-strings'; import { FIELD_IDS } from '../../../../../../constants'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; -import api from '../../../../../../commands/api'; -import flattenKeystoneDocument from '../../../../../../commands/flatten-keystone-document'; - const { taskList } = partials.insurancePartials; const CONTENT_STRINGS = PAGES.INSURANCE.DECLARATIONS.ANTI_BRIBERY.VERSIONS[0]; @@ -76,43 +73,41 @@ context( cy.checkText(headingCaption(), CONTENT_STRINGS.HEADING_CAPTION); }); - describe('latest confidentiality content', () => { - let content; - - const { intro, level1, firstLevel2, secondLevel2 } = antiBriberyPage.listItems; + describe('latest anti-bribery content', () => { + const listContent = CONTENT_STRINGS.LIST; - before(() => { - api.declarations.getLatestAntiBribery().then((data) => { - content = flattenKeystoneDocument(data.content.document); - }); - }); + const { intro, level1, level2 } = listPage.listItems; it('renders an intro paragraph', () => { - cy.checkText(intro(), content[0].text); + cy.checkText(intro(), CONTENT_STRINGS.INTRO); }); it('renders level 1 list items', () => { - cy.checkText(level1.item(1), content[1].text); - cy.checkText(level1.item(2), content[2].text); - cy.checkText(level1.item(3), content[3].text); - - cy.checkText(level1.item(4), content[7].text); - cy.checkText(level1.item(5), content[8].text); - cy.checkText(level1.item(6), content[9].text); - cy.checkText(level1.item(7), content[10].text); - - cy.checkText(level1.item(8), content[14].text); - cy.checkText(level1.item(9), content[15].text); + const level1Content = listContent; + + cy.checkText(level1.item(1), level1Content[0].text); + cy.checkText(level1.item(2), level1Content[1].text); + cy.checkText(level1.item(3), level1Content[2].text); + cy.checkText(level1.item(4), level1Content[3].text); + cy.checkText(level1.item(5), level1Content[4].text); + cy.checkText(level1.item(6), level1Content[5].text); + cy.checkText(level1.item(7), level1Content[6].text); + cy.checkText(level1.item(8), level1Content[7].text); + cy.checkText(level1.item(9), level1Content[8].text); }); it('renders level 2 list items', () => { - cy.checkText(firstLevel2.item(1), content[4].text); - cy.checkText(firstLevel2.item(2), content[5].text); - cy.checkText(firstLevel2.item(3), content[6].text); + const level2Content0 = listContent[2].children; + + cy.checkText(level2.itemLevel(1, 0), level2Content0[0].text); + cy.checkText(level2.itemLevel(2, 0), level2Content0[1].text); + cy.checkText(level2.itemLevel(3, 0), level2Content0[2].text); + + const level2Content1 = listContent[6].children; - cy.checkText(secondLevel2.item(1), content[11].text); - cy.checkText(secondLevel2.item(2), content[12].text); - cy.checkText(secondLevel2.item(3), content[13].text); + cy.checkText(level2.itemLevel(1, 1), level2Content1[0].text); + cy.checkText(level2.itemLevel(2, 1), level2Content1[1].text); + cy.checkText(level2.itemLevel(3, 1), level2Content1[2].text); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confidentiality/confidentiality.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confidentiality/confidentiality.spec.js index aa6d931629..55ef09ab8a 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confidentiality/confidentiality.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confidentiality/confidentiality.spec.js @@ -1,5 +1,4 @@ -import { headingCaption, singleInputField } from '../../../../../../pages/shared'; -import { confidentialityPage } from '../../../../../../pages/insurance/declarations'; +import { headingCaption, singleInputField, listPage } from '../../../../../../pages/shared'; import partials from '../../../../../../partials'; import { PAGES, ERROR_MESSAGES } from '../../../../../../content-strings'; import { FIELD_IDS } from '../../../../../../constants'; @@ -76,7 +75,7 @@ context( describe('latest confidentiality content', () => { const listContent = CONTENT_STRINGS.LIST; - const { intro, level1, level2, level3 } = confidentialityPage.listItems; + const { intro, level1, level2, level3 } = listPage.listItems; it('renders an intro paragraph', () => { cy.checkText(intro(), CONTENT_STRINGS.INTRO); @@ -85,25 +84,25 @@ context( it('renders level 1 list items', () => { const level1Content = listContent; - cy.checkText(level1.item1(), level1Content[0].text); - cy.checkText(level1.item2(), level1Content[1].text); - cy.checkText(level1.item3(), level1Content[2].text); + cy.checkText(level1.item(1), level1Content[0].text); + cy.checkText(level1.item(2), level1Content[1].text); + cy.checkText(level1.item(3), level1Content[2].text); }); it('renders level 2 list items', () => { const level2Content = listContent[0].children; - cy.checkText(level2.item1(), level2Content[0].text); - cy.checkText(level2.item2(), level2Content[1].text); - cy.checkText(level2.item3(), level2Content[2].text); - cy.checkText(level2.item4(), level2Content[3].text); + cy.checkText(level2.item(1), level2Content[0].text); + cy.checkText(level2.item(2), level2Content[1].text); + cy.checkText(level2.item(3), level2Content[2].text); + cy.checkText(level2.item(4), level2Content[3].text); }); it('renders level 3 list items', () => { const level3Content = listContent[0].children[3].children; - cy.checkText(level3.item1(), level3Content[0].text); - cy.checkText(level3.item2(), level3Content[1].text); + cy.checkText(level3.item(1), level3Content[0].text); + cy.checkText(level3.item(2), level3Content[1].text); }); }); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/confirmation-and-acknowledgements.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/confirmation-and-acknowledgements.spec.js index 3eef571458..0cfa2c86a1 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/confirmation-and-acknowledgements.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/confirmation-and-acknowledgements.spec.js @@ -1,13 +1,9 @@ -import { headingCaption, singleInputField } from '../../../../../../pages/shared'; -import { confirmationAndAcknowledgementsPage } from '../../../../../../pages/insurance/declarations'; +import { headingCaption, singleInputField, listPage } from '../../../../../../pages/shared'; import partials from '../../../../../../partials'; import { PAGES, ERROR_MESSAGES } from '../../../../../../content-strings'; import { FIELD_IDS } from '../../../../../../constants'; import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; -import api from '../../../../../../commands/api'; -import flattenKeystoneDocument from '../../../../../../commands/flatten-keystone-document'; - const { taskList } = partials.insurancePartials; const CONTENT_STRINGS = PAGES.INSURANCE.DECLARATIONS.CONFIRMATION_AND_ACKNOWLEDGEMENTS.VERSIONS[0]; @@ -81,30 +77,28 @@ context( cy.checkText(headingCaption(), CONTENT_STRINGS.HEADING_CAPTION); }); - describe('latest confidentiality content', () => { - let content; - - const { intro, level1, level2 } = confirmationAndAcknowledgementsPage.listItems; + describe('latest confirmation-and-acknowledgements content', () => { + const listContent = CONTENT_STRINGS.LIST; - before(() => { - api.declarations.getLatestConfirmationAndAcknowledgements().then((data) => { - content = flattenKeystoneDocument(data.content.document); - }); - }); + const { intro, level1, level2 } = listPage.listItems; it('renders an intro paragraph', () => { - cy.checkText(intro(), content[0].text); + cy.checkText(intro(), CONTENT_STRINGS.INTRO); }); it('renders level 1 list items', () => { - cy.checkText(level1.item(1), content[1].text); - cy.checkText(level1.item(2), content[2].text); + const level1Content = listContent; + + cy.checkText(level1.item(1), level1Content[0].text); + cy.checkText(level1.item(2), level1Content[1].text); }); it('renders level 2 list items', () => { - cy.checkText(level2.item(1), content[3].text); - cy.checkText(level2.item(2), content[4].text); - cy.checkText(level2.item(3), content[5].text); + const level2Content = listContent[1].children; + + cy.checkText(level2.item(1), level2Content[0].text); + cy.checkText(level2.item(2), level2Content[1].text); + cy.checkText(level2.item(3), level2Content[2].text); }); }); diff --git a/e2e-tests/pages/insurance/declarations/confidentiality.js b/e2e-tests/pages/insurance/declarations/confidentiality.js deleted file mode 100644 index 9bccab5516..0000000000 --- a/e2e-tests/pages/insurance/declarations/confidentiality.js +++ /dev/null @@ -1,22 +0,0 @@ -const confidentialityPage = { - listItems: { - intro: () => cy.get("[data-cy='intro']"), - level1: { - item1: () => cy.get("[data-cy='list-level-1-item-1']"), - item2: () => cy.get("[data-cy='list-level-1-item-2']"), - item3: () => cy.get("[data-cy='list-level-1-item-3']"), - }, - level2: { - item1: () => cy.get("[data-cy='list-level-2-item-1']"), - item2: () => cy.get("[data-cy='list-level-2-item-2']"), - item3: () => cy.get("[data-cy='list-level-2-item-3']"), - item4: () => cy.get("[data-cy='list-level-2-item-4']"), - }, - level3: { - item1: () => cy.get("[data-cy='list-level-3-item-1']"), - item2: () => cy.get("[data-cy='list-level-3-item-2']"), - }, - }, -}; - -export default confidentialityPage; diff --git a/e2e-tests/pages/insurance/declarations/index.js b/e2e-tests/pages/insurance/declarations/index.js index 0ac38f5088..1b077f9832 100644 --- a/e2e-tests/pages/insurance/declarations/index.js +++ b/e2e-tests/pages/insurance/declarations/index.js @@ -1,7 +1,6 @@ -import confidentialityPage from './confidentiality'; import antiBriberyPage from './anti-bribery'; import codeOfConductPage from './code-of-conduct'; import confirmationAndAcknowledgementsPage from './confirmation-and-acknowledgements'; import exportingWithCodeOfConductPage from './exporting-with-code-of-conduct'; -export { confidentialityPage, antiBriberyPage, codeOfConductPage, confirmationAndAcknowledgementsPage, exportingWithCodeOfConductPage }; +export { antiBriberyPage, codeOfConductPage, confirmationAndAcknowledgementsPage, exportingWithCodeOfConductPage }; diff --git a/e2e-tests/pages/shared/index.js b/e2e-tests/pages/shared/index.js index b20cde9901..0ff218099f 100644 --- a/e2e-tests/pages/shared/index.js +++ b/e2e-tests/pages/shared/index.js @@ -7,6 +7,7 @@ import needToStartAgainPage from './needToStartAgain'; import summaryList from './summaryList'; import ukGoodsOrServicesPage from './ukGoodsOrServices'; import field from './field'; +import listPage from './listPage'; const allSectionsLink = () => cy.get('[data-cy="all-sections-link"]'); const backLink = () => cy.get('[data-cy="back-link"]'); @@ -70,6 +71,7 @@ export { listIntro, listItem, listOutro, + listPage, yesNoRadioHint, yesRadio, yesRadioInput, diff --git a/e2e-tests/pages/shared/listPage.js b/e2e-tests/pages/shared/listPage.js new file mode 100644 index 0000000000..5920232550 --- /dev/null +++ b/e2e-tests/pages/shared/listPage.js @@ -0,0 +1,17 @@ +const listPage = { + listItems: { + intro: () => cy.get("[data-cy='intro']"), + level1: { + item: (itemNumber) => cy.get(`[data-cy='list-level-1-item-${itemNumber}']`), + }, + level2: { + item: (itemNumber) => cy.get(`[data-cy='list-level-2-item-${itemNumber}']`), + itemLevel: (itemNumber, level) => cy.get(`[data-cy='list-level-2-item-${itemNumber}']`).eq(level), + }, + level3: { + item: (itemNumber) => cy.get(`[data-cy='list-level-3-item-${itemNumber}']`), + }, + }, +}; + +export default listPage; 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 219323908f..1e47f0aef1 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 @@ -86,6 +86,58 @@ export const ANTI_BRIBERY = { ], }, }, + INTRO: "By submitting this application (also known as a 'proposal') you agree that:", + LIST: [ + { + text: 'neither you nor any of your current Senior Officers appear on a debarment list published by the World Bank Group, the African Development Bank, the Asian Development Bank, the European Bank for Reconstruction and Development or the Inter-American Development Bank (or any successor organisations of the foregoing), of contractors or individuals who are ineligible to tender for, or participate in, any project they fund;', + }, + { + text: 'you have no reason to believe, after having made reasonable enquiries, that any Involved Group Company, Consortium Party or Agent, or any of their current Senior Officers, appear on any such list;', + }, + { + text: 'during the last 5 years neither you nor any of your current Senior Officers or any Group Company have:', + children: [ + { + text: 'been found guilty by any court or competent authority of a Relevant Offence or any offence relating to bribery or corruption under the law of any jurisdiction outside the UK;', + }, + { + text: 'been subject to any administrative sanction (for example, a deferred prosecution agreement or civil forfeiture order) or other similar administrative measure anywhere in the world for contravening any laws which prohibit bribery, including bribery of foreign public officials; or', + }, + { + text: 'admitted to having engaged in any offence or activity as referred to in paragraph (3)(a) above or has admitted to engaging in any other activity which is prohibited under applicable laws relating to bribery or corrupt activity;', + }, + ], + }, + { + text: 'neither you nor any of your current Senior Officers or any Group Company are currently under charge in any court or before any competent authority, or to the best of your knowledge, subject to a formal investigation by public prosecutors on the grounds that you or they have committed an offence of the type listed in paragraph 3(a) above;', + }, + { + text: 'neither you nor any Group Company has: engaged in, any Potential Corrupt Activity or Corrupt Activity in relation to the export contract(s) or any related agreement (which includes any unilateral undertaking as well as any consent or authorisation needed to obtain or perform the export contract(s) but not any subcontract);', + }, + { + text: 'neither you nor any Involved Group Company has any knowledge of any person engaging in any Potential Corrupt Activity or Corrupt Activity in relation to the export contract(s) or any related agreement;', + }, + { + text: 'you have no reason to believe and you do not believe, after having made reasonable enquiries, that:', + children: [ + { + text: 'any Consortium Party or Agent, any of their current Senior Officers has at any time during the last five years engaged in or been subject to any of the events referred to in paragraph (3) above;', + }, + { + text: 'any Consortium Party or Agent or any of their current Senior Officers has at any time during the last five years been subject to any of the events referred to in paragraph (4) above; or', + }, + { + text: 'any Consortium Party or Agent has engaged in any Potential Corrupt Activity or Corrupt Activity in relation to the export contract(s) or any related agreement;', + }, + ], + }, + { + text: 'you have made reasonable enquiries regarding (i) any Consortium Party or Agent and its conduct in relation to the export contract and any related agreement; and (ii) whether any Group Companies, at the date of this Proposal, have had, or are intended to have any material part in the negotiation or supply of the export contract;', + }, + { + text: 'the export contract(s) referred to in this Proposal , and all arrangements connected with its/their financing or procurement, have not been, and will not be, used for the purposes of money laundering (as defined in Part 7 of the Proceeds of Crime Act 2002) or in any other manner that would constitute a Relevant Offence.', + }, + ], }, ], }; 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 9a0a421bea..e45f5e488d 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 @@ -11,6 +11,26 @@ export const CONFIRMATION_AND_ACKNOWLEDGEMENTS = { TEXT: `${HAVE_READ_AND_AGREED} the confirmation and acknowledgements`, VALUE: true, }, + INTRO: "By submitting this application (also known as a 'proposal') you agree that:", + LIST: [ + { + text: 'you confirm that the information contained in this Proposal and any related discussions or correspondence constitutes a fair presentation of the risk to include all material facts and circumstances; and', + }, + { + text: 'you acknowledge that:', + children: [ + { + text: 'you should contact us or your broker (if applicable) if you are in any doubt as to what constitutes a material fact;', + }, + { + text: 'we will rely on the information, statements and declarations in this Proposal when deciding whether, and on what terms, to issue any policy; and', + }, + { + text: 'you must continue to disclose material facts to us and any changes to material facts after the date of signature of this Proposal until the date cover commences under any policy unless this would, or might reasonably be considered to, constitute the offence of “tipping off” under s.333A of the Proceeds of Crime Act 2002.', + }, + ], + }, + ], }, ], }; diff --git a/src/ui/server/controllers/insurance/declarations/anti-bribery/index.test.ts b/src/ui/server/controllers/insurance/declarations/anti-bribery/index.test.ts index 1ed6614d86..7cc03235aa 100644 --- a/src/ui/server/controllers/insurance/declarations/anti-bribery/index.test.ts +++ b/src/ui/server/controllers/insurance/declarations/anti-bribery/index.test.ts @@ -1,16 +1,14 @@ import { FIELD_ID, pageVariables, TEMPLATE, get, post } from '.'; import { ERROR_MESSAGES } from '../../../../content-strings'; import { FIELD_IDS, TEMPLATES, ROUTES, DECLARATIONS } from '../../../../constants'; -import api from '../../../../api'; import insuranceCorePageVariables from '../../../../helpers/page-variables/core/insurance'; import getUserNameFromSession from '../../../../helpers/get-user-name-from-session'; import constructPayload from '../../../../helpers/construct-payload'; import mapApplicationToFormFields from '../../../../helpers/mappings/map-application-to-form-fields'; -import keystoneDocumentRendererConfig from '../../../../helpers/keystone-document-renderer-config'; import generateValidationErrors from '../../../../shared-validation/yes-no-radios-form'; import save from '../save-data'; import { Request, Response } from '../../../../../types'; -import { mockReq, mockRes, mockApplication, mockDeclarations, mockSpyPromise, referenceNumber } from '../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockSpyPromise, referenceNumber } from '../../../../test-mocks'; const { INSURANCE_ROOT, @@ -32,13 +30,9 @@ describe('controllers/insurance/declarations/anti-bribery', () => { let req: Request; let res: Response; - let getLatestAntiBriberySpy = jest.fn(() => Promise.resolve(mockDeclarations.antiBribery)); - beforeEach(() => { req = mockReq(); res = mockRes(); - - api.keystone.application.declarations.getLatestAntiBribery = getLatestAntiBriberySpy; }); describe('FIELD_ID', () => { @@ -72,12 +66,6 @@ describe('controllers/insurance/declarations/anti-bribery', () => { }); describe('get', () => { - it('should call api.keystone.application.declarations.getLatestAntiBribery', async () => { - await get(req, res); - - expect(getLatestAntiBriberySpy).toHaveBeenCalledTimes(1); - }); - it('should render template', async () => { await get(req, res); @@ -88,9 +76,8 @@ describe('controllers/insurance/declarations/anti-bribery', () => { }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - documentContent: mockDeclarations.antiBribery.content.document, - documentConfig: keystoneDocumentRendererConfig(), application: mapApplicationToFormFields(res.locals.application), + CONTENT: ANTI_BRIBERY, }; expect(res.render).toHaveBeenCalledWith(TEMPLATE, expectedVariables); @@ -107,19 +94,6 @@ describe('controllers/insurance/declarations/anti-bribery', () => { expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); }); }); - - describe('when there is an error calling the API', () => { - beforeAll(() => { - getLatestAntiBriberySpy = jest.fn(() => Promise.reject(new Error('mock'))); - api.keystone.application.declarations.getLatestAntiBribery = getLatestAntiBriberySpy; - }); - - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await get(req, res); - - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); - }); - }); }); describe('post', () => { @@ -127,12 +101,6 @@ describe('controllers/insurance/declarations/anti-bribery', () => { [FIELD_ID]: 'true', }; - beforeEach(() => { - getLatestAntiBriberySpy = jest.fn(() => Promise.resolve(mockDeclarations.confidentiality)); - - api.keystone.application.declarations.getLatestAntiBribery = getLatestAntiBriberySpy; - }); - describe('when there are no validation errors', () => { beforeEach(() => { req.body = validBody; @@ -157,12 +125,6 @@ describe('controllers/insurance/declarations/anti-bribery', () => { }); describe('when there are validation errors', () => { - it('should call api.keystone.application.declarations.getLatestConfidentiality', async () => { - await post(req, res); - - expect(getLatestAntiBriberySpy).toHaveBeenCalledTimes(1); - }); - it('should render template with validation errors from constructPayload function', async () => { await post(req, res); @@ -175,9 +137,8 @@ describe('controllers/insurance/declarations/anti-bribery', () => { }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - documentContent: mockDeclarations.confidentiality.content.document, - documentConfig: keystoneDocumentRendererConfig(), validationErrors: generateValidationErrors(payload, FIELD_ID, ERROR_MESSAGES.INSURANCE.DECLARATIONS[FIELD_ID].IS_EMPTY), + CONTENT: ANTI_BRIBERY, }; expect(res.render).toHaveBeenCalledWith(TEMPLATE, expectedVariables); @@ -197,50 +158,33 @@ describe('controllers/insurance/declarations/anti-bribery', () => { }); describe('api error handling', () => { - describe('get latest anti-bribery call', () => { - describe('when the get latest anti-bribery API call fails', () => { - beforeEach(() => { - getLatestAntiBriberySpy = jest.fn(() => Promise.reject(new Error('mock'))); - api.keystone.application.declarations.getLatestAntiBribery = getLatestAntiBriberySpy; - }); - - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await post(req, res); - - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); - }); - }); - }); - - describe('save data call', () => { - describe('when the save data API call does not return anything', () => { - beforeEach(() => { - mockSaveDeclaration = jest.fn(() => Promise.resolve(false)); - save.declaration = mockSaveDeclaration; + describe('when the save data API call does not return anything', () => { + beforeEach(() => { + mockSaveDeclaration = jest.fn(() => Promise.resolve(false)); + save.declaration = mockSaveDeclaration; - req.body = validBody; - }); + req.body = validBody; + }); - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await post(req, res); + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); - }); + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); }); + }); - describe('when the save data API call fails', () => { - beforeEach(() => { - mockSaveDeclaration = jest.fn(() => Promise.reject(new Error('mock'))); - save.declaration = mockSaveDeclaration; + describe('when the save data API call fails', () => { + beforeEach(() => { + mockSaveDeclaration = jest.fn(() => Promise.reject(new Error('mock'))); + save.declaration = mockSaveDeclaration; - req.body = validBody; - }); + req.body = validBody; + }); - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await post(req, res); + it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { + await post(req, res); - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); - }); + expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); }); }); }); diff --git a/src/ui/server/controllers/insurance/declarations/anti-bribery/index.ts b/src/ui/server/controllers/insurance/declarations/anti-bribery/index.ts index 53adb5a0c2..dd12c60fca 100644 --- a/src/ui/server/controllers/insurance/declarations/anti-bribery/index.ts +++ b/src/ui/server/controllers/insurance/declarations/anti-bribery/index.ts @@ -1,11 +1,9 @@ import { ERROR_MESSAGES } from '../../../../content-strings'; import { FIELD_IDS, TEMPLATES, ROUTES, DECLARATIONS } from '../../../../constants'; -import api from '../../../../api'; import insuranceCorePageVariables from '../../../../helpers/page-variables/core/insurance'; import getUserNameFromSession from '../../../../helpers/get-user-name-from-session'; import constructPayload from '../../../../helpers/construct-payload'; import mapApplicationToFormFields from '../../../../helpers/mappings/map-application-to-form-fields'; -import keystoneDocumentRendererConfig from '../../../../helpers/keystone-document-renderer-config'; import generateValidationErrors from '../../../../shared-validation/yes-no-radios-form'; import save from '../save-data'; import { Request, Response } from '../../../../../types'; @@ -51,26 +49,16 @@ export const get = async (req: Request, res: Response) => { if (!application) { return res.redirect(PROBLEM_WITH_SERVICE); } - - try { - const antiBriberyContent = await api.keystone.application.declarations.getLatestAntiBribery(); - - return res.render(TEMPLATE, { - ...insuranceCorePageVariables({ - PAGE_CONTENT_STRINGS: ANTI_BRIBERY, - BACK_LINK: req.headers.referer, - }), - ...pageVariables(application.referenceNumber), - userName: getUserNameFromSession(req.session.user), - documentContent: antiBriberyContent.content.document, - documentConfig: keystoneDocumentRendererConfig(), - application: mapApplicationToFormFields(res.locals.application), - }); - } catch (err) { - console.error("Error getting declarations - anti-bribery and rendering 'anti-bribery' page %O", err); - - return res.redirect(PROBLEM_WITH_SERVICE); - } + return res.render(TEMPLATE, { + ...insuranceCorePageVariables({ + PAGE_CONTENT_STRINGS: ANTI_BRIBERY, + BACK_LINK: req.headers.referer, + }), + ...pageVariables(application.referenceNumber), + userName: getUserNameFromSession(req.session.user), + application: mapApplicationToFormFields(res.locals.application), + CONTENT: ANTI_BRIBERY, + }); }; /** @@ -94,25 +82,16 @@ export const post = async (req: Request, res: Response) => { const validationErrors = generateValidationErrors(payload, FIELD_ID, ERROR_MESSAGES.INSURANCE.DECLARATIONS[FIELD_ID].IS_EMPTY); if (validationErrors) { - try { - const antiBriberyContent = await api.keystone.application.declarations.getLatestAntiBribery(); - - return res.render(TEMPLATE, { - ...insuranceCorePageVariables({ - PAGE_CONTENT_STRINGS: ANTI_BRIBERY, - BACK_LINK: req.headers.referer, - }), - ...pageVariables(referenceNumber), - userName: getUserNameFromSession(req.session.user), - documentContent: antiBriberyContent.content.document, - documentConfig: keystoneDocumentRendererConfig(), - validationErrors, - }); - } catch (err) { - console.error("Error getting declarations - confidentiality and rendering 'confidentiality' page %O", err); - - return res.redirect(PROBLEM_WITH_SERVICE); - } + return res.render(TEMPLATE, { + ...insuranceCorePageVariables({ + PAGE_CONTENT_STRINGS: ANTI_BRIBERY, + BACK_LINK: req.headers.referer, + }), + ...pageVariables(referenceNumber), + userName: getUserNameFromSession(req.session.user), + CONTENT: ANTI_BRIBERY, + validationErrors, + }); } try { diff --git a/src/ui/server/controllers/insurance/declarations/confidentiality/index.test.ts b/src/ui/server/controllers/insurance/declarations/confidentiality/index.test.ts index 10ac58592a..a69839b5f5 100644 --- a/src/ui/server/controllers/insurance/declarations/confidentiality/index.test.ts +++ b/src/ui/server/controllers/insurance/declarations/confidentiality/index.test.ts @@ -77,7 +77,7 @@ describe('controllers/insurance/declarations/confidentiality', () => { }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - CONFIDENTIALITY_CONTENT: CONFIDENTIALITY, + CONTENT: CONFIDENTIALITY, application: mapApplicationToFormFields(res.locals.application), }; @@ -138,7 +138,7 @@ describe('controllers/insurance/declarations/confidentiality', () => { }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - CONFIDENTIALITY_CONTENT: CONFIDENTIALITY, + CONTENT: CONFIDENTIALITY, validationErrors: generateValidationErrors(payload, FIELD_ID, ERROR_MESSAGES.INSURANCE.DECLARATIONS[FIELD_ID].IS_EMPTY), }; diff --git a/src/ui/server/controllers/insurance/declarations/confidentiality/index.ts b/src/ui/server/controllers/insurance/declarations/confidentiality/index.ts index b7f3677dff..4ded339e37 100644 --- a/src/ui/server/controllers/insurance/declarations/confidentiality/index.ts +++ b/src/ui/server/controllers/insurance/declarations/confidentiality/index.ts @@ -58,7 +58,7 @@ export const get = async (req: Request, res: Response) => { }), ...pageVariables(application.referenceNumber), userName: getUserNameFromSession(req.session.user), - CONFIDENTIALITY_CONTENT: CONFIDENTIALITY, + CONTENT: CONFIDENTIALITY, application: mapApplicationToFormFields(res.locals.application), }); }; @@ -91,7 +91,7 @@ export const post = async (req: Request, res: Response) => { }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - CONFIDENTIALITY_CONTENT: CONFIDENTIALITY, + CONTENT: CONFIDENTIALITY, validationErrors, }); } diff --git a/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.test.ts b/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.test.ts index 68e3755ed4..0423107e53 100644 --- a/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.test.ts +++ b/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.test.ts @@ -6,11 +6,10 @@ import insuranceCorePageVariables from '../../../../helpers/page-variables/core/ import getUserNameFromSession from '../../../../helpers/get-user-name-from-session'; import constructPayload from '../../../../helpers/construct-payload'; import mapApplicationToFormFields from '../../../../helpers/mappings/map-application-to-form-fields'; -import keystoneDocumentRendererConfig from '../../../../helpers/keystone-document-renderer-config'; import generateValidationErrors from '../../../../shared-validation/yes-no-radios-form'; import save from '../save-data'; import { Request, Response } from '../../../../../types'; -import { mockReq, mockRes, mockApplication, mockDeclarations, mockSpyPromise, referenceNumber } from '../../../../test-mocks'; +import { mockReq, mockRes, mockApplication, mockSpyPromise, referenceNumber } from '../../../../test-mocks'; const { INSURANCE_ROOT, @@ -31,15 +30,11 @@ describe('controllers/insurance/declarations/confirmation-and-acknowledgements', let req: Request; let res: Response; - let getLatestConfirmationAndAcknowledgementSpy = jest.fn(() => Promise.resolve(mockDeclarations.confirmationAndAcknowledgement)); - let submitApplicationSpy = jest.fn(() => Promise.resolve({ success: true })); beforeEach(() => { req = mockReq(); res = mockRes(); - - api.keystone.application.declarations.getLatestConfirmationAndAcknowledgement = getLatestConfirmationAndAcknowledgementSpy; }); describe('FIELD_ID', () => { @@ -73,12 +68,6 @@ describe('controllers/insurance/declarations/confirmation-and-acknowledgements', }); describe('get', () => { - it('should call api.keystone.application.declarations.getLatestConfirmationAndAcknowledgement', async () => { - await get(req, res); - - expect(getLatestConfirmationAndAcknowledgementSpy).toHaveBeenCalledTimes(1); - }); - it('should render template', async () => { await get(req, res); @@ -89,8 +78,7 @@ describe('controllers/insurance/declarations/confirmation-and-acknowledgements', }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - documentContent: mockDeclarations.confirmationAndAcknowledgement.content.document, - documentConfig: keystoneDocumentRendererConfig(), + CONTENT: CONFIRMATION_AND_ACKNOWLEDGEMENTS, application: mapApplicationToFormFields(res.locals.application), }; @@ -108,20 +96,6 @@ describe('controllers/insurance/declarations/confirmation-and-acknowledgements', expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); }); }); - - describe('when there is an error calling the API', () => { - beforeAll(() => { - getLatestConfirmationAndAcknowledgementSpy = jest.fn(() => Promise.reject(new Error('mock'))); - - api.keystone.application.declarations.getLatestConfirmationAndAcknowledgement = getLatestConfirmationAndAcknowledgementSpy; - }); - - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await get(req, res); - - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); - }); - }); }); describe('post', () => { @@ -130,10 +104,6 @@ describe('controllers/insurance/declarations/confirmation-and-acknowledgements', }; beforeEach(() => { - getLatestConfirmationAndAcknowledgementSpy = jest.fn(() => Promise.resolve(mockDeclarations.confirmationAndAcknowledgement)); - - api.keystone.application.declarations.getLatestConfirmationAndAcknowledgement = getLatestConfirmationAndAcknowledgementSpy; - api.keystone.application.submit = submitApplicationSpy; }); @@ -181,12 +151,6 @@ describe('controllers/insurance/declarations/confirmation-and-acknowledgements', }); describe('when there are validation errors', () => { - it('should call api.keystone.application.declarations.getLatestConfirmationAndAcknowledgement', async () => { - await post(req, res); - - expect(getLatestConfirmationAndAcknowledgementSpy).toHaveBeenCalledTimes(1); - }); - it('should render template with validation errors from constructPayload function', async () => { await post(req, res); @@ -199,8 +163,7 @@ describe('controllers/insurance/declarations/confirmation-and-acknowledgements', }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - documentContent: mockDeclarations.confirmationAndAcknowledgement.content.document, - documentConfig: keystoneDocumentRendererConfig(), + CONTENT: CONFIRMATION_AND_ACKNOWLEDGEMENTS, validationErrors: generateValidationErrors(payload, FIELD_ID, ERROR_MESSAGES.INSURANCE.DECLARATIONS[FIELD_ID].IS_EMPTY), }; @@ -221,21 +184,6 @@ describe('controllers/insurance/declarations/confirmation-and-acknowledgements', }); describe('api error handling', () => { - describe('get latest confirmation and acknowledgements call', () => { - describe('when the get latest confirmation and acknowledgements API call fails', () => { - beforeEach(() => { - getLatestConfirmationAndAcknowledgementSpy = jest.fn(() => Promise.reject(new Error('mock'))); - api.keystone.application.declarations.getLatestConfirmationAndAcknowledgement = getLatestConfirmationAndAcknowledgementSpy; - }); - - it(`should redirect to ${PROBLEM_WITH_SERVICE}`, async () => { - await post(req, res); - - expect(res.redirect).toHaveBeenCalledWith(PROBLEM_WITH_SERVICE); - }); - }); - }); - describe('save data call', () => { describe('when the save data API call does not return anything', () => { beforeEach(() => { diff --git a/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.ts b/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.ts index ac15f1807d..f1b0719a08 100644 --- a/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.ts +++ b/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.ts @@ -5,7 +5,6 @@ import insuranceCorePageVariables from '../../../../helpers/page-variables/core/ import getUserNameFromSession from '../../../../helpers/get-user-name-from-session'; import constructPayload from '../../../../helpers/construct-payload'; import mapApplicationToFormFields from '../../../../helpers/mappings/map-application-to-form-fields'; -import keystoneDocumentRendererConfig from '../../../../helpers/keystone-document-renderer-config'; import generateValidationErrors from '../../../../shared-validation/yes-no-radios-form'; import save from '../save-data'; import canSubmitApplication from '../../../../helpers/can-submit-application'; @@ -52,25 +51,16 @@ export const get = async (req: Request, res: Response) => { return res.redirect(PROBLEM_WITH_SERVICE); } - try { - const declarationContent = await api.keystone.application.declarations.getLatestConfirmationAndAcknowledgement(); - - return res.render(TEMPLATE, { - ...insuranceCorePageVariables({ - PAGE_CONTENT_STRINGS: CONFIRMATION_AND_ACKNOWLEDGEMENTS, - BACK_LINK: req.headers.referer, - }), - ...pageVariables(application.referenceNumber), - userName: getUserNameFromSession(req.session.user), - documentContent: declarationContent.content.document, - documentConfig: keystoneDocumentRendererConfig(), - application: mapApplicationToFormFields(res.locals.application), - }); - } catch (err) { - console.error("Error getting declarations - confirmation and acknowledgements and rendering 'confirmation and acknowledgements' page %O", err); - - return res.redirect(PROBLEM_WITH_SERVICE); - } + return res.render(TEMPLATE, { + ...insuranceCorePageVariables({ + PAGE_CONTENT_STRINGS: CONFIRMATION_AND_ACKNOWLEDGEMENTS, + BACK_LINK: req.headers.referer, + }), + ...pageVariables(application.referenceNumber), + userName: getUserNameFromSession(req.session.user), + CONTENT: CONFIRMATION_AND_ACKNOWLEDGEMENTS, + application: mapApplicationToFormFields(res.locals.application), + }); }; /** @@ -94,25 +84,16 @@ export const post = async (req: Request, res: Response) => { const validationErrors = generateValidationErrors(payload, FIELD_ID, ERROR_MESSAGES.INSURANCE.DECLARATIONS[FIELD_ID].IS_EMPTY); if (validationErrors) { - try { - const declarationContent = await api.keystone.application.declarations.getLatestConfirmationAndAcknowledgement(); - - return res.render(TEMPLATE, { - ...insuranceCorePageVariables({ - PAGE_CONTENT_STRINGS: CONFIRMATION_AND_ACKNOWLEDGEMENTS, - BACK_LINK: req.headers.referer, - }), - ...pageVariables(referenceNumber), - userName: getUserNameFromSession(req.session.user), - documentContent: declarationContent.content.document, - documentConfig: keystoneDocumentRendererConfig(), - validationErrors, - }); - } catch (err) { - console.error("Error getting declarations - confirmation and acknowledgements and rendering 'confirmation and acknowledgements' page %O", err); - - return res.redirect(PROBLEM_WITH_SERVICE); - } + return res.render(TEMPLATE, { + ...insuranceCorePageVariables({ + PAGE_CONTENT_STRINGS: CONFIRMATION_AND_ACKNOWLEDGEMENTS, + BACK_LINK: req.headers.referer, + }), + ...pageVariables(referenceNumber), + userName: getUserNameFromSession(req.session.user), + CONTENT: CONFIRMATION_AND_ACKNOWLEDGEMENTS, + validationErrors, + }); } try { diff --git a/src/ui/server/helpers/keystone-document-renderer-config/index.test.ts b/src/ui/server/helpers/keystone-document-renderer-config/index.test.ts deleted file mode 100644 index a489d001e7..0000000000 --- a/src/ui/server/helpers/keystone-document-renderer-config/index.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -import keystoneDocumentRendererConfig from '.'; - -describe('server/helpers/keystone-document-renderer-config', () => { - const defaultConfig = { - listItemClass: 'counter-list-item', - secondLevelListClass: 'lower-alpha-counter-list', - thirdLevelListClass: 'lower-roman-counter-list', - }; - - it('should return an object with default config', () => { - const result = keystoneDocumentRendererConfig(); - - expect(result).toEqual(defaultConfig); - }); - - describe('when overrides are provided', () => { - it('should return default config with additional settings', () => { - const overrides = { - thirdLevelListClass: 'mock-class', - }; - - const result = keystoneDocumentRendererConfig(overrides); - - const expected = { - ...defaultConfig, - ...overrides, - }; - - expect(result).toEqual(expected); - }); - }); - - describe('when overrides is an empty object', () => { - it('should return default config', () => { - const overrides = {}; - - const result = keystoneDocumentRendererConfig(overrides); - - expect(result).toEqual(defaultConfig); - }); - }); -}); diff --git a/src/ui/server/helpers/keystone-document-renderer-config/index.ts b/src/ui/server/helpers/keystone-document-renderer-config/index.ts deleted file mode 100644 index 89c5c3190d..0000000000 --- a/src/ui/server/helpers/keystone-document-renderer-config/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { objectHasKeysAndValues } from '../object'; - -/** - * keystoneDocumentRendererConfig - * Generate config/settings for keystone document renderer component - * @param {Object} Custom settings - * @returns {Object} Keystone document renderer config - */ -const keystoneDocumentRendererConfig = (overrides?: object) => { - let config = { - listItemClass: 'counter-list-item', - secondLevelListClass: 'lower-alpha-counter-list', - thirdLevelListClass: 'lower-roman-counter-list', - }; - - if (overrides && objectHasKeysAndValues(overrides)) { - config = { - ...config, - ...overrides, - }; - } - - return config; -}; - -export default keystoneDocumentRendererConfig; diff --git a/src/ui/server/test-mocks/index.ts b/src/ui/server/test-mocks/index.ts index a58473c5f6..e3da77c79e 100644 --- a/src/ui/server/test-mocks/index.ts +++ b/src/ui/server/test-mocks/index.ts @@ -39,7 +39,6 @@ import mockBusinessNatureOfBusiness from './mock-business-nature-of-business'; import mockBusinessTurnover from './mock-business-turnover'; import mockBroker from './mock-broker'; import mockBuyer, { mockBuyerTradingHistory, mockBuyerRelationship, mockBuyerContact } from './mock-buyer'; -import mockDeclarations from './mock-declarations'; import { mockInsuranceFeedback } from './mock-feedback'; import mockJointlyInsuredParty from './mock-jointly-insured-party'; import mockLossPayeeDetails from './mock-loss-payee-details'; @@ -154,7 +153,6 @@ export { mockCurrencies, mockCurrenciesResponse, mockCurrenciesEmptyResponse, - mockDeclarations, mockCompanyDifferentTradingAddress, mockEligibility, mockErrorMessagesObject, diff --git a/src/ui/server/test-mocks/mock-declarations.ts b/src/ui/server/test-mocks/mock-declarations.ts deleted file mode 100644 index f22834f33c..0000000000 --- a/src/ui/server/test-mocks/mock-declarations.ts +++ /dev/null @@ -1,76 +0,0 @@ -const mockDeclarations = { - confidentiality: { - id: 'clf3te7vx1432cfoqp9rbop73', - version: '1.1', - content: { - document: [ - { - type: 'paragraph', - children: [ - { - text: 'By submitting this application you...', - }, - { - type: 'list-item-content', - children: [ - { - text: '(unless otherwise agreed) this...', - }, - ], - }, - ], - }, - ], - }, - }, - antiBribery: { - id: 'clf3te7vx1432cfoqp9rbop74', - version: '1.1', - content: { - document: [ - { - type: 'paragraph', - children: [ - { - text: 'By submitting this application you...', - }, - { - type: 'list-item-content', - children: [ - { - text: 'neither you nor any of your current...', - }, - ], - }, - ], - }, - ], - }, - }, - confirmationAndAcknowledgement: { - id: 'clfdt2h8k0087cdoq8mc361ug', - version: '1.2', - content: { - document: [ - { - type: 'paragraph', - children: [ - { - text: 'By submitting this application you...', - }, - { - type: 'list-item-content', - children: [ - { - text: 'you confirm that the information...', - }, - ], - }, - ], - }, - ], - }, - }, -}; - -export default mockDeclarations; diff --git a/src/ui/templates/components/declarations/declaration-list.njk b/src/ui/templates/components/declarations/declaration-list.njk new file mode 100644 index 0000000000..371a710ea6 --- /dev/null +++ b/src/ui/templates/components/declarations/declaration-list.njk @@ -0,0 +1,54 @@ +{% macro render(params) %} + + {% set CONTENT = params.CONTENT %} + {% set DATA_CY = params.DATA_CY %} + +

{{ CONTENT.INTRO }}

+ +
    + + {% for level1Item in CONTENT.LIST %} + +
  1. + {{ level1Item.text }} + + {% if level1Item.children %} + +
      + + {% for level2Item in level1Item.children %} + +
    1. + {{ level2Item.text }} + + {% if level2Item.children %} + +
        + + {% for level3Item in level2Item.children %} + +
      1. + {{ level3Item.text }} +
      2. + + {% endfor %} + +
      + + {% endif %} + +
    2. + + {% endfor %} + +
    + + {% endif %} + +
  2. + + {% endfor %} + +
+ +{% endmacro %} \ No newline at end of file diff --git a/src/ui/templates/components/keystone/document/README.md b/src/ui/templates/components/keystone/document/README.md deleted file mode 100644 index ca294f45c3..0000000000 --- a/src/ui/templates/components/keystone/document/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# Keystone Document Renderer :page_with_curl: - -This component consumes data generated by a Keystone rich text editor/[document field](https://keystonejs.com/docs/guides/document-fields) and renders GOV design components. :clipboard: - -## How to use :rocket: - -1. Setup an API call in your client to call the relevant Keystone endpoint. -2. Pass this data as a variable to a Nunjucks page. -3. In your Nunjucks template, import and call `keystoneDocument`. :computer: - -## Example :page_facing_up: - -Assuming you can fetch the data from the Keystone API, for example: :calling: - -```js -const getKeystonePage = async (pageId) => { - const config = { - method: 'GET', - url: `http://localhost:5001/api/graphql?query={page(where: { id: "${pageId}" }) {heading, content {document}}}`, - headers: { - 'Content-Type': 'application/json', - }, - }; - - const response = await axios(config); - - return response.data.data.page; -}; -``` - -You can then call this in a GET endpoint and pass the data to a nunjucks page: - -```js -const get = async (req, res) => { - const keystoneData = await getKeystonePage('PAGE_ID'); - - return res.render('about-page.njk', { - keystoneData, - }); -}; -``` - -Finally, import and call the `keystoneDocument` nunjucks component in that page: - -```html -{% import '../components/keystone/document/index.njk' as keystoneDocument %} - -
-
{{ keystoneDocument.render({ document: keystoneData.content.document }) }}
-
-``` - ---- diff --git a/src/ui/templates/components/keystone/document/blockquote.njk b/src/ui/templates/components/keystone/document/blockquote.njk deleted file mode 100644 index 193ae1bfd6..0000000000 --- a/src/ui/templates/components/keystone/document/blockquote.njk +++ /dev/null @@ -1,34 +0,0 @@ -{% from "govuk/components/inset-text/macro.njk" import govukInsetText %} - -{% macro render(params) %} - - {% set insetTextHtml %} - - {% endset %} - - {{ govukInsetText({ - html: insetTextHtml - }) }} - -{% endmacro %} diff --git a/src/ui/templates/components/keystone/document/index.njk b/src/ui/templates/components/keystone/document/index.njk deleted file mode 100644 index c8d17ad8d6..0000000000 --- a/src/ui/templates/components/keystone/document/index.njk +++ /dev/null @@ -1,54 +0,0 @@ -{% import './blockquote.njk' as blockquote %} -{% import './paragraph.njk' as paragraph %} -{% import './list.njk' as list %} - -{% macro render(params) %} - - {% for element in params.document %} - - {% if element.type === 'heading' %} - {{ element.children[0].text }} - {% endif %} - - {% if element.type === 'paragraph' %} - {{ paragraph.render({ - content: element.children, - index: loop.index - }) }} - {% endif %} - - {% if element.type === 'unordered-list' %} - {{ list.render({ - type: 'unordered', - content: element.children, - listItemClass: params.listItemClass, - firstLevelListClass: params.firstLevelListClass, - secondLevelListClass: params.secondLevelListClass, - thirdLevelListClass: params.thirdLevelListClass - }) }} - {% endif %} - - {% if element.type === 'ordered-list' %} - {{ list.render({ - type: 'ordered', - content: element.children, - listItemClass: params.listItemClass, - firstLevelListClass: params.firstLevelListClass, - secondLevelListClass: params.secondLevelListClass, - thirdLevelListClass: params.thirdLevelListClass - }) }} - {% endif %} - - {% if element.type === 'blockquote' %} - {{ blockquote.render({ - content: element.children - }) }} - {% endif %} - - {% if element.type === 'divider' %} -
- {% endif %} - - {% endfor %} - -{% endmacro %} diff --git a/src/ui/templates/components/keystone/document/list-item/child.njk b/src/ui/templates/components/keystone/document/list-item/child.njk deleted file mode 100644 index f7b61aafe9..0000000000 --- a/src/ui/templates/components/keystone/document/list-item/child.njk +++ /dev/null @@ -1,50 +0,0 @@ -{% import './grand-child.njk' as grandChildListItem %} - -{% macro render(params) %} - - {% set child = params.child %} - {% set class = params.class %} - {% set loopIndex = params.loopIndex %} - {% set secondLevelListClass = params.secondLevelListClass %} - {% set thirdLevelListClass = params.thirdLevelListClass %} - - {% if child.type === 'ordered-list' %} - -
    - - {% for grandChild in child.children %} - - {{ grandChildListItem.render({ - child: grandChild, - class: class, - loopIndex: loop.index, - thirdLevelListClass: thirdLevelListClass - }) }} - - {% endfor %} - -
- - {% endif %} - - {% for grandChild in child.children %} - - {% if grandChild.type === 'link' %} - - - {% for child in grandChild.children %} - {{ child.text }} - {% endfor %} - - - {% elif grandChild.text %} - -
  • - {{ grandChild.text }} -
  • - - {% endif %} - - {% endfor %} - -{% endmacro %} diff --git a/src/ui/templates/components/keystone/document/list-item/grand-child.njk b/src/ui/templates/components/keystone/document/list-item/grand-child.njk deleted file mode 100644 index 42759f60e6..0000000000 --- a/src/ui/templates/components/keystone/document/list-item/grand-child.njk +++ /dev/null @@ -1,23 +0,0 @@ -{% import './great-grand-child.njk' as greatGrandChildListItem %} - -{% macro render(params) %} - - {% set child = params.child %} - {% set class = params.class %} - {% set loopIndex = params.loopIndex %} - {% set thirdLevelListClass = params.thirdLevelListClass %} - - {% if child.type === 'list-item' %} - - {% for greatGrandChild in child.children %} - - {{ greatGrandChildListItem.render({ - child: greatGrandChild, - class: class, - loopIndex: loopIndex, - thirdLevelListClass: thirdLevelListClass - }) }} - - {% endfor %} - {% endif %} -{% endmacro %} diff --git a/src/ui/templates/components/keystone/document/list-item/great-grand-child.njk b/src/ui/templates/components/keystone/document/list-item/great-grand-child.njk deleted file mode 100644 index 47731769e4..0000000000 --- a/src/ui/templates/components/keystone/document/list-item/great-grand-child.njk +++ /dev/null @@ -1,46 +0,0 @@ -{% import './great-great-grand-child.njk' as greatGreatGrandChildListItem %} - -{% macro render(params) %} - - {% set child = params.child %} - {% set class = params.class %} - {% set loopIndex = params.loopIndex %} - {% set thirdLevelListClass = params.thirdLevelListClass %} - - {% if child.type === 'ordered-list' %} - -
      - - {% for greatGreatGrandChild in child.children %} - - {{ greatGreatGrandChildListItem.render({ - child: greatGreatGrandChild, - class: class, - loopIndex: loop.index - }) }} - - {% endfor %} - -
    - - {% elif child.text %} - -
  • - {{ child.text }} -
  • - - {% endif %} - - {% if child.type === 'list-item-content' %} - - {% for greatGreatGrandChild in child.children %} - -
  • - {{ greatGreatGrandChild.text }} -
  • - - {% endfor %} - - {% endif %} - -{% endmacro %} diff --git a/src/ui/templates/components/keystone/document/list-item/great-great-grand-child.njk b/src/ui/templates/components/keystone/document/list-item/great-great-grand-child.njk deleted file mode 100644 index 7e8331b254..0000000000 --- a/src/ui/templates/components/keystone/document/list-item/great-great-grand-child.njk +++ /dev/null @@ -1,29 +0,0 @@ -{% import './great-great-great-grand-child.njk' as greatGreatGreatGrandChildListItem %} - -{% macro render(params) %} - - {% set child = params.child %} - {% set class = params.class %} - {% set loopIndex = params.loopIndex %} - - {% if child.children %} - - {% for greatGreatGreatGrandChild in child.children %} - - {{ greatGreatGreatGrandChildListItem.render({ - child: greatGreatGreatGrandChild, - class: class, - loopIndex: loopIndex - }) }} - - {% endfor %} - - {% else %} - -
  • - {{ child.text }} -
  • - - {% endif %} - -{% endmacro %} diff --git a/src/ui/templates/components/keystone/document/list-item/great-great-great-grand-child.njk b/src/ui/templates/components/keystone/document/list-item/great-great-great-grand-child.njk deleted file mode 100644 index 5666c75700..0000000000 --- a/src/ui/templates/components/keystone/document/list-item/great-great-great-grand-child.njk +++ /dev/null @@ -1,25 +0,0 @@ -{% macro render(params) %} - - {% set child = params.child %} - {% set class = params.class %} - {% set loopIndex = params.loopIndex %} - - {% if child.children %} - - {% for child in child.children %} - -
  • - {{ child.text }} -
  • - - {% endfor %} - - {% else %} - -
  • - {{ child.text }} -
  • - - {% endif %} - -{% endmacro %} diff --git a/src/ui/templates/components/keystone/document/list-item/index.njk b/src/ui/templates/components/keystone/document/list-item/index.njk deleted file mode 100644 index 144bec9f57..0000000000 --- a/src/ui/templates/components/keystone/document/list-item/index.njk +++ /dev/null @@ -1,17 +0,0 @@ -{% import './child.njk' as childListItem %} - -{% macro render(params) %} - - {% for child in params.content.children %} - - {{ childListItem.render({ - child: child, - class: params.class, - loopIndex: params.loopIndex, - secondLevelListClass: params.secondLevelListClass, - thirdLevelListClass: params.thirdLevelListClass - }) }} - - {% endfor %} - -{% endmacro %} diff --git a/src/ui/templates/components/keystone/document/list.njk b/src/ui/templates/components/keystone/document/list.njk deleted file mode 100644 index 04232d2d69..0000000000 --- a/src/ui/templates/components/keystone/document/list.njk +++ /dev/null @@ -1,41 +0,0 @@ -{% import './list-item/index.njk' as listItem %} - -{% macro render(params) %} - - {% if params.type === 'ordered' %} -
      - - {% for child in params.content %} - - {{ listItem.render({ - content: child, - loopIndex: loop.index, - class: params.listItemClass, - secondLevelListClass: params.secondLevelListClass, - thirdLevelListClass: params.thirdLevelListClass - }) }} - - {% endfor %} - -
    - {% endif %} - - {% if params.type === 'unordered' %} - - {% endif %} - -{% endmacro %} diff --git a/src/ui/templates/components/keystone/document/paragraph.njk b/src/ui/templates/components/keystone/document/paragraph.njk deleted file mode 100644 index a4ebd96fd3..0000000000 --- a/src/ui/templates/components/keystone/document/paragraph.njk +++ /dev/null @@ -1,20 +0,0 @@ -{% macro render(params) %} - - {% set content = params.content %} - {% set index = params.index %} - -

    - {% for child in params.content %} - - {% if child.type and child.type === 'link' %} - {{ child.children[0].text}} - {% endif %} - - {% if child.text %} - {{ child.text }} - {% endif %} - - {% endfor %} -

    - -{% endmacro %} diff --git a/src/ui/templates/insurance/declarations/anti-bribery.njk b/src/ui/templates/insurance/declarations/anti-bribery.njk index 2d904082f2..8bac479594 100644 --- a/src/ui/templates/insurance/declarations/anti-bribery.njk +++ b/src/ui/templates/insurance/declarations/anti-bribery.njk @@ -4,6 +4,7 @@ {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} {% import '../../components/keystone/document/index.njk' as keystoneDocument %} {% import '../../components/declarations/anti-bribery/expandable-content.njk' as expandableContent %} +{% import '../../components/declarations/declaration-list.njk' as declarationList %} {% import '../../components/form-buttons.njk' as formButtons %} {% block pageTitle %} @@ -33,12 +34,9 @@
    - {{ keystoneDocument.render({ - document: documentContent, - listItemClass: documentConfig.listItemClass, - firstLevelListClass: documentConfig.firstLevelListClass, - secondLevelListClass: documentConfig.secondLevelListClass, - thirdLevelListClass: documentConfig.thirdLevelListClass + {{ declarationList.render({ + CONTENT: CONTENT, + DATA_CY: DATA_CY }) }}
    diff --git a/src/ui/templates/insurance/declarations/confidentiality.njk b/src/ui/templates/insurance/declarations/confidentiality.njk index 6108fa5092..f37c94adbd 100644 --- a/src/ui/templates/insurance/declarations/confidentiality.njk +++ b/src/ui/templates/insurance/declarations/confidentiality.njk @@ -3,6 +3,7 @@ {% from 'govuk/components/error-summary/macro.njk' import govukErrorSummary %} {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} {% from 'govuk/components/button/macro.njk' import govukButton %} +{% import '../../components/declarations/declaration-list.njk' as declarationList %} {% import '../../components/form-buttons.njk' as formButtons %} {% block pageTitle %} @@ -32,53 +33,10 @@
    -

    {{ CONFIDENTIALITY_CONTENT.INTRO }}

    - -
      - - {% for level1Item in CONFIDENTIALITY_CONTENT.LIST %} - -
    1. - {{ level1Item.text }} - - {% if level1Item.children %} - -
        - - {% for level2Item in level1Item.children %} - -
      1. - {{ level2Item.text }} - - {% if level2Item.children %} - -
          - - {% for level3Item in level2Item.children %} - -
        1. - {{ level3Item.text }} -
        2. - - {% endfor %} - -
        - - {% endif %} - -
      2. - - {% endfor %} - -
      - - {% endif %} - -
    2. - - {% endfor %} - -
    + {{ declarationList.render({ + CONTENT: CONTENT, + DATA_CY: DATA_CY + }) }}
    diff --git a/src/ui/templates/shared-pages/declaration.njk b/src/ui/templates/shared-pages/declaration.njk index 57d41e86ce..d34b326368 100644 --- a/src/ui/templates/shared-pages/declaration.njk +++ b/src/ui/templates/shared-pages/declaration.njk @@ -2,8 +2,8 @@ {% from "govuk/components/back-link/macro.njk" import govukBackLink %} {% from 'govuk/components/error-summary/macro.njk' import govukErrorSummary %} {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} -{% import '../components/keystone/document/index.njk' as keystoneDocument %} {% import '../components/form-buttons.njk' as formButtons %} +{% import '../components/declarations/declaration-list.njk' as declarationList %} {% block pageTitle %} {{ CONTENT_STRINGS.PAGE_TITLE }} @@ -32,12 +32,9 @@
    - {{ keystoneDocument.render({ - document: documentContent, - listItemClass: documentConfig.listItemClass, - firstLevelListClass: documentConfig.firstLevelListClass, - secondLevelListClass: documentConfig.secondLevelListClass, - thirdLevelListClass: documentConfig.thirdLevelListClass + {{ declarationList.render({ + CONTENT: CONTENT, + DATA_CY: DATA_CY }) }}
    From 45d76c94113d72c315871a265a3b654dde5b4bc2 Mon Sep 17 00:00:00 2001 From: Zain Kassam Date: Thu, 25 Jul 2024 11:59:26 +0100 Subject: [PATCH 2/4] feat(EMS-3631): remove e2e api calls for declarations --- e2e-tests/commands/api/index.js | 134 ------------------ .../commands/flatten-keystone-document.js | 25 ---- 2 files changed, 159 deletions(-) delete mode 100644 e2e-tests/commands/flatten-keystone-document.js diff --git a/e2e-tests/commands/api/index.js b/e2e-tests/commands/api/index.js index 2f2342e6ee..aaecbb7d9a 100644 --- a/e2e-tests/commands/api/index.js +++ b/e2e-tests/commands/api/index.js @@ -154,52 +154,6 @@ const queryStrings = { } } `, - declarations: { - getLatestConfidentiality: () => gql` - query declarationConfidentialities { - declarationConfidentialities(orderBy: { version: desc }, take: 1) { - id - version - content { - document - } - } - } - `, - getLatestAntiBribery: () => gql` - query declarationAntiBriberies { - declarationAntiBriberies(orderBy: { version: desc }, take: 1) { - id - version - content { - document - } - } - } - `, - getLatestConfirmationAndAcknowledgements: () => gql` - query declarationConfirmationAndAcknowledgements { - declarationConfirmationAndAcknowledgements(orderBy: { version: desc }, take: 1) { - id - version - content { - document - } - } - } - `, - getLatestHowDataWillBeUsed: () => gql` - query declarationHowDataWillBeUseds { - declarationHowDataWillBeUseds(orderBy: { version: desc }, take: 1) { - id - version - content { - document - } - } - } - `, - }, }; /** @@ -582,93 +536,6 @@ const getACountry = async () => { } }; -const declarations = { - /** - * getLatestConfidentiality - * Get the latest Confidentiality declaration content - * @returns {Object} Confidentiality declaration - */ - getLatestConfidentiality: async () => { - try { - const responseBody = await apollo - .query({ - query: queryStrings.declarations.getLatestConfidentiality(), - context: APOLLO_CONTEXT, - }) - .then((response) => response.data.declarationConfidentialities[0]); - - return responseBody; - } catch (err) { - console.error(err); - - throw new Error('Getting latest declaration - confidentiality ', { err }); - } - }, - /** - * getLatestAntiBribery - * Get the latest Anti-bribery declaration content - * @returns {Object} Anti-bribery declaration - */ - getLatestAntiBribery: async () => { - try { - const responseBody = await apollo - .query({ - query: queryStrings.declarations.getLatestAntiBribery(), - context: APOLLO_CONTEXT, - }) - .then((response) => response.data.declarationAntiBriberies[0]); - - return responseBody; - } catch (err) { - console.error(err); - - throw new Error('Getting latest declaration - anti-bribery ', { err }); - } - }, - /** - * getLatestConfirmationAndAcknowledgements - * Get the latest Confirmation and acknowledgements declaration content - * @returns {Object} Confirmation and acknowledgements declaration - */ - getLatestConfirmationAndAcknowledgements: async () => { - try { - const responseBody = await apollo - .query({ - query: queryStrings.declarations.getLatestConfirmationAndAcknowledgements(), - context: APOLLO_CONTEXT, - }) - .then((response) => response.data.declarationConfirmationAndAcknowledgements[0]); - - return responseBody; - } catch (err) { - console.error(err); - - throw new Error('Getting latest declaration - confirmation and acknowledgements ', { err }); - } - }, - /** - * getLatestHowDataWillBeUsed - * Get the latest How data will be used declaration content - * @returns {Object} Confirmation and acknowledgements declaration - */ - getLatestHowDataWillBeUsed: async () => { - try { - const responseBody = await apollo - .query({ - query: queryStrings.declarations.getLatestHowDataWillBeUsed(), - context: APOLLO_CONTEXT, - }) - .then((response) => response.data.declarationHowDataWillBeUseds[0]); - - return responseBody; - } catch (err) { - console.error(err); - - throw new Error('Getting latest declaration - how data will be used ', { err }); - } - }, -}; - const api = { createAnAccount, createBuyer, @@ -685,7 +552,6 @@ const api = { deleteApplicationByReferenceNumber, deleteApplications, getACountry, - declarations, }; export default api; diff --git a/e2e-tests/commands/flatten-keystone-document.js b/e2e-tests/commands/flatten-keystone-document.js deleted file mode 100644 index e0f123036c..0000000000 --- a/e2e-tests/commands/flatten-keystone-document.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * mapChild - * Map a child keystone document object - * Calls itself if the child has children - * @param {Object} Keystone RTE document data - * @returns {Array | Object} Flattened child array or child object - */ -const mapChild = (child) => { - if (child.children) { - return child.children.map((c) => mapChild(c)).flat(); - } - - return child; -}; - -/** - * flattenKeystoneDocument - * Map keystone document data into a flattened array - * This is dynamic and can handle unlimited nested data - * @param {Array} Keystone RTE document data - * @returns {Array} Flattened array - */ -const flattenKeystoneDocument = (content) => content.map((child) => mapChild(child)).flat(); - -export default flattenKeystoneDocument; From 655114afcef8056ba1c565e670fac103fd8c620c Mon Sep 17 00:00:00 2001 From: Zain Kassam Date: Thu, 25 Jul 2024 12:12:47 +0100 Subject: [PATCH 3/4] feat(EMS-3631): fixed failing tests and removed all declaration api query calls --- .../declarations/get-latest-anti-bribery.ts | 37 ------------------- ...latest-confirmation-and-acknowledgement.ts | 37 ------------------- .../get-latest-how-data-will-be-used.ts | 37 ------------------- .../application/declarations/index.ts | 6 --- .../queries/declarations/anti-bribery.ts | 15 -------- .../confirmation-and-acknowledgement.ts | 15 -------- .../declarations/how-data-will-be-used.ts | 15 -------- .../insurance/declarations/anti-bribery.njk | 1 - 8 files changed, 163 deletions(-) delete mode 100644 src/ui/server/api/keystone/application/declarations/get-latest-anti-bribery.ts delete mode 100644 src/ui/server/api/keystone/application/declarations/get-latest-confirmation-and-acknowledgement.ts delete mode 100644 src/ui/server/api/keystone/application/declarations/get-latest-how-data-will-be-used.ts delete mode 100644 src/ui/server/graphql/queries/declarations/anti-bribery.ts delete mode 100644 src/ui/server/graphql/queries/declarations/confirmation-and-acknowledgement.ts delete mode 100644 src/ui/server/graphql/queries/declarations/how-data-will-be-used.ts diff --git a/src/ui/server/api/keystone/application/declarations/get-latest-anti-bribery.ts b/src/ui/server/api/keystone/application/declarations/get-latest-anti-bribery.ts deleted file mode 100644 index b6754d7aca..0000000000 --- a/src/ui/server/api/keystone/application/declarations/get-latest-anti-bribery.ts +++ /dev/null @@ -1,37 +0,0 @@ -import apollo from '../../../../graphql/apollo'; -import getDeclarationAntiBriberyQuery from '../../../../graphql/queries/declarations/anti-bribery'; -import { isPopulatedArray } from '../../../../helpers/array'; -import { ApolloResponse } from '../../../../../types'; - -/** - * getLatestAntiBribery - * Get the latest "anti bribery" declaration content - * @returns {Object} Latest "anti bribery" declaration content - */ -const getLatestAntiBribery = async () => { - try { - console.info('Getting latest declaration - anti-bribery'); - - const response = (await apollo('POST', getDeclarationAntiBriberyQuery, {})) as ApolloResponse; - - if (response.errors) { - console.error('GraphQL error getting latest declaration - anti-bribery %O', response.errors); - } - - if (response?.networkError?.result?.errors) { - console.error('GraphQL network error getting latest declaration - anti-bribery %O', response.networkError.result.errors); - } - - if (response?.data?.declarationAntiBriberies && isPopulatedArray(response.data.declarationAntiBriberies)) { - return response.data.declarationAntiBriberies[0]; - } - - console.error('Error with GraphQL getDeclarationAntiBriberyQuery %O', response); - throw new Error('Getting latest declaration - anti-bribery'); - } catch (err) { - console.error('Error getting latest declaration - anti bribery %O', err); - throw new Error('Getting latest declaration - anti-bribery'); - } -}; - -export default getLatestAntiBribery; diff --git a/src/ui/server/api/keystone/application/declarations/get-latest-confirmation-and-acknowledgement.ts b/src/ui/server/api/keystone/application/declarations/get-latest-confirmation-and-acknowledgement.ts deleted file mode 100644 index e77eca0e78..0000000000 --- a/src/ui/server/api/keystone/application/declarations/get-latest-confirmation-and-acknowledgement.ts +++ /dev/null @@ -1,37 +0,0 @@ -import apollo from '../../../../graphql/apollo'; -import getDeclarationConfirmationAndAcknowledgementQuery from '../../../../graphql/queries/declarations/confirmation-and-acknowledgement'; -import { isPopulatedArray } from '../../../../helpers/array'; -import { ApolloResponse } from '../../../../../types'; - -/** - * getLatestConfirmationAndAcknowledgement - * Get the latest "confirmation and acknowledgement" declaration content - * @returns {Object} Latest "confirmation and acknowledgement" declaration content - */ -const getLatestConfirmationAndAcknowledgement = async () => { - try { - console.info('Getting latest declaration - confirmation and acknowledgement'); - - const response = (await apollo('POST', getDeclarationConfirmationAndAcknowledgementQuery, {})) as ApolloResponse; - - if (response.errors) { - console.error('GraphQL error getting latest declaration - confirmation and acknowledgement %O', response.errors); - } - - if (response?.networkError?.result?.errors) { - console.error('GraphQL network error getting latest declaration - confirmation and acknowledgement %O', response.networkError.result.errors); - } - - if (response?.data?.declarationConfirmationAndAcknowledgements && isPopulatedArray(response.data.declarationConfirmationAndAcknowledgements)) { - return response.data.declarationConfirmationAndAcknowledgements[0]; - } - - console.error('Error with GraphQL getDeclarationConfirmationAndAcknowledgementQuery %O', response); - throw new Error('Getting latest declaration - confirmation and acknowledgement'); - } catch (err) { - console.error('Error getting latest declaration - confirmation and acknowledgement %O', err); - throw new Error('Getting latest declaration - confirmation and acknowledgement'); - } -}; - -export default getLatestConfirmationAndAcknowledgement; diff --git a/src/ui/server/api/keystone/application/declarations/get-latest-how-data-will-be-used.ts b/src/ui/server/api/keystone/application/declarations/get-latest-how-data-will-be-used.ts deleted file mode 100644 index 926be26578..0000000000 --- a/src/ui/server/api/keystone/application/declarations/get-latest-how-data-will-be-used.ts +++ /dev/null @@ -1,37 +0,0 @@ -import apollo from '../../../../graphql/apollo'; -import getDeclarationHowDataWillBeUsedQuery from '../../../../graphql/queries/declarations/how-data-will-be-used'; -import { isPopulatedArray } from '../../../../helpers/array'; -import { ApolloResponse } from '../../../../../types'; - -/** - * getLatestHowDataWillBeUsed - * Get the latest "how data will be used" declaration content - * @returns {Object} Latest "how data will be used" declaration content - */ -const getLatestHowDataWillBeUsed = async () => { - try { - console.info('Getting latest declaration - how data will be used'); - - const response = (await apollo('POST', getDeclarationHowDataWillBeUsedQuery, {})) as ApolloResponse; - - if (response.errors) { - console.error('GraphQL error getting latest declaration - how data will be used %O', response.errors); - } - - if (response?.networkError?.result?.errors) { - console.error('GraphQL network error getting latest declaration - how data will be used %O', response.networkError.result.errors); - } - - if (response?.data?.declarationHowDataWillBeUseds && isPopulatedArray(response.data.declarationHowDataWillBeUseds)) { - return response.data.declarationHowDataWillBeUseds[0]; - } - - console.error('Error with GraphQL getDeclarationHowDataWillBeUsedQuery %O', response); - throw new Error('Getting latest declaration - how data will be used'); - } catch (err) { - console.error('Error getting latest declaration - how data will be used %O', err); - throw new Error('Getting latest declaration - how data will be used'); - } -}; - -export default getLatestHowDataWillBeUsed; diff --git a/src/ui/server/api/keystone/application/declarations/index.ts b/src/ui/server/api/keystone/application/declarations/index.ts index d60939f0f3..910285a4ad 100644 --- a/src/ui/server/api/keystone/application/declarations/index.ts +++ b/src/ui/server/api/keystone/application/declarations/index.ts @@ -1,6 +1,3 @@ -import getLatestAntiBribery from './get-latest-anti-bribery'; -import getLatestConfirmationAndAcknowledgement from './get-latest-confirmation-and-acknowledgement'; -import getLatestHowDataWillBeUsed from './get-latest-how-data-will-be-used'; import update from './update'; /** @@ -9,9 +6,6 @@ import update from './update'; * @returns {Object} API calls */ const declarations = { - getLatestAntiBribery, - getLatestConfirmationAndAcknowledgement, - getLatestHowDataWillBeUsed, update, }; diff --git a/src/ui/server/graphql/queries/declarations/anti-bribery.ts b/src/ui/server/graphql/queries/declarations/anti-bribery.ts deleted file mode 100644 index 59268f2fdd..0000000000 --- a/src/ui/server/graphql/queries/declarations/anti-bribery.ts +++ /dev/null @@ -1,15 +0,0 @@ -import gql from 'graphql-tag'; - -const getDeclarationAntiBriberyQuery = gql` - query declarationAntiBriberies { - declarationAntiBriberies(orderBy: { version: desc }, take: 1) { - id - version - content { - document - } - } - } -`; - -export default getDeclarationAntiBriberyQuery; diff --git a/src/ui/server/graphql/queries/declarations/confirmation-and-acknowledgement.ts b/src/ui/server/graphql/queries/declarations/confirmation-and-acknowledgement.ts deleted file mode 100644 index e3cc82c0fb..0000000000 --- a/src/ui/server/graphql/queries/declarations/confirmation-and-acknowledgement.ts +++ /dev/null @@ -1,15 +0,0 @@ -import gql from 'graphql-tag'; - -const getDeclarationConfirmationAndAcknowledgementQuery = gql` - query declarationConfirmationAndAcknowledgements { - declarationConfirmationAndAcknowledgements(orderBy: { version: desc }, take: 1) { - id - version - content { - document - } - } - } -`; - -export default getDeclarationConfirmationAndAcknowledgementQuery; diff --git a/src/ui/server/graphql/queries/declarations/how-data-will-be-used.ts b/src/ui/server/graphql/queries/declarations/how-data-will-be-used.ts deleted file mode 100644 index 5c18bf1c6c..0000000000 --- a/src/ui/server/graphql/queries/declarations/how-data-will-be-used.ts +++ /dev/null @@ -1,15 +0,0 @@ -import gql from 'graphql-tag'; - -const getDeclarationHowDataWillBeUsedQuery = gql` - query declarationHowDataWillBeUseds { - declarationHowDataWillBeUseds(orderBy: { version: desc }, take: 1) { - id - version - content { - document - } - } - } -`; - -export default getDeclarationHowDataWillBeUsedQuery; diff --git a/src/ui/templates/insurance/declarations/anti-bribery.njk b/src/ui/templates/insurance/declarations/anti-bribery.njk index 8bac479594..a33b0b85ff 100644 --- a/src/ui/templates/insurance/declarations/anti-bribery.njk +++ b/src/ui/templates/insurance/declarations/anti-bribery.njk @@ -2,7 +2,6 @@ {% from "govuk/components/back-link/macro.njk" import govukBackLink %} {% from 'govuk/components/error-summary/macro.njk' import govukErrorSummary %} {% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %} -{% import '../../components/keystone/document/index.njk' as keystoneDocument %} {% import '../../components/declarations/anti-bribery/expandable-content.njk' as expandableContent %} {% import '../../components/declarations/declaration-list.njk' as declarationList %} {% import '../../components/form-buttons.njk' as formButtons %} From 6d78e0c90dc26b624dbb71f078c4b6a958dc7352 Mon Sep 17 00:00:00 2001 From: Zain Kassam Date: Thu, 25 Jul 2024 12:24:40 +0100 Subject: [PATCH 4/4] feat(EMS-3631): code improvements --- .../journeys/declarations/anti-bribery/anti-bribery.spec.js | 4 ++-- .../declarations/confidentiality/confidentiality.spec.js | 4 ++-- .../confirmation-and-acknowledgements.spec.js | 4 ++-- e2e-tests/pages/shared/{listPage.js => declarationPage.js} | 4 ++-- e2e-tests/pages/shared/index.js | 4 ++-- .../insurance/declarations/anti-bribery/index.test.ts | 2 -- .../insurance/declarations/anti-bribery/index.ts | 2 -- .../insurance/declarations/confidentiality/index.test.ts | 2 -- .../insurance/declarations/confidentiality/index.ts | 2 -- .../confirmation-and-acknowledgements/index.test.ts | 2 -- .../declarations/confirmation-and-acknowledgements/index.ts | 2 -- .../templates/components/declarations/declaration-list.njk | 6 +++--- src/ui/templates/insurance/declarations/anti-bribery.njk | 2 +- src/ui/templates/insurance/declarations/confidentiality.njk | 2 +- src/ui/templates/shared-pages/declaration.njk | 2 +- 15 files changed, 16 insertions(+), 28 deletions(-) rename e2e-tests/pages/shared/{listPage.js => declarationPage.js} (89%) diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery.spec.js index b5527739df..2b23bb4c47 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/anti-bribery/anti-bribery.spec.js @@ -1,4 +1,4 @@ -import { headingCaption, singleInputField, listPage } from '../../../../../../pages/shared'; +import { headingCaption, singleInputField, declarationPage } from '../../../../../../pages/shared'; import { antiBriberyPage } from '../../../../../../pages/insurance/declarations'; import partials from '../../../../../../partials'; import { PAGES, ERROR_MESSAGES } from '../../../../../../content-strings'; @@ -76,7 +76,7 @@ context( describe('latest anti-bribery content', () => { const listContent = CONTENT_STRINGS.LIST; - const { intro, level1, level2 } = listPage.listItems; + const { intro, level1, level2 } = declarationPage.listItems; it('renders an intro paragraph', () => { cy.checkText(intro(), CONTENT_STRINGS.INTRO); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confidentiality/confidentiality.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confidentiality/confidentiality.spec.js index 55ef09ab8a..10f42903e1 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confidentiality/confidentiality.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confidentiality/confidentiality.spec.js @@ -1,4 +1,4 @@ -import { headingCaption, singleInputField, listPage } from '../../../../../../pages/shared'; +import { headingCaption, singleInputField, declarationPage } from '../../../../../../pages/shared'; import partials from '../../../../../../partials'; import { PAGES, ERROR_MESSAGES } from '../../../../../../content-strings'; import { FIELD_IDS } from '../../../../../../constants'; @@ -75,7 +75,7 @@ context( describe('latest confidentiality content', () => { const listContent = CONTENT_STRINGS.LIST; - const { intro, level1, level2, level3 } = listPage.listItems; + const { intro, level1, level2, level3 } = declarationPage.listItems; it('renders an intro paragraph', () => { cy.checkText(intro(), CONTENT_STRINGS.INTRO); diff --git a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/confirmation-and-acknowledgements.spec.js b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/confirmation-and-acknowledgements.spec.js index 0cfa2c86a1..34e5ccf606 100644 --- a/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/confirmation-and-acknowledgements.spec.js +++ b/e2e-tests/insurance/cypress/e2e/journeys/declarations/confirmation-and-acknowledgements/confirmation-and-acknowledgements.spec.js @@ -1,4 +1,4 @@ -import { headingCaption, singleInputField, listPage } from '../../../../../../pages/shared'; +import { headingCaption, singleInputField, declarationPage } from '../../../../../../pages/shared'; import partials from '../../../../../../partials'; import { PAGES, ERROR_MESSAGES } from '../../../../../../content-strings'; import { FIELD_IDS } from '../../../../../../constants'; @@ -80,7 +80,7 @@ context( describe('latest confirmation-and-acknowledgements content', () => { const listContent = CONTENT_STRINGS.LIST; - const { intro, level1, level2 } = listPage.listItems; + const { intro, level1, level2 } = declarationPage.listItems; it('renders an intro paragraph', () => { cy.checkText(intro(), CONTENT_STRINGS.INTRO); diff --git a/e2e-tests/pages/shared/listPage.js b/e2e-tests/pages/shared/declarationPage.js similarity index 89% rename from e2e-tests/pages/shared/listPage.js rename to e2e-tests/pages/shared/declarationPage.js index 5920232550..d66d46398c 100644 --- a/e2e-tests/pages/shared/listPage.js +++ b/e2e-tests/pages/shared/declarationPage.js @@ -1,4 +1,4 @@ -const listPage = { +const declarationPage = { listItems: { intro: () => cy.get("[data-cy='intro']"), level1: { @@ -14,4 +14,4 @@ const listPage = { }, }; -export default listPage; +export default declarationPage; diff --git a/e2e-tests/pages/shared/index.js b/e2e-tests/pages/shared/index.js index 0ff218099f..4f3df1fc92 100644 --- a/e2e-tests/pages/shared/index.js +++ b/e2e-tests/pages/shared/index.js @@ -7,7 +7,7 @@ import needToStartAgainPage from './needToStartAgain'; import summaryList from './summaryList'; import ukGoodsOrServicesPage from './ukGoodsOrServices'; import field from './field'; -import listPage from './listPage'; +import declarationPage from './declarationPage'; const allSectionsLink = () => cy.get('[data-cy="all-sections-link"]'); const backLink = () => cy.get('[data-cy="back-link"]'); @@ -71,7 +71,7 @@ export { listIntro, listItem, listOutro, - listPage, + declarationPage, yesNoRadioHint, yesRadio, yesRadioInput, diff --git a/src/ui/server/controllers/insurance/declarations/anti-bribery/index.test.ts b/src/ui/server/controllers/insurance/declarations/anti-bribery/index.test.ts index 7cc03235aa..4dece8998f 100644 --- a/src/ui/server/controllers/insurance/declarations/anti-bribery/index.test.ts +++ b/src/ui/server/controllers/insurance/declarations/anti-bribery/index.test.ts @@ -77,7 +77,6 @@ describe('controllers/insurance/declarations/anti-bribery', () => { ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), application: mapApplicationToFormFields(res.locals.application), - CONTENT: ANTI_BRIBERY, }; expect(res.render).toHaveBeenCalledWith(TEMPLATE, expectedVariables); @@ -138,7 +137,6 @@ describe('controllers/insurance/declarations/anti-bribery', () => { ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), validationErrors: generateValidationErrors(payload, FIELD_ID, ERROR_MESSAGES.INSURANCE.DECLARATIONS[FIELD_ID].IS_EMPTY), - CONTENT: ANTI_BRIBERY, }; expect(res.render).toHaveBeenCalledWith(TEMPLATE, expectedVariables); diff --git a/src/ui/server/controllers/insurance/declarations/anti-bribery/index.ts b/src/ui/server/controllers/insurance/declarations/anti-bribery/index.ts index dd12c60fca..e69fa9ee8c 100644 --- a/src/ui/server/controllers/insurance/declarations/anti-bribery/index.ts +++ b/src/ui/server/controllers/insurance/declarations/anti-bribery/index.ts @@ -57,7 +57,6 @@ export const get = async (req: Request, res: Response) => { ...pageVariables(application.referenceNumber), userName: getUserNameFromSession(req.session.user), application: mapApplicationToFormFields(res.locals.application), - CONTENT: ANTI_BRIBERY, }); }; @@ -89,7 +88,6 @@ export const post = async (req: Request, res: Response) => { }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - CONTENT: ANTI_BRIBERY, validationErrors, }); } diff --git a/src/ui/server/controllers/insurance/declarations/confidentiality/index.test.ts b/src/ui/server/controllers/insurance/declarations/confidentiality/index.test.ts index a69839b5f5..7e32437936 100644 --- a/src/ui/server/controllers/insurance/declarations/confidentiality/index.test.ts +++ b/src/ui/server/controllers/insurance/declarations/confidentiality/index.test.ts @@ -77,7 +77,6 @@ describe('controllers/insurance/declarations/confidentiality', () => { }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - CONTENT: CONFIDENTIALITY, application: mapApplicationToFormFields(res.locals.application), }; @@ -138,7 +137,6 @@ describe('controllers/insurance/declarations/confidentiality', () => { }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - CONTENT: CONFIDENTIALITY, validationErrors: generateValidationErrors(payload, FIELD_ID, ERROR_MESSAGES.INSURANCE.DECLARATIONS[FIELD_ID].IS_EMPTY), }; diff --git a/src/ui/server/controllers/insurance/declarations/confidentiality/index.ts b/src/ui/server/controllers/insurance/declarations/confidentiality/index.ts index 4ded339e37..213e8b9397 100644 --- a/src/ui/server/controllers/insurance/declarations/confidentiality/index.ts +++ b/src/ui/server/controllers/insurance/declarations/confidentiality/index.ts @@ -58,7 +58,6 @@ export const get = async (req: Request, res: Response) => { }), ...pageVariables(application.referenceNumber), userName: getUserNameFromSession(req.session.user), - CONTENT: CONFIDENTIALITY, application: mapApplicationToFormFields(res.locals.application), }); }; @@ -91,7 +90,6 @@ export const post = async (req: Request, res: Response) => { }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - CONTENT: CONFIDENTIALITY, validationErrors, }); } diff --git a/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.test.ts b/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.test.ts index 0423107e53..95c57a42f1 100644 --- a/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.test.ts +++ b/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.test.ts @@ -78,7 +78,6 @@ describe('controllers/insurance/declarations/confirmation-and-acknowledgements', }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - CONTENT: CONFIRMATION_AND_ACKNOWLEDGEMENTS, application: mapApplicationToFormFields(res.locals.application), }; @@ -163,7 +162,6 @@ describe('controllers/insurance/declarations/confirmation-and-acknowledgements', }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - CONTENT: CONFIRMATION_AND_ACKNOWLEDGEMENTS, validationErrors: generateValidationErrors(payload, FIELD_ID, ERROR_MESSAGES.INSURANCE.DECLARATIONS[FIELD_ID].IS_EMPTY), }; diff --git a/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.ts b/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.ts index f1b0719a08..5b4e0835ec 100644 --- a/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.ts +++ b/src/ui/server/controllers/insurance/declarations/confirmation-and-acknowledgements/index.ts @@ -58,7 +58,6 @@ export const get = async (req: Request, res: Response) => { }), ...pageVariables(application.referenceNumber), userName: getUserNameFromSession(req.session.user), - CONTENT: CONFIRMATION_AND_ACKNOWLEDGEMENTS, application: mapApplicationToFormFields(res.locals.application), }); }; @@ -91,7 +90,6 @@ export const post = async (req: Request, res: Response) => { }), ...pageVariables(referenceNumber), userName: getUserNameFromSession(req.session.user), - CONTENT: CONFIRMATION_AND_ACKNOWLEDGEMENTS, validationErrors, }); } diff --git a/src/ui/templates/components/declarations/declaration-list.njk b/src/ui/templates/components/declarations/declaration-list.njk index 371a710ea6..940afb6354 100644 --- a/src/ui/templates/components/declarations/declaration-list.njk +++ b/src/ui/templates/components/declarations/declaration-list.njk @@ -1,13 +1,13 @@ {% macro render(params) %} - {% set CONTENT = params.CONTENT %} + {% set CONTENT_STRINGS = params.CONTENT_STRINGS %} {% set DATA_CY = params.DATA_CY %} -

    {{ CONTENT.INTRO }}

    +

    {{ CONTENT_STRINGS.INTRO }}

      - {% for level1Item in CONTENT.LIST %} + {% for level1Item in CONTENT_STRINGS.LIST %}
    1. {{ level1Item.text }} diff --git a/src/ui/templates/insurance/declarations/anti-bribery.njk b/src/ui/templates/insurance/declarations/anti-bribery.njk index a33b0b85ff..d1c9c0c37a 100644 --- a/src/ui/templates/insurance/declarations/anti-bribery.njk +++ b/src/ui/templates/insurance/declarations/anti-bribery.njk @@ -34,7 +34,7 @@
      {{ declarationList.render({ - CONTENT: CONTENT, + CONTENT_STRINGS: CONTENT_STRINGS, DATA_CY: DATA_CY }) }} diff --git a/src/ui/templates/insurance/declarations/confidentiality.njk b/src/ui/templates/insurance/declarations/confidentiality.njk index f37c94adbd..5d625dc1ed 100644 --- a/src/ui/templates/insurance/declarations/confidentiality.njk +++ b/src/ui/templates/insurance/declarations/confidentiality.njk @@ -34,7 +34,7 @@
      {{ declarationList.render({ - CONTENT: CONTENT, + CONTENT_STRINGS: CONTENT_STRINGS, DATA_CY: DATA_CY }) }} diff --git a/src/ui/templates/shared-pages/declaration.njk b/src/ui/templates/shared-pages/declaration.njk index d34b326368..cf627ac649 100644 --- a/src/ui/templates/shared-pages/declaration.njk +++ b/src/ui/templates/shared-pages/declaration.njk @@ -33,7 +33,7 @@
      {{ declarationList.render({ - CONTENT: CONTENT, + CONTENT_STRINGS: CONTENT_STRINGS, DATA_CY: DATA_CY }) }}