Skip to content

Commit

Permalink
[ACS-6278] - fix after CR
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikiwanekhyland committed Nov 8, 2023
1 parent f3ba2c3 commit 5ad5fe3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 32 deletions.
56 changes: 25 additions & 31 deletions projects/aca-shared/rules/src/app.rules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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);

Expand All @@ -882,11 +857,30 @@ 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', () => {
expect(app.canManagePermissions(context)).toBe(true);
});
});
});

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;
}
3 changes: 2 additions & 1 deletion projects/aca-shared/rules/src/app.rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 ?? [];
}

0 comments on commit 5ad5fe3

Please sign in to comment.