Skip to content

Commit

Permalink
Merge branch 'feature/query-management' of github.com:hmcts/ccd-case-…
Browse files Browse the repository at this point in the history
…ui-toolkit into feature/query-management
  • Loading branch information
olusegz07 committed Dec 3, 2024
2 parents 4dadc42 + a39024e commit d569e43
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 9 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.1.15-fix-event-hiding",
"version": "7.1.16-response-status",
"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.1.15-fix-event-hiding",
"version": "7.1.16-response-status",
"engines": {
"node": ">=18.19.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('QualifyingQuestionOptionsComponent', () => {

it('should have the link to case details queries tab', () => {
component.click();
expect(router.navigate).toHaveBeenCalledWith(['cases', 'case-details', '12345'], { fragment: 'Query Management' });
expect(router.navigate).toHaveBeenCalledWith(['cases', 'case-details', '12345'], { fragment: 'Queries' });
});

describe('displayError', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class QualifyingQuestionOptionsComponent implements OnInit {
}

public click(): void {
this.router.navigate(['cases', 'case-details', this.caseId], { fragment: 'Query Management' });
this.router.navigate(['cases', 'case-details', this.caseId], { fragment: 'Queries' });
}

public get displayError(): boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export enum QueryItemResponseStatus {
NEW = 'New',
RESPONDED = 'Responded'
RESPONDED = 'Responded',
Awaiting = 'Awaiting Response'
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ describe('QueryListItem', () => {
hearingDate: '',
createdOn: new Date('2023-06-01'),
createdBy: 'Person D',
parentId: '444-444',
parentId: '444-444'
}
];

const childrenItems = items.map(item => {
const childrenItems = items.map((item) => {
const listItem = new QueryListItem();
Object.assign(listItem, item);
return listItem;
Expand Down Expand Up @@ -163,7 +163,37 @@ describe('QueryListItem', () => {
it('should return "No response required" when it has no children', () => {
queryListItem.children = [];
expect(queryListItem.children).toEqual([]);
expect(queryListItem.responseStatus).toEqual(QueryItemResponseStatus.NEW);
expect(queryListItem.responseStatus).toEqual(QueryItemResponseStatus.Awaiting);
});

it('should return "Awaiting Response" when it has children and is for Follow up question', () => {
// Create additional child items
const additionalChildren = [
new QueryListItem(),
new QueryListItem(),
new QueryListItem(),
new QueryListItem()
].map((child, index) => {
Object.assign(child, {
id: `child-${index + 1}`,
subject: `Subject ${index + 2}`,
name: `Name ${index + 2}`,
body: `Body ${index + 2}`,
attachments: [],
isHearingRelated: false,
hearingDate: '',
createdOn: new Date(`2021-0${index + 2}-01`),
createdBy: `Person ${String.fromCharCode(65 + index + 1)}`,
parentId: queryListItem.id,
children: []
});
return child;
});

// Assign these new children to queryListItem
queryListItem.children = additionalChildren;
expect(queryListItem.children.length).toEqual(4);
expect(queryListItem.responseStatus).toEqual(QueryItemResponseStatus.Awaiting);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export class QueryListItem implements CaseMessage {
}

public get responseStatus(): QueryItemResponseStatus {
return this.children?.length > 0 ? QueryItemResponseStatus.RESPONDED : QueryItemResponseStatus.NEW;
if (this.children?.length > 0) {
return this.children.length % 2 === 1
? QueryItemResponseStatus.RESPONDED
: QueryItemResponseStatus.Awaiting;
}
return QueryItemResponseStatus.Awaiting;
}
}

0 comments on commit d569e43

Please sign in to comment.