From b988874df148295735e57062b63d14788ca2f113 Mon Sep 17 00:00:00 2001
From: Akash Rathod <41251473+akashrathod28@users.noreply.github.com>
Date: Mon, 27 Nov 2023 12:04:55 +0100
Subject: [PATCH] [ACS-6398] folder action-available e2e test (#3537)
* [ACS-6398] folder action-avilable test
* review changes
* review changes
* review changes
---
.../src/tests/folders-actions.spec.ts | 117 ++++++++++++++++++
.../tests/special-permissions-actions.test.ts | 5 +-
.../files-folders/folders-actions.test.ts | 38 +-----
.../dataTable/data-table.component.ts | 10 ++
.../src/resources/test-data/index.ts | 1 +
.../test-data/test-data-files-folders.ts | 61 +++++++++
6 files changed, 193 insertions(+), 39 deletions(-)
create mode 100644 e2e/playwright/special-permissions-actions-available/src/tests/folders-actions.spec.ts
create mode 100644 projects/aca-playwright-shared/src/resources/test-data/test-data-files-folders.ts
diff --git a/e2e/playwright/special-permissions-actions-available/src/tests/folders-actions.spec.ts b/e2e/playwright/special-permissions-actions-available/src/tests/folders-actions.spec.ts
new file mode 100644
index 0000000000..fc636d25cd
--- /dev/null
+++ b/e2e/playwright/special-permissions-actions-available/src/tests/folders-actions.spec.ts
@@ -0,0 +1,117 @@
+/*!
+ * 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 .
+ */
+
+import { ApiClientFactory, FavoritesPageApi, PersonalFilesPage, NodesApi, TrashcanApi, Utils, test, timeouts } from '@alfresco/playwright-shared';
+import * as testData from '@alfresco/playwright-shared';
+
+test.describe('Folders - available actions : ', () => {
+ const username = `user-${Utils.random()}`;
+ let parentId: string;
+ let nodesApi: NodesApi;
+ let trashCanActions: TrashcanApi;
+
+ async function checkActionsAvailable(
+ myPersonalFiles: PersonalFilesPage,
+ item: string,
+ expectedToolbarPrimary: string[],
+ expectedToolbarMore: string[]
+ ): Promise {
+ await myPersonalFiles.dataTable.selectItem(item);
+ await myPersonalFiles.acaHeader.verifyToolbarPrimaryActions(expectedToolbarPrimary);
+ await myPersonalFiles.acaHeader.clickMoreActions();
+ await myPersonalFiles.matMenu.verifyActualMoreActions(expectedToolbarMore);
+ }
+
+ async function checkMultipleSelActionsAvailable(
+ myPersonalFiles: PersonalFilesPage,
+ expectedToolbarPrimary: string[],
+ expectedToolbarMore: string[]
+ ): Promise {
+ await myPersonalFiles.acaHeader.verifyToolbarPrimaryActions(expectedToolbarPrimary);
+ await myPersonalFiles.acaHeader.clickMoreActions();
+ await myPersonalFiles.matMenu.verifyActualMoreActions(expectedToolbarMore);
+ }
+
+ test.beforeAll(async () => {
+ test.setTimeout(timeouts.extendedTest);
+ const apiClientFactory = new ApiClientFactory();
+ const parentName = `parent-${Utils.random()}`;
+ await apiClientFactory.setUpAcaBackend('admin');
+ await apiClientFactory.createUser({ username });
+ nodesApi = await NodesApi.initialize(username, username);
+ const favoritesActions = await FavoritesPageApi.initialize(username, username);
+ trashCanActions = await TrashcanApi.initialize(username, username);
+ parentId = (await nodesApi.createFolder(parentName)).entry.id;
+ await nodesApi.createFile(testData.file.name, parentId);
+ await nodesApi.createFolder(testData.folderFile.name, parentId);
+ const folderFavId = (await nodesApi.createFolder(testData.folderFavFile.name, parentId)).entry.id;
+ const initialFavoritesTotalItems = (await favoritesActions.getFavoritesTotalItems(username)) || 0;
+ await favoritesActions.addFavoritesByIds('folder', [folderFavId]);
+ await favoritesActions.waitForApi(username, { expect: initialFavoritesTotalItems + 1 });
+ });
+
+ test.afterAll(async () => {
+ await nodesApi.deleteNodes([parentId]);
+ await trashCanActions.emptyTrashcan();
+ });
+
+ test.describe('on Personal Files : ', () => {
+ test.beforeEach(async ({ personalFiles, loginPage }) => {
+ await personalFiles.navigate({ remoteUrl: `#/personal-files/${parentId}` });
+ await loginPage.loginUser({ username, password: username });
+ });
+
+ test('Folder not favorite - [C213123]', async ({ personalFiles }) => {
+ await personalFiles.dataTable.getRowByName(testData.folderFile.name).click({ button: 'right' });
+ await personalFiles.matMenu.verifyActualMoreActions(testData.folderFile.contextMenu);
+ await checkActionsAvailable(personalFiles, testData.folderFile.name, testData.folderFile.toolbarPrimary, testData.folderFile.toolbarMore);
+ });
+
+ test('Folder favorite - [C280451]', async ({ personalFiles }) => {
+ await personalFiles.dataTable.getRowByName(testData.folderFavFile.name).click({ button: 'right' });
+ await personalFiles.matMenu.verifyActualMoreActions(testData.folderFavFile.contextMenu);
+ await checkActionsAvailable(
+ personalFiles,
+ testData.folderFavFile.name,
+ testData.folderFavFile.toolbarPrimary,
+ testData.folderFavFile.toolbarMore
+ );
+ });
+
+ test('multiple folders - [C280459]', async ({ personalFiles }) => {
+ await personalFiles.dataTable.selectMultiItem(testData.folderFavFile.name, testData.folderFile.name);
+ await personalFiles.dataTable.getRowByName(testData.folderFavFile.name).click({ button: 'right' });
+ await personalFiles.matMenu.verifyActualMoreActions(testData.multipleSelFile.contextMenu);
+ await personalFiles.dataTable.selectMultiItem(testData.folderFavFile.name, testData.folderFile.name);
+ await checkMultipleSelActionsAvailable(personalFiles, testData.multipleSelFile.toolbarPrimary, testData.multipleSelFile.toolbarMore);
+ });
+
+ test('both files and folders - [C280460]', async ({ personalFiles }) => {
+ await personalFiles.dataTable.selectMultiItem(testData.file.name, testData.folderFile.name);
+ await personalFiles.dataTable.getRowByName(testData.folderFile.name).click({ button: 'right' });
+ await personalFiles.matMenu.verifyActualMoreActions(testData.multipleSelFile.contextMenu);
+ await checkMultipleSelActionsAvailable(personalFiles, testData.multipleSelFile.toolbarPrimary, testData.multipleSelFile.toolbarMore);
+ });
+ });
+});
diff --git a/e2e/playwright/special-permissions-actions-available/src/tests/special-permissions-actions.test.ts b/e2e/playwright/special-permissions-actions-available/src/tests/special-permissions-actions.test.ts
index e072108cd7..c2dc09a421 100644
--- a/e2e/playwright/special-permissions-actions-available/src/tests/special-permissions-actions.test.ts
+++ b/e2e/playwright/special-permissions-actions-available/src/tests/special-permissions-actions.test.ts
@@ -34,7 +34,8 @@ import {
SitesApi,
test,
SharedLinksApi,
- SearchPageApi
+ SearchPageApi,
+ timeouts
} from '@alfresco/playwright-shared';
import { Site } from '@alfresco/js-api';
@@ -79,7 +80,7 @@ test.describe('Special permissions : ', () => {
let managerSearchActions: SearchPageApi;
test.beforeAll(async () => {
- test.setTimeout(140000);
+ test.setTimeout(timeouts.extendedTest);
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username: userManager });
await apiClientFactory.createUser({ username: userConsumer });
diff --git a/e2e/protractor/suites/actions-available/files-folders/folders-actions.test.ts b/e2e/protractor/suites/actions-available/files-folders/folders-actions.test.ts
index 344cfcf1c4..608d0a8552 100755
--- a/e2e/protractor/suites/actions-available/files-folders/folders-actions.test.ts
+++ b/e2e/protractor/suites/actions-available/files-folders/folders-actions.test.ts
@@ -43,7 +43,7 @@ describe('Folders - available actions : ', () => {
const loginPage = new LoginPage();
const page = new BrowsingPage();
- const { dataTable, toolbar } = page;
+ const { toolbar } = page;
const { searchInput } = page.pageLayoutHeader;
const searchResultsPage = new SearchResultsPage();
@@ -78,42 +78,6 @@ describe('Folders - available actions : ', () => {
await Utils.pressEscape();
});
- describe('on Personal Files : ', () => {
- beforeAll(async () => {
- await page.clickPersonalFilesAndWait();
- await dataTable.doubleClickOnRowByName(parentName);
- await dataTable.waitForHeader();
- });
-
- it('Folder not favorite - [C213123]', async () => {
- await testUtil.checkToolbarActions(testData.folder.name, testData.folder.toolbarPrimary, testData.folder.toolbarMore);
- await testUtil.checkContextMenu(testData.folder.name, testData.folder.contextMenu);
- });
-
- it('Folder favorite - [C280451]', async () => {
- await testUtil.checkToolbarActions(testData.folderFav.name, testData.folderFav.toolbarPrimary, testData.folderFav.toolbarMore);
- await testUtil.checkContextMenu(testData.folderFav.name, testData.folderFav.contextMenu);
- });
-
- it('multiple folders - [C280459]', async () => {
- await testUtil.checkMultipleSelContextMenu([testData.folderFav.name, testData.folder.name], testData.multipleSel.contextMenu);
- await testUtil.checkMultipleSelToolbarActions(
- [testData.folderFav.name, testData.folder.name],
- testData.multipleSel.toolbarPrimary,
- testData.multipleSel.toolbarMore
- );
- });
-
- it('both files and folders - [C280460]', async () => {
- await testUtil.checkMultipleSelContextMenu([testData.file.name, testData.folder.name], testData.multipleSel.contextMenu);
- await testUtil.checkMultipleSelToolbarActions(
- [testData.file.name, testData.folder.name],
- testData.multipleSel.toolbarPrimary,
- testData.multipleSel.toolbarMore
- );
- });
- });
-
describe('on Favorites Files : ', () => {
beforeAll(async () => {
await page.clickFavoritesAndWait();
diff --git a/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts
index bc5669a233..4e51de20ba 100644
--- a/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts
+++ b/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts
@@ -216,6 +216,16 @@ export class DataTableComponent extends BaseComponent {
}
}
+ async selectMultiItem(name: string, name2: string): Promise {
+ await this.page.keyboard.down('Meta');
+ let row = this.getRowByName(name);
+ await row.locator('[title="Size"]').click();
+ await row.locator('.adf-datatable-selected').waitFor({ state: 'attached' });
+ row = this.getRowByName(name2);
+ await row.locator('[title="Size"]').click();
+ await row.locator('.adf-datatable-selected').waitFor({ state: 'attached' });
+ }
+
async hasCheckMarkIcon(itemName: string): Promise {
const row = this.getRowByName(itemName);
return await row.locator('.adf-datatable-selected').isVisible();
diff --git a/projects/aca-playwright-shared/src/resources/test-data/index.ts b/projects/aca-playwright-shared/src/resources/test-data/index.ts
index 9d04786adc..88e9da4c2c 100644
--- a/projects/aca-playwright-shared/src/resources/test-data/index.ts
+++ b/projects/aca-playwright-shared/src/resources/test-data/index.ts
@@ -23,3 +23,4 @@
*/
export * from './test-data-permissions';
+export * from './test-data-files-folders';
diff --git a/projects/aca-playwright-shared/src/resources/test-data/test-data-files-folders.ts b/projects/aca-playwright-shared/src/resources/test-data/test-data-files-folders.ts
new file mode 100644
index 0000000000..97c76b84ee
--- /dev/null
+++ b/projects/aca-playwright-shared/src/resources/test-data/test-data-files-folders.ts
@@ -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 .
+ */
+
+import { Utils } from '@alfresco/playwright-shared';
+
+const random = Utils.random();
+const multipleSelToolbarPrimary = ['Download', 'View Details', 'More Actions'];
+
+// ---- folders ---
+
+const folderContextMenu = ['Download', 'Edit', 'Favorite', 'Move', 'Copy', 'Delete', 'Edit Aspects', 'Permissions', 'Manage Rules'];
+const folderFavContextMenu = ['Download', 'Edit', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Edit Aspects', 'Permissions', 'Manage Rules'];
+const folderToolbarMore = ['Edit', 'Favorite', 'Move', 'Copy', 'Delete', 'Edit Aspects', 'Permissions', 'Manage Rules'];
+const folderFavToolbarMore = ['Edit', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Edit Aspects', 'Permissions', 'Manage Rules'];
+
+export const folderFile = {
+ name: `folderActions-${random}`,
+ description: 'folder not favorite',
+ contextMenu: folderContextMenu,
+ toolbarPrimary: multipleSelToolbarPrimary,
+ toolbarMore: folderToolbarMore
+};
+
+export const folderFavFile = {
+ name: `folderActions-fav-${random}`,
+ contextMenu: folderFavContextMenu,
+ toolbarPrimary: multipleSelToolbarPrimary,
+ toolbarMore: folderFavToolbarMore
+};
+
+// ---- multiple selection ---
+
+const multipleSelContextMenu = ['Download', 'Favorite', 'Move', 'Copy', 'Delete', 'Permissions'];
+const multipleSelToolbarMore = ['Favorite', 'Move', 'Copy', 'Delete', 'Permissions'];
+
+export const multipleSelFile = {
+ contextMenu: multipleSelContextMenu,
+ toolbarPrimary: multipleSelToolbarPrimary,
+ toolbarMore: multipleSelToolbarMore
+};