mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
Fix content-services unit tests: getEcmUsername from authentication service
Fix content-services unit tests: alfresco api service has been replaced by authentication service
This commit is contained in:
+6
-6
@@ -18,7 +18,6 @@
|
|||||||
import { CUSTOM_ELEMENTS_SCHEMA, SimpleChange, QueryList, Component, ViewChild, SimpleChanges } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA, SimpleChange, QueryList, Component, ViewChild, SimpleChanges } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||||
import {
|
import {
|
||||||
AlfrescoApiService,
|
|
||||||
DataColumnListComponent,
|
DataColumnListComponent,
|
||||||
DataColumnComponent,
|
DataColumnComponent,
|
||||||
DataColumn,
|
DataColumn,
|
||||||
@@ -27,7 +26,8 @@ import {
|
|||||||
ObjectDataTableAdapter,
|
ObjectDataTableAdapter,
|
||||||
ShowHeaderMode,
|
ShowHeaderMode,
|
||||||
ThumbnailService,
|
ThumbnailService,
|
||||||
AppConfigService
|
AppConfigService,
|
||||||
|
AuthenticationService
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { ContentService } from '../../common/services/content.service';
|
import { ContentService } from '../../common/services/content.service';
|
||||||
import { Subject, of, throwError } from 'rxjs';
|
import { Subject, of, throwError } from 'rxjs';
|
||||||
@@ -69,7 +69,6 @@ const mockDialog = {
|
|||||||
describe('DocumentList', () => {
|
describe('DocumentList', () => {
|
||||||
let documentList: DocumentListComponent;
|
let documentList: DocumentListComponent;
|
||||||
let documentListService: DocumentListService;
|
let documentListService: DocumentListService;
|
||||||
let apiService: AlfrescoApiService;
|
|
||||||
let customResourcesService: CustomResourcesService;
|
let customResourcesService: CustomResourcesService;
|
||||||
let thumbnailService: ThumbnailService;
|
let thumbnailService: ThumbnailService;
|
||||||
let contentService: ContentService;
|
let contentService: ContentService;
|
||||||
@@ -81,6 +80,7 @@ describe('DocumentList', () => {
|
|||||||
let spyFavorite: any;
|
let spyFavorite: any;
|
||||||
let spyFolder: any;
|
let spyFolder: any;
|
||||||
let spyFolderNode: any;
|
let spyFolderNode: any;
|
||||||
|
let authenticationService: AuthenticationService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@@ -98,11 +98,11 @@ describe('DocumentList', () => {
|
|||||||
documentList = fixture.componentInstance;
|
documentList = fixture.componentInstance;
|
||||||
|
|
||||||
documentListService = TestBed.inject(DocumentListService);
|
documentListService = TestBed.inject(DocumentListService);
|
||||||
apiService = TestBed.inject(AlfrescoApiService);
|
|
||||||
customResourcesService = TestBed.inject(CustomResourcesService);
|
customResourcesService = TestBed.inject(CustomResourcesService);
|
||||||
thumbnailService = TestBed.inject(ThumbnailService);
|
thumbnailService = TestBed.inject(ThumbnailService);
|
||||||
contentService = TestBed.inject(ContentService);
|
contentService = TestBed.inject(ContentService);
|
||||||
appConfigService = TestBed.inject(AppConfigService);
|
appConfigService = TestBed.inject(AppConfigService);
|
||||||
|
authenticationService = TestBed.inject(AuthenticationService);
|
||||||
|
|
||||||
spyFolder = spyOn(documentListService, 'getFolder').and.returnValue(of({ list: {} }));
|
spyFolder = spyOn(documentListService, 'getFolder').and.returnValue(of({ list: {} }));
|
||||||
spyFolderNode = spyOn(documentListService, 'getFolderNode').and.returnValue(of(new NodeEntry({ entry: {} })));
|
spyFolderNode = spyOn(documentListService, 'getFolderNode').and.returnValue(of(new NodeEntry({ entry: {} })));
|
||||||
@@ -622,7 +622,7 @@ describe('DocumentList', () => {
|
|||||||
title: 'FileAction'
|
title: 'FileAction'
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('lockOwner');
|
spyOn(authenticationService, 'getEcmUsername').and.returnValue('lockOwner');
|
||||||
|
|
||||||
documentList.actions = [documentMenu];
|
documentList.actions = [documentMenu];
|
||||||
|
|
||||||
@@ -653,7 +653,7 @@ describe('DocumentList', () => {
|
|||||||
title: 'FileAction'
|
title: 'FileAction'
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('jerryTheKillerCow');
|
spyOn(authenticationService, 'getEcmUsername').and.returnValue('jerryTheKillerCow');
|
||||||
|
|
||||||
documentList.actions = [documentMenu];
|
documentList.actions = [documentMenu];
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { LockService } from './lock.service';
|
import { LockService } from './lock.service';
|
||||||
import { CoreTestingModule, AlfrescoApiService } from '@alfresco/adf-core';
|
import { CoreTestingModule, AuthenticationService } from '@alfresco/adf-core';
|
||||||
import { Node } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
@@ -25,7 +25,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
|||||||
describe('PeopleProcessService', () => {
|
describe('PeopleProcessService', () => {
|
||||||
|
|
||||||
let service: LockService;
|
let service: LockService;
|
||||||
let apiService: AlfrescoApiService;
|
let authenticationService: AuthenticationService;
|
||||||
|
|
||||||
const fakeNodeUnlocked: Node = { name: 'unlocked', isLocked: false, isFile: true } as Node;
|
const fakeNodeUnlocked: Node = { name: 'unlocked', isLocked: false, isFile: true } as Node;
|
||||||
const fakeFolderNode: Node = { name: 'unlocked', isLocked: false, isFile: false, isFolder: true } as Node;
|
const fakeFolderNode: Node = { name: 'unlocked', isLocked: false, isFile: false, isFolder: true } as Node;
|
||||||
@@ -39,7 +39,7 @@ describe('PeopleProcessService', () => {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
service = TestBed.inject(LockService);
|
service = TestBed.inject(LockService);
|
||||||
apiService = TestBed.inject(AlfrescoApiService);
|
authenticationService = TestBed.inject(AuthenticationService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false when no lock is configured', () => {
|
it('should return false when no lock is configured', () => {
|
||||||
@@ -145,22 +145,22 @@ describe('PeopleProcessService', () => {
|
|||||||
} as Node;
|
} as Node;
|
||||||
|
|
||||||
it('should return false when the user is the lock owner', () => {
|
it('should return false when the user is the lock owner', () => {
|
||||||
spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('lock-owner-user');
|
spyOn(authenticationService, 'getEcmUsername').and.returnValue('lock-owner-user');
|
||||||
expect(service.isLocked(nodeOwnerAllowedLock)).toBeFalsy();
|
expect(service.isLocked(nodeOwnerAllowedLock)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true when the user is not the lock owner', () => {
|
it('should return true when the user is not the lock owner', () => {
|
||||||
spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('banana-user');
|
spyOn(authenticationService, 'getEcmUsername').and.returnValue('banana-user');
|
||||||
expect(service.isLocked(nodeOwnerAllowedLock)).toBeTruthy();
|
expect(service.isLocked(nodeOwnerAllowedLock)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false when the user is not the lock owner but the lock is expired', () => {
|
it('should return false when the user is not the lock owner but the lock is expired', () => {
|
||||||
spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('banana-user');
|
spyOn(authenticationService, 'getEcmUsername').and.returnValue('banana-user');
|
||||||
expect(service.isLocked(nodeOwnerAllowedLockWithExpiredDate)).toBeFalsy();
|
expect(service.isLocked(nodeOwnerAllowedLockWithExpiredDate)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true when is not the lock owner and the expiration date is valid', () => {
|
it('should return true when is not the lock owner and the expiration date is valid', () => {
|
||||||
spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('banana-user');
|
spyOn(authenticationService, 'getEcmUsername').and.returnValue('banana-user');
|
||||||
expect(service.isLocked(nodeOwnerAllowedLockWithActiveExpiration)).toBeTruthy();
|
expect(service.isLocked(nodeOwnerAllowedLockWithActiveExpiration)).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user