[ACS-5923] playwright sidenav and single click test (#3442)

* [ACS-5923] sidenav and singleclick test

* remove protractor test and fix flaky test

* test fix

* Update error message for expect
This commit is contained in:
Akash Rathod
2023-09-25 13:00:22 +02:00
committed by GitHub
parent 2157e8e031
commit 97f01386f8
21 changed files with 435 additions and 294 deletions

View File

@@ -23,11 +23,12 @@
*/
import { BaseComponent } from '.././base.component';
import { Page } from '@playwright/test';
import { Locator, Page } from '@playwright/test';
export class Breadcrumb extends BaseComponent {
private static rootElement = 'adf-breadcrumb';
public items = this.getChild('.adf-breadcrumb-item');
public currentItem = this.getChild('.adf-breadcrumb-item-current');
getItemByTitle = (name: string): Locator => this.getChild(`.adf-breadcrumb-item[title=${name}]`);
constructor(page: Page) {
super(page, Breadcrumb.rootElement);

View File

@@ -113,6 +113,8 @@ export class DataTableComponent extends BaseComponent {
getColumnHeaderByTitleLocator = (headerTitle: string): Locator => this.getChild('[role="columnheader"]', { hasText: headerTitle });
getSearchResultLinkByName = (name: string): Locator => this.getChild('.aca-search-results-row span[role="link"]', { hasText: name });
async sortBy(columnTitle: string, order: 'Ascending' | 'Descending'): Promise<void> {
const columnHeaderLocator = this.getColumnHeaderByTitleLocator(columnTitle);
await this.spinnerWaitForReload();

View File

@@ -36,3 +36,4 @@ export * from './viewer.component';
export * from './search/search-input.component';
export * from './search/search-overlay.components';
export * from './breadcrumb/breadcrumb.component';
export * from './sidenav.component';

View File

@@ -29,6 +29,7 @@ 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');
getIconByName = (name: string): Locator => this.getChild('.mat-icon', { hasText: name });
/**
* Method used in cases where user have possibility to navigate "inside" the element (it's clickable and has link attribute).
@@ -43,9 +44,8 @@ export class SearchInputComponent extends BaseComponent {
}
async performDoubleClickFolderOrFileToOpen(name: string): Promise<void> {
await this.getCellLinkByName(name).waitFor({ state:'visible', timeout: timeouts.normal });
await this.getCellLinkByName(name).waitFor({ state: 'visible', timeout: timeouts.normal });
await this.getCellLinkByName(name).dblclick();
await this.spinnerWaitForReload();
}
}

View File

@@ -0,0 +1,97 @@
/*!
* 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 { SIDEBAR_LABELS } from '../../utils';
import { BaseComponent } from './base.component';
import { Locator, Page } from '@playwright/test';
export class SidenavComponent extends BaseComponent {
private static rootElement = 'app-sidenav';
private personalFiles = this.getChild(`[data-automation-id='app.navbar.personalFiles']`);
private fileLibraries = this.getChild(`[data-automation-id='app.navbar.libraries.menu']`);
private myLibraries = this.getChild(`[data-automation-id='app.navbar.libraries.files']`);
private favoriteLibraries = this.getChild(`[data-automation-id='app.navbar.libraries.favorite']`);
private shared = this.getChild(`[data-automation-id='app.navbar.shared']`);
private recentFiles = this.getChild(`[data-automation-id='app.navbar.recentFiles']`);
private favorites = this.getChild(`[data-automation-id='app.navbar.favorites']`);
private trash = this.getChild(`[data-automation-id='app.navbar.trashcan']`);
private sidenavToggle = this.getChild(`.sidenav-header-title-logo`);
private sidenavExpand = this.page.getByTitle('Expand navigation menu');
public expandedSidenav = this.page.locator(`[data-automation-id='expanded']`);
constructor(page: Page) {
super(page, SidenavComponent.rootElement);
}
async isActive(name: string): Promise<boolean> {
const cssClass = await this.getLinkLabel(name).getAttribute('class');
return cssClass.includes('action-button--active');
}
async openPanel(name: string): Promise<void> {
await this.getLinkLabel(name).click();
}
private getLinkLabel(name: string): Locator {
switch (name) {
case SIDEBAR_LABELS.PERSONAL_FILES:
return this.personalFiles;
case SIDEBAR_LABELS.MY_LIBRARIES:
return this.myLibraries;
case SIDEBAR_LABELS.FAVORITE_LIBRARIES:
return this.favoriteLibraries;
case SIDEBAR_LABELS.SHARED_FILES:
return this.shared;
case SIDEBAR_LABELS.RECENT_FILES:
return this.recentFiles;
case SIDEBAR_LABELS.FAVORITES:
return this.favorites;
case SIDEBAR_LABELS.TRASH:
return this.trash;
default:
return this.personalFiles;
}
}
async isSidenavExpanded(): Promise<boolean> {
return this.expandedSidenav.isVisible();
}
async expandSideNav(): Promise<void> {
const expanded = await this.isSidenavExpanded();
if (!expanded) {
await this.sidenavExpand.click();
await this.expandedSidenav.waitFor({ state: 'attached' });
}
}
async collapseSideNav(): Promise<void> {
const expanded = await this.isSidenavExpanded();
if (expanded) {
await this.sidenavToggle.click();
await this.expandedSidenav.waitFor({ state: 'detached' });
}
}
}

View File

@@ -0,0 +1,45 @@
/*!
* 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 { BasePage } from './base.page';
import { DataTableComponent, MatMenuComponent, SidenavComponent, ViewerComponent } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent, ViewerOverlayDialogComponent } from '../components/dialogs';
export class FavoritesLibrariesPage extends BasePage {
private static pageUrl = 'favorite/libraries';
constructor(page: Page) {
super(page, FavoritesLibrariesPage.pageUrl);
}
public acaHeader = new AcaHeader(this.page);
public matMenu = new MatMenuComponent(this.page);
public folderDialog = new AdfFolderDialogComponent(this.page);
public dataTable = new DataTableComponent(this.page);
public viewer = new ViewerComponent(this.page);
public viewerDialog = new ViewerOverlayDialogComponent(this.page);
public sidenav = new SidenavComponent(this.page);
}

View File

@@ -24,7 +24,7 @@
import { Page } from '@playwright/test';
import { BasePage } from './base.page';
import { DataTableComponent, MatMenuComponent, ViewerComponent } from '../components';
import { DataTableComponent, MatMenuComponent, ViewerComponent, SidenavComponent } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent, ViewerOverlayDialogComponent } from '../components/dialogs';
@@ -41,4 +41,5 @@ export class FavoritesPage extends BasePage {
public dataTable = new DataTableComponent(this.page);
public viewer = new ViewerComponent(this.page);
public viewerDialog = new ViewerOverlayDialogComponent(this.page);
public sidenav = new SidenavComponent(this.page);
}

View File

@@ -32,3 +32,4 @@ export * from './shared.page';
export * from './search.page';
export * from './favorites.page';
export * from './trash.page';
export * from './favorites-libraries.page';

View File

@@ -33,7 +33,8 @@ import {
ViewerComponent,
ViewerOverlayDialogComponent,
ContentNodeSelectorDialog,
Breadcrumb
Breadcrumb,
SidenavComponent
} from '../components';
export class MyLibrariesPage extends BasePage {
@@ -51,6 +52,7 @@ export class MyLibrariesPage extends BasePage {
public viewerDialog = new ViewerOverlayDialogComponent(this.page);
public copyMoveDialog = new ContentNodeSelectorDialog(this.page);
public breadcrumb = new Breadcrumb(this.page);
public sidenav = new SidenavComponent(this.page);
async selectCreateLibrary(): Promise<void> {
await this.acaHeader.createButton.click();

View File

@@ -24,7 +24,7 @@
import { Page } from '@playwright/test';
import { BasePage } from './base.page';
import { Breadcrumb, DataTableComponent, MatMenuComponent, ViewerComponent } from '../components';
import { Breadcrumb, DataTableComponent, MatMenuComponent, ViewerComponent, SidenavComponent } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent, PasswordOverlayDialogComponent, ViewerOverlayDialogComponent } from '../components/dialogs';
@@ -43,6 +43,7 @@ export class PersonalFilesPage extends BasePage {
public passwordDialog = new PasswordOverlayDialogComponent(this.page);
public viewerDialog = new ViewerOverlayDialogComponent(this.page);
public breadcrumb = new Breadcrumb(this.page);
public sidenav = new SidenavComponent(this.page);
async selectCreateFolder(): Promise<void> {
await this.acaHeader.createButton.click();

View File

@@ -22,10 +22,9 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { Page } from '@playwright/test';
import { BasePage } from './base.page';
import { DataTableComponent, MatMenuComponent, ViewerComponent } from '../components';
import { DataTableComponent, MatMenuComponent, ViewerComponent, SidenavComponent } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent } from '../components/dialogs';
@@ -41,4 +40,5 @@ export class RecentFilesPage extends BasePage {
public folderDialog = new AdfFolderDialogComponent(this.page);
public dataTable = new DataTableComponent(this.page);
public viewer = new ViewerComponent(this.page);
public sidenav = new SidenavComponent(this.page);
}

View File

@@ -24,7 +24,7 @@
import { Page } from '@playwright/test';
import { BasePage } from './base.page';
import { DataTableComponent, MatMenuComponent, ViewerComponent, SearchInputComponent, SearchOverlayComponent } from '../components';
import { DataTableComponent, MatMenuComponent, ViewerComponent, SearchInputComponent, SearchOverlayComponent, SidenavComponent } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent } from '../components/dialogs';
@@ -42,4 +42,5 @@ export class SearchPage extends BasePage {
public viewer = new ViewerComponent(this.page);
public searchInput = new SearchInputComponent(this.page);
public searchOverlay = new SearchOverlayComponent(this.page);
public sidenav = new SidenavComponent(this.page);
}

View File

@@ -24,7 +24,7 @@
import { Page } from '@playwright/test';
import { BasePage } from './base.page';
import { DataTableComponent, MatMenuComponent, ViewerComponent } from '../components';
import { DataTableComponent, MatMenuComponent, ViewerComponent, SidenavComponent } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent, ViewerOverlayDialogComponent } from '../components/dialogs';
@@ -41,4 +41,5 @@ export class SharedPage extends BasePage {
public dataTable = new DataTableComponent(this.page);
public viewer = new ViewerComponent(this.page);
public viewerDialog = new ViewerOverlayDialogComponent(this.page);
public sidenav = new SidenavComponent(this.page);
}

View File

@@ -24,7 +24,7 @@
import { Page } from '@playwright/test';
import { BasePage } from './base.page';
import { DataTableComponent, MatMenuComponent, ViewerComponent } from '../components';
import { DataTableComponent, MatMenuComponent, ViewerComponent, SidenavComponent } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent, ViewerOverlayDialogComponent } from '../components/dialogs';
@@ -41,4 +41,5 @@ export class TrashPage extends BasePage {
public dataTable = new DataTableComponent(this.page);
public viewer = new ViewerComponent(this.page);
public viewerDialog = new ViewerOverlayDialogComponent(this.page);
public sidenav = new SidenavComponent(this.page);
}

View File

@@ -0,0 +1,45 @@
/*!
* 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
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export const APP_ROUTES = {
FAVORITES: '/favorites',
MY_LIBRARIES: '/libraries',
FAVORITE_LIBRARIES: '/favorite/libraries',
LOGIN: '/login',
LOGOUT: '/logout',
PERSONAL_FILES: '/personal-files',
RECENT_FILES: '/recent-files',
SHARED_FILES: '/shared',
TRASHCAN: '/trashcan'
};
export const SIDEBAR_LABELS = {
PERSONAL_FILES: 'Personal Files',
MY_LIBRARIES: 'My Libraries',
FAVORITE_LIBRARIES: 'Favorite Libraries',
SHARED_FILES: 'Shared',
RECENT_FILES: 'Recent Files',
FAVORITES: 'Favorites',
TRASH: 'Trash'
};

View File

@@ -29,3 +29,4 @@ export * from './state-helper';
export * from './folder-errors';
export * from './utils';
export * from './library-errors';
export * from './config';