Skip to content

Commit

Permalink
add test for external user not being shown hyperlink
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-HMCTS committed Oct 7, 2024
1 parent 8bbe150 commit fea03cc
Showing 1 changed file with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ 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 = {
roles: [
Expand Down Expand Up @@ -210,10 +211,8 @@ describe('EventLogTableComponent', () => {
});

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

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

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

TestBed
Expand Down Expand Up @@ -253,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');
});
});
});

0 comments on commit fea03cc

Please sign in to comment.