[AAE-5874] Re-evaluate extension rules when context changes (#2296)

* [AAE-5874] Re-evaluate extension rules when context changes

* [AAE-5874] Add disabled attribute to toolbar actions

* [AAE-5874] Fix unit tests
This commit is contained in:
Pablo Martinez Garcia
2021-09-16 15:48:43 +02:00
committed by Denys Vuika
parent 46a179c75a
commit c4e4b50f8a
17 changed files with 408 additions and 238 deletions

View File

@@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { AppTestingModule } from '../../testing/app-testing.module';
import { ContextMenuComponent } from './context-menu.component';
import { ContextMenuModule } from './context-menu.module';
@@ -75,7 +75,7 @@ describe('ContextMenuComponent', () => {
contextMenuOverlayRef = TestBed.inject(ContextMenuOverlayRef);
extensionsService = TestBed.inject(AppExtensionService);
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue([contextItem]);
spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue(of([contextItem]));
fixture.detectChanges();
});
@@ -85,15 +85,16 @@ describe('ContextMenuComponent', () => {
expect(contextMenuOverlayRef.close).toHaveBeenCalled();
});
it('should render defined context menu actions items', fakeAsync(() => {
it('should render defined context menu actions items', async () => {
component.ngAfterViewInit();
tick(500);
fixture.detectChanges();
await fixture.whenStable();
const contextMenuElements = document.body.querySelector('.aca-context-menu').querySelectorAll('button');
expect(contextMenuElements.length).toBe(1);
expect(contextMenuElements[0].querySelector('span').innerText).toBe(contextItem.title);
}));
});
it('should run action with provided action id', () => {
spyOn(extensionsService, 'runActionById');