Skip to content

Commit

Permalink
[ACS-5923] playwright sidenav and single click test (#3442)
Browse files Browse the repository at this point in the history
* [ACS-5923] sidenav and singleclick test

* remove protractor test and fix flaky test

* test fix

* Update error message for expect
  • Loading branch information
akashrathod28 authored Sep 25, 2023
1 parent 2157e8e commit 97f0138
Show file tree
Hide file tree
Showing 21 changed files with 435 additions and 294 deletions.
57 changes: 57 additions & 0 deletions e2e/playwright/navigation/src/tests/breadcrumb-admin.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*!
* 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, getUserState, NodesApi, test, Utils } from '@alfresco/playwright-shared';

test.use({ storageState: getUserState('admin') });
test.describe('as admin', () => {
const apiClientFactory = new ApiClientFactory();
const userFolder = `userFolder-${Utils.random()}`;
const username = `userAdmin-${Utils.random()}`;
let userFolderId: string;
let nodesApi: NodesApi;

test.beforeAll(async () => {
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
nodesApi = await NodesApi.initialize(username, username);
const node = await nodesApi.createFolder(userFolder);
userFolderId = node.entry.id;
});

test.beforeEach(async ({ personalFiles }) => {
await personalFiles.navigate({ remoteUrl: `#/personal-files}` });
});

test.afterAll(async () => {
await apiClientFactory.nodes.deleteNode(userFolderId, { permanent: true });
});

test(`[C260970] Breadcrumb on navigation to a user's home`, async ({ personalFiles }) => {
await personalFiles.navigate({ remoteUrl: `#/personal-files/${userFolderId}` });
personalFiles.breadcrumb.getItemByTitle(username).waitFor({ state: 'attached' });
expect(await personalFiles.breadcrumb.getAllItems()).toEqual(['Personal Files', 'User Homes', username, userFolder]);
});
});
78 changes: 78 additions & 0 deletions e2e/playwright/navigation/src/tests/sidebar.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, APP_ROUTES, getUserState, SIDEBAR_LABELS, test } from '@alfresco/playwright-shared';

test.use({ storageState: getUserState('hruser') });
test.describe('Sidebar', () => {
const apiClientFactory = new ApiClientFactory();

test.beforeAll(async () => {
await apiClientFactory.setUpAcaBackend('hruser');
});

test('[C289901] navigate to My Libraries', async ({ personalFiles, myLibrariesPage }) => {
await personalFiles.navigate();
await personalFiles.sidenav.openPanel(SIDEBAR_LABELS.MY_LIBRARIES);
await personalFiles.dataTable.spinnerWaitForReload();
expect(myLibrariesPage.page.url()).toContain(APP_ROUTES.MY_LIBRARIES);
expect(await myLibrariesPage.sidenav.isActive(SIDEBAR_LABELS.MY_LIBRARIES), 'My Libraries link not active').toBe(true);
});

test('[C277230] sidenav can be expanded when search results page is displayed', async ({ personalFiles }) => {
await personalFiles.navigate({ remoteUrl: `#/search;q=test` });
expect(await personalFiles.sidenav.isSidenavExpanded(), 'Sidebar expanded').toBe(false);
await personalFiles.sidenav.expandSideNav();
expect(await personalFiles.sidenav.isSidenavExpanded(), 'Sidebar not expanded').toBe(true);
});

test('[C269100] sidebar state is preserved on page refresh', async ({ personalFiles }) => {
await personalFiles.navigate();
expect(await personalFiles.sidenav.isSidenavExpanded(), 'Sidebar not expanded').toBe(true);
await personalFiles.reload();
expect(await personalFiles.sidenav.isSidenavExpanded(), 'Sidebar not expanded').toBe(true);

await personalFiles.sidenav.collapseSideNav();

expect(await personalFiles.sidenav.isSidenavExpanded(), 'Sidebar expanded').toBe(false);
await personalFiles.reload();
expect(await personalFiles.sidenav.isSidenavExpanded(), 'Sidebar expanded').toBe(false);
});

test('[C269096] sidebar toggle', async ({ personalFiles }) => {
await personalFiles.navigate();
await personalFiles.sidenav.collapseSideNav();
expect(await personalFiles.sidenav.isSidenavExpanded(), 'Sidebar expanded').toBe(false);
await personalFiles.sidenav.expandSideNav();
expect(await personalFiles.sidenav.isSidenavExpanded(), 'Sidebar not expanded').toBe(true);
});

test('[C277224] sidenav returns to the default state when navigating away from the Search Results page', async ({ personalFiles, searchPage }) => {
await personalFiles.navigate({ remoteUrl: `#/search;q=test` });
await searchPage.searchInput.getIconByName('close').click();
await searchPage.sidenav.expandedSidenav.waitFor({ state: 'attached' });
expect(await personalFiles.sidenav.isSidenavExpanded(), 'Sidebar not expanded').toBe(true);
});
});
89 changes: 89 additions & 0 deletions e2e/playwright/navigation/src/tests/single-click.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*!
* 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, getUserState, test, Utils } from '@alfresco/playwright-shared';

