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-6239] Migrated personal files of pagination suit to playwright #3528

Merged
merged 7 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ jobs:
id: 5
- name: "special-permissions"
id: 6
- name: "pagination"
id: 7
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
17 changes: 17 additions & 0 deletions e2e/playwright/pagination/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "../../../.eslintrc.json",
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": ["e2e/playwright/pagination/tsconfig.e2e.json"],
"createDefaultProgram": true
},
"plugins": ["rxjs", "unicorn"],
"rules": {
"@typescript-eslint/no-floating-promises": "off"
}
}
]
}
1 change: 1 addition & 0 deletions e2e/playwright/pagination/exclude.tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
44 changes: 44 additions & 0 deletions e2e/playwright/pagination/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, 'Pagination'),
projects: [
{
name: 'Pagination',
testDir: './src/tests/',
use: {
users: ['hruser']
}
}
]
};

export default config;
22 changes: 22 additions & 0 deletions e2e/playwright/pagination/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "pagination-e2e",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/playwright/pagination/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "nx:run-commands",
"options": {
"commands": ["npx playwright test --config=e2e/playwright/pagination/playwright.config.ts"]
},
"configurations": {
"production": {
"devServerTarget": "content-ce:serve:production"
}
}
},
"lint": {
"executor": "@angular-eslint/builder:lint"
}
}
}
57 changes: 57 additions & 0 deletions e2e/playwright/pagination/src/tests/multiple-pages-files.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*!
* 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 { ApiClientFactory, NodesApi, test, Utils } from '@alfresco/playwright-shared';
import { personalFilesTests } from './personal-files';

test.describe('Pagination on multiple pages : ', () => {
const random = Utils.random();
const username = `user-${random}`;

const parent = `parent-${random}`;
let parentId: string;

const files = Array(51)
AleksanderSklorz marked this conversation as resolved.
Show resolved Hide resolved
.fill('my-file')
.map((name, index): string => `${name}-${index + 1}-${random}.txt`);

const apiClientFactory = new ApiClientFactory();

test.beforeAll(async () => {
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
const nodesApi = await NodesApi.initialize(username, username);
parentId = (await nodesApi.createFolder(parent)).entry.id;

(await nodesApi.createFiles(files, parent)).list.entries.map((entries: any) => entries.entry.id);
AleksanderSklorz marked this conversation as resolved.
Show resolved Hide resolved
});

test.afterAll(async () => {
await apiClientFactory.nodes.deleteNode(parentId, { permanent: true });
});

test.describe('on Personal Files', () => {
personalFilesTests(username, parent);
});
});
107 changes: 107 additions & 0 deletions e2e/playwright/pagination/src/tests/personal-files.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*!
* 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 { test, timeouts } from '@alfresco/playwright-shared';
import { expect } from '@playwright/test';

