From d5181394c89240f088fee45d619295c565c20578 Mon Sep 17 00:00:00 2001 From: RiteshHMCTS <74713687+RiteshHMCTS@users.noreply.github.com> Date: Mon, 18 Nov 2024 14:51:15 +0000 Subject: [PATCH 01/11] Add the fix and tests (#1807) * Add the fix and tests * version updated --- RELEASE-NOTES.md | 3 +++ package.json | 2 +- projects/ccd-case-ui-toolkit/package.json | 2 +- ...dynamic-radio-list-field.component.spec.ts | 25 +++++++++++++++++++ ...rite-dynamic-radio-list-field.component.ts | 4 ++- 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 5c10db0ed9..a15321732a 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,5 +1,8 @@ ## RELEASE NOTES +### Version 7.0.75-exui-2462-rc1 +**EXUI-2462** DynamicRadioList incorrectly selects the wrong radio button + ### Version 7.0.75 **EXUI-2415** Redirect to an new event by a hyperlink diff --git a/package.json b/package.json index 8bb3eeb326..72f2aaabd8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75", + "version": "7.0.75-exui-2462-rc1", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/package.json b/projects/ccd-case-ui-toolkit/package.json index e61648f592..ca14310784 100644 --- a/projects/ccd-case-ui-toolkit/package.json +++ b/projects/ccd-case-ui-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75", + "version": "7.0.75-exui-2462-rc1", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.spec.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.spec.ts index 95e6530a43..e19097d53f 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.spec.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.spec.ts @@ -98,4 +98,29 @@ describe('WriteDynamicRadioListFieldComponent', () => { expect(attr(options[1], 'id')).toEqual('MaritalStatus_F'); expect(attr(options[2], 'id')).toEqual('MaritalStatus_O'); }); + + // Note: Currently unknown why this is the default for a parent with relevant value + it('test parent value sets element ID', () => { + component.parent = {value: {id: '1', value: 'value'}} as any; + fixture.detectChanges(); + const options = de.queryAll($RADIO); + + expect(options.length).toEqual(3); + expect(attr(options[0], 'type')).toEqual('radio'); + expect(attr(options[0], 'id')).toEqual('1value'); + expect(attr(options[1], 'id')).toEqual('1value'); + expect(attr(options[2], 'id')).toEqual('1value'); + }); + + it('test parent value not present', () => { + component.parent = {value: null} as any; + fixture.detectChanges(); + const options = de.queryAll($RADIO); + + expect(options.length).toEqual(3); + expect(attr(options[0], 'type')).toEqual('radio'); + expect(attr(options[0], 'id')).toEqual('MaritalStatus_M'); + expect(attr(options[1], 'id')).toEqual('MaritalStatus_F'); + expect(attr(options[2], 'id')).toEqual('MaritalStatus_O'); + }); }); diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.ts index add27f771b..a36f9cf641 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/dynamic-radio-list/write-dynamic-radio-list-field.component.ts @@ -33,6 +33,8 @@ export class WriteDynamicRadioListFieldComponent extends AbstractFieldWriteCompo } public createElementId(name: string): string { - return this.parent && this.parent.value ? this.parent.value.id + this.parent.value.value : super.createElementId(name); + // EXUI-2462 - parent may not always have value with content + // this is independent from the caseField.list_items so is irrelevant to event journey + return this.parent?.value?.id ? this.parent.value.id + this.parent.value.value : super.createElementId(name); } } From 507de29e691ac41f4d198116556bbd4cf80bb70a Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 18 Nov 2024 14:58:21 +0000 Subject: [PATCH 02/11] update yarn audit --- yarn-audit-known-issues | 1 + 1 file changed, 1 insertion(+) diff --git a/yarn-audit-known-issues b/yarn-audit-known-issues index f6ae578c82..c218140e2f 100644 --- a/yarn-audit-known-issues +++ b/yarn-audit-known-issues @@ -5,6 +5,7 @@ {"value":"cookie","children":{"ID":1099846,"Issue":"cookie accepts cookie name, path, and domain with out of bounds characters","URL":"https://github.com/advisories/GHSA-pxg6-pf52-xh8x","Severity":"low","Vulnerable Versions":"<0.7.0","Tree Versions":["0.6.0"],"Dependents":["express@npm:4.19.2"]}} {"value":"copy-concurrently","children":{"ID":"copy-concurrently (deprecation)","Issue":"This package is no longer supported.","Severity":"moderate","Vulnerable Versions":"1.0.5","Tree Versions":["1.0.5"],"Dependents":["move-concurrently@npm:1.0.1"]}} {"value":"core-js","children":{"ID":"core-js (deprecation)","Issue":"core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.","Severity":"moderate","Vulnerable Versions":"1.2.7","Tree Versions":["1.2.7"],"Dependents":["fbjs@npm:0.8.18"]}} +{"value":"cross-spawn","children":{"ID":1100467,"Issue":"Regular Expression Denial of Service (ReDoS) in cross-spawn","URL":"https://github.com/advisories/GHSA-3xgq-45jj-v275","Severity":"high","Vulnerable Versions":"<7.0.5","Tree Versions":["5.1.0","7.0.3"],"Dependents":["execa@npm:0.7.0","foreground-child@npm:3.2.1"]}} {"value":"domexception","children":{"ID":"domexception (deprecation)","Issue":"Use your platform's native DOMException instead","Severity":"moderate","Vulnerable Versions":"4.0.0","Tree Versions":["4.0.0"],"Dependents":["jsdom@virtual:ce56289c4b7a2e9003d709997e253c1c80dcaee4c6fbe440cbe9ba5de5db8af3a7b7ad41bbdec5a5e3d40dc9c3c54bef92dd6885ff84cd436d636d5a1b380a61#npm:20.0.3"]}} {"value":"express","children":{"ID":1099529,"Issue":"express vulnerable to XSS via response.redirect()","URL":"https://github.com/advisories/GHSA-qw6h-vgh9-j6wx","Severity":"moderate","Vulnerable Versions":"<4.20.0","Tree Versions":["4.19.2"],"Dependents":["json-server@npm:0.15.1"]}} {"value":"figgy-pudding","children":{"ID":"figgy-pudding (deprecation)","Issue":"This module is no longer supported.","Severity":"moderate","Vulnerable Versions":"3.5.2","Tree Versions":["3.5.2"],"Dependents":["npm-registry-fetch@npm:4.0.7"]}} From 3913532cc8644c79a491e485102183d064dd09a9 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 18 Nov 2024 15:05:56 +0000 Subject: [PATCH 03/11] change ver num --- package.json | 2 +- projects/ccd-case-ui-toolkit/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 72f2aaabd8..7b227dc4c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75-exui-2462-rc1", + "version": "7.0.75-exui-2462-rc", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/package.json b/projects/ccd-case-ui-toolkit/package.json index ca14310784..cb26fbc835 100644 --- a/projects/ccd-case-ui-toolkit/package.json +++ b/projects/ccd-case-ui-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75-exui-2462-rc1", + "version": "7.0.75-exui-2462-rc", "engines": { "node": ">=18.19.0" }, From c86360f6d3fe22012aface8ee24fc979b8caa9c1 Mon Sep 17 00:00:00 2001 From: RiteshHMCTS <74713687+RiteshHMCTS@users.noreply.github.com> Date: Mon, 25 Nov 2024 10:53:03 +0000 Subject: [PATCH 04/11] exui-2515-case-link-issue (#1805) * checking for the availability of Other type reason * version updated * cve * version updated * version updated --- RELEASE-NOTES.md | 5 ++++- package.json | 2 +- projects/ccd-case-ui-toolkit/package.json | 2 +- .../write-linked-cases-field.component.ts | 9 ++++++--- yarn-audit-known-issues | 11 ++++++----- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index a15321732a..e63ff2ddac 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,4 +1,7 @@ -## RELEASE NOTES +## RELEASE NOTES + +### Version 7.0.75-exui-2515 +**EXUI-2515** case-link-issue ### Version 7.0.75-exui-2462-rc1 **EXUI-2462** DynamicRadioList incorrectly selects the wrong radio button diff --git a/package.json b/package.json index 7b227dc4c6..ad572f51fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75-exui-2462-rc", + "version": "7.0.75-exui-2515", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/package.json b/projects/ccd-case-ui-toolkit/package.json index cb26fbc835..640f1fc5a1 100644 --- a/projects/ccd-case-ui-toolkit/package.json +++ b/projects/ccd-case-ui-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75-exui-2462-rc", + "version": "7.0.75-exui-2515", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.ts index 0e16f51629..27989afaca 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/linked-cases/write-linked-cases-field.component.ts @@ -98,10 +98,13 @@ export class WriteLinkedCasesFieldComponent extends AbstractFieldWriteComponent next: (reasons) => { // Sort in ascending order const linkCaseReasons = reasons.list_of_values.sort((a, b) => (a.value_en > b.value_en) ? 1 : -1); - - this.linkedCasesService.linkCaseReasons = linkCaseReasons?.filter((reason) => reason.value_en !== 'Other'); + if (linkCaseReasons?.filter((reason) => reason.value_en !== 'Other').length > 0) { + this.linkedCasesService.linkCaseReasons = linkCaseReasons?.filter((reason) => reason.value_en !== 'Other'); + } // Move Other option to the end of the list - this.linkedCasesService.linkCaseReasons.push(linkCaseReasons?.find((reason) => reason.value_en === 'Other')); + if (linkCaseReasons?.find((reason) => reason.value_en === 'Other')) { + this.linkedCasesService.linkCaseReasons.push(linkCaseReasons?.find((reason) => reason.value_en === 'Other')); + } } }); } diff --git a/yarn-audit-known-issues b/yarn-audit-known-issues index c218140e2f..00840674be 100644 --- a/yarn-audit-known-issues +++ b/yarn-audit-known-issues @@ -5,9 +5,10 @@ {"value":"cookie","children":{"ID":1099846,"Issue":"cookie accepts cookie name, path, and domain with out of bounds characters","URL":"https://github.com/advisories/GHSA-pxg6-pf52-xh8x","Severity":"low","Vulnerable Versions":"<0.7.0","Tree Versions":["0.6.0"],"Dependents":["express@npm:4.19.2"]}} {"value":"copy-concurrently","children":{"ID":"copy-concurrently (deprecation)","Issue":"This package is no longer supported.","Severity":"moderate","Vulnerable Versions":"1.0.5","Tree Versions":["1.0.5"],"Dependents":["move-concurrently@npm:1.0.1"]}} {"value":"core-js","children":{"ID":"core-js (deprecation)","Issue":"core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.","Severity":"moderate","Vulnerable Versions":"1.2.7","Tree Versions":["1.2.7"],"Dependents":["fbjs@npm:0.8.18"]}} -{"value":"cross-spawn","children":{"ID":1100467,"Issue":"Regular Expression Denial of Service (ReDoS) in cross-spawn","URL":"https://github.com/advisories/GHSA-3xgq-45jj-v275","Severity":"high","Vulnerable Versions":"<7.0.5","Tree Versions":["5.1.0","7.0.3"],"Dependents":["execa@npm:0.7.0","foreground-child@npm:3.2.1"]}} +{"value":"cross-spawn","children":{"ID":1100562,"Issue":"Regular Expression Denial of Service (ReDoS) in cross-spawn","URL":"https://github.com/advisories/GHSA-3xgq-45jj-v275","Severity":"high","Vulnerable Versions":"<6.0.6","Tree Versions":["5.1.0"],"Dependents":["execa@npm:0.7.0"]}} +{"value":"cross-spawn","children":{"ID":1100563,"Issue":"Regular Expression Denial of Service (ReDoS) in cross-spawn","URL":"https://github.com/advisories/GHSA-3xgq-45jj-v275","Severity":"high","Vulnerable Versions":">=7.0.0 <7.0.5","Tree Versions":["7.0.3"],"Dependents":["foreground-child@npm:3.2.1"]}} {"value":"domexception","children":{"ID":"domexception (deprecation)","Issue":"Use your platform's native DOMException instead","Severity":"moderate","Vulnerable Versions":"4.0.0","Tree Versions":["4.0.0"],"Dependents":["jsdom@virtual:ce56289c4b7a2e9003d709997e253c1c80dcaee4c6fbe440cbe9ba5de5db8af3a7b7ad41bbdec5a5e3d40dc9c3c54bef92dd6885ff84cd436d636d5a1b380a61#npm:20.0.3"]}} -{"value":"express","children":{"ID":1099529,"Issue":"express vulnerable to XSS via response.redirect()","URL":"https://github.com/advisories/GHSA-qw6h-vgh9-j6wx","Severity":"moderate","Vulnerable Versions":"<4.20.0","Tree Versions":["4.19.2"],"Dependents":["json-server@npm:0.15.1"]}} +{"value":"express","children":{"ID":1100530,"Issue":"express vulnerable to XSS via response.redirect()","URL":"https://github.com/advisories/GHSA-qw6h-vgh9-j6wx","Severity":"low","Vulnerable Versions":"<4.20.0","Tree Versions":["4.19.2"],"Dependents":["json-server@npm:0.15.1"]}} {"value":"figgy-pudding","children":{"ID":"figgy-pudding (deprecation)","Issue":"This module is no longer supported.","Severity":"moderate","Vulnerable Versions":"3.5.2","Tree Versions":["3.5.2"],"Dependents":["npm-registry-fetch@npm:4.0.7"]}} {"value":"fs-write-stream-atomic","children":{"ID":"fs-write-stream-atomic (deprecation)","Issue":"This package is no longer supported.","Severity":"moderate","Vulnerable Versions":"1.0.10","Tree Versions":["1.0.10"],"Dependents":["move-concurrently@npm:1.0.1"]}} {"value":"gauge","children":{"ID":"gauge (deprecation)","Issue":"This package is no longer supported.","Severity":"moderate","Vulnerable Versions":"3.0.2","Tree Versions":["3.0.2"],"Dependents":["npmlog@npm:5.0.1"]}} @@ -33,9 +34,9 @@ {"value":"request","children":{"ID":1096727,"Issue":"Server-Side Request Forgery in Request","URL":"https://github.com/advisories/GHSA-p8p7-x288-28g6","Severity":"moderate","Vulnerable Versions":"<=2.88.2","Tree Versions":["2.88.2"],"Dependents":["json-server@npm:0.15.1"]}} {"value":"resolve-url","children":{"ID":"resolve-url (deprecation)","Issue":"https://github.com/lydell/resolve-url#deprecated","Severity":"moderate","Vulnerable Versions":"0.2.1","Tree Versions":["0.2.1"],"Dependents":["source-map-resolve@npm:0.5.3"]}} {"value":"rimraf","children":{"ID":"rimraf (deprecation)","Issue":"Rimraf versions prior to v4 are no longer supported","Severity":"moderate","Vulnerable Versions":"3.0.2","Tree Versions":["3.0.2"],"Dependents":["@mapbox/node-pre-gyp@npm:1.0.11"]}} -{"value":"send","children":{"ID":1099525,"Issue":"send vulnerable to template injection that can lead to XSS","URL":"https://github.com/advisories/GHSA-m6fv-jmcg-4jfg","Severity":"moderate","Vulnerable Versions":"<0.19.0","Tree Versions":["0.18.0"],"Dependents":["express@npm:4.19.2"]}} -{"value":"serve-static","children":{"ID":1099527,"Issue":"serve-static vulnerable to template injection that can lead to XSS","URL":"https://github.com/advisories/GHSA-cm22-4g7w-348p","Severity":"moderate","Vulnerable Versions":"<1.16.0","Tree Versions":["1.15.0"],"Dependents":["express@npm:4.19.2"]}} -{"value":"socket.io-parser","children":{"ID":1098329,"Issue":"Insufficient validation when decoding a Socket.IO packet","URL":"https://github.com/advisories/GHSA-cqmj-92xf-r6r9","Severity":"high","Vulnerable Versions":">=4.0.4 <4.2.3","Tree Versions":["4.0.5"],"Dependents":["socket.io-client@npm:3.1.3"]}} +{"value":"send","children":{"ID":1100526,"Issue":"send vulnerable to template injection that can lead to XSS","URL":"https://github.com/advisories/GHSA-m6fv-jmcg-4jfg","Severity":"low","Vulnerable Versions":"<0.19.0","Tree Versions":["0.18.0"],"Dependents":["express@npm:4.19.2"]}} +{"value":"serve-static","children":{"ID":1100528,"Issue":"serve-static vulnerable to template injection that can lead to XSS","URL":"https://github.com/advisories/GHSA-cm22-4g7w-348p","Severity":"low","Vulnerable Versions":"<1.16.0","Tree Versions":["1.15.0"],"Dependents":["express@npm:4.19.2"]}} +{"value":"socket.io-parser","children":{"ID":1100541,"Issue":"Insufficient validation when decoding a Socket.IO packet","URL":"https://github.com/advisories/GHSA-cqmj-92xf-r6r9","Severity":"moderate","Vulnerable Versions":">=4.0.4 <4.2.3","Tree Versions":["4.0.5"],"Dependents":["socket.io-client@npm:3.1.3"]}} {"value":"source-map-resolve","children":{"ID":"source-map-resolve (deprecation)","Issue":"See https://github.com/lydell/source-map-resolve#deprecated","Severity":"moderate","Vulnerable Versions":"0.5.3","Tree Versions":["0.5.3"],"Dependents":["snapdragon@npm:0.8.2"]}} {"value":"source-map-url","children":{"ID":"source-map-url (deprecation)","Issue":"See https://github.com/lydell/source-map-url#deprecated","Severity":"moderate","Vulnerable Versions":"0.4.1","Tree Versions":["0.4.1"],"Dependents":["source-map-resolve@npm:0.5.3"]}} {"value":"tough-cookie","children":{"ID":1097682,"Issue":"tough-cookie Prototype Pollution vulnerability","URL":"https://github.com/advisories/GHSA-72xf-g2v4-qvf3","Severity":"moderate","Vulnerable Versions":"<4.1.3","Tree Versions":["2.5.0"],"Dependents":["request@npm:2.88.2"]}} From e73c77b1c6c0b64e8da0295a43c6fcf4b2fb77e3 Mon Sep 17 00:00:00 2001 From: connorpgpmcelroy <74015088+connorpgpmcelroy@users.noreply.github.com> Date: Thu, 28 Nov 2024 13:09:44 +0000 Subject: [PATCH 05/11] Add readCookieService and language information to client context (#1780) * Add readCookieService and language information to client context * Add version * Add additional language setting on clientcontext Event guard also sets it * Make sonar advised change * Add sonar suggested change * Update npmpublish.yml * Add change to make client context always appear with language * version updated * release notes updated * version updated * version updated --------- Co-authored-by: Ritesh Dsouza --- .github/workflows/npmpublish.yml | 2 +- RELEASE-NOTES.md | 3 ++ package.json | 2 +- projects/ccd-case-ui-toolkit/package.json | 2 +- .../case-editor/services/cases.service.ts | 50 ------------------- .../services/page-validation.service.ts | 2 +- .../event-guard/event-start.guard.spec.ts | 30 ++++++++++- .../event-guard/event-start.guard.ts | 23 ++++++++- .../event-start/event-start.component.ts | 7 ++- ...event-start-state-machine-context.model.ts | 3 +- .../event-start-state-machine.service.spec.ts | 7 ++- .../event-start-state-machine.service.ts | 6 ++- .../src/lib/shared/services/cookie/index.ts | 1 + .../cookie/read-cookie-service.spec.ts | 21 ++++++++ .../services/cookie/read-cookie-service.ts | 21 ++++++++ .../src/lib/shared/services/index.ts | 1 + sonar-project.properties | 1 - 17 files changed, 117 insertions(+), 65 deletions(-) create mode 100644 projects/ccd-case-ui-toolkit/src/lib/shared/services/cookie/index.ts create mode 100644 projects/ccd-case-ui-toolkit/src/lib/shared/services/cookie/read-cookie-service.spec.ts create mode 100644 projects/ccd-case-ui-toolkit/src/lib/shared/services/cookie/read-cookie-service.ts diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml index 65057afdc4..bd0ecda177 100644 --- a/.github/workflows/npmpublish.yml +++ b/.github/workflows/npmpublish.yml @@ -53,7 +53,7 @@ jobs: name: code-coverage-report path: coverage - name: Analyze with SonarCloud - uses: sonarsource/sonarcloud-github-action@v3.0.0 + uses: sonarsource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index e63ff2ddac..0d6d02e97b 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,5 +1,8 @@ ## RELEASE NOTES +### Version 7.0.75-exui-2315 +**EXUI-2315** etrieve current user language selection + ### Version 7.0.75-exui-2515 **EXUI-2515** case-link-issue diff --git a/package.json b/package.json index ad572f51fa..20f7e931d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75-exui-2515", + "version": "7.0.75-exui-2315", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/package.json b/projects/ccd-case-ui-toolkit/package.json index 640f1fc5a1..08fb6f6352 100644 --- a/projects/ccd-case-ui-toolkit/package.json +++ b/projects/ccd-case-ui-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75-exui-2515", + "version": "7.0.75-exui-2315", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/services/cases.service.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/services/cases.service.ts index 87edcd258d..856e9f502c 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/services/cases.service.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/services/cases.service.ts @@ -406,59 +406,9 @@ export class CasesService { } private updateClientContextStorage(headers: HttpHeaders): void { - // for mocking - TODO: Kasi Remove/Uncomment for testing - // headers = this.setMockClientContextHeader(headers); if (headers && headers.get('Client-Context')) { const clientContextString = window.atob(headers.get('Client-Context')); this.sessionStorageService.setItem('clientContext', clientContextString); } } - - // for mocking - TODO: Kasi Remove/Uncomment for testing - /* private setMockClientContextHeader(headers: HttpHeaders): HttpHeaders { - const mockClientContext = { client_context: { - user_task: { - task_data: { - // Replace with relevant task id to complete other/current task - id: "2c7e03cc-18e8-11ef-bfd0-763319b21cea", - // Can edit other details to check they update - name: "Review the appeal - Test mocked", - assignee: "dfd4c2d1-67b1-40f9-8680-c9551632f5d9", - type: "reviewTheAppeal", - task_state: "assigned", - task_system: "SELF", - security_classification: "PUBLIC", - task_title: "Review the appeal", - created_date: "2024-05-23T09:38:12+0000", - due_date: "2024-05-28T09:39:00+0000", - location_name: "Taylor House", - location: "765324", - execution_type: "Case Management Task", - jurisdiction: "IA", - region: "1", - case_type_id: "Asylum", - case_id: "1716456926502698", - case_category: "Protection", - case_name: "Aipp Check", - auto_assigned: false, - warnings: false, - warning_list: { values: [] }, - case_management_category: "Protection", - work_type_id: "decision_making_work", - work_type_label: "Decision-making work", - permissions: { values : ["Read","Own","Manage","Execute","Cancel","Complete","Claim","Assign","Unassign"] }, - description: "[Request respondent evidence](/case/IA/Asylum/${[CASE_REFERENCE]}/trigger/requestRespondentEvidence)", - role_category: "LEGAL_OPERATIONS", - minor_priority: 500, - major_priority: 5000, - priority_date: "2024-05-28T09:39:00+0000" - }, - // determines whether task will be completed - sets default to true via EXUI - complete_task: true - } - }}; - const encodedMockedClientContext = window.btoa(JSON.stringify(mockClientContext)); - headers = headers.set('Client-Context', encodedMockedClientContext); - return headers; - } */ } diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/services/page-validation.service.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/services/page-validation.service.ts index e4d13b4780..172d7443ec 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/services/page-validation.service.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/case-editor/services/page-validation.service.ts @@ -16,7 +16,7 @@ export class PageValidationService { page.case_fields .filter(caseField => !this.caseFieldService.isReadOnly(caseField)) .filter(caseField => !this.isHidden(caseField, editForm)) - .map(caseField => { + .forEach(caseField => { const theControl = FieldsUtils.isCaseFieldOfType(caseField, ['JudicialUser']) ? editForm.controls['data'].get(`${caseField.id}_judicialUserControl`) : editForm.controls['data'].get(caseField.id); diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.spec.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.spec.ts index 693e3b2642..a5e546cfd1 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.spec.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.spec.ts @@ -3,7 +3,7 @@ import { ActivatedRouteSnapshot, Router } from '@angular/router'; import { of } from 'rxjs'; import { TaskPayload } from '../../../domain/work-allocation/TaskPayload'; import { UserInfo } from '../../../domain/user/user-info.model'; -import { SessionStorageService } from '../../../services'; +import { ReadCookieService, SessionStorageService } from '../../../services'; import { WorkAllocationService } from '../../case-editor'; import { EventStartGuard } from './event-start.guard'; import { AbstractAppConfig } from '../../../../app.config'; @@ -30,12 +30,14 @@ describe('EventStartGuard', () => { let service: jasmine.SpyObj; let router: jasmine.SpyObj; let sessionStorageService: jasmine.SpyObj; + let mockCookieService: jasmine.SpyObj; let mockAbstractConfig: jasmine.SpyObj; beforeEach(() => { service = jasmine.createSpyObj('WorkAllocationService', ['getTasksByCaseIdAndEventId']); router = jasmine.createSpyObj('Router', ['navigate']); sessionStorageService = jasmine.createSpyObj('SessionStorageService', ['getItem', 'setItem', 'removeItem']); + mockCookieService = jasmine.createSpyObj('readCookieService', ['getCookie']); mockAbstractConfig = jasmine.createSpyObj('AbstractAppConfig', ['logMessage']); TestBed.configureTestingModule({ @@ -44,7 +46,8 @@ describe('EventStartGuard', () => { { provide: WorkAllocationService, useValue: service }, { provide: Router, useValue: router }, { provide: SessionStorageService, useValue: sessionStorageService }, - { provide: AbstractAppConfig, useValue: mockAbstractConfig } + { provide: AbstractAppConfig, useValue: mockAbstractConfig }, + { provide: ReadCookieService, useValue: mockCookieService } ] }); @@ -64,6 +67,19 @@ describe('EventStartGuard', () => { }); }); + it('client context should be set with language regardless whether task is attached to event', () => { + sessionStorageService.getItem.and.returnValue(null); + const mockClientContext = { client_context: { user_language: { language: 'cookieString' } } }; + mockCookieService.getCookie.and.returnValue('cookieString'); + const route = createActivatedRouteSnapshot('caseId', 'eventId'); + const result$ = guard.canActivate(route); + result$.subscribe(result => { + expect(result).toEqual(false); + // check client contesxt is set correctly + expect(sessionStorageService.setItem).toHaveBeenCalledWith('clientContext', JSON.stringify(mockClientContext)); + }); + }); + it('should log a message and not call getTasksByCaseIdAndEventId when caseInfo is not available', () => { sessionStorageService.getItem.and.returnValue(null); const route = createActivatedRouteSnapshot('caseId', 'eventId'); @@ -136,17 +152,22 @@ describe('EventStartGuard', () => { }); it('should return true and navigate to event trigger if one task is assigned to user', () => { + const mockLanguage = 'en'; const clientContext = { client_context: { user_task: { task_data: tasks[0], complete_task: true + }, + user_language: { + language: mockLanguage } } } tasks[0].assignee = '1'; const mockPayload: TaskPayload = {task_required_for_event: false, tasks}; sessionStorageService.getItem.and.returnValue(JSON.stringify(getExampleUserInfo())); + mockCookieService.getCookie.and.returnValue(mockLanguage); expect(guard.checkTaskInEventNotRequired(mockPayload, caseId, null)).toBe(true); expect(sessionStorageService.setItem).toHaveBeenCalledWith('clientContext', JSON.stringify(clientContext)); }); @@ -161,11 +182,15 @@ describe('EventStartGuard', () => { }); it('should return true and navigate to event trigger if navigated to via task next steps', () => { + const mockLanguage = 'cy'; const clientContext = { client_context: { user_task: { task_data: tasks[0], complete_task: true + }, + user_language: { + language: mockLanguage } } } @@ -173,6 +198,7 @@ describe('EventStartGuard', () => { tasks.push(tasks[0]); const mockPayload: TaskPayload = {task_required_for_event: false, tasks}; sessionStorageService.getItem.and.returnValue(JSON.stringify(getExampleUserInfo())); + mockCookieService.getCookie.and.returnValue(mockLanguage); expect(guard.checkTaskInEventNotRequired(mockPayload, caseId, '0d22d838-b25a-11eb-a18c-f2d58a9b7bc6')).toBe(true); expect(sessionStorageService.setItem).toHaveBeenCalledWith('clientContext', JSON.stringify(clientContext)); }); diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.ts index 81feae8093..1d6a7e0471 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.ts @@ -6,7 +6,7 @@ import { switchMap } from 'rxjs/operators'; import { AbstractAppConfig } from '../../../../app.config'; import { TaskEventCompletionInfo } from '../../../domain/work-allocation/Task'; import { TaskPayload } from '../../../domain/work-allocation/TaskPayload'; -import { SessionStorageService } from '../../../services'; +import { ReadCookieService, SessionStorageService } from '../../../services'; import { WorkAllocationService } from '../../case-editor'; @Injectable() @@ -16,7 +16,8 @@ export class EventStartGuard implements CanActivate { constructor(private readonly workAllocationService: WorkAllocationService, private readonly router: Router, private readonly sessionStorageService: SessionStorageService, - private readonly abstractConfig: AbstractAppConfig) { + private readonly abstractConfig: AbstractAppConfig, + private readonly cookieService: ReadCookieService) { } public canActivate(route: ActivatedRouteSnapshot): Observable { @@ -30,6 +31,16 @@ export class EventStartGuard implements CanActivate { userId = userInfo.id ? userInfo.id : userInfo.uid; } const caseInfoStr = this.sessionStorageService.getItem('caseInfo'); + const currentLanguage = this.cookieService.getCookie('exui-preferred-language'); + // if one task assigned to user, allow user to complete event + const storeClientContext = { + client_context: { + user_language: { + language: currentLanguage + } + } + }; + this.sessionStorageService.setItem(EventStartGuard.CLIENT_CONTEXT, JSON.stringify(storeClientContext)); if (caseInfoStr) { const caseInfo = JSON.parse(caseInfoStr); if (caseInfo && caseInfo.cid === caseId) { @@ -75,12 +86,16 @@ export class EventStartGuard implements CanActivate { } else { task = tasksAssignedToUser[0]; } + const currentLanguage = this.cookieService.getCookie('exui-preferred-language'); // if one task assigned to user, allow user to complete event const storeClientContext = { client_context: { user_task: { task_data: task, complete_task: true + }, + user_language: { + language: currentLanguage } } }; @@ -105,11 +120,15 @@ export class EventStartGuard implements CanActivate { taskId: task.id, createdTimestamp: Date.now() }; + const currentLanguage = this.cookieService.getCookie('exui-preferred-language'); const storeClientContext = { client_context: { user_task: { task_data: task, complete_task: true + }, + user_language: { + language: currentLanguage } } }; diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-start.component.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-start.component.ts index c02d551db7..a291ca8d72 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-start.component.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-start.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { StateMachine } from '@edium/fsm'; import { Task } from '../../domain/work-allocation/Task'; +import { ReadCookieService } from '../../services/cookie/read-cookie-service'; import { SessionStorageService } from '../../services/session/session-storage.service'; import { EventStartStateMachineContext } from './models/event-start-state-machine-context.model'; import { EventStartStateMachineService } from './services/event-start-state-machine.service'; @@ -18,7 +19,8 @@ export class EventStartComponent implements OnInit { constructor(private service: EventStartStateMachineService, private readonly router: Router, private readonly route: ActivatedRoute, - private readonly sessionStorageService: SessionStorageService) { + private readonly sessionStorageService: SessionStorageService, + private readonly cookieService: ReadCookieService) { } public ngOnInit(): void { @@ -36,7 +38,8 @@ export class EventStartComponent implements OnInit { taskId, router: this.router, route: this.route, - sessionStorageService: this.sessionStorageService + sessionStorageService: this.sessionStorageService, + cookieService: this.cookieService }; // Initialise state machine diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/models/event-start-state-machine-context.model.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/models/event-start-state-machine-context.model.ts index 0cfd149b0b..2470a68119 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/models/event-start-state-machine-context.model.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/models/event-start-state-machine-context.model.ts @@ -1,6 +1,6 @@ import { ActivatedRoute, Router } from '@angular/router'; import { Task } from '../../../domain/work-allocation/Task'; -import { SessionStorageService } from '../../../services'; +import { ReadCookieService, SessionStorageService } from '../../../services'; export interface EventStartStateMachineContext { tasks: Task[]; @@ -10,4 +10,5 @@ export interface EventStartStateMachineContext { router: Router; route: ActivatedRoute; sessionStorageService: SessionStorageService; + cookieService: ReadCookieService; } diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/services/event-start-state-machine.service.spec.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/services/event-start-state-machine.service.spec.ts index d0a6cdb145..d2ea4c7e81 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/services/event-start-state-machine.service.spec.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/services/event-start-state-machine.service.spec.ts @@ -3,7 +3,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { StateMachine } from '@edium/fsm'; import { Task } from '../../../domain/work-allocation/Task'; -import { SessionStorageService } from '../../../services'; +import { ReadCookieService, SessionStorageService } from '../../../services'; import { EventStartStateMachineContext, EventStartStates } from '../models'; import { EventStartStateMachineService } from './event-start-state-machine.service'; import createSpyObj = jasmine.createSpyObj; @@ -11,6 +11,7 @@ import createSpyObj = jasmine.createSpyObj; describe('EventStartStateMachineService', () => { let service: EventStartStateMachineService; let stateMachine: StateMachine; + let mockReadCookieService: any; let mockSessionStorageService: any; // tslint:disable-next-line: prefer-const let mockRoute: ActivatedRoute; @@ -109,6 +110,7 @@ describe('EventStartStateMachineService', () => { ]; mockSessionStorageService = createSpyObj('sessionStorageService', ['getItem', 'setItem']); + mockReadCookieService = createSpyObj('readCookieService', ['getCookie']); mockSessionStorageService.getItem.and.returnValue(`{"id": "test-user-id", "forename": "Test", "surname": "User", "roles": ["caseworker-role1", "caseworker-role3"], "email": "test@mail.com", "token": null}`); @@ -119,7 +121,8 @@ describe('EventStartStateMachineService', () => { taskId: '1122-3344-5566-7788', router: mockRouter, route: mockRoute, - sessionStorageService: mockSessionStorageService + sessionStorageService: mockSessionStorageService, + cookieService: mockReadCookieService }; beforeEach(async () => { diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/services/event-start-state-machine.service.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/services/event-start-state-machine.service.ts index 8ab746f4b4..5b95b4cf08 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/services/event-start-state-machine.service.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/services/event-start-state-machine.service.ts @@ -184,14 +184,18 @@ export class EventStartStateMachineService { task = context.tasks[0]; } - const taskStr= JSON.stringify(task); + const taskStr = JSON.stringify(task); console.log('entryActionForStateOneTaskAssignedToUser: setting client context task_data to ' + taskStr); // Store task to session + const currentLanguage = context.cookieService.getCookie('exui-preferred-language'); const clientContext = { client_context: { user_task: { task_data: task, complete_task: true + }, + user_language: { + language: currentLanguage } } }; diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/services/cookie/index.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/services/cookie/index.ts new file mode 100644 index 0000000000..af017e92dd --- /dev/null +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/services/cookie/index.ts @@ -0,0 +1 @@ +export * from './read-cookie-service'; \ No newline at end of file diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/services/cookie/read-cookie-service.spec.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/services/cookie/read-cookie-service.spec.ts new file mode 100644 index 0000000000..d68b07870c --- /dev/null +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/services/cookie/read-cookie-service.spec.ts @@ -0,0 +1,21 @@ +import { ReadCookieService } from "./read-cookie-service"; + +describe('CookieService', () => { + const mockDocument: any = { + cookie: '' + }; + + const cookieService: ReadCookieService = new ReadCookieService(mockDocument); + + afterEach(() => { + mockDocument.cookie = ''; + }); + + it('should get a cookie', () => { + + mockDocument.cookie = 'user=dummy'; + const result = cookieService.getCookie('user'); + expect(result).toBe('dummy'); + }); + +}); diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/services/cookie/read-cookie-service.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/services/cookie/read-cookie-service.ts new file mode 100644 index 0000000000..34739d5365 --- /dev/null +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/services/cookie/read-cookie-service.ts @@ -0,0 +1,21 @@ +import { DOCUMENT } from '@angular/common'; +import { Inject, Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class ReadCookieService { + private readonly document?: Document; + + constructor(@Inject(DOCUMENT) doc?: any) { + this.document = doc as Document; + } + + public getCookie(key: string): string { + const cookieValue = this.document.cookie + .split('; ') + .find(row => row.startsWith(`${key}=`)) + .split('=')[1]; + return cookieValue; + } +} diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/services/index.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/services/index.ts index f36a406324..060ab28f09 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/services/index.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/services/index.ts @@ -5,6 +5,7 @@ export * from './auth'; export * from './case-fields'; export * from './case-file-view'; export * from './case-flag'; +export * from './cookie'; export * from './document-management'; export * from './draft'; export * from './error'; diff --git a/sonar-project.properties b/sonar-project.properties index 9c0f09a1fd..2fd4084099 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -8,5 +8,4 @@ sonar.test.inclusions=projects/ccd-case-ui-toolkit/src/**/*.spec.ts sonar.exclusions=projects/ccd-case-ui-toolkit/src/*.spec.ts, projects/ccd-case-ui-toolkit/src/**/*.module.ts, projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/datetime-picker/datetime-picker-component.spec.ts, projects/ccd-case-ui-toolkit/src/lib/shared/test/mock-rpx-translate.pipe.ts, projects/ccd-case-ui-toolkit/src/test.ts, projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/case-flag/write-case-flag-field.component.ts, projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/datetime-picker/datetime-picker-component.ts, projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/complex/read-complex-field.component.ts, projects/ccd-case-ui-toolkit/src/lib/shared/commons/address-validation-constants.ts, projects/ccd-case-ui-toolkit/src/lib/shared/components/palette/markdown/markdown.component.ts sonar.javascript.lcov.reportPaths=/github/workspace/coverage/ccd-case-ui-toolkit/lcov-report/lcov.info -sonar.host.url= sonar.sourceEncoding=UTF-8 From 4d5c79d2ec5225d8ed9ddcb71fb742e9786aa726 Mon Sep 17 00:00:00 2001 From: connorpgpmcelroy <74015088+connorpgpmcelroy@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:26:58 +0000 Subject: [PATCH 06/11] Bug/ex UI 2624 user task missing (#1822) * Update event-start.guard.ts Fix regression issue that overwrites user_task * Change version * Update event-start.guard.ts Add 'en' even if no cookie Add language to existing client_context object, not just object with user_task * Add version * Update event-start.guard.spec.ts Add helpful test * update to rel name --------- Co-authored-by: Josh --- package.json | 2 +- projects/ccd-case-ui-toolkit/package.json | 2 +- .../event-guard/event-start.guard.spec.ts | 16 ++++++++- .../event-guard/event-start.guard.ts | 34 ++++++++++++++----- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 20f7e931d6..b7a086e188 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75-exui-2315", + "version": "7.0.75-user-task-missing-rel", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/package.json b/projects/ccd-case-ui-toolkit/package.json index 08fb6f6352..2c40161dea 100644 --- a/projects/ccd-case-ui-toolkit/package.json +++ b/projects/ccd-case-ui-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75-exui-2315", + "version": "7.0.75-user-task-missing-rel", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.spec.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.spec.ts index a5e546cfd1..8636750f2a 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.spec.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.spec.ts @@ -75,7 +75,21 @@ describe('EventStartGuard', () => { const result$ = guard.canActivate(route); result$.subscribe(result => { expect(result).toEqual(false); - // check client contesxt is set correctly + // check client context is set correctly + expect(sessionStorageService.setItem).toHaveBeenCalledWith('clientContext', JSON.stringify(mockClientContext)); + }); + }); + + it('client context should be set with language regardless if client context already exists', () => { + const mockClientContext: any = { client_context: { user_task: {}, additional_field: 'test' } }; + sessionStorageService.getItem.and.returnValues(null, null, JSON.stringify(mockClientContext)); + mockCookieService.getCookie.and.returnValue('cookieString'); + const route = createActivatedRouteSnapshot('caseId', 'eventId'); + const result$ = guard.canActivate(route); + mockClientContext.client_context.user_language = { language: 'cookieString' }; + result$.subscribe(result => { + expect(result).toEqual(false); + // check client context is set correctly expect(sessionStorageService.setItem).toHaveBeenCalledWith('clientContext', JSON.stringify(mockClientContext)); }); }); diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.ts b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.ts index 1d6a7e0471..2472f22c03 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.ts +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/event-start/event-guard/event-start.guard.ts @@ -31,16 +31,34 @@ export class EventStartGuard implements CanActivate { userId = userInfo.id ? userInfo.id : userInfo.uid; } const caseInfoStr = this.sessionStorageService.getItem('caseInfo'); - const currentLanguage = this.cookieService.getCookie('exui-preferred-language'); - // if one task assigned to user, allow user to complete event - const storeClientContext = { - client_context: { - user_language: { - language: currentLanguage + const languageCookie = this.cookieService.getCookie('exui-preferred-language'); + const currentLanguage = !!languageCookie && languageCookie !== '' ? languageCookie : 'en'; + const preClientContext = this.sessionStorageService.getItem(EventStartGuard.CLIENT_CONTEXT); + if (!preClientContext) { + // creates client context for language if not already existing + const storeClientContext = { + client_context: { + user_language: { + language: currentLanguage + } } + }; + this.sessionStorageService.setItem(EventStartGuard.CLIENT_CONTEXT, JSON.stringify(storeClientContext)); + } else { + const clientContextObj = JSON.parse(preClientContext); + if (!clientContextObj?.client_context?.user_language) { + const clientContextAddLanguage = { + ...clientContextObj, + client_context: { + ...clientContextObj.client_context, + user_language: { + language: currentLanguage + } + } + } + this.sessionStorageService.setItem(EventStartGuard.CLIENT_CONTEXT, JSON.stringify(clientContextAddLanguage)); } - }; - this.sessionStorageService.setItem(EventStartGuard.CLIENT_CONTEXT, JSON.stringify(storeClientContext)); + } if (caseInfoStr) { const caseInfo = JSON.parse(caseInfoStr); if (caseInfo && caseInfo.cid === caseId) { From f6b6afcbe45b9f969711d39767b71c1c8fd4a122 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 9 Dec 2024 11:32:42 +0000 Subject: [PATCH 07/11] yarn audit --- yarn-audit-known-issues | 1 + 1 file changed, 1 insertion(+) diff --git a/yarn-audit-known-issues b/yarn-audit-known-issues index 00840674be..a4304f848c 100644 --- a/yarn-audit-known-issues +++ b/yarn-audit-known-issues @@ -29,6 +29,7 @@ {"value":"osenv","children":{"ID":"osenv (deprecation)","Issue":"This package is no longer supported.","Severity":"moderate","Vulnerable Versions":"0.1.5","Tree Versions":["0.1.5"],"Dependents":["npm-package-arg@npm:6.1.1"]}} {"value":"path-to-regexp","children":{"ID":1099561,"Issue":"path-to-regexp outputs backtracking regular expressions","URL":"https://github.com/advisories/GHSA-9wv6-86v2-598j","Severity":"high","Vulnerable Versions":">=0.2.0 <1.9.0","Tree Versions":["1.8.0"],"Dependents":["express-urlrewrite@npm:1.4.0"]}} {"value":"path-to-regexp","children":{"ID":1099562,"Issue":"path-to-regexp outputs backtracking regular expressions","URL":"https://github.com/advisories/GHSA-9wv6-86v2-598j","Severity":"high","Vulnerable Versions":"<0.1.10","Tree Versions":["0.1.7"],"Dependents":["express@npm:4.19.2"]}} +{"value":"path-to-regexp","children":{"ID":1101081,"Issue":"Unpatched `path-to-regexp` ReDoS in 0.1.x","URL":"https://github.com/advisories/GHSA-rhx6-c78j-4q9w","Severity":"moderate","Vulnerable Versions":"<0.1.12","Tree Versions":["0.1.7"],"Dependents":["express@npm:4.19.2"]}} {"value":"prismjs","children":{"ID":1089189,"Issue":"prismjs Regular Expression Denial of Service vulnerability","URL":"https://github.com/advisories/GHSA-hqhp-5p83-hx96","Severity":"moderate","Vulnerable Versions":"<1.25.0","Tree Versions":["1.24.1"],"Dependents":["@hmcts/ccd-case-ui-toolkit@workspace:."]}} {"value":"prismjs","children":{"ID":1090424,"Issue":"Cross-site Scripting in Prism","URL":"https://github.com/advisories/GHSA-3949-f494-cm99","Severity":"high","Vulnerable Versions":">=1.14.0 <1.27.0","Tree Versions":["1.24.1"],"Dependents":["@hmcts/ccd-case-ui-toolkit@workspace:."]}} {"value":"request","children":{"ID":1096727,"Issue":"Server-Side Request Forgery in Request","URL":"https://github.com/advisories/GHSA-p8p7-x288-28g6","Severity":"moderate","Vulnerable Versions":"<=2.88.2","Tree Versions":["2.88.2"],"Dependents":["json-server@npm:0.15.1"]}} From 7024ab796cbca3395c28a63617779cbeed7695e1 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 9 Dec 2024 11:34:34 +0000 Subject: [PATCH 08/11] version name --- package.json | 2 +- projects/ccd-case-ui-toolkit/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b7a086e188..02b539bc9d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75-user-task-missing-rel", + "version": "7.0.75-user-task-missing-release", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/package.json b/projects/ccd-case-ui-toolkit/package.json index 2c40161dea..cfa465b988 100644 --- a/projects/ccd-case-ui-toolkit/package.json +++ b/projects/ccd-case-ui-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75-user-task-missing-rel", + "version": "7.0.75-user-task-missing-release", "engines": { "node": ">=18.19.0" }, From 7e86e9c85c99953d9aa851490fbe8840e5dc9264 Mon Sep 17 00:00:00 2001 From: StoeBenHMCTS Date: Mon, 9 Dec 2024 11:34:58 +0000 Subject: [PATCH 09/11] moves small change on to a new branch --- .../components/error-message/error-message.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/ccd-case-ui-toolkit/src/lib/shared/components/error-message/error-message.component.html b/projects/ccd-case-ui-toolkit/src/lib/shared/components/error-message/error-message.component.html index d8367428a9..d6cf1e37e2 100644 --- a/projects/ccd-case-ui-toolkit/src/lib/shared/components/error-message/error-message.component.html +++ b/projects/ccd-case-ui-toolkit/src/lib/shared/components/error-message/error-message.component.html @@ -5,7 +5,7 @@

{{error.title | From 5b1f118880befe8c094ce52cc9de314705d150be Mon Sep 17 00:00:00 2001 From: StoeBenHMCTS Date: Tue, 10 Dec 2024 09:04:43 +0000 Subject: [PATCH 10/11] updates version --- package.json | 2 +- projects/ccd-case-ui-toolkit/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 20f7e931d6..5a372352f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75-exui-2315", + "version": "7.0.76-accesible-error-links", "engines": { "node": ">=18.19.0" }, diff --git a/projects/ccd-case-ui-toolkit/package.json b/projects/ccd-case-ui-toolkit/package.json index 08fb6f6352..ccef3cd92d 100644 --- a/projects/ccd-case-ui-toolkit/package.json +++ b/projects/ccd-case-ui-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@hmcts/ccd-case-ui-toolkit", - "version": "7.0.75-exui-2315", + "version": "7.0.76-accesible-error-links", "engines": { "node": ">=18.19.0" }, From 7826d9103f7d2f0a5c13b8bf3fe80c1d3c15c97b Mon Sep 17 00:00:00 2001 From: StoeBenHMCTS Date: Fri, 3 Jan 2025 08:30:36 +0000 Subject: [PATCH 11/11] updates yarn audit file --- yarn-audit-known-issues | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-audit-known-issues b/yarn-audit-known-issues index 0791c5b5f0..21c8794522 100644 --- a/yarn-audit-known-issues +++ b/yarn-audit-known-issues @@ -28,7 +28,7 @@ {"value":"mermaid","children":{"ID":1100231,"Issue":"Prototype pollution vulnerability found in Mermaid's bundled version of DOMPurify","URL":"https://github.com/advisories/GHSA-m4gq-x24j-jpmf","Severity":"high","Vulnerable Versions":"<=10.9.2","Tree Versions":["10.9.1"],"Dependents":["ngx-markdown@virtual:6ff8c2a3aef81417d9f60600e3255d97c9c6c863d8733a87ed99d869392767523e0e28c07db1eb2a034bc9265813386132447698258584d621a7fd0e13d93585#npm:17.2.1"]}} {"value":"micromatch","children":{"ID":1098681,"Issue":"Regular Expression Denial of Service (ReDoS) in micromatch","URL":"https://github.com/advisories/GHSA-952p-6rrq-rcjv","Severity":"moderate","Vulnerable Versions":"<4.0.8","Tree Versions":["4.0.5"],"Dependents":["fast-glob@npm:3.3.2"]}} {"value":"move-concurrently","children":{"ID":"move-concurrently (deprecation)","Issue":"This package is no longer supported.","Severity":"moderate","Vulnerable Versions":"1.0.1","Tree Versions":["1.0.1"],"Dependents":["cacache@npm:12.0.4"]}} -{"value":"nanoid","children":{"ID":1101092,"Issue":"Infinite loop in nanoid","URL":"https://github.com/advisories/GHSA-mwcw-c2x4-8c55","Severity":"low","Vulnerable Versions":"<3.3.8","Tree Versions":["2.1.11"],"Dependents":["json-server@npm:0.15.1"]}} +{"value":"nanoid","children":{"ID":1101163,"Issue":"Predictable results in nanoid generation when given non-integer values","URL":"https://github.com/advisories/GHSA-mwcw-c2x4-8c55","Severity":"moderate","Vulnerable Versions":"<3.3.8","Tree Versions":["2.1.11"],"Dependents":["json-server@npm:0.15.1"]}} {"value":"node-fetch-npm","children":{"ID":"node-fetch-npm (deprecation)","Issue":"This module is not used anymore, npm uses minipass-fetch for its fetch implementation now","Severity":"moderate","Vulnerable Versions":"2.0.4","Tree Versions":["2.0.4"],"Dependents":["make-fetch-happen@npm:5.0.2"]}} {"value":"npmlog","children":{"ID":"npmlog (deprecation)","Issue":"This package is no longer supported.","Severity":"moderate","Vulnerable Versions":"6.0.2","Tree Versions":["6.0.2"],"Dependents":["node-gyp@npm:9.4.0"]}} {"value":"osenv","children":{"ID":"osenv (deprecation)","Issue":"This package is no longer supported.","Severity":"moderate","Vulnerable Versions":"0.1.5","Tree Versions":["0.1.5"],"Dependents":["npm-package-arg@npm:6.1.1"]}}