mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-5014] Migrated Copy Move actions E2Es from protractor to playwright (#3531)
* [ACS-5014] Added Playwright E2E tests for copy-move actions * [ACS-5014] Fixed missing import in tsconfig.e2e.json * [ACS-5014] Removed unneeded method from utils.ts * [ACS-5014] Updated playwright.config.ts * [ACS-5014] Copy and Move tests are now working * [ACS-5014] Removed unneeded test.only * [ACS-5014] Added test case IDs to E2E tests * [ACS-6211] Removed TODO note. Removed protractor test case files * [ACS-5014] Added E2E tests for Destination Picker in copy-move actions * [ACS-5014] Removed unneded only from test suite * [ACS-5014] Updated import of logger from @alfresco/adf-cli to @alfresco/adf-testing * [ACS-5014] Addressed code review findings. Moved objects to beforeAll/beforeEach wherever applicable. Added missing await. * [ACS-5014] Addressed code review findings. Removed unused methods/objects from content-node-selector-dialog.ts * [ACS-5014] Addressed code review findings. Removed unused methods/objects from content-node-selector-dialog.ts * [ACS-5014] SonarLint fix * [ACS-5014] Fixed breaking change for other E2Es * [ACS-5014] Updated E2Es to use correct locator for more actions button
This commit is contained in:
26
e2e/playwright/copy-move-actions/.eslintrc.json
Normal file
26
e2e/playwright/copy-move-actions/.eslintrc.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"extends": "../../../.eslintrc.json",
|
||||
"ignorePatterns": [
|
||||
"!**/*"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.ts"
|
||||
],
|
||||
"parserOptions": {
|
||||
"project": [
|
||||
"e2e/playwright/copy-move-actions/tsconfig.e2e.json"
|
||||
],
|
||||
"createDefaultProgram": true
|
||||
},
|
||||
"plugins": [
|
||||
"rxjs",
|
||||
"unicorn"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-floating-promises": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
1
e2e/playwright/copy-move-actions/exclude.tests.json
Normal file
1
e2e/playwright/copy-move-actions/exclude.tests.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
45
e2e/playwright/copy-move-actions/playwright.config.ts
Normal file
45
e2e/playwright/copy-move-actions/playwright.config.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/*!
|
||||
* 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, timeouts } from '@alfresco/playwright-shared';
|
||||
import EXCLUDED_JSON from './exclude.tests.json';
|
||||
|
||||
const config: PlaywrightTestConfig<CustomConfig> = {
|
||||
...getGlobalConfig,
|
||||
|
||||
grepInvert: getExcludedTestsRegExpArray(EXCLUDED_JSON, 'Copy Move Actions'),
|
||||
projects: [
|
||||
{
|
||||
name: 'Copy Move Actions',
|
||||
testDir: './src/tests',
|
||||
use: {
|
||||
users: ['hruser']
|
||||
},
|
||||
timeout: timeouts.extendedTest
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export default config;
|
22
e2e/playwright/copy-move-actions/project.json
Normal file
22
e2e/playwright/copy-move-actions/project.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "copy-move-actions-e2e",
|
||||
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "e2e/playwright/copy-move-actions/src",
|
||||
"projectType": "application",
|
||||
"targets": {
|
||||
"e2e": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"commands": ["npx playwright test --config=e2e/playwright/copy-move-actions/playwright.config.ts"]
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"devServerTarget": "content-ce:serve:production"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@angular-eslint/builder:lint"
|
||||
}
|
||||
}
|
||||
}
|
220
e2e/playwright/copy-move-actions/src/tests/copy.test.ts
Normal file
220
e2e/playwright/copy-move-actions/src/tests/copy.test.ts
Normal file
@@ -0,0 +1,220 @@
|
||||
/*!
|
||||
* 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, test, Utils, PersonalFilesPage, NodesApi, LoginPage } from '@alfresco/playwright-shared';
|
||||
import { expect } from '@playwright/test';
|
||||
import { Logger } from '@alfresco/adf-testing';
|
||||
|
||||
test.describe('Copy actions', () => {
|
||||
let nodesApi: NodesApi;
|
||||
const username = `user-${Utils.random()}`;
|
||||
|
||||
let sourceFile: string;
|
||||
let sourceFileInsideFolder: string;
|
||||
let sourceFolder: string;
|
||||
let destinationFolder: string;
|
||||
|
||||
let sourceFileId: string;
|
||||
let sourceFileInsideFolderId: string;
|
||||
let destinationFolderId: string;
|
||||
|
||||
test.beforeAll(async () => {
|
||||
try {
|
||||
const apiClientFactory = new ApiClientFactory();
|
||||
await apiClientFactory.setUpAcaBackend('admin');
|
||||
await apiClientFactory.createUser({ username });
|
||||
nodesApi = await NodesApi.initialize(username, username);
|
||||
} catch (error) {
|
||||
Logger.error(`beforeAll failed : ${error}`);
|
||||
}
|
||||
});
|
||||
|
||||
test.afterAll(async ({ nodesApiAction }) => {
|
||||
try {
|
||||
await nodesApiAction.deleteCurrentUserNodes();
|
||||
} catch (error) {
|
||||
Logger.error(`afterAll failed : ${error}`);
|
||||
}
|
||||
});
|
||||
|
||||
test.beforeEach(async ({ personalFiles, page }) => {
|
||||
sourceFile = `source-file-${Utils.random()}.txt`;
|
||||
sourceFileInsideFolder = `source-file-inside-folder-${Utils.random()}.txt`;
|
||||
sourceFolder = `source-folder-${Utils.random()}`;
|
||||
destinationFolder = `destination-folder-${Utils.random()}`;
|
||||
|
||||
const loginPage = new LoginPage(page);
|
||||
try {
|
||||
await loginPage.loginUser(
|
||||
{ username, password: username },
|
||||
{
|
||||
withNavigation: true,
|
||||
waitForLoading: true
|
||||
}
|
||||
);
|
||||
destinationFolderId = (await nodesApi.createFolder(destinationFolder)).entry.id;
|
||||
const sourceFolderId = (await nodesApi.createFolder(sourceFolder)).entry.id;
|
||||
sourceFileInsideFolderId = (await nodesApi.createFile(sourceFileInsideFolder, sourceFolderId)).entry.id;
|
||||
sourceFileId = (await nodesApi.createFile(sourceFile)).entry.id;
|
||||
|
||||
await personalFiles.navigate();
|
||||
} catch (error) {
|
||||
Logger.error(`beforeEach failed : ${error}`);
|
||||
}
|
||||
});
|
||||
|
||||
const copyContentInPersonalFiles = async (personalFilesPage: PersonalFilesPage, sourceFileList: string[], destinationName: string) => {
|
||||
await personalFilesPage.copyOrMoveContentInDatatable(sourceFileList, destinationName, 'Copy');
|
||||
const msg = await personalFilesPage.snackBar.message.innerText();
|
||||
if (sourceFileList.length === 1) {
|
||||
expect.soft(msg).toContain('Copied 1 item');
|
||||
} else {
|
||||
expect.soft(msg).toContain(`Copied ${sourceFileList.length} items`);
|
||||
}
|
||||
};
|
||||
|
||||
test('[C217135] Copy a file', async ({ personalFiles }) => {
|
||||
await copyContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder);
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('[C291888] Copy a folder with content', async ({ personalFiles }) => {
|
||||
await copyContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder);
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(sourceFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect(await personalFiles.dataTable.isItemPresent(sourceFileInsideFolder)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('[C291889] Copy multiple items', async ({ personalFiles }) => {
|
||||
await copyContentInPersonalFiles(personalFiles, [sourceFolder, sourceFile], destinationFolder);
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
expect(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('[C217137] Copy a file with a name that already exists on the destination', async ({ personalFiles }) => {
|
||||
await nodesApi.createFile(sourceFile, destinationFolderId);
|
||||
const expectedNameForCopiedFile = sourceFile.replace('.', '-1.');
|
||||
await copyContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder);
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
expect(await personalFiles.dataTable.isItemPresent(expectedNameForCopiedFile)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('[C217138] Copy a folder with a name that already exists on the destination', async ({ personalFiles }) => {
|
||||
const existingFolderId = (await nodesApi.createFolder(sourceFolder, destinationFolderId)).entry.id;
|
||||
await nodesApi.createFile(sourceFileInsideFolder, existingFolderId);
|
||||
const expectedNameForCopiedFile = sourceFileInsideFolder.replace('.', '-1.');
|
||||
await copyContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder);
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(sourceFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFileInsideFolder)).toBeTruthy();
|
||||
expect(await personalFiles.dataTable.isItemPresent(expectedNameForCopiedFile)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('[C217139] Copy locked file', async ({ personalFiles }) => {
|
||||
const lockType = 'ALLOW_OWNER_CHANGES';
|
||||
await nodesApi.lockNodes([sourceFileId], lockType);
|
||||
await copyContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder);
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('[C217140] Copy folder that contains locked file', async ({ personalFiles }) => {
|
||||
const lockType = 'ALLOW_OWNER_CHANGES';
|
||||
await nodesApi.lockNodes([sourceFileInsideFolderId], lockType);
|
||||
await copyContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder);
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(sourceFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect(await personalFiles.dataTable.isItemPresent(sourceFileInsideFolder)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('[C217171] Undo copy of files', async ({ personalFiles }) => {
|
||||
await copyContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder);
|
||||
await personalFiles.snackBar.actionButton.click();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('[C217172] Undo copy of folders', async ({ personalFiles }) => {
|
||||
await copyContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder);
|
||||
await personalFiles.snackBar.actionButton.click();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('[C217173] Undo copy of a file when a file with same name already exists on the destination', async ({ personalFiles }) => {
|
||||
await nodesApi.createFile(sourceFile, destinationFolderId);
|
||||
const expectedNameForCopiedFile = sourceFile.replace('.', '-1.');
|
||||
await copyContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder);
|
||||
await personalFiles.snackBar.actionButton.click();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
expect(await personalFiles.dataTable.isItemPresent(expectedNameForCopiedFile)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('[C217174] Undo copy of a folder when a folder with same name already exists on the destination', async ({ personalFiles }) => {
|
||||
const existingFolderId = (await nodesApi.createFolder(sourceFolder, destinationFolderId)).entry.id;
|
||||
await nodesApi.createFile(sourceFileInsideFolder, existingFolderId);
|
||||
const expectedNameForCopiedFile = sourceFileInsideFolder.replace('.', '-1.');
|
||||
await copyContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder);
|
||||
await personalFiles.snackBar.actionButton.click();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(sourceFolder);
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFileInsideFolder)).toBeTruthy();
|
||||
expect(await personalFiles.dataTable.isItemPresent(expectedNameForCopiedFile)).toBeFalsy();
|
||||
});
|
||||
});
|
@@ -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 { ApiClientFactory, MyLibrariesPage, NodesApi, SitesApi, test, Utils } from '@alfresco/playwright-shared';
|
||||
import { expect } from '@playwright/test';
|
||||
import { Site } from '@alfresco/js-api';
|
||||
import { Logger } from '@alfresco/adf-testing';
|
||||
|
||||
test.describe('Copy Move actions', () => {
|
||||
let nodesApi: NodesApi;
|
||||
let sitesApi: SitesApi;
|
||||
|
||||
const site = `site-${Utils.random()}`;
|
||||
const consumerUser = `consumer-${Utils.random()}`;
|
||||
const contributorUser = `contributor-${Utils.random()}`;
|
||||
const collaboratorUser = `collaborator-${Utils.random()}`;
|
||||
|
||||
const sourceFile = `source-file-${Utils.random()}.txt`;
|
||||
const destinationFolder = `destination-folder-${Utils.random()}`;
|
||||
|
||||
let siteId: string;
|
||||
|
||||
test.beforeAll(async () => {
|
||||
try {
|
||||
const apiClientFactory = new ApiClientFactory();
|
||||
await apiClientFactory.setUpAcaBackend('admin');
|
||||
const username = `user-${Utils.random()}`;
|
||||
await apiClientFactory.createUser({ username });
|
||||
nodesApi = await NodesApi.initialize(username, username);
|
||||
sitesApi = await SitesApi.initialize(username, username);
|
||||
|
||||
siteId = (await sitesApi.createSite(site, Site.VisibilityEnum.PRIVATE)).entry.id;
|
||||
const docLibId = await sitesApi.getDocLibId(siteId);
|
||||
|
||||
const consumerId = (await apiClientFactory.createUser({ username: consumerUser })).entry.id;
|
||||
const contributorId = (await apiClientFactory.createUser({ username: contributorUser })).entry.id;
|
||||
const collaboratorId = (await apiClientFactory.createUser({ username: collaboratorUser })).entry.id;
|
||||
|
||||
await sitesApi.addSiteMember(siteId, consumerId, Site.RoleEnum.SiteConsumer);
|
||||
await sitesApi.addSiteMember(siteId, contributorId, Site.RoleEnum.SiteContributor);
|
||||
await sitesApi.addSiteMember(siteId, collaboratorId, Site.RoleEnum.SiteCollaborator);
|
||||
|
||||
await nodesApi.createFile(sourceFile, docLibId);
|
||||
await nodesApi.createFolder(destinationFolder, docLibId);
|
||||
} catch (error) {
|
||||
Logger.error(`beforeAll failed : ${error}`);
|
||||
}
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
try {
|
||||
await nodesApi.deleteCurrentUserNodes();
|
||||
await sitesApi.deleteSites([siteId]);
|
||||
} catch (error) {
|
||||
Logger.error(`afterAll failed : ${error}`);
|
||||
}
|
||||
});
|
||||
|
||||
const copyContentInMyLibraries = async (myLibrariesPage: MyLibrariesPage) => {
|
||||
await myLibrariesPage.dataTable.performClickFolderOrFileToOpen(site);
|
||||
await myLibrariesPage.dataTable.selectItem(sourceFile);
|
||||
await myLibrariesPage.clickMoreActionsButton('Copy');
|
||||
await myLibrariesPage.contentNodeSelector.selectDestination(destinationFolder);
|
||||
};
|
||||
|
||||
test('[C263876] Consumer user cannot select the folder as destination', async ({ loginPage, myLibrariesPage }) => {
|
||||
await loginPage.loginUser({ username: consumerUser, password: consumerUser }, { withNavigation: true, waitForLoading: true });
|
||||
await myLibrariesPage.navigate();
|
||||
await copyContentInMyLibraries(myLibrariesPage);
|
||||
expect(await myLibrariesPage.contentNodeSelector.actionButton.isEnabled()).toBe(false);
|
||||
});
|
||||
|
||||
test('[C263877] Contributor user can select the folder as destination', async ({ loginPage, myLibrariesPage }) => {
|
||||
await loginPage.loginUser({ username: contributorUser, password: contributorUser }, { withNavigation: true, waitForLoading: true });
|
||||
await myLibrariesPage.navigate();
|
||||
await copyContentInMyLibraries(myLibrariesPage);
|
||||
expect(await myLibrariesPage.contentNodeSelector.actionButton.isEnabled()).toBe(true);
|
||||
});
|
||||
|
||||
test('[C263878] Collaborator user can select the folder as destination', async ({ loginPage, myLibrariesPage }) => {
|
||||
await loginPage.loginUser({ username: collaboratorUser, password: collaboratorUser }, { withNavigation: true, waitForLoading: true });
|
||||
await myLibrariesPage.navigate();
|
||||
await copyContentInMyLibraries(myLibrariesPage);
|
||||
expect(await myLibrariesPage.contentNodeSelector.actionButton.isEnabled()).toBe(true);
|
||||
});
|
||||
});
|
202
e2e/playwright/copy-move-actions/src/tests/move.test.ts
Normal file
202
e2e/playwright/copy-move-actions/src/tests/move.test.ts
Normal file
@@ -0,0 +1,202 @@
|
||||
/*!
|
||||
* 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, test, Utils, PersonalFilesPage, NodesApi, LoginPage } from '@alfresco/playwright-shared';
|
||||
import { expect } from '@playwright/test';
|
||||
import { Logger } from '@alfresco/adf-testing';
|
||||
|
||||
test.describe('Move actions', () => {
|
||||
let nodesApi: NodesApi;
|
||||
const username = `user-${Utils.random()}`;
|
||||
|
||||
let sourceFile: string;
|
||||
let sourceFileInsideFolder: string;
|
||||
let sourceFolder: string;
|
||||
let destinationFolder: string;
|
||||
|
||||
let sourceFileId: string;
|
||||
let sourceFileInsideFolderId: string;
|
||||
let destinationFolderId: string;
|
||||
|
||||
test.beforeAll(async () => {
|
||||
try {
|
||||
const apiClientFactory = new ApiClientFactory();
|
||||
await apiClientFactory.setUpAcaBackend('admin');
|
||||
await apiClientFactory.createUser({ username });
|
||||
nodesApi = await NodesApi.initialize(username, username);
|
||||
} catch (error) {
|
||||
Logger.error(`beforeAll failed : ${error}`);
|
||||
}
|
||||
});
|
||||
|
||||
test.afterAll(async ({ nodesApiAction }) => {
|
||||
try {
|
||||
await nodesApiAction.deleteCurrentUserNodes();
|
||||
} catch (error) {
|
||||
Logger.error(`afterAll failed : ${error}`);
|
||||
}
|
||||
});
|
||||
|
||||
test.beforeEach(async ({ personalFiles, page }) => {
|
||||
sourceFile = `source-file-${Utils.random()}.txt`;
|
||||
sourceFileInsideFolder = `source-file-inside-folder-${Utils.random()}.txt`;
|
||||
sourceFolder = `source-folder-${Utils.random()}`;
|
||||
destinationFolder = `destination-folder-${Utils.random()}`;
|
||||
|
||||
const loginPage = new LoginPage(page);
|
||||
try {
|
||||
await loginPage.loginUser(
|
||||
{ username, password: username },
|
||||
{
|
||||
withNavigation: true,
|
||||
waitForLoading: true
|
||||
}
|
||||
);
|
||||
destinationFolderId = (await nodesApi.createFolder(destinationFolder)).entry.id;
|
||||
const sourceFolderId = (await nodesApi.createFolder(sourceFolder)).entry.id;
|
||||
sourceFileInsideFolderId = (await nodesApi.createFile(sourceFileInsideFolder, sourceFolderId)).entry.id;
|
||||
sourceFileId = (await nodesApi.createFile(sourceFile)).entry.id;
|
||||
|
||||
await personalFiles.navigate();
|
||||
} catch (error) {
|
||||
Logger.error(`beforeEach failed : ${error}`);
|
||||
}
|
||||
});
|
||||
|
||||
const moveContentInPersonalFiles = async (personalFilesPage: PersonalFilesPage, sourceFileList: string[], destinationName: string) => {
|
||||
await personalFilesPage.copyOrMoveContentInDatatable(sourceFileList, destinationName, 'Move');
|
||||
await personalFilesPage.spinner.waitForReload();
|
||||
};
|
||||
|
||||
test('[C217316] Move a file', async ({ personalFiles }) => {
|
||||
await moveContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder);
|
||||
const msg = await personalFiles.snackBar.message.innerText();
|
||||
expect.soft(msg).toContain('Moved 1 item.');
|
||||
await personalFiles.snackBar.closeIcon.click();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeFalsy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
expect(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('[C217317] Move a folder with content', async ({ personalFiles }) => {
|
||||
await moveContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder);
|
||||
const msg = await personalFiles.snackBar.message.innerText();
|
||||
expect.soft(msg).toContain('Moved 1 item.');
|
||||
await personalFiles.snackBar.closeIcon.click();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeFalsy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(sourceFolder);
|
||||
expect(await personalFiles.dataTable.isItemPresent(sourceFileInsideFolder)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('[C291958] Move multiple items', async ({ personalFiles }) => {
|
||||
await moveContentInPersonalFiles(personalFiles, [sourceFolder, sourceFile], destinationFolder);
|
||||
const msg = await personalFiles.snackBar.message.innerText();
|
||||
expect.soft(msg).toContain('Moved 2 items.');
|
||||
await personalFiles.snackBar.closeIcon.click();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeFalsy();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeFalsy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('[C217318] Move a file with a name that already exists on the destination', async ({ personalFiles }) => {
|
||||
await nodesApi.createFile(sourceFile, destinationFolderId);
|
||||
const expectedNameForCopiedFile = sourceFile.replace('.', '-1.');
|
||||
await moveContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder);
|
||||
const msg = await personalFiles.snackBar.message.innerText();
|
||||
expect.soft(msg).toContain('Move unsuccessful, a file with the same name already exists.');
|
||||
await personalFiles.snackBar.closeIcon.click();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
expect(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
expect(await personalFiles.dataTable.isItemPresent(expectedNameForCopiedFile)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('[C217319] Move a folder with a name that already exists on the destination', async ({ personalFiles }) => {
|
||||
const existingFolderId = (await nodesApi.createFolder(sourceFolder, destinationFolderId)).entry.id;
|
||||
await nodesApi.createFile(sourceFileInsideFolder, existingFolderId);
|
||||
const expectedNameForCopiedFile = sourceFileInsideFolder.replace('.', '-1.');
|
||||
await moveContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder);
|
||||
const msg = await personalFiles.snackBar.message.innerText();
|
||||
expect.soft(msg).toContain('Move unsuccessful, a file with the same name already exists.');
|
||||
await personalFiles.snackBar.closeIcon.click();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
expect(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(sourceFolder);
|
||||
expect(await personalFiles.dataTable.isItemPresent(sourceFileInsideFolder)).toBeTruthy();
|
||||
expect(await personalFiles.dataTable.isItemPresent(expectedNameForCopiedFile)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('[C217320] Move locked file', async ({ personalFiles }) => {
|
||||
const lockType = 'ALLOW_OWNER_CHANGES';
|
||||
await nodesApi.lockNodes([sourceFileId], lockType);
|
||||
await moveContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder);
|
||||
const msg = await personalFiles.snackBar.message.innerText();
|
||||
expect.soft(msg).toContain('Moved 1 item.');
|
||||
await personalFiles.snackBar.closeIcon.click();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeFalsy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('[C217321] Move folder that contains locked file', async ({ personalFiles }) => {
|
||||
const lockType = 'ALLOW_OWNER_CHANGES';
|
||||
await nodesApi.lockNodes([sourceFileInsideFolderId], lockType);
|
||||
await moveContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder);
|
||||
const msg = await personalFiles.snackBar.message.innerText();
|
||||
expect.soft(msg).toContain('Moved 1 item.');
|
||||
await personalFiles.snackBar.closeIcon.click();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeFalsy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(sourceFolder);
|
||||
expect(await personalFiles.dataTable.isItemPresent(sourceFileInsideFolder)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('[C217324] Undo move files', async ({ personalFiles, trashPage }) => {
|
||||
await moveContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder);
|
||||
await personalFiles.snackBar.actionButton.click();
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeFalsy();
|
||||
await trashPage.navigate();
|
||||
expect(await trashPage.dataTable.isItemPresent(sourceFile)).toBeFalsy();
|
||||
});
|
||||
|
||||
test('[C217325] Undo move of folders', async ({ personalFiles, trashPage }) => {
|
||||
await moveContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder);
|
||||
await personalFiles.snackBar.actionButton.click();
|
||||
await personalFiles.spinner.waitForReload();
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy();
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder);
|
||||
expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeFalsy();
|
||||
await trashPage.navigate();
|
||||
expect(await trashPage.dataTable.isItemPresent(sourceFolder)).toBeFalsy();
|
||||
});
|
||||
});
|
15
e2e/playwright/copy-move-actions/tsconfig.e2e.adf.json
Normal file
15
e2e/playwright/copy-move-actions/tsconfig.e2e.adf.json
Normal 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"]
|
||||
}
|
15
e2e/playwright/copy-move-actions/tsconfig.e2e.json
Executable file
15
e2e/playwright/copy-move-actions/tsconfig.e2e.json
Executable 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"]
|
||||
}
|
Reference in New Issue
Block a user