Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-5519] viewer-general tests Playwright #3327

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ jobs:
id: 1
- name: "folder-rules"
id: 2
- name: "viewer"
id: 3
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
26 changes: 26 additions & 0 deletions e2e/playwright/viewer/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": "../../../.eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"e2e/playwright/viewer/tsconfig.e2e.json"
],
"createDefaultProgram": true
},
"plugins": [
"rxjs",
"unicorn"
],
"rules": {
"@typescript-eslint/no-floating-promises": "off"
}
}
]
}
1 change: 1 addition & 0 deletions e2e/playwright/viewer/exclude.tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
44 changes: 44 additions & 0 deletions e2e/playwright/viewer/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*!
* 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 { PlaywrightTestConfig } from '@playwright/test';
import { CustomConfig, getGlobalConfig, getExcludedTestsRegExpArray } from '@alfresco/playwright-shared';
import EXCLUDED_JSON from './exclude.tests.json';

const config: PlaywrightTestConfig<CustomConfig> = {
...getGlobalConfig,

grepInvert: getExcludedTestsRegExpArray(EXCLUDED_JSON, 'Viewer'),
projects: [
{
name: 'Viewer',
testDir: './src/tests',
use: {
users: ['hruser', 'admin']
}
}
]
};

export default config;
34 changes: 34 additions & 0 deletions e2e/playwright/viewer/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"name": "viewer-e2e",
"sourceRoot": "e2e/playwright/viewer/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "nx:run-commands",
"options": {
"commands": [
"npx playwright test --config=e2e/playwright/viewer/playwright.config.ts"
]
},
"configurations": {
"production": {
"devServerTarget": "content-ce:serve:production"
}
}
},
"lint": {
"executor": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"e2e/**/*.ts",
"e2e/**/*.html"
],
"cache": true,
"cacheLocation": ".eslintcache",
"ignorePath": ".eslintignore"
},
"outputs": ["{options.outputFile}"]
}
}
}
135 changes: 135 additions & 0 deletions e2e/playwright/viewer/src/tests/viewer.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*!
* 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 } 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);
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.beforeEach(async ({ personalFiles }) => {
await personalFiles.navigate({ waitUntil: 'domcontentloaded' });
await personalFiles.dataTable.performClickFolderOrFileToOpen(randomFolderName);
});

test.afterAll(async () => {
await apiClientFactory.nodes.deleteNode(folderId);
});

