Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXUI-2104 - Event History Summary #1775

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.67",
"version": "7.0.67-external-link-history",
"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.67",
"version": "7.0.67-external-link-history",
"engines": {
"node": ">=18.19.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
<div *ngSwitchCase="false">
<a [routerLink]="['./', 'event', event.id, 'history']"
[target]="'_blank'"
*ngIf="event.state_id !== 'Draft'" class="text-16 event-link" attr.aria-label="{{getAriaLabelforLink(event)}}">{{event.event_name | rpxTranslate}}</a>
*ngIf="event.state_id !== 'Draft' && !isUserExternal" class="text-16 event-link" attr.aria-label="{{getAriaLabelforLink(event)}}">{{event.event_name | rpxTranslate}}</a>
<span *ngIf="isUserExternal" class="text-16 event-link" attr.aria-label="{{getAriaLabelforLink(event)}}">{{event.event_name | rpxTranslate}}</span>
</div>
</ng-container>
<span *ngIf="event.state_id === 'Draft'">{{event.event_name}}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import { MockRpxTranslatePipe } from '../../../../test/mock-rpx-translate.pipe';
import { DatePipe } from '../../utils';
import { EventLogTableComponent } from './event-log-table.component';
import createSpyObj = jasmine.createSpyObj;
import { SessionStorageService } from '../../../../services';

describe('EventLogTableComponent', () => {
const mockSessionStorageService = jasmine.createSpyObj<SessionStorageService>('SessionStorageService', ['getItem']);

const EVENTS: CaseViewEvent[] = [
{
Expand Down Expand Up @@ -57,6 +59,13 @@ describe('EventLogTableComponent', () => {
const $TABLE_ROW_LINKS_TIMELINE = By.css('table>tbody>tr>td>div#case-timeline>a');
const $TABLE_ROW_LINKS_STANDALONE = By.css('table>tbody>tr>td>div:not(.tooltip)>a');
const $TABLE_COLUMNS = By.css('table>tbody>tr>td');
const $TABLE_ROW_LINKS_TIMELINE_EXTERNAL = By.css('table>tbody>tr>td>div>span.event-link');

const USER = {
Josh-HMCTS marked this conversation as resolved.
Show resolved Hide resolved
roles: [
'caseworker'
]
};

const COL_EVENT = 0;
const COL_DATE = 1;
Expand All @@ -76,12 +85,15 @@ describe('EventLogTableComponent', () => {
DatePipe,
MockRpxTranslatePipe
],
providers: [FormatTranslatorService]
providers: [FormatTranslatorService,
{ provide: SessionStorageService, useValue: mockSessionStorageService }
]
})
.compileComponents();

fixture = TestBed.createComponent(EventLogTableComponent);
component = fixture.componentInstance;
mockSessionStorageService.getItem.and.returnValue(JSON.stringify(USER));

component.events = EVENTS;
component.selected = SELECTED_EVENT;
Expand Down Expand Up @@ -199,10 +211,8 @@ describe('EventLogTableComponent', () => {
});

describe('Case timeline use', () => {

let caseHistoryHandler;
beforeEach(waitForAsync(() => {

caseHistoryHandler = createSpyObj('caseHistoryHandler', ['apply']);

TestBed
Expand All @@ -213,12 +223,16 @@ describe('EventLogTableComponent', () => {
DatePipe,
MockRpxTranslatePipe
],
providers: [FormatTranslatorService]
providers: [FormatTranslatorService,
{ provide: SessionStorageService, useValue: mockSessionStorageService }

]
})
.compileComponents();

fixture = TestBed.createComponent(EventLogTableComponent);
component = fixture.componentInstance;
mockSessionStorageService.getItem.and.returnValue(JSON.stringify(USER));

component.events = EVENTS;
component.selected = SELECTED_EVENT;
Expand All @@ -238,4 +252,48 @@ describe('EventLogTableComponent', () => {
expect(caseHistoryHandler.apply).toHaveBeenCalledWith(4);
});
});

describe('External user', () => {
beforeEach(waitForAsync(() => {
TestBed
.configureTestingModule({
imports: [RouterTestingModule],
declarations: [
EventLogTableComponent,
DatePipe,
MockRpxTranslatePipe
],
providers: [FormatTranslatorService,
{ provide: SessionStorageService, useValue: mockSessionStorageService }
]
})
.compileComponents();

fixture = TestBed.createComponent(EventLogTableComponent);
component = fixture.componentInstance;
const EXTERNAL_USER = {
roles: [
'pui-case-manager'
]
};
mockSessionStorageService.getItem.and.returnValue(JSON.stringify(EXTERNAL_USER));

component.events = EVENTS;
component.selected = SELECTED_EVENT;
component.isPartOfCaseTimeline = false;

de = fixture.debugElement;
fixture.detectChanges();
}));

it('should not render hyperlink for each row and link to event id', () => {
const links = de.queryAll($TABLE_ROW_LINKS_TIMELINE_EXTERNAL);
expect(component.isUserExternal).toBeTruthy();
expect(links.length).toBe(2);
expect(links[0].nativeElement.getAttribute('href')).toBeNull();
expect(links[1].nativeElement.getAttribute('href')).toBeNull();
expect(links[0].nativeElement.textContent).toContain('Update a case');
expect(links[1].nativeElement.textContent).toContain('Update a case');
});
});
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { formatDate } from '@angular/common';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { CaseViewEvent } from '../../../../domain';
import { SessionStorageService } from '../../../../services';

@Component({
selector: 'ccd-event-log-table',
templateUrl: './event-log-table.component.html',
styleUrls: ['./event-log-table.scss']
})
export class EventLogTableComponent implements OnInit {

@Input()
public events: CaseViewEvent[];

Expand All @@ -23,8 +23,15 @@ export class EventLogTableComponent implements OnInit {

public isPartOfCaseTimeline = false;

public isUserExternal: boolean;

constructor(
private sessionStorage: SessionStorageService
){}

public ngOnInit(): void {
this.isPartOfCaseTimeline = this.onCaseHistory.observers.length > 0;
this.isUserExternal = JSON.parse(this.sessionStorage.getItem('userDetails')).roles.includes('pui-case-manager');
}

public select(event: CaseViewEvent): void {
Expand Down
Loading