mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-17 14:21:14 +00:00
committed by
DominikIwanek
parent
a666ae45e7
commit
7cb18bc19a
@@ -57,14 +57,7 @@ describe('DetailsComponent', () => {
|
|||||||
select: () => mockStream
|
select: () => mockStream
|
||||||
};
|
};
|
||||||
|
|
||||||
const extensionsServiceMock = {
|
const mockAspectActionsSubject$ = new BehaviorSubject<Array<ContentActionRef>>([]);
|
||||||
getAllowedSidebarActions: jasmine.createSpy('getAllowedSidebarActions')
|
|
||||||
};
|
|
||||||
|
|
||||||
const mockAspectActions: ContentActionRef[] = [];
|
|
||||||
|
|
||||||
const mockAspectActionsSubject$ = new BehaviorSubject(mockAspectActions);
|
|
||||||
extensionsServiceMock.getAllowedSidebarActions.and.returnValue(mockAspectActionsSubject$.asObservable());
|
|
||||||
|
|
||||||
const getBreadcrumb = (): BreadcrumbComponent => fixture.debugElement.query(By.directive(BreadcrumbComponent)).componentInstance;
|
const getBreadcrumb = (): BreadcrumbComponent => fixture.debugElement.query(By.directive(BreadcrumbComponent)).componentInstance;
|
||||||
|
|
||||||
@@ -99,6 +92,9 @@ describe('DetailsComponent', () => {
|
|||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const appExtensionService = TestBed.inject(AppExtensionService);
|
||||||
|
spyOn(appExtensionService, 'getAllowedSidebarActions').and.returnValue(mockAspectActionsSubject$.asObservable());
|
||||||
|
|
||||||
fixture = TestBed.createComponent(DetailsComponent);
|
fixture = TestBed.createComponent(DetailsComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
contentApiService = TestBed.inject(ContentApiService);
|
contentApiService = TestBed.inject(ContentApiService);
|
||||||
@@ -130,138 +126,134 @@ describe('DetailsComponent', () => {
|
|||||||
fixture.destroy();
|
fixture.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get node id from router', () => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(component.nodeId).toBe('someId');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set active tab from router', () => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(component.activeTab).toBe(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should get node info after setting node from router', () => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(contentApiService.getNode).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should dispatch navigation to a given folder', () => {
|
|
||||||
const pathElement: PathElement = {
|
|
||||||
id: 'fake-id'
|
|
||||||
};
|
|
||||||
getBreadcrumb().navigate.emit(pathElement);
|
|
||||||
fixture.detectChanges();
|
|
||||||
|
|
||||||
expect(store.dispatch).toHaveBeenCalledWith(new NavigateToFolder({ entry: pathElement } as NodeEntry));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should pass different node as folderNode to breadcrumb when nodeUpdated from nodesApiService is triggered', () => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
const breadcrumbComponent = getBreadcrumb();
|
|
||||||
const updatedNode = {
|
|
||||||
name: 'other node'
|
|
||||||
} as Node;
|
|
||||||
|
|
||||||
nodesApiService.nodeUpdated.next(updatedNode);
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(breadcrumbComponent.folderNode).toEqual(updatedNode);
|
|
||||||
expect(breadcrumbComponent.folderNode).not.toBe(updatedNode);
|
|
||||||
expect(updatedNode).not.toEqual(node.entry);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should dispatch node selection', () => {
|
|
||||||
fixture.detectChanges();
|
|
||||||
expect(store.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([node]));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set aspectActions from extensions', async () => {
|
|
||||||
extensionsServiceMock.getAllowedSidebarActions.and.returnValue(of(mockAspectActions));
|
|
||||||
fixture.detectChanges();
|
|
||||||
await fixture.whenStable().then(() => {
|
|
||||||
expect(component.aspectActions).toEqual(mockAspectActions);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return the icon when getNodeIcon is called', () => {
|
|
||||||
const expectedIcon = 'assets/images/ft_ic_folder';
|
|
||||||
spyOn(contentService, 'getNodeIcon').and.returnValue(expectedIcon);
|
|
||||||
fixture.detectChanges();
|
|
||||||
component.ngOnInit();
|
|
||||||
expect(contentService.getNodeIcon).toHaveBeenCalled();
|
|
||||||
expect(component.nodeIcon).toContain(expectedIcon);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set aspectActions from extension mock', () => {
|
it('should set aspectActions from extension mock', () => {
|
||||||
const extensionMock = {
|
const extensionMock = [
|
||||||
getAllowedSidebarActions: () =>
|
{
|
||||||
of([
|
id: 'app.sidebar.close',
|
||||||
{
|
order: 100,
|
||||||
id: 'app.sidebar.close',
|
title: 'close',
|
||||||
order: 100,
|
icon: 'highlight_off'
|
||||||
title: 'close',
|
} as ContentActionRef
|
||||||
icon: 'highlight_off'
|
];
|
||||||
}
|
|
||||||
])
|
mockAspectActionsSubject$.next(extensionMock);
|
||||||
};
|
|
||||||
|
|
||||||
extensionsServiceMock.getAllowedSidebarActions.and.returnValue(of(extensionMock));
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture
|
expect(component.aspectActions).toEqual([
|
||||||
.whenStable()
|
{
|
||||||
.then(() => {
|
id: 'app.sidebar.close',
|
||||||
expect(component.aspectActions).toEqual([
|
order: 100,
|
||||||
{
|
title: 'close',
|
||||||
id: 'app.sidebar.close',
|
icon: 'highlight_off'
|
||||||
order: 100,
|
} as ContentActionRef
|
||||||
title: 'close',
|
]);
|
||||||
icon: 'highlight_off'
|
});
|
||||||
} as ContentActionRef
|
|
||||||
]);
|
describe('', () => {
|
||||||
})
|
beforeEach(() => {
|
||||||
.catch((error) => {
|
mockAspectActionsSubject$.next([]);
|
||||||
fail(`An error occurred: ${error}`);
|
});
|
||||||
|
|
||||||
|
it('should get node id from router', () => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(component.nodeId).toBe('someId');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set active tab from router', () => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(component.activeTab).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should get node info after setting node from router', () => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(contentApiService.getNode).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should dispatch navigation to a given folder', () => {
|
||||||
|
const pathElement: PathElement = {
|
||||||
|
id: 'fake-id'
|
||||||
|
};
|
||||||
|
getBreadcrumb().navigate.emit(pathElement);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(store.dispatch).toHaveBeenCalledWith(new NavigateToFolder({ entry: pathElement } as NodeEntry));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass different node as folderNode to breadcrumb when nodeUpdated from nodesApiService is triggered', () => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
const breadcrumbComponent = getBreadcrumb();
|
||||||
|
const updatedNode = {
|
||||||
|
name: 'other node'
|
||||||
|
} as Node;
|
||||||
|
|
||||||
|
nodesApiService.nodeUpdated.next(updatedNode);
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(breadcrumbComponent.folderNode).toEqual(updatedNode);
|
||||||
|
expect(breadcrumbComponent.folderNode).not.toBe(updatedNode);
|
||||||
|
expect(updatedNode).not.toEqual(node.entry);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should dispatch node selection', () => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(store.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([node]));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set aspectActions from extensions', async () => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable().then(() => {
|
||||||
|
expect(component.aspectActions).toEqual([]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should disable the permissions tab for smart folders based on aspects', () => {
|
it('should return the icon when getNodeIcon is called', () => {
|
||||||
node.entry.isFolder = true;
|
const expectedIcon = 'assets/images/ft_ic_folder';
|
||||||
node.entry.aspectNames = ['smf:customConfigSmartFolder'];
|
spyOn(contentService, 'getNodeIcon').and.returnValue(expectedIcon);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
expect(component.canManagePermissions).toBeFalse();
|
expect(contentService.getNodeIcon).toHaveBeenCalled();
|
||||||
expect(component.activeTab).not.toBe(2);
|
expect(component.nodeIcon).toContain(expectedIcon);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should enable the permissions tab for regular folders based on aspects', () => {
|
it('should disable the permissions tab for smart folders based on aspects', () => {
|
||||||
node.entry.isFolder = true;
|
node.entry.isFolder = true;
|
||||||
node.entry.aspectNames = [];
|
node.entry.aspectNames = ['smf:customConfigSmartFolder'];
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
expect(component.canManagePermissions).toBeFalse();
|
||||||
|
expect(component.activeTab).not.toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
expect(component.canManagePermissions).toBeTrue();
|
it('should enable the permissions tab for regular folders based on aspects', () => {
|
||||||
});
|
node.entry.isFolder = true;
|
||||||
|
node.entry.aspectNames = [];
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.ngOnInit();
|
||||||
|
|
||||||
it('should change active tab based on canManagePermissions and tabName', () => {
|
expect(component.canManagePermissions).toBeTrue();
|
||||||
component.nodeId = 'someNodeId';
|
});
|
||||||
component.activeTab = 0;
|
|
||||||
|
|
||||||
node.entry.isFolder = true;
|
it('should change active tab based on canManagePermissions and tabName', () => {
|
||||||
node.entry.aspectNames = [];
|
component.nodeId = 'someNodeId';
|
||||||
|
component.activeTab = 0;
|
||||||
|
|
||||||
fixture.detectChanges();
|
node.entry.isFolder = true;
|
||||||
component.ngOnInit();
|
node.entry.aspectNames = [];
|
||||||
|
|
||||||
component.setActiveTab('permissions');
|
fixture.detectChanges();
|
||||||
expect(component.activeTab).toBe(2);
|
component.ngOnInit();
|
||||||
|
|
||||||
node.entry.isFolder = true;
|
component.setActiveTab('permissions');
|
||||||
node.entry.aspectNames = ['smf:customConfigSmartFolder'];
|
expect(component.activeTab).toBe(2);
|
||||||
|
|
||||||
fixture.detectChanges();
|
node.entry.isFolder = true;
|
||||||
component.ngOnInit();
|
node.entry.aspectNames = ['smf:customConfigSmartFolder'];
|
||||||
|
|
||||||
component.setActiveTab('permissions');
|
fixture.detectChanges();
|
||||||
expect(component.activeTab).not.toBe(2);
|
component.ngOnInit();
|
||||||
|
|
||||||
|
component.setActiveTab('permissions');
|
||||||
|
expect(component.activeTab).not.toBe(2);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should navigate back when nodesDeleted event is triggered', () => {
|
it('should navigate back when nodesDeleted event is triggered', () => {
|
||||||
|
Reference in New Issue
Block a user