From 0363f4c3454a416f90c3f757be576ffa7abcf45c Mon Sep 17 00:00:00 2001 From: Saral Kaushik Date: Mon, 17 Feb 2025 15:31:42 +0000 Subject: [PATCH 1/3] update script and run to support HMRC --- clients/dfeApplyForTeacherTraining.ts | 2 +- clients/hmrc.ts | 9 +++++++++ clients/iaa.ts | 16 +++++----------- interfaces/client.interface.ts | 3 +++ interfaces/translations.interface.ts | 3 +++ scripts/generate | 11 ++++------- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/clients/dfeApplyForTeacherTraining.ts b/clients/dfeApplyForTeacherTraining.ts index 29113d7..fa1a818 100644 --- a/clients/dfeApplyForTeacherTraining.ts +++ b/clients/dfeApplyForTeacherTraining.ts @@ -18,7 +18,7 @@ const dfeApplyForTeacherTraining: Client = { description: "Apply for a teacher training course to teach in England.", linkText: "Go to your Apply for teacher training account", linkUrl: - "https://www.apply-for-teacher-training.service.gov.uk/candidate/", + "https://www.apply-for-teacher-training.service.gov.uk/candidate/account", }, }, }; diff --git a/clients/hmrc.ts b/clients/hmrc.ts index 5694bfb..95cae46 100644 --- a/clients/hmrc.ts +++ b/clients/hmrc.ts @@ -17,12 +17,21 @@ const hmrc: Client = { header: "A service run by HM Revenue and Customs (HMRC)", linkText: "Find the HMRC service you need", linkUrl: "https://www.gov.uk/government/organisations/hm-revenue-customs", + hintText: "For example services about tax, childcare, or state pensions.", + paragraph1: + "At the moment, GOV.UK One Login cannot show you which HMRC service you’ve used.", + paragraph2: "We’re working to make this possible.", }, cy: { header: "Gwasanaeth a weithredir gan Gyllid a Thollau EF (CThEF)", linkText: "Dod o hyd i wasanaeth CThEF rydych ei angen", linkUrl: "https://www.gov.uk/government/organisations/hm-revenue-customs.cy", + hintText: + "Er enghraifft gwasanaethau am dreth, gofal plant, neu bensiynau'r wladwriaeth.", + paragraph1: + "Ar hyn o bryd, ni all GOV.UK One Login ddangos i chi pa wasanaeth CThEF rydych wedi'i ddefnyddio.", + paragraph2: "Rydym yn gweithio i wneud hyn yn bosibl.", }, }, }; diff --git a/clients/iaa.ts b/clients/iaa.ts index 81f7fef..f023d34 100644 --- a/clients/iaa.ts +++ b/clients/iaa.ts @@ -6,7 +6,7 @@ const iaa: Client = { integration: "Gk-D7WMvytB44Nze7oEC5KcThQZ4yl7sAA", nonProduction: "iaa", }, - isAvailableInWelsh: true, + isAvailableInWelsh: false, isAllowed: true, clientType: "account", isHmrc: false, @@ -14,18 +14,12 @@ const iaa: Client = { showInClientSearch: { production: true, nonProduction: true }, translations: { en: { - header: "Register of immigration advisers", + header: "Immigration Advice Authority", description: "Authorise and register an immigration adviser or organisation.", - linkText: "Go to your Register of immigration advisers account", - linkUrl: "https://portal.oisc.gov.uk/", - }, - cy: { - header: "Cofrestr o ymgynghorwyr mewnfudo", - description: - "Awdurdodi a chofrestru ymgynghorydd neu sefydliad mewnfudo.", - linkText: "Ewch i'ch cyfrif Cofrestr o gynghorwyr mewnfudo", - linkUrl: "https://portal.oisc.gov.uk/", + linkText: "Go to your Immigration Advice Authority account", + linkUrl: + "https://www.gov.uk/government/organisations/immigration-advice-authority", }, }, }; diff --git a/interfaces/client.interface.ts b/interfaces/client.interface.ts index 5bb6a05..821e1dd 100644 --- a/interfaces/client.interface.ts +++ b/interfaces/client.interface.ts @@ -11,6 +11,9 @@ interface Translations { description?: string; linkText: string; linkUrl: EnvironmentValue; + hintText?: string; + paragraph1?: string; + paragraph2?: string; } interface BaseClient { diff --git a/interfaces/translations.interface.ts b/interfaces/translations.interface.ts index 5bdcc69..4459529 100644 --- a/interfaces/translations.interface.ts +++ b/interfaces/translations.interface.ts @@ -3,6 +3,9 @@ export interface Translation { description?: string; link_text: string; link_href: string; + hint_text?: string; + paragraph1?: string; + paragraph2?: string; } export type TranslationsObject = Record; \ No newline at end of file diff --git a/scripts/generate b/scripts/generate index 6e21347..850d39e 100755 --- a/scripts/generate +++ b/scripts/generate @@ -1,6 +1,7 @@ #!/usr/bin/env bun import { writeFileSync, readFileSync } from "fs"; import { Client } from "../interfaces/client.interface"; +import { Translation } from '../interfaces/translations.interface' import { getAllowedAccountListClientIDs, clientsToShowInSearchProd, @@ -8,13 +9,6 @@ import { rsaAllowList, } from "../../di-account-management-frontend/src/config"; -interface Translation { - header: string; - description?: string; - link_text: string; - link_href: string; -} - interface IDs { production: string; integration: string; @@ -88,6 +82,9 @@ function transformTranslate( description: client.description, linkText: client.link_text, linkUrl: generateLinkObject(ids, language), + ...client.hint_text && { hintText: client.hint_text }, + ...client.paragraph1 && { paragraph1: client.paragraph1 }, + ...client.paragraph2 && { paragraph2: client.paragraph2 }, }; } From 2358e2f187c9e0a787dfc8310ee752fa5b76cee6 Mon Sep 17 00:00:00 2001 From: Saral Kaushik Date: Wed, 19 Feb 2025 13:59:23 +0000 Subject: [PATCH 2/3] support hmrc --- src/get-translations.ts | 5 +++- tests/get-translations.test.ts | 49 +++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/get-translations.ts b/src/get-translations.ts index 919d4b5..c69ab7a 100644 --- a/src/get-translations.ts +++ b/src/get-translations.ts @@ -8,7 +8,10 @@ const convertToTranslation = (translations: Client["translations"]["en"], enviro header: translations.header, link_text: translations.linkText, link_href: getValueForEnvironment(environment, translations.linkUrl), - description: translations.description || undefined + ...translations.description && { description: translations.description }, + ...translations.hintText && { hint_text: translations.hintText }, + ...translations.paragraph1 && { paragraph1: translations.paragraph1 }, + ...translations.paragraph2 && { paragraph2: translations.paragraph2 } } } diff --git a/tests/get-translations.test.ts b/tests/get-translations.test.ts index 169d8a4..ca1a701 100644 --- a/tests/get-translations.test.ts +++ b/tests/get-translations.test.ts @@ -45,6 +45,26 @@ jest.mock('../clients', () => ({ isHmrc: false, isReportSuspiciousActivityEnabled: false, showInClientSearch: true + }, + hmrcClient: { + isAvailableInWelsh: false, + translations: { + en: { + header: 'header en', + linkText: 'link text en', + linkUrl: 'link url en', + description: 'description en', + hintText: 'hint text en', + paragraph1: 'paragraph 1 en', + paragraph2: 'paragraph 2 en' + }, + }, + clientId: 'englishClient', + clientType: 'account', + isAllowed: true, + isHmrc: false, + isReportSuspiciousActivityEnabled: false, + showInClientSearch: true } })); @@ -63,7 +83,16 @@ describe('getTranslations', () => { link_text: 'link text en', link_href: 'link url en', description: 'description en' - } + }, + hmrcClient: { + description: "description en", + header: "header en", + hint_text: "hint text en", + link_href: "link url en", + link_text: "link text en", + paragraph1: "paragraph 1 en", + paragraph2: "paragraph 2 en", + }, }); }); test('should return transaltions in welsh', async () => { @@ -80,6 +109,15 @@ describe('getTranslations', () => { link_text: 'link text en', link_href: 'link url en', description: 'description en' + }, + hmrcClient: { + description: "description en", + header: "header en", + hint_text: "hint text en", + link_href: "link url en", + link_text: "link text en", + paragraph1: "paragraph 1 en", + paragraph2: "paragraph 2 en", } }); }) @@ -97,6 +135,15 @@ describe('getTranslations', () => { link_text: 'link text en', link_href: 'link url en', description: 'description en' + }, + hmrcClient: { + description: "description en", + header: "header en", + hint_text: "hint text en", + link_href: "link url en", + link_text: "link text en", + paragraph1: "paragraph 1 en", + paragraph2: "paragraph 2 en", } }); }) From 5cad7d84e9a9f3d3b4bfb10b51b937d7a2a7abd7 Mon Sep 17 00:00:00 2001 From: Saral Kaushik Date: Wed, 19 Feb 2025 14:09:32 +0000 Subject: [PATCH 3/3] add test for description undefined --- tests/get-translations.test.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/get-translations.test.ts b/tests/get-translations.test.ts index ca1a701..cd8c577 100644 --- a/tests/get-translations.test.ts +++ b/tests/get-translations.test.ts @@ -10,7 +10,6 @@ jest.mock('../clients', () => ({ header: 'header en', linkText: 'link text en', linkUrl: 'link url en', - description: 'description en' }, cy: { header: 'header cy', @@ -19,7 +18,6 @@ jest.mock('../clients', () => ({ production: 'link url cy production', nonProduction: 'link url cy non production' }, - description: 'description cy' } }, clientId: 'welshClient', @@ -71,12 +69,11 @@ jest.mock('../clients', () => ({ describe('getTranslations', () => { test('should return translations in english', async () => { const translations = getTranslations('test', 'en'); - expect(translations).toEqual({ + expect(translations).toStrictEqual({ cyClient: { header: 'header en', link_text: 'link text en', link_href: 'link url en', - description: 'description en' }, enClient: { header: 'header en', @@ -97,12 +94,11 @@ describe('getTranslations', () => { }); test('should return transaltions in welsh', async () => { const translations = getTranslations('test', 'cy'); - expect(translations).toEqual({ + expect(translations).toStrictEqual({ cyClient: { header: 'header cy', link_text: 'link text cy', link_href: 'link url cy non production', - description: 'description cy' }, enClient: { header: 'header en', @@ -123,12 +119,11 @@ describe('getTranslations', () => { }) test('should return correct environment varialbes', async () => { const translations = getTranslations('production', 'cy'); - expect(translations).toEqual({ + expect(translations).toStrictEqual({ cyClient: { header: 'header cy', link_text: 'link text cy', link_href: 'link url cy production', - description: 'description cy' }, enClient: { header: 'header en',