From 5d0d68d0bd9b62b87b7b235672caa50ba607c0e7 Mon Sep 17 00:00:00 2001 From: siva kumar Date: Mon, 8 Mar 2021 15:03:44 +0530 Subject: [PATCH] [ACA-4323] Can't add aspects to a folder in ACA/ADW (#2041) * [ACA-4323] Can't add aspects to a folder in ACA/ADW * * Added unit tests --- src/app/store/effects/node.effects.spec.ts | 19 ++++++++++++++++--- src/app/store/effects/node.effects.ts | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/app/store/effects/node.effects.spec.ts b/src/app/store/effects/node.effects.spec.ts index 17f6f0aef..c5b296764 100644 --- a/src/app/store/effects/node.effects.spec.ts +++ b/src/app/store/effects/node.effects.spec.ts @@ -472,17 +472,30 @@ describe('NodeEffects', () => { expect(contentService.manageAspects).toHaveBeenCalled(); }); - it('should call aspect dialog from the active selection', fakeAsync(() => { + it('should call aspect dialog from the active file selection', fakeAsync(() => { spyOn(contentService, 'manageAspects').and.stub(); - const node: any = { entry: { isFile: true } }; + const node: any = { entry: { isFile: true, id: 'file-node-id' } }; store.dispatch(new SetSelectedNodesAction([node])); tick(100); store.dispatch(new ManageAspectsAction(null)); - expect(contentService.manageAspects).toHaveBeenCalled(); + expect(contentService.manageAspects).toHaveBeenCalledWith({ entry: { isFile: true, id: 'file-node-id' } }); + })); + + it('should call aspect dialog from the active folder selection', fakeAsync(() => { + spyOn(contentService, 'manageAspects').and.stub(); + + const node: any = { entry: { isFile: false, id: 'folder-node-id' } }; + store.dispatch(new SetSelectedNodesAction([node])); + + tick(100); + + store.dispatch(new ManageAspectsAction(null)); + + expect(contentService.manageAspects).toHaveBeenCalledWith({ entry: { isFile: false, id: 'folder-node-id' } }); })); }); }); diff --git a/src/app/store/effects/node.effects.ts b/src/app/store/effects/node.effects.ts index 7db2e5f8d..ed809d073 100644 --- a/src/app/store/effects/node.effects.ts +++ b/src/app/store/effects/node.effects.ts @@ -328,8 +328,8 @@ export class NodeEffects { .select(getAppSelection) .pipe(take(1)) .subscribe((selection) => { - if (selection && selection.file) { - this.contentService.manageAspects(selection.file); + if (selection && !selection.isEmpty) { + this.contentService.manageAspects(selection.nodes[0]); } }); }