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-5882] infoDrawer comments tests migrated to Playwright #3615

Merged
26 changes: 26 additions & 0 deletions e2e/playwright/info-drawer/.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/info-drawer/tsconfig.e2e.json"
],
"createDefaultProgram": true
},
"plugins": [
"rxjs",
"unicorn"
],
"rules": {
"@typescript-eslint/no-floating-promises": "off"
}
}
]
}
4 changes: 4 additions & 0 deletions e2e/playwright/info-drawer/exclude.tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"C299195" : "https://alfresco.atlassian.net/browse/ACS-6688",
"C299189" : "https://alfresco.atlassian.net/browse/ACS-6688"
}
44 changes: 44 additions & 0 deletions e2e/playwright/info-drawer/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*!
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { PlaywrightTestConfig } from '@playwright/test';
import { CustomConfig, getGlobalConfig, getExcludedTestsRegExpArray } from '@alfresco/playwright-shared';
import EXCLUDED_JSON from './exclude.tests.json';

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

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

export default config;
22 changes: 22 additions & 0 deletions e2e/playwright/info-drawer/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "info-drawer-e2e",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/playwright/info-drawer",
"projectType": "application",
"targets": {
"e2e": {
"executor": "nx:run-commands",
"options": {
"commands": ["npx playwright test --config=e2e/playwright/info-drawer/playwright.config.ts"]
},
"configurations": {
"production": {
"devServerTarget": "content-ce:serve:production"
}
}
},
"lint": {
"executor": "@angular-eslint/builder:lint"
}
}
}
154 changes: 154 additions & 0 deletions e2e/playwright/info-drawer/src/tests/comments.spec.ts
datguychen marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*!
* 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, Utils, test, TrashcanApi, FavoritesPageApi, NodesApi, FileActionsApi } from '@alfresco/playwright-shared';

test.describe('Info Drawer - Comments', () => {
const apiClientFactory = new ApiClientFactory();
let nodesApi: NodesApi;
let trashcanApi: TrashcanApi;
let fileActionsApi: FileActionsApi;
let favoritesActions: FavoritesPageApi;
const username = `user-e2e-${Utils.random()}`;
const commentText = `comment-e2e-${Utils.random()}`;

test.beforeAll(async () => {
try {
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
nodesApi = await NodesApi.initialize(username, username);
trashcanApi = await TrashcanApi.initialize(username, username);
favoritesActions = await FavoritesPageApi.initialize(username, username);
fileActionsApi = await FileActionsApi.initialize(username, username);
} catch (error) {
console.error(`beforeAll failed : ${error}`);
}
});

test.beforeEach(async ({ loginPage }) => {
try {
await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true });
} catch (error) {
console.error(`Main beforeEach failed: ${error}`);
}
});

test.afterAll(async () => {
try {
await nodesApi.deleteCurrentUserNodes();
await trashcanApi.emptyTrashcan();
} catch (error) {
console.error(`Main afterAll failed: ${error}`);
}
});

test('[C299173] from Personal Files - Comments tab default fields', async ({ personalFiles }) => {
const personalFolderName = `personalFolder-e2e-${Utils.random()}`;
await nodesApi.createFolder(personalFolderName);
await fileActionsApi.waitForNodes(personalFolderName, { expect: 1 });
await personalFiles.navigate();
await expect(personalFiles.dataTable.getRowByName(personalFolderName)).toBeVisible();
await personalFiles.dataTable.getRowByName(personalFolderName).click();
await personalFiles.acaHeader.viewDetails.click();
await personalFiles.infoDrawer.commentsTab.click();
await expect(personalFiles.infoDrawer.commentInputField).toBeVisible();
expect(await personalFiles.infoDrawer.checkCommentsHeaderCount()).toEqual(0);
await expect(personalFiles.infoDrawer.addCommentButton).toBeDisabled();
});

