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-6457] Migrated unshare-file e2es to playwright #3575

Merged
merged 10 commits into from
Dec 28, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ jobs:
id: 2
- name: "viewer,infoDrawer,extensions"
id: 3
- name: "shareActions"
id: 4
- name: "copyMoveActions"
id: 6
- name: "deleteActions"
Expand Down Expand Up @@ -176,6 +174,8 @@ jobs:
id: 7
- name: "list-views"
id: 8
- name: "share-action"
id: 9
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
26 changes: 26 additions & 0 deletions e2e/playwright/share-action/.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/share-action/tsconfig.e2e.json"
],
"createDefaultProgram": true
},
"plugins": [
"rxjs",
"unicorn"
],
"rules": {
"@typescript-eslint/no-floating-promises": "off"
}
}
]
}
1 change: 1 addition & 0 deletions e2e/playwright/share-action/exclude.tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
44 changes: 44 additions & 0 deletions e2e/playwright/share-action/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, 'Share Action'),
projects: [
{
name: 'Share Action',
testDir: './src/tests',
use: {
users: ['hruser']
}
}
]
};

export default config;
22 changes: 22 additions & 0 deletions e2e/playwright/share-action/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "share-action-e2e",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/playwright/share-action/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "nx:run-commands",
"options": {
"commands": ["npx playwright test --config=e2e/playwright/share-action/playwright.config.ts"]
},
"configurations": {
"production": {
"devServerTarget": "content-ce:serve:production"
}
}
},
"lint": {
"executor": "@angular-eslint/builder:lint"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
/*!
* 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 { Site } from '@alfresco/js-api';
import { ApiClientFactory, FileActionsApi, NodesApi, SharedLinksApi, SitesApi, Utils, test, timeouts } from '@alfresco/playwright-shared';
import { expect } from '@playwright/test';

test.describe('Unshare a file from Search Results', () => {
const random = Utils.random();

const username = `user-${random}`;
const parent = `parent-${random}`;
let parentId: string;
const searchRandom = random;
let sitesApi: SitesApi;

let file1Id: string;
let file2Id: string;
let file3Id: string;
let file4Id: string;
const file1 = `search-file-${searchRandom}-1.txt`;
const file2 = `search-file-${searchRandom}-2.txt`;
const file3 = `search-file-${searchRandom}-3.txt`;
const file4 = `search-file-${searchRandom}-4.txt`;

const sitePrivate = `site-private-${random}`;

let fileSite2Id: string;
const fileSite1 = `search-file-${searchRandom}-Site1.txt`;
const fileSite2 = `search-file-${searchRandom}-Site2.txt`;

const apiClientFactory = new ApiClientFactory();

test.beforeAll(async () => {
try {
test.setTimeout(timeouts.extendedTest);
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
const nodesApi = await NodesApi.initialize(username, username);
sitesApi = await SitesApi.initialize(username, username);
const shareApi = await SharedLinksApi.initialize(username, username);
const filesAction = await FileActionsApi.initialize(username, username);
parentId = (await nodesApi.createFolder(parent)).entry.id;

file1Id = (await nodesApi.createFile(file1, parentId)).entry.id;
file2Id = (await nodesApi.createFile(file2, parentId)).entry.id;
file3Id = (await nodesApi.createFile(file3, parentId)).entry.id;
file4Id = (await nodesApi.createFile(file4, parentId)).entry.id;

await sitesApi.createSite(sitePrivate, Site.VisibilityEnum.PRIVATE);
const docLibId = await sitesApi.getDocLibId(sitePrivate);

const fileSite1Id = (await nodesApi.createFile(fileSite1, docLibId)).entry.id;
fileSite2Id = (await nodesApi.createFile(fileSite2, docLibId)).entry.id;

await sitesApi.addSiteMember(sitePrivate, username, Site.RoleEnum.SiteConsumer);

await shareApi.shareFilesByIds([fileSite1Id]);
await shareApi.waitForFilesToBeShared([fileSite1Id]);

await shareApi.shareFilesByIds([file1Id, file2Id, file3Id, file4Id, fileSite2Id]);
await shareApi.waitForFilesToBeShared([file1Id, file2Id, file3Id, file4Id, fileSite2Id]);

await filesAction.waitForNodes(`search-file-${searchRandom}`, { expect: 6 });
} catch (error) {
throw new Error(`----- beforeAll failed : ${error}`);

Check failure on line 87 in e2e/playwright/share-action/src/tests/share/unshare-file-search-results.spec.ts

View workflow job for this annotation

GitHub Actions / E2e test suites: Playwright (share-action, 9)

[Share Action] › src/tests/share/unshare-file-search-results.spec.ts:102:7 › Unshare a file from Search Results › [C306995] Unshare dialog UI

1) [Share Action] › src/tests/share/unshare-file-search-results.spec.ts:102:7 › Unshare a file from Search Results › [C306995] Unshare dialog UI Error: ----- beforeAll failed : false 85 | await filesAction.waitForNodes(`search-file-${searchRandom}`, { expect: 6 }); 86 | } catch (error) { > 87 | throw new Error(`----- beforeAll failed : ${error}`); | ^ 88 | } 89 | }); 90 | at /home/runner/work/alfresco-content-app/alfresco-content-app/e2e/playwright/share-action/src/tests/share/unshare-file-search-results.spec.ts:87:13

Check failure on line 87 in e2e/playwright/share-action/src/tests/share/unshare-file-search-results.spec.ts

View workflow job for this annotation

GitHub Actions / E2e test suites: Playwright (share-action, 9)

[Share Action] › src/tests/share/unshare-file-search-results.spec.ts:142:7 › Unshare a file from Search Results › [C306997] Cancel the Unshare action

2) [Share Action] › src/tests/share/unshare-file-search-results.spec.ts:142:7 › Unshare a file from Search Results › [C306997] Cancel the Unshare action Error: ----- beforeAll failed : false 85 | await filesAction.waitForNodes(`search-file-${searchRandom}`, { expect: 6 }); 86 | } catch (error) { > 87 | throw new Error(`----- beforeAll failed : ${error}`); | ^ 88 | } 89 | }); 90 | at /home/runner/work/alfresco-content-app/alfresco-content-app/e2e/playwright/share-action/src/tests/share/unshare-file-search-results.spec.ts:87:13

Check failure on line 87 in e2e/playwright/share-action/src/tests/share/unshare-file-search-results.spec.ts

View workflow job for this annotation

GitHub Actions / E2e test suites: Playwright (share-action, 9)

[Share Action] › src/tests/share/unshare-file-search-results.spec.ts:179:7 › Unshare a file from Search Results › [C306998] Consumer - on Search Results - file shared by other user

3) [Share Action] › src/tests/share/unshare-file-search-results.spec.ts:179:7 › Unshare a file from Search Results › [C306998] Consumer - on Search Results - file shared by other user Error: ----- beforeAll failed : false 85 | await filesAction.waitForNodes(`search-file-${searchRandom}`, { expect: 6 }); 86 | } catch (error) { > 87 | throw new Error(`----- beforeAll failed : ${error}`); | ^ 88 | } 89 | }); 90 | at /home/runner/work/alfresco-content-app/alfresco-content-app/e2e/playwright/share-action/src/tests/share/unshare-file-search-results.spec.ts:87:13
}
});

test.beforeEach(async ({ loginPage, personalFiles }) => {
await loginPage.navigate();
await loginPage.loginUser({ username: username, password: username });
await personalFiles.waitForPageLoad();
});

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

test('[C306995] Unshare dialog UI', async ({ personalFiles, searchPage }) => {
await personalFiles.acaHeader.searchButton.click();
await searchPage.searchInput.searchButton.click();
await searchPage.searchOverlay.checkFilesAndFolders();
await searchPage.searchOverlay.searchFor(file1);

await personalFiles.dataTable.selectItem(file1);
await personalFiles.acaHeader.shareButton.click();
await personalFiles.viewerDialog.shareDialogTitle.waitFor({ state: 'attached', timeout: timeouts.normal });

expect(await personalFiles.shareDialog.isShareToggleChecked()).toBe(true);
await personalFiles.shareDialog.shareToggle.click();

expect(personalFiles.confirmDialog.getDialogTitle('Remove this shared link')).toBeVisible();
expect(
personalFiles.confirmDialog.getDialogContent('This link will be deleted and a new link will be created next time this file is shared')
).toBeVisible();
expect(personalFiles.confirmDialog.okButton).toBeEnabled();
expect(personalFiles.confirmDialog.cancelButton).toBeEnabled();
});

test('[C306996] Unshare a file', async ({ personalFiles, searchPage, nodesApiAction, page }) => {
await personalFiles.acaHeader.searchButton.click();
await searchPage.searchInput.searchButton.click();
await searchPage.searchOverlay.checkFilesAndFolders();
await searchPage.searchOverlay.searchFor(file2);

await personalFiles.dataTable.selectItem(file2);
await personalFiles.acaHeader.shareButton.click();
const url = await personalFiles.shareDialog.getLinkUrl();
await personalFiles.shareDialog.shareToggle.click();

await personalFiles.confirmDialog.okButton.click();

await page.goto(url);
await personalFiles.viewer.waitForViewerToOpen();
expect(await personalFiles.viewer.fileTitleButtonLocator.innerText()).not.toEqual(file2);
expect(await nodesApiAction.isFileShared(file2Id)).toBe(false);
});

test('[C306997] Cancel the Unshare action', async ({ personalFiles, searchPage }) => {
await personalFiles.acaHeader.searchButton.click();
await searchPage.searchInput.searchButton.click();
await searchPage.searchOverlay.checkFilesAndFolders();
await searchPage.searchOverlay.searchFor(file3);

await personalFiles.dataTable.selectItem(file3);
await personalFiles.acaHeader.shareButton.click();

const urlBefore = await personalFiles.shareDialog.getLinkUrl();
await personalFiles.shareDialog.shareToggle.click();
await personalFiles.confirmDialog.cancelButton.click();
expect(await personalFiles.shareDialog.isShareToggleChecked()).toBe(true);

const urlAfter = await personalFiles.shareDialog.getLinkUrl();
expect(urlBefore).toEqual(urlAfter);
});

test('[C306999] Unshare a file from the context menu', async ({ personalFiles, searchPage, nodesApiAction, page }) => {
await personalFiles.acaHeader.searchButton.click();
await searchPage.searchInput.searchButton.click();
await searchPage.searchOverlay.checkFilesAndFolders();
await searchPage.searchOverlay.searchFor(file4);

await personalFiles.dataTable.rightClickOnItem(file4);
await personalFiles.matMenu.clickMenuItem('Shared Link Settings');
const url = await personalFiles.shareDialog.getLinkUrl();
await personalFiles.shareDialog.shareToggle.click();

await personalFiles.confirmDialog.okButton.click();

await page.goto(url);
await personalFiles.viewer.waitForViewerToOpen();
expect(personalFiles.viewer.fileTitleButtonLocator).not.toEqual(file4);
expect(await nodesApiAction.isFileShared(file4Id)).toBe(false);
});

test('[C306998] Consumer - on Search Results - file shared by other user', async ({ personalFiles, searchPage, nodesApiAction }) => {
await personalFiles.acaHeader.searchButton.click();
await searchPage.searchInput.searchButton.click();
await searchPage.searchOverlay.checkFilesAndFolders();
await searchPage.searchOverlay.searchFor(fileSite1);

await personalFiles.dataTable.selectItem(fileSite1);
await personalFiles.acaHeader.shareButton.click();

expect(await personalFiles.shareDialog.isShareToggleChecked()).toBe(true);
await personalFiles.shareDialog.shareToggle.click();
await personalFiles.confirmDialog.okButton.click();
expect(await nodesApiAction.isFileShared(fileSite2Id)).toBe(true);
});

test('[C307000] Consumer - on Search Results - file shared by the user', async ({ personalFiles, searchPage, nodesApiAction, page }) => {
await personalFiles.acaHeader.searchButton.click();
await searchPage.searchInput.searchButton.click();
await searchPage.searchOverlay.checkFilesAndFolders();
await searchPage.searchOverlay.searchFor(fileSite2);

await personalFiles.dataTable.selectItem(fileSite2);
await personalFiles.acaHeader.shareButton.click();
expect(await personalFiles.shareDialog.isShareToggleChecked()).toBe(true);

await personalFiles.shareDialog.shareToggle.click();
await personalFiles.confirmDialog.okButton.click();
await page.waitForTimeout(timeouts.tiny);
expect(await nodesApiAction.isFileShared(fileSite2Id)).toBe(false);
});
});
15 changes: 15 additions & 0 deletions e2e/playwright/share-action/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/share-action/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