[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

@@ -50,13 +50,13 @@ export enum ActionType {
}
export class ActionsDropdownComponent extends BaseComponent {
private static rootElement = 'aca-rule-action-list';
private static rootElement = 'aca-edit-rule-dialog aca-rule-action-list';
private getOptionLocator = (optionName: string): Locator => this.page.locator('.mat-select-panel .mat-option-text', { hasText: optionName }).first();
private ruleActionLocator = this.getChild('aca-rule-action');
private addActionButtonLocator = this.getChild('[data-automation-id="rule-action-list-add-action-button"]');
private actionDropdownLocator = this.getChild('[data-automation-id="rule-action-select"]');
private actionAspectNameLocator = '[data-automation-id="header-aspect-name"] mat-select';
private actionAspectNameLocator = '[data-automation-id="header-aspect-name"] .adf-property-field';
private actionCheckInInputLocator = '[data-automation-id="header-description"] input';
private actionAutoDeclareLocator = '[data-automation-id="header-version"] mat-select';
private actionSimpleWorkflowStepInputLocator = '[data-automation-id="header-approve-step"] input';
@@ -85,7 +85,7 @@ export class ActionsDropdownComponent extends BaseComponent {
}
async insertCheckInActionValues(checkInValue: string, index: number): Promise<void> {
await this.ruleActionLocator.nth(index).locator(this.actionCheckInInputLocator).type(checkInValue, { delay: 50 });
await this.ruleActionLocator.nth(index).locator(this.actionCheckInInputLocator).fill(checkInValue);
}
async insertAddAspectActionValues(AspectValue: string, index: number): Promise<void> {
@@ -97,11 +97,11 @@ export class ActionsDropdownComponent extends BaseComponent {
}
async insertSimpleWorkflowActionValues(stepValue: string, index: number): Promise<void> {
await this.ruleActionLocator.nth(index).locator(this.actionSimpleWorkflowStepInputLocator).type(stepValue, { delay: 50 });
await this.ruleActionLocator.nth(index).locator(this.actionSimpleWorkflowStepInputLocator).fill(stepValue);
await this.ruleActionLocator.nth(index).locator(this.actionSimpleWorkflowApproveFolderLocator).click();
await this.page.locator(this.actionSimpleWorkflowActionChoiceLocator).click();
await this.ruleActionLocator.nth(index).locator(this.actionSimpleWorkflowLabelApproveLocator).click();
await this.ruleActionLocator.nth(index).locator(this.actionSimpleWorkflowSRejectStepLocator).type(stepValue, { delay: 50 });
await this.ruleActionLocator.nth(index).locator(this.actionSimpleWorkflowSRejectStepLocator).fill(stepValue);
await this.ruleActionLocator.nth(index).locator(this.actionSimpleWorkflowRejectFolderLocator).click();
await this.page.locator(this.actionSimpleWorkflowActionChoiceLocator).click();
}

View File

@@ -28,7 +28,11 @@ import { ManageRulesDialogComponent } from './manageRules/manage-rules-dialog.co
export enum Field {
Name = 'Name',
Size = 'Size',
Mimetype = 'Mimetype'
Mimetype = 'Mimetype',
Encoding = 'Encoding',
HasCategory = 'Has category',
HasTag = 'Has tag',
HasAspect = 'Has aspect'
}
export enum Comparator {
@@ -53,17 +57,22 @@ export class ConditionComponent extends ManageRulesDialogComponent {
await option.click();
}
async addCondition(fields: Partial<Field>, comparators: Partial<Comparator>, value: string, index: number): Promise<void> {
async addCondition(fields: Partial<Field>, value: string, index: number, comparators?: Partial<Comparator>): Promise<void> {
await this.addConditionButton.click();
await this.selectField(fields, index);
await this.selectComparator(comparators, index);
await this.valueField.nth(index).type(value);
if (comparators) {
await this.selectComparator(comparators, index);
}
await this.valueField.nth(index).fill(value);
}
async addConditionGroup(fields: Partial<Field>, comparators: Partial<Comparator>, value: string, index: number): Promise<void> {
await this.addConditionButton.nth(0).click();
async addConditionGroup(fields: Partial<Field>, value: string, index: number, comparators?: Partial<Comparator>): Promise<void> {
await this.addConditionGroupButton.last().click();
await this.addConditionButton.nth(index).click();
await this.selectField(fields, index);
await this.selectComparator(comparators, index);
await this.valueField.nth(index).type(value);
if (comparators) {
await this.selectComparator(comparators, index);
}
await this.valueField.nth(index).fill(value);
}
}

View File

@@ -28,6 +28,7 @@ import { Page } from '@playwright/test';
export class ToolbarComponent extends BaseComponent {
private static rootElement = 'adf-toolbar';
private createRuleButton = this.getChild('[data-automation-id="manage-rules-create-button"]');
private linkRulesButton = this.getChild('[data-automation-id="manage-rules-link-button"]');
constructor(page: Page) {
super(page, ToolbarComponent.rootElement);
@@ -36,4 +37,8 @@ export class ToolbarComponent extends BaseComponent {
async clickCreateRuleButton(): Promise<void> {
await this.createRuleButton.click();
}
async clickLinkRulesButton(): Promise<void> {
await this.linkRulesButton.click();
}
}

View File

@@ -22,7 +22,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Locator, Page } from '@playwright/test';
import { Locator, Page, expect } from '@playwright/test';
import { BaseComponent } from '../base.component';
export class ContentNodeSelectorDialog extends BaseComponent {
@@ -40,13 +40,13 @@ export class ContentNodeSelectorDialog extends BaseComponent {
private getRowByName = (name: string | number): Locator => this.getChild(`adf-datatable-row`, { hasText: name.toString() });
getDialogTitle = (text: string) => this.getChild('[data-automation-id="content-node-selector-title"]', { hasText: text });
getBreadcrumb = (text: string) => this.getChild('[data-automation-id="current-folder"]', { hasText: text });
getFolderIcon = this.getChild('mat-icon[role="img"]', { hasText: "folder" });
getFolderIcon = this.getChild('[data-automation-id="dropdown-breadcrumb-trigger"]');
loadMoreButton = this.getChild('[data-automation-id="adf-infinite-pagination-button"]');
async loadMoreNodes(): Promise<void> {
await this.spinnerWaitForReload();
while (await this.loadMoreButton.isVisible()) {
await this.loadMoreButton.click();
await this.loadMoreButton.click();
}
}
@@ -59,8 +59,17 @@ export class ContentNodeSelectorDialog extends BaseComponent {
async selectDestination(folderName: string): Promise<void> {
const row = this.getRowByName(folderName);
await row.click();
await this.selectedRow.waitFor({ state: 'attached' });
await this.selectedRow.isVisible();
await expect(row).toBeVisible();
await row.click({ trial: true });
await expect(async () => {
await row.hover({ timeout: 1000 });
await row.click();
await expect(this.selectedRow).toBeVisible();
}).toPass({
intervals: [2_000, 2_000, 2_000, 2_000, 2_000, 2_000, 2_000],
timeout: 20_000
});
}
}

View File

@@ -34,3 +34,4 @@ export * from './upload-new-version-dialog.component';
export * from './manage-versions-dialog.component';
export * from './upload-dialog.component';
export * from './delete-trash-dialog.component';
export * from './link-rules.component';

View File

@@ -0,0 +1,64 @@
/*!
* 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
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Locator, Page, expect } from '@playwright/test';
import { BaseComponent } from '../base.component';
export class LinkRulesDialog extends BaseComponent {
private static rootElement = 'aca-rule-set-picker';
constructor(page: Page) {
super(page, LinkRulesDialog.rootElement);
}
cancelButton = this.getChild('[data-automation-id="content-node-selector-actions-cancel"]');
selectFolderButton = this.getChild('button', { hasText: ' Select folder ' });
emptyLinkRules = this.getChild('.adf-empty-content__title');
getOptionLocator = (optionName: string): Locator => this.page.locator('.mat-select-panel .mat-option-text', { hasText: optionName });
private getRowByName = (name: string | number): Locator => this.getChild(`adf-datatable-row`, { hasText: name.toString() });
getDialogTitle = (text: string) => this.getChild('[data-automation-id="content-node-selector-title"]', { hasText: text });
getBreadcrumb = (text: string) => this.getChild('[data-automation-id="current-folder"]', { hasText: text });
getFolderIcon = this.getChild('.adf-dropdown-breadcrumb-icon', { hasText: 'folder' });
getLibraryIcon = this.getChild('.adf-empty-content__icon', { hasText: 'library_books' });
async selectDestination(folderName: string): Promise<void> {
const row = this.getRowByName(folderName);
await expect(row).toBeVisible();
await row.click({ trial: true });
await expect(async () => {
await row.hover({ timeout: 1000 });
await row.click();
await expect(this.selectFolderButton).toBeEnabled();
}).toPass({
intervals: [2_000, 2_000, 2_000, 2_000, 2_000, 2_000, 2_000],
timeout: 20_000
});
}
async waitForLinkRules(): Promise<void> {
await this.getLibraryIcon.waitFor();
}
}

View File

@@ -29,15 +29,23 @@ export class ManageRulesDialogComponent extends BaseComponent {
private static rootElement = 'aca-edit-rule-dialog';
public createRuleButton = this.getChild('[data-automation-id="edit-rule-dialog-submit"]');
public cancelRuleButton = this.getChild('.aca-edit-rule-dialog__footer button').filter({ hasText: 'Cancel' });
public ruleNameInputLocator = this.getChild('[id="rule-details-name-input"]');
public ruleDescriptionInputLocator = this.getChild('[id="rule-details-description-textarea"]');
public addConditionButton = this.getChild('[data-automation-id="add-condition-button"]');
public addConditionGroupButton = this.getChild('[data-automation-id="add-group-button"]');
public fieldDropDown = this.getChild('[data-automation-id="field-select"]');
public comparatorDropDown = this.getChild('[data-automation-id="comparator-select"]');
public valueField = this.getChild('[data-automation-id="value-input"]');
public whenCreatedCheckbox = this.getChild('[data-automation-id="rule-trigger-checkbox-inbound"]');
public whenUpdatedCheckbox = this.getChild('[data-automation-id="rule-trigger-checkbox-update"]');
public whenDeletedCheckbox = this.getChild('[data-automation-id="rule-trigger-checkbox-outbound"]');
public destinationFolderButton = this.getChild('[data-automation-id="card-textitem-clickable-icon-destination-folder"]');
public ruleInBackgroundCheckbox = this.getChild('[data-automation-id="rule-option-checkbox-asynchronous"]');
public ruleSubfoldersCheckbox = this.getChild('[data-automation-id="rule-option-checkbox-inheritable"]');
public ruleDisableCheckbox = this.getChild('[data-automation-id="rule-option-checkbox-disabled"]');
constructor(page: Page) {
super(page, ManageRulesDialogComponent.rootElement);
}
}

View File

@@ -22,7 +22,7 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { Locator, Page } from '@playwright/test';
import { Locator, Page, expect } from '@playwright/test';
import { BaseComponent } from '../base.component';
export class ManageRules extends BaseComponent {
@@ -31,8 +31,29 @@ export class ManageRules extends BaseComponent {
public getGroupsList = (optionName: string): Locator => this.getChild('.aca-rule-list-item__header', { hasText: optionName });
public ruleToggle = this.getChild('.aca-manage-rules__container .mat-slide-toggle-bar').first();
public ruleToggleFalse = this.getChild('aca-rule-list-grouping input[type="checkbox"][aria-checked="false"]').first();
public ruleDetailsTitle = this.getChild('.aca-manage-rules__container__rule-details__header__title__name');
public ruleDetailsTrashButton = this.getChild('#delete-rule-btn');
public ruleDetailsEditButton = this.getChild('#edit-rule-btn');
public ruleDetailsWhenText = this.getChild('[data-automation-id="rule-details-triggers-component"]');
public ruleDetailsPerformActionsDiv = this.getChild('adf-card-view-textitem mat-form-field input');
public rulesEmptyListTitle = this.getChild('.adf-empty-content__title');
constructor(page: Page) {
super(page, ManageRules.rootElement);
}
async checkAspects(aspects: string[]): Promise<void> {
for (let i = 0; i < aspects.length; i++) {
const aspectsActions = await this.ruleDetailsPerformActionsDiv.nth(i).inputValue();
expect(aspects).toContain(aspectsActions);
}
}
async checkIfRuleListEmpty(): Promise<boolean> {
return await this.rulesEmptyListTitle.isVisible();
}
async checkIfRuleIsOnTheList(ruleName: string): Promise<void> {
await expect(this.getGroupsList(ruleName)).toBeVisible({ timeout: 5000 });
}
}

View File

@@ -23,10 +23,17 @@
*/
import { Page } from '@playwright/test';
import { ConditionComponent, ManageRules, ManageRulesDialogComponent, ToolbarComponent, ActionsDropdownComponent } from '../components';
import {
ConditionComponent,
ManageRules,
ManageRulesDialogComponent,
ToolbarComponent,
ActionsDropdownComponent,
ContentNodeSelectorDialog,
LinkRulesDialog
} from '../components';
import { BasePage } from './base.page';
export class NodesPage extends BasePage {
private static pageUrl = 'nodes';
@@ -39,4 +46,6 @@ export class NodesPage extends BasePage {
public actionsDropdown = new ActionsDropdownComponent(this.page);
public conditionsDropdown = new ConditionComponent(this.page);
public manageRules = new ManageRules(this.page);
public contentNodeSelectorDialog = new ContentNodeSelectorDialog(this.page);
public linkRulesDialog = new LinkRulesDialog(this.page);
}