test('[C299209] from Favorites - Add a comment on a folder', async ({ favoritePage }) => {
const favoriteFolderName = `favoriteFolder-e2e-${Utils.random()}`;
const folderFavId: string = (await nodesApi.createFolder(favoriteFolderName)).entry.id;
await favoritesActions.addFavoritesByIds('folder', [folderFavId]);
await fileActionsApi.waitForNodes(favoriteFolderName, { expect: 1 });
await favoritePage.navigate();
await expect(favoritePage.dataTable.getRowByName(favoriteFolderName)).toBeVisible();
await favoritePage.dataTable.getRowByName(favoriteFolderName).click();
await favoritePage.acaHeader.viewDetails.click();
await favoritePage.infoDrawer.commentsTab.click();
await expect(favoritePage.infoDrawer.commentInputField).toBeVisible();
await favoritePage.infoDrawer.addCommentToNode(commentText);
await expect(favoritePage.infoDrawer.addCommentButton).toBeDisabled();
expect(await favoritePage.infoDrawer.checkCommentsHeaderCount()).toEqual(1);
expect(await favoritePage.infoDrawer.verifyCommentsCountFromList(1));
});

test('[C299189] from Shared Files - Comments are displayed ordered by created date in descending order', async ({ sharedPage }) => {
const sharedFileName = `sharedFile-e2e-${Utils.random()}`;
const e2eCommentFirst = `e2e-comment-${Utils.random()}`;
const e2eCommentSecond = `e2e-comment-${Utils.random()}`;
const sharedFileId: string = (await nodesApi.createFile(sharedFileName)).entry.id;
await fileActionsApi.waitForNodes(sharedFileName, { expect: 1 });
await apiClientFactory.commentsApi.createComment(sharedFileId, { content: e2eCommentFirst });
await apiClientFactory.commentsApi.createComment(sharedFileId, { content: e2eCommentSecond });
await apiClientFactory.share.createSharedLink({ nodeId: sharedFileId });
await fileActionsApi.waitForNodes(sharedFileName, { expect: 1 });
await sharedPage.navigate();
await expect(sharedPage.dataTable.getRowByName(sharedFileName)).toBeVisible();
await sharedPage.dataTable.getRowByName(sharedFileName).click();
await sharedPage.acaHeader.viewDetails.click();
await sharedPage.infoDrawer.commentsTab.click();
await sharedPage.infoDrawer.waitForComments();
expect(await sharedPage.infoDrawer.checkCommentsHeaderCount()).toEqual(2);
expect(await sharedPage.infoDrawer.commentTextContent.nth(0).textContent()).toEqual(e2eCommentSecond);
expect(await sharedPage.infoDrawer.commentTextContent.nth(1).textContent()).toEqual(e2eCommentFirst);
});

test('[C299195] from Recent Files - Add a comment on a file', async ({ recentFilesPage }) => {
const recentFile = `e2e-recentFile-${Utils.random()}`;
await nodesApi.createFile(recentFile);
await fileActionsApi.waitForNodes(recentFile, { expect: 1 });
await recentFilesPage.navigate();
await expect(recentFilesPage.dataTable.getRowByName(recentFile)).toBeVisible();
await recentFilesPage.dataTable.getRowByName(recentFile).click();
await recentFilesPage.acaHeader.viewDetails.click();
await recentFilesPage.infoDrawer.commentsTab.click();
await expect(recentFilesPage.infoDrawer.commentInputField).toBeVisible();
await recentFilesPage.infoDrawer.addCommentToNode(commentText);
await expect(recentFilesPage.infoDrawer.addCommentButton).toBeDisabled();
expect(await recentFilesPage.infoDrawer.checkCommentsHeaderCount()).toEqual(1);
expect(await recentFilesPage.infoDrawer.verifyCommentsCountFromList(1));
});

