Skip to content

Commit

Permalink
Merge pull request #1513 from hmcts/feature/EUI-8608-QM-follow-up-on-…
Browse files Browse the repository at this point in the history
…the-query-tab

EUI-8608 QM follow up on the query tab
  • Loading branch information
johnbenjamin-hmcts authored Nov 27, 2023
2 parents efd59a4 + 0c513fe commit 6029336
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 13 deletions.
3 changes: 3 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## RELEASE NOTES
### Version 6.16.0-follow-up-on-query-tab-v2
**EUI-8608** Query management follow up on the query tab

### Version 6.16.0-query-management-navigate-back-to-query-list
**EUI-8693** Query management navigate back to query list from query details

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
</ng-container>

<ng-template #followUpMessage>
<div class="query_details_caption">{{ 'Follow-up' | rpxTranslate }}</div>
<table class="govuk-table query-details-table"
[attr.aria-describedby]="'Follow-up of the response' | rpxTranslate">
<caption class="govuk-table__caption govuk-table__caption--l">
Expand All @@ -103,10 +104,21 @@
<td class="govuk-table__cell">{{ child.name }}</td>
</tr>

<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header">{{ 'Query detail' | rpxTranslate }}</th>
<td class="govuk-table__cell">{{ child.body }}</td>
</tr>
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header">{{ 'Query detail' | rpxTranslate }}</th>
<td class="govuk-table__cell">{{ child.body }}</td>
</tr>

<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header">{{ 'Attachments' | rpxTranslate }}</th>
<td class="govuk-table__cell">
<ccd-query-attachments-read
*ngIf="child.attachments"
[attachments]="child.attachments"
>
</ccd-query-attachments-read>
</td>
</tr>
</tbody>
</table>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,126 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { SessionStorageService } from '../../../../../services';
import { MockRpxTranslatePipe } from '../../../../../test/mock-rpx-translate.pipe';
import { QueryListItem } from '../../models';
import { QueryDetailsComponent } from './query-details.component';

describe('QueryDetailsComponent', () => {
let component: QueryDetailsComponent;
let fixture: ComponentFixture<QueryDetailsComponent>;
const mockSessionStorageService = jasmine.createSpyObj<SessionStorageService>('SessionStorageService', ['getItem']);

const items = [
{
id: '222-222',
subject: '',
name: 'Name 2',
body: 'Body 2',
attachments: [],
isHearingRelated: false,
hearingDate: '',
createdOn: new Date('2021-02-01'),
createdBy: 'Person A',
parentId: '111-111',
children: []
},
{
id: '333-333',
subject: '',
name: 'Name 3',
body: 'Body 3',
attachments: [],
isHearingRelated: false,
hearingDate: '',
createdOn: new Date('2021-03-01'),
createdBy: 'Person B',
parentId: '111-111',
children: []
},
{
id: '444-444',
subject: '',
name: 'Name 4',
body: 'Body 4',
attachments: [],
isHearingRelated: false,
hearingDate: '',
createdOn: new Date('2020-03-01'),
createdBy: 'Person C',
parentId: '222-222'
},
// lastSubmittedBy
{
id: '555-555',
subject: '',
name: 'Name 5',
body: 'Body 5',
attachments: [],
isHearingRelated: false,
hearingDate: '',
createdOn: new Date('2023-06-01'),
createdBy: 'Person D',
parentId: '444-444',
}
];

const childrenItems = items.map(item => {
const listItem = new QueryListItem();
Object.assign(listItem, item);
return listItem;
});

const queryListItem = new QueryListItem();
Object.assign(queryListItem, {
id: '111-111',
subject: 'Subject 1',
name: 'Name 1',
body: 'Body 1',
attachments: [
{
_links: {
self: {
href: 'https://hmcts.internal/documents/111-111'
},
binary: {
href: 'https://hmcts.internal/documents/111-111/binary'
}
},
originalDocumentName: 'Document 1'
}
],
isHearingRelated: true,
hearingDate: new Date('2023-06-29'),
createdOn: new Date('2023-06-25'),
createdBy: 'Person A',
children: [
childrenItems[0],
childrenItems[1],
{
...childrenItems[2],
children: [
// lastSubmittedBy
childrenItems[3]
]
}
]
});

const USER = {
roles: [
'caseworker'
]
};

beforeEach(async () => {
mockSessionStorageService.getItem.and.returnValue(JSON.stringify(USER));
await TestBed.configureTestingModule({
declarations: [ QueryDetailsComponent ],
declarations: [
QueryDetailsComponent,
MockRpxTranslatePipe
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [ {provide: SessionStorageService, useValue: mockSessionStorageService } ]
})
.compileComponents();
Expand All @@ -18,6 +129,7 @@ describe('QueryDetailsComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(QueryDetailsComponent);
component = fixture.componentInstance;
component.query = queryListItem;
fixture.detectChanges();
});

Expand All @@ -31,13 +143,25 @@ describe('QueryDetailsComponent', () => {
expect(component.backClicked.emit).toHaveBeenCalled();
});

describe('isCaseworker', () => {
const USER = {
roles: [
'caseworker'
]
};
it('should verify table column names for response', () => {
const tables = fixture.debugElement.queryAll(By.css('.query-details-table'));
const columnHeaders = tables[1].queryAll(By.css('.govuk-table__header'));
expect(columnHeaders[0].nativeElement.textContent.trim()).toEqual('Last response date');
expect(columnHeaders[1].nativeElement.textContent.trim()).toEqual('Caseworker name');
expect(columnHeaders[2].nativeElement.textContent.trim()).toEqual('Response detail');
expect(columnHeaders[3].nativeElement.textContent.trim()).toEqual('Attachments');
});

it('should verify table column names for follow-up', () => {
const tables = fixture.debugElement.queryAll(By.css('.query-details-table'));
const columnHeaders = tables[2].queryAll(By.css('.govuk-table__header'));
expect(columnHeaders[0].nativeElement.textContent.trim()).toEqual('Last submission date');
expect(columnHeaders[1].nativeElement.textContent.trim()).toEqual('Last submitted by');
expect(columnHeaders[2].nativeElement.textContent.trim()).toEqual('Query detail');
expect(columnHeaders[3].nativeElement.textContent.trim()).toEqual('Attachments');
});

describe('isCaseworker', () => {
it('should return true if the user doesnt have pui-case-manager', () => {
mockSessionStorageService.getItem.and.returnValue(JSON.stringify(USER));
fixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export class QueryDetailsComponent {
@Output() public backClicked: EventEmitter<boolean> = new EventEmitter();
@Input() public caseId: string;

constructor(private sessionStorage: SessionStorageService) { }
constructor(private sessionStorageService: SessionStorageService) { }

public onBack(): void {
this.backClicked.emit(true);
}

public isCaseworker(): boolean {
const userDetails = JSON.parse(this.sessionStorage.getItem('userDetails'));
const userDetails = JSON.parse(this.sessionStorageService.getItem('userDetails'));
return userDetails && userDetails.roles
&& !(userDetails.roles.includes('pui-case-manager')
|| userDetails.roles.some((role) => role.toLowerCase().includes('judge')));
Expand Down

0 comments on commit 6029336

Please sign in to comment.