Skip to content

Commit

Permalink
Merge branch 'master' into exui-2526-adding-extra-query-option
Browse files Browse the repository at this point in the history
  • Loading branch information
olusegz07 committed Jan 9, 2025
2 parents 205f020 + 94b21b2 commit e976ba9
Show file tree
Hide file tree
Showing 30 changed files with 592 additions and 327 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- run: corepack enable && yarn --version
Expand All @@ -32,7 +32,7 @@ jobs:
- name: Change Report Path
run: sed -i 's+/home/runner/work/ccd-case-ui-toolkit/ccd-case-ui-toolkit+/github/workspace+g' coverage/ccd-case-ui-toolkit/lcov.info
- name: Archive code coverage results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: coverage
Expand All @@ -43,23 +43,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Download code coverage results
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: code-coverage-report
path: coverage
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@v3.0.0
uses: sonarsource/sonarcloud-github-action@v4.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Send slack
if: failure()
uses: sonots/slack-notice-action@v3
uses: sonots/slack-notice-action@v3.2.0
with:
status: ${{ job.status }}
env:
Expand All @@ -71,8 +71,8 @@ jobs:
needs: sonarcloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/
Expand All @@ -89,8 +89,8 @@ jobs:
needs: sonarcloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://npm.pkg.github.com/
Expand Down
24 changes: 23 additions & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
## RELEASE NOTES
## RELEASE NOTES

### Version 7.1.25
**EXUI-1951** etrieve current user language selection

### Version 7.1.24
Taken by PR

### Version 7.0.75-exui-2575
**EXUI-2536** issue with DynamicMultiSelectList
**EXUI-2431** Special characters stopping events
**EXUI-2537** upgrade pdf-dist in media viewer
**EXUI-2389** PED and Media Viewer

### Version 7.0.75-exui-2315
**EXUI-2315** etrieve current user language selection


### 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