test('[C279269] Viewer opens on double clicking on a file from Personal Files', async ({ personalFiles }) => {
await personalFiles.dataTable.performClickFolderOrFileToOpen(randomDocxName);
expect(await personalFiles.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
});

test('[C279270] Viewer opens when clicking the View action for a file', async ({ personalFiles }) => {
await personalFiles.dataTable.selectItem(randomDocxName);
await personalFiles.acaHeader.viewButton.click();
await personalFiles.dataTable.spinnerWaitForReload();
expect(await personalFiles.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
});

test('[C279283] The viewer general elements are displayed', async ({ personalFiles }) => {
await personalFiles.dataTable.performClickFolderOrFileToOpen(randomDocxName);
expect(await personalFiles.viewer.isViewerOpened()).toBe(true);
await personalFiles.dataTable.spinnerWaitForReload();
expect(await personalFiles.viewer.isCloseButtonDisplayed(), 'Close button is not displayed').toBe(true);
expect(await personalFiles.viewer.isFileTitleDisplayed(), 'File title is not displayed').toBe(true);
});

test('[C279271] Close the viewer', async ({ personalFiles }) => {
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);
});

test('[C284632] Close button tooltip', async ({ personalFiles }) => {
await personalFiles.dataTable.performClickFolderOrFileToOpen(randomDocxName);
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');
await recentFilesPage.navigate();
await recentFilesPage.reload();
await recentFilesPage.dataTable.performClickFolderOrFileToOpen(randomDocxName);
expect(await recentFilesPage.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
expect(await recentFilesPage.viewer.isCloseButtonDisplayed(), 'Close button is not displayed').toBe(true);
expect(await recentFilesPage.viewer.isFileTitleDisplayed(), 'File title is not displayed').toBe(true);
});

test('[C284635] Viewer opens for a file from Shared Files', async ({ sharedPage }) => {
await sharedPage.navigate();
await sharedPage.reload();
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);
expect(await sharedPage.viewer.isFileTitleDisplayed(), 'File title is not displayed').toBe(true);
});

test('[C284634] Viewer opens for a file from Favorites', async ({ favoritePage }) => {
await favoritePage.navigate({ waitUntil: 'domcontentloaded' });
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);
});
});
15 changes: 15 additions & 0 deletions e2e/playwright/viewer/tsconfig.e2e.adf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../../tsconfig.adf.json",
"compilerOptions": {
"outDir": "../../out-tsc/e2e",
"baseUrl": "./",
"module": "commonjs",
"target": "es2017",
"types": ["jasmine", "jasminewd2", "node"],
"skipLibCheck": true,
"paths": {
"@alfresco/playwright-shared": ["../../../projects/aca-playwright-shared/src/index.ts"]
}
},
"exclude": ["node_modules"]
}
12 changes: 12 additions & 0 deletions e2e/playwright/viewer/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/e2e",
"baseUrl": "./",
"module": "commonjs",
"target": "es2017",
"types": ["jasmine", "jasminewd2", "node", "@playwright/test"],
"skipLibCheck": true,
},
"exclude": ["node_modules"]
}
84 changes: 1 addition & 83 deletions e2e/protractor/suites/viewer/viewer-general.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import { AdminActions, UserActions, LoginPage, BrowsingPage, FILES, SITE_VISIBILITY, RepoClient, Utils, Viewer } from '@alfresco/aca-testing-shared';
import { BrowserActions } from '@alfresco/adf-testing';

describe('Viewer general', () => {
const username = `user-${Utils.random()}`;
Expand All @@ -49,9 +48,8 @@ describe('Viewer general', () => {

const loginPage = new LoginPage();
const page = new BrowsingPage();
const { dataTable, toolbar } = page;
const { dataTable } = page;
const viewer = new Viewer();
const { searchInput } = page.pageLayoutHeader;

const adminApiActions = new AdminActions();
const userActions = new UserActions();
Expand Down Expand Up @@ -98,45 +96,6 @@ describe('Viewer general', () => {
await apis.user.sites.deleteSite(siteUser);
});

it('[C279269] Viewer opens on double clicking on a file from Personal Files', async () => {
await dataTable.doubleClickOnRowByName(xlsxFile);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
});

it('[C279270] Viewer opens when clicking the View action for a file', async () => {
await dataTable.selectItem(xlsxFile);
await BrowserActions.click(page.toolbar.viewButton);

expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
});

it('[C279283] The viewer general elements are displayed', async () => {
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('[C279271] Close the viewer', async () => {
await dataTable.doubleClickOnRowByName(xlsxFile);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
await BrowserActions.click(viewer.closeButton);
expect(await viewer.isViewerOpened()).toBe(false, 'Viewer did not close');
});

it('[C284632] Close button tooltip', async () => {
await dataTable.doubleClickOnRowByName(xlsxFile);
expect(await viewer.getCloseButtonTooltip()).toEqual('Close');
});

it('[C279285] Viewer opens when accessing the preview URL for a file', async () => {
const previewURL = `personal-files/${parentId}/(viewer:view/${xlsxFileId})`;
await page.load(previewURL);
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
expect(await viewer.getFileTitle()).toEqual(xlsxFile);
});

it('[C279287] Viewer does not open when accessing the preview URL for a file without permissions', async () => {
const previewURL = `libraries/${docLibId}/(viewer:view/${fileAdminId})`;
await page.load(previewURL);
Expand All @@ -153,45 +112,4 @@ 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');
});
});
Loading