test('[C299196] Comment info display - File from Favorites', async ({ favoritePage }) => {
const e2eCommentFirst = `e2e-comment-${Utils.random()}`;
const commentInfoFileName = `e2e-commentFile-${Utils.random()}`;
const commentInfoFileId: string = (await nodesApi.createFile(commentInfoFileName)).entry.id;
await favoritesActions.addFavoritesByIds('file', [commentInfoFileId]);
await fileActionsApi.waitForNodes(commentInfoFileName, { expect: 1 });
await apiClientFactory.commentsApi.createComment(commentInfoFileId, { content: e2eCommentFirst });
await fileActionsApi.waitForNodes(commentInfoFileName, { expect: 1 });
await favoritePage.navigate();
await expect(favoritePage.dataTable.getRowByName(commentInfoFileName)).toBeVisible();
await favoritePage.dataTable.getRowByName(commentInfoFileName).click();
await favoritePage.acaHeader.viewDetails.click();
await favoritePage.infoDrawer.commentsTab.click();
await favoritePage.infoDrawer.waitForComments();
expect(await favoritePage.infoDrawer.checkCommentsHeaderCount()).toEqual(1);
expect(await favoritePage.infoDrawer.commentTextContent.nth(0).textContent()).toEqual(e2eCommentFirst);
expect(await favoritePage.infoDrawer.commentTimestamp.nth(0).textContent()).toEqual('less than a minute ago');
expect(await favoritePage.infoDrawer.commentUsername.nth(0).textContent()).toEqual('Administrator');
});
});
15 changes: 15 additions & 0 deletions e2e/playwright/info-drawer/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/info-drawer/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"]
}
4 changes: 4 additions & 0 deletions e2e/playwright/navigation/src/tests/single-click.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ test.describe('Single click on item name', () => {

test('[C280034] Navigate inside the folder when clicking the hyperlink on Personal Files', async ({ personalFiles }) => {
await personalFiles.navigate();
await personalFiles.dataTable.setPaginationTo50();
await personalFiles.dataTable.getCellLinkByName(folder1).click();
await personalFiles.dataTable.spinnerWaitForReload();
while ((await personalFiles.breadcrumb.currentItem.innerText()) === 'Personal Files') {
await personalFiles.breadcrumb.currentItem.innerText();
}
expect(await personalFiles.breadcrumb.currentItem.innerText()).toBe(folder1);
});

Expand Down
5 changes: 4 additions & 1 deletion projects/aca-playwright-shared/src/api/api-client-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ import {
SharedlinksApi,
FavoritesApi,
TrashcanApi,
PersonEntry
PersonEntry,
CommentsApi
} from '@alfresco/js-api';
import { ActionTypes, Rule } from './rules-api';
import { users } from '../base-config';
Expand Down Expand Up @@ -83,6 +84,7 @@ export class ApiClientFactory {
public share: SharedlinksApi;
public favorites: FavoritesApi;
public trashCan: TrashcanApi;
public commentsApi: CommentsApi;

constructor() {
this.alfrescoApi = new AlfrescoApi(config);
Expand All @@ -105,6 +107,7 @@ export class ApiClientFactory {
this.share = new SharedlinksApi(this.alfrescoApi);
this.favorites = new FavoritesApi(this.alfrescoApi);
this.trashCan = new TrashcanApi(this.alfrescoApi);
this.commentsApi = new CommentsApi(this.alfrescoApi);

return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { BaseComponent } from './base.component';
import { Page } from '@playwright/test';
import { Page, expect } from '@playwright/test';

export class AdfInfoDrawerComponent extends BaseComponent {
private static rootElement = 'adf-info-drawer';
Expand All @@ -36,4 +36,35 @@ export class AdfInfoDrawerComponent extends BaseComponent {
public getIdField = (labelText: string) => this.getChild('[data-automation-id="library-id-properties-wrapper"]', { hasText: labelText });
public getVisibilityField = (labelText: string) => this.getChild('[data-automation-id="library-visibility-properties-wrapper"]', { hasText: labelText });
public getDescriptionField = this.getChild('[data-automation-id="library-description-properties-wrapper"] textarea');
public propertiesTab = this.getChild('.adf-info-drawer-tab').nth(0);
public commentsTab = this.getChild('.adf-info-drawer-tab').nth(1);
public commentInputField = this.getChild('mat-form-field');
public commentsHeader = this.getChild('#comment-header');
public addCommentButton = this.getChild('[data-automation-id="comments-input-add"]');
public commentsList = this.getChild('.adf-comment-list-item');
public commentUsername = this.getChild('.adf-comment-user-name');
public commentTextContent = this.getChild('.adf-comment-message');
public commentTimestamp = this.getChild('.adf-comment-message-time');


async checkCommentsHeaderCount(): Promise<number> {
datguychen marked this conversation as resolved.
Show resolved Hide resolved
const commentsCountTextContent = await this.commentsHeader.textContent();
const commentsCountString = commentsCountTextContent.match(/\d+/g)[0];
return parseInt(commentsCountString);
}

async verifyCommentsCountFromList(expectedNumber: number): Promise<void> {
datguychen marked this conversation as resolved.
Show resolved Hide resolved
const commentsCountFromList = await this.commentsList.count();
expect(commentsCountFromList).toEqual(expectedNumber);
}

async waitForComments(): Promise<void> {
datguychen marked this conversation as resolved.
Show resolved Hide resolved
await this.commentsList.first().waitFor();
}

async addCommentToNode(commentText: string): Promise<void> {
datguychen marked this conversation as resolved.
Show resolved Hide resolved
await this.commentInputField.click();
await this.page.keyboard.type(commentText);
await this.addCommentButton.click();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
emptyListSubtitle = this.getChild('.adf-empty-content__subtitle');
emptySearchText = this.getChild('.empty-search__text');
emptyListTest = this.getChild('adf-custom-empty-content-template');
paginationButton = this.page.locator('.adf-pagination__block button').nth(0);
paginationOptions = this.page.locator('#cdk-overlay-0 button');

/** Locator for row (or rows) */
getRowLocator = this.getChild(`adf-datatable-row`);
Expand Down Expand Up @@ -274,7 +276,7 @@
}

async clickItemLocation(name: string): Promise<void> {
await this.getItemLocationEl(name).click();

Check failure on line 279 in projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts

View workflow job for this annotation

GitHub Actions / E2e test suites: Playwright (list-views, 8)

[List Views] › src/tests/trash.spec.ts:111:9 › Trash › Regular user's personal files › [C280496] Location column redirect - file in folder

3) [List Views] › src/tests/trash.spec.ts:111:9 › Trash › Regular user's personal files › [C280496] Location column redirect - file in folder Error: locator.click: Target closed =========================== logs =========================== waiting for locator('adf-datatable adf-datatable-row').filter({ hasText: 'file-1ukgk.txt' }).locator('.aca-location-link') locator resolved to <aca-location-link class="aca-location-link adf-location-cell adf-d…>…</aca-location-link> attempting click action waiting for element to be visible, enabled and stable element is not visible - waiting... ============================================================ at ../../../projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts:279 277 | 278 | async clickItemLocation(name: string): Promise<void> { > 279 | await this.getItemLocationEl(name).click(); | ^ 280 | } 281 | 282 | async getSortingOrder(): Promise<string> { at DataTableComponent.clickItemLocation (/home/runner/work/alfresco-content-app/alfresco-content-app/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts:279:40) at /home/runner/work/alfresco-content-app/alfresco-content-app/e2e/playwright/list-views/src/tests/trash.spec.ts:112:33
}

async getSortingOrder(): Promise<string> {
Expand Down Expand Up @@ -319,4 +321,9 @@
async rightClickOnItem(itemName: string): Promise<void> {
await this.getCellByColumnNameAndRowItem(itemName, 'Name').click({ button: 'right' });
}

async setPaginationTo50(): Promise<void> {
await this.paginationButton.click();
await this.paginationOptions.getByText("50").click();
}
}
Loading
Loading