[ACS-3887] Rule set listing, including linked & inherited rules (#2780)

* [ACS-3887] Rule set listing to include linked & inherited rules

* Handled rules & rule sets reloading after a create/update/delete operation

* Linting

* Start rewrite of folder rules service unit tests

* Rules service and rule sets service unit tests

* Readd rules services create, update & delete unit tests

* rule set list ui component unit tests

* Manage rules component unit tests

* Remove & modify comments
This commit is contained in:
Thomas Hunter
2022-11-16 16:29:26 +00:00
committed by GitHub
parent cc9af931c6
commit c75091bf59
25 changed files with 1220 additions and 465 deletions

View File

@@ -23,44 +23,32 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export const dummyGetNodeResponse = {
import { NodeInfo } from '@alfresco/aca-shared/store';
import { NodeEntry } from '@alfresco/js-api';
export const getOwningFolderEntryMock: NodeEntry = {
entry: {
aspectNames: ['rule:rules', 'cm:titled', 'cm:auditable'],
createdAt: '2022-08-16T07:58:21.416+0000',
isFolder: true,
isFile: false,
createdByUser: {
id: 'username',
displayName: 'username'
},
modifiedAt: '2022-08-16T07:59:45.771+0000',
modifiedByUser: {
id: 'username',
displayName: 'username'
},
name: 'folder1',
id: '76659fe3-5f93-483d-948e-38b9e006cc94',
nodeType: 'cm:folder',
parentId: 'eb48d545-61f7-4ebd-861d-5fe5b072472f'
id: 'owning-folder-id',
name: 'owning-folder-name'
}
} as NodeEntry;
export const getOtherFolderEntryMock: NodeEntry = {
entry: {
id: 'other-folder-id',
name: 'other-folder-name'
}
} as NodeEntry;
export const owningFolderIdMock = 'owning-folder-id';
export const otherFolderIdMock = 'other-folder-id';
export const owningFolderMock: NodeInfo = {
id: owningFolderIdMock,
name: 'owning-folder-name'
};
export const dummyNodeInfo = {
aspectNames: ['rule:rules', 'cm:titled', 'cm:auditable'],
createdAt: '2022-08-16T07:58:21.416+0000',
isFolder: true,
isFile: false,
createdByUser: {
id: 'username',
displayName: 'username'
},
modifiedAt: '2022-08-16T07:59:45.771+0000',
modifiedByUser: {
id: 'username',
displayName: 'username'
},
name: 'folder1',
id: '76659fe3-5f93-483d-948e-38b9e006cc94',
nodeType: 'cm:folder',
parentId: 'eb48d545-61f7-4ebd-861d-5fe5b072472f'
export const otherFolderMock: NodeInfo = {
id: otherFolderIdMock,
name: 'other-folder-name'
};

View File

@@ -0,0 +1,109 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { RuleSet } from '../model/rule-set.model';
import { otherFolderIdMock, otherFolderMock, owningFolderIdMock, owningFolderMock } from './node.mock';
import { Rule } from '../model/rule.model';
import { inheritedRulesMock, linkedRulesMock, ownedRulesMock } from './rules.mock';
export const getRuleSetsResponseMock = {
list: {
pagination: {
count: 3,
hasMoreItems: false,
totalItems: 3,
skipCount: 0,
maxItems: 100
},
entries: [
{
entry: {
linkedToBy: [],
owningFolder: otherFolderIdMock,
isLinkedTo: false,
id: 'inherited-rule-set'
}
},
{
entry: {
linkedToBy: [],
owningFolder: owningFolderIdMock,
isLinkedTo: false,
id: 'rule-set-no-links'
}
},
{
entry: {
linkedToBy: [owningFolderIdMock],
owningFolder: otherFolderIdMock,
isLinkedTo: true,
id: 'rule-set-with-link'
}
}
]
}
};
export const ruleSetMock = (rules: Rule[] = []): RuleSet => ({
id: 'rule-set-id',
isLinkedTo: false,
owningFolder: owningFolderMock,
linkedToBy: [],
rules: [...rules],
hasMoreRules: true,
loadingRules: false
});
const ruleSetWithNoLinksMock: RuleSet = {
id: 'rule-set-no-links',
isLinkedTo: false,
owningFolder: owningFolderMock,
linkedToBy: [],
rules: ownedRulesMock,
hasMoreRules: false,
loadingRules: false
};
const ruleSetWithLinkMock: RuleSet = {
id: 'rule-set-with-link',
isLinkedTo: true,
owningFolder: otherFolderMock,
linkedToBy: [owningFolderIdMock],
rules: linkedRulesMock,
hasMoreRules: false,
loadingRules: false
};
const inheritedRuleSetMock: RuleSet = {
id: 'inherited-rule-set',
isLinkedTo: false,
owningFolder: otherFolderMock,
linkedToBy: [],
rules: inheritedRulesMock,
hasMoreRules: false,
loadingRules: false
};
export const ruleSetsMock: RuleSet[] = [inheritedRuleSetMock, ruleSetWithNoLinksMock, ruleSetWithLinkMock];

View File

@@ -25,7 +25,7 @@
import { Rule } from '../model/rule.model';
export const dummyResponse = {
export const getRulesResponseMock = {
list: {
pagination: {
count: 2,
@@ -40,17 +40,13 @@ export const dummyResponse = {
isShared: false,
isInheritable: false,
isAsynchronous: false,
name: 'rule1',
id: 'd388ed54-a522-410f-a158-6dbf5a833731',
name: 'rule1-name',
id: 'rule1-id',
triggers: ['inbound'],
actions: [
{
actionDefinitionId: 'copy',
params: {
'deep-copy': false,
'destination-folder': '279c65f0-912b-4563-affb-ed9dab8338e0',
actionContext: 'rule'
}
actionDefinitionId: 'counter',
params: {}
}
],
isEnabled: true
@@ -61,16 +57,13 @@ export const dummyResponse = {
isShared: false,
isInheritable: false,
isAsynchronous: false,
name: 'rule2',
id: 'e0e645ca-e6c0-47d4-9936-1a8872a6c30b',
name: 'rule2-name',
id: 'rule2-id',
triggers: ['inbound'],
actions: [
{
actionDefinitionId: 'move',
params: {
'destination-folder': '279c65f0-912b-4563-affb-ed9dab8338e0',
actionContext: 'rule'
}
actionDefinitionId: 'counter',
params: {}
}
],
isEnabled: true
@@ -80,58 +73,88 @@ export const dummyResponse = {
}
};
export const dummyRules: Rule[] = [
{
id: 'd388ed54-a522-410f-a158-6dbf5a833731',
name: 'rule1',
description: '',
isEnabled: true,
isInheritable: false,
isAsynchronous: false,
errorScript: '',
isShared: false,
triggers: ['inbound'],
conditions: {
inverted: false,
booleanMode: 'and',
simpleConditions: [],
compositeConditions: []
export const getMoreRulesResponseMock = {
list: {
pagination: {
count: 2,
hasMoreItems: false,
totalItems: 2,
skipCount: 0,
maxItems: 100
},
actions: [
entries: [
{
actionDefinitionId: 'copy',
params: {
'deep-copy': false,
'destination-folder': '279c65f0-912b-4563-affb-ed9dab8338e0',
actionContext: 'rule'
entry: {
isShared: false,
isInheritable: false,
isAsynchronous: false,
name: 'rule3-name',
id: 'rule3-id',
triggers: ['inbound'],
actions: [
{
actionDefinitionId: 'counter',
params: {}
}
],
isEnabled: true
}
}
]
},
{
id: 'e0e645ca-e6c0-47d4-9936-1a8872a6c30b',
name: 'rule2',
description: '',
isEnabled: true,
isInheritable: false,
isAsynchronous: false,
errorScript: '',
isShared: false,
triggers: ['inbound'],
conditions: {
inverted: false,
booleanMode: 'and',
simpleConditions: [],
compositeConditions: []
},
actions: [
},
{
actionDefinitionId: 'move',
params: {
'destination-folder': '279c65f0-912b-4563-affb-ed9dab8338e0',
actionContext: 'rule'
entry: {
isShared: false,
isInheritable: false,
isAsynchronous: false,
name: 'rule4-name',
id: 'rule4-id',
triggers: ['inbound'],
actions: [
{
actionDefinitionId: 'counter',
params: {}
}
],
isEnabled: true
}
}
]
}
];
};
const genericRuleMock: Rule = {
id: '',
name: '',
description: '',
isEnabled: true,
isInheritable: false,
isAsynchronous: false,
errorScript: '',
isShared: false,
triggers: ['inbound'],
conditions: {
inverted: false,
booleanMode: 'and',
simpleConditions: [],
compositeConditions: []
},
actions: [
{
actionDefinitionId: 'counter',
params: {}
}
]
};
export const ruleMock = (unique: string): Rule => ({
...genericRuleMock,
id: `${unique}-id`,
name: `${unique}-name`
});
export const rulesMock: Rule[] = [ruleMock('rule1'), ruleMock('rule2')];
export const moreRulesMock: Rule[] = [ruleMock('rule3'), ruleMock('rule4')];
export const manyRulesMock: Rule[] = [ruleMock('rule1'), ruleMock('rule2'), ruleMock('rule3'), ruleMock('rule4'), ruleMock('rule5')];
export const ownedRulesMock: Rule[] = [ruleMock('owned-rule-1'), ruleMock('owned-rule-2')];
export const linkedRulesMock: Rule[] = [ruleMock('linked-rule-1'), ruleMock('linked-rule-2')];
export const inheritedRulesMock: Rule[] = [ruleMock('inherited-rule-1'), ruleMock('inherited-rule-2')];