From f75255f537b781acf8fe990b280025237ebf8b03 Mon Sep 17 00:00:00 2001 From: datguycheb Date: Fri, 26 Jan 2024 11:00:39 +0100 Subject: [PATCH 01/22] [ACS-5882] infoDrawer comments tests migrated to Playwright --- .../src/page-objects/pages/favorites.page.ts | 6 ++++++ .../src/page-objects/pages/personal-files.page.ts | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts index 8aa940f26a..4f561f5b3e 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts @@ -49,4 +49,10 @@ export class FavoritesPage extends BasePage { async waitForPageLoad() { await this.page.waitForURL(`**/${FavoritesPage.pageUrl}`); } + + async addCommentToNode(commentText: any) { + await this.infoDrawer.commentInputField.click(); + await this.page.keyboard.type(commentText); + await this.infoDrawer.addCommentButton.click(); + } } 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 8098788fb4..bfa28c743e 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 @@ -95,4 +95,8 @@ export class PersonalFilesPage extends BasePage { await this.contentNodeSelector.selectDestination(destinationName); await this.contentNodeSelector.actionButton.click(); } + + async clickInfoDrawerButton(): Promise { + await this.acaHeader.viewDetails.click(); + } } From adb240d9de69b1a6454d7d84c0a7f1cd04ac488f Mon Sep 17 00:00:00 2001 From: datguycheb Date: Fri, 26 Jan 2024 12:11:04 +0100 Subject: [PATCH 02/22] [ACS-5882] fixed issues from pull request comments --- .../src/page-objects/pages/favorites.page.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts index 4f561f5b3e..8aa940f26a 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts @@ -49,10 +49,4 @@ export class FavoritesPage extends BasePage { async waitForPageLoad() { await this.page.waitForURL(`**/${FavoritesPage.pageUrl}`); } - - async addCommentToNode(commentText: any) { - await this.infoDrawer.commentInputField.click(); - await this.page.keyboard.type(commentText); - await this.infoDrawer.addCommentButton.click(); - } } From eeacbf0242e530620897bc8168e5ce86f1e17a14 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Fri, 2 Feb 2024 00:07:28 +0100 Subject: [PATCH 03/22] Protractor to Playwright info-drawer tests --- .../info-drawer/src/tests/general.spec.ts | 86 +++++++ .../src/tests/library-properties.spec.ts | 233 ++++++++++++++++++ .../src/api/api-client-factory.ts | 2 + .../aca-playwright-shared/src/api/index.ts | 1 + .../src/api/queries-api.ts | 72 ++++++ .../src/api/sites-api.ts | 9 + 6 files changed, 403 insertions(+) create mode 100644 e2e/playwright/info-drawer/src/tests/general.spec.ts create mode 100644 e2e/playwright/info-drawer/src/tests/library-properties.spec.ts create mode 100755 projects/aca-playwright-shared/src/api/queries-api.ts diff --git a/e2e/playwright/info-drawer/src/tests/general.spec.ts b/e2e/playwright/info-drawer/src/tests/general.spec.ts new file mode 100644 index 0000000000..aad7e4867d --- /dev/null +++ b/e2e/playwright/info-drawer/src/tests/general.spec.ts @@ -0,0 +1,86 @@ +/*! + * 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, Utils, test, TrashcanApi, NodesApi } from '@alfresco/playwright-shared'; + +test.describe('Info Drawer - General', () => { + let nodesApi: NodesApi; + let trashcanApi: TrashcanApi; + + const username = `user1-${Utils.random()}`; + const parentFolder = `parent-${Utils.random()}`; + const file1 = `file1-${Utils.random()}.txt`; + const folder1 = `folder1-${Utils.random()}`; + let parentId: string; + + test.beforeAll(async () => { + try { + const apiClientFactory = new ApiClientFactory(); + await apiClientFactory.setUpAcaBackend('admin'); + await apiClientFactory.createUser({ username }); + nodesApi = await NodesApi.initialize(username, username); + trashcanApi = await TrashcanApi.initialize(username, username); + + parentId = (await nodesApi.createFolder(parentFolder)).entry.id; + await nodesApi.createFile(file1, parentId); + await nodesApi.createFolder(folder1, parentId); + } catch (error) { + console.error(`beforeAll failed: ${error}`); + } + }); + + test.beforeEach(async ({ loginPage }) => { + try { + await loginPage.loginUser({ username: username, password: username }, { withNavigation: true, waitForLoading: true }); + } catch (error) { + console.error(`beforeEach failed: ${error}`); + } + }); + + test.afterAll(async () => { + try { + await nodesApi.deleteCurrentUserNodes(); + await trashcanApi.emptyTrashcan(); + } catch (error) { + console.error(`afterAll failed: ${error}`); + } + }); + + test.afterEach(async ({ personalFiles }) => { + if (await personalFiles.infoDrawer.infoDrawerPanel.isVisible()) { + await personalFiles.clickInfoDrawerButton(); + } + }); + + test('[C268999] Info drawer closes on page refresh', async ({ personalFiles }) => { + await personalFiles.dataTable.selectItem(file1); + await personalFiles.clickInfoDrawerButton(); + expect(await personalFiles.infoDrawer.infoDrawerPanel.isVisible()).toBe(true); + + await personalFiles.reload(); + await personalFiles.waitForPageLoad(); + + expect(personalFiles.infoDrawer.infoDrawerPanel.isVisible()).toBe(false); + }); +}); diff --git a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts new file mode 100644 index 0000000000..54ed7f28cb --- /dev/null +++ b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts @@ -0,0 +1,233 @@ +/*! + * 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 { SITE_VISIBILITY, SITE_ROLES } from '@alfresco/aca-testing-shared'; +import { ApiClientFactory, Utils, test, SitesApi, QueriesApi } from '@alfresco/playwright-shared'; + +describe('Library properties', () => { + let sitesApi: SitesApi; + let queriesApi: QueriesApi; + const username = `user1-${Utils.random()}`; + const user2 = `user2-${Utils.random()}`; + const user3 = `user3-${Utils.random()}`; + + const site = { + name: `site1-${Utils.random()}`, + id: `site-id-${Utils.random()}`, + visibility: SITE_VISIBILITY.MODERATED, + description: 'my site description' + }; + + const siteForUpdate = { + name: `site2-${Utils.random()}`, + id: `site-id-${Utils.random()}`, + visibility: SITE_VISIBILITY.MODERATED, + description: 'my initial description' + }; + + const siteUpdated = { + name: `site-for-rename-${Utils.random()}`, + visibility: SITE_VISIBILITY.PRIVATE, + description: 'new description' + }; + + const siteDup = `site3-${Utils.random()}`; + + test.beforeAll(async ({ loginPage }) => { + try { + const apiClientFactory = new ApiClientFactory(); + await apiClientFactory.setUpAcaBackend('admin'); + await apiClientFactory.createUser({ username }); + await apiClientFactory.createUser({ username: user2 }); + await apiClientFactory.createUser({ username: user3 }); + + sitesApi = await SitesApi.initialize(username, username); + await sitesApi.createSite(site.name, site.visibility, site.description, site.id); + await sitesApi.createSite(siteForUpdate.name, siteForUpdate.visibility, siteForUpdate.description, siteForUpdate.id); + await sitesApi.createSite(siteDup); + await sitesApi.addSiteMember(site.id, user2, SITE_ROLES.SITE_COLLABORATOR.ROLE); + await sitesApi.addSiteMember(site.id, user3, SITE_ROLES.SITE_MANAGER.ROLE); + + await loginPage.loginUser({ username: username, password: username }, { withNavigation: true, waitForLoading: true }); + } catch (error) { + console.error(`beforeEach failed: ${error}`); + } + }); + + test.afterAll(async () => { + await sitesApi.deleteSites([site.id, siteForUpdate.id, siteDup]); + }); + + test.beforeEach(async ({ myLibrariesPage }) => { + await myLibrariesPage.navigate(); + }); + + test.afterEach(async ({ myLibrariesPage }) => { + if (await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()) { + await myLibrariesPage.acaHeader.viewDetails.click(); + } + }); + test('[C289336] Info drawer opens for a library', async ({ myLibrariesPage }) => { + await myLibrariesPage.dataTable.selectItem(site.name); + await myLibrariesPage.acaHeader.viewDetails.click(); + + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); + expect(await myLibrariesPage.libraryDetails.headerTitle).toEqual(site.name); + expect(await myLibrariesPage.libraryDetails.propertiesTab.isVisible()).toBe(true, 'Properties tab is not visible'); + expect(await myLibrariesPage.libraryDetails.getNameField('Name').isVisible).toBe(true, 'Name field is not visible'); + expect(await myLibrariesPage.libraryDetails.getIdField('Library ID').isVisible).toBe(true, 'Library ID field is not visible'); + expect(await myLibrariesPage.libraryDetails.getVisibilityField('Visibility').isVisible).toBe(true, 'Visibility field is not visible'); + expect(await myLibrariesPage.libraryDetails.getDescriptionField.isVisible).toBe(true, 'Description field is not visible'); + expect(await myLibrariesPage.libraryDetails.getNameField('Name').textContent()).toEqual(site.name); + expect(await myLibrariesPage.libraryDetails.getIdField('Library ID').textContent()).toEqual(site.id); + expect(await myLibrariesPage.libraryDetails.getVisibilityField('Visibility').textContent()).toEqual(site.visibility); + expect(await myLibrariesPage.libraryDetails.getDescriptionField.textContent()).toEqual(site.description); + expect(await myLibrariesPage.libraryDetails.editButton.isVisible()).toBe(true, 'Edit button is not visible'); + }); + + test('[C289338] Editable properties', async ({ myLibrariesPage }) => { + await myLibrariesPage.dataTable.selectItem(site.name); + await myLibrariesPage.acaHeader.viewDetails.click(); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); + expect(await myLibrariesPage.libraryDetails.editButton.isVisible()).toBe(true, 'Edit button is not visible'); + + await myLibrariesPage.libraryDetails.editButton.click(); + expect(await myLibrariesPage.libraryDetails.getNameField('Name').isEditable).toBe(true, 'Name field is not editable'); + expect(await myLibrariesPage.libraryDetails.getIdField('Library ID').isEditable).toBe(false, 'Library ID field is not disabled'); + expect(await myLibrariesPage.libraryDetails.getVisibilityField('Visibility').isEditable).toBe(true, 'Visibility field is not editable'); + expect(await myLibrariesPage.libraryDetails.getDescriptionField.isEditable).toBe(true, 'Description field is not editable'); + expect(await myLibrariesPage.libraryDetails.cancelButton.isVisible()).toBe(true, 'Cancel button is not visible'); + expect(await myLibrariesPage.libraryDetails.updateButton.isVisible()).toBe(true, 'Update button is not visible'); + expect(await myLibrariesPage.libraryDetails.cancelButton.isEnabled()).toBe(true, 'Cancel button is not enabled'); + expect(await myLibrariesPage.libraryDetails.updateButton.isEnabled()).toBe(false, 'Edit button is not disabled'); + }); + + test('[C289339] Edit site details', async ({ myLibrariesPage }) => { + await myLibrariesPage.dataTable.selectItem(site.name); + await myLibrariesPage.acaHeader.viewDetails.click(); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); + expect(await myLibrariesPage.libraryDetails.editButton.isVisible()).toBe(true, 'Edit button is not visible'); + + await myLibrariesPage.libraryDetails.editButton.click(); + await myLibrariesPage.libraryDetails.getNameField('Name').fill(siteUpdated.name); + await myLibrariesPage.libraryDetails.getVisibilityField('Visibility').selectOption(siteUpdated.visibility); + await myLibrariesPage.libraryDetails.getDescriptionField.fill(siteUpdated.description); + expect(await myLibrariesPage.libraryDetails.updateButton.isEnabled()).toBe(true, 'Update button is not enabled'); + + await myLibrariesPage.libraryDetails.updateButton.click(); + expect(await myLibrariesPage.snackBar.message).toEqual('Library properties updated'); + expect(await myLibrariesPage.dataTable.isItemPresent(siteUpdated.name)).toBe(true, 'New site name is not visible on the list'); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible).toBe(false, 'Info Drawer is still opened'); + expect((await sitesApi.getSite(siteForUpdate.id)).entry.title).toEqual(siteUpdated.name); + expect((await sitesApi.getSite(siteForUpdate.id)).entry.description).toEqual(siteUpdated.description); + expect((await sitesApi.getSite(siteForUpdate.id)).entry.visibility).toEqual(siteUpdated.visibility); + }); + + test('[C289340] Cancel editing a site', async ({ myLibrariesPage }) => { + const newName = `new-name-${Utils.random}`; + const newDesc = `new desc ${Utils.random}`; + + await myLibrariesPage.dataTable.selectItem(site.name); + await myLibrariesPage.acaHeader.viewDetails.click(); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); + expect(await myLibrariesPage.libraryDetails.editButton.isVisible()).toBe(true, 'Edit button is not visible'); + + await myLibrariesPage.libraryDetails.editButton.click(); + await myLibrariesPage.libraryDetails.getNameField('Name').fill(newName); + await myLibrariesPage.libraryDetails.getVisibilityField('Visibility').selectOption(SITE_VISIBILITY.MODERATED); + await myLibrariesPage.libraryDetails.getDescriptionField.fill(newDesc); + expect(await myLibrariesPage.libraryDetails.updateButton.isEnabled()).toBe(true, 'Update button is not enabled'); + + await myLibrariesPage.libraryDetails.cancelButton.click(); + expect(await myLibrariesPage.dataTable.isItemPresent(newName)).toBe(false, 'New site name is visible on the list'); + expect(await myLibrariesPage.dataTable.isItemPresent(site.name)).toBe(true, 'Original name is not visible on the list'); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible).toBe(true, 'Info Drawer is not opened'); + }); + + test('[C289341] Warning appears when editing the name of the library by entering an existing name', async ({ myLibrariesPage }) => { + queriesApi = await QueriesApi.initialize(username, username); + await queriesApi.waitForSites(site.name, { expect: 1 }); + await myLibrariesPage.dataTable.selectItem(siteDup); + await myLibrariesPage.acaHeader.viewDetails.click(); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); + expect(await myLibrariesPage.libraryDetails.editButton.isVisible()).toBe(true, 'Edit button is not visible'); + + await myLibrariesPage.libraryDetails.editButton.click(); + await myLibrariesPage.libraryDetails.getNameField('Name').fill(site.name); + expect(await myLibrariesPage.libraryDetails.hintMessage.isVisible()).toBe(true, 'Hint message is not visible'); + expect(await myLibrariesPage.libraryDetails.hintMessage).toEqual('Library name already in use'); + }); + + test('[C289342] Site name too long', async ({ myLibrariesPage }) => { + await myLibrariesPage.dataTable.selectItem(site.name); + await myLibrariesPage.acaHeader.viewDetails.click(); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); + + await myLibrariesPage.libraryDetails.editButton.click(); + await myLibrariesPage.libraryDetails.getNameField('Name').fill(Utils.string257Long); + expect(await myLibrariesPage.libraryDetails.hintMessage.isVisible()).toBe(true, 'Hint message is not visible'); + expect(await myLibrariesPage.libraryDetails.hintMessage).toEqual('Use 256 characters or less for title'); + expect(await myLibrariesPage.libraryDetails.updateButton.isEnabled()).toBe(false, 'Update button is not disabled'); + }); + + test('[C289343] Site description too long', async ({ myLibrariesPage }) => { + await myLibrariesPage.dataTable.selectItem(site.name); + await myLibrariesPage.acaHeader.viewDetails.click(); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); + + await myLibrariesPage.libraryDetails.editButton.click(); + await myLibrariesPage.libraryDetails.getDescriptionField.fill(Utils.string513Long); + expect(await myLibrariesPage.libraryDetails.hintMessage.isVisible()).toBe(true, 'Hint message is not visible'); + expect(await myLibrariesPage.libraryDetails.hintMessage).toEqual('Use 512 characters or less for description'); + expect(await myLibrariesPage.libraryDetails.updateButton.isEnabled()).toBe(false, 'Update button is not disabled'); + }); + + test.describe('Non manager', () => { + test.beforeEach(async ({ myLibrariesPage }) => { + await myLibrariesPage.navigate(); + }); + + test.afterAll(async ({ loginPage }) => { + await loginPage.loginUser({ username: username, password: username }, { withNavigation: true, waitForLoading: true }); + }); + + test('[C289337] Info drawer button is not displayed when user is not the library manager', async ({ loginPage, myLibrariesPage }) => { + await loginPage.loginUser({ username: user2, password: user2 }, { withNavigation: true, waitForLoading: true }); + await myLibrariesPage.dataTable.selectItem(site.name); + expect(await myLibrariesPage.acaHeader.viewDetails.isVisible).toBe(false, 'View Details button is visible'); + }); + + test('[C289344] Error notification', async ({ loginPage, myLibrariesPage }) => { + await loginPage.loginUser({ username: user3, password: user3 }, { withNavigation: true, waitForLoading: true }); + await myLibrariesPage.dataTable.selectItem(site.name); + await myLibrariesPage.acaHeader.viewDetails.click(); + await myLibrariesPage.libraryDetails.editButton.click(); + await sitesApi.updateSiteMember(site.id, user3, SITE_ROLES.SITE_CONSUMER.ROLE); + await myLibrariesPage.libraryDetails.getDescriptionField.fill('new description'); + await myLibrariesPage.libraryDetails.updateButton.click(); + + expect(await myLibrariesPage.snackBar.message).toEqual('There was an error updating library properties'); + }); + }); +}); diff --git a/projects/aca-playwright-shared/src/api/api-client-factory.ts b/projects/aca-playwright-shared/src/api/api-client-factory.ts index 1eec3b96fe..585966fce7 100644 --- a/projects/aca-playwright-shared/src/api/api-client-factory.ts +++ b/projects/aca-playwright-shared/src/api/api-client-factory.ts @@ -85,6 +85,7 @@ export class ApiClientFactory { public favorites: FavoritesApi; public trashCan: TrashcanApi; public commentsApi: CommentsApi; + public queriesApi: QueriesApi; constructor() { this.alfrescoApi = new AlfrescoApi(config); @@ -108,6 +109,7 @@ export class ApiClientFactory { this.favorites = new FavoritesApi(this.alfrescoApi); this.trashCan = new TrashcanApi(this.alfrescoApi); this.commentsApi = new CommentsApi(this.alfrescoApi); + this.queriesApi = new QueriesApi(this.alfrescoApi); return this; } diff --git a/projects/aca-playwright-shared/src/api/index.ts b/projects/aca-playwright-shared/src/api/index.ts index a855779580..0cdb747b0c 100644 --- a/projects/aca-playwright-shared/src/api/index.ts +++ b/projects/aca-playwright-shared/src/api/index.ts @@ -33,3 +33,4 @@ export * from './sites-api'; export * from './node-content-tree'; export * from './search-api'; export * from './trashcan-api'; +export * from './queries-api'; diff --git a/projects/aca-playwright-shared/src/api/queries-api.ts b/projects/aca-playwright-shared/src/api/queries-api.ts new file mode 100755 index 0000000000..b583ef8277 --- /dev/null +++ b/projects/aca-playwright-shared/src/api/queries-api.ts @@ -0,0 +1,72 @@ +/*! + * 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 + * along with Alfresco. If not, see . + */ + +import { Utils } from '../utils'; +import { ApiClientFactory } from './api-client-factory'; + +export class QueriesApi { + private apiService: ApiClientFactory; + + constructor() { + this.apiService = new ApiClientFactory(); + } + static async initialize(userName: string, password?: string): Promise { + const classObj = new QueriesApi(); + await classObj.apiService.setUpAcaBackend(userName, password); + return classObj; + } + + private async findSitesTotalItems(searchTerm: string): Promise { + try { + const opts = { + term: searchTerm, + fields: ['title'] + }; + + const sites = await this.apiService.queries.findSites(searchTerm, opts); + return sites.list.pagination.totalItems; + } catch (error) { + console.error(`QueriesApi findSitesTotalItems : catch :`, error); + return null; + } + } + + async waitForSites(searchTerm: string, data: { expect: number }) { + try { + const sites = async () => { + const totalItems = await this.findSitesTotalItems(searchTerm); + if (totalItems !== data.expect) { + return Promise.reject(totalItems); + } else { + return Promise.resolve(totalItems); + } + }; + + return await Utils.retryCall(sites); + } catch (error) { + console.error(`QueriesApi waitForSites : catch : `); + console.error(`\tExpected: ${data.expect} items, but found ${error}`); + } + } +} diff --git a/projects/aca-playwright-shared/src/api/sites-api.ts b/projects/aca-playwright-shared/src/api/sites-api.ts index a2e27f2b3c..4591ce5e72 100755 --- a/projects/aca-playwright-shared/src/api/sites-api.ts +++ b/projects/aca-playwright-shared/src/api/sites-api.ts @@ -158,4 +158,13 @@ export class SitesApi { console.error(`SitesApi deleteSiteMember : catch : `, error); } } + + async getSite(siteId: string) { + try { + return await this.apiService.sites.getSite(siteId); + } catch (error) { + console.error(`SitesApi getSite : catch : `, error); + return null; + } + } } From ec4b0e91da99859634b56eae4dfe20df7df0042a Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Tue, 6 Feb 2024 10:44:26 +0100 Subject: [PATCH 04/22] Protractor to Playwright info-drawer tests --- e2e/playwright/info-drawer/src/tests/general.spec.ts | 2 +- .../info-drawer/src/tests/library-properties.spec.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e/playwright/info-drawer/src/tests/general.spec.ts b/e2e/playwright/info-drawer/src/tests/general.spec.ts index aad7e4867d..7156441d41 100644 --- a/e2e/playwright/info-drawer/src/tests/general.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/general.spec.ts @@ -52,7 +52,7 @@ test.describe('Info Drawer - General', () => { test.beforeEach(async ({ loginPage }) => { try { - await loginPage.loginUser({ username: username, password: username }, { withNavigation: true, waitForLoading: true }); + await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); } catch (error) { console.error(`beforeEach failed: ${error}`); } diff --git a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts index 54ed7f28cb..90d6228c8a 100644 --- a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts @@ -25,7 +25,7 @@ import { SITE_VISIBILITY, SITE_ROLES } from '@alfresco/aca-testing-shared'; import { ApiClientFactory, Utils, test, SitesApi, QueriesApi } from '@alfresco/playwright-shared'; -describe('Library properties', () => { +test.describe('Library properties', () => { let sitesApi: SitesApi; let queriesApi: QueriesApi; const username = `user1-${Utils.random()}`; @@ -69,7 +69,7 @@ describe('Library properties', () => { await sitesApi.addSiteMember(site.id, user2, SITE_ROLES.SITE_COLLABORATOR.ROLE); await sitesApi.addSiteMember(site.id, user3, SITE_ROLES.SITE_MANAGER.ROLE); - await loginPage.loginUser({ username: username, password: username }, { withNavigation: true, waitForLoading: true }); + await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); } catch (error) { console.error(`beforeEach failed: ${error}`); } @@ -209,17 +209,17 @@ describe('Library properties', () => { }); test.afterAll(async ({ loginPage }) => { - await loginPage.loginUser({ username: username, password: username }, { withNavigation: true, waitForLoading: true }); + await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); }); test('[C289337] Info drawer button is not displayed when user is not the library manager', async ({ loginPage, myLibrariesPage }) => { - await loginPage.loginUser({ username: user2, password: user2 }, { withNavigation: true, waitForLoading: true }); + await loginPage.loginUser({ username, password: user2 }, { withNavigation: true, waitForLoading: true }); await myLibrariesPage.dataTable.selectItem(site.name); expect(await myLibrariesPage.acaHeader.viewDetails.isVisible).toBe(false, 'View Details button is visible'); }); test('[C289344] Error notification', async ({ loginPage, myLibrariesPage }) => { - await loginPage.loginUser({ username: user3, password: user3 }, { withNavigation: true, waitForLoading: true }); + await loginPage.loginUser({ username, password: user3 }, { withNavigation: true, waitForLoading: true }); await myLibrariesPage.dataTable.selectItem(site.name); await myLibrariesPage.acaHeader.viewDetails.click(); await myLibrariesPage.libraryDetails.editButton.click(); From d2f615c4fd51e3012f1ee93671bea74996f91e17 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Tue, 6 Feb 2024 14:41:43 +0100 Subject: [PATCH 05/22] Fixed general tests --- .../info-drawer/src/tests/general.spec.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/e2e/playwright/info-drawer/src/tests/general.spec.ts b/e2e/playwright/info-drawer/src/tests/general.spec.ts index 7156441d41..8f1ba64830 100644 --- a/e2e/playwright/info-drawer/src/tests/general.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/general.spec.ts @@ -22,11 +22,13 @@ * from Hyland Software. If not, see . */ -import { ApiClientFactory, Utils, test, TrashcanApi, NodesApi } from '@alfresco/playwright-shared'; +import { expect } from '@playwright/test'; +import { ApiClientFactory, Utils, test, TrashcanApi, NodesApi, FileActionsApi } from '@alfresco/playwright-shared'; test.describe('Info Drawer - General', () => { let nodesApi: NodesApi; let trashcanApi: TrashcanApi; + let fileActionsApi: FileActionsApi; const username = `user1-${Utils.random()}`; const parentFolder = `parent-${Utils.random()}`; @@ -41,10 +43,7 @@ test.describe('Info Drawer - General', () => { await apiClientFactory.createUser({ username }); nodesApi = await NodesApi.initialize(username, username); trashcanApi = await TrashcanApi.initialize(username, username); - - parentId = (await nodesApi.createFolder(parentFolder)).entry.id; - await nodesApi.createFile(file1, parentId); - await nodesApi.createFolder(folder1, parentId); + fileActionsApi = await FileActionsApi.initialize(username, username); } catch (error) { console.error(`beforeAll failed: ${error}`); } @@ -74,13 +73,18 @@ test.describe('Info Drawer - General', () => { }); test('[C268999] Info drawer closes on page refresh', async ({ personalFiles }) => { + parentId = (await nodesApi.createFolder(parentFolder)).entry.id; + await nodesApi.createFile(file1, parentId); + await nodesApi.createFolder(folder1, parentId); + await fileActionsApi.waitForNodes(file1, { expect: 1 }); + await personalFiles.navigate(); + await expect(personalFiles.dataTable.getRowByName(parentFolder)).toBeVisible(); + await personalFiles.dataTable.performClickFolderOrFileToOpen(parentFolder); await personalFiles.dataTable.selectItem(file1); await personalFiles.clickInfoDrawerButton(); - expect(await personalFiles.infoDrawer.infoDrawerPanel.isVisible()).toBe(true); - - await personalFiles.reload(); - await personalFiles.waitForPageLoad(); + await expect(personalFiles.infoDrawer.infoDrawerPanel).toBeVisible(); - expect(personalFiles.infoDrawer.infoDrawerPanel.isVisible()).toBe(false); + await personalFiles.reload({ waitUntil: 'load' }); + expect(personalFiles.infoDrawer.infoDrawerPanel).not.toBeVisible(); }); }); From d2e8957dbf0ca234bec058b441e6f471b937a213 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Thu, 8 Feb 2024 11:35:29 +0100 Subject: [PATCH 06/22] Fixes for library-properties tests --- .../src/tests/library-properties.spec.ts | 111 ++++++++++-------- 1 file changed, 59 insertions(+), 52 deletions(-) diff --git a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts index 90d6228c8a..a8a7d279c0 100644 --- a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts @@ -23,6 +23,7 @@ */ import { SITE_VISIBILITY, SITE_ROLES } from '@alfresco/aca-testing-shared'; +import { expect } from '@playwright/test'; import { ApiClientFactory, Utils, test, SitesApi, QueriesApi } from '@alfresco/playwright-shared'; test.describe('Library properties', () => { @@ -54,11 +55,11 @@ test.describe('Library properties', () => { const siteDup = `site3-${Utils.random()}`; - test.beforeAll(async ({ loginPage }) => { + test.beforeAll(async () => { try { const apiClientFactory = new ApiClientFactory(); await apiClientFactory.setUpAcaBackend('admin'); - await apiClientFactory.createUser({ username }); + await apiClientFactory.createUser({ username: username }); await apiClientFactory.createUser({ username: user2 }); await apiClientFactory.createUser({ username: user3 }); @@ -68,10 +69,8 @@ test.describe('Library properties', () => { await sitesApi.createSite(siteDup); await sitesApi.addSiteMember(site.id, user2, SITE_ROLES.SITE_COLLABORATOR.ROLE); await sitesApi.addSiteMember(site.id, user3, SITE_ROLES.SITE_MANAGER.ROLE); - - await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); } catch (error) { - console.error(`beforeEach failed: ${error}`); + console.error(`beforeAll failed: ${error}`); } }); @@ -79,8 +78,13 @@ test.describe('Library properties', () => { await sitesApi.deleteSites([site.id, siteForUpdate.id, siteDup]); }); - test.beforeEach(async ({ myLibrariesPage }) => { - await myLibrariesPage.navigate(); + test.beforeEach(async ({ myLibrariesPage, loginPage }) => { + try { + await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); + await myLibrariesPage.navigate(); + } catch (error) { + console.error(` beforeEach failed: ${error}`); + } }); test.afterEach(async ({ myLibrariesPage }) => { @@ -88,57 +92,60 @@ test.describe('Library properties', () => { await myLibrariesPage.acaHeader.viewDetails.click(); } }); + test('[C289336] Info drawer opens for a library', async ({ myLibrariesPage }) => { - await myLibrariesPage.dataTable.selectItem(site.name); + await expect(myLibrariesPage.dataTable.getRowByName(site.name)).toBeVisible(); + await myLibrariesPage.dataTable.getRowByName(site.name).click(); await myLibrariesPage.acaHeader.viewDetails.click(); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); - expect(await myLibrariesPage.libraryDetails.headerTitle).toEqual(site.name); - expect(await myLibrariesPage.libraryDetails.propertiesTab.isVisible()).toBe(true, 'Properties tab is not visible'); - expect(await myLibrariesPage.libraryDetails.getNameField('Name').isVisible).toBe(true, 'Name field is not visible'); - expect(await myLibrariesPage.libraryDetails.getIdField('Library ID').isVisible).toBe(true, 'Library ID field is not visible'); - expect(await myLibrariesPage.libraryDetails.getVisibilityField('Visibility').isVisible).toBe(true, 'Visibility field is not visible'); - expect(await myLibrariesPage.libraryDetails.getDescriptionField.isVisible).toBe(true, 'Description field is not visible'); - expect(await myLibrariesPage.libraryDetails.getNameField('Name').textContent()).toEqual(site.name); - expect(await myLibrariesPage.libraryDetails.getIdField('Library ID').textContent()).toEqual(site.id); - expect(await myLibrariesPage.libraryDetails.getVisibilityField('Visibility').textContent()).toEqual(site.visibility); + await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); + expect(await myLibrariesPage.libraryDetails.headerTitle.textContent()).toEqual(site.name); + await expect(myLibrariesPage.libraryDetails.propertiesTab).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.getNameField('Name')).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.getIdField('Library ID')).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.getVisibilityField('Visibility')).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.getDescriptionField).toBeVisible(); + + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.locator('label', { hasText: 'Name' }).inputValue()).toEqual(site.name); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.locator('label', { hasText: 'Library ID' }).inputValue()).toEqual(site.id); + // expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.locator('label', {hasText: 'Visibility'}).locator('../../..').inputValue()).toEqual(site.visibility); expect(await myLibrariesPage.libraryDetails.getDescriptionField.textContent()).toEqual(site.description); - expect(await myLibrariesPage.libraryDetails.editButton.isVisible()).toBe(true, 'Edit button is not visible'); + await expect(myLibrariesPage.libraryDetails.editButton).toBeVisible(); }); test('[C289338] Editable properties', async ({ myLibrariesPage }) => { await myLibrariesPage.dataTable.selectItem(site.name); await myLibrariesPage.acaHeader.viewDetails.click(); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); - expect(await myLibrariesPage.libraryDetails.editButton.isVisible()).toBe(true, 'Edit button is not visible'); + await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.editButton).toBeVisible(); await myLibrariesPage.libraryDetails.editButton.click(); - expect(await myLibrariesPage.libraryDetails.getNameField('Name').isEditable).toBe(true, 'Name field is not editable'); - expect(await myLibrariesPage.libraryDetails.getIdField('Library ID').isEditable).toBe(false, 'Library ID field is not disabled'); - expect(await myLibrariesPage.libraryDetails.getVisibilityField('Visibility').isEditable).toBe(true, 'Visibility field is not editable'); - expect(await myLibrariesPage.libraryDetails.getDescriptionField.isEditable).toBe(true, 'Description field is not editable'); - expect(await myLibrariesPage.libraryDetails.cancelButton.isVisible()).toBe(true, 'Cancel button is not visible'); - expect(await myLibrariesPage.libraryDetails.updateButton.isVisible()).toBe(true, 'Update button is not visible'); - expect(await myLibrariesPage.libraryDetails.cancelButton.isEnabled()).toBe(true, 'Cancel button is not enabled'); - expect(await myLibrariesPage.libraryDetails.updateButton.isEnabled()).toBe(false, 'Edit button is not disabled'); + await expect(myLibrariesPage.libraryDetails.getNameField('Name')).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.getIdField('Library ID')).not.toBeEditable(); + await expect(myLibrariesPage.libraryDetails.getVisibilityField('Visibility')).toBeEditable(); + await expect(myLibrariesPage.libraryDetails.getDescriptionField).toBeEditable(); + await expect(myLibrariesPage.libraryDetails.cancelButton).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.updateButton).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.cancelButton).toBeEnabled(); + await expect(myLibrariesPage.libraryDetails.updateButton).not.toBeEnabled(); }); test('[C289339] Edit site details', async ({ myLibrariesPage }) => { await myLibrariesPage.dataTable.selectItem(site.name); await myLibrariesPage.acaHeader.viewDetails.click(); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); - expect(await myLibrariesPage.libraryDetails.editButton.isVisible()).toBe(true, 'Edit button is not visible'); + await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.editButton).toBeVisible(); await myLibrariesPage.libraryDetails.editButton.click(); await myLibrariesPage.libraryDetails.getNameField('Name').fill(siteUpdated.name); await myLibrariesPage.libraryDetails.getVisibilityField('Visibility').selectOption(siteUpdated.visibility); await myLibrariesPage.libraryDetails.getDescriptionField.fill(siteUpdated.description); - expect(await myLibrariesPage.libraryDetails.updateButton.isEnabled()).toBe(true, 'Update button is not enabled'); + await expect(myLibrariesPage.libraryDetails.updateButton).toBeEnabled(); await myLibrariesPage.libraryDetails.updateButton.click(); - expect(await myLibrariesPage.snackBar.message).toEqual('Library properties updated'); - expect(await myLibrariesPage.dataTable.isItemPresent(siteUpdated.name)).toBe(true, 'New site name is not visible on the list'); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible).toBe(false, 'Info Drawer is still opened'); + await expect(myLibrariesPage.snackBar.message).toEqual('Library properties updated'); + await expect(myLibrariesPage.dataTable.isItemPresent(siteUpdated.name)).toBe(true); + await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); expect((await sitesApi.getSite(siteForUpdate.id)).entry.title).toEqual(siteUpdated.name); expect((await sitesApi.getSite(siteForUpdate.id)).entry.description).toEqual(siteUpdated.description); expect((await sitesApi.getSite(siteForUpdate.id)).entry.visibility).toEqual(siteUpdated.visibility); @@ -150,19 +157,19 @@ test.describe('Library properties', () => { await myLibrariesPage.dataTable.selectItem(site.name); await myLibrariesPage.acaHeader.viewDetails.click(); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); - expect(await myLibrariesPage.libraryDetails.editButton.isVisible()).toBe(true, 'Edit button is not visible'); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); + expect(await myLibrariesPage.libraryDetails.editButton).toBeVisible(); await myLibrariesPage.libraryDetails.editButton.click(); await myLibrariesPage.libraryDetails.getNameField('Name').fill(newName); await myLibrariesPage.libraryDetails.getVisibilityField('Visibility').selectOption(SITE_VISIBILITY.MODERATED); await myLibrariesPage.libraryDetails.getDescriptionField.fill(newDesc); - expect(await myLibrariesPage.libraryDetails.updateButton.isEnabled()).toBe(true, 'Update button is not enabled'); + expect(await myLibrariesPage.libraryDetails.updateButton).toBeEnabled(); await myLibrariesPage.libraryDetails.cancelButton.click(); - expect(await myLibrariesPage.dataTable.isItemPresent(newName)).toBe(false, 'New site name is visible on the list'); - expect(await myLibrariesPage.dataTable.isItemPresent(site.name)).toBe(true, 'Original name is not visible on the list'); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible).toBe(true, 'Info Drawer is not opened'); + expect(await myLibrariesPage.dataTable.isItemPresent(newName)).toBe(false); + expect(await myLibrariesPage.dataTable.isItemPresent(site.name)).toBe(true); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); }); test('[C289341] Warning appears when editing the name of the library by entering an existing name', async ({ myLibrariesPage }) => { @@ -170,37 +177,37 @@ test.describe('Library properties', () => { await queriesApi.waitForSites(site.name, { expect: 1 }); await myLibrariesPage.dataTable.selectItem(siteDup); await myLibrariesPage.acaHeader.viewDetails.click(); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); - expect(await myLibrariesPage.libraryDetails.editButton.isVisible()).toBe(true, 'Edit button is not visible'); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); + expect(await myLibrariesPage.libraryDetails.editButton).toBeVisible(); await myLibrariesPage.libraryDetails.editButton.click(); await myLibrariesPage.libraryDetails.getNameField('Name').fill(site.name); - expect(await myLibrariesPage.libraryDetails.hintMessage.isVisible()).toBe(true, 'Hint message is not visible'); + expect(await myLibrariesPage.libraryDetails.hintMessage).toBeVisible(); expect(await myLibrariesPage.libraryDetails.hintMessage).toEqual('Library name already in use'); }); test('[C289342] Site name too long', async ({ myLibrariesPage }) => { await myLibrariesPage.dataTable.selectItem(site.name); await myLibrariesPage.acaHeader.viewDetails.click(); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); await myLibrariesPage.libraryDetails.editButton.click(); await myLibrariesPage.libraryDetails.getNameField('Name').fill(Utils.string257Long); - expect(await myLibrariesPage.libraryDetails.hintMessage.isVisible()).toBe(true, 'Hint message is not visible'); + expect(await myLibrariesPage.libraryDetails.hintMessage).toBeVisible(); expect(await myLibrariesPage.libraryDetails.hintMessage).toEqual('Use 256 characters or less for title'); - expect(await myLibrariesPage.libraryDetails.updateButton.isEnabled()).toBe(false, 'Update button is not disabled'); + expect(await myLibrariesPage.libraryDetails.updateButton).not.toBeEnabled(); }); test('[C289343] Site description too long', async ({ myLibrariesPage }) => { await myLibrariesPage.dataTable.selectItem(site.name); await myLibrariesPage.acaHeader.viewDetails.click(); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()).toBe(true, 'infoDrawerPanel is not visible'); + expect(await myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); await myLibrariesPage.libraryDetails.editButton.click(); await myLibrariesPage.libraryDetails.getDescriptionField.fill(Utils.string513Long); - expect(await myLibrariesPage.libraryDetails.hintMessage.isVisible()).toBe(true, 'Hint message is not visible'); + expect(await myLibrariesPage.libraryDetails.hintMessage).toBeVisible(); expect(await myLibrariesPage.libraryDetails.hintMessage).toEqual('Use 512 characters or less for description'); - expect(await myLibrariesPage.libraryDetails.updateButton.isEnabled()).toBe(false, 'Update button is not disabled'); + expect(await myLibrariesPage.libraryDetails.updateButton).not.toBeEnabled(); }); test.describe('Non manager', () => { @@ -215,7 +222,7 @@ test.describe('Library properties', () => { test('[C289337] Info drawer button is not displayed when user is not the library manager', async ({ loginPage, myLibrariesPage }) => { await loginPage.loginUser({ username, password: user2 }, { withNavigation: true, waitForLoading: true }); await myLibrariesPage.dataTable.selectItem(site.name); - expect(await myLibrariesPage.acaHeader.viewDetails.isVisible).toBe(false, 'View Details button is visible'); + expect(await myLibrariesPage.acaHeader.viewDetails).not.toBeVisible(); }); test('[C289344] Error notification', async ({ loginPage, myLibrariesPage }) => { @@ -227,7 +234,7 @@ test.describe('Library properties', () => { await myLibrariesPage.libraryDetails.getDescriptionField.fill('new description'); await myLibrariesPage.libraryDetails.updateButton.click(); - expect(await myLibrariesPage.snackBar.message).toEqual('There was an error updating library properties'); + await expect(myLibrariesPage.snackBar.message).toEqual('There was an error updating library properties'); }); }); }); From f9554a83996c60dba5d44fd78c7d50a4d30df01f Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Fri, 9 Feb 2024 01:52:38 +0100 Subject: [PATCH 07/22] Fixes for library-properties tests --- .../src/tests/library-properties.spec.ts | 172 ++++++++++-------- .../components/adf-info-drawer.component.ts | 54 +++--- .../aca-playwright-shared/src/utils/config.ts | 28 +++ 3 files changed, 159 insertions(+), 95 deletions(-) diff --git a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts index a8a7d279c0..5144fe2c3d 100644 --- a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts @@ -22,9 +22,8 @@ * from Hyland Software. If not, see . */ -import { SITE_VISIBILITY, SITE_ROLES } from '@alfresco/aca-testing-shared'; import { expect } from '@playwright/test'; -import { ApiClientFactory, Utils, test, SitesApi, QueriesApi } from '@alfresco/playwright-shared'; +import { ApiClientFactory, Utils, test, SitesApi, QueriesApi, SITE_VISIBILITY, SITE_ROLES } from '@alfresco/playwright-shared'; test.describe('Library properties', () => { let sitesApi: SitesApi; @@ -101,29 +100,29 @@ test.describe('Library properties', () => { await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); expect(await myLibrariesPage.libraryDetails.headerTitle.textContent()).toEqual(site.name); await expect(myLibrariesPage.libraryDetails.propertiesTab).toBeVisible(); - await expect(myLibrariesPage.libraryDetails.getNameField('Name')).toBeVisible(); - await expect(myLibrariesPage.libraryDetails.getIdField('Library ID')).toBeVisible(); - await expect(myLibrariesPage.libraryDetails.getVisibilityField('Visibility')).toBeVisible(); - await expect(myLibrariesPage.libraryDetails.getDescriptionField).toBeVisible(); - - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.locator('label', { hasText: 'Name' }).inputValue()).toEqual(site.name); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.locator('label', { hasText: 'Library ID' }).inputValue()).toEqual(site.id); - // expect(await myLibrariesPage.libraryDetails.infoDrawerPanel.locator('label', {hasText: 'Visibility'}).locator('../../..').inputValue()).toEqual(site.visibility); - expect(await myLibrariesPage.libraryDetails.getDescriptionField.textContent()).toEqual(site.description); + await expect(myLibrariesPage.libraryDetails.nameField).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.idField).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.visibilityField).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.descriptionField).toBeVisible(); + + expect(await myLibrariesPage.libraryDetails.nameField.inputValue()).toEqual(site.name); + expect(await myLibrariesPage.libraryDetails.idField.inputValue()).toEqual(site.id); + expect((await myLibrariesPage.libraryDetails.visibilityField.textContent()).toUpperCase()).toEqual(site.visibility); + expect(await myLibrariesPage.libraryDetails.descriptionField.inputValue()).toEqual(site.description); await expect(myLibrariesPage.libraryDetails.editButton).toBeVisible(); }); test('[C289338] Editable properties', async ({ myLibrariesPage }) => { - await myLibrariesPage.dataTable.selectItem(site.name); + await myLibrariesPage.dataTable.getRowByName(site.name).click(); await myLibrariesPage.acaHeader.viewDetails.click(); await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); await expect(myLibrariesPage.libraryDetails.editButton).toBeVisible(); await myLibrariesPage.libraryDetails.editButton.click(); - await expect(myLibrariesPage.libraryDetails.getNameField('Name')).toBeVisible(); - await expect(myLibrariesPage.libraryDetails.getIdField('Library ID')).not.toBeEditable(); - await expect(myLibrariesPage.libraryDetails.getVisibilityField('Visibility')).toBeEditable(); - await expect(myLibrariesPage.libraryDetails.getDescriptionField).toBeEditable(); + await expect(myLibrariesPage.libraryDetails.nameField).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.idField).not.toBeEditable(); + await expect(myLibrariesPage.libraryDetails.visibilityField).toBeEditable(); + await expect(myLibrariesPage.libraryDetails.descriptionField).toBeEditable(); await expect(myLibrariesPage.libraryDetails.cancelButton).toBeVisible(); await expect(myLibrariesPage.libraryDetails.updateButton).toBeVisible(); await expect(myLibrariesPage.libraryDetails.cancelButton).toBeEnabled(); @@ -131,21 +130,22 @@ test.describe('Library properties', () => { }); test('[C289339] Edit site details', async ({ myLibrariesPage }) => { - await myLibrariesPage.dataTable.selectItem(site.name); + await myLibrariesPage.dataTable.getRowByName(siteForUpdate.name).click(); await myLibrariesPage.acaHeader.viewDetails.click(); await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); await expect(myLibrariesPage.libraryDetails.editButton).toBeVisible(); await myLibrariesPage.libraryDetails.editButton.click(); - await myLibrariesPage.libraryDetails.getNameField('Name').fill(siteUpdated.name); - await myLibrariesPage.libraryDetails.getVisibilityField('Visibility').selectOption(siteUpdated.visibility); - await myLibrariesPage.libraryDetails.getDescriptionField.fill(siteUpdated.description); + await myLibrariesPage.libraryDetails.nameField.fill(siteUpdated.name); + await myLibrariesPage.libraryDetails.visibilityField.click(); + await myLibrariesPage.libraryDetails.selectVisibility(siteUpdated.visibility); + await myLibrariesPage.libraryDetails.descriptionField.fill(siteUpdated.description); await expect(myLibrariesPage.libraryDetails.updateButton).toBeEnabled(); await myLibrariesPage.libraryDetails.updateButton.click(); - await expect(myLibrariesPage.snackBar.message).toEqual('Library properties updated'); - await expect(myLibrariesPage.dataTable.isItemPresent(siteUpdated.name)).toBe(true); - await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); + expect(await myLibrariesPage.snackBar.message.innerText()).toEqual('Library properties updated'); + expect(await myLibrariesPage.dataTable.isItemPresent(siteUpdated.name)).toBe(true); + await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).not.toBeVisible(); expect((await sitesApi.getSite(siteForUpdate.id)).entry.title).toEqual(siteUpdated.name); expect((await sitesApi.getSite(siteForUpdate.id)).entry.description).toEqual(siteUpdated.description); expect((await sitesApi.getSite(siteForUpdate.id)).entry.visibility).toEqual(siteUpdated.visibility); @@ -155,86 +155,116 @@ test.describe('Library properties', () => { const newName = `new-name-${Utils.random}`; const newDesc = `new desc ${Utils.random}`; - await myLibrariesPage.dataTable.selectItem(site.name); + await myLibrariesPage.dataTable.getRowByName(site.name).click(); await myLibrariesPage.acaHeader.viewDetails.click(); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); - expect(await myLibrariesPage.libraryDetails.editButton).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.editButton).toBeVisible(); await myLibrariesPage.libraryDetails.editButton.click(); - await myLibrariesPage.libraryDetails.getNameField('Name').fill(newName); - await myLibrariesPage.libraryDetails.getVisibilityField('Visibility').selectOption(SITE_VISIBILITY.MODERATED); - await myLibrariesPage.libraryDetails.getDescriptionField.fill(newDesc); - expect(await myLibrariesPage.libraryDetails.updateButton).toBeEnabled(); + await myLibrariesPage.libraryDetails.nameField.fill(newName); + await myLibrariesPage.libraryDetails.visibilityField.click(); + await myLibrariesPage.libraryDetails.selectVisibility(SITE_VISIBILITY.MODERATED); + await myLibrariesPage.libraryDetails.descriptionField.fill(newDesc); + await expect(myLibrariesPage.libraryDetails.updateButton).toBeEnabled(); await myLibrariesPage.libraryDetails.cancelButton.click(); expect(await myLibrariesPage.dataTable.isItemPresent(newName)).toBe(false); expect(await myLibrariesPage.dataTable.isItemPresent(site.name)).toBe(true); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); }); test('[C289341] Warning appears when editing the name of the library by entering an existing name', async ({ myLibrariesPage }) => { queriesApi = await QueriesApi.initialize(username, username); await queriesApi.waitForSites(site.name, { expect: 1 }); - await myLibrariesPage.dataTable.selectItem(siteDup); + await myLibrariesPage.dataTable.getRowByName(siteDup).click(); await myLibrariesPage.acaHeader.viewDetails.click(); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); - expect(await myLibrariesPage.libraryDetails.editButton).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.editButton).toBeVisible(); await myLibrariesPage.libraryDetails.editButton.click(); - await myLibrariesPage.libraryDetails.getNameField('Name').fill(site.name); - expect(await myLibrariesPage.libraryDetails.hintMessage).toBeVisible(); - expect(await myLibrariesPage.libraryDetails.hintMessage).toEqual('Library name already in use'); + await myLibrariesPage.libraryDetails.nameField.fill(site.name); + await expect(myLibrariesPage.libraryDetails.hintMessage).toBeVisible(); + expect(await myLibrariesPage.libraryDetails.hintMessage.textContent()).toEqual('Library name already in use'); }); test('[C289342] Site name too long', async ({ myLibrariesPage }) => { - await myLibrariesPage.dataTable.selectItem(site.name); + await myLibrariesPage.dataTable.getRowByName(site.name).click(); await myLibrariesPage.acaHeader.viewDetails.click(); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); await myLibrariesPage.libraryDetails.editButton.click(); - await myLibrariesPage.libraryDetails.getNameField('Name').fill(Utils.string257Long); - expect(await myLibrariesPage.libraryDetails.hintMessage).toBeVisible(); - expect(await myLibrariesPage.libraryDetails.hintMessage).toEqual('Use 256 characters or less for title'); - expect(await myLibrariesPage.libraryDetails.updateButton).not.toBeEnabled(); + await myLibrariesPage.libraryDetails.nameField.fill(Utils.string257Long); + await expect(myLibrariesPage.libraryDetails.errorMessage).toBeVisible(); + expect((await myLibrariesPage.libraryDetails.errorMessage.textContent()).trim()).toEqual('Use 256 characters or less for title'); + await expect(myLibrariesPage.libraryDetails.updateButton).not.toBeEnabled(); }); test('[C289343] Site description too long', async ({ myLibrariesPage }) => { - await myLibrariesPage.dataTable.selectItem(site.name); + await myLibrariesPage.dataTable.getRowByName(site.name).click(); await myLibrariesPage.acaHeader.viewDetails.click(); - expect(await myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); + await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); await myLibrariesPage.libraryDetails.editButton.click(); - await myLibrariesPage.libraryDetails.getDescriptionField.fill(Utils.string513Long); - expect(await myLibrariesPage.libraryDetails.hintMessage).toBeVisible(); - expect(await myLibrariesPage.libraryDetails.hintMessage).toEqual('Use 512 characters or less for description'); - expect(await myLibrariesPage.libraryDetails.updateButton).not.toBeEnabled(); + await myLibrariesPage.libraryDetails.descriptionField.fill(Utils.string513Long); + await expect(myLibrariesPage.libraryDetails.errorMessage).toBeVisible(); + expect((await myLibrariesPage.libraryDetails.errorMessage.textContent()).trim()).toEqual('Use 512 characters or less for description'); + await expect(myLibrariesPage.libraryDetails.updateButton).not.toBeEnabled(); }); +}); - test.describe('Non manager', () => { - test.beforeEach(async ({ myLibrariesPage }) => { - await myLibrariesPage.navigate(); - }); +test.describe('Non manager', () => { + let sitesApi: SitesApi; + const username = `user1-${Utils.random()}`; + const user2 = `user2-${Utils.random()}`; + const user3 = `user3-${Utils.random()}`; - test.afterAll(async ({ loginPage }) => { - await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); - }); + const site = { + name: `site1-${Utils.random()}`, + id: `site-id-${Utils.random()}`, + visibility: SITE_VISIBILITY.MODERATED, + description: 'my site description' + }; - test('[C289337] Info drawer button is not displayed when user is not the library manager', async ({ loginPage, myLibrariesPage }) => { - await loginPage.loginUser({ username, password: user2 }, { withNavigation: true, waitForLoading: true }); - await myLibrariesPage.dataTable.selectItem(site.name); - expect(await myLibrariesPage.acaHeader.viewDetails).not.toBeVisible(); - }); + test.beforeAll(async () => { + try { + const apiClientFactory = new ApiClientFactory(); + await apiClientFactory.setUpAcaBackend('admin'); + await apiClientFactory.createUser({ username: username }); + await apiClientFactory.createUser({ username: user2 }); + await apiClientFactory.createUser({ username: user3 }); - test('[C289344] Error notification', async ({ loginPage, myLibrariesPage }) => { - await loginPage.loginUser({ username, password: user3 }, { withNavigation: true, waitForLoading: true }); - await myLibrariesPage.dataTable.selectItem(site.name); - await myLibrariesPage.acaHeader.viewDetails.click(); - await myLibrariesPage.libraryDetails.editButton.click(); - await sitesApi.updateSiteMember(site.id, user3, SITE_ROLES.SITE_CONSUMER.ROLE); - await myLibrariesPage.libraryDetails.getDescriptionField.fill('new description'); - await myLibrariesPage.libraryDetails.updateButton.click(); + sitesApi = await SitesApi.initialize(username, username); + await sitesApi.createSite(site.name, site.visibility, site.description, site.id); + await sitesApi.addSiteMember(site.id, user2, SITE_ROLES.SITE_COLLABORATOR.ROLE); + await sitesApi.addSiteMember(site.id, user3, SITE_ROLES.SITE_MANAGER.ROLE); + } catch (error) { + console.error(`beforeAll failed: ${error}`); + } + }); + + test.afterAll(async () => { + await sitesApi.deleteSites([site.id]); + }); + + test('[C289337] Info drawer button is not displayed when user is not the library manager', async ({ loginPage, myLibrariesPage }) => { + await loginPage.loginUser({ username: user2, password: user2 }, { withNavigation: true, waitForLoading: true }); + await myLibrariesPage.navigate(); + + await myLibrariesPage.dataTable.getRowByName(site.name).click(); + await expect(myLibrariesPage.acaHeader.viewDetails).not.toBeVisible(); + }); + + test('[C289344] Error notification when editing with no rights', async ({ loginPage, myLibrariesPage }) => { + await loginPage.loginUser({ username: user3, password: user3 }, { withNavigation: true, waitForLoading: true }); + await myLibrariesPage.navigate(); + + await myLibrariesPage.dataTable.getRowByName(site.name).click(); + await myLibrariesPage.acaHeader.viewDetails.click(); + await myLibrariesPage.libraryDetails.editButton.click(); + await sitesApi.updateSiteMember(site.id, user3, SITE_ROLES.SITE_CONSUMER.ROLE); + await myLibrariesPage.libraryDetails.descriptionField.fill('new description'); + await myLibrariesPage.libraryDetails.updateButton.click(); - await expect(myLibrariesPage.snackBar.message).toEqual('There was an error updating library properties'); - }); + expect(await myLibrariesPage.snackBar.message.textContent()).toEqual('There was an error updating library properties'); }); }); diff --git a/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts b/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts index 3edb4ce8d7..8ecc46a0b9 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts @@ -1,26 +1,26 @@ /*! - * 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 . - */ + * 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 { BaseComponent } from './base.component'; import { Page, expect } from '@playwright/test'; @@ -34,7 +34,8 @@ export class AdfInfoDrawerComponent extends BaseComponent { public getNameField = (labelText: string) => this.getChild('[data-automation-id="library-name-properties-wrapper"]', { hasText: labelText }); public getIdField = (labelText: string) => this.getChild('[data-automation-id="library-id-properties-wrapper"]', { hasText: labelText }); - public getVisibilityField = (labelText: string) => this.getChild('[data-automation-id="library-visibility-properties-wrapper"]', { hasText: labelText }); + public getVisibilityField = (labelText: string) => + this.getChild('[data-automation-id="library-visibility-properties-wrapper"]', { hasText: labelText }); public getDescriptionField = this.getChild('[data-automation-id="library-description-properties-wrapper"] textarea'); public infoDrawerTabs = this.getChild('.adf-info-drawer-tab'); public propertiesTab = this.infoDrawerTabs.nth(0); @@ -49,7 +50,12 @@ export class AdfInfoDrawerComponent extends BaseComponent { public headerTitle = this.getChild('.adf-info-drawer-layout-header-title div'); public expandDetailsButton = this.getChild(`button[title='Expand panel']`); public expandedDetailsTabs = this.page.locator('.aca-details-container .mat-tab-label-content'); - public expandedDetailsPermissionsTab = this.expandedDetailsTabs.getByText("Permissions"); + public expandedDetailsPermissionsTab = this.expandedDetailsTabs.getByText('Permissions'); + public nameField = this.page.locator('label', { hasText: 'Name' }); + public idField = this.page.locator('label', { hasText: 'Library ID' }); + public descriptionField = this.page.locator('label', { hasText: 'Description' }); + public visibilityField = this.infoDrawerPanel.getByRole('combobox'); + public selectVisibility = (visibilityOption: string) => this.page.getByRole('listbox').getByRole('option', { name: visibilityOption }).click(); async checkCommentsHeaderCount(): Promise { diff --git a/projects/aca-playwright-shared/src/utils/config.ts b/projects/aca-playwright-shared/src/utils/config.ts index f85982bae7..4575a49eb7 100644 --- a/projects/aca-playwright-shared/src/utils/config.ts +++ b/projects/aca-playwright-shared/src/utils/config.ts @@ -43,3 +43,31 @@ export const SIDEBAR_LABELS = { FAVORITES: 'Favorites', TRASH: 'Trash' }; + +export const SITE_VISIBILITY = { + PUBLIC: 'PUBLIC', + MODERATED: 'MODERATED', + PRIVATE: 'PRIVATE' +}; + +export const SITE_ROLES = { + SITE_CONSUMER: { + ROLE: 'SiteConsumer', + LABEL: 'Consumer' + }, + SITE_COLLABORATOR: { + ROLE: 'SiteCollaborator', + LABEL: 'Collaborator' + }, + SITE_CONTRIBUTOR: { + ROLE: 'SiteContributor', + LABEL: 'Contributor' + }, + SITE_MANAGER: { + ROLE: 'SiteManager', + LABEL: 'Manager' + }, + NONE: { + LABEL: 'Not a member' + } +}; From d8f9c1f38c07ebf3ee394ed4037d9f67b26c0a4d Mon Sep 17 00:00:00 2001 From: datguycheb Date: Fri, 26 Jan 2024 11:00:39 +0100 Subject: [PATCH 08/22] [ACS-5882] infoDrawer comments tests migrated to Playwright --- .../src/page-objects/pages/favorites.page.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts index 8aa940f26a..4f561f5b3e 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts @@ -49,4 +49,10 @@ export class FavoritesPage extends BasePage { async waitForPageLoad() { await this.page.waitForURL(`**/${FavoritesPage.pageUrl}`); } + + async addCommentToNode(commentText: any) { + await this.infoDrawer.commentInputField.click(); + await this.page.keyboard.type(commentText); + await this.infoDrawer.addCommentButton.click(); + } } From f20024b8af4c9046cca7837fb4171b088dcf39b3 Mon Sep 17 00:00:00 2001 From: datguycheb Date: Fri, 26 Jan 2024 12:11:04 +0100 Subject: [PATCH 09/22] [ACS-5882] fixed issues from pull request comments --- .../src/page-objects/pages/favorites.page.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts index 4f561f5b3e..8aa940f26a 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts @@ -49,10 +49,4 @@ export class FavoritesPage extends BasePage { async waitForPageLoad() { await this.page.waitForURL(`**/${FavoritesPage.pageUrl}`); } - - async addCommentToNode(commentText: any) { - await this.infoDrawer.commentInputField.click(); - await this.page.keyboard.type(commentText); - await this.infoDrawer.addCommentButton.click(); - } } From 1e124d41d7fa59f3da2b68b07f466a2d04408a61 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Fri, 2 Feb 2024 00:07:28 +0100 Subject: [PATCH 10/22] Protractor to Playwright info-drawer tests --- e2e/playwright/info-drawer/src/tests/general.spec.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/e2e/playwright/info-drawer/src/tests/general.spec.ts b/e2e/playwright/info-drawer/src/tests/general.spec.ts index 8f1ba64830..8f8d214221 100644 --- a/e2e/playwright/info-drawer/src/tests/general.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/general.spec.ts @@ -44,6 +44,10 @@ test.describe('Info Drawer - General', () => { nodesApi = await NodesApi.initialize(username, username); trashcanApi = await TrashcanApi.initialize(username, username); fileActionsApi = await FileActionsApi.initialize(username, username); + + parentId = (await nodesApi.createFolder(parentFolder)).entry.id; + await nodesApi.createFile(file1, parentId); + await nodesApi.createFolder(folder1, parentId); } catch (error) { console.error(`beforeAll failed: ${error}`); } @@ -86,5 +90,13 @@ test.describe('Info Drawer - General', () => { await personalFiles.reload({ waitUntil: 'load' }); expect(personalFiles.infoDrawer.infoDrawerPanel).not.toBeVisible(); + await personalFiles.dataTable.selectItem(file1); + await personalFiles.clickInfoDrawerButton(); + expect(await personalFiles.infoDrawer.infoDrawerPanel.isVisible()).toBe(true); + + await personalFiles.reload(); + await personalFiles.waitForPageLoad(); + + expect(personalFiles.infoDrawer.infoDrawerPanel.isVisible()).toBe(false); }); }); From 3f80a17813a5d7c12797e7e01b24b9406e32e9b9 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Tue, 6 Feb 2024 14:41:43 +0100 Subject: [PATCH 11/22] Fixed general tests --- e2e/playwright/info-drawer/src/tests/general.spec.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/e2e/playwright/info-drawer/src/tests/general.spec.ts b/e2e/playwright/info-drawer/src/tests/general.spec.ts index 8f8d214221..7a9c1ef020 100644 --- a/e2e/playwright/info-drawer/src/tests/general.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/general.spec.ts @@ -92,11 +92,9 @@ test.describe('Info Drawer - General', () => { expect(personalFiles.infoDrawer.infoDrawerPanel).not.toBeVisible(); await personalFiles.dataTable.selectItem(file1); await personalFiles.clickInfoDrawerButton(); - expect(await personalFiles.infoDrawer.infoDrawerPanel.isVisible()).toBe(true); - - await personalFiles.reload(); - await personalFiles.waitForPageLoad(); + await expect(personalFiles.infoDrawer.infoDrawerPanel).toBeVisible(); - expect(personalFiles.infoDrawer.infoDrawerPanel.isVisible()).toBe(false); + await personalFiles.reload({ waitUntil: 'load' }); + expect(personalFiles.infoDrawer.infoDrawerPanel).not.toBeVisible(); }); }); From ea815e790fffcbdf62b2617040e7fec8533e923b Mon Sep 17 00:00:00 2001 From: datguycheb Date: Fri, 26 Jan 2024 11:00:39 +0100 Subject: [PATCH 12/22] [ACS-5882] infoDrawer comments tests migrated to Playwright --- .../src/page-objects/pages/favorites.page.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts index 8aa940f26a..4f561f5b3e 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts @@ -49,4 +49,10 @@ export class FavoritesPage extends BasePage { async waitForPageLoad() { await this.page.waitForURL(`**/${FavoritesPage.pageUrl}`); } + + async addCommentToNode(commentText: any) { + await this.infoDrawer.commentInputField.click(); + await this.page.keyboard.type(commentText); + await this.infoDrawer.addCommentButton.click(); + } } From 37b582be7dfa5a0535f471fc41faea2958f73402 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Tue, 6 Feb 2024 14:41:43 +0100 Subject: [PATCH 13/22] Fixed general tests --- .../src/page-objects/components/adf-info-drawer.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts b/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts index 8ecc46a0b9..4a706aaccb 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts @@ -57,7 +57,6 @@ export class AdfInfoDrawerComponent extends BaseComponent { public visibilityField = this.infoDrawerPanel.getByRole('combobox'); public selectVisibility = (visibilityOption: string) => this.page.getByRole('listbox').getByRole('option', { name: visibilityOption }).click(); - async checkCommentsHeaderCount(): Promise { const commentsCountTextContent = await this.commentsHeader.textContent(); const commentsCountString = commentsCountTextContent.match(/\d+/g)[0]; From d769370fd1904533d910b1c004d2705b645d2046 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Fri, 9 Feb 2024 09:59:40 +0100 Subject: [PATCH 14/22] Removed duplicated code from general test --- e2e/playwright/info-drawer/src/tests/general.spec.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/e2e/playwright/info-drawer/src/tests/general.spec.ts b/e2e/playwright/info-drawer/src/tests/general.spec.ts index 7a9c1ef020..80ecdcf730 100644 --- a/e2e/playwright/info-drawer/src/tests/general.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/general.spec.ts @@ -44,10 +44,6 @@ test.describe('Info Drawer - General', () => { nodesApi = await NodesApi.initialize(username, username); trashcanApi = await TrashcanApi.initialize(username, username); fileActionsApi = await FileActionsApi.initialize(username, username); - - parentId = (await nodesApi.createFolder(parentFolder)).entry.id; - await nodesApi.createFile(file1, parentId); - await nodesApi.createFolder(folder1, parentId); } catch (error) { console.error(`beforeAll failed: ${error}`); } From 194eb7ed9b9d098f8662b29d359bc3225cdad1bd Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Fri, 9 Feb 2024 11:13:46 +0100 Subject: [PATCH 15/22] Reverted lost selectors --- .../components/adf-info-drawer.component.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts b/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts index 4a706aaccb..2e1d2d8823 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts @@ -37,9 +37,9 @@ export class AdfInfoDrawerComponent extends BaseComponent { public getVisibilityField = (labelText: string) => this.getChild('[data-automation-id="library-visibility-properties-wrapper"]', { hasText: labelText }); public getDescriptionField = this.getChild('[data-automation-id="library-description-properties-wrapper"] textarea'); + public propertiesTab = this.page.getByRole('tab', { name: 'Properties' }); + public commentsTab = this.page.getByRole('tab', { name: 'Comments' }); public infoDrawerTabs = this.getChild('.adf-info-drawer-tab'); - public propertiesTab = this.infoDrawerTabs.nth(0); - public commentsTab = this.infoDrawerTabs.nth(1); public commentInputField = this.getChild('mat-form-field'); public commentsHeader = this.getChild('#comment-header'); public addCommentButton = this.getChild('[data-automation-id="comments-input-add"]'); @@ -47,7 +47,14 @@ export class AdfInfoDrawerComponent extends BaseComponent { public commentUsername = this.getChild('.adf-comment-user-name'); public commentTextContent = this.getChild('.adf-comment-message'); public commentTimestamp = this.getChild('.adf-comment-message-time'); - public headerTitle = this.getChild('.adf-info-drawer-layout-header-title div'); + public commentProfileIcon = this.getChild('.adf-comment-user-icon'); + public infoDrawerPanel = this.page.locator('.adf-info-drawer'); + public headerTitle = this.page.locator('.adf-info-drawer-layout-header-title').getByRole('heading'); + public editButton = this.page.getByRole('button', { name: 'Edit' }); + public cancelButton = this.page.getByRole('button', { name: 'Cancel' }); + public updateButton = this.page.getByRole('button', { name: 'Update' }); + public hintMessage = this.page.locator('.mat-hint'); + public errorMessage = this.page.locator('.mat-error'); public expandDetailsButton = this.getChild(`button[title='Expand panel']`); public expandedDetailsTabs = this.page.locator('.aca-details-container .mat-tab-label-content'); public expandedDetailsPermissionsTab = this.expandedDetailsTabs.getByText('Permissions'); From e7e9edbe76042d4a81cd87bf81bc3495ae43ab2f Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Fri, 9 Feb 2024 11:36:39 +0100 Subject: [PATCH 16/22] moved duplicated blocks of code --- .../info-drawer/src/tests/general.spec.ts | 14 +++++----- .../src/tests/library-properties.spec.ts | 8 +++--- .../aca-playwright-shared/src/utils/config.ts | 26 +++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/e2e/playwright/info-drawer/src/tests/general.spec.ts b/e2e/playwright/info-drawer/src/tests/general.spec.ts index 80ecdcf730..ac004086d4 100644 --- a/e2e/playwright/info-drawer/src/tests/general.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/general.spec.ts @@ -49,20 +49,20 @@ test.describe('Info Drawer - General', () => { } }); - test.beforeEach(async ({ loginPage }) => { + test.afterAll(async () => { try { - await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); + await nodesApi.deleteCurrentUserNodes(); + await trashcanApi.emptyTrashcan(); } catch (error) { - console.error(`beforeEach failed: ${error}`); + console.error(`afterAll failed: ${error}`); } }); - test.afterAll(async () => { + test.beforeEach(async ({ loginPage }) => { try { - await nodesApi.deleteCurrentUserNodes(); - await trashcanApi.emptyTrashcan(); + await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); } catch (error) { - console.error(`afterAll failed: ${error}`); + console.error(`beforeEach failed: ${error}`); } }); diff --git a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts index 5144fe2c3d..513959b3f8 100644 --- a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts @@ -73,10 +73,6 @@ test.describe('Library properties', () => { } }); - test.afterAll(async () => { - await sitesApi.deleteSites([site.id, siteForUpdate.id, siteDup]); - }); - test.beforeEach(async ({ myLibrariesPage, loginPage }) => { try { await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); @@ -86,6 +82,10 @@ test.describe('Library properties', () => { } }); + test.afterAll(async () => { + await sitesApi.deleteSites([site.id, siteForUpdate.id, siteDup]); + }); + test.afterEach(async ({ myLibrariesPage }) => { if (await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()) { await myLibrariesPage.acaHeader.viewDetails.click(); diff --git a/projects/aca-playwright-shared/src/utils/config.ts b/projects/aca-playwright-shared/src/utils/config.ts index 4575a49eb7..41f572999e 100644 --- a/projects/aca-playwright-shared/src/utils/config.ts +++ b/projects/aca-playwright-shared/src/utils/config.ts @@ -44,30 +44,30 @@ export const SIDEBAR_LABELS = { TRASH: 'Trash' }; -export const SITE_VISIBILITY = { - PUBLIC: 'PUBLIC', - MODERATED: 'MODERATED', - PRIVATE: 'PRIVATE' -}; - export const SITE_ROLES = { + SITE_MANAGER: { + ROLE: 'SiteManager', + LABEL: 'Manager' + }, SITE_CONSUMER: { ROLE: 'SiteConsumer', LABEL: 'Consumer' }, - SITE_COLLABORATOR: { - ROLE: 'SiteCollaborator', - LABEL: 'Collaborator' - }, SITE_CONTRIBUTOR: { ROLE: 'SiteContributor', LABEL: 'Contributor' }, - SITE_MANAGER: { - ROLE: 'SiteManager', - LABEL: 'Manager' + SITE_COLLABORATOR: { + ROLE: 'SiteCollaborator', + LABEL: 'Collaborator' }, NONE: { LABEL: 'Not a member' } }; + +export const SITE_VISIBILITY = { + PUBLIC: 'PUBLIC', + MODERATED: 'MODERATED', + PRIVATE: 'PRIVATE' +}; From edf70007e388ec870a1a0ec153ef86f96264e748 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Sun, 11 Feb 2024 22:20:45 +0100 Subject: [PATCH 17/22] Fixed duplicated code blocks --- .../src/tests/library-properties.spec.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts index 513959b3f8..23c22616fc 100644 --- a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts @@ -54,6 +54,21 @@ test.describe('Library properties', () => { const siteDup = `site3-${Utils.random()}`; + test.beforeEach(async ({ myLibrariesPage, loginPage }) => { + try { + await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); + await myLibrariesPage.navigate(); + } catch (error) { + console.error(` beforeEach failed: ${error}`); + } + }); + + test.afterEach(async ({ myLibrariesPage }) => { + if (await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()) { + await myLibrariesPage.acaHeader.viewDetails.click(); + } + }); + test.beforeAll(async () => { try { const apiClientFactory = new ApiClientFactory(); @@ -73,25 +88,10 @@ test.describe('Library properties', () => { } }); - test.beforeEach(async ({ myLibrariesPage, loginPage }) => { - try { - await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); - await myLibrariesPage.navigate(); - } catch (error) { - console.error(` beforeEach failed: ${error}`); - } - }); - test.afterAll(async () => { await sitesApi.deleteSites([site.id, siteForUpdate.id, siteDup]); }); - test.afterEach(async ({ myLibrariesPage }) => { - if (await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()) { - await myLibrariesPage.acaHeader.viewDetails.click(); - } - }); - test('[C289336] Info drawer opens for a library', async ({ myLibrariesPage }) => { await expect(myLibrariesPage.dataTable.getRowByName(site.name)).toBeVisible(); await myLibrariesPage.dataTable.getRowByName(site.name).click(); From ccc862c6987d07b1f4a2d39fe6683012ae6074b6 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Sun, 11 Feb 2024 22:24:30 +0100 Subject: [PATCH 18/22] Fixed duplicated blocks --- .../src/api/queries-api.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/projects/aca-playwright-shared/src/api/queries-api.ts b/projects/aca-playwright-shared/src/api/queries-api.ts index b583ef8277..d814359fee 100755 --- a/projects/aca-playwright-shared/src/api/queries-api.ts +++ b/projects/aca-playwright-shared/src/api/queries-api.ts @@ -37,21 +37,6 @@ export class QueriesApi { return classObj; } - private async findSitesTotalItems(searchTerm: string): Promise { - try { - const opts = { - term: searchTerm, - fields: ['title'] - }; - - const sites = await this.apiService.queries.findSites(searchTerm, opts); - return sites.list.pagination.totalItems; - } catch (error) { - console.error(`QueriesApi findSitesTotalItems : catch :`, error); - return null; - } - } - async waitForSites(searchTerm: string, data: { expect: number }) { try { const sites = async () => { @@ -69,4 +54,19 @@ export class QueriesApi { console.error(`\tExpected: ${data.expect} items, but found ${error}`); } } + + private async findSitesTotalItems(searchTerm: string): Promise { + try { + const opts = { + term: searchTerm, + fields: ['title'] + }; + + const sites = await this.apiService.queries.findSites(searchTerm, opts); + return sites.list.pagination.totalItems; + } catch (error) { + console.error(`QueriesApi findSitesTotalItems : catch :`, error); + return null; + } + } } From caa96c8dcf7acf5446ba8e5967043d5178d2a45c Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Mon, 12 Feb 2024 13:47:36 +0100 Subject: [PATCH 19/22] Fixed after PR comments --- .../info-drawer/src/tests/general.spec.ts | 20 ++++++------ .../src/tests/library-properties.spec.ts | 32 +++++++------------ .../src/api/queries-api.ts | 6 ++-- .../src/api/sites-api.ts | 2 +- .../components/adf-info-drawer.component.ts | 1 - .../src/page-objects/pages/favorites.page.ts | 6 ---- .../page-objects/pages/personal-files.page.ts | 4 --- 7 files changed, 27 insertions(+), 44 deletions(-) diff --git a/e2e/playwright/info-drawer/src/tests/general.spec.ts b/e2e/playwright/info-drawer/src/tests/general.spec.ts index ac004086d4..b913c52bdd 100644 --- a/e2e/playwright/info-drawer/src/tests/general.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/general.spec.ts @@ -31,10 +31,6 @@ test.describe('Info Drawer - General', () => { let fileActionsApi: FileActionsApi; const username = `user1-${Utils.random()}`; - const parentFolder = `parent-${Utils.random()}`; - const file1 = `file1-${Utils.random()}.txt`; - const folder1 = `folder1-${Utils.random()}`; - let parentId: string; test.beforeAll(async () => { try { @@ -68,12 +64,16 @@ test.describe('Info Drawer - General', () => { test.afterEach(async ({ personalFiles }) => { if (await personalFiles.infoDrawer.infoDrawerPanel.isVisible()) { - await personalFiles.clickInfoDrawerButton(); + await personalFiles.acaHeader.viewDetails.click(); } }); test('[C268999] Info drawer closes on page refresh', async ({ personalFiles }) => { - parentId = (await nodesApi.createFolder(parentFolder)).entry.id; + const parentFolder = `parent-${Utils.random()}`; + const file1 = `file1-${Utils.random()}.txt`; + const folder1 = `folder1-${Utils.random()}`; + const parentId = (await nodesApi.createFolder(parentFolder)).entry.id; + await nodesApi.createFile(file1, parentId); await nodesApi.createFolder(folder1, parentId); await fileActionsApi.waitForNodes(file1, { expect: 1 }); @@ -81,16 +81,16 @@ test.describe('Info Drawer - General', () => { await expect(personalFiles.dataTable.getRowByName(parentFolder)).toBeVisible(); await personalFiles.dataTable.performClickFolderOrFileToOpen(parentFolder); await personalFiles.dataTable.selectItem(file1); - await personalFiles.clickInfoDrawerButton(); + await personalFiles.acaHeader.viewDetails.click(); await expect(personalFiles.infoDrawer.infoDrawerPanel).toBeVisible(); await personalFiles.reload({ waitUntil: 'load' }); - expect(personalFiles.infoDrawer.infoDrawerPanel).not.toBeVisible(); + await expect(personalFiles.infoDrawer.infoDrawerPanel).not.toBeVisible(); await personalFiles.dataTable.selectItem(file1); - await personalFiles.clickInfoDrawerButton(); + await personalFiles.acaHeader.viewDetails.click(); await expect(personalFiles.infoDrawer.infoDrawerPanel).toBeVisible(); await personalFiles.reload({ waitUntil: 'load' }); - expect(personalFiles.infoDrawer.infoDrawerPanel).not.toBeVisible(); + await expect(personalFiles.infoDrawer.infoDrawerPanel).not.toBeVisible(); }); }); diff --git a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts index 23c22616fc..787d95cdaf 100644 --- a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts @@ -27,31 +27,20 @@ import { ApiClientFactory, Utils, test, SitesApi, QueriesApi, SITE_VISIBILITY, S test.describe('Library properties', () => { let sitesApi: SitesApi; - let queriesApi: QueriesApi; - const username = `user1-${Utils.random()}`; - const user2 = `user2-${Utils.random()}`; - const user3 = `user3-${Utils.random()}`; + const username = `user1-${Utils.random()}`; const site = { name: `site1-${Utils.random()}`, id: `site-id-${Utils.random()}`, visibility: SITE_VISIBILITY.MODERATED, description: 'my site description' }; - const siteForUpdate = { name: `site2-${Utils.random()}`, id: `site-id-${Utils.random()}`, visibility: SITE_VISIBILITY.MODERATED, description: 'my initial description' }; - - const siteUpdated = { - name: `site-for-rename-${Utils.random()}`, - visibility: SITE_VISIBILITY.PRIVATE, - description: 'new description' - }; - const siteDup = `site3-${Utils.random()}`; test.beforeEach(async ({ myLibrariesPage, loginPage }) => { @@ -73,16 +62,12 @@ test.describe('Library properties', () => { try { const apiClientFactory = new ApiClientFactory(); await apiClientFactory.setUpAcaBackend('admin'); - await apiClientFactory.createUser({ username: username }); - await apiClientFactory.createUser({ username: user2 }); - await apiClientFactory.createUser({ username: user3 }); + await apiClientFactory.createUser({ username }); sitesApi = await SitesApi.initialize(username, username); await sitesApi.createSite(site.name, site.visibility, site.description, site.id); await sitesApi.createSite(siteForUpdate.name, siteForUpdate.visibility, siteForUpdate.description, siteForUpdate.id); await sitesApi.createSite(siteDup); - await sitesApi.addSiteMember(site.id, user2, SITE_ROLES.SITE_COLLABORATOR.ROLE); - await sitesApi.addSiteMember(site.id, user3, SITE_ROLES.SITE_MANAGER.ROLE); } catch (error) { console.error(`beforeAll failed: ${error}`); } @@ -130,6 +115,12 @@ test.describe('Library properties', () => { }); test('[C289339] Edit site details', async ({ myLibrariesPage }) => { + const siteUpdated = { + name: `site-for-rename-${Utils.random()}`, + visibility: SITE_VISIBILITY.PRIVATE, + description: 'new description' + }; + await myLibrariesPage.dataTable.getRowByName(siteForUpdate.name).click(); await myLibrariesPage.acaHeader.viewDetails.click(); await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); @@ -174,7 +165,8 @@ test.describe('Library properties', () => { }); test('[C289341] Warning appears when editing the name of the library by entering an existing name', async ({ myLibrariesPage }) => { - queriesApi = await QueriesApi.initialize(username, username); + const queriesApi = await QueriesApi.initialize(username, username); + await queriesApi.waitForSites(site.name, { expect: 1 }); await myLibrariesPage.dataTable.getRowByName(siteDup).click(); await myLibrariesPage.acaHeader.viewDetails.click(); @@ -214,10 +206,10 @@ test.describe('Library properties', () => { test.describe('Non manager', () => { let sitesApi: SitesApi; + const username = `user1-${Utils.random()}`; const user2 = `user2-${Utils.random()}`; const user3 = `user3-${Utils.random()}`; - const site = { name: `site1-${Utils.random()}`, id: `site-id-${Utils.random()}`, @@ -229,7 +221,7 @@ test.describe('Non manager', () => { try { const apiClientFactory = new ApiClientFactory(); await apiClientFactory.setUpAcaBackend('admin'); - await apiClientFactory.createUser({ username: username }); + await apiClientFactory.createUser({ username }); await apiClientFactory.createUser({ username: user2 }); await apiClientFactory.createUser({ username: user3 }); diff --git a/projects/aca-playwright-shared/src/api/queries-api.ts b/projects/aca-playwright-shared/src/api/queries-api.ts index d814359fee..b56bb71cbe 100755 --- a/projects/aca-playwright-shared/src/api/queries-api.ts +++ b/projects/aca-playwright-shared/src/api/queries-api.ts @@ -31,13 +31,14 @@ export class QueriesApi { constructor() { this.apiService = new ApiClientFactory(); } + static async initialize(userName: string, password?: string): Promise { const classObj = new QueriesApi(); await classObj.apiService.setUpAcaBackend(userName, password); return classObj; } - async waitForSites(searchTerm: string, data: { expect: number }) { + async waitForSites(searchTerm: string, data: { expect: number }): Promise { try { const sites = async () => { const totalItems = await this.findSitesTotalItems(searchTerm); @@ -52,12 +53,13 @@ export class QueriesApi { } catch (error) { console.error(`QueriesApi waitForSites : catch : `); console.error(`\tExpected: ${data.expect} items, but found ${error}`); + return null; } } private async findSitesTotalItems(searchTerm: string): Promise { try { - const opts = { + const opts: { term: string; fields: Array } = { term: searchTerm, fields: ['title'] }; diff --git a/projects/aca-playwright-shared/src/api/sites-api.ts b/projects/aca-playwright-shared/src/api/sites-api.ts index 4591ce5e72..9bd6de215b 100755 --- a/projects/aca-playwright-shared/src/api/sites-api.ts +++ b/projects/aca-playwright-shared/src/api/sites-api.ts @@ -159,7 +159,7 @@ export class SitesApi { } } - async getSite(siteId: string) { + async getSite(siteId: string): Promise { try { return await this.apiService.sites.getSite(siteId); } catch (error) { diff --git a/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts b/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts index 2e1d2d8823..f52ffa1ce0 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts @@ -47,7 +47,6 @@ export class AdfInfoDrawerComponent extends BaseComponent { public commentUsername = this.getChild('.adf-comment-user-name'); public commentTextContent = this.getChild('.adf-comment-message'); public commentTimestamp = this.getChild('.adf-comment-message-time'); - public commentProfileIcon = this.getChild('.adf-comment-user-icon'); public infoDrawerPanel = this.page.locator('.adf-info-drawer'); public headerTitle = this.page.locator('.adf-info-drawer-layout-header-title').getByRole('heading'); public editButton = this.page.getByRole('button', { name: 'Edit' }); diff --git a/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts index 4f561f5b3e..8aa940f26a 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts @@ -49,10 +49,4 @@ export class FavoritesPage extends BasePage { async waitForPageLoad() { await this.page.waitForURL(`**/${FavoritesPage.pageUrl}`); } - - async addCommentToNode(commentText: any) { - await this.infoDrawer.commentInputField.click(); - await this.page.keyboard.type(commentText); - await this.infoDrawer.addCommentButton.click(); - } } 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 bfa28c743e..8098788fb4 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 @@ -95,8 +95,4 @@ export class PersonalFilesPage extends BasePage { await this.contentNodeSelector.selectDestination(destinationName); await this.contentNodeSelector.actionButton.click(); } - - async clickInfoDrawerButton(): Promise { - await this.acaHeader.viewDetails.click(); - } } From 3ae343a4b3c8499143d09c02794de9e455895919 Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Mon, 12 Feb 2024 13:53:16 +0100 Subject: [PATCH 20/22] Fixed not.toBeEnabled methods --- .../info-drawer/src/tests/library-properties.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts index 787d95cdaf..c539677084 100644 --- a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts @@ -111,7 +111,7 @@ test.describe('Library properties', () => { await expect(myLibrariesPage.libraryDetails.cancelButton).toBeVisible(); await expect(myLibrariesPage.libraryDetails.updateButton).toBeVisible(); await expect(myLibrariesPage.libraryDetails.cancelButton).toBeEnabled(); - await expect(myLibrariesPage.libraryDetails.updateButton).not.toBeEnabled(); + await expect(myLibrariesPage.libraryDetails.updateButton).toBeDisabled(); }); test('[C289339] Edit site details', async ({ myLibrariesPage }) => { @@ -188,7 +188,7 @@ test.describe('Library properties', () => { await myLibrariesPage.libraryDetails.nameField.fill(Utils.string257Long); await expect(myLibrariesPage.libraryDetails.errorMessage).toBeVisible(); expect((await myLibrariesPage.libraryDetails.errorMessage.textContent()).trim()).toEqual('Use 256 characters or less for title'); - await expect(myLibrariesPage.libraryDetails.updateButton).not.toBeEnabled(); + await expect(myLibrariesPage.libraryDetails.updateButton).toBeDisabled(); }); test('[C289343] Site description too long', async ({ myLibrariesPage }) => { @@ -200,7 +200,7 @@ test.describe('Library properties', () => { await myLibrariesPage.libraryDetails.descriptionField.fill(Utils.string513Long); await expect(myLibrariesPage.libraryDetails.errorMessage).toBeVisible(); expect((await myLibrariesPage.libraryDetails.errorMessage.textContent()).trim()).toEqual('Use 512 characters or less for description'); - await expect(myLibrariesPage.libraryDetails.updateButton).not.toBeEnabled(); + await expect(myLibrariesPage.libraryDetails.updateButton).toBeDisabled(); }); }); From 18f572c328fb9edda4f9e8eb26c589084801208a Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Tue, 13 Feb 2024 00:46:58 +0100 Subject: [PATCH 21/22] Fixes after PR comments, removed afterEach blocks --- .../info-drawer/playwright.config.ts | 2 +- .../info-drawer/src/tests/general.spec.ts | 24 +++++++------------ .../src/tests/library-properties.spec.ts | 6 ----- .../src/api/queries-api.ts | 3 ++- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/e2e/playwright/info-drawer/playwright.config.ts b/e2e/playwright/info-drawer/playwright.config.ts index 2f5d2d83ff..31cb13ef51 100644 --- a/e2e/playwright/info-drawer/playwright.config.ts +++ b/e2e/playwright/info-drawer/playwright.config.ts @@ -35,7 +35,7 @@ const config: PlaywrightTestConfig = { name: 'Info Drawer', testDir: './src/tests', use: { - users: ['hruser', 'admin'] + users: [] } } ] diff --git a/e2e/playwright/info-drawer/src/tests/general.spec.ts b/e2e/playwright/info-drawer/src/tests/general.spec.ts index b913c52bdd..9e0a6debd8 100644 --- a/e2e/playwright/info-drawer/src/tests/general.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/general.spec.ts @@ -32,6 +32,15 @@ test.describe('Info Drawer - General', () => { const username = `user1-${Utils.random()}`; + test.afterAll(async () => { + try { + await nodesApi.deleteCurrentUserNodes(); + await trashcanApi.emptyTrashcan(); + } catch (error) { + console.error(`afterAll failed: ${error}`); + } + }); + test.beforeAll(async () => { try { const apiClientFactory = new ApiClientFactory(); @@ -45,15 +54,6 @@ test.describe('Info Drawer - General', () => { } }); - test.afterAll(async () => { - try { - await nodesApi.deleteCurrentUserNodes(); - await trashcanApi.emptyTrashcan(); - } catch (error) { - console.error(`afterAll failed: ${error}`); - } - }); - test.beforeEach(async ({ loginPage }) => { try { await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); @@ -62,12 +62,6 @@ test.describe('Info Drawer - General', () => { } }); - test.afterEach(async ({ personalFiles }) => { - if (await personalFiles.infoDrawer.infoDrawerPanel.isVisible()) { - await personalFiles.acaHeader.viewDetails.click(); - } - }); - test('[C268999] Info drawer closes on page refresh', async ({ personalFiles }) => { const parentFolder = `parent-${Utils.random()}`; const file1 = `file1-${Utils.random()}.txt`; diff --git a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts index c539677084..94f9f96ed5 100644 --- a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts @@ -52,12 +52,6 @@ test.describe('Library properties', () => { } }); - test.afterEach(async ({ myLibrariesPage }) => { - if (await myLibrariesPage.libraryDetails.infoDrawerPanel.isVisible()) { - await myLibrariesPage.acaHeader.viewDetails.click(); - } - }); - test.beforeAll(async () => { try { const apiClientFactory = new ApiClientFactory(); diff --git a/projects/aca-playwright-shared/src/api/queries-api.ts b/projects/aca-playwright-shared/src/api/queries-api.ts index b56bb71cbe..0bc00aea82 100755 --- a/projects/aca-playwright-shared/src/api/queries-api.ts +++ b/projects/aca-playwright-shared/src/api/queries-api.ts @@ -22,6 +22,7 @@ * along with Alfresco. If not, see . */ +import { FindQuery } from '@alfresco/js-api'; import { Utils } from '../utils'; import { ApiClientFactory } from './api-client-factory'; @@ -59,7 +60,7 @@ export class QueriesApi { private async findSitesTotalItems(searchTerm: string): Promise { try { - const opts: { term: string; fields: Array } = { + const opts: FindQuery = { term: searchTerm, fields: ['title'] }; From 3ce84afc696a0fe03f0002919d07f7cce0ff2c0b Mon Sep 17 00:00:00 2001 From: Katarzyna Kita Date: Tue, 13 Feb 2024 01:14:41 +0100 Subject: [PATCH 22/22] Changed code blocks order --- .../info-drawer/src/tests/general.spec.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/e2e/playwright/info-drawer/src/tests/general.spec.ts b/e2e/playwright/info-drawer/src/tests/general.spec.ts index 9e0a6debd8..5e61d1cc4a 100644 --- a/e2e/playwright/info-drawer/src/tests/general.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/general.spec.ts @@ -26,18 +26,17 @@ import { expect } from '@playwright/test'; import { ApiClientFactory, Utils, test, TrashcanApi, NodesApi, FileActionsApi } from '@alfresco/playwright-shared'; test.describe('Info Drawer - General', () => { - let nodesApi: NodesApi; - let trashcanApi: TrashcanApi; let fileActionsApi: FileActionsApi; + let trashcanApi: TrashcanApi; + let nodesApi: NodesApi; const username = `user1-${Utils.random()}`; - test.afterAll(async () => { + test.beforeEach(async ({ loginPage }) => { try { - await nodesApi.deleteCurrentUserNodes(); - await trashcanApi.emptyTrashcan(); + await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); } catch (error) { - console.error(`afterAll failed: ${error}`); + console.error(`beforeEach failed: ${error}`); } }); @@ -46,19 +45,20 @@ test.describe('Info Drawer - General', () => { const apiClientFactory = new ApiClientFactory(); await apiClientFactory.setUpAcaBackend('admin'); await apiClientFactory.createUser({ username }); - nodesApi = await NodesApi.initialize(username, username); - trashcanApi = await TrashcanApi.initialize(username, username); fileActionsApi = await FileActionsApi.initialize(username, username); + trashcanApi = await TrashcanApi.initialize(username, username); + nodesApi = await NodesApi.initialize(username, username); } catch (error) { console.error(`beforeAll failed: ${error}`); } }); - test.beforeEach(async ({ loginPage }) => { + test.afterAll(async () => { try { - await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true }); + await trashcanApi.emptyTrashcan(); + await nodesApi.deleteCurrentUserNodes(); } catch (error) { - console.error(`beforeEach failed: ${error}`); + console.error(`afterAll failed: ${error}`); } });