[DURACOM-133] Do not show edit/delete button

for observer
This commit is contained in:
Alisa Ismailati
2023-04-27 15:58:37 +02:00
parent 4847fc6f7a
commit 8ec5d11fcc
3 changed files with 143 additions and 12 deletions

View File

@@ -1,3 +1,4 @@
import { EPerson } from './../../../core/eperson/models/eperson.model';
import { ChangeDetectionStrategy, Injector, NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { Router } from '@angular/router';
@@ -24,12 +25,16 @@ import { RequestService } from '../../../core/data/request.service';
import { getMockRequestService } from '../../mocks/request.service.mock';
import { getMockSearchService } from '../../mocks/search-service.mock';
import { SearchService } from '../../../core/shared/search/search.service';
import { AuthService } from '../../../core/auth/auth.service';
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
let component: WorkspaceitemActionsComponent;
let fixture: ComponentFixture<WorkspaceitemActionsComponent>;
let mockObject: WorkspaceItem;
let notificationsServiceStub: NotificationsServiceStub;
let authorizationService;
let authService;
const mockDataService = jasmine.createSpyObj('WorkspaceitemDataService', {
delete: jasmine.createSpy('delete')
@@ -71,10 +76,88 @@ const item = Object.assign(new Item(), {
const rd = createSuccessfulRemoteDataObject(item);
mockObject = Object.assign(new WorkspaceItem(), { item: observableOf(rd), id: '1234', uuid: '1234' });
describe('WorkspaceitemActionsComponent', () => {
beforeEach(waitForAsync(() => {
const ePersonMock: EPerson = Object.assign(new EPerson(), {
handle: null,
netid: null,
lastActive: '2023-04-27T12:15:57.054+00:00',
canLogIn: true,
email: 'dspacedemo+submit@gmail.com',
requireCertificate: false,
selfRegistered: false,
_name: 'dspacedemo+submit@gmail.com',
id: '914955b1-cf2e-4884-8af7-a166aa24cf73',
uuid: '914955b1-cf2e-4884-8af7-a166aa24cf73',
type: 'eperson',
metadata: {
'dspace.agreements.cookies': [
{
uuid: '0a53a0f2-e168-4ed9-b4af-cba9a2d267ca',
language: null,
value:
'{"authentication":true,"preferences":true,"acknowledgement":true,"google-analytics":true}',
place: 0,
authority: null,
confidence: -1,
},
],
'dspace.agreements.end-user': [
{
uuid: '0879e571-6e4a-4efe-af9b-704c755166be',
language: null,
value: 'true',
place: 0,
authority: null,
confidence: -1,
},
],
'eperson.firstname': [
{
uuid: '18052a3e-f19b-49ca-b9f9-ee4cf9c71b86',
language: null,
value: 'Demo',
place: 0,
authority: null,
confidence: -1,
},
],
'eperson.language': [
{
uuid: '98c2abdb-6a6f-4b41-b455-896bcf333ca3',
language: null,
value: 'en',
place: 0,
authority: null,
confidence: -1,
},
],
'eperson.lastname': [
{
uuid: 'df722e70-9497-468d-a92a-4038e7ef2586',
language: null,
value: 'Submitter',
place: 0,
authority: null,
confidence: -1,
},
],
},
_links: {
groups: {
href: 'http://localhost:8080/server/api/eperson/epersons/914955b1-cf2e-4884-8af7-a166aa24cf73/groups',
},
self: {
href: 'http://localhost:8080/server/api/eperson/epersons/914955b1-cf2e-4884-8af7-a166aa24cf73',
},
},
});
TestBed.configureTestingModule({
authService = jasmine.createSpyObj('authService', {
getAuthenticatedUserFromStore: jasmine.createSpy('getAuthenticatedUserFromStore')
});
describe('WorkspaceitemActionsComponent', () => {
beforeEach(waitForAsync(async () => {
await TestBed.configureTestingModule({
imports: [
NgbModule,
TranslateModule.forRoot({
@@ -92,6 +175,8 @@ describe('WorkspaceitemActionsComponent', () => {
{ provide: WorkspaceitemDataService, useValue: mockDataService },
{ provide: SearchService, useValue: searchService },
{ provide: RequestService, useValue: requestServce },
{ provide: AuthService, useValue: authService },
{ provide: AuthorizationDataService, useValue: authorizationService},
NgbModal
],
schemas: [NO_ERRORS_SCHEMA]
@@ -105,6 +190,10 @@ describe('WorkspaceitemActionsComponent', () => {
component = fixture.componentInstance;
component.object = mockObject;
notificationsServiceStub = TestBed.inject(NotificationsService as any);
authorizationService = jasmine.createSpyObj('authorizationService', {
isAuthorized: observableOf(true)
});
(authService.getAuthenticatedUserFromStore as jasmine.Spy).and.returnValue(observableOf(ePersonMock));
fixture.detectChanges();
});
@@ -150,7 +239,6 @@ describe('WorkspaceitemActionsComponent', () => {
confirmBtn.click();
fixture.detectChanges();
fixture.whenStable().then(() => {
done();
});