test.use({ storageState: getUserState('hruser') });
test.describe('Single click on item name', () => {
const apiClientFactory = new ApiClientFactory();

const folder1 = `folder1-${Utils.random()}`;
let folder1Id: string;
const folderSearch = `folder1-${Utils.random()}`;
let folderSearchId: string;

const deletedFile1 = `file1-${Utils.random()}.txt`;
let deletedFile1Id: string;
const deletedFolder1 = `folder1-${Utils.random()}`;
let deletedFolder1Id: string;

const siteName = `site-${Utils.random()}`;
const fileSite = `fileSite-${Utils.random()}.txt`;

test.beforeAll(async ({ nodesApiAction, sitesApiAction }) => {
await apiClientFactory.setUpAcaBackend('hruser');
const node = await apiClientFactory.nodes.createNode('-my-', { name: folder1, nodeType: 'cm:folder', relativePath: '/' });
folder1Id = node.entry.id;
folderSearchId = (await nodesApiAction.createFolder(folderSearch)).entry.id;
deletedFile1Id = (await nodesApiAction.createFile(deletedFile1)).entry.id;
deletedFolder1Id = (await nodesApiAction.createFolder(deletedFolder1)).entry.id;

await sitesApiAction.createSite(siteName);
const docLibId = await sitesApiAction.getDocLibId(siteName);
await nodesApiAction.createFile(fileSite, docLibId);
});

test.afterAll(async ({ nodesApiAction }) => {
await nodesApiAction.deleteNodes([deletedFolder1Id, deletedFile1Id], true);
});

test('[C284899] Hyperlink does not appear for items in the Trash', async ({ trashPage }) => {
await trashPage.navigate();
expect(await trashPage.dataTable.getCellLinkByName(deletedFile1).isVisible(), 'Link on name is present').toBe(false);
expect(await trashPage.dataTable.getCellLinkByName(deletedFolder1).isVisible(), 'Link on name is present').toBe(false);
});

test.describe('on Personal Files', () => {
test.afterAll(async ({ nodesApiAction }) => {
await nodesApiAction.deleteNodes([folder1Id, folderSearchId], true);
});

test('[C280034] Navigate inside the folder when clicking the hyperlink on Personal Files', async ({ personalFiles }) => {
await personalFiles.navigate();
await personalFiles.dataTable.getCellLinkByName(folder1).click();
await personalFiles.dataTable.spinnerWaitForReload();
expect(await personalFiles.breadcrumb.currentItem.innerText()).toBe(folder1);
});
});

test('[C284902] Navigate inside the library when clicking the hyperlink on File Libraries', async ({ myLibrariesPage }) => {
await myLibrariesPage.navigate();
await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(siteName);
await myLibrariesPage.dataTable.getCellLinkByName(siteName).click();
await myLibrariesPage.dataTable.spinnerWaitForReload();
expect(await myLibrariesPage.breadcrumb.currentItem.innerText()).toBe(siteName);
expect(await myLibrariesPage.dataTable.getCellLinkByName(fileSite).isVisible(), `${fileSite} not displayed`).toBe(true);
});
});
Loading

0 comments on commit 97f0138

Please sign in to comment.