[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

@@ -1 +1,6 @@
{}
{
"C284636" : "https://alfresco.atlassian.net/browse/ACS-5639",
"C284635" : "https://alfresco.atlassian.net/browse/ACS-5639",
"C279175" : "https://alfresco.atlassian.net/browse/ACS-5639",
"C284634" : "https://alfresco.atlassian.net/browse/ACS-5639"
}

View File

@@ -0,0 +1,91 @@
/*!
* 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 { expect } from '@playwright/test';
import { ApiClientFactory, getUserState, test, TEST_FILES, Utils } from '@alfresco/playwright-shared';
test.use({ storageState: getUserState('hruser') });
test.describe('viewer file', () => {
const apiClientFactory = new ApiClientFactory();
const randomFolderName = `playwright-folder-${Utils.random()}`;
const randomDocxName = `${TEST_FILES.DOCX_PROTECTED.name}-${Utils.random()}`;
let folderId: string;
let fileDocxId: string;
test.beforeAll(async ({ fileAction, shareAction, favoritesPageAction: favoritesPageAction }) => {
await apiClientFactory.setUpAcaBackend('hruser');
const node = await apiClientFactory.nodes.createNode('-my-', { name: randomFolderName, nodeType: 'cm:folder', relativePath: '/' });
folderId = await node.entry.id;
const fileDoc = await fileAction.uploadFile(TEST_FILES.DOCX_PROTECTED.path, randomDocxName, folderId);
fileDocxId = await fileDoc.entry.id;
await shareAction.shareFileById(fileDocxId);
await favoritesPageAction.addFavoriteById('file', fileDocxId);
});
test.beforeEach(async ({ personalFiles }) => {
const gotoNodeURL = `#/personal-files/${folderId}`;
await personalFiles.navigate({ remoteUrl: gotoNodeURL });
await personalFiles.dataTable.performClickFolderOrFileToOpen(randomDocxName);
});
test.afterAll(async () => {
await apiClientFactory.nodes.deleteNode(folderId);
});
test('[C268958] Password dialog appears when opening a protected file', async ({ personalFiles }) => {
expect(await personalFiles.passwordDialog.isDialogOpen(), 'Password dialog not open').toBe(true);
expect(await personalFiles.passwordDialog.isPasswordInputDisplayed(), 'Password input not displayed').toBe(true);
expect(await personalFiles.passwordDialog.submitButton.isHidden(), 'Submit button not disabled').toBe(false);
expect(await personalFiles.passwordDialog.isCloseVisible(), 'Close button not enabled').toBe(true);
expect(await personalFiles.viewer.pdfViewerContentPages.isVisible(), 'Viewer did not close').toBe(false);
});
test('[C268959] File content is displayed when entering the correct password', async ({ personalFiles }) => {
await personalFiles.passwordDialog.enterPassword(TEST_FILES.DOCX_PROTECTED.password);
expect(await personalFiles.passwordDialog.submitButton.isVisible(), 'Submit button not enabled').toBe(true);
await personalFiles.passwordDialog.submitButton.click();
await personalFiles.passwordDialog.waitForDialogToClose();
expect(await personalFiles.viewer.isPdfViewerContentDisplayed(), 'file content not displayed').toBe(true);
});
test('[C268960] Error appears when entering an incorrect password', async ({ personalFiles }) => {
await personalFiles.passwordDialog.enterPassword('incorrect');
expect(await personalFiles.passwordDialog.submitButton.isVisible(), 'Submit button not enabled').toBe(true);
await personalFiles.passwordDialog.submitButton.click();
expect(await personalFiles.passwordDialog.getErrorMessage()).toBe('Password is wrong');
expect(await personalFiles.viewer.isPdfViewerContentDisplayed(), 'file content is displayed').toBe(false);
});
test('[C268961] Refresh the page while Password dialog is open', async ({ personalFiles }) => {
await personalFiles.passwordDialog.enterPassword(TEST_FILES.DOCX_PROTECTED.password);
await personalFiles.reload({ waitUntil: 'domcontentloaded' });
await personalFiles.viewer.waitForViewerToOpen();
expect(await personalFiles.viewer.isPdfViewerContentDisplayed(), 'file content is displayed').toBe(false);
expect(await personalFiles.passwordDialog.isDialogOpen(), 'Password dialog not open').toBe(true);
});
});

View File

@@ -23,29 +23,25 @@
*/
import { expect } from '@playwright/test';
import { ApiClientFactory, getUserState, test, TEST_FILES } from '@alfresco/playwright-shared';
import { ApiClientFactory, getUserState, test, TEST_FILES, Utils } from '@alfresco/playwright-shared';
test.use({ storageState: getUserState('admin') });
test.describe('viewer file', () => {
const apiClientFactory = new ApiClientFactory();
const randomFolderName = `playwright-folder-${(Math.random() + 1).toString(36).substring(6)}`;
const randomDocxName = TEST_FILES.DOCX.name + (Math.random() + 1).toString(36).substring(6);
const randomFolderName = `playwright-folder-${Utils.random()}`;
const randomDocxName = `$(TEST_FILES.DOCX.name)-${Utils.random()}`;
let folderId: string;
let fileDocxId: string;
test.beforeAll(async ({ fileAction, shareAction, favoritesPageAction: favoritesPageAction }) => {
test.beforeAll(async ({ fileAction }) => {
await apiClientFactory.setUpAcaBackend('admin');
const node = await apiClientFactory.nodes.createNode('-my-', { name: randomFolderName, nodeType: 'cm:folder', relativePath: '/' });
folderId = await node.entry.id;
const fileDoc = await fileAction.uploadFile(TEST_FILES.DOCX.path, randomDocxName, folderId);
fileDocxId = await fileDoc.entry.id;
await shareAction.shareFileById(fileDocxId);
await favoritesPageAction.addFavoriteById('file', fileDocxId);
await fileAction.uploadFile(TEST_FILES.DOCX.path, randomDocxName, folderId);
});
test.beforeEach(async ({ personalFiles }) => {
await personalFiles.navigate({ waitUntil: 'domcontentloaded' });
await personalFiles.dataTable.performClickFolderOrFileToOpen(randomFolderName);
const gotoNodeURL = `#/personal-files/${folderId}`;
await personalFiles.navigate({ remoteUrl: gotoNodeURL });
});
test.afterAll(async () => {
@@ -76,7 +72,7 @@ test.describe('viewer file', () => {
await personalFiles.dataTable.performClickFolderOrFileToOpen(randomDocxName);
expect(await personalFiles.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
await personalFiles.viewer.closeButtonLocator.click();
expect(await personalFiles.viewer.isViewerOpened(), 'Viewer did not close').toBe(false);
expect(await personalFiles.dataTable.getCellLinkByName(randomDocxName).isVisible(), 'Viewer did not close').toBe(true);
});
test('[C284632] Close button tooltip', async ({ personalFiles }) => {
@@ -84,14 +80,6 @@ test.describe('viewer file', () => {
expect(await personalFiles.viewer.getCloseButtonTooltip()).toEqual('Close');
});
test('[C279285] Viewer opens when accessing the preview URL for a file', async ({ personalFiles }) => {
const previewURL = `#/personal-files/${folderId}/(viewer:view/${fileDocxId})`;
await personalFiles.navigate({ remoteUrl: previewURL });
await personalFiles.dataTable.spinnerWaitForReload();
expect(await personalFiles.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
expect(await personalFiles.viewer.fileTitleButtonLocator.innerText()).toEqual(randomDocxName);
});
test('[C284636] Viewer opens for a file from Recent Files', async ({ personalFiles, recentFilesPage }) => {
await personalFiles.dataTable.performClickFolderOrFileToOpen(randomDocxName);
expect(await personalFiles.viewer.getCloseButtonTooltip()).toEqual('Close');
@@ -103,9 +91,53 @@ test.describe('viewer file', () => {
expect(await recentFilesPage.viewer.isFileTitleDisplayed(), 'File title is not displayed').toBe(true);
});
test('[C279175] Viewer opens for a file from Search Results', async ({ personalFiles, searchPage }) => {
await personalFiles.acaHeader.searchButton.click();
await searchPage.searchInput.searchButton.click();
await searchPage.searchOverlay.checkFilesAndFolders();
await searchPage.searchOverlay.searchFor(randomDocxName);
await searchPage.reload({ waitUntil: 'domcontentloaded' });
await searchPage.dataTable.goThroughPagesLookingForRowWithName(randomDocxName);
await searchPage.searchInput.performDoubleClickFolderOrFileToOpen(randomDocxName);
expect(await searchPage.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
expect(await searchPage.viewer.isCloseButtonDisplayed(), 'Close button is not displayed').toBe(true);
expect(await searchPage.viewer.isFileTitleDisplayed(), 'File title is not displayed').toBe(true);
});
});
test.describe('viewer file', () => {
const apiClientFactory = new ApiClientFactory();
const randomFolderName = `playwright-folder-${Utils.random()}`;
const randomDocxName = `$(TEST_FILES.DOCX.name)-${Utils.random()}`;
let folderId: string;
let fileDocxId: string;
test.beforeAll(async ({ fileAction, shareAction, favoritesPageAction: favoritesPageAction }) => {
await apiClientFactory.setUpAcaBackend('admin');
const node = await apiClientFactory.nodes.createNode('-my-', { name: randomFolderName, nodeType: 'cm:folder', relativePath: '/' });
folderId = await node.entry.id;
const fileDoc = await fileAction.uploadFile(TEST_FILES.DOCX.path, randomDocxName, folderId);
fileDocxId = await fileDoc.entry.id;
await shareAction.shareFileById(fileDocxId);
await favoritesPageAction.addFavoriteById('file', fileDocxId);
});
test.afterAll(async () => {
await apiClientFactory.nodes.deleteNode(folderId);
});
test('[C279285] Viewer opens when accessing the preview URL for a file', async ({ personalFiles }) => {
const previewURL = `#/personal-files/${folderId}/(viewer:view/${fileDocxId})`;
await personalFiles.navigate({ remoteUrl: previewURL });
await personalFiles.dataTable.spinnerWaitForReload();
expect(await personalFiles.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
expect(await personalFiles.viewer.fileTitleButtonLocator.innerText()).toEqual(randomDocxName);
});
test('[C284635] Viewer opens for a file from Shared Files', async ({ sharedPage }) => {
await sharedPage.navigate();
await sharedPage.reload();
await sharedPage.dataTable.goThroughPagesLookingForRowWithName(randomDocxName);
await sharedPage.dataTable.performClickFolderOrFileToOpen(randomDocxName);
expect(await sharedPage.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
expect(await sharedPage.viewer.isCloseButtonDisplayed(), 'Close button is not displayed').toBe(true);
@@ -114,22 +146,10 @@ test.describe('viewer file', () => {
test('[C284634] Viewer opens for a file from Favorites', async ({ favoritePage }) => {
await favoritePage.navigate({ waitUntil: 'domcontentloaded' });
await favoritePage.dataTable.goThroughPagesLookingForRowWithName(randomDocxName);
await favoritePage.dataTable.performClickFolderOrFileToOpen(randomDocxName);
expect(await favoritePage.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
expect(await favoritePage.viewer.isCloseButtonDisplayed(), 'Close button is not displayed').toBe(true);
expect(await favoritePage.viewer.isFileTitleDisplayed(), 'File title is not displayed').toBe(true);
});
test('[C279175] Viewer opens for a file from Search Results', async ({ personalFiles, searchPage }) => {
await personalFiles.acaHeader.searchButton.click();
await searchPage.searchInput.searchButton.click();
await searchPage.searchOverlay.checkFilesAndFolders();
await searchPage.searchOverlay.searchFor(randomDocxName);
await searchPage.reload({ waitUntil: 'domcontentloaded' });
await searchPage.searchInput.performDoubleClickFolderOrFileToOpen(randomDocxName);
expect(await searchPage.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
expect(await searchPage.viewer.isCloseButtonDisplayed(), 'Close button is not displayed').toBe(true);
expect(await searchPage.viewer.isFileTitleDisplayed(), 'File title is not displayed').toBe(true);
});
});

View File

@@ -19,5 +19,11 @@
"C279221": "temp, will be fixed in https://alfresco.atlassian.net/browse/ACS-4985",
"C279220": "temp, will be fixed in https://alfresco.atlassian.net/browse/ACS-4985",
"C325006": "temp, will be fixed in https://alfresco.atlassian.net/browse/ACS-4985",
"C213097": "https://alfresco.atlassian.net/browse/ACS-5479"
"C213097": "https://alfresco.atlassian.net/browse/ACS-5479",
"C268958" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5604",
"C268959" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5604",
"C268960" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5604",
"C268961" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5604"
}

View File

@@ -48,8 +48,9 @@ describe('Viewer general', () => {
const loginPage = new LoginPage();
const page = new BrowsingPage();
const { dataTable } = page;
const { dataTable, toolbar } = page;
const viewer = new Viewer();
const { searchInput } = page.pageLayoutHeader;
const adminApiActions = new AdminActions();
const userActions = new UserActions();
@@ -112,4 +113,45 @@ describe('Viewer general', () => {
expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed');
expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed');
});
it('[C284636] Viewer opens for a file from Recent Files', async () => {
await page.clickRecentFilesAndWait();
await dataTable.doubleClickOnRowByName(xlsxFile);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed');
expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed');
expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed');
});
it('[C284635] Viewer opens for a file from Shared Files', async () => {
await page.clickSharedFilesAndWait();
await dataTable.doubleClickOnRowByName(xlsxFile);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed');
expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed');
expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed');
});
it('[C284634] Viewer opens for a file from Favorites', async () => {
await page.clickFavoritesAndWait();
await dataTable.doubleClickOnRowByName(xlsxFile);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed');
expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed');
expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed');
});
it('[C279175] Viewer opens for a file from Search Results', async () => {
await toolbar.clickSearchIconButton();
await searchInput.clickSearchButton();
await searchInput.checkFilesAndFolders();
await searchInput.searchFor(xlsxFile);
await dataTable.waitForBody();
await dataTable.doubleClickOnRowByName(xlsxFile);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed');
expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed');
expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed');
});
});

View File

@@ -161,7 +161,6 @@ 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();
}

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,9 +1,25 @@
/*
* 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';
@@ -19,4 +35,10 @@ export const TEST_FILES = {
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'
}
};