[ACS-4892] [E2E] Created new tests for adding folder rules (#3895)

* [ACS-4892] [E2E] Created new tests for adding folder rules

* [ACS-4892] excluded one test for now

* [ACS-4892] [E2E] The rest of test cases automated

* [ACS-4892] deleted the unused if enum

* [ACS-4892] review fixes 1

* [ACS-4892] review fixes 2

* [ACS-4892] review fixes 3
This commit is contained in:
Adam Świderski
2024-07-11 10:53:04 +02:00
committed by GitHub
parent 1e176c3300
commit e7cd5741d2
14 changed files with 433 additions and 166 deletions

View File

@@ -1 +1,3 @@
{}
{
"C691642": "https://hyland.atlassian.net/browse/ACS-4894"
}

View File

@@ -34,9 +34,7 @@ const config: PlaywrightTestConfig<CustomConfig> = {
{
name: 'Folder Rules',
testDir: './src/tests',
use: {
users: ['hruser']
}
use: {}
}
]
};

View File

@@ -1,73 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* 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
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { expect } from '@playwright/test';
import { ActionType, ApiClientFactory, getUserState, test, Utils } from '@alfresco/playwright-shared';
test.use({ storageState: getUserState('hruser') });
test.describe('Folder Rules Actions', () => {
const apiClientFactory = new ApiClientFactory();
const randomFolderName = `folder-rules-actions-${Utils.random()}`;
const randomRuleName = `playwright-rule-${Utils.random()}`;
const checkInValue = 'check In Value';
const actionValue = ' A site which contains sfdc content [sfdc:site] ';
const autoDeclareOptionsValue = 'For all major and minor versions [ALL]';
const simpleWorkFlow = 'accept reject';
let folderId: string;
test.beforeAll(async () => {
await apiClientFactory.setUpAcaBackend('hruser');
const node = await apiClientFactory.nodes.createNode('-my-', { name: randomFolderName, nodeType: 'cm:folder' });
folderId = node.entry.id;
});
test.beforeEach(async ({ personalFiles }) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderId}/rules` });
});
test.afterAll(async () => {
await apiClientFactory.nodes.deleteNode(folderId, { permanent: true });
});
test('[C691637] Create a rule with actions', async ({ nodesPage }) => {
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.type(randomRuleName);
await nodesPage.actionsDropdown.selectAction(ActionType.HideRecord, 0);
await nodesPage.actionsDropdown.selectAction(ActionType.IncrementCounter, 1);
await nodesPage.actionsDropdown.selectAction(ActionType.CheckIn, 2);
await nodesPage.actionsDropdown.insertCheckInActionValues(checkInValue, 2);
await nodesPage.actionsDropdown.selectAction(ActionType.AddAspect, 3);
await nodesPage.actionsDropdown.insertAddAspectActionValues(actionValue, 3);
await nodesPage.actionsDropdown.selectAction(ActionType.AutoDeclareOptions, 4);
await nodesPage.actionsDropdown.insertAutoDeclareOptionsActionValues(autoDeclareOptionsValue, 4);
await nodesPage.actionsDropdown.selectAction(ActionType.SimpleWorkflow, 5);
await nodesPage.actionsDropdown.insertSimpleWorkflowActionValues(simpleWorkFlow, 5);
await nodesPage.manageRulesDialog.createRuleButton.click();
await expect.soft(nodesPage.manageRules.getGroupsList(randomRuleName)).toBeVisible();
});
});

View File

@@ -1,66 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* 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
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { expect } from '@playwright/test';
import { ActionType, ApiClientFactory, Comparator, Field, getUserState, test, Utils } from '@alfresco/playwright-shared';
test.use({ storageState: getUserState('hruser') });
test.describe('Folder Rules Conditions', () => {
const apiClientFactory = new ApiClientFactory();
const randomFolderName = `folder-rules-conditions-${Utils.random()}`;
const randomRuleName = `playwright-rule-${Utils.random()}`;
const specialChars = '!@£$%^&*()~#/';
let folderId: string;
test.beforeAll(async () => {
await apiClientFactory.setUpAcaBackend('hruser');
const node = await apiClientFactory.nodes.createNode('-my-', { name: randomFolderName, nodeType: 'cm:folder' });
folderId = node.entry.id;
});
test.beforeEach(async ({ personalFiles }) => {
await personalFiles.navigate();
});
test.afterAll(async () => {
await apiClientFactory.nodes.deleteNode(folderId, { permanent: true });
});
test('[C691638] Create a rule with condition', async ({ personalFiles, nodesPage }) => {
await personalFiles.dataTable.performActionFromExpandableMenu(randomFolderName, 'Manage rules');
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.type(randomRuleName);
await nodesPage.conditionsDropdown.addCondition(Field.Size, Comparator.Equals, specialChars, 0);
await nodesPage.conditionsDropdown.addCondition(Field.Size, Comparator.Equals, specialChars, 1);
await nodesPage.conditionsDropdown.addConditionGroupButton.click();
await nodesPage.conditionsDropdown.addConditionGroup(Field.Size, Comparator.Equals, specialChars, 0);
await nodesPage.conditionsDropdown.addConditionGroup(Field.Size, Comparator.Equals, specialChars, 1);
await nodesPage.actionsDropdown.selectAction(ActionType.IncrementCounter, 0);
await nodesPage.manageRulesDialog.createRuleButton.click();
await expect.soft(nodesPage.manageRules.getGroupsList(randomRuleName)).toBeVisible();
});
});

View File

@@ -0,0 +1,280 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* 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
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { expect } from '@playwright/test';
import { ActionType, ApiClientFactory, test, Utils, TrashcanApi, NodesApi, Comparator, Field } from '@alfresco/playwright-shared';
test.use({ launchOptions: { slowMo: 300 } });
test.describe('Folder Rules Actions', () => {
const apiClientFactory = new ApiClientFactory();
let nodesApi: NodesApi;
let trashcanApi: TrashcanApi;
const username = `user-e2e-${Utils.random()}`;
const folderName883 = `folder-XAT-883-${Utils.random()}`;
const folderName883_2 = `folder-XAT-883-2-${Utils.random()}`;
const folderName883_3 = `folder-XAT-883-3-${Utils.random()}`;
let randomRuleName: string;
const copyFileName = `copy-file-XAT-888-${Utils.random()}`;
const specialChars = '!@£$%^&*()~#/';
const testString = '"!@£$%^&*()_+{}|:""?&gt;&lt;,/.\';][=-`~"';
let folderName883Id: string;
let folderName883Id2: string;
let folderName883Id3: string;
test.beforeAll(async () => {
try {
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
nodesApi = await NodesApi.initialize(username, username);
trashcanApi = await TrashcanApi.initialize(username, username);
} catch (error) {
console.error(`beforeAll failed : ${error}`);
}
folderName883Id = (await nodesApi.createFolder(folderName883)).entry.id;
folderName883Id2 = (await nodesApi.createFolder(folderName883_2)).entry.id;
folderName883Id3 = (await nodesApi.createFolder(folderName883_3, folderName883Id)).entry.id;
await nodesApi.createFile(copyFileName, folderName883Id);
});
test.beforeEach(async ({ loginPage }) => {
await Utils.tryLoginUser(loginPage, username, username, 'beforeEach failed');
randomRuleName = `rule-XAT-${Utils.random()}`;
});
test.afterAll(async () => {
await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed');
});
test('[XAT-883] Create a rule with symbols in its name and description', async ({ personalFiles, nodesPage }) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(testString);
await nodesPage.manageRulesDialog.ruleDescriptionInputLocator.fill(testString);
await nodesPage.actionsDropdown.selectAction(ActionType.IncrementCounter, 0);
await nodesPage.manageRulesDialog.createRuleButton.click();
await expect(nodesPage.manageRules.getGroupsList(testString)).toBeVisible();
});
test('[XAT-884] Create a rule and link it to an existing folder', async ({ personalFiles, nodesPage }) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(randomRuleName);
await nodesPage.actionsDropdown.selectAction(ActionType.IncrementCounter, 0);
await nodesPage.manageRulesDialog.createRuleButton.click();
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id2}/rules` });
await nodesPage.toolbar.clickLinkRulesButton();
await nodesPage.linkRulesDialog.waitForLinkRules();
await nodesPage.linkRulesDialog.getFolderIcon.click();
await nodesPage.linkRulesDialog.getOptionLocator(username).click();
await nodesPage.linkRulesDialog.selectDestination(folderName883);
await nodesPage.linkRulesDialog.selectFolderButton.click();
await nodesPage.manageRules.checkIfRuleIsOnTheList(randomRuleName);
});
test('[XAT-885] Create a rule in a folder and inherit it in a subfolder (Rule applies to subfolders)', async ({ personalFiles, nodesPage }) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(randomRuleName);
await nodesPage.actionsDropdown.selectAction(ActionType.IncrementCounter, 0);
await nodesPage.manageRulesDialog.ruleSubfoldersCheckbox.click();
await nodesPage.manageRulesDialog.createRuleButton.click();
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id3}/rules` });
await nodesPage.manageRules.checkIfRuleIsOnTheList(randomRuleName);
});
test('[XAT-886] Create a rule and press cancel', async ({ personalFiles, nodesPage }) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await expect(nodesPage.manageRulesDialog.createRuleButton).toBeDisabled();
await nodesPage.manageRulesDialog.cancelRuleButton.click();
expect(nodesPage.manageRules.checkIfRuleListEmpty()).toBeTruthy();
});
test('[XAT-887] Create a disabled rule', async ({ personalFiles, nodesPage }) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(randomRuleName);
await nodesPage.actionsDropdown.selectAction(ActionType.IncrementCounter, 0);
await nodesPage.manageRulesDialog.ruleDisableCheckbox.click();
await nodesPage.manageRulesDialog.createRuleButton.click();
await expect(nodesPage.manageRules.ruleToggleFalse).toBeVisible();
});
test('[XAT-888] Create a rule with multiple actions', async ({ personalFiles, nodesPage }) => {
const checkInValue = 'check In Value';
const actionValue = ' A site which contains sfdc content [sfdc:site] ';
const autoDeclareOptionsValue = 'For all major and minor versions [ALL]';
const simpleWorkFlow = 'accept reject';
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(randomRuleName);
await nodesPage.actionsDropdown.selectAction(ActionType.HideRecord, 0);
await nodesPage.actionsDropdown.selectAction(ActionType.IncrementCounter, 1);
await nodesPage.actionsDropdown.selectAction(ActionType.CheckIn, 2);
await nodesPage.actionsDropdown.insertCheckInActionValues(checkInValue, 2);
await nodesPage.actionsDropdown.selectAction(ActionType.AddAspect, 3);
await nodesPage.actionsDropdown.insertAddAspectActionValues(actionValue, 3);
await nodesPage.actionsDropdown.selectAction(ActionType.AutoDeclareOptions, 4);
await nodesPage.actionsDropdown.insertAutoDeclareOptionsActionValues(autoDeclareOptionsValue, 4);
await nodesPage.actionsDropdown.selectAction(ActionType.SimpleWorkflow, 5);
await nodesPage.actionsDropdown.insertSimpleWorkflowActionValues(simpleWorkFlow, 5);
await nodesPage.manageRulesDialog.createRuleButton.click();
await nodesPage.manageRules.checkIfRuleIsOnTheList(randomRuleName);
});
test('[XAT-889] Create a rule which runs when items are deleted or leave a folder', async ({ nodesPage, personalFiles }) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(randomRuleName);
await nodesPage.manageRulesDialog.whenCreatedCheckbox.click();
await nodesPage.manageRulesDialog.whenDeletedCheckbox.click();
await nodesPage.actionsDropdown.selectAction(ActionType.Copy, 0);
await nodesPage.manageRulesDialog.destinationFolderButton.click();
await nodesPage.contentNodeSelectorDialog.getFolderIcon.click();
await nodesPage.contentNodeSelectorDialog.getOptionLocator(username).click();
await nodesPage.contentNodeSelectorDialog.selectDestination(folderName883_2);
await nodesPage.contentNodeSelectorDialog.actionButton.click();
await nodesPage.manageRulesDialog.createRuleButton.click();
await nodesPage.manageRules.checkIfRuleIsOnTheList(randomRuleName);
await personalFiles.navigate({ remoteUrl: `#/personal-files/${folderName883Id}` });
await personalFiles.dataTable.selectItem(copyFileName);
await personalFiles.acaHeader.clickMoreActions();
await personalFiles.acaHeader.matMenu.clickMenuItem('Delete');
await personalFiles.snackBar.message.waitFor({ state: 'visible' });
await personalFiles.navigate({ remoteUrl: `#/personal-files/${folderName883Id2}` });
await expect(personalFiles.dataTable.getRowByName(copyFileName)).toBeVisible();
});
test('[XAT-890] Create a rule which adds multiple aspects when its ran', async ({ nodesPage, personalFiles }) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(randomRuleName);
await nodesPage.actionsDropdown.selectAction(ActionType.AddAspect, 0);
await nodesPage.actionsDropdown.insertAddAspectActionValues('Controls', 0);
await nodesPage.actionsDropdown.selectAction(ActionType.AddAspect, 1);
await nodesPage.actionsDropdown.insertAddAspectActionValues('CMM', 1);
await nodesPage.actionsDropdown.selectAction(ActionType.AddAspect, 2);
await nodesPage.actionsDropdown.insertAddAspectActionValues('folder', 2);
await nodesPage.actionsDropdown.selectAction(ActionType.AddAspect, 3);
await nodesPage.actionsDropdown.insertAddAspectActionValues('site which', 3);
await nodesPage.manageRulesDialog.createRuleButton.click();
await nodesPage.manageRulesDialog.createRuleButton.waitFor({ state: 'hidden' });
await nodesPage.manageRules.getGroupsList(randomRuleName).click();
await nodesPage.manageRules.checkAspects(['sc:controlsAreClearance', 'sfdc:objectModel', 'sfdc:folder', 'sfdc:site']);
});
test('[XAT-891] Prevent rule creation after clicking on cancel during selecting destination folder', async ({ nodesPage, personalFiles }) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(randomRuleName);
await nodesPage.actionsDropdown.selectAction(ActionType.AddAspect, 0);
await nodesPage.actionsDropdown.insertAddAspectActionValues('Controls', 0);
await expect(nodesPage.manageRulesDialog.createRuleButton).toBeEnabled();
await nodesPage.actionsDropdown.selectAction(ActionType.Copy, 1);
await nodesPage.manageRulesDialog.destinationFolderButton.click();
await nodesPage.contentNodeSelectorDialog.cancelButton.click();
await expect(nodesPage.manageRulesDialog.createRuleButton).toBeDisabled();
});
test('[XAT-892] Prevent rule creation when missing any required field for action', async ({ nodesPage, personalFiles }) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(randomRuleName);
await nodesPage.actionsDropdown.selectAction(ActionType.AddAspect, 0);
await nodesPage.actionsDropdown.insertAddAspectActionValues('Controls', 0);
await expect(nodesPage.manageRulesDialog.createRuleButton).toBeEnabled();
await nodesPage.actionsDropdown.selectAction(ActionType.Copy, 1);
await expect(nodesPage.manageRulesDialog.createRuleButton).toBeDisabled();
});
test('[XAT-893] Removing values from required fields should restore disabled state for Create button', async ({ nodesPage, personalFiles }) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(randomRuleName);
await nodesPage.actionsDropdown.selectAction(ActionType.AddAspect, 0);
await nodesPage.actionsDropdown.insertAddAspectActionValues('Controls', 0);
await expect(nodesPage.manageRulesDialog.createRuleButton).toBeEnabled();
await nodesPage.actionsDropdown.insertAddAspectActionValues('None', 0);
await expect(nodesPage.manageRulesDialog.createRuleButton).toBeDisabled();
});
test('[XAT-894] Create rule with filled required fields and empty optional fields', async ({ nodesPage, personalFiles }) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(randomRuleName);
await nodesPage.actionsDropdown.selectAction(ActionType.AddAspect, 0);
await nodesPage.actionsDropdown.insertAddAspectActionValues('Controls', 0);
await expect(nodesPage.manageRulesDialog.createRuleButton).toBeEnabled();
await nodesPage.actionsDropdown.selectAction(ActionType.CheckIn, 1);
await expect(nodesPage.manageRulesDialog.createRuleButton).toBeEnabled();
});
test('[XAT-895] Create a rule with multiple conditions utilising all available comparators and conditions', async ({
personalFiles,
nodesPage
}) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(randomRuleName);
await nodesPage.conditionsDropdown.addCondition(Field.Size, specialChars, 0, Comparator.Equals);
await nodesPage.conditionsDropdown.addCondition(Field.Name, specialChars, 1, Comparator.Equals);
await nodesPage.conditionsDropdown.addCondition(Field.Encoding, specialChars, 2);
await nodesPage.conditionsDropdown.addCondition(Field.HasTag, specialChars, 3);
await nodesPage.conditionsDropdown.addCondition(Field.HasAspect, specialChars, 4);
await nodesPage.actionsDropdown.selectAction(ActionType.IncrementCounter, 0);
await nodesPage.manageRulesDialog.createRuleButton.click();
await nodesPage.manageRules.checkIfRuleIsOnTheList(randomRuleName);
});
test('[XAT-896] Create a rule with multiple groups utilising all available comparators and conditions', async ({ personalFiles, nodesPage }) => {
await personalFiles.navigate({ remoteUrl: `#/nodes/${folderName883Id}/rules` });
await nodesPage.toolbar.clickCreateRuleButton();
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(randomRuleName);
await nodesPage.conditionsDropdown.addConditionGroup(Field.Size, specialChars, 0, Comparator.Equals);
await nodesPage.conditionsDropdown.addConditionGroup(Field.Name, specialChars, 1, Comparator.Equals);
await nodesPage.conditionsDropdown.addConditionGroup(Field.Encoding, specialChars, 2);
await nodesPage.conditionsDropdown.addConditionGroup(Field.HasTag, specialChars, 3);
await nodesPage.conditionsDropdown.addConditionGroup(Field.HasAspect, specialChars, 4);
await nodesPage.actionsDropdown.selectAction(ActionType.IncrementCounter, 0);
await nodesPage.manageRulesDialog.createRuleButton.click();
await nodesPage.manageRules.checkIfRuleIsOnTheList(randomRuleName);
});
});