[ACS-5014] Migrated Copy Move actions E2Es from protractor to playwright (#3531)

* [ACS-5014] Added Playwright E2E tests for copy-move actions

* [ACS-5014] Fixed missing import in tsconfig.e2e.json

* [ACS-5014] Removed unneeded method from utils.ts

* [ACS-5014] Updated playwright.config.ts

* [ACS-5014] Copy and Move tests are now working

* [ACS-5014] Removed unneeded test.only

* [ACS-5014] Added test case IDs to E2E tests

* [ACS-6211] Removed TODO note. Removed protractor test case files

* [ACS-5014] Added E2E tests for Destination Picker in copy-move actions

* [ACS-5014] Removed unneded only from test suite

* [ACS-5014] Updated import of logger from @alfresco/adf-cli to @alfresco/adf-testing

* [ACS-5014] Addressed code review findings. Moved objects to beforeAll/beforeEach wherever applicable. Added missing await.

* [ACS-5014] Addressed code review findings. Removed unused methods/objects from content-node-selector-dialog.ts

* [ACS-5014] Addressed code review findings. Removed unused methods/objects from content-node-selector-dialog.ts

* [ACS-5014] SonarLint fix

* [ACS-5014] Fixed breaking change for other E2Es

* [ACS-5014] Updated E2Es to use correct locator for more actions button
This commit is contained in:
swapnil-verma-gl
2023-12-06 16:01:48 +05:30
committed by GitHub
parent 5062220056
commit f917a663b7
18 changed files with 696 additions and 1137 deletions

View File

@@ -192,18 +192,22 @@ export class DataTableComponent extends BaseComponent {
return null;
}
if ((await this.pagination.currentPageLocator.textContent()) !== ' Page 1 ') {
await this.pagination.navigateToPage(1);
}
const maxPages = (await this.pagination.totalPageLocator.textContent()).match(/\d/)[0];
for (let page = 1; page <= Number(maxPages); page++) {
if (await this.getRowByName(name).isVisible()) {
break;
if (await this.pagination.currentPageLocator.isVisible()) {
if ((await this.pagination.currentPageLocator.textContent()) !== ' Page 1 ') {
await this.pagination.navigateToPage(1);
}
}
if (await this.pagination.totalPageLocator.isVisible()) {
const maxPages = (await this.pagination.totalPageLocator?.textContent())?.match(/\d/)[0];
for (let page = 1; page <= Number(maxPages); page++) {
if (await this.getRowByName(name).isVisible()) {
break;
}
if (await this.pagination.getArrowLocatorFor(PaginationActionsType.NextPageSelector).isEnabled()) {
await this.pagination.getArrowLocatorFor(PaginationActionsType.NextPageSelector).click();
}
await this.spinnerWaitForReload();
}
await this.pagination.getArrowLocatorFor(PaginationActionsType.NextPageSelector).isEnabled();
await this.pagination.getArrowLocatorFor(PaginationActionsType.NextPageSelector).click();
await this.spinnerWaitForReload();
}
}

View File

@@ -38,7 +38,7 @@ export class ContentNodeSelectorDialog extends BaseComponent {
private selectedRow = this.getChild('.adf-is-selected');
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('.mat-dialog-title', { hasText: text });
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" });

View File

@@ -28,7 +28,11 @@ import { BaseComponent } from '../base.component';
export class SnackBarComponent extends BaseComponent {
private static rootElement = 'adf-snackbar-content';
public message = this.getChild(' [data-automation-id=\'adf-snackbar-message-content\']').first();
public message = this.getChild('[data-automation-id="adf-snackbar-message-content"]').first();
public actionButton = this.getChild('[data-automation-id="adf-snackbar-message-content-action-button"]')
public closeIcon = this.getChild('.adf-snackbar-message-content-action-icon');
public getByMessageLocator = (message: string) => this.getChild(`[data-automation-id='adf-snackbar-message-content']`,
{ hasText: message }).first();

View File

@@ -63,4 +63,9 @@ export class MyLibrariesPage extends BasePage {
await this.acaHeader.createButton.click();
await this.matMenu.createLibrary.click();
}
async clickMoreActionsButton(buttonLabel: string): Promise<void> {
await this.acaHeader.clickMoreActions();
await this.matMenu.clickMenuItem(buttonLabel);
}
}

View File

@@ -71,4 +71,20 @@ export class PersonalFilesPage extends BasePage {
async waitForPageLoad() {
await this.page.waitForURL(`**/${PersonalFilesPage.pageUrl}`);
}
async clickMoreActionsButton(buttonLabel: string): Promise<void> {
await this.acaHeader.clickMoreActions();
await this.matMenu.clickMenuItem(buttonLabel);
}
async copyOrMoveContentInDatatable(sourceFileList: string[], destinationName: string, operation = 'Copy'): Promise<void> {
await this.page.keyboard.down('Control');
for (const sourceName of sourceFileList) {
await this.dataTable.selectItem(sourceName);
}
await this.page.keyboard.up('Control');
await this.clickMoreActionsButton(operation);
await this.contentNodeSelector.selectDestination(destinationName);
await this.contentNodeSelector.actionButton.click();
}
}

View File

@@ -24,24 +24,19 @@
import { by, browser, protractor } from 'protractor';
import { GenericDialog } from '../dialog/generic-dialog';
import { isPresentAndDisplayed, waitForStaleness, waitForPresence, isPresentAndEnabled } from '../../utilities/utils';
import { DropDownBreadcrumb } from '../breadcrumb/dropdown-breadcrumb';
import { waitForStaleness, waitForPresence } from '../../utilities/utils';
import { DataTable } from '../data-table/data-table';
import { BrowserActions } from '@alfresco/adf-testing';
export class ContentNodeSelectorDialog extends GenericDialog {
cancelButton = this.childElement(by.css('[data-automation-id="content-node-selector-actions-cancel"]'));
copyButton = this.childElement(by.cssContainingText('[data-automation-id="content-node-selector-actions-choose"]', 'Copy'));
moveButton = this.childElement(by.cssContainingText('[data-automation-id="content-node-selector-actions-choose"]', 'Move'));
locationDropDown = this.rootElem.element(by.id('site-dropdown-container'));
locationPersonalFiles = browser.element(by.cssContainingText('.mat-option .mat-option-text', 'Personal Files'));
locationFileLibraries = browser.element(by.cssContainingText('.mat-option .mat-option-text', 'My Libraries'));
searchInput = this.rootElem.element(by.css('#searchInput'));
toolbarTitle = this.rootElem.element(by.css('.adf-toolbar-title'));
breadcrumb = new DropDownBreadcrumb();
dataTable = new DataTable('.adf-content-node-selector-dialog');
constructor() {
@@ -74,25 +69,9 @@ export class ContentNodeSelectorDialog extends GenericDialog {
await waitForPresence(browser.element(by.css('.adf-is-selected')));
}
async isSelectLocationDropdownDisplayed(): Promise<boolean> {
return isPresentAndDisplayed(this.locationDropDown);
}
async isCopyButtonEnabled(): Promise<boolean> {
return isPresentAndEnabled(this.copyButton);
}
async isCancelButtonEnabled(): Promise<boolean> {
return isPresentAndEnabled(this.cancelButton);
}
async searchFor(text: string): Promise<void> {
await BrowserActions.clearWithBackSpace(this.searchInput);
await this.searchInput.sendKeys(text);
await this.searchInput.sendKeys(protractor.Key.ENTER);
}
async getToolbarTitle(): Promise<string> {
return this.toolbarTitle.getText();
}
}