[ACS-5604] viewer protected file test playwright (#3354)

* re-enable protracotr test

* viewer protected file tests

* remove navigate though pages
This commit is contained in:
Akash Rathod
2023-07-19 22:56:03 +02:00
committed by GitHub
parent f9f5834fb7
commit 9a585c1642
12 changed files with 340 additions and 61 deletions

View File

@@ -160,11 +160,10 @@ export class DataTableComponent extends BaseComponent {
*
* @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 performClickFolderOrFileToOpen(name: string): Promise<void> {
await this.getCellLinkByName(name).click();
await this.spinnerWaitForReload();
}
async getActionLocatorFromExpandableMenu(name: string | number, action: string): Promise<Locator> {
await this.getRowByName(name).click({ button: 'right' });
@@ -200,8 +199,8 @@ export class DataTableComponent extends BaseComponent {
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();
const row = await this.getRowByName(name);
await row.locator('.mat-checkbox[id*="mat-checkbox"]').check();
}
}

View File

@@ -24,4 +24,4 @@
export * from './adf-folder-dialog.component';
export * from './adf-library-dialog.component';
export * from './password-overlay-dialog.component';

View File

@@ -0,0 +1,83 @@
/*!
* 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 { timeouts } from '../../../utils';
export class PasswordOverlayDialogComponent extends BaseComponent {
private static rootElement = '.cdk-overlay-pane';
public closeButton = this.getChild('[data-automation-id="adf-password-dialog-close"]');
public submitButton = this.getChild('[data-automation-id="adf-password-dialog-submit"]');
public passwordInput = this.getChild('[data-automation-id="adf-password-dialog-input"]');
public errorMessage = this.getChild('[data-automation-id="adf-password-dialog-error"]');
constructor(page: Page, rootElement = PasswordOverlayDialogComponent.rootElement) {
super(page, rootElement);
}
async waitForDialogToOpen(): Promise<void> {
await this.spinnerWaitForReload();
await this.passwordInput.waitFor({ state: 'attached', timeout: timeouts.large });
await this.passwordInput.isVisible();
}
async waitForDialogToClose(): Promise<void> {
await this.passwordInput.waitFor({ state: 'detached', timeout: timeouts.large });
}
async isDialogOpen(): Promise<boolean> {
await this.waitForDialogToOpen();
return await this.passwordInput.isVisible();
}
async isCloseVisible(): Promise<boolean> {
return await this.closeButton.isVisible();
}
async isSubmitHidden(): Promise<boolean> {
return await this.submitButton.isHidden();
}
async isPasswordInputDisplayed(): Promise<boolean> {
return await this.passwordInput.isVisible();
}
async isErrorDisplayed(): Promise<boolean> {
await this.errorMessage.waitFor({ state: 'visible', timeout: timeouts.short });
return await this.errorMessage.isVisible();
}
async getErrorMessage(): Promise<string> {
if (await this.isErrorDisplayed()) {
return this.errorMessage.innerText();
}
return '';
}
async enterPassword(password: string): Promise<void> {
await this.passwordInput.fill(password);
}
}

View File

@@ -33,6 +33,7 @@ export class ViewerComponent extends BaseComponent {
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');
public pdfViewerContentPages = this.getChild('.adf-pdf-viewer__content .page');
toolbar = new AcaHeader(this.page);
@@ -40,7 +41,17 @@ export class ViewerComponent extends BaseComponent {
super(page, ViewerComponent.rootElement);
}
async isPdfViewerContentDisplayed(): Promise<boolean> {
const count = await this.pdfViewerContentPages.count();
return count > 0;
}
async waitForViewerToOpen(): Promise<void> {
await this.viewerLocator.waitFor({ state: 'visible', timeout: timeouts.medium });
}
async isViewerOpened(): Promise<boolean> {
await this.waitForViewerToOpen();
return await this.viewerLocator.isVisible();
}

View File

@@ -22,12 +22,11 @@
* 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 { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent } from '../components/dialogs';
import { AdfFolderDialogComponent, PasswordOverlayDialogComponent } from '../components/dialogs';
export class PersonalFilesPage extends BasePage {
private static pageUrl = 'personal-files';
@@ -41,4 +40,5 @@ export class PersonalFilesPage extends BasePage {
public folderDialog = new AdfFolderDialogComponent(this.page);
public dataTable = new DataTableComponent(this.page);
public viewer = new ViewerComponent(this.page);
public passwordDialog = new PasswordOverlayDialogComponent(this.page);
}

View File

@@ -1,22 +1,44 @@
/*
* Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved.
/*!
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
* 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 { resolve } from 'path';
export const TEST_FILES = {
DOCX: {
path: resolve(__dirname, 'file-docx.docx'),
name: 'file-docx',
data: 'Lorem ipsum dolor sit amet'
},
PDF: {
path: resolve(__dirname, 'file-pdf.pdf'),
name: 'file-pdf',
data: 'Lorem ipsum dolor sit amet'
},
DOCX: {
path: resolve(__dirname, 'file-docx.docx'),
name: 'file-docx',
data: 'Lorem ipsum dolor sit amet'
},
PDF: {
path: resolve(__dirname, 'file-pdf.pdf'),
name: 'file-pdf',
data: 'Lorem ipsum dolor sit amet'
},
DOCX_PROTECTED: {
path: resolve(__dirname, 'file-pdf-protected.pdf'),
name: 'file-pdf-protected',
data: 'Lorem ipsum dolor sit amet',
password: '0000'
}
};