mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACS-8898] Empty context menu on multi-selected libraries (#4260)
This commit is contained in:
parent
e13c1b684b
commit
f8c6b6bbd8
@ -70,17 +70,18 @@ describe('ContextMenuComponent', () => {
|
|||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
|
||||||
extensionsService = TestBed.inject(AppExtensionService);
|
extensionsService = TestBed.inject(AppExtensionService);
|
||||||
|
|
||||||
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue(of([contextItem]));
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load context menu actions on init', () => {
|
it('should load context menu actions on init', () => {
|
||||||
|
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue(of([contextItem]));
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(component.actions.length).toBe(1);
|
expect(component.actions.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render defined context menu actions items', async () => {
|
it('should render defined context menu actions items', async () => {
|
||||||
|
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue(of([contextItem]));
|
||||||
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
const contextMenuElements = document.body.querySelector('.aca-context-menu')?.querySelectorAll('button');
|
const contextMenuElements = document.body.querySelector('.aca-context-menu')?.querySelectorAll('button');
|
||||||
@ -89,4 +90,14 @@ describe('ContextMenuComponent', () => {
|
|||||||
expect(contextMenuElements?.length).toBe(1);
|
expect(contextMenuElements?.length).toBe(1);
|
||||||
expect(actionButtonLabel.innerText).toBe(contextItem.title);
|
expect(actionButtonLabel.innerText).toBe(contextItem.title);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not render context menu if no actions items', async () => {
|
||||||
|
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue(of([]));
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
|
||||||
|
const contextMenuElements = document.body.querySelector('.aca-context-menu');
|
||||||
|
|
||||||
|
expect(contextMenuElements).toBeNull();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -75,6 +75,8 @@ export class ContextMenuComponent extends BaseContextMenuDirective implements On
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
|
if (this.actions.length) {
|
||||||
setTimeout(() => this.trigger.openMenu(), 0);
|
setTimeout(() => this.trigger.openMenu(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user