[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');
});
});