[ACS-8898] Empty context menu on multi-selected libraries (#4260)

This commit is contained in:
dominikiwanekhyland 2024-11-27 15:34:01 +01:00 committed by GitHub
parent e13c1b684b
commit f8c6b6bbd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 5 deletions

View File

@ -70,17 +70,18 @@ describe('ContextMenuComponent', () => {
component = fixture.componentInstance;
extensionsService = TestBed.inject(AppExtensionService);
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue(of([contextItem]));
fixture.detectChanges();
});
it('should load context menu actions on init', () => {
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue(of([contextItem]));
fixture.detectChanges();
expect(component.actions.length).toBe(1);
});
it('should render defined context menu actions items', async () => {
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue(of([contextItem]));
fixture.detectChanges();
await fixture.whenStable();
const contextMenuElements = document.body.querySelector('.aca-context-menu')?.querySelectorAll('button');
@ -89,4 +90,14 @@ describe('ContextMenuComponent', () => {
expect(contextMenuElements?.length).toBe(1);
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();
});
});

View File

@ -75,6 +75,8 @@ export class ContextMenuComponent extends BaseContextMenuDirective implements On
}
ngAfterViewInit() {
setTimeout(() => this.trigger.openMenu(), 0);
if (this.actions.length) {
setTimeout(() => this.trigger.openMenu(), 0);
}
}
}