From eab5caaf469527f53d031011f043683434e3a3f1 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Tue, 4 Jun 2024 09:55:29 +0200 Subject: [PATCH 1/8] ACS-8064 Migrate actions-favorites tests to Playwright --- .github/workflows/pull-request.yml | 2 + .../favorite-actions/.eslintrc.json | 26 +++ .../favorite-actions/exclude.tests.json | 1 + .../favorite-actions/playwright.config.ts | 44 ++++ e2e/playwright/favorite-actions/project.json | 22 ++ .../src/tests/mark-favorite.e2e.ts | 188 ++++++++++++++++++ .../favorite-actions/tsconfig.e2e.adf.json | 15 ++ .../favorite-actions/tsconfig.e2e.json | 15 ++ .../src/api/favorites-api.ts | 16 ++ 9 files changed, 329 insertions(+) create mode 100644 e2e/playwright/favorite-actions/.eslintrc.json create mode 100644 e2e/playwright/favorite-actions/exclude.tests.json create mode 100644 e2e/playwright/favorite-actions/playwright.config.ts create mode 100644 e2e/playwright/favorite-actions/project.json create mode 100644 e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts create mode 100644 e2e/playwright/favorite-actions/tsconfig.e2e.adf.json create mode 100755 e2e/playwright/favorite-actions/tsconfig.e2e.json diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 7c862d2bd3..d07135a1ec 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -174,6 +174,8 @@ jobs: id: 13 - name: "upload-download-actions" id: 14 + - name: "delete-actions" + id: 15 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/e2e/playwright/favorite-actions/.eslintrc.json b/e2e/playwright/favorite-actions/.eslintrc.json new file mode 100644 index 0000000000..582353ca8f --- /dev/null +++ b/e2e/playwright/favorite-actions/.eslintrc.json @@ -0,0 +1,26 @@ +{ + "extends": "../../../.eslintrc.json", + "ignorePatterns": [ + "!**/*" + ], + "overrides": [ + { + "files": [ + "*.ts" + ], + "parserOptions": { + "project": [ + "e2e/playwright/favorite-actions/tsconfig.e2e.json" + ], + "createDefaultProgram": true + }, + "plugins": [ + "rxjs", + "unicorn" + ], + "rules": { + "@typescript-eslint/no-floating-promises": "off" + } + } + ] +} diff --git a/e2e/playwright/favorite-actions/exclude.tests.json b/e2e/playwright/favorite-actions/exclude.tests.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/e2e/playwright/favorite-actions/exclude.tests.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/e2e/playwright/favorite-actions/playwright.config.ts b/e2e/playwright/favorite-actions/playwright.config.ts new file mode 100644 index 0000000000..018c367f9d --- /dev/null +++ b/e2e/playwright/favorite-actions/playwright.config.ts @@ -0,0 +1,44 @@ +/*! + * Copyright © 2005-2024 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 { PlaywrightTestConfig } from '@playwright/test'; +import { CustomConfig, getGlobalConfig, getExcludedTestsRegExpArray } from '@alfresco/playwright-shared'; +import EXCLUDED_JSON from './exclude.tests.json'; + +const config: PlaywrightTestConfig = { + ...getGlobalConfig, + + grepInvert: getExcludedTestsRegExpArray(EXCLUDED_JSON, 'Favorite Actions'), + projects: [ + { + name: 'Favorite Actions', + testDir: './src/tests', + use: { + users: [] + } + } + ] +}; + +export default config; diff --git a/e2e/playwright/favorite-actions/project.json b/e2e/playwright/favorite-actions/project.json new file mode 100644 index 0000000000..20fec7c673 --- /dev/null +++ b/e2e/playwright/favorite-actions/project.json @@ -0,0 +1,22 @@ +{ + "name": "favorite-actions-e2e", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "e2e/playwright/favorite-actions", + "projectType": "application", + "targets": { + "e2e": { + "executor": "nx:run-commands", + "options": { + "commands": ["npx playwright test --config=e2e/playwright/favorite-actions/playwright.config.ts"] + }, + "configurations": { + "production": { + "devServerTarget": "content-ce:serve:production" + } + } + }, + "lint": { + "executor": "@angular-eslint/builder:lint" + } + } +} diff --git a/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts b/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts new file mode 100644 index 0000000000..8aa1300c8a --- /dev/null +++ b/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts @@ -0,0 +1,188 @@ +/*! + * Copyright © 2005-2024 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 { expect } from '@playwright/test'; +import { ApiClientFactory, Utils, test, TrashcanApi, NodesApi, FavoritesPageApi, SharedLinksApi } from '@alfresco/playwright-shared'; + +test.describe('Mark items as favorites', () => { + let trashcanApi: TrashcanApi; + let nodesApi: NodesApi; + let favoritesApi: FavoritesPageApi; + let sharedApi: SharedLinksApi; + + const username = `user-${Utils.random()}`; + const parent = `parent-${Utils.random()}`; + + const fileNotFavUI = `fileNotFavUI-${Utils.random()}.txt`; + const fileFavUI = `fileFavUI-${Utils.random()}.txt`; + const fileNotFav1 = `fileNotFav1-${Utils.random()}.txt`; + const fileNotFav2 = `fileNotFav2-${Utils.random()}.txt`; + const fileNotFav3 = `fileNotFav3-${Utils.random()}.txt`; + const fileNotFav4 = `fileNotFav4-${Utils.random()}.txt`; + const fileFav1 = `fileFav1-${Utils.random()}.txt`; + const fileFav2 = `fileFav2-${Utils.random()}.txt`; + const fileFav3 = `fileFav3-${Utils.random()}.txt`; + const fileFav4 = `fileFav4-${Utils.random()}.txt`; + const folder = `folder-${Utils.random()}`; + + let fileFavUIId: string; + let fileNotFav1Id: string; + let fileNotFav2Id: string; + let fileNotFav3Id: string; + let fileNotFav4Id: string; + let fileFav1Id: string; + let fileFav2Id: string; + let fileFav3Id: string; + let fileFav4Id: string; + let folderId: string; + let parentId: string; + + test.beforeAll(async () => { + try { + const apiClientFactory = new ApiClientFactory(); + await apiClientFactory.setUpAcaBackend('admin'); + await apiClientFactory.createUser({ username }); + trashcanApi = await TrashcanApi.initialize(username, username); + nodesApi = await NodesApi.initialize(username, username); + favoritesApi = await FavoritesPageApi.initialize(username, username); + sharedApi = await SharedLinksApi.initialize(username, username); + + parentId = (await nodesApi.createFolder(parent)).entry.id; + fileFavUIId = (await nodesApi.createFile(fileFavUI, parentId)).entry.id; + fileNotFav1Id = (await nodesApi.createFile(fileNotFav1, parentId)).entry.id; + fileNotFav2Id = (await nodesApi.createFile(fileNotFav2, parentId)).entry.id; + fileNotFav3Id = (await nodesApi.createFile(fileNotFav3, parentId)).entry.id; + fileNotFav4Id = (await nodesApi.createFile(fileNotFav4, parentId)).entry.id; + fileFav1Id = (await nodesApi.createFile(fileFav1, parentId)).entry.id; + fileFav2Id = (await nodesApi.createFile(fileFav2, parentId)).entry.id; + fileFav3Id = (await nodesApi.createFile(fileFav3, parentId)).entry.id; + fileFav4Id = (await nodesApi.createFile(fileFav4, parentId)).entry.id; + folderId = (await nodesApi.createFolder(folder, parentId)).entry.id; + + const currentFavoritesTotalItems = await favoritesApi.getFavoritesTotalItems(username); + await favoritesApi.addFavoritesByIds('file', [fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id]); + await favoritesApi.waitForApi(username, { expect: currentFavoritesTotalItems + 5 }); + + await sharedApi.shareFilesByIds([fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id]); + await sharedApi.shareFilesByIds([fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id]); + await sharedApi.waitForFilesToBeShared([ + fileFav1Id, + fileFav2Id, + fileFav3Id, + fileFav4Id, + fileNotFav1Id, + fileNotFav2Id, + fileNotFav3Id, + fileNotFav4Id + ]); + } catch (error) { + console.error(`beforeAll failed: ${error}`); + } + }); + + test.beforeEach(async ({ loginPage }) => { + await Utils.tryLoginUser(loginPage, username, username, 'beforeEach failed'); + }); + + test.afterAll(async () => { + await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed'); + }); + + test.describe('on Personal Files', () => { + test.afterAll(async () => { + try { + await favoritesApi.addFavoritesByIds('file', [fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id]); + await favoritesApi.addFavoriteById('folder', folderId); + await favoritesApi.removeFavoritesByIds(username, [fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id]); + } catch (error) {} + }); + + test.beforeEach(async ({ personalFiles }) => { + await personalFiles.dataTable.performClickFolderOrFileToOpen(parent); + }); + + test('Favorite action has empty star icon for an item not marked as favorite', async ({ personalFiles }) => { + await personalFiles.dataTable.selectItem(fileNotFavUI); + await personalFiles.acaHeader.clickMoreActions(); + expect(await personalFiles.matMenu.isMenuItemVisible('Favorite')).toBe(true); + }); + + test('Favorite action has empty star icon for multiple selection of items when some are not favorite', async ({ personalFiles }) => { + await personalFiles.dataTable.selectMultiItem(fileNotFavUI, fileFavUI); + await personalFiles.acaHeader.clickMoreActions(); + expect(await personalFiles.matMenu.isMenuItemVisible('Favorite')).toBe(true); + }); + + test('Favorite action has full star icon for items marked as favorite', async ({ personalFiles }) => { + await personalFiles.dataTable.selectItem(fileFavUI); + await personalFiles.acaHeader.clickMoreActions(); + expect(await personalFiles.matMenu.isMenuItemVisible('Remove Favorite')).toBe(true); + }); + + test('favorite a file', async ({ personalFiles }) => { + await personalFiles.dataTable.selectItem(fileNotFav1); + await personalFiles.acaHeader.clickMoreActions(); + await personalFiles.matMenu.clickMenuItem('Favorite'); + expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav1Id, { expect: true })).toBe(true); + }); + + test('favorite a folder', async ({ personalFiles }) => { + await personalFiles.dataTable.selectItem(folder); + await personalFiles.acaHeader.clickMoreActions(); + await personalFiles.matMenu.clickMenuItem('Favorite'); + expect(await favoritesApi.isFavoriteWithRetry(username, folderId, { expect: true })).toBe(true); + }); + + test('unfavorite an item', async ({ personalFiles }) => { + await personalFiles.dataTable.selectItem(fileFav1); + await personalFiles.acaHeader.clickMoreActions(); + await personalFiles.matMenu.clickMenuItem('Remove Favorite'); + expect(await favoritesApi.isFavoriteWithRetry(username, fileFav1Id, { expect: false })).toBe(false); + }); + + test('favorite multiple items - all unfavorite', async ({ personalFiles }) => { + await personalFiles.dataTable.selectMultiItem(fileNotFav2, fileNotFav3); + await personalFiles.acaHeader.clickMoreActions(); + await personalFiles.matMenu.clickMenuItem('Favorite'); + expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav2Id, { expect: true })).toBe(true); + expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav3Id, { expect: true })).toBe(true); + }); + + test('favorite multiple items - some favorite and some unfavorite', async ({ personalFiles }) => { + await personalFiles.dataTable.selectMultiItem(fileNotFav4, fileFav2); + await personalFiles.acaHeader.clickMoreActions(); + await personalFiles.matMenu.clickMenuItem('Favorite'); + expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav4Id, { expect: true })).toBe(true); + expect(await favoritesApi.isFavoriteWithRetry(username, fileFav2Id, { expect: true })).toBe(true); + }); + + test('unfavorite multiple items', async ({ personalFiles }) => { + await personalFiles.dataTable.selectMultiItem(fileFav3, fileFav4); + await personalFiles.acaHeader.clickMoreActions(); + await personalFiles.matMenu.clickMenuItem('Remove Favorite'); + expect(await favoritesApi.isFavoriteWithRetry(username, fileFav3Id, { expect: false })).toBe(false); + expect(await favoritesApi.isFavoriteWithRetry(username, fileFav4Id, { expect: false })).toBe(false); + }); + }); +}); diff --git a/e2e/playwright/favorite-actions/tsconfig.e2e.adf.json b/e2e/playwright/favorite-actions/tsconfig.e2e.adf.json new file mode 100644 index 0000000000..87cbcf775a --- /dev/null +++ b/e2e/playwright/favorite-actions/tsconfig.e2e.adf.json @@ -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"] +} diff --git a/e2e/playwright/favorite-actions/tsconfig.e2e.json b/e2e/playwright/favorite-actions/tsconfig.e2e.json new file mode 100755 index 0000000000..c317985239 --- /dev/null +++ b/e2e/playwright/favorite-actions/tsconfig.e2e.json @@ -0,0 +1,15 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/e2e", + "baseUrl": "./", + "module": "commonjs", + "target": "es2017", + "types": ["jasmine", "jasminewd2", "node", "@playwright/test"], + "skipLibCheck": true, + "paths": { + "@alfresco/playwright-shared": ["../../../projects/aca-playwright-shared/src/index.ts"] + } + }, + "exclude": ["node_modules"] +} diff --git a/projects/aca-playwright-shared/src/api/favorites-api.ts b/projects/aca-playwright-shared/src/api/favorites-api.ts index 4f1a26b210..384999a756 100755 --- a/projects/aca-playwright-shared/src/api/favorites-api.ts +++ b/projects/aca-playwright-shared/src/api/favorites-api.ts @@ -115,4 +115,20 @@ export class FavoritesPageApi { return await Utils.retryCall(favoriteFiles); } catch {} } + + async removeFavoriteById(username: string, nodeId: string): Promise { + try { + await this.apiService.favorites.deleteFavorite(username, nodeId); + } catch {} + } + + async removeFavoritesByIds(username: string, ids: string[]): Promise { + try { + if (ids && ids.length > 0) { + for (const id of ids) { + await this.removeFavoriteById(username, id); + } + } + } catch {} + } } From df7e8c29ebfab148bf81cc624e4f1db599dc7585 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Wed, 5 Jun 2024 00:48:52 +0200 Subject: [PATCH 2/8] Removed protractor tests, fixes --- .../src/tests/mark-favorite.e2e.ts | 1 + .../actions/favorite/mark-favorite.test.ts | 195 ------------------ 2 files changed, 1 insertion(+), 195 deletions(-) delete mode 100644 e2e/protractor/suites/actions/favorite/mark-favorite.test.ts diff --git a/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts b/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts index 8aa1300c8a..af18b7a243 100644 --- a/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts +++ b/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts @@ -79,6 +79,7 @@ test.describe('Mark items as favorites', () => { fileFav3Id = (await nodesApi.createFile(fileFav3, parentId)).entry.id; fileFav4Id = (await nodesApi.createFile(fileFav4, parentId)).entry.id; folderId = (await nodesApi.createFolder(folder, parentId)).entry.id; + await nodesApi.createFile(fileNotFavUI, parentId); const currentFavoritesTotalItems = await favoritesApi.getFavoritesTotalItems(username); await favoritesApi.addFavoritesByIds('file', [fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id]); diff --git a/e2e/protractor/suites/actions/favorite/mark-favorite.test.ts b/e2e/protractor/suites/actions/favorite/mark-favorite.test.ts deleted file mode 100644 index 79ae6e80de..0000000000 --- a/e2e/protractor/suites/actions/favorite/mark-favorite.test.ts +++ /dev/null @@ -1,195 +0,0 @@ -/*! - * Copyright © 2005-2024 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 { AdminActions, LoginPage, BrowsingPage, RepoClient, Utils, UserActions } from '@alfresco/aca-testing-shared'; - -describe('Mark items as favorites', () => { - const username = `user-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; - - const fileNotFavUI = `fileNotFavUI-${Utils.random()}.txt`; - const fileFavUI = `fileFavUI-${Utils.random()}.txt`; - const fileNotFav1 = `fileNotFav1-${Utils.random()}.txt`; - const fileNotFav2 = `fileNotFav2-${Utils.random()}.txt`; - const fileNotFav3 = `fileNotFav3-${Utils.random()}.txt`; - const fileNotFav4 = `fileNotFav4-${Utils.random()}.txt`; - const fileFav1 = `fileFav1-${Utils.random()}.txt`; - const fileFav2 = `fileFav2-${Utils.random()}.txt`; - const fileFav3 = `fileFav3-${Utils.random()}.txt`; - const fileFav4 = `fileFav4-${Utils.random()}.txt`; - const folder = `folder-${Utils.random()}`; - - let fileFavUIId: string; - let fileNotFav1Id: string; - let fileNotFav2Id: string; - let fileNotFav3Id: string; - let fileNotFav4Id: string; - let fileFav1Id: string; - let fileFav2Id: string; - let fileFav3Id: string; - let fileFav4Id: string; - let folderId: string; - let parentId: string; - - const apis = { - user: new RepoClient(username, username) - }; - - const loginPage = new LoginPage(); - const page = new BrowsingPage(); - const { dataTable, toolbar } = page; - - const adminApiActions = new AdminActions(); - const userActions = new UserActions(); - - beforeAll(async () => { - await adminApiActions.createUser({ username }); - await userActions.login(username, username); - - parentId = (await apis.user.nodes.createFolder(parent)).entry.id; - - await apis.user.nodes.createFile(fileNotFavUI, parentId); - fileFavUIId = (await apis.user.nodes.createFile(fileFavUI, parentId)).entry.id; - fileNotFav1Id = (await apis.user.nodes.createFile(fileNotFav1, parentId)).entry.id; - fileNotFav2Id = (await apis.user.nodes.createFile(fileNotFav2, parentId)).entry.id; - fileNotFav3Id = (await apis.user.nodes.createFile(fileNotFav3, parentId)).entry.id; - fileNotFav4Id = (await apis.user.nodes.createFile(fileNotFav4, parentId)).entry.id; - fileFav1Id = (await apis.user.nodes.createFile(fileFav1, parentId)).entry.id; - fileFav2Id = (await apis.user.nodes.createFile(fileFav2, parentId)).entry.id; - fileFav3Id = (await apis.user.nodes.createFile(fileFav3, parentId)).entry.id; - fileFav4Id = (await apis.user.nodes.createFile(fileFav4, parentId)).entry.id; - folderId = (await apis.user.nodes.createFolder(folder, parentId)).entry.id; - - const currentFavoritesTotalItems = await apis.user.favorites.getFavoritesTotalItems(); - await apis.user.favorites.addFavoritesByIds('file', [fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id]); - await apis.user.favorites.waitForApi({ expect: currentFavoritesTotalItems + 5 }); - - await apis.user.shared.shareFilesByIds([fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id]); - await apis.user.shared.shareFilesByIds([fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id]); - await apis.user.shared.waitForFilesToBeShared([ - fileFav1Id, - fileFav2Id, - fileFav3Id, - fileFav4Id, - fileNotFav1Id, - fileNotFav2Id, - fileNotFav3Id, - fileNotFav4Id - ]); - - await loginPage.loginWith(username); - }); - - afterAll(async () => { - await apis.user.nodes.deleteNodeById(parentId); - }); - - afterEach(async () => { - await Utils.pressEscape(); - }); - - describe('on Personal Files', () => { - afterAll(async () => { - try { - await apis.user.favorites.addFavoritesByIds('file', [fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id]); - await apis.user.favorites.addFavoriteById('folder', folderId); - await apis.user.favorites.removeFavoritesByIds([fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id]); - } catch (error) {} - }); - - beforeEach(async () => { - await page.clickPersonalFilesAndWait(); - await dataTable.doubleClickOnRowByName(parent); - }); - - it('[C217186] Favorite action has empty star icon for an item not marked as favorite', async () => { - await dataTable.selectItem(fileNotFavUI); - await toolbar.openMoreMenu(); - - expect(await toolbar.menu.getItemIconText('Favorite')).toEqual('star_border'); - await toolbar.closeMoreMenu(); - }); - - it('[C217187] Favorite action has empty star icon for multiple selection of items when some are not favorite', async () => { - await dataTable.selectMultipleItems([fileNotFavUI, fileFavUI]); - await toolbar.openMoreMenu(); - - expect(await toolbar.menu.getItemIconText('Favorite')).toEqual('star_border'); - await toolbar.closeMoreMenu(); - }); - - it('[C217188] Favorite action has full star icon for items marked as favorite', async () => { - await dataTable.selectItem(fileFavUI); - await toolbar.openMoreMenu(); - - expect(await toolbar.menu.getItemIconText('Remove Favorite')).toEqual('star'); - await toolbar.closeMoreMenu(); - }); - - it('[C217189] favorite a file', async () => { - await dataTable.selectItem(fileNotFav1); - await toolbar.clickMoreActionsFavorite(); - - expect(await apis.user.favorites.isFavoriteWithRetry(fileNotFav1Id, { expect: true })).toBe(true, `${fileNotFav1} not marked as favorite`); - }); - - it('[C280390] favorite a folder', async () => { - await dataTable.selectItem(folder); - await toolbar.clickMoreActionsFavorite(); - - expect(await apis.user.favorites.isFavoriteWithRetry(folderId, { expect: true })).toBe(true, `${folder} not marked as favorite`); - }); - - it('[C217190] unfavorite an item', async () => { - await dataTable.selectItem(fileFav1); - await toolbar.clickMoreActionsRemoveFavorite(); - - expect(await apis.user.favorites.isFavoriteWithRetry(fileFav1Id, { expect: false })).toBe(false, `${fileFav1} is marked as favorite`); - }); - - it('[C217192] favorite multiple items - all unfavorite', async () => { - await dataTable.selectMultipleItems([fileNotFav2, fileNotFav3]); - await toolbar.clickMoreActionsFavorite(); - - expect(await apis.user.favorites.isFavoriteWithRetry(fileNotFav2Id, { expect: true })).toBe(true, `${fileNotFav2} not marked as favorite`); - expect(await apis.user.favorites.isFavoriteWithRetry(fileNotFav3Id, { expect: true })).toBe(true, `${fileNotFav3} not marked as favorite`); - }); - - it('[C217194] favorite multiple items - some favorite and some unfavorite', async () => { - await dataTable.selectMultipleItems([fileNotFav4, fileFav2]); - await toolbar.clickMoreActionsFavorite(); - - expect(await apis.user.favorites.isFavoriteWithRetry(fileNotFav4Id, { expect: true })).toBe(true, `${fileNotFav4} not marked as favorite`); - expect(await apis.user.favorites.isFavoriteWithRetry(fileFav2Id, { expect: true })).toBe(true, `${fileFav2} not marked as favorite`); - }); - - it('[C217193] unfavorite multiple items', async () => { - await dataTable.selectMultipleItems([fileFav3, fileFav4]); - await toolbar.clickMoreActionsRemoveFavorite(); - - expect(await apis.user.favorites.isFavoriteWithRetry(fileFav3Id, { expect: false })).toBe(false, `${fileFav3} marked as favorite`); - expect(await apis.user.favorites.isFavoriteWithRetry(fileFav4Id, { expect: false })).toBe(false, `${fileFav4} marked as favorite`); - }); - }); -}); From c94220812f691510c2c8516c8f8ac7b0568a5c84 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Wed, 5 Jun 2024 12:02:53 +0200 Subject: [PATCH 3/8] Fixed github config --- .github/workflows/pull-request.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index d07135a1ec..d7199f5864 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -102,11 +102,9 @@ jobs: matrix: e2e-suites: - name: "deleteActions" - id: 7 - - name: "editActions,favoriteActions" - id: 8 - - name: "uploadDownloadActions" - id: 9 + id: 1 + - name: "editActions" + id: 2 steps: - name: Checkout uses: actions/checkout@v3 From 06fe3f99eccd02b15b078e045ce8c3f5167f5dd4 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Wed, 5 Jun 2024 12:07:02 +0200 Subject: [PATCH 4/8] Fixed github config --- .github/workflows/pull-request.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index d7199f5864..3c23368e84 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -101,10 +101,8 @@ jobs: fail-fast: false matrix: e2e-suites: - - name: "deleteActions" - id: 1 - name: "editActions" - id: 2 + id: 1 steps: - name: Checkout uses: actions/checkout@v3 @@ -172,8 +170,10 @@ jobs: id: 13 - name: "upload-download-actions" id: 14 - - name: "delete-actions" + - name: "favorite-actions" id: 15 + - name: "delete-actions" + id: 16 steps: - name: Checkout uses: actions/checkout@v3 @@ -240,5 +240,3 @@ jobs: echo -e "\e[31mPRs are not mergeable with conditional build. This build was run with custom ADF branch: $BRANCH \e[0m" exit 1 fi; - - From e2034c5458de4d1fe635cc4b6260665b4f60088b Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Wed, 5 Jun 2024 12:19:40 +0200 Subject: [PATCH 5/8] Added error log --- projects/aca-playwright-shared/src/api/favorites-api.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/projects/aca-playwright-shared/src/api/favorites-api.ts b/projects/aca-playwright-shared/src/api/favorites-api.ts index 384999a756..2190c87472 100755 --- a/projects/aca-playwright-shared/src/api/favorites-api.ts +++ b/projects/aca-playwright-shared/src/api/favorites-api.ts @@ -119,7 +119,9 @@ export class FavoritesPageApi { async removeFavoriteById(username: string, nodeId: string): Promise { try { await this.apiService.favorites.deleteFavorite(username, nodeId); - } catch {} + } catch (error) { + console.error('FavoritesApi: removeFavoriteById failed ', error); + } } async removeFavoritesByIds(username: string, ids: string[]): Promise { @@ -129,6 +131,8 @@ export class FavoritesPageApi { await this.removeFavoriteById(username, id); } } - } catch {} + } catch (error) { + console.error('FavoritesApi: removeFavoritesByIds failed ', error); + } } } From ca13185b6e822e8abb2a7b22b1956f5dae1e517f Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Mon, 10 Jun 2024 13:45:57 +0200 Subject: [PATCH 6/8] CR comments fixes --- .../src/tests/mark-favorite.e2e.ts | 30 ++++++++----------- .../src/api/favorites-api.ts | 10 +------ .../page-objects/pages/personal-files.page.ts | 8 +++++ 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts b/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts index af18b7a243..76232fd402 100644 --- a/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts +++ b/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts @@ -142,46 +142,40 @@ test.describe('Mark items as favorites', () => { }); test('favorite a file', async ({ personalFiles }) => { - await personalFiles.dataTable.selectItem(fileNotFav1); - await personalFiles.acaHeader.clickMoreActions(); - await personalFiles.matMenu.clickMenuItem('Favorite'); + await personalFiles.selectItemsAndToggleFavorite([fileNotFav1], 'Favorite'); + expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav1Id, { expect: true })).toBe(true); }); test('favorite a folder', async ({ personalFiles }) => { - await personalFiles.dataTable.selectItem(folder); - await personalFiles.acaHeader.clickMoreActions(); - await personalFiles.matMenu.clickMenuItem('Favorite'); + await personalFiles.selectItemsAndToggleFavorite([folder], 'Favorite'); + expect(await favoritesApi.isFavoriteWithRetry(username, folderId, { expect: true })).toBe(true); }); test('unfavorite an item', async ({ personalFiles }) => { - await personalFiles.dataTable.selectItem(fileFav1); - await personalFiles.acaHeader.clickMoreActions(); - await personalFiles.matMenu.clickMenuItem('Remove Favorite'); + await personalFiles.selectItemsAndToggleFavorite([fileFav1], 'Remove Favorite'); + expect(await favoritesApi.isFavoriteWithRetry(username, fileFav1Id, { expect: false })).toBe(false); }); test('favorite multiple items - all unfavorite', async ({ personalFiles }) => { - await personalFiles.dataTable.selectMultiItem(fileNotFav2, fileNotFav3); - await personalFiles.acaHeader.clickMoreActions(); - await personalFiles.matMenu.clickMenuItem('Favorite'); + await personalFiles.selectItemsAndToggleFavorite([fileNotFav2, fileNotFav3], 'Favorite'); + expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav2Id, { expect: true })).toBe(true); expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav3Id, { expect: true })).toBe(true); }); test('favorite multiple items - some favorite and some unfavorite', async ({ personalFiles }) => { - await personalFiles.dataTable.selectMultiItem(fileNotFav4, fileFav2); - await personalFiles.acaHeader.clickMoreActions(); - await personalFiles.matMenu.clickMenuItem('Favorite'); + await personalFiles.selectItemsAndToggleFavorite([fileNotFav4, fileFav2], 'Favorite'); + expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav4Id, { expect: true })).toBe(true); expect(await favoritesApi.isFavoriteWithRetry(username, fileFav2Id, { expect: true })).toBe(true); }); test('unfavorite multiple items', async ({ personalFiles }) => { - await personalFiles.dataTable.selectMultiItem(fileFav3, fileFav4); - await personalFiles.acaHeader.clickMoreActions(); - await personalFiles.matMenu.clickMenuItem('Remove Favorite'); + await personalFiles.selectItemsAndToggleFavorite([fileFav3, fileFav4], 'Remove Favorite'); + expect(await favoritesApi.isFavoriteWithRetry(username, fileFav3Id, { expect: false })).toBe(false); expect(await favoritesApi.isFavoriteWithRetry(username, fileFav4Id, { expect: false })).toBe(false); }); diff --git a/projects/aca-playwright-shared/src/api/favorites-api.ts b/projects/aca-playwright-shared/src/api/favorites-api.ts index 2190c87472..d676a81c73 100755 --- a/projects/aca-playwright-shared/src/api/favorites-api.ts +++ b/projects/aca-playwright-shared/src/api/favorites-api.ts @@ -116,19 +116,11 @@ export class FavoritesPageApi { } catch {} } - async removeFavoriteById(username: string, nodeId: string): Promise { - try { - await this.apiService.favorites.deleteFavorite(username, nodeId); - } catch (error) { - console.error('FavoritesApi: removeFavoriteById failed ', error); - } - } - async removeFavoritesByIds(username: string, ids: string[]): Promise { try { if (ids && ids.length > 0) { for (const id of ids) { - await this.removeFavoriteById(username, id); + await this.apiService.favorites.deleteFavorite(username, id); } } } catch (error) { diff --git a/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts index dcf7f17dc2..9b3eea07b3 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts @@ -103,4 +103,12 @@ export class PersonalFilesPage extends BasePage { await this.contentNodeSelector.selectDestination(destinationName); await this.contentNodeSelector.actionButton.click(); } + + async selectItemsAndToggleFavorite(item: string[], action: 'Favorite' | 'Remove Favorite') { + for (const itemToSelect of item) { + await this.dataTable.selectItem(itemToSelect); + } + await this.acaHeader.clickMoreActions(); + await this.matMenu.clickMenuItem(action); + } } From 95684ea54fd1c2fb18d68c7013731770a615343c Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Thu, 13 Jun 2024 01:39:27 +0200 Subject: [PATCH 7/8] Added xray test IDs --- .github/workflows/pull-request.yml | 2 -- .../src/tests/mark-favorite.e2e.ts | 30 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3c23368e84..60ff145872 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -172,8 +172,6 @@ jobs: id: 14 - name: "favorite-actions" id: 15 - - name: "delete-actions" - id: 16 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts b/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts index 76232fd402..762a866710 100644 --- a/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts +++ b/e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts @@ -123,61 +123,61 @@ test.describe('Mark items as favorites', () => { await personalFiles.dataTable.performClickFolderOrFileToOpen(parent); }); - test('Favorite action has empty star icon for an item not marked as favorite', async ({ personalFiles }) => { + test('[XAT-5042] Favorite action has empty star icon for an item not marked as favorite', async ({ personalFiles }) => { await personalFiles.dataTable.selectItem(fileNotFavUI); await personalFiles.acaHeader.clickMoreActions(); expect(await personalFiles.matMenu.isMenuItemVisible('Favorite')).toBe(true); }); - test('Favorite action has empty star icon for multiple selection of items when some are not favorite', async ({ personalFiles }) => { + test('[XAT-5043] Favorite action has empty star icon for multiple selection of items when some are not favorite', async ({ personalFiles }) => { await personalFiles.dataTable.selectMultiItem(fileNotFavUI, fileFavUI); await personalFiles.acaHeader.clickMoreActions(); expect(await personalFiles.matMenu.isMenuItemVisible('Favorite')).toBe(true); }); - test('Favorite action has full star icon for items marked as favorite', async ({ personalFiles }) => { + test('[XAT-5044] Favorite action has full star icon for items marked as favorite', async ({ personalFiles }) => { await personalFiles.dataTable.selectItem(fileFavUI); await personalFiles.acaHeader.clickMoreActions(); expect(await personalFiles.matMenu.isMenuItemVisible('Remove Favorite')).toBe(true); }); - test('favorite a file', async ({ personalFiles }) => { + test('[XAT-5045] Favorite a file', async ({ personalFiles }) => { await personalFiles.selectItemsAndToggleFavorite([fileNotFav1], 'Favorite'); expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav1Id, { expect: true })).toBe(true); }); - test('favorite a folder', async ({ personalFiles }) => { + test('[XAT-5046] Favorite a folder', async ({ personalFiles }) => { await personalFiles.selectItemsAndToggleFavorite([folder], 'Favorite'); expect(await favoritesApi.isFavoriteWithRetry(username, folderId, { expect: true })).toBe(true); }); - test('unfavorite an item', async ({ personalFiles }) => { + test('[XAT-5047] Unfavorite an item', async ({ personalFiles }) => { await personalFiles.selectItemsAndToggleFavorite([fileFav1], 'Remove Favorite'); expect(await favoritesApi.isFavoriteWithRetry(username, fileFav1Id, { expect: false })).toBe(false); }); - test('favorite multiple items - all unfavorite', async ({ personalFiles }) => { + test('[XAT-5048] Favorite multiple items - all unfavorite', async ({ personalFiles }) => { await personalFiles.selectItemsAndToggleFavorite([fileNotFav2, fileNotFav3], 'Favorite'); expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav2Id, { expect: true })).toBe(true); expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav3Id, { expect: true })).toBe(true); }); - test('favorite multiple items - some favorite and some unfavorite', async ({ personalFiles }) => { - await personalFiles.selectItemsAndToggleFavorite([fileNotFav4, fileFav2], 'Favorite'); - - expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav4Id, { expect: true })).toBe(true); - expect(await favoritesApi.isFavoriteWithRetry(username, fileFav2Id, { expect: true })).toBe(true); - }); - - test('unfavorite multiple items', async ({ personalFiles }) => { + test('[XAT-5049] Unfavorite multiple items', async ({ personalFiles }) => { await personalFiles.selectItemsAndToggleFavorite([fileFav3, fileFav4], 'Remove Favorite'); expect(await favoritesApi.isFavoriteWithRetry(username, fileFav3Id, { expect: false })).toBe(false); expect(await favoritesApi.isFavoriteWithRetry(username, fileFav4Id, { expect: false })).toBe(false); }); + + test('[XAT-5050] Favorite multiple items - some favorite and some unfavorite', async ({ personalFiles }) => { + await personalFiles.selectItemsAndToggleFavorite([fileNotFav4, fileFav2], 'Favorite'); + + expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav4Id, { expect: true })).toBe(true); + expect(await favoritesApi.isFavoriteWithRetry(username, fileFav2Id, { expect: true })).toBe(true); + }); }); }); From 0bffb21552a5793dbc8e3c981dec83526a781043 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Thu, 13 Jun 2024 10:45:58 +0200 Subject: [PATCH 8/8] Added failing test in delete-actions to excluded --- .github/workflows/pull-request.yml | 2 ++ e2e/playwright/delete-actions/exclude.tests.json | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 60ff145872..3c23368e84 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -172,6 +172,8 @@ jobs: id: 14 - name: "favorite-actions" id: 15 + - name: "delete-actions" + id: 16 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/e2e/playwright/delete-actions/exclude.tests.json b/e2e/playwright/delete-actions/exclude.tests.json index 0967ef424b..893d21a54a 100644 --- a/e2e/playwright/delete-actions/exclude.tests.json +++ b/e2e/playwright/delete-actions/exclude.tests.json @@ -1 +1,3 @@ -{} +{ + "C280502": "https://hyland.atlassian.net/browse/ACS-8200" +}