From 5ad5fe3c153cb40373f4ad74ef2e06e8ae34d33f Mon Sep 17 00:00:00 2001 From: DominikIwanek Date: Wed, 8 Nov 2023 15:48:28 +0100 Subject: [PATCH] [ACS-6278] - fix after CR --- .../aca-shared/rules/src/app.rules.spec.ts | 56 +++++++++---------- projects/aca-shared/rules/src/app.rules.ts | 3 +- 2 files changed, 27 insertions(+), 32 deletions(-) diff --git a/projects/aca-shared/rules/src/app.rules.spec.ts b/projects/aca-shared/rules/src/app.rules.spec.ts index dd96564a55..0b80eb57c9 100644 --- a/projects/aca-shared/rules/src/app.rules.spec.ts +++ b/projects/aca-shared/rules/src/app.rules.spec.ts @@ -796,22 +796,9 @@ describe('app.evaluators', () => { describe('canEditAspects', () => { let context: TestRuleContext; - beforeEach(() => { - context = new TestRuleContext(); - context.repository = { - version: { - major: 10 - }, - edition: '', - status: undefined - } as unknown as RepositoryInfo; - context.permissions = { - check() { - return true; - } - }; - context.selection.isEmpty = false; + beforeEach(() => { + context = createTestContext(); }); it('should return false for multiselection', () => { @@ -851,23 +838,11 @@ describe('app.evaluators', () => { describe('canManagePermissions', () => { let context: TestRuleContext; - beforeEach(() => { - context = new TestRuleContext(); - context.repository = { - version: { - major: 10 - }, - edition: '', - status: undefined - } as unknown as RepositoryInfo; - context.permissions = { - check() { - return true; - } - }; - context.selection.isEmpty = false; + beforeEach(() => { + context = createTestContext(); }); + it('should return false if user cannot update the selected node', () => { context.permissions.check = spyOn(context.permissions, 'check').and.returnValue(false); @@ -882,7 +857,7 @@ describe('app.evaluators', () => { it('should return false if the selected node is a smart folder', () => { context.selection.first = { entry: { aspectNames: ['smf:customConfigSmartFolder'], isFolder: true } } as NodeEntry; - expect(app.canEditAspects(context)).toBe(false); + expect(app.canManagePermissions(context)).toBe(false); }); it('should return true if user can update the selected node and it is not a trashcan nor smart folder', () => { @@ -890,3 +865,22 @@ describe('app.evaluators', () => { }); }); }); + +function createTestContext(): TestRuleContext { + const context = new TestRuleContext(); + context.repository = { + version: { + major: 10 + }, + edition: '', + status: undefined + } as unknown as RepositoryInfo; + + context.permissions = { + check() { + return true; + } + }; + context.selection.isEmpty = false; + return context; +} diff --git a/projects/aca-shared/rules/src/app.rules.ts b/projects/aca-shared/rules/src/app.rules.ts index 6142286447..ebebea9189 100644 --- a/projects/aca-shared/rules/src/app.rules.ts +++ b/projects/aca-shared/rules/src/app.rules.ts @@ -27,6 +27,7 @@ import { RuleContext } from '@alfresco/adf-extensions'; import * as navigation from './navigation.rules'; import * as repository from './repository.rules'; import { isAdmin } from './user.rules'; +import { NodeEntry } from '@alfresco/js-api'; /* cspell:disable */ export const supportedExtensions = { @@ -638,6 +639,6 @@ function isSmartFolder(context: RuleContext): boolean { return false; } -function getNodeAspectNames(node: any): any[] { +function getNodeAspectNames(node: NodeEntry): string[] { return node.entry?.aspectNames ?? []; }