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

* [ACS-5519] view general tests Playwright

* [ACS-5519] remove same function call
This commit is contained in:
Akash Rathod 2023-07-11 19:54:58 +02:00 committed by GitHub
parent b192c5f6bb
commit 5abbda78a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 901 additions and 101 deletions

View File

@ -176,6 +176,8 @@ jobs:
id: 1
- name: "folder-rules"
id: 2
- name: "viewer"
id: 3
steps:
- name: Checkout
uses: actions/checkout@v3

View File

@ -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"
}
}
]
}

View File

@ -0,0 +1 @@
{}

View File

@ -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;

View File

@ -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}"]
}
}
}

View File

@ -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);
});
});

View File

@ -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"]
}

View File

@ -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"]
}

View File

@ -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()}`;
@ -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();
@ -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);
@ -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');
});
});

View File

@ -35,7 +35,9 @@ import {
SecurityGroupsApi,
SecurityMarksApi,
SitesApi,
UploadApi
UploadApi,
SharedlinksApi,
FavoritesApi
} from '@alfresco/js-api';
import { logger } from '@alfresco/adf-cli/scripts/logger';
import { ActionTypes, Rule } from './rules-api';
@ -45,6 +47,8 @@ export interface AcaBackend {
sites: SitesApi;
upload: UploadApi;
nodes: NodesApi;
share: SharedlinksApi;
favorites: FavoritesApi;
tearDown(): Promise<any>;
}
@ -73,6 +77,8 @@ export class ApiClientFactory {
public securityGroupsApi: SecurityGroupsApi;
public securityMarksApi: SecurityMarksApi;
public contentClient: ContentClient;
public share: SharedlinksApi;
public favorites: FavoritesApi;
constructor() {
this.alfrescoApi = new AlfrescoApi(config);
@ -92,6 +98,8 @@ export class ApiClientFactory {
this.search = new SearchApi(this.alfrescoApi);
this.securityGroupsApi = new SecurityGroupsApi(this.alfrescoApi);
this.securityMarksApi = new SecurityMarksApi(this.alfrescoApi);
this.share = new SharedlinksApi(this.alfrescoApi);
this.favorites = new FavoritesApi(this.alfrescoApi);
return this;
}

View File

@ -0,0 +1,52 @@
/*!
* 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 { ApiClientFactory } from './api-client-factory';
import { FavoriteEntry } from '@alfresco/js-api';
import { users } from '../base-config/global-variables';
export class FavoritesPageApi extends ApiClientFactory {
private apiService: ApiClientFactory;
constructor() {
super();
this.apiService = new ApiClientFactory();
}
static async initialize(userProfile: keyof typeof users): Promise<FavoritesPageApi> {
const classObj = new FavoritesPageApi();
await classObj.apiService.setUpAcaBackend(userProfile);
return classObj;
}
async addFavoriteById(nodeType: 'file' | 'folder' | 'site', id: string): Promise<FavoriteEntry | null> {
let guid = nodeType === 'site' ? (await this.sites.getSite(id)).entry.guid : id;
const data = {
target: {
[nodeType]: {
guid: guid
}
}
};
return await this.apiService.favorites.createFavorite('-me-', data);
}
}

View File

@ -0,0 +1,59 @@
/*!
* 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 * as fs from 'fs';
import { ApiClientFactory } from './api-client-factory';
import { users } from '../base-config/global-variables';
export class FileActionsApi extends ApiClientFactory {
private apiService: ApiClientFactory;
constructor() {
super();
this.apiService = new ApiClientFactory();
}
static async initialize(
userProfile: keyof typeof users
): Promise<FileActionsApi> {
const classObj = new FileActionsApi();
await classObj.apiService.setUpAcaBackend(userProfile);
return classObj;
}
async uploadFile(fileLocation: string, fileName: string, parentFolderId: string): Promise<any> {
const file = fs.createReadStream(fileLocation);
return this.apiService.upload.uploadFile(
file,
'',
parentFolderId,
null,
{
name: fileName,
nodeType: 'cm:content',
renditions: 'doclib'
}
);
}
}

View File

@ -24,3 +24,6 @@
export * from './rules-api';
export * from './api-client-factory';
export * from './file-actions';
export * from './shared-links-api';
export * from './favorites-api';

View File

@ -0,0 +1,55 @@
/*!
* 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 { ApiClientFactory } from './api-client-factory';
import { SharedLinkEntry } from '@alfresco/js-api';
import { users } from '../base-config/global-variables';
export class SharedLinksApi extends ApiClientFactory {
private apiService: ApiClientFactory;
constructor() {
super();
this.apiService = new ApiClientFactory();
}
static async initialize(
userProfile: keyof typeof users
): Promise<SharedLinksApi> {
const classObj = new SharedLinksApi();
await classObj.apiService.setUpAcaBackend(userProfile);
return classObj;
}
async shareFileById(id: string, expireDate?: Date): Promise<SharedLinkEntry | null> {
try {
const data = {
nodeId: id,
expiresAt: expireDate
};
return await this.apiService.share.createSharedLink(data);
} catch (error) {
return null;
}
}
}

View File

@ -22,20 +22,63 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { test as base } from '@playwright/test';
import { NodesPage, PersonalFilesPage } from '../';
import {
FileActionsApi,
NodesPage,
PersonalFilesPage,
RecentFilesPage,
SharedLinksApi,
SharedPage,
SearchPage,
FavoritesPage,
FavoritesPageApi
} from '../';
interface Pages {
personalFiles: PersonalFilesPage;
nodesPage: NodesPage;
recentFilesPage: RecentFilesPage;
sharedPage: SharedPage;
searchPage: SearchPage;
favoritePage: FavoritesPage;
}
export const test = base.extend<Pages>({
interface Api {
fileAction: FileActionsApi;
shareAction: SharedLinksApi;
favoritesPageAction: FavoritesPageApi;
}
export const test = base.extend<Pages & Api>({
personalFiles: async ({ page }, use) => {
await use(new PersonalFilesPage(page));
},
nodesPage: async ({ page }, use) => {
await use(new NodesPage(page));
},
recentFilesPage: async ({ page }, use) => {
await use(new RecentFilesPage(page));
},
sharedPage: async ({ page }, use) => {
await use(new SharedPage(page));
},
searchPage: async ({ page }, use) => {
await use(new SearchPage(page));
},
favoritePage: async ({ page }, use) => {
await use(new FavoritesPage(page));
},
// eslint-disable-next-line no-empty-pattern
fileAction: async ({}, use) => {
await use(await FileActionsApi.initialize('admin'));
},
// eslint-disable-next-line no-empty-pattern
shareAction: async ({}, use) => {
await use(await SharedLinksApi.initialize('admin'));
},
// eslint-disable-next-line no-empty-pattern
favoritesPageAction: async ({}, use) => {
await use(await FavoritesPageApi.initialize('admin'));
}
});

View File

@ -28,3 +28,4 @@ export * from './models';
export * from './page-objects';
export * from './fixtures/page-initialization';
export * from './utils';
export * from './resources/test-files';

View File

@ -28,6 +28,8 @@
export class AcaHeader extends BaseComponent {
private static rootElement = 'adf-toolbar';
public createButton = this.getChild('[id="app.toolbar.create"]');
public viewButton = this.getChild('button[title="View"]');
public searchButton = this.getChild('button[title="Search"]');
constructor(page: Page) {
super(page, AcaHeader.rootElement);

View File

@ -77,7 +77,7 @@ export class ActionsDropdownComponent extends BaseComponent {
await this.actionDropdownLocator.nth(index).click();
await this.spinnerWaitForReload();
const option = this.getOptionLocator(action);
await option.click();
await option.nth(0).click();
}
async dropdownSelection(selectValue: string, locator: string, index: number): Promise<void> {

View File

@ -50,13 +50,13 @@ export abstract class BaseComponent extends PlaywrightBase {
async closeAdditionalOverlayElementIfVisible(): Promise<void> {
if (await this.overlayElement.isVisible()) {
await this.page.keyboard.press('Escape');
await this.overlayElement.waitFor({ state: 'detached', timeout: 5000 });
await this.overlayElement.waitFor({ state: 'detached', timeout: timeouts.medium });
}
}
async spinnerWaitForReload(): Promise<void> {
try {
await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: timeouts.short });
await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: timeouts.normal });
await this.page.locator('mat-progress-spinner').waitFor({ state: 'detached', timeout: timeouts.normal });
} catch (e) {
this.logger.info('Spinner was not present');

View File

@ -155,6 +155,17 @@ export class DataTableComponent extends BaseComponent {
}
}
/**
* This method is used when we want to perform double click on the dataTable row to open a file or folder
*
* @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 getActionLocatorFromExpandableMenu(name: string | number, action: string): Promise<Locator> {
await this.getRowByName(name).click({ button: 'right' });
return this.contextMenuActions.getButtonByText(action);
@ -180,4 +191,17 @@ export class DataTableComponent extends BaseComponent {
await this.spinnerWaitForReload();
}
}
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();
}
}
async hasCheckMarkIcon(itemName: string): Promise<boolean> {
const row = this.getRowByName(itemName);
return await row.locator('.mat-checkbox[class*="checked"]').isVisible();
}
}

View File

@ -31,4 +31,6 @@ export * from './spinner.component';
export * from './actions-dropdown.component';
export * from './conditions.component';
export * from './pagination.component';
export * from './viewer.component';
export * from './search/search-input.component';
export * from './search/search-overlay.components';

View File

@ -0,0 +1,51 @@
/*!
* 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 { Locator, Page } from '@playwright/test';
import { BaseComponent } from '.././base.component';
import { timeouts } from '../../../utils';
export class SearchInputComponent extends BaseComponent {
private static rootElement = 'aca-page-layout';
public searchButton = this.getChild('aca-search-input .app-search-button');
/**
* Method used in cases where user have possibility to navigate "inside" the element (it's clickable and has link attribute).
* Perform action .click() to navigate inside it
*
* @returns reference to cell element which contains link.
*/
getCellLinkByName = (name: string): Locator => this.getChild('.adf-datatable-row[role="row"]', { hasText: name });
constructor(page: Page, rootElement = SearchInputComponent.rootElement) {
super(page, rootElement);
}
async performDoubleClickFolderOrFileToOpen(name: string): Promise<void> {
await this.getCellLinkByName(name).waitFor({ state:'visible', timeout: timeouts.normal });
await this.getCellLinkByName(name).dblclick();
await this.spinnerWaitForReload();
}
}

View File

@ -0,0 +1,50 @@
/*!
* 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';
export class SearchOverlayComponent extends BaseComponent {
private static rootElement = '.cdk-overlay-pane';
public searchFilesOption = this.getChild('label[for="content-input"]');
public searchFoldersOption = this.getChild('label[for="folder-input"]');
public searchLibrariesOption = this.getChild('label[for="libraries-input"]');
public searchInput = this.getChild('input[id="app-control-input"]');
public searchButton = this.getChild('.app-search-button');
constructor(page: Page, rootElement = SearchOverlayComponent.rootElement) {
super(page, rootElement);
}
async checkFilesAndFolders(): Promise<void> {
await this.searchFilesOption.click();
await this.searchFoldersOption.click();
}
async searchFor(input: string): Promise<void> {
await this.searchInput.fill(input);
await this.searchButton.click();
}
}

View File

@ -0,0 +1,61 @@
/*!
* 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 { AcaHeader } from './aca-header.component';
import { timeouts } from '../../utils';
export class ViewerComponent extends BaseComponent {
private static rootElement = 'adf-viewer';
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');
toolbar = new AcaHeader(this.page);
constructor(page: Page) {
super(page, ViewerComponent.rootElement);
}
async isViewerOpened(): Promise<boolean> {
return await this.viewerLocator.isVisible();
}
async isCloseButtonDisplayed(): Promise<boolean> {
await this.closeButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal });
return await this.closeButtonLocator.isEnabled({ timeout: timeouts.normal });
}
async isFileTitleDisplayed(): Promise<boolean> {
await this.fileTitleButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal });
return await this.fileTitleButtonLocator.isVisible();
}
async getCloseButtonTooltip(): Promise<string> {
await this.closeButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal });
return await this.closeButtonLocator.getAttribute('title');
}
}

View File

@ -0,0 +1,43 @@
/*!
* 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 { BasePage } from './base.page';
import { DataTableComponent, MatMenuComponent, ViewerComponent } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent } from '../components/dialogs';
export class FavoritesPage extends BasePage {
private static pageUrl = 'favorites';
constructor(page: Page) {
super(page, FavoritesPage.pageUrl);
}
public acaHeader = new AcaHeader(this.page);
public matMenu = new MatMenuComponent(this.page);
public folderDialog = new AdfFolderDialogComponent(this.page);
public dataTable = new DataTableComponent(this.page);
public viewer = new ViewerComponent(this.page);
}

View File

@ -26,3 +26,7 @@ export * from './base.page';
export * from './login.page';
export * from './nodes.page';
export * from './personal-files.page';
export * from './recent-files.page';
export * from './shared.page';
export * from './search.page';
export * from './favorites.page';

View File

@ -25,7 +25,7 @@
import { Page } from '@playwright/test';
import { BasePage } from './base.page';
import { DataTableComponent, MatMenuComponent } from '../components';
import { DataTableComponent, MatMenuComponent, ViewerComponent } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent } from '../components/dialogs';
@ -40,4 +40,5 @@ export class PersonalFilesPage extends BasePage {
public matMenu = new MatMenuComponent(this.page);
public folderDialog = new AdfFolderDialogComponent(this.page);
public dataTable = new DataTableComponent(this.page);
public viewer = new ViewerComponent(this.page);
}

View File

@ -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 { 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';
export class RecentFilesPage extends BasePage {
private static pageUrl = 'recent-files';
constructor(page: Page) {
super(page, RecentFilesPage.pageUrl);
}
public acaHeader = new AcaHeader(this.page);
public matMenu = new MatMenuComponent(this.page);
public folderDialog = new AdfFolderDialogComponent(this.page);
public dataTable = new DataTableComponent(this.page);
public viewer = new ViewerComponent(this.page);
}

View File

@ -0,0 +1,45 @@
/*!
* 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 { BasePage } from './base.page';
import { DataTableComponent, MatMenuComponent, ViewerComponent, SearchInputComponent, SearchOverlayComponent } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent } from '../components/dialogs';
export class SearchPage extends BasePage {
private static pageUrl = 'search';
constructor(page: Page) {
super(page, SearchPage.pageUrl);
}
public acaHeader = new AcaHeader(this.page);
public matMenu = new MatMenuComponent(this.page);
public folderDialog = new AdfFolderDialogComponent(this.page);
public dataTable = new DataTableComponent(this.page);
public viewer = new ViewerComponent(this.page);
public searchInput = new SearchInputComponent(this.page);
public searchOverlay = new SearchOverlayComponent(this.page);
}

View File

@ -0,0 +1,43 @@
/*!
* 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 { BasePage } from './base.page';
import { DataTableComponent, MatMenuComponent, ViewerComponent } from '../components';
import { AcaHeader } from '../components/aca-header.component';
import { AdfFolderDialogComponent } from '../components/dialogs';
export class SharedPage extends BasePage {
private static pageUrl = 'shared';
constructor(page: Page) {
super(page, SharedPage.pageUrl);
}
public acaHeader = new AcaHeader(this.page);
public matMenu = new MatMenuComponent(this.page);
public folderDialog = new AdfFolderDialogComponent(this.page);
public dataTable = new DataTableComponent(this.page);
public viewer = new ViewerComponent(this.page);
}

View File

@ -0,0 +1,22 @@
/*
* Copyright © 2005 - 2021 Alfresco Software, Ltd. 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.
*/
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'
},
};