[ACS-5519] viewer-general tests Playwright (#3327)

* [ACS-5519] view general tests Playwright

* [ACS-5519] remove same function call
This commit is contained in:
Akash Rathod
2023-07-11 19:54:58 +02:00
committed by GitHub
parent b192c5f6bb
commit 5abbda78a3
32 changed files with 901 additions and 101 deletions

View File

@@ -22,14 +22,16 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { BaseComponent } from './base.component';
import { Page } from '@playwright/test';
import { BaseComponent } from './base.component';
import { Page } from '@playwright/test';
export class AcaHeader extends BaseComponent {
private static rootElement = 'adf-toolbar';
public createButton = this.getChild('[id="app.toolbar.create"]');
export class AcaHeader extends BaseComponent {
private static rootElement = 'adf-toolbar';
public createButton = this.getChild('[id="app.toolbar.create"]');
public viewButton = this.getChild('button[title="View"]');
public searchButton = this.getChild('button[title="Search"]');
constructor(page: Page) {
super(page, AcaHeader.rootElement);
}
}
constructor(page: Page) {
super(page, AcaHeader.rootElement);
}
}

View File

@@ -77,7 +77,7 @@ export class ActionsDropdownComponent extends BaseComponent {
await this.actionDropdownLocator.nth(index).click();
await this.spinnerWaitForReload();
const option = this.getOptionLocator(action);
await option.click();
await option.nth(0).click();
}
async dropdownSelection(selectValue: string, locator: string, index: number): Promise<void> {

View File

@@ -50,13 +50,13 @@ export abstract class BaseComponent extends PlaywrightBase {
async closeAdditionalOverlayElementIfVisible(): Promise<void> {
if (await this.overlayElement.isVisible()) {
await this.page.keyboard.press('Escape');
await this.overlayElement.waitFor({ state: 'detached', timeout: 5000 });
await this.overlayElement.waitFor({ state: 'detached', timeout: timeouts.medium });
}
}
async spinnerWaitForReload(): Promise<void> {
try {
await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: timeouts.short });
await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: timeouts.normal });
await this.page.locator('mat-progress-spinner').waitFor({ state: 'detached', timeout: timeouts.normal });
} catch (e) {
this.logger.info('Spinner was not present');

View File

@@ -155,6 +155,17 @@ export class DataTableComponent extends BaseComponent {
}
}
/**
* This method is used when we want to perform double click on the dataTable row to open a file or folder
*
* @param name of the data table element with which we want to double click
*/
async performClickFolderOrFileToOpen(name: string): Promise<void> {
await this.goThroughPagesLookingForRowWithName(name);
await this.getCellLinkByName(name).click();
await this.spinnerWaitForReload();
}
async getActionLocatorFromExpandableMenu(name: string | number, action: string): Promise<Locator> {
await this.getRowByName(name).click({ button: 'right' });
return this.contextMenuActions.getButtonByText(action);
@@ -180,4 +191,17 @@ export class DataTableComponent extends BaseComponent {
await this.spinnerWaitForReload();
}
}
async selectItem(name: string): Promise<void> {
const isSelected = await this.hasCheckMarkIcon(name);
if (!isSelected) {
const row = await this.getRowByName(name);
await row.locator('.mat-checkbox[id*="mat-checkbox"]').check();
}
}
async hasCheckMarkIcon(itemName: string): Promise<boolean> {
const row = this.getRowByName(itemName);
return await row.locator('.mat-checkbox[class*="checked"]').isVisible();
}
}

View File

@@ -31,4 +31,6 @@ export * from './spinner.component';
export * from './actions-dropdown.component';
export * from './conditions.component';
export * from './pagination.component';
export * from './viewer.component';
export * from './search/search-input.component';
export * from './search/search-overlay.components';

View File

@@ -0,0 +1,51 @@
/*!
* Copyright © 2005-2023 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 { Locator, Page } from '@playwright/test';
import { BaseComponent } from '.././base.component';
import { timeouts } from '../../../utils';
export class SearchInputComponent extends BaseComponent {
private static rootElement = 'aca-page-layout';
public searchButton = this.getChild('aca-search-input .app-search-button');
/**
* Method used in cases where user have possibility to navigate "inside" the element (it's clickable and has link attribute).
* Perform action .click() to navigate inside it
*
* @returns reference to cell element which contains link.
*/
getCellLinkByName = (name: string): Locator => this.getChild('.adf-datatable-row[role="row"]', { hasText: name });
constructor(page: Page, rootElement = SearchInputComponent.rootElement) {
super(page, rootElement);
}
async performDoubleClickFolderOrFileToOpen(name: string): Promise<void> {
await this.getCellLinkByName(name).waitFor({ state:'visible', timeout: timeouts.normal });
await this.getCellLinkByName(name).dblclick();
await this.spinnerWaitForReload();
}
}

View File

@@ -0,0 +1,50 @@
/*!
* Copyright © 2005-2023 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 { Page } from '@playwright/test';
import { BaseComponent } from '.././base.component';
export class SearchOverlayComponent extends BaseComponent {
private static rootElement = '.cdk-overlay-pane';
public searchFilesOption = this.getChild('label[for="content-input"]');
public searchFoldersOption = this.getChild('label[for="folder-input"]');
public searchLibrariesOption = this.getChild('label[for="libraries-input"]');
public searchInput = this.getChild('input[id="app-control-input"]');
public searchButton = this.getChild('.app-search-button');
constructor(page: Page, rootElement = SearchOverlayComponent.rootElement) {
super(page, rootElement);
}
async checkFilesAndFolders(): Promise<void> {
await this.searchFilesOption.click();
await this.searchFoldersOption.click();
}
async searchFor(input: string): Promise<void> {
await this.searchInput.fill(input);
await this.searchButton.click();
}
}

View File

@@ -0,0 +1,61 @@
/*!
* Copyright © 2005-2023 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 { Page } from '@playwright/test';
import { BaseComponent } from './base.component';
import { AcaHeader } from './aca-header.component';
import { timeouts } from '../../utils';
export class ViewerComponent extends BaseComponent {
private static rootElement = 'adf-viewer';
private viewerLocator = this.getChild('.adf-viewer-render-layout-content');
public closeButtonLocator = this.getChild('.adf-viewer-close-button');
public fileTitleButtonLocator = this.getChild('.adf-viewer__file-title');
toolbar = new AcaHeader(this.page);
constructor(page: Page) {
super(page, ViewerComponent.rootElement);
}
async isViewerOpened(): Promise<boolean> {
return await this.viewerLocator.isVisible();
}
async isCloseButtonDisplayed(): Promise<boolean> {
await this.closeButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal });
return await this.closeButtonLocator.isEnabled({ timeout: timeouts.normal });
}
async isFileTitleDisplayed(): Promise<boolean> {
await this.fileTitleButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal });
return await this.fileTitleButtonLocator.isVisible();
}
async getCloseButtonTooltip(): Promise<string> {
await this.closeButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal });
return await this.closeButtonLocator.getAttribute('title');
}
}