Skip to content

Commit

Permalink
EXUI-1735 - Case hyperlink for case consolidated (#1729)
Browse files Browse the repository at this point in the history
* Add case consolidated link to 'linked from' table

* Change version name for pre-release

* Add unit tests for new function
  • Loading branch information
Josh-HMCTS authored Jun 25, 2024
1 parent 4b1bec9 commit d58c6ae
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "7.0.41",
"version": "7.0.42",
"engines": {
"node": ">=18.19.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.0.41",
"version": "7.0.42",
"engines": {
"node": ">=18.19.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
<td class="case-table-column"><span [title]="case.stateDescription">{{case.state}}</span></td>
<td class="case-table-column" *ngFor="let details of case.linkDetails">
<span *ngFor="let reason of details.reasons; let i = index; let isLast = last">
{{reason | ccdLinkCasesFromReasonValue}} <br>
{{reason | ccdLinkCasesFromReasonValue}}<span><a class="govuk-!-padding-left-1"
href="cases/case-details/{{ case.caseReference }}"
*ngIf="hasLeadCaseOrConsolidated(reason.reasonCode)">{{getCaseReferenceLink(case.caseReference)}}</a></span>
<br *ngIf="!isLast" />
</span>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,29 @@ describe('LinkCasesFromTableComponent', () => {
document.getElementsByClassName('govuk-table__cell')[0].textContent.trim()
).toEqual('None');
});

it('should return the last 4 digits of the case reference', () => {
component.caseId = '1234567890123456';
const caseRef = '1234567890123456';
const result = component.getCaseReferenceLink(caseRef);
expect(result).toEqual('3456');
});

it('should return true for CASE_PROGRESS_REASON_CODE', () => {
const reasonCode = 'CLRC016';
const result = component.hasLeadCaseOrConsolidated(reasonCode);
expect(result).toBeTruthy();
});

it('should return true for CASE_CONSOLIDATED_REASON_CODE', () => {
const reasonCode = 'CLRC015';
const result = component.hasLeadCaseOrConsolidated(reasonCode);
expect(result).toBeTruthy();
});

it('should return false for any other reason code', () => {
const reasonCode = 'OTHER_CODE';
const result = component.hasLeadCaseOrConsolidated(reasonCode);
expect(result).toBeFalsy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { LinkedCasesService } from '../../services';

export class LinkedCasesFromTableComponent implements OnInit, AfterViewInit {
private static readonly CASE_NAME_MISSING_TEXT = 'Case name missing';
private static readonly CASE_CONSOLIDATED_REASON_CODE = 'CLRC015';
private static readonly CASE_PROGRESS_REASON_CODE = 'CLRC016';

@Input()
public caseField: CaseField;
Expand Down Expand Up @@ -95,6 +97,15 @@ export class LinkedCasesFromTableComponent implements OnInit, AfterViewInit {
return this.linkedCasesService.mapLookupIDToValueFromJurisdictions(fieldName, fieldValue);
}

public getCaseReferenceLink(caseRef: string): string {
return caseRef.slice(this.caseId.length - 4);
}

public hasLeadCaseOrConsolidated(reasonCode: string): boolean {
return reasonCode === LinkedCasesFromTableComponent.CASE_PROGRESS_REASON_CODE ||
reasonCode === LinkedCasesFromTableComponent.CASE_CONSOLIDATED_REASON_CODE;
}

public onClick(): void {
this.showHideLinkText = this.showHideLinkText === 'Show'
? 'Hide'
Expand Down

0 comments on commit d58c6ae

Please sign in to comment.