export function personalFilesTests(userName: string, parentName: string) {
test.describe('Pagination controls : ', () => {
test.beforeEach(async ({ loginPage, personalFiles, page }) => {
await loginPage.navigate();
await loginPage.loginUser({ username: userName, password: userName });
await personalFiles.navigate();
DenysVuika marked this conversation as resolved.
Show resolved Hide resolved
await personalFiles.dataTable.getRowByName(parentName).dblclick();
await page.waitForTimeout(timeouts.tiny);
});

test('[C280077] Pagination control default values', async ({ personalFiles }) => {
expect(await personalFiles.pagination.getRange()).toContain('Showing 1-25 of 51');
expect(await personalFiles.pagination.getMaxItems()).toContain('25');
expect(await personalFiles.pagination.getCurrentPage()).toContain('Page 1');
expect(await personalFiles.pagination.getTotalPages()).toContain('of 3');
expect(await personalFiles.pagination.isPreviousEnabled()).toBe(false);
expect(await personalFiles.pagination.isNextEnabled()).toBe(true);
});

test('[C280078] Items per page values', async ({ personalFiles }) => {
await personalFiles.pagination.openMaxItemsMenu();
expect(await (await personalFiles.pagination.menu.getNthItem(1)).innerText()).toBe('25');
expect(await (await personalFiles.pagination.menu.getNthItem(2)).innerText()).toBe('50');
expect(await (await personalFiles.pagination.menu.getNthItem(3)).innerText()).toBe('100');
await personalFiles.closeMenu();
});

test('[C280079] current page menu items', async ({ personalFiles }) => {
await personalFiles.pagination.openMaxItemsMenu();
await personalFiles.pagination.menu.clickMenuItem('25');
expect(await personalFiles.pagination.getMaxItems()).toContain('25');
expect(await personalFiles.pagination.getTotalPages()).toContain('of 3');
expect(await personalFiles.pagination.menu.getItemsCount()).toBe(3);

Check failure on line 60 in e2e/playwright/pagination/src/tests/personal-files.ts

View workflow job for this annotation

GitHub Actions / E2e test suites: Playwright (pagination, 7)

[Pagination] › src/tests/personal-files.ts:55:9 › Pagination on multiple pages : › on Personal Files › Pagination controls : › [C280079] current page menu items

1) [Pagination] › src/tests/personal-files.ts:55:9 › Pagination on multiple pages : › on Personal Files › Pagination controls : › [C280079] current page menu items Error: expect(received).toBe(expected) // Object.is equality Expected: 3 Received: 0 58 | expect(await personalFiles.pagination.getMaxItems()).toContain('25'); 59 | expect(await personalFiles.pagination.getTotalPages()).toContain('of 3'); > 60 | expect(await personalFiles.pagination.menu.getItemsCount()).toBe(3); | ^ 61 | 62 | await personalFiles.pagination.openMaxItemsMenu(); 63 | await personalFiles.pagination.menu.clickMenuItem('50'); at /home/runner/work/alfresco-content-app/alfresco-content-app/e2e/playwright/pagination/src/tests/personal-files.ts:60:67

await personalFiles.pagination.openMaxItemsMenu();
await personalFiles.pagination.menu.clickMenuItem('50');
expect(await personalFiles.pagination.getMaxItems()).toContain('50');
expect(await personalFiles.pagination.getTotalPages()).toContain('of 2');

await personalFiles.pagination.openMaxItemsMenu();
await personalFiles.pagination.menu.clickMenuItem('100');
expect(await personalFiles.pagination.getMaxItems()).toContain('100');
expect(await personalFiles.pagination.getTotalPages()).toContain('of 1');

await personalFiles.pagination.resetToDefaultPageSize();
});

test('[C280080] change the current page from menu', async ({ personalFiles }) => {
await personalFiles.pagination.clickOnNextPage();
expect(await personalFiles.pagination.getRange()).toContain('Showing 26-50 of 51');
expect(await personalFiles.pagination.getCurrentPage()).toContain('Page 2');
expect(await personalFiles.pagination.isPreviousEnabled()).toBe(true);
expect(await personalFiles.pagination.isNextEnabled()).toBe(true);
await personalFiles.pagination.resetToDefaultPageSize();
});

test('[C280083] navigate to next and previous pages', async ({ personalFiles }) => {
await personalFiles.pagination.openMaxItemsMenu();
await personalFiles.pagination.menu.clickMenuItem('25');
expect(await personalFiles.pagination.getMaxItems()).toContain('25');
await personalFiles.pagination.clickOnNextPage();
expect(await personalFiles.pagination.getRange()).toContain('Showing 26-50 of 51');

await personalFiles.pagination.clickOnPreviousPage();
expect(await personalFiles.pagination.getRange()).toContain('Showing 1-25 of 51');
});

test('[C280081] Previous button is disabled on first page', async ({ personalFiles }) => {
expect(await personalFiles.pagination.getCurrentPage()).toContain('Page 1');
expect(await personalFiles.pagination.isPreviousEnabled()).toBe(false);
});

test('[C280082] Next button is disabled on last page', async ({ personalFiles }) => {
await personalFiles.pagination.openMaxItemsMenu();
await personalFiles.pagination.menu.clickNthItem(3);
expect(await personalFiles.pagination.getCurrentPage()).toContain('Page 1');
expect(await personalFiles.pagination.isNextEnabled()).toBe(false);
});
});
}
15 changes: 15 additions & 0 deletions e2e/playwright/pagination/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/pagination/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"]
}
5 changes: 0 additions & 5 deletions e2e/protractor/suites/pagination/multiple-pages-files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import { Utils, AdminActions, RepoClient } from '@alfresco/aca-testing-shared';
import { personalFilesTests } from './personal-files';
import { recentFilesTests } from './recent-files';
import { searchResultsTests } from './search-results';
import { sharedFilesTests } from './shared-files';
Expand Down Expand Up @@ -64,10 +63,6 @@ describe('Pagination on multiple pages : ', () => {
await userApi.nodes.deleteNodeById(parentId);
});

describe('on Personal Files', () => {
personalFilesTests(username, parent);
});

describe('on Recent Files', () => {
beforeAll(async () => {
await userApi.search.waitForApi(username, { expect: initialSearchTotalItems + 51 });
Expand Down
Loading
Loading