[ACS-6456] Migrated Share File e2es to Playwright (#3565)

* [AACS-6456] migrated share-file e2es to playwright

* [ACS-6456] fixed code smells and removed duplication

* [ACS-6456] cleanup, addressed review comments

* [ACS-6456] addressed review comments

* [ACS-6456] added return types, fixed typos
This commit is contained in:
SheenaMalhotra182
2023-12-23 01:07:48 +05:30
committed by GitHub
parent 683138ced1
commit 373a41bd16
11 changed files with 457 additions and 271 deletions

View File

@@ -37,6 +37,7 @@ export class AcaHeader extends BaseComponent {
public fullScreenButton = this.getChild('button[id="app.viewer.fullscreen"]');
public shareButton = this.getChild('button[id="share-action-button"]');
public downloadButton = this.getChild('button[id="app.viewer.download"]');
public sharedDownloadButton = this.getChild('button[id="app.viewer.shared.download"]');
constructor(page: Page) {
super(page, AcaHeader.rootElement);

View File

@@ -0,0 +1,58 @@
/*!
* 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/>.
*/
import { Page } from '@playwright/test';
import { BaseComponent } from '../base.component';
export class DateTimePicker extends BaseComponent {
private static rootElement = '.mat-calendar';
calendar = this.getChild('.mat-datepicker-popup');
dayPicker = this.getChild('mat-month-view');
nextMonthBtn = this.getChild('.mat-calendar-next-button');
rootElemLocator = this.page.locator('.mat-datepicker-popup');
constructor(page: Page) {
super(page, DateTimePicker.rootElement);
}
async isCalendarOpen(): Promise<boolean> {
const element = this.rootElemLocator;
return element.isVisible();
}
async pickDateTime(): Promise<void> {
const today = new Date();
const nextAvailableDay = new Date();
nextAvailableDay.setDate(today.getDate() + 2);
if (nextAvailableDay.getMonth() !== today.getMonth()) {
await this.nextMonthBtn.click();
}
await this.selectDay(nextAvailableDay.getDate());
}
async selectDay(day: number): Promise<void> {
const firstActiveDayElem = this.dayPicker.locator(`text=${day}`).first();
await firstActiveDayElem.click();
}
}

View File

@@ -29,3 +29,4 @@ export * from './viewer-overlay-dialog.component';
export * from './content-node-selector-dialog';
export * from './create-from-template-dialog-component';
export * from './adf-confirm-dialog.component';
export * from './share-dialog.component';

View File

@@ -0,0 +1,101 @@
/*!
* 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/>.
*/
import { ElementHandle, Locator, Page } from '@playwright/test';
import { BaseComponent } from '../base.component';
import { timeouts } from '../../../utils';
import { DateTimePicker } from '../datetime-picker/datetime-picker.component';
export class ShareDialogComponent extends BaseComponent {
private static rootElement = 'adf-share-dialog';
constructor(page: Page) {
super(page, ShareDialogComponent.rootElement);
}
closeButton = this.getChild('[data-automation-id="adf-share-dialog-close"]');
dialogTitle = this.getChild('[data-automation-id="adf-share-dialog-title"]');
infoText = this.getChild('.adf-share-link__info').first();
labels = '.adf-share-link__label';
shareToggle = this.getChild(`[data-automation-id='adf-share-toggle']`);
url = this.getChild(`[data-automation-id='adf-share-link']`);
urlAction = this.getChild('.adf-input-action');
expireToggle = this.getChild(`[data-automation-id='adf-expire-toggle']`);
expireInput = this.getChild('input[formcontrolname="time"]');
datetimePickerButton = this.getChild('.mat-datepicker-toggle');
dateTimePicker = new DateTimePicker(this.page);
getDialogLabel = () => this.getChild('label').innerText();
getErrorByText = (text: string): Locator => this.page.locator('mat-error', { hasText: text });
async getLabels(): Promise<Array<string>> {
return await this.page.$$eval('.adf-share-link__label', (elements) => elements.map((element) => element.textContent));
}
async getDialogTitle(): Promise<string> {
return await this.dialogTitle.innerText();
}
async getInfoText(): Promise<string> {
return await this.infoText.innerText();
}
async getLinkUrl(): Promise<string> {
return await this.url.inputValue();
}
async isUrlReadOnly(): Promise<boolean> {
const urlAttr = await this.url.getAttribute('readonly');
return urlAttr === 'true';
}
async isCloseEnabled(): Promise<boolean> {
return await this.closeButton.isEnabled();
}
async clickClose(): Promise<void> {
await this.page.waitForTimeout(timeouts.tiny);
await this.closeButton.click();
}
async isToggleStatus(toggle: ElementHandle, status: string): Promise<boolean> {
const toggleClass = await toggle.getAttribute('class');
return toggleClass.includes(status);
}
async isShareToggleChecked(): Promise<boolean> {
const shareToggleElement = await this.shareToggle.elementHandle();
return this.isToggleStatus(shareToggleElement, 'checked');
}
async isExpireToggleEnabled(): Promise<boolean> {
const expireToggleElement = await this.expireToggle.elementHandle();
return this.isToggleStatus(expireToggleElement, 'checked');
}
async getExpireDate(): Promise<string> {
return await this.expireInput.inputValue();
}
}

View File

@@ -39,3 +39,4 @@ export * from './breadcrumb/breadcrumb.component';
export * from './sidenav.component';
export * from './aca-header.component';
export * from './error.component';
export * from './datetime-picker/datetime-picker.component';