[ACS-5019] Migrated e2e tests - Actions - download (#3829)

* [ACS-5019] Migrated Tests Protractor2Playwright Actions - download
---------

Co-authored-by: akash.rathod@hyland.com <akash.rathod@hyland.com>
This commit is contained in:
Katarzyna Kita
2024-05-07 11:00:27 +02:00
committed by GitHub
parent 995305fc13
commit 12742b3b90
11 changed files with 237 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
{
"extends": "../../../.eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"e2e/playwright/upload-download-actions/tsconfig.e2e.json"
],
"createDefaultProgram": true
},
"plugins": [
"rxjs",
"unicorn"
],
"rules": {
"@typescript-eslint/no-floating-promises": "off"
}
}
]
}

View File

@@ -0,0 +1 @@
{}

View File

@@ -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, 'Upload Download Actions'),
projects: [
{
name: 'Upload Download Actions',
testDir: './src/tests',
use: {
users: []
}
}
]
};
export default config;

View File

@@ -0,0 +1,22 @@
{
"name": "upload-download-actions-e2e",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/playwright/upload-download-actions",
"projectType": "application",
"targets": {
"e2e": {
"executor": "nx:run-commands",
"options": {
"commands": ["npx playwright test --config=e2e/playwright/upload-download-actions/playwright.config.ts"]
},
"configurations": {
"production": {
"devServerTarget": "content-ce:serve:production"
}
}
},
"lint": {
"executor": "@angular-eslint/builder:lint"
}
}
}

View File

@@ -0,0 +1,85 @@
/*!
* 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 } from '@alfresco/playwright-shared';
test.describe('Download from Personal Files', () => {
let trashcanApi: TrashcanApi;
let nodesApi: NodesApi;
let parentId: string;
const random = Utils.random();
const username = `user-${random}`;
const parent = `parent-${random}`;
const childFile = `childFile-${random}.txt`;
const childFolder = `childFolder-${random}`;
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);
parentId = (await nodesApi.createFolder(parent)).entry.id;
await nodesApi.createFolder(childFolder, parentId);
await nodesApi.createFile(childFile, parentId);
} 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('Download a file', async ({ personalFiles }) => {
await personalFiles.dataTable.performClickFolderOrFileToOpen(parent);
await personalFiles.dataTable.selectItem(childFile);
const [download] = await Promise.all([personalFiles.page.waitForEvent('download'), personalFiles.acaHeader.downloadButton.click()]);
expect(download.suggestedFilename()).toBe(childFile);
});
test('Download a folder', async ({ personalFiles }) => {
await personalFiles.dataTable.performClickFolderOrFileToOpen(parent);
await personalFiles.dataTable.selectItem(childFolder);
const [download] = await Promise.all([personalFiles.page.waitForEvent('download'), personalFiles.acaHeader.downloadButton.click()]);
const filePath = await download.path();
expect(await Utils.verifyZipFileContent(filePath, [childFolder])).toBe(true);
});
test('Download multiple items', async ({ personalFiles }) => {
await personalFiles.dataTable.performClickFolderOrFileToOpen(parent);
await personalFiles.dataTable.selectMultiItem(childFile, childFolder);
const [download] = await Promise.all([personalFiles.page.waitForEvent('download'), personalFiles.acaHeader.downloadButton.click()]);
const filePath = await download.path();
expect(await Utils.verifyZipFileContent(filePath, [childFile, childFolder])).toBe(true);
});
});

View File

@@ -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"]
}

View File

@@ -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"]
}

View File

@@ -85,7 +85,7 @@ test.describe('viewer action file', () => {
await personalFiles.dataTable.performClickFolderOrFileToOpen(randomDocxName);
await personalFiles.viewer.waitForViewerToOpen();
const downloadPromise = personalFiles.page.waitForEvent('download');
await personalFiles.acaHeader.downloadButton.click();
await personalFiles.acaHeader.downloadButtonViewer.click();
const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(randomDocxName);
});
@@ -112,7 +112,7 @@ test.describe('viewer action file', () => {
await personalFiles.matMenu.clickMenuItem('Edit Offline');
const downloadPromise = personalFiles.page.waitForEvent('download');
await personalFiles.acaHeader.downloadButton.click();
await personalFiles.acaHeader.downloadButtonViewer.click();
const download = await downloadPromise;
expect(download.suggestedFilename(), 'File should found in download location').toBe(fileForEditOffline);
expect(await personalFiles.viewer.isViewerOpened(), 'Viewer is closed after pressing Full screen').toBe(true);