Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[ACS-8064] Migrate actions-favorites tests to Playwright #3871

Merged
merged 8 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,8 @@ jobs:
fail-fast: false
matrix:
e2e-suites:
- name: "deleteActions"
id: 7
- name: "editActions,favoriteActions"
id: 8
- name: "uploadDownloadActions"
id: 9
- name: "editActions"
id: 1
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -174,6 +170,10 @@ jobs:
id: 13
- name: "upload-download-actions"
id: 14
- name: "favorite-actions"
id: 15
- name: "delete-actions"
id: 16
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -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;


4 changes: 3 additions & 1 deletion e2e/playwright/delete-actions/exclude.tests.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"C280502": "https://hyland.atlassian.net/browse/ACS-8200"
}
26 changes: 26 additions & 0 deletions e2e/playwright/favorite-actions/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": "../../../.eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"e2e/playwright/favorite-actions/tsconfig.e2e.json"
],
"createDefaultProgram": true
},
"plugins": [
"rxjs",
"unicorn"
],
"rules": {
"@typescript-eslint/no-floating-promises": "off"
}
}
]
}
1 change: 1 addition & 0 deletions e2e/playwright/favorite-actions/exclude.tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
44 changes: 44 additions & 0 deletions e2e/playwright/favorite-actions/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -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 <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, 'Favorite Actions'),
projects: [
{
name: 'Favorite Actions',
testDir: './src/tests',
use: {
users: []
}
}
]
};

export default config;
22 changes: 22 additions & 0 deletions e2e/playwright/favorite-actions/project.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
183 changes: 183 additions & 0 deletions e2e/playwright/favorite-actions/src/tests/mark-favorite.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
/*!
* 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 <http://www.gnu.org/licenses/>.
*/

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;
await nodesApi.createFile(fileNotFavUI, parentId);

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('[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('[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('[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('[XAT-5045] Favorite a file', async ({ personalFiles }) => {
await personalFiles.selectItemsAndToggleFavorite([fileNotFav1], 'Favorite');

expect(await favoritesApi.isFavoriteWithRetry(username, fileNotFav1Id, { expect: true })).toBe(true);
});

test('[XAT-5046] Favorite a folder', async ({ personalFiles }) => {
await personalFiles.selectItemsAndToggleFavorite([folder], 'Favorite');

expect(await favoritesApi.isFavoriteWithRetry(username, folderId, { expect: true })).toBe(true);
});

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('[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('[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);
});
});
});
15 changes: 15 additions & 0 deletions e2e/playwright/favorite-actions/tsconfig.e2e.adf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../../tsconfig.adf.json",
"compilerOptions": {
"outDir": "../../out-tsc/e2e",
"baseUrl": "./",
"module": "commonjs",
"target": "es2017",
"types": ["jasmine", "jasminewd2", "node"],
"skipLibCheck": true,
"paths": {
"@alfresco/playwright-shared": ["../../../projects/aca-playwright-shared/src/index.ts"]
}
},
"exclude": ["node_modules"]
}
15 changes: 15 additions & 0 deletions e2e/playwright/favorite-actions/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -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"]
}
Loading
Loading