mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[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:
committed by
GitHub
parent
683138ced1
commit
373a41bd16
@@ -409,4 +409,44 @@ export class NodesApi {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getNodeProperty(nodeId: string, property: string): Promise<string> {
|
||||
try {
|
||||
const node = await this.getNodeById(nodeId);
|
||||
return node.entry.properties?.[property] || '';
|
||||
} catch (error) {
|
||||
console.error(`${this.constructor.name} ${this.getNodeProperty.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async getSharedId(nodeId: string): Promise<string> {
|
||||
try {
|
||||
const sharedId = await this.getNodeProperty(nodeId, 'qshare:sharedId');
|
||||
return sharedId || '';
|
||||
} catch (error) {
|
||||
console.error(`${this.constructor.name} ${this.getSharedId.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async getSharedExpiryDate(nodeId: string): Promise<string> {
|
||||
try {
|
||||
const expiryDate = await this.getNodeProperty(nodeId, 'qshare:expiryDate');
|
||||
return expiryDate || '';
|
||||
} catch (error) {
|
||||
console.error(`${this.constructor.name} ${this.getSharedExpiryDate.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async isFileShared(nodeId: string): Promise<boolean> {
|
||||
try {
|
||||
const sharedId = await this.getSharedId(nodeId);
|
||||
return sharedId !== '';
|
||||
} catch (error) {
|
||||
console.error(`${this.constructor.name} ${this.isFileShared.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -50,12 +50,12 @@ export class SharedLinksApi {
|
||||
}
|
||||
}
|
||||
|
||||
async shareFilesByIds(ids: string[]): Promise<SharedLinkEntry[]> {
|
||||
async shareFilesByIds(ids: string[], expireDate?: Date): Promise<SharedLinkEntry[]> {
|
||||
const sharedLinks: SharedLinkEntry[] = [];
|
||||
try {
|
||||
if (ids && ids.length > 0) {
|
||||
for (const id of ids) {
|
||||
const sharedLink = await this.shareFileById(id);
|
||||
const sharedLink = await this.shareFileById(id, expireDate);
|
||||
sharedLinks.push(sharedLink);
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -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';
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -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';
|
||||
|
@@ -37,7 +37,8 @@ import {
|
||||
ViewerComponent,
|
||||
SidenavComponent,
|
||||
PaginationComponent,
|
||||
ErrorComponent
|
||||
ErrorComponent,
|
||||
ShareDialogComponent
|
||||
} from '../components';
|
||||
|
||||
export class PersonalFilesPage extends BasePage {
|
||||
@@ -60,6 +61,7 @@ export class PersonalFilesPage extends BasePage {
|
||||
public createFromTemplateDialogComponent = new CreateFromTemplateDialogComponent(this.page);
|
||||
public pagination = new PaginationComponent(this.page);
|
||||
public errorDialog = new ErrorComponent(this.page);
|
||||
public shareDialog= new ShareDialogComponent(this.page);
|
||||
|
||||
async selectCreateFolder(): Promise<void> {
|
||||
await this.acaHeader.createButton.click();
|
||||
|
@@ -42,4 +42,8 @@ export class Utils {
|
||||
|
||||
return run(retry);
|
||||
}
|
||||
|
||||
static formatDate(date: string): string {
|
||||
return new Date(date).toLocaleDateString('en-US');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user