### Version 7.0.75
**EXUI-2415** Redirect to an new event by a hyperlink
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "7.1.18-extra-query-options",
"version": "7.1.32-extra-query-options",
"engines": {
"node": ">=18.19.0"
},
Expand Down Expand Up @@ -64,7 +64,7 @@
"@edium/fsm": "^2.1.2",
"@hmcts/ccpay-web-component": "6.2.1",
"@hmcts/frontend": "0.0.50-alpha",
"@hmcts/media-viewer": "4.0.8",
"@hmcts/media-viewer": "4.0.9",
"@ngrx/effects": "17.2.0",
"@ngrx/store": "^17.2.0",
"@nicky-lenaers/ngx-scroll-to": "^14.0.0",
Expand Down
2 changes: 1 addition & 1 deletion projects/ccd-case-ui-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "7.1.18-extra-query-options",
"version": "7.1.32-extra-query-options",
"engines": {
"node": ">=18.19.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h2 class="heading-h2">{{pageTitle | rpxTranslate }}</h2>
<th *ngIf="!isLabel(field) && !caseEdit.isCaseFlagSubmission" class="valign-top case-field-label">
<span class="text-16">{{field.label | rpxTranslate}}</span>
</th>
<td class="form-cell case-field-content" [attr.colspan]="isLabel(field) ? '2' : '1'">
<td class="form-cell case-field-content text-16" [attr.colspan]="isLabel(field) ? '2' : '1'">
<ccd-field-read
[formGroup]="editForm.controls['data']" [topLevelFormGroup]="editForm.controls['data']"
[caseField]="summaryCaseField(field)" [context]="paletteContext" [caseFields]="contextFields"></ccd-field-read>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { CaseEditUtils, convertNonASCIICharacter } from "./case-edit.utils";

describe('CaseEditUtils', () => {
const caseUtils: CaseEditUtils = new CaseEditUtils();
const LONG_ASCII_STRING = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@£$%^&*()-=[];\,./`<>?:"|{}_+';
const LONG_PRE_STRING: string = 'Examples of non-ASCII characters: éこ¥🌍';
const LONG_POST_STRING: string = 'Examples of non-ASCII characters: &#233;&#12371;&#165;&#55356;&#57101;';

describe('editNonASCIICharacters', () => {

it('should not edit undefined', () => {
// Note: Should never happen
const response = caseUtils.convertNonASCIICharacters(undefined);
expect(response).toEqual('');
});

it('should not edit an empty string', () => {
const mockString = '';
const response = caseUtils.convertNonASCIICharacters(mockString);
expect(response).toEqual(mockString);
});

it('should note edit ASCII characters', () => {
// note: string includes £ (non-ASCII) which should not be edited
const response = caseUtils.convertNonASCIICharacters(LONG_ASCII_STRING);
expect(response).toEqual(LONG_ASCII_STRING);
});

it('should not edit £ (non ASCII)', () => {
const mockString = 'Cost: £2.50';
const response = caseUtils.convertNonASCIICharacters(mockString);
expect(response).toEqual(mockString);
});

it('should edit ASCII characters', () => {
// Summarises with copied mock string
const response = caseUtils.convertNonASCIICharacters(LONG_PRE_STRING);
expect(response).toEqual(LONG_POST_STRING);

// Goes deeper into what should be happening just in case
const chineseCharacter = '漢';
const secondMockString = 'Examples of non-ASCII characters: ' + chineseCharacter;
const editedSecondMockString =
`Examples of non-ASCII characters: ${CaseEditUtils.PREFIX + chineseCharacter.charCodeAt(0) + CaseEditUtils.SUFFIX}`;
const secondResponse = caseUtils.convertNonASCIICharacters(secondMockString);
expect(secondResponse).toEqual(editedSecondMockString);
});
});

describe('revertEditNonASCIICharacters', () => {

it('should not revert strings without the prefix and/or suffix', () => {
const mockString = 'Hello World!';
const response = caseUtils.convertHTMLEntities(mockString);
expect(response).toEqual(mockString);
});

it('should revert relevant strings', () => {
const response = caseUtils.convertHTMLEntities(LONG_POST_STRING);
expect(response).toEqual(LONG_PRE_STRING);
});
});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

export function convertNonASCIICharacter(character: string): string {
if (character === '£') {
// pound sign will be frequently used and works for btoa despite being non-ASCII
// note: this could be done for other characters provided they work for btoa()
return character;
}
// Note: Will convert to HTML entity
return CaseEditUtils.PREFIX + character.charCodeAt(0) + CaseEditUtils.SUFFIX;
}

export class CaseEditUtils {

public static readonly PREFIX = '&#';
public static readonly SUFFIX = ';';

public convertNonASCIICharacters(rawString: string): string {
return rawString ? rawString.replace(/[^\x20-\x7E]/g, function (c) {
return convertNonASCIICharacter(c);
}) : '';
}

public convertHTMLEntities(editedString: string): string {
const revertedCharacterList = editedString.split(CaseEditUtils.PREFIX);
let rawString = revertedCharacterList[0];
for (let index = 1; index < revertedCharacterList.length; index++) {
const currentSection = revertedCharacterList[index];
if (!currentSection.includes(CaseEditUtils.SUFFIX)) {
return rawString.concat(currentSection);
} else {
const suffixSplitList = currentSection.split(CaseEditUtils.SUFFIX);
const characterCode = Number(suffixSplitList[0]);
rawString = rawString.concat(String.fromCharCode(characterCode), suffixSplitList[1]);
}
}
return rawString;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { LinkedCasesResponse } from '../../palette/linked-cases/domain/linked-ca
import { CaseAccessUtils } from '../case-access-utils';
import { WizardPage } from '../domain';
import { WizardPageFieldToCaseFieldMapper } from './wizard-page-field-to-case-field.mapper';
import { CaseEditUtils } from '../case-edit-utils/case-edit.utils';

@Injectable()
export class CasesService {
Expand Down Expand Up @@ -396,8 +397,10 @@ export class CasesService {
private addClientContextHeader(headers: HttpHeaders): HttpHeaders {
const clientContextDetails = this.sessionStorageService.getItem('clientContext');
if (clientContextDetails) {
// may require URI encoding in certain circumstances
const clientContext = window.btoa(clientContextDetails);
const caseEditUtils = new CaseEditUtils();
// below changes non-ASCII characters
const editedClientContext = caseEditUtils.convertNonASCIICharacters(clientContextDetails);
const clientContext = window.btoa(editedClientContext);
if (clientContext) {
headers = headers.set('Client-Context', clientContext);
}
Expand All @@ -406,59 +409,13 @@ 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 caseEditUtils = new CaseEditUtils();
const clientContextString = window.atob(headers.get('Client-Context'));
this.sessionStorageService.setItem('clientContext', clientContextString);
// below reverts non-ASCII characters
const editedClientContextString = caseEditUtils.convertHTMLEntities(clientContextString);
this.sessionStorageService.setItem('clientContext', editedClientContextString);
}
}

// 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;
} */
}
Loading

0 comments on commit e976ba9

Please sign in to comment.