Skip to content

Commit

Permalink
[ACS-6510] playwright List View e2e test (#3566)
Browse files Browse the repository at this point in the history
* [ACS-6435] playwright e2e for list views personal files

* e2e test for trash page

* e2e test for trash page

* e2e test for file-libraries page

* e2e test for file-libraries page fix

* e2e test for file-libraries page fix

* e2e test shared recent  page

* e2e test shared recent  page fix

* e2e test review comment fix

* e2e test review fix flaky test fix

* e2e test fail test fix

* e2e test fail  fix

* test code fix

* protractor list-view test enable

* [ACS-6510] listview playwright e2e test

* code fix

* code fix

* code fix

* code fix

* code fix

* code fix

* code fix for review

* code fix for review
  • Loading branch information
akashrathod28 committed Dec 22, 2023
1 parent 1d0752c commit 7465bbb
Show file tree
Hide file tree
Showing 20 changed files with 859 additions and 817 deletions.
78 changes: 78 additions & 0 deletions e2e/playwright/list-views/src/tests/empty-list.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*!
* 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 { expect } from '@playwright/test';
import { ApiClientFactory, LoginPage, Utils, test } from '@alfresco/playwright-shared';

test.describe('Empty list views', () => {
const username = `user-${Utils.random()}`;

test.beforeAll(async () => {
const apiClientFactory = new ApiClientFactory();
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
});

test.beforeEach(async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.loginUser(
{ username, password: username },
{
withNavigation: true,
waitForLoading: true
}
);
});

test('[C217099] empty My Libraries', async ({ myLibrariesPage }) => {
await myLibrariesPage.navigate();
expect(await myLibrariesPage.dataTable.isEmpty(), 'list is not empty').toBe(true);
expect(await myLibrariesPage.dataTable.getEmptyStateTitle()).toContain(`You aren't a member of any File Libraries yet`);
expect(await myLibrariesPage.dataTable.getEmptyStateSubtitle()).toContain('Join libraries to upload, view, and share files.');
});

test('[C280134] [C280120] Empty Trash - pagination controls not displayed', async ({ trashPage }) => {
await trashPage.navigate();
expect(await trashPage.dataTable.isEmpty(), 'list is not empty').toBe(true);
expect(await trashPage.dataTable.getEmptyStateTitle()).toContain('Trash is empty');
expect(await trashPage.dataTable.getEmptyListText()).toContain('Items you delete are moved to the Trash.');
expect(await trashPage.dataTable.getEmptyListText()).toContain('Empty Trash to permanently delete items.');
expect(await trashPage.pagination.isRangePresent(), 'Range is present').toBe(false);
expect(await trashPage.pagination.isMaxItemsPresent(), 'Max items is present').toBe(false);
});

test('[C290123] [C290031] Empty Search results - pagination controls not displayed', async ({ personalFiles, searchPage }) => {
await personalFiles.acaHeader.searchButton.click();
await searchPage.searchInput.searchButton.click();
await searchPage.searchOverlay.checkFilesAndFolders();
await searchPage.searchOverlay.searchFor('InvalidText');
await searchPage.reload({ waitUntil: 'domcontentloaded' });
await searchPage.dataTable.spinnerWaitForReload();

expect(await personalFiles.pagination.isRangePresent(), 'Range is present').toBe(false);
expect(await personalFiles.pagination.isMaxItemsPresent(), 'Max items is present').toBe(false);
expect(await personalFiles.dataTable.isEmpty(), 'list is not empty').toBe(true);
expect(await personalFiles.dataTable.emptySearchText.innerText()).toContain('Your search returned 0 results');
});
});
99 changes: 99 additions & 0 deletions e2e/playwright/list-views/src/tests/generic-errors.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*!
* 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 { expect } from '@playwright/test';
import { ApiClientFactory, LoginPage, NodesApi, TrashcanApi, Utils, test } from '@alfresco/playwright-shared';

test.describe('Generic errors', () => {
const username = `user-${Utils.random()}`;
const username2 = `user2-${Utils.random()}`;
let parentId: string;
let file1Id: string;
let file2Id: string;
let actionUser: NodesApi;

test.beforeAll(async () => {
try {
const parent = `folder-${Utils.random()}`;
const file1 = `file1-${Utils.random()}.txt`;
const file2 = `file2-${Utils.random()}.txt`;
const apiClientFactory = new ApiClientFactory();
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
await apiClientFactory.createUser({ username: username2 });

actionUser = await NodesApi.initialize(username, username);
parentId = (await actionUser.createFolder(parent)).entry.id;
file1Id = (await actionUser.createFile(file1, parentId)).entry.id;
file2Id = (await actionUser.createFile(file2, parentId)).entry.id;
} catch (error) {
console.error(`----- beforeAll failed : ${error}`);
}
});

test.beforeEach(async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.loginUser(
{ username, password: username },
{
withNavigation: true,
waitForLoading: true
}
);
});

test.afterAll(async () => {
actionUser = await NodesApi.initialize(username, username);
const trashcanApi = await TrashcanApi.initialize(username, username);
await actionUser.deleteNodeById(parentId);
await trashcanApi.emptyTrashcan();
});

test('[C217313] File / folder not found', async ({ personalFiles }) => {
await actionUser.deleteNodeById(file1Id, false);
await personalFiles.navigate({ remoteUrl: `#/personal-files/${file1Id}` });

expect(await personalFiles.errorDialog.genericError.isVisible(), 'Generic error page not displayed').toBe(true);
expect(await personalFiles.errorDialog.genericErrorTitle.innerText()).toContain(
`This item no longer exists or you don't have permission to view it.`
);
});

test('[C217314] Permission denied', async ({ personalFiles, loginPage }) => {
await loginPage.logoutUser();
await loginPage.loginUser(
{ username: username2, password: username2 },
{
withNavigation: true,
waitForLoading: true
}
);
await personalFiles.navigate({ remoteUrl: `#/personal-files/${file2Id}` });

expect(await personalFiles.errorDialog.genericError.isVisible(), 'Generic error page not displayed').toBe(true);
expect(await personalFiles.errorDialog.genericErrorTitle.innerText()).toContain(
`This item no longer exists or you don't have permission to view it.`
);
});
});
205 changes: 205 additions & 0 deletions e2e/playwright/list-views/src/tests/permissions.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
/*!
* 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 { expect } from '@playwright/test';
import {
ApiClientFactory,
FavoritesPageApi,
FileActionsApi,
LoginPage,
NodesApi,
SharedLinksApi,
SitesApi,
Utils,
test,
timeouts
} from '@alfresco/playwright-shared';
import { Site } from '@alfresco/js-api';

test.describe('Special permissions', () => {
const username = `userPermissions-${Utils.random()}`;
let siteApiAdmin: SitesApi;
test.beforeAll(async () => {
const apiClientFactory = new ApiClientFactory();
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
});

test.describe('file not displayed if user no longer has permissions on it', () => {
const sitePrivate = `private-${Utils.random()}`;
const fileName = `file-${Utils.random()}.txt`;

test.beforeAll(async () => {
test.setTimeout(timeouts.webServer);
const userFavoritesApi = await FavoritesPageApi.initialize(username, username);
const userFileActionApi = await FileActionsApi.initialize(username, username);
siteApiAdmin = await SitesApi.initialize('admin');
const nodeApiAdmin = await NodesApi.initialize('admin');
const shareApiAdmin = await SharedLinksApi.initialize('admin');
const shareApiUser = await SharedLinksApi.initialize(username, username);

await siteApiAdmin.createSite(sitePrivate, Site.VisibilityEnum.PRIVATE);
await siteApiAdmin.addSiteMember(sitePrivate, username, Site.RoleEnum.SiteCollaborator);
const docLibId = await siteApiAdmin.getDocLibId(sitePrivate);
const fileId = (await nodeApiAdmin.createFile(fileName, docLibId)).entry.id;
await shareApiAdmin.shareFileById(fileId);
await userFavoritesApi.addFavoriteById('file', fileId);

await userFileActionApi.updateNodeContent(fileId, 'edited by user');

await userFileActionApi.waitForNodes(username, { expect: 1 });

await shareApiAdmin.waitForFilesToBeShared([fileId]);
await shareApiUser.waitForFilesToBeShared([fileId]);
});

test.beforeEach(async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.loginUser(
{ username, password: username },
{
withNavigation: true,
waitForLoading: true
}
);
});

test.afterEach(async () => {
await siteApiAdmin.addSiteMember(sitePrivate, username, Site.RoleEnum.SiteCollaborator);
});

test.afterAll(async () => {
await siteApiAdmin.deleteSites([sitePrivate]);
});

test('[C213173] on Recent Files', async ({ recentFilesPage }) => {
await recentFilesPage.navigate();
expect(await recentFilesPage.dataTable.getRowsCount(), 'Incorrect number of items').toBe(2);
await siteApiAdmin.deleteSiteMember(sitePrivate, username);
await recentFilesPage.reload();
expect(await recentFilesPage.dataTable.isEmpty(), 'Items are still displayed').toBe(true);
});

test('[C213227] on Favorites', async ({ favoritePage }) => {
await favoritePage.navigate();
expect(await favoritePage.dataTable.getRowsCount(), 'Incorrect number of items').toBe(2);
await siteApiAdmin.deleteSiteMember(sitePrivate, username);
await favoritePage.reload();
expect(await favoritePage.dataTable.isEmpty(), 'Items are still displayed').toBe(true);
});

test('[C213116] on Shared Files', async ({ sharedPage }) => {
await sharedPage.navigate();
expect(await sharedPage.dataTable.getRowsCount(), 'Incorrect number of items').toBe(2);
await siteApiAdmin.deleteSiteMember(sitePrivate, username);
await sharedPage.reload();
expect(await sharedPage.dataTable.getRowsCount(), 'Incorrect number of items').toBe(0);
});

test('[C290122] on Search Results', async ({ personalFiles, searchPage }) => {
await personalFiles.acaHeader.searchButton.click();
await searchPage.searchInput.searchButton.click();
await searchPage.searchOverlay.checkFilesAndFolders();
await searchPage.searchOverlay.searchFor(fileName);
await searchPage.dataTable.spinnerWaitForReload();

expect(await searchPage.dataTable.getRowsCount(), 'Incorrect number of items').toBe(2);

await siteApiAdmin.deleteSiteMember(sitePrivate, username);

await searchPage.reload();
await searchPage.dataTable.spinnerWaitForReload();

expect(await searchPage.dataTable.getRowsCount(), 'Incorrect number of items').toBe(0);
});
});

test.describe(`Location column is empty if user doesn't have permissions on the file's parent folder`, () => {
const sitePrivate = `private-${Utils.random()}`;
const fileName = `file-${Utils.random()}.txt`;
let adminSiteApiActions: SitesApi;

test.beforeAll(async () => {
test.setTimeout(timeouts.webServer);
const userFavoritesApi = await FavoritesPageApi.initialize(username, username);
const userShareActionApi = await SharedLinksApi.initialize(username, username);
const userNodeActionApi = await NodesApi.initialize(username, username);
adminSiteApiActions = await SitesApi.initialize('admin');

await adminSiteApiActions.createSite(sitePrivate, Site.VisibilityEnum.PRIVATE);
await adminSiteApiActions.addSiteMember(sitePrivate, username, Site.RoleEnum.SiteCollaborator);
const docLibId = await adminSiteApiActions.getDocLibId(sitePrivate);
const fileId = (await userNodeActionApi.createFile(fileName, docLibId)).entry.id;
await userFavoritesApi.addFavoriteById('file', fileId);

await userShareActionApi.shareFileById(fileId);
await userShareActionApi.waitForFilesToBeShared([fileId]);
await adminSiteApiActions.deleteSiteMember(sitePrivate, username);
});

test.beforeEach(async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.loginUser(
{ username, password: username },
{
withNavigation: true,
waitForLoading: true
}
);
});

test.afterAll(async () => {
await adminSiteApiActions.deleteSites([sitePrivate]);
});

test('[C213178] on Recent Files', async ({ recentFilesPage }) => {
await recentFilesPage.navigate();
expect(await recentFilesPage.dataTable.getRowsCount(), 'Incorrect number of items').toBe(2);
expect(await recentFilesPage.dataTable.getItemLocationText(fileName)).toEqual('Unknown');
});

test('[C213672] on Favorites', async ({ favoritePage }) => {
await favoritePage.navigate();
expect(await favoritePage.dataTable.getRowsCount(), 'Incorrect number of items').toBe(2);
expect(await favoritePage.dataTable.getItemLocationText(fileName)).toEqual('Unknown');
});

test(`[C213668] on Shared Files`, async ({ sharedPage }) => {
await sharedPage.navigate();
expect(await sharedPage.dataTable.getRowsCount(), 'Incorrect number of items').toBe(2);
expect(await sharedPage.dataTable.getItemLocationText(fileName)).toEqual('Unknown');
});

test('[C306868] on Search results', async ({ personalFiles, searchPage }) => {
await personalFiles.acaHeader.searchButton.click();
await searchPage.searchInput.searchButton.click();
await searchPage.searchOverlay.checkFilesAndFolders();
await searchPage.searchOverlay.searchFor(fileName);
await searchPage.dataTable.spinnerWaitForReload();

expect(await searchPage.dataTable.getRowsCount(), 'Incorrect number of items').toBe(2);
expect(await searchPage.dataTable.getItemLocationText(fileName)).toEqual('Unknown');
});
});
});

0 comments on commit 7465bbb

Please sign in to comment.