Skip to content

Commit

Permalink
EUI-8608 QM follow up on the query tab
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbenjamin-hmcts committed Nov 27, 2023
1 parent 3ac2fa6 commit 2f6539a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { MockRpxTranslatePipe } from 'projects/ccd-case-ui-toolkit/src/lib/shared/test/mock-rpx-translate.pipe';
import { SessionStorageService } from '../../../../../services';
import { MockRpxTranslatePipe } from '../../../../../test/mock-rpx-translate.pipe';
import { QueryListItem } from '../../models';
import { QueryDetailsComponent } from './query-details.component';

Expand Down Expand Up @@ -106,12 +107,20 @@ describe('QueryDetailsComponent', () => {
]
});

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

beforeEach(async () => {
mockSessionStorageService.getItem.and.returnValue(JSON.stringify(USER));
await TestBed.configureTestingModule({
declarations: [
QueryDetailsComponent,
MockRpxTranslatePipe
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [ {provide: SessionStorageService, useValue: mockSessionStorageService } ]
})
.compileComponents();
Expand All @@ -136,28 +145,23 @@ describe('QueryDetailsComponent', () => {

it('should verify table column names for response', () => {
const tables = fixture.debugElement.queryAll(By.css('.query-details-table'));
const columnHeaders = tables[0].queryAll(By.css('.govuk-table__header'));
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('Response detail');
expect(columnHeaders[2].nativeElement.textContent.trim()).toEqual('Attachments');
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[1].queryAll(By.css('.govuk-table__header'));
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', () => {
const USER = {
roles: [
'caseworker'
]
};

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 2f6539a

Please sign in to comment.