From 7d2800ad721f20aa343b2cda9c503fead42c238c Mon Sep 17 00:00:00 2001 From: Tom Saunders Date: Fri, 24 Jan 2025 13:39:51 +0000 Subject: [PATCH] SCRATCH - demo contextual answer vs change strings. --- app/resources/cy/translation/applicant/name.json | 2 ++ app/resources/cy/translation/language.json | 2 ++ app/resources/en/translation/applicant/name.json | 2 ++ app/resources/en/translation/language.json | 2 ++ app/steps/ui/applicant/name/index.js | 11 +++++++++++ app/steps/ui/summary/includes/deceased.njk | 4 ++++ app/steps/ui/summary/includes/executors-applicant.njk | 4 ++++ test/component/applicant/testApplicantName.js | 2 +- test/component/testLanguage.js | 2 +- 9 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/resources/cy/translation/applicant/name.json b/app/resources/cy/translation/applicant/name.json index 56db73232c..63e75c0d56 100644 --- a/app/resources/cy/translation/applicant/name.json +++ b/app/resources/cy/translation/applicant/name.json @@ -5,6 +5,8 @@ "content2": "Dylai eich enw fod union yr un fath ag y mae wedi’i ysgrifennu ar eich pasbort neu fath arall o ddogfen adnabod awdurdodedig, er enghraifft trwydded yrru.", "content3": "Dylech wneud yn siŵr mai dyma’r un math o brawf adnabod a ddefnyddiwch pan fyddwch yn delio ag ystad yr unigolyn sydd wedi marw.", "firstName": "Enw cyntaf ac unrhyw enwau canol", + "changeFirstName": "Welsh - Change your first or middle names", + "answerFirstName": "Welsh - Provide your first or middle names", "lastName": "Cyfenw", "warningText": "Os nad yw’r enw ar y grant yn cyfateb i’r prawf adnabod a ddefnyddiwch, efallai y cewch anawsterau wrth ddelio â’r ystad.", diff --git a/app/resources/cy/translation/language.json b/app/resources/cy/translation/language.json index cc9fb3461e..7631e7a93b 100644 --- a/app/resources/cy/translation/language.json +++ b/app/resources/cy/translation/language.json @@ -1,6 +1,8 @@ { "title": "Grant language", "question": "Hoffech chi grant dwyieithog, sef Cymraeg a Saesneg?", + "a11yChange": "Welsh - Change bilingual grant required", + "a11yAnswer": "Welsh - Is a bilingual grant required", "optionYes": "Hoffwn", "optionNo": "Na hoffwn", diff --git a/app/resources/en/translation/applicant/name.json b/app/resources/en/translation/applicant/name.json index cb5f2a47c7..a915b59775 100644 --- a/app/resources/en/translation/applicant/name.json +++ b/app/resources/en/translation/applicant/name.json @@ -5,6 +5,8 @@ "content2": "Your name should match exactly what is written on your passport or other official identification document, such as a driving licence.", "content3": "You should make sure that this is the same form of identification you use when you are dealing with the estate of the person who died.", "firstName": "First name and any middle names", + "changeFirstName": "English - Change your first or middle names", + "answerFirstName": "English - Provide your first or middle names", "lastName": "Last name", "warningText": "If the name on the grant does not match the identification you use, you may have difficulties dealing with the estate.", diff --git a/app/resources/en/translation/language.json b/app/resources/en/translation/language.json index 14c66819db..c9a1831517 100644 --- a/app/resources/en/translation/language.json +++ b/app/resources/en/translation/language.json @@ -1,6 +1,8 @@ { "title": "Select the language for the Grant", "question": "Do you require a bilingual grant in English and Welsh?", + "a11yChange": "English - Change bilingual grant required", + "a11yAnswer": "English - Is a bilingual grant required", "optionYes": "Yes", "optionNo": "No", diff --git a/app/steps/ui/applicant/name/index.js b/app/steps/ui/applicant/name/index.js index 5bf189f86a..e4b44ff529 100644 --- a/app/steps/ui/applicant/name/index.js +++ b/app/steps/ui/applicant/name/index.js @@ -1,5 +1,6 @@ 'use strict'; +const crypto = require('crypto'); const ValidationStep = require('app/core/steps/ValidationStep'); class ApplicantName extends ValidationStep { @@ -7,6 +8,16 @@ class ApplicantName extends ValidationStep { static getUrl() { return '/applicant-name'; } + + generateContent(ctx, formdata, language = 'en') { + const superContent = super.generateContent(ctx, formdata, language); + + const dynamic = crypto.randomBytes(100).toString() + .padStart(2, '0'); + superContent.answerFirstName = superContent.answerFirstName + ' dynamic=' + dynamic; + superContent.changeFirstName = superContent.changeFirstName + ' dynamic=' + dynamic; + return superContent; + } } module.exports = ApplicantName; diff --git a/app/steps/ui/summary/includes/deceased.njk b/app/steps/ui/summary/includes/deceased.njk index 80a90097df..1567f847d1 100644 --- a/app/steps/ui/summary/includes/deceased.njk +++ b/app/steps/ui/summary/includes/deceased.njk @@ -3,6 +3,10 @@ { question: content.BilingualGOP.question, answer: content.BilingualGOP[fields.language.bilingual.value], + a11yCtx: { + change: content.BilingualGOP.a11yChange, + answer: content.BilingualGOP.a11yAnswer + }, visible: true } ], diff --git a/app/steps/ui/summary/includes/executors-applicant.njk b/app/steps/ui/summary/includes/executors-applicant.njk index c4d440418f..9fd470247c 100644 --- a/app/steps/ui/summary/includes/executors-applicant.njk +++ b/app/steps/ui/summary/includes/executors-applicant.njk @@ -3,6 +3,10 @@ { question: content.ApplicantName.firstName, answer: fields.applicant.firstName.value, + a11yCtx: { + change: content.ApplicantName.changeFirstName, + answer: content.ApplicantName.answerFirstName + }, visible: true }, { diff --git a/test/component/applicant/testApplicantName.js b/test/component/applicant/testApplicantName.js index 059f871a6f..1d002ca2af 100644 --- a/test/component/applicant/testApplicantName.js +++ b/test/component/applicant/testApplicantName.js @@ -30,7 +30,7 @@ describe('applicant-name', () => { testWrapper.agent.post('/prepare-session/form') .send(sessionData) .end(() => { - testWrapper.testContent(done); + testWrapper.testContent(done, {}, ['changeFirstName', 'answerFirstName']); }); }); diff --git a/test/component/testLanguage.js b/test/component/testLanguage.js index c97d37ff15..94d98ab4b8 100644 --- a/test/component/testLanguage.js +++ b/test/component/testLanguage.js @@ -23,7 +23,7 @@ describe('bilingual-gop', () => { testCommonContent.runTest('BilingualGOP'); it('test content loaded on the page', (done) => { - testWrapper.testContent(done); + testWrapper.testContent(done, {}, ['a11yChange', 'a11yAnswer']); }); it('test errors message displayed for missing data', (done) => {