diff --git a/e2e/playwright/actions/src/tests/share/unshare-file-search-results.spec.ts b/e2e/playwright/actions/src/tests/share/unshare-file-search-results.spec.ts
new file mode 100755
index 0000000000..b0ae548be2
--- /dev/null
+++ b/e2e/playwright/actions/src/tests/share/unshare-file-search-results.spec.ts
@@ -0,0 +1,224 @@
+/*!
+ * 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 .
+ */
+
+import {
+ ApiClientFactory,
+ FileActionsApi,
+ NodesApi,
+ SITE_ROLES,
+ SITE_VISIBILITY,
+ SharedLinksApi,
+ SitesApi,
+ Utils,
+ test,
+ timeouts
+} from '@alfresco/playwright-shared';
+import { expect } from '@playwright/test';
+
+test.describe.only('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 fileSite1Id: string;
+ 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(140000);
+ 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_VISIBILITY.PRIVATE);
+ const docLibId = await sitesApi.getDocLibId(sitePrivate);
+
+ fileSite1Id = (await nodesApi.createFile(fileSite1, docLibId)).entry.id;
+ fileSite2Id = (await nodesApi.createFile(fileSite2, docLibId)).entry.id;
+
+ await sitesApi.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE);
+
+ 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}`);
+ }
+ });
+
+ 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(await personalFiles.confirmDialog.isRemoveEnabled()).toBe(true);
+ expect(await personalFiles.confirmDialog.isCancelEnabled()).toBe(true);
+ });
+
+ 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 personalFiles.shareDialog.clickClose();
+ expect(await nodesApiAction.isFileShared(file2Id)).toBe(false);
+
+ await page.goto(url);
+ await personalFiles.viewer.waitForViewerToOpen();
+ expect(await personalFiles.viewer.fileTitleButtonLocator.innerText()).not.toEqual(file2);
+ });
+
+ 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 personalFiles.shareDialog.clickClose();
+ expect(await nodesApiAction.isFileShared(file4Id)).toBe(false);
+
+ await page.goto(url);
+ await personalFiles.viewer.waitForViewerToOpen();
+ expect(personalFiles.viewer.fileTitleButtonLocator).not.toEqual(file4);
+
+ await page.reload();
+ });
+
+ 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 }) => {
+ 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 personalFiles.shareDialog.clickClose();
+ expect(await nodesApiAction.isFileShared(fileSite2Id)).toBe(false);
+ });
+});
diff --git a/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts
index 95df52d4be..8bdd991e29 100644
--- a/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts
+++ b/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts
@@ -315,4 +315,8 @@ export class DataTableComponent extends BaseComponent {
async getRowsCount(): Promise {
return this.getRowLocator.count();
}
+
+ async rightClickOnItem(itemName: string): Promise {
+ await this.getCellByColumnNameAndRowItem(itemName, 'Name').click({ button: 'right' });
+ }
}
diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-confirm-dialog.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-confirm-dialog.component.ts
index 0590fa0a6e..0de17b3d8b 100644
--- a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-confirm-dialog.component.ts
+++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-confirm-dialog.component.ts
@@ -36,4 +36,22 @@ export class AdfConfirmDialogComponent extends BaseComponent {
getDialogContent = (text: string) => this.getChild('[data-automation-id="adf-confirm-dialog-base-message"]', { hasText: text });
okButton = this.getChild('[data-automation-id="adf-confirm-dialog-confirmation"]');
cancelButton = this.getChild('[data-automation-id="adf-confirm-dialog-reject"]');
+
+ async isRemoveEnabled(): Promise {
+ try {
+ await this.okButton.isVisible();
+ return this.okButton.isEnabled();
+ } catch {
+ throw new Error(`Remove button is not enabled`);
+ }
+ }
+
+ async isCancelEnabled(): Promise {
+ try {
+ await this.cancelButton.isVisible();
+ return this.cancelButton.isEnabled();
+ } catch {
+ throw new Error(`CANCEL button is not enabled`);
+ }
+ }
}
diff --git a/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts
index d9f43da3f8..3c119c73f6 100644
--- a/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts
+++ b/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts
@@ -38,7 +38,8 @@ import {
SidenavComponent,
PaginationComponent,
ErrorComponent,
- ShareDialogComponent
+ ShareDialogComponent,
+ AdfConfirmDialogComponent
} from '../components';
export class PersonalFilesPage extends BasePage {
@@ -62,6 +63,7 @@ export class PersonalFilesPage extends BasePage {
public pagination = new PaginationComponent(this.page);
public errorDialog = new ErrorComponent(this.page);
public shareDialog= new ShareDialogComponent(this.page);
+ public confirmDialog = new AdfConfirmDialogComponent(this.page);
async selectCreateFolder(): Promise {
await this.acaHeader.createButton.click();
diff --git a/projects/aca-playwright-shared/src/utils/config.ts b/projects/aca-playwright-shared/src/utils/config.ts
index f85982bae7..6765d11cf9 100644
--- a/projects/aca-playwright-shared/src/utils/config.ts
+++ b/projects/aca-playwright-shared/src/utils/config.ts
@@ -43,3 +43,13 @@ export const SIDEBAR_LABELS = {
FAVORITES: 'Favorites',
TRASH: 'Trash'
};
+
+export const SITE_VISIBILITY = {
+ PRIVATE: 'PRIVATE'
+};
+
+export const SITE_ROLES = {
+ SITE_CONSUMER: {
+ ROLE: 'SiteConsumer'
+ }
+};