From 2765357ce4f6591f9e02e308ff6bbf2ea9f40ac6 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 7 Jul 2023 15:57:09 +0200 Subject: [PATCH 01/54] [ACS-511]-adding-library-tests --- .../actions/src/tests/create-library.spec.ts | 250 ++++++++++++++++++ .../src/fixtures/page-initialization.ts | 8 +- .../components/aca-header.component.ts | 1 + .../components/adf-info-drawer.component.ts | 36 +++ .../breadcrumb/breadcrumb.component.ts | 36 +++ .../components/breadcrumb/index.ts | 25 ++ .../dataTable/mat-menu.component.ts | 1 + .../dialogs/adf-library-dialog.component.ts | 62 +++++ .../page-objects/components/dialogs/index.ts | 2 + .../src/page-objects/components/index.ts | 2 + .../src/page-objects/pages/index.ts | 1 + .../page-objects/pages/my-libraries.page.ts | 44 +++ .../aca-playwright-shared/src/utils/index.ts | 1 + .../src/utils/library-errors.ts | 29 ++ 14 files changed, 496 insertions(+), 2 deletions(-) create mode 100644 e2e/playwright/actions/src/tests/create-library.spec.ts create mode 100644 projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts create mode 100644 projects/aca-playwright-shared/src/page-objects/components/breadcrumb/breadcrumb.component.ts create mode 100644 projects/aca-playwright-shared/src/page-objects/components/breadcrumb/index.ts create mode 100644 projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts create mode 100644 projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts create mode 100644 projects/aca-playwright-shared/src/utils/library-errors.ts diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts new file mode 100644 index 0000000000..9f379e5d70 --- /dev/null +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -0,0 +1,250 @@ +/*! + * 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 { expect } from '@playwright/test'; +import { getUserState, test } from '@alfresco/playwright-shared'; +import { libraryErrors } from '../../../../../projects/aca-playwright-shared/src/utils/library-errors'; + +test.use({ storageState: getUserState('hruser') }); +test.describe('Create Libraries ', () => { + let randomLibraryName: string; + let randomLibraryId: string; + let randomLibraryDescription: string; + const libraryDialogTitle = 'Create Library'; + const libraryNameLebel = 'Name *'; + const libraryIdLebel = 'Library ID *'; + const libraryDescriptionLebel = 'Description'; + const publicVisibility = 'Public'; + const moderatedVisibility = 'Moderated'; + const privateVisibility = 'Private'; + const deleteAction = 'Delete'; + + test.beforeEach(async ({ myLibrariesPage }) => { + randomLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; + randomLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; + randomLibraryDescription = `libraryDescription-${(Math.random() + 1).toString(36).substring(6)}`; + await myLibrariesPage.navigate(); + }); + + test('[C280024] Create Library dialog UI', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + + await expect(myLibrariesPage.libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.getLabelText(libraryDescriptionLebel)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.getLabelText(publicVisibility)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.getLabelText(publicVisibility)).toBeChecked(); + await expect(myLibrariesPage.libraryDialog.getLabelText(privateVisibility)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.getLabelText(moderatedVisibility)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.cancelButton).toBeEnabled(); + await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); + }); + + test('[C280025] Create a public library', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await expect(myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel)).toHaveValue(randomLibraryName); + await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(randomLibraryName); + await myLibrariesPage.libraryDialog.createButton.click(); + + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + + await myLibrariesPage.navigate(); + await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(myLibrariesPage.dataTable.getCellByColumnNameAndRowItem(randomLibraryName, publicVisibility)).toBeVisible(); + + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + }); + + test('[C289880] Create a moderated library', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, moderatedVisibility); + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + + await myLibrariesPage.navigate(); + await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(myLibrariesPage.dataTable.getCellByColumnNameAndRowItem(randomLibraryName, moderatedVisibility)).toBeVisible(); + + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + }); + + test('[C289881] Create a private library', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, privateVisibility); + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + + await myLibrariesPage.navigate(); + await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(myLibrariesPage.dataTable.getCellByColumnNameAndRowItem(randomLibraryName, privateVisibility)).toBeVisible(); + + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + }); + + test('[C289882] Create a library with a given ID and description', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, randomLibraryDescription); + + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + + await myLibrariesPage.navigate(); + await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect( + myLibrariesPage.dataTable.getCellLinkByName(randomLibraryName).and(myLibrariesPage.page.getByTitle(randomLibraryDescription)) + ).toBeVisible(); + + await myLibrariesPage.dataTable.getRowByName(randomLibraryName).click(); + await myLibrariesPage.acaHeader.viewDetails.click(); + await expect(myLibrariesPage.viewDetails.getFieldData('Name').and(myLibrariesPage.viewDetails.getFieldData(randomLibraryName))).toBeVisible(); + await expect(myLibrariesPage.viewDetails.getFieldData('Library ID').and(myLibrariesPage.viewDetails.getFieldData(randomLibraryId))).toBeVisible(); + await expect( + myLibrariesPage.viewDetails.getFieldData('Visibility').and(myLibrariesPage.viewDetails.getFieldData(publicVisibility)) + ).toBeVisible(); + await expect( + myLibrariesPage.viewDetails.getFieldData(libraryDescriptionLebel).and(myLibrariesPage.viewDetails.getFieldData(randomLibraryDescription)) + ).toBeVisible(); + + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + }); + + test('[C280027] Duplicate library ID', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId); + + await myLibrariesPage.navigate(); + // duplicate library id + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName + '2'); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(randomLibraryId); + + await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); + await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.libraryIdIsNotAvailable)).toBeVisible(); + + await myLibrariesPage.libraryDialog.cancelButton.click(); + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + }); + + test('[C280028] Create library using the ID of a library from the Trashcan', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId); + + await myLibrariesPage.navigate(); + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + // library id from the trashcan + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName + '2'); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(randomLibraryId); + + await expect(myLibrariesPage.libraryDialog.createButton).toBeEnabled(); + await myLibrariesPage.libraryDialog.createButton.click(); + await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); + await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.libraryIdIsAlreadyUsed)).toBeVisible(); + + await myLibrariesPage.libraryDialog.cancelButton.click(); + }); + + test('[C280029] Cancel button', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await expect(myLibrariesPage.libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await myLibrariesPage.libraryDialog.cancelButton.click(); + + await expect(myLibrariesPage.libraryDialog.getDialogTitle(libraryDialogTitle)).toBeHidden(); + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toHaveCount(0); + await expect(myLibrariesPage.dataTable.getRowByName(randomLibraryName)).toHaveCount(0); + }); + + test('[C280026] Library ID cannot contain special characters', async ({ myLibrariesPage }) => { + const idsWithSpecialChars = [ + 'a!a', + 'a@a', + 'a#a', + 'a%a', + 'a^a', + 'a&a', + 'a*a', + 'a(a', + 'a)a', + 'a"a', + 'aa', + `a\\a`, + 'a/a', + 'a?a', + 'a:a', + 'a|a' + ]; + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + + for (const specialLibraryId of idsWithSpecialChars) { + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); + await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); + await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.useNumbersAndLettersOnly)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); + } + + await myLibrariesPage.libraryDialog.cancelButton.click(); + }); + + test('[C280030] Create 2 libraries with same name but different IDs', async ({ myLibrariesPage }) => { + const libraryName = randomLibraryName + ' (' + randomLibraryId + ')'; + const libraryName2 = randomLibraryName + ' (' + randomLibraryId + '2)'; + + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId); + await myLibrariesPage.navigate(); + + // duplicate library name but different id + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId + '2'); + + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + + await myLibrariesPage.navigate(); + await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(libraryName); + await expect(myLibrariesPage.dataTable.getRowByName(libraryName)).toBeVisible(); + await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(libraryName2); + await expect(myLibrariesPage.dataTable.getRowByName(libraryName2)).toBeVisible(); + + await myLibrariesPage.dataTable.performActionFromExpandableMenu(libraryName2, deleteAction); + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + }); +}); diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index b9a701c7c0..3a9367a091 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -24,11 +24,12 @@ import { test as base } from '@playwright/test'; -import { ApiClientFactory, NodesPage, PersonalFilesPage } from '../'; +import { ApiClientFactory, MyLibrariesPage, NodesPage, PersonalFilesPage } from '../'; interface Pages { personalFiles: PersonalFilesPage; nodesPage: NodesPage; + myLibrariesPage: MyLibrariesPage; } interface Api { @@ -47,5 +48,8 @@ export const test = base.extend({ const apiClient = new ApiClientFactory(); await apiClient.setUpAcaBackend('admin'); await use(apiClient); - } + }, + myLibrariesPage: async ({ page }, use) => { + await use(new MyLibrariesPage(page)); + }, }); diff --git a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts index dc8c10ee4e..141c8ff09c 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts @@ -28,6 +28,7 @@ export class AcaHeader extends BaseComponent { private static rootElement = 'adf-toolbar'; public createButton = this.getChild('[id="app.toolbar.create"]'); + public viewDetails = this.getChild('[title="View Details"]'); constructor(page: Page) { super(page, AcaHeader.rootElement); 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 new file mode 100644 index 0000000000..71ad3e3aa8 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts @@ -0,0 +1,36 @@ +/*! + * 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 } from '@playwright/test'; + +export class AdfInfoDrawerComponent extends BaseComponent { + private static rootElement = 'adf-info-drawer'; + + constructor(page: Page) { + super(page, AdfInfoDrawerComponent.rootElement); + } + + public getFieldData = (labelText: string) => this.getChild('.mat-form-field-wrapper', { hasText: labelText }); +} diff --git a/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/breadcrumb.component.ts b/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/breadcrumb.component.ts new file mode 100644 index 0000000000..2b88148f10 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/breadcrumb.component.ts @@ -0,0 +1,36 @@ +/*! + * 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 } from '@playwright/test'; + +export class AdfBreadcrumbComponent extends BaseComponent { + private static rootElement = 'adf-breadcrumb'; + + constructor(page: Page) { + super(page, AdfBreadcrumbComponent.rootElement); + } + + public getBreadcrumbItem = (text: string) => this.getChild('.adf-breadcrumb-item', { hasText: text }); +} diff --git a/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/index.ts b/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/index.ts new file mode 100644 index 0000000000..0d88c7dea3 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/index.ts @@ -0,0 +1,25 @@ +/*! + * 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 . + */ + +export * from './breadcrumb.component'; diff --git a/projects/aca-playwright-shared/src/page-objects/components/dataTable/mat-menu.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dataTable/mat-menu.component.ts index 82c4669068..a38e78e0ee 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dataTable/mat-menu.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dataTable/mat-menu.component.ts @@ -35,5 +35,6 @@ export class MatMenuComponent extends BaseComponent { public getMenuItemsLocator = this.getChild('button'); public getMenuItemTextLocator = this.getChild('[data-automation-id="menu-item-title"]'); public createFolder = this.getChild('[id="app.create.folder"]'); + public createLibrary = this.getChild('[id="app.create.library"]'); public getButtonByText = (text: string) => this.getChild('button', { hasText: text }); } diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts new file mode 100644 index 0000000000..e6ab268af1 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts @@ -0,0 +1,62 @@ +/*! + * 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 } from '@playwright/test'; + +export class AdfLibraryDialogComponent extends BaseComponent { + private static rootElement = 'adf-library-dialog'; + + public createButton = this.getChild('[data-automation-id="create-library-id"]'); + public cancelButton = this.getChild('[data-automation-id="cancel-library-id"]'); + + constructor(page: Page) { + super(page, AdfLibraryDialogComponent.rootElement); + } + + public getLabelText = (text: string) => this.getChild('label', { hasText: text }); + public getDialogTitle = (text: string) => this.getChild('.mat-dialog-title', { hasText: text }); + public getMatError = (text: string) => this.getChild('.mat-error', { hasText: text }); + + /** + * This method is used when we want to fill in Create Library Dialog and choose Create button + * + * @param nameInput input for the Name field + * @param libraryIdInput input for Library ID field + * @param descriptionInput input for Description field + * @param visibility visibility of the library + */ + async createLibraryWithNameAndId(nameInput: string, libraryIdInput: string, descriptionInput?: string, visibility?: string): Promise { + await this.getLabelText('Name *').fill(nameInput); + await this.getLabelText('Library ID *').clear(); + await this.getLabelText('Library ID *').fill(libraryIdInput); + if (descriptionInput) { + await this.getLabelText('Description').fill(descriptionInput); + } + if (visibility) { + await this.getLabelText(visibility).click(); + } + await this.createButton.click(); + } +} diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/index.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/index.ts index f659ffb7d3..1177660266 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dialogs/index.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/index.ts @@ -23,3 +23,5 @@ */ export * from './adf-folder-dialog.component'; +export * from './adf-library-dialog.component'; + diff --git a/projects/aca-playwright-shared/src/page-objects/components/index.ts b/projects/aca-playwright-shared/src/page-objects/components/index.ts index 2286fc7061..96c444c8c2 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/index.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/index.ts @@ -31,4 +31,6 @@ export * from './spinner.component'; export * from './actions-dropdown.component'; export * from './conditions.component'; export * from './pagination.component'; +export * from './breadcrumb'; +export * from './adf-info-drawer.component'; diff --git a/projects/aca-playwright-shared/src/page-objects/pages/index.ts b/projects/aca-playwright-shared/src/page-objects/pages/index.ts index c1d1ae1c15..cd4830c453 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/index.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/index.ts @@ -26,3 +26,4 @@ export * from './base.page'; export * from './login.page'; export * from './nodes.page'; export * from './personal-files.page'; +export * from './my-libraries.page'; diff --git a/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts new file mode 100644 index 0000000000..d94e755f3b --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts @@ -0,0 +1,44 @@ +/*! + * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. + * + * Alfresco Example Content Application + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * from Hyland Software. If not, see . + */ + + +import { Page } from '@playwright/test'; +import { BasePage } from './base.page'; +import { AcaHeader } from '../components/aca-header.component'; +import { AdfBreadcrumbComponent, AdfInfoDrawerComponent, AdfLibraryDialogComponent, DataTableComponent, MatMenuComponent } from '../components'; + +export class MyLibrariesPage extends BasePage { + private static pageUrl = 'libraries'; + + constructor(page: Page) { + super(page, MyLibrariesPage.pageUrl); + } + public acaHeader = new AcaHeader(this.page); + public matMenu = new MatMenuComponent(this.page); + public libraryDialog = new AdfLibraryDialogComponent(this.page); + public dataTable = new DataTableComponent(this.page); + public breadcrumb = new AdfBreadcrumbComponent(this.page); + public viewDetails = new AdfInfoDrawerComponent (this.page); + +} diff --git a/projects/aca-playwright-shared/src/utils/index.ts b/projects/aca-playwright-shared/src/utils/index.ts index f3bdc9b5fb..cb79e01dc8 100644 --- a/projects/aca-playwright-shared/src/utils/index.ts +++ b/projects/aca-playwright-shared/src/utils/index.ts @@ -27,3 +27,4 @@ export * from './timeouts'; export * from './exclude-tests'; export * from './state-helper'; export * from './folder-errors'; +export * from './library-errors'; diff --git a/projects/aca-playwright-shared/src/utils/library-errors.ts b/projects/aca-playwright-shared/src/utils/library-errors.ts new file mode 100644 index 0000000000..c0b5648ad5 --- /dev/null +++ b/projects/aca-playwright-shared/src/utils/library-errors.ts @@ -0,0 +1,29 @@ +/*! + * 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 . + */ + +export const libraryErrors = { + libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID`, + libraryIdIsAlreadyUsed: `This Library ID is already used. Check the trashcan.`, + useNumbersAndLettersOnly: `Use numbers and letters only` +} From f9bc90abc8ee9719f2ceaf890d7493316207bbbb Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 7 Jul 2023 19:40:18 +0200 Subject: [PATCH 02/54] updating tests and adding before and after all --- .../actions/src/tests/create-library.spec.ts | 74 +++++++++---------- .../src/utils/library-errors.ts | 2 +- 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index 9f379e5d70..c5fc881c7a 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -23,11 +23,13 @@ */ import { expect } from '@playwright/test'; -import { getUserState, test } from '@alfresco/playwright-shared'; +import { ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; import { libraryErrors } from '../../../../../projects/aca-playwright-shared/src/utils/library-errors'; +import { SiteBodyCreate } from '@alfresco/js-api'; test.use({ storageState: getUserState('hruser') }); test.describe('Create Libraries ', () => { + const apiClientFactory = new ApiClientFactory(); let randomLibraryName: string; let randomLibraryId: string; let randomLibraryDescription: string; @@ -40,6 +42,22 @@ test.describe('Create Libraries ', () => { const privateVisibility = 'Private'; const deleteAction = 'Delete'; + const commonLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; + const commonLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; + const commonTrashLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; + const commonTrashLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; + + test.beforeAll(async () => { + await apiClientFactory.setUpAcaBackend('hruser'); + await apiClientFactory.sites.createSite({ id: commonLibraryId, title: commonLibraryName, visibility: SiteBodyCreate.VisibilityEnum.PUBLIC }); + await apiClientFactory.sites.createSite({ + id: commonTrashLibraryId, + title: commonTrashLibraryName, + visibility: SiteBodyCreate.VisibilityEnum.PUBLIC + }); + await apiClientFactory.sites.deleteSite(commonTrashLibraryId); + }); + test.beforeEach(async ({ myLibrariesPage }) => { randomLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; randomLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; @@ -47,6 +65,10 @@ test.describe('Create Libraries ', () => { await myLibrariesPage.navigate(); }); + test.afterAll(async () => { + await apiClientFactory.sites.deleteSite(commonLibraryId, { permanent: true }); + }); + test('[C280024] Create Library dialog UI', async ({ myLibrariesPage }) => { await myLibrariesPage.acaHeader.createButton.click(); await myLibrariesPage.matMenu.createLibrary.click(); @@ -70,7 +92,6 @@ test.describe('Create Libraries ', () => { await expect(myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel)).toHaveValue(randomLibraryName); await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(randomLibraryName); await myLibrariesPage.libraryDialog.createButton.click(); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); @@ -110,7 +131,6 @@ test.describe('Create Libraries ', () => { await myLibrariesPage.acaHeader.createButton.click(); await myLibrariesPage.matMenu.createLibrary.click(); await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, randomLibraryDescription); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); @@ -118,7 +138,6 @@ test.describe('Create Libraries ', () => { await expect( myLibrariesPage.dataTable.getCellLinkByName(randomLibraryName).and(myLibrariesPage.page.getByTitle(randomLibraryDescription)) ).toBeVisible(); - await myLibrariesPage.dataTable.getRowByName(randomLibraryName).click(); await myLibrariesPage.acaHeader.viewDetails.click(); await expect(myLibrariesPage.viewDetails.getFieldData('Name').and(myLibrariesPage.viewDetails.getFieldData(randomLibraryName))).toBeVisible(); @@ -130,49 +149,31 @@ test.describe('Create Libraries ', () => { myLibrariesPage.viewDetails.getFieldData(libraryDescriptionLebel).and(myLibrariesPage.viewDetails.getFieldData(randomLibraryDescription)) ).toBeVisible(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + await apiClientFactory.sites.deleteSite(randomLibraryId, { permanent: true }); }); test('[C280027] Duplicate library ID', async ({ myLibrariesPage }) => { await myLibrariesPage.acaHeader.createButton.click(); await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId); - - await myLibrariesPage.navigate(); - // duplicate library id - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName + '2'); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(randomLibraryId); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(commonLibraryId); await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.libraryIdIsNotAvailable)).toBeVisible(); - - await myLibrariesPage.libraryDialog.cancelButton.click(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); }); test('[C280028] Create library using the ID of a library from the Trashcan', async ({ myLibrariesPage }) => { await myLibrariesPage.acaHeader.createButton.click(); await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId); - - await myLibrariesPage.navigate(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); - // library id from the trashcan - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName + '2'); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(randomLibraryId); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(commonTrashLibraryId); await expect(myLibrariesPage.libraryDialog.createButton).toBeEnabled(); await myLibrariesPage.libraryDialog.createButton.click(); await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.libraryIdIsAlreadyUsed)).toBeVisible(); - - await myLibrariesPage.libraryDialog.cancelButton.click(); }); test('[C280029] Cancel button', async ({ myLibrariesPage }) => { @@ -218,25 +219,17 @@ test.describe('Create Libraries ', () => { await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.useNumbersAndLettersOnly)).toBeVisible(); await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); } - - await myLibrariesPage.libraryDialog.cancelButton.click(); }); test('[C280030] Create 2 libraries with same name but different IDs', async ({ myLibrariesPage }) => { - const libraryName = randomLibraryName + ' (' + randomLibraryId + ')'; - const libraryName2 = randomLibraryName + ' (' + randomLibraryId + '2)'; - - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId); - await myLibrariesPage.navigate(); + const libraryName = commonLibraryName + ' (' + commonLibraryId + ')'; + const libraryName2 = commonLibraryName + ' (' + randomLibraryId + ')'; - // duplicate library name but different id await myLibrariesPage.acaHeader.createButton.click(); await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId + '2'); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(commonLibraryName, randomLibraryId); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(commonLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(libraryName); @@ -244,7 +237,6 @@ test.describe('Create Libraries ', () => { await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(libraryName2); await expect(myLibrariesPage.dataTable.getRowByName(libraryName2)).toBeVisible(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(libraryName2, deleteAction); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + await apiClientFactory.sites.deleteSite(randomLibraryId, { permanent: true }); }); }); diff --git a/projects/aca-playwright-shared/src/utils/library-errors.ts b/projects/aca-playwright-shared/src/utils/library-errors.ts index c0b5648ad5..57d4619a41 100644 --- a/projects/aca-playwright-shared/src/utils/library-errors.ts +++ b/projects/aca-playwright-shared/src/utils/library-errors.ts @@ -23,7 +23,7 @@ */ export const libraryErrors = { - libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID`, + libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID.`, libraryIdIsAlreadyUsed: `This Library ID is already used. Check the trashcan.`, useNumbersAndLettersOnly: `Use numbers and letters only` } From e7943288f851a062275e0ac2a490046c3eb9af3c Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Mon, 10 Jul 2023 09:16:35 +0200 Subject: [PATCH 03/54] spinner timeouts update --- .../src/page-objects/components/base.component.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/projects/aca-playwright-shared/src/page-objects/components/base.component.ts b/projects/aca-playwright-shared/src/page-objects/components/base.component.ts index 3e62d41398..62919a0fdb 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/base.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/base.component.ts @@ -24,6 +24,7 @@ import { Locator, Page } from '@playwright/test'; import { PlaywrightBase } from '../playwright-base'; +import { timeouts } from '../../utils'; export abstract class BaseComponent extends PlaywrightBase { private readonly rootElement: string; @@ -55,8 +56,8 @@ export abstract class BaseComponent extends PlaywrightBase { async spinnerWaitForReload(): Promise { try { - await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: 2000 }); - await this.page.locator('mat-progress-spinner').waitFor({ state: 'detached', timeout: 2000 }); + await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: timeouts.short }); + await this.page.locator('mat-progress-spinner').waitFor({ state: 'detached', timeout: timeouts.normal }); } catch (e) { this.logger.info('Spinner was not present'); } From 25ebd0b3c8381c880a2066ef99a3450f86055baf Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Mon, 10 Jul 2023 13:16:55 +0200 Subject: [PATCH 04/54] updating import statement --- e2e/playwright/actions/src/tests/create-library.spec.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index c5fc881c7a..e8efbcebb3 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -23,8 +23,7 @@ */ import { expect } from '@playwright/test'; -import { ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; -import { libraryErrors } from '../../../../../projects/aca-playwright-shared/src/utils/library-errors'; +import { libraryErrors, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; test.use({ storageState: getUserState('hruser') }); From e74602af9fa550f48d5ba8a58ec84aa5fe75f7b1 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Mon, 10 Jul 2023 22:01:13 +0200 Subject: [PATCH 05/54] update error locator --- .../components/dialogs/adf-library-dialog.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts index e6ab268af1..8b84b1c340 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts @@ -37,7 +37,7 @@ export class AdfLibraryDialogComponent extends BaseComponent { public getLabelText = (text: string) => this.getChild('label', { hasText: text }); public getDialogTitle = (text: string) => this.getChild('.mat-dialog-title', { hasText: text }); - public getMatError = (text: string) => this.getChild('.mat-error', { hasText: text }); + public getMatError = (text: string) => this.getChild('mat-error', { hasText: text }); /** * This method is used when we want to fill in Create Library Dialog and choose Create button From 0407311434aabdbcfbbeeae5208b029ab8310ee3 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 09:16:34 +0200 Subject: [PATCH 06/54] adding random method in general utils --- .../actions/src/tests/create-library.spec.ts | 15 +++++---- .../src/utils/general-utils.ts | 33 +++++++++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 projects/aca-playwright-shared/src/utils/general-utils.ts diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index e8efbcebb3..8dc21679aa 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -25,6 +25,7 @@ import { expect } from '@playwright/test'; import { libraryErrors, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; +import { GeneralUtils } from '../../../../../projects/aca-playwright-shared/src/utils/general-utils'; test.use({ storageState: getUserState('hruser') }); test.describe('Create Libraries ', () => { @@ -41,10 +42,10 @@ test.describe('Create Libraries ', () => { const privateVisibility = 'Private'; const deleteAction = 'Delete'; - const commonLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; - const commonLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; - const commonTrashLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; - const commonTrashLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; + const commonLibraryName = `playwright-library-${GeneralUtils.random()}`; + const commonLibraryId = `libraryId-${GeneralUtils.random()}`; + const commonTrashLibraryName = `playwright-library-${GeneralUtils.random()}`; + const commonTrashLibraryId = `libraryId-${GeneralUtils.random()}`; test.beforeAll(async () => { await apiClientFactory.setUpAcaBackend('hruser'); @@ -58,9 +59,9 @@ test.describe('Create Libraries ', () => { }); test.beforeEach(async ({ myLibrariesPage }) => { - randomLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; - randomLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; - randomLibraryDescription = `libraryDescription-${(Math.random() + 1).toString(36).substring(6)}`; + randomLibraryName = `playwright-library-${GeneralUtils.random()}`; + randomLibraryId = `libraryId-${GeneralUtils.random()}`; + randomLibraryDescription = `libraryDescription-${GeneralUtils.random()}`; await myLibrariesPage.navigate(); }); diff --git a/projects/aca-playwright-shared/src/utils/general-utils.ts b/projects/aca-playwright-shared/src/utils/general-utils.ts new file mode 100644 index 0000000000..9e30d8eea0 --- /dev/null +++ b/projects/aca-playwright-shared/src/utils/general-utils.ts @@ -0,0 +1,33 @@ +/*! + * 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 . + */ + + +export class GeneralUtils { + + + static random(): string { + return (Math.random() + 1).toString(36).substring(6); + } + +} From 836e31c0c8166ad23e9bf2e7cb90dc3fe972626e Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Tue, 11 Jul 2023 08:39:17 +0100 Subject: [PATCH 07/54] [ACA-4715] break dependency on envsubst (#3325) * remove BPM host * break dependency on envsubst * remove prebuild script * cleanup package.json --- .github/actions/before-e2e/action.yml | 14 +- .github/actions/run-e2e-playwright/action.yml | 6 - .github/actions/run-e2e/action.yml | 6 - .github/workflows/pull-request.yml | 2 +- .github/workflows/release.yml | 3 +- Dockerfile | 3 - README.md | 2 +- app/project.json | 6 +- app/proxy.conf.js | 6 +- .../{app.config.json.tpl => app.config.json} | 6 +- docker/run.sh | 4 - docs/getting-started/building-from-source.md | 2 +- package-lock.json | 174 ------------------ package.json | 8 +- .../src/api/api-client-factory.ts | 6 +- protractor.conf.js | 4 +- 16 files changed, 21 insertions(+), 231 deletions(-) rename app/src/{app.config.json.tpl => app.config.json} (99%) diff --git a/.github/actions/before-e2e/action.yml b/.github/actions/before-e2e/action.yml index e6a4edc188..aa5f87fab1 100644 --- a/.github/actions/before-e2e/action.yml +++ b/.github/actions/before-e2e/action.yml @@ -32,7 +32,7 @@ runs: steps: - name: Check content UP shell: bash - run: ./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host $APP_CONFIG_ECM_HOST -u $ADMIN_EMAIL -p $ADMIN_PASSWORD || exit 1 + run: ./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host $BASE_URL -u $ADMIN_EMAIL -p $ADMIN_PASSWORD || exit 1 - name: Download artifacts uses: ./.github/actions/download-job-artifact @@ -43,18 +43,6 @@ runs: aws-secret-access-key: ${{ inputs.aws-secret-access-key }} aws-region: ${{ inputs.aws-region }} - - name: Replace variables in app.config.json - shell: bash - run: | - APP_CONFIG_FILE_PATH="${{ inputs.to }}/app.config.json" - npx envsub --all $APP_CONFIG_FILE_PATH $APP_CONFIG_FILE_PATH || exit 1 - echo -n " \_ Validating replaced config file ... "; - npx ajv validate -s ./node_modules/@alfresco/adf-core/app.config.schema.json -d $APP_CONFIG_FILE_PATH --errors=text --verbose || exit 4 - if grep -E -q '\$\{[A-Z0-9_]*\}' $APP_CONFIG_FILE_PATH; then - echo -e "\e[31m \_ ERROR: Variables are still present in the app.config.json file. Some of them might not have default value set.\e[0m"; - exit 5; - fi - - name: Update webdriver-manager shell: bash run: | diff --git a/.github/actions/run-e2e-playwright/action.yml b/.github/actions/run-e2e-playwright/action.yml index 4706f315ec..30a5fd9473 100644 --- a/.github/actions/run-e2e-playwright/action.yml +++ b/.github/actions/run-e2e-playwright/action.yml @@ -22,12 +22,6 @@ runs: - name: Setup and run with options shell: bash run: | - # npx http-server -c-1 $CONTENT_CE_DIST_PATH -p 4200 > /dev/null &\ - - { - echo "APP_CONFIG_ECM_HOST={protocol}//{hostname}{:port}" - } >> .env - npm start > /dev/null &\ echo "Running playwright tests with options ${{ inputs.options }}" diff --git a/.github/actions/run-e2e/action.yml b/.github/actions/run-e2e/action.yml index 91acd6c465..3684275bc9 100644 --- a/.github/actions/run-e2e/action.yml +++ b/.github/actions/run-e2e/action.yml @@ -23,12 +23,6 @@ runs: shell: bash run: | ./node_modules/.bin/tsc -p "./e2e/protractor/$E2E_TSCONFIG" || exit 1; - # npx http-server -c-1 $CONTENT_CE_DIST_PATH -p 4200 > /dev/null &\ - - { - echo "APP_CONFIG_ECM_HOST={protocol}//{hostname}{:port}" - } >> .env - npm start > /dev/null &\ if [ ${{ inputs.test-runner }} == "playwright" ]; then diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 8e48464deb..9ed5968679 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,7 +10,7 @@ concurrency: cancel-in-progress: true env: - APP_CONFIG_ECM_HOST: ${{ secrets.PIPELINE_ENV_URL }} + BASE_URL: ${{ secrets.PIPELINE_ENV_URL }} ADMIN_EMAIL: ${{ secrets.PIPELINE_ADMIN_USERNAME }} ADMIN_PASSWORD: ${{ secrets.PIPELINE_ADMIN_PASSWORD }} HR_USER: ${{ secrets.HR_USER }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf9d39a9e1..565bdf73d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ on: - develop env: - APP_CONFIG_ECM_HOST: ${{ secrets.PIPELINE_ENV_URL }} + BASE_URL: ${{ secrets.PIPELINE_ENV_URL }} ADMIN_EMAIL: ${{ secrets.PIPELINE_ADMIN_USERNAME }} ADMIN_PASSWORD: ${{ secrets.PIPELINE_ADMIN_PASSWORD }} AWS_REGION: "eu-west-2" @@ -22,7 +22,6 @@ env: PLAYWRIGHT_E2E_HOST: ${{ secrets.PLAYWRIGHT_E2E_HOST }} NPM_REGISTRY_ADDRESS: ${{ secrets.NPM_REGISTRY_ADDRESS }} - jobs: publish-docker-registry: name: "Publish to Quay" diff --git a/Dockerfile b/Dockerfile index 3871207c26..63d033de38 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,9 +18,6 @@ USER 101 ARG PROJECT_NAME -ENV APP_CONFIG_BPM_HOST="{protocol}//{hostname}{:port}" -ENV APP_CONFIG_ECM_HOST="{protocol}//{hostname}{:port}" - COPY docker/default.conf.template /etc/nginx/templates/ COPY dist/$PROJECT_NAME /usr/share/nginx/html/ diff --git a/README.md b/README.md index 36ae04780d..92ffaeab0f 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Please refer to the public [documentation](https://alfresco-content-app.netlify. Create an `.env` file in the project root folder with the following content ```yml -APP_CONFIG_ECM_HOST="" +BASE_URL="" ``` Where `` is the address of the ACS. diff --git a/app/project.json b/app/project.json index e93f66818a..66f72c684c 100644 --- a/app/project.json +++ b/app/project.json @@ -33,9 +33,9 @@ "app/src/assets", "app/src/favicon-96x96.png", { - "input": "app/.tmp", - "output": "/", - "glob": "app.config.json" + "glob": "app.config.json", + "input": "app/src", + "output": "/" }, { "glob": "**/*", diff --git a/app/proxy.conf.js b/app/proxy.conf.js index be998bbbaf..cd22e0f55a 100644 --- a/app/proxy.conf.js +++ b/app/proxy.conf.js @@ -1,10 +1,10 @@ require('@alfresco/adf-cli/tooling').dotenvConfig({ path: process.env.ENV_FILE }); -const APP_CONFIG_ECM_HOST = process.env.APP_CONFIG_ECM_HOST; +const { BASE_URL } = process.env; module.exports = { "/alfresco": { - "target": APP_CONFIG_ECM_HOST, + "target": BASE_URL, "secure": false, "pathRewrite": { "^/alfresco/alfresco": "" @@ -13,7 +13,7 @@ module.exports = { 'logLevel': 'debug', onProxyReq: function(request) { if(request["method"] !== "GET") - request.setHeader("origin", APP_CONFIG_ECM_HOST); + request.setHeader("origin", BASE_URL); }, // workaround for REPO-2260 onProxyRes: function (proxyRes) { diff --git a/app/src/app.config.json.tpl b/app/src/app.config.json similarity index 99% rename from app/src/app.config.json.tpl rename to app/src/app.config.json index 8a65d75fc4..49018c02ca 100644 --- a/app/src/app.config.json.tpl +++ b/app/src/app.config.json @@ -1,8 +1,8 @@ { "$schema": "../node_modules/@alfresco/adf-core/app.config.schema.json", - "ecmHost": "${APP_CONFIG_ECM_HOST}", - "aosHost": "${APP_CONFIG_ECM_HOST}/alfresco/aos", - "baseShareUrl": "${APP_CONFIG_ECM_HOST}/#/preview/s", + "ecmHost": "{protocol}//{hostname}{:port}", + "aosHost": "{protocol}//{hostname}{:port}/alfresco/aos", + "baseShareUrl": "{protocol}//{hostname}{:port}/#/preview/s", "providers": "ECM", "authType": "BASIC", "loginRoute": "login", diff --git a/docker/run.sh b/docker/run.sh index 2098ff9601..0f4de1c542 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -3,10 +3,6 @@ set -e eval ALL_ARGUMENTS=("BASE_PATH" - "APP_BASE_SHARE_URL" - "APP_CONFIG_IDENTITY_HOST" - "APP_CONFIG_BPM_HOST" - "APP_CONFIG_ECM_HOST" ) ALL_ARGUMENTS_LENGTH=${#ALL_ARGUMENTS[@]} DOCKER_ARGS="" diff --git a/docs/getting-started/building-from-source.md b/docs/getting-started/building-from-source.md index 7bd1f379f2..01dcd79024 100644 --- a/docs/getting-started/building-from-source.md +++ b/docs/getting-started/building-from-source.md @@ -34,7 +34,7 @@ You need to set some environment variables to be able to run the local dev serve ```yml # App config settings -APP_CONFIG_ECM_HOST="" +BASE_URL="" ``` ## Proxy settings diff --git a/package-lock.json b/package-lock.json index fc9790d8c3..db2bee3825 100644 --- a/package-lock.json +++ b/package-lock.json @@ -76,7 +76,6 @@ "cypress": "^12.14.0", "dotenv": "8.2.0", "dotenv-expand": "^5.1.0", - "envsub": "^4.1.0", "eslint": "^8.42.0", "eslint-plugin-ban": "^1.6.0", "eslint-plugin-import": "2.27.5", @@ -13046,102 +13045,6 @@ "node": ">=6" } }, - "node_modules/envsub": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/envsub/-/envsub-4.1.0.tgz", - "integrity": "sha512-B44hta3xNFu6+zDhOha1TIrZkQHGDO3G5K8D2sJIkm/s3XyQjxWBGp1B+b/Y74Go1PqMP+cp8moPR4JullnD9Q==", - "dev": true, - "dependencies": { - "bluebird": "^3.7.2", - "chalk": "^3.0.0", - "commander": "^4.0.1", - "diff": "^4.0.1", - "handlebars": "^4.5.3", - "lodash": "^4.17.15", - "replace-last": "^1.2.6", - "string.prototype.matchall": "^4.0.8" - }, - "bin": { - "envsub": "bin/envsub.js", - "envsubh": "bin/envsubh.js" - } - }, - "node_modules/envsub/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/envsub/node_modules/chalk": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", - "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/envsub/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/envsub/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/envsub/node_modules/commander": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", - "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, - "node_modules/envsub/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/envsub/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/errno": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz", @@ -15857,36 +15760,6 @@ "integrity": "sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==", "dev": true }, - "node_modules/handlebars": { - "version": "4.7.7", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", - "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5", - "neo-async": "^2.6.0", - "source-map": "^0.6.1", - "wordwrap": "^1.0.0" - }, - "bin": { - "handlebars": "bin/handlebars" - }, - "engines": { - "node": ">=0.4.7" - }, - "optionalDependencies": { - "uglify-js": "^3.1.4" - } - }, - "node_modules/handlebars/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", @@ -26754,15 +26627,6 @@ "node": ">=0.10" } }, - "node_modules/replace-last": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/replace-last/-/replace-last-1.2.6.tgz", - "integrity": "sha512-Cj+MK38VtNu1S5J73mEZY3ciQb9dJajNq1Q8inP4dn/MhJMjHwoAF3Z3FjspwAEV9pfABl565MQucmrjOkty4g==", - "dev": true, - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -28201,25 +28065,6 @@ "node": ">=8" } }, - "node_modules/string.prototype.matchall": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.8.tgz", - "integrity": "sha512-6zOCOcJ+RJAQshcTvXPHoxoQGONa3e/Lqx90wUA+wEzX78sg5Bo+1tQo4N0pohS0erG9qtCqJDjNCQBjeWVxyg==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", - "get-intrinsic": "^1.1.3", - "has-symbols": "^1.0.3", - "internal-slot": "^1.0.3", - "regexp.prototype.flags": "^1.4.3", - "side-channel": "^1.0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/string.prototype.trim": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz", @@ -29669,19 +29514,6 @@ "node": "*" } }, - "node_modules/uglify-js": { - "version": "3.17.4", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", - "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==", - "dev": true, - "optional": true, - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -30628,12 +30460,6 @@ "node": ">=0.10.0" } }, - "node_modules/wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", - "dev": true - }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/package.json b/package.json index 8959a3ad7f..40423c505e 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,12 @@ { "name": "alfresco-content-app", "version": "4.1.0", - "commit": "", "license": "LGPL-3.0", "scripts": { "postinstall": "ngcc", "ng": "ng", - "validate-app-config": "ajv validate -s ./node_modules/@alfresco/adf-core/app.config.schema.json -d ./app/.tmp/app.config.json --errors=text --verbose", - "assemble-app-config": "envsub --env-file ./.env --env APP_CONFIG_ECM_HOST={protocol}//{hostname}{:port} --all ./app/src/app.config.json.tpl ./app/.tmp/app.config.json", - "prestart": "mkdir -p ./app/.tmp && npm run assemble-app-config && npm run validate-app-config", "start": "nx serve content-ce", - "start:prod": "npm run validate-app-config && node --max-old-space-size=8192 nx serve content-ce --configuration production", - "prebuild": "mkdir -p ./app/.tmp && cp ./app/src/app.config.json.tpl ./app/.tmp/app.config.json", + "start:prod": "node --max-old-space-size=8192 nx serve content-ce --configuration production", "build": "nx build content-ce", "build.release": "npm run build -- --configuration=production,release", "test": "nx test", @@ -104,7 +99,6 @@ "cypress": "^12.14.0", "dotenv": "8.2.0", "dotenv-expand": "^5.1.0", - "envsub": "^4.1.0", "eslint": "^8.42.0", "eslint-plugin-ban": "^1.6.0", "eslint-plugin-import": "2.27.5", 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 a848a00eb0..6147a78759 100644 --- a/projects/aca-playwright-shared/src/api/api-client-factory.ts +++ b/projects/aca-playwright-shared/src/api/api-client-factory.ts @@ -49,10 +49,12 @@ export interface AcaBackend { tearDown(): Promise; } +const { BASE_URL } = process.env; + const config = { authType: 'BASIC', - hostBpm: process.env.APP_CONFIG_BPM_HOST, - hostEcm: process.env.APP_CONFIG_ECM_HOST, + hostBpm: BASE_URL, + hostEcm: BASE_URL, provider: 'ECM', contextRoot: 'alfresco' }; diff --git a/protractor.conf.js b/protractor.conf.js index 5186a89326..31e28b1a23 100755 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -19,15 +19,15 @@ const width = 1366; const height = 768; const SAVE_SCREENSHOT = process.env.SAVE_SCREENSHOT === 'true'; -const APP_CONFIG_ECM_HOST = process.env.APP_CONFIG_ECM_HOST || 'http://localhost:8080'; const MAXINSTANCES = process.env.MAXINSTANCES || 1; const E2E_LOG_LEVEL = process.env.E2E_LOG_LEVEL || 'ERROR'; const E2E_TS_CONFIG_FOR_ADF = 'tsconfig.e2e.adf.json'; const LOCAL_ADF_OPTION = '--with-local-adf'; +const { BASE_URL } = process.env; const appConfig = { - hostEcm: APP_CONFIG_ECM_HOST, + hostEcm: BASE_URL || 'http://localhost:8080', providers: 'ECM', authType: 'BASIC' }; From 7320efaa32c9bbb5b6c7ab6af6decaa0de4be822 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 7 Jul 2023 15:57:09 +0200 Subject: [PATCH 08/54] [ACS-511]-adding-library-tests --- .../aca-playwright-shared/src/fixtures/page-initialization.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index 5c095039f4..db65e44b7d 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -24,7 +24,7 @@ import { test as base } from '@playwright/test'; -import { NodesPage, PersonalFilesPage } from '../'; +import {MyLibrariesPage, NodesPage, PersonalFilesPage} from '../'; interface Pages { personalFiles: PersonalFilesPage; @@ -41,5 +41,5 @@ export const test = base.extend({ }, myLibrariesPage: async ({ page }, use) => { await use(new MyLibrariesPage(page)); - } + }, }); From d43abff1c89b93ea50994dc3343ebaba1f7987c6 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 10:06:42 +0200 Subject: [PATCH 09/54] adding lost MyLibrariesPage import --- .../aca-playwright-shared/src/fixtures/page-initialization.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index db65e44b7d..493bfc831d 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -22,7 +22,6 @@ * from Hyland Software. If not, see . */ - import { test as base } from '@playwright/test'; import {MyLibrariesPage, NodesPage, PersonalFilesPage} from '../'; From 93092132427257a4a1b46b50cc04ee03bb4c7cb8 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 7 Jul 2023 15:57:09 +0200 Subject: [PATCH 10/54] rebase page initialization merge --- .../aca-playwright-shared/src/fixtures/page-initialization.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index 493bfc831d..fed7ed9b67 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -40,5 +40,5 @@ export const test = base.extend({ }, myLibrariesPage: async ({ page }, use) => { await use(new MyLibrariesPage(page)); - }, + } }); From b1724e738c62025ecad8e28235f094eab87367fe Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 7 Jul 2023 15:57:09 +0200 Subject: [PATCH 11/54] [ACS-511]-adding-library-tests --- .../aca-playwright-shared/src/fixtures/page-initialization.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index fed7ed9b67..493bfc831d 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -40,5 +40,5 @@ export const test = base.extend({ }, myLibrariesPage: async ({ page }, use) => { await use(new MyLibrariesPage(page)); - } + }, }); From 00340795ca7d3006bdbad28b411d2633fe11b47c Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 13:47:05 +0200 Subject: [PATCH 12/54] comma deleted --- .../aca-playwright-shared/src/fixtures/page-initialization.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index 493bfc831d..fed7ed9b67 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -40,5 +40,5 @@ export const test = base.extend({ }, myLibrariesPage: async ({ page }, use) => { await use(new MyLibrariesPage(page)); - }, + } }); From 4fe33dbd179934f852b31b90178d0a3a5c6bb24a Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 15:50:16 +0200 Subject: [PATCH 13/54] fix readability and indentation --- .../actions/src/tests/create-library.spec.ts | 213 ++++++++++-------- .../dialogs/adf-library-dialog.component.ts | 8 +- .../page-objects/pages/my-libraries.page.ts | 7 +- 3 files changed, 123 insertions(+), 105 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index 8dc21679aa..8d1e112208 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -70,125 +70,140 @@ test.describe('Create Libraries ', () => { }); test('[C280024] Create Library dialog UI', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - - await expect(myLibrariesPage.libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.getLabelText(libraryDescriptionLebel)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.getLabelText(publicVisibility)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.getLabelText(publicVisibility)).toBeChecked(); - await expect(myLibrariesPage.libraryDialog.getLabelText(privateVisibility)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.getLabelText(moderatedVisibility)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.cancelButton).toBeEnabled(); - await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); + const libraryDialog = myLibrariesPage.libraryDialog; + + await myLibrariesPage.selectCreateLibrary(); + + await expect(libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); + await expect(libraryDialog.getLabelText(libraryNameLebel)).toBeVisible(); + await expect(libraryDialog.getLabelText(libraryIdLebel)).toBeVisible(); + await expect(libraryDialog.getLabelText(libraryDescriptionLebel)).toBeVisible(); + await expect(libraryDialog.getLabelText(publicVisibility)).toBeVisible(); + await expect(libraryDialog.getLabelText(publicVisibility)).toBeChecked(); + await expect(libraryDialog.getLabelText(privateVisibility)).toBeVisible(); + await expect(libraryDialog.getLabelText(moderatedVisibility)).toBeVisible(); + await expect(libraryDialog.cancelButton).toBeEnabled(); + await expect(libraryDialog.createButton).toBeDisabled(); }); test('[C280025] Create a public library', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); - await expect(myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel)).toHaveValue(randomLibraryName); - await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(randomLibraryName); - await myLibrariesPage.libraryDialog.createButton.click(); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + const libraryDialog = myLibrariesPage.libraryDialog; + const libraryTable = myLibrariesPage.dataTable; + const libraryBreadcrumb = myLibrariesPage.breadcrumb; + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await expect(libraryDialog.getLabelText(libraryNameLebel)).toHaveValue(randomLibraryName); + await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(randomLibraryName); + await libraryDialog.createButton.click(); + await expect(libraryBreadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); - await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); - await expect(myLibrariesPage.dataTable.getCellByColumnNameAndRowItem(randomLibraryName, publicVisibility)).toBeVisible(); + await libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, publicVisibility)).toBeVisible(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + await libraryTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); }); test('[C289880] Create a moderated library', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, moderatedVisibility); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + const libraryDialog = myLibrariesPage.libraryDialog; + const libraryTable = myLibrariesPage.dataTable; + const libraryBreadcrumb = myLibrariesPage.breadcrumb; + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, moderatedVisibility); + await expect(libraryBreadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); - await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); - await expect(myLibrariesPage.dataTable.getCellByColumnNameAndRowItem(randomLibraryName, moderatedVisibility)).toBeVisible(); + await libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, moderatedVisibility)).toBeVisible(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + await libraryTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); }); test('[C289881] Create a private library', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, privateVisibility); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + const libraryDialog = myLibrariesPage.libraryDialog; + const libraryTable = myLibrariesPage.dataTable; + const libraryBreadcrumb = myLibrariesPage.breadcrumb; + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, privateVisibility); + await expect(libraryBreadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); - await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); - await expect(myLibrariesPage.dataTable.getCellByColumnNameAndRowItem(randomLibraryName, privateVisibility)).toBeVisible(); + await libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, privateVisibility)).toBeVisible(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + await libraryTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); }); test('[C289882] Create a library with a given ID and description', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, randomLibraryDescription); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + const libraryDialog = myLibrariesPage.libraryDialog; + const libraryTable = myLibrariesPage.dataTable; + const libraryBreadcrumb = myLibrariesPage.breadcrumb; + const libraryViewDetails = myLibrariesPage.acaHeader.viewDetails; + const libraryDetails = myLibrariesPage.libraryDetails; + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, randomLibraryDescription); + await expect(libraryBreadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); - await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); - await expect( - myLibrariesPage.dataTable.getCellLinkByName(randomLibraryName).and(myLibrariesPage.page.getByTitle(randomLibraryDescription)) - ).toBeVisible(); - await myLibrariesPage.dataTable.getRowByName(randomLibraryName).click(); - await myLibrariesPage.acaHeader.viewDetails.click(); - await expect(myLibrariesPage.viewDetails.getFieldData('Name').and(myLibrariesPage.viewDetails.getFieldData(randomLibraryName))).toBeVisible(); - await expect(myLibrariesPage.viewDetails.getFieldData('Library ID').and(myLibrariesPage.viewDetails.getFieldData(randomLibraryId))).toBeVisible(); - await expect( - myLibrariesPage.viewDetails.getFieldData('Visibility').and(myLibrariesPage.viewDetails.getFieldData(publicVisibility)) - ).toBeVisible(); - await expect( - myLibrariesPage.viewDetails.getFieldData(libraryDescriptionLebel).and(myLibrariesPage.viewDetails.getFieldData(randomLibraryDescription)) - ).toBeVisible(); + await libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(libraryTable.getCellLinkByName(randomLibraryName).and(myLibrariesPage.page.getByTitle(randomLibraryDescription))).toBeVisible(); + await libraryTable.getRowByName(randomLibraryName).click(); + await libraryViewDetails.click(); + await expect(libraryDetails.getFieldData('Name').and(libraryDetails.getFieldData(randomLibraryName))).toBeVisible(); + await expect(libraryDetails.getFieldData('Library ID').and(libraryDetails.getFieldData(randomLibraryId))).toBeVisible(); + await expect(libraryDetails.getFieldData('Visibility').and(libraryDetails.getFieldData(publicVisibility))).toBeVisible(); + await expect(libraryDetails.getFieldData(libraryDescriptionLebel).and(libraryDetails.getFieldData(randomLibraryDescription))).toBeVisible(); await apiClientFactory.sites.deleteSite(randomLibraryId, { permanent: true }); }); test('[C280027] Duplicate library ID', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(commonLibraryId); - - await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); - await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.libraryIdIsNotAvailable)).toBeVisible(); + const libraryDialog = myLibrariesPage.libraryDialog; + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await libraryDialog.getLabelText(libraryIdLebel).clear(); + await libraryDialog.getLabelText(libraryIdLebel).fill(commonLibraryId); + + await expect(libraryDialog.createButton).toBeDisabled(); + await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsNotAvailable)).toBeVisible(); }); test('[C280028] Create library using the ID of a library from the Trashcan', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(commonTrashLibraryId); - - await expect(myLibrariesPage.libraryDialog.createButton).toBeEnabled(); - await myLibrariesPage.libraryDialog.createButton.click(); - await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); - await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.libraryIdIsAlreadyUsed)).toBeVisible(); + const libraryDialog = myLibrariesPage.libraryDialog; + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await libraryDialog.getLabelText(libraryIdLebel).clear(); + await libraryDialog.getLabelText(libraryIdLebel).fill(commonTrashLibraryId); + + await expect(libraryDialog.createButton).toBeEnabled(); + await libraryDialog.createButton.click(); + await expect(libraryDialog.createButton).toBeDisabled(); + await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsAlreadyUsed)).toBeVisible(); }); test('[C280029] Cancel button', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await expect(myLibrariesPage.libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); - await myLibrariesPage.libraryDialog.cancelButton.click(); - - await expect(myLibrariesPage.libraryDialog.getDialogTitle(libraryDialogTitle)).toBeHidden(); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toHaveCount(0); - await expect(myLibrariesPage.dataTable.getRowByName(randomLibraryName)).toHaveCount(0); + const libraryDialog = myLibrariesPage.libraryDialog; + const libraryTable = myLibrariesPage.dataTable; + const libraryBreadcrumb = myLibrariesPage.breadcrumb; + + await myLibrariesPage.selectCreateLibrary(); + await expect(libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); + await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await libraryDialog.cancelButton.click(); + + await expect(libraryDialog.getDialogTitle(libraryDialogTitle)).toBeHidden(); + await expect(libraryBreadcrumb.getBreadcrumbItem(randomLibraryName)).toHaveCount(0); + await expect(libraryTable.getRowByName(randomLibraryName)).toHaveCount(0); }); test('[C280026] Library ID cannot contain special characters', async ({ myLibrariesPage }) => { + const libraryDialog = myLibrariesPage.libraryDialog; const idsWithSpecialChars = [ 'a!a', 'a@a', @@ -208,34 +223,36 @@ test.describe('Create Libraries ', () => { 'a:a', 'a|a' ]; - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); for (const specialLibraryId of idsWithSpecialChars) { - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); - await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); - await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.useNumbersAndLettersOnly)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); + await libraryDialog.getLabelText(libraryIdLebel).clear(); + await libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); + await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); + await expect(libraryDialog.getMatError(libraryErrors.useNumbersAndLettersOnly)).toBeVisible(); + await expect(libraryDialog.createButton).toBeDisabled(); } }); test('[C280030] Create 2 libraries with same name but different IDs', async ({ myLibrariesPage }) => { + const libraryDialog = myLibrariesPage.libraryDialog; + const libraryTable = myLibrariesPage.dataTable; + const libraryBreadcrumb = myLibrariesPage.breadcrumb; const libraryName = commonLibraryName + ' (' + commonLibraryId + ')'; const libraryName2 = commonLibraryName + ' (' + randomLibraryId + ')'; - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(commonLibraryName, randomLibraryId); + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.createLibraryWithNameAndId(commonLibraryName, randomLibraryId); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(commonLibraryName)).toBeVisible(); + await expect(libraryBreadcrumb.getBreadcrumbItem(commonLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); - await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(libraryName); - await expect(myLibrariesPage.dataTable.getRowByName(libraryName)).toBeVisible(); - await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(libraryName2); - await expect(myLibrariesPage.dataTable.getRowByName(libraryName2)).toBeVisible(); + await libraryTable.goThroughPagesLookingForRowWithName(libraryName); + await expect(libraryTable.getRowByName(libraryName)).toBeVisible(); + await libraryTable.goThroughPagesLookingForRowWithName(libraryName2); + await expect(libraryTable.getRowByName(libraryName2)).toBeVisible(); await apiClientFactory.sites.deleteSite(randomLibraryId, { permanent: true }); }); diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts index 8b84b1c340..20de9e94c7 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts @@ -51,12 +51,8 @@ export class AdfLibraryDialogComponent extends BaseComponent { await this.getLabelText('Name *').fill(nameInput); await this.getLabelText('Library ID *').clear(); await this.getLabelText('Library ID *').fill(libraryIdInput); - if (descriptionInput) { - await this.getLabelText('Description').fill(descriptionInput); - } - if (visibility) { - await this.getLabelText(visibility).click(); - } + if (descriptionInput) { await this.getLabelText('Description').fill(descriptionInput); } + if (visibility) { await this.getLabelText(visibility).click(); } await this.createButton.click(); } } diff --git a/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts index d94e755f3b..46ba9d572a 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts @@ -39,6 +39,11 @@ export class MyLibrariesPage extends BasePage { public libraryDialog = new AdfLibraryDialogComponent(this.page); public dataTable = new DataTableComponent(this.page); public breadcrumb = new AdfBreadcrumbComponent(this.page); - public viewDetails = new AdfInfoDrawerComponent (this.page); + public libraryDetails = new AdfInfoDrawerComponent (this.page); + + async selectCreateLibrary(): Promise { + await this.acaHeader.createButton.click(); + await this.matMenu.createLibrary.click(); + } } From d379c1f0d84fc42c342d94046025b0d7efbc672e Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 18:08:08 +0200 Subject: [PATCH 14/54] adding id to info drawer --- .../actions/src/tests/create-library.spec.ts | 10 ++++++---- .../library-metadata-form.component.html | 8 ++++---- .../components/adf-info-drawer.component.ts | 5 ++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index 8d1e112208..c45d706afc 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -153,10 +153,12 @@ test.describe('Create Libraries ', () => { await expect(libraryTable.getCellLinkByName(randomLibraryName).and(myLibrariesPage.page.getByTitle(randomLibraryDescription))).toBeVisible(); await libraryTable.getRowByName(randomLibraryName).click(); await libraryViewDetails.click(); - await expect(libraryDetails.getFieldData('Name').and(libraryDetails.getFieldData(randomLibraryName))).toBeVisible(); - await expect(libraryDetails.getFieldData('Library ID').and(libraryDetails.getFieldData(randomLibraryId))).toBeVisible(); - await expect(libraryDetails.getFieldData('Visibility').and(libraryDetails.getFieldData(publicVisibility))).toBeVisible(); - await expect(libraryDetails.getFieldData(libraryDescriptionLebel).and(libraryDetails.getFieldData(randomLibraryDescription))).toBeVisible(); + await expect(libraryDetails.getNameField('Name').and(libraryDetails.getNameField(randomLibraryName))).toBeVisible(); + await expect(libraryDetails.getIdField('Library ID').and(libraryDetails.getIdField(randomLibraryId))).toBeVisible(); + await expect(libraryDetails.getVisibilityField('Visibility').and(libraryDetails.getVisibilityField(publicVisibility))).toBeVisible(); + await expect( + libraryDetails.getDescriptionField(libraryDescriptionLebel).and(libraryDetails.getDescriptionField(randomLibraryDescription)) + ).toBeVisible(); await apiClientFactory.sites.deleteSite(randomLibraryId, { permanent: true }); }); diff --git a/projects/aca-content/src/lib/components/info-drawer/library-metadata-tab/library-metadata-form.component.html b/projects/aca-content/src/lib/components/info-drawer/library-metadata-tab/library-metadata-form.component.html index f11ba26e7d..febcac6b9c 100644 --- a/projects/aca-content/src/lib/components/info-drawer/library-metadata-tab/library-metadata-form.component.html +++ b/projects/aca-content/src/lib/components/info-drawer/library-metadata-tab/library-metadata-form.component.html @@ -1,7 +1,7 @@
-
+
@@ -19,7 +19,7 @@
-
+
@@ -37,7 +37,7 @@
-
+
@@ -55,7 +55,7 @@
-
+
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 71ad3e3aa8..0e859048eb 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 @@ -32,5 +32,8 @@ export class AdfInfoDrawerComponent extends BaseComponent { super(page, AdfInfoDrawerComponent.rootElement); } - public getFieldData = (labelText: string) => this.getChild('.mat-form-field-wrapper', { hasText: labelText }); + 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 getDescriptionField = (labelText: string) => this.getChild('[data-automation-id="library-description-properties-wrapper"]', { hasText: labelText }); } From 36188b94ed6bd7e6d6c249332061c343142090cd Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 22:28:19 +0200 Subject: [PATCH 15/54] adding index and updating import --- e2e/playwright/actions/src/tests/create-library.spec.ts | 3 +-- projects/aca-playwright-shared/src/utils/index.ts | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index c45d706afc..b0af0f0bc7 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -23,9 +23,8 @@ */ import { expect } from '@playwright/test'; -import { libraryErrors, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; +import { GeneralUtils, libraryErrors, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; -import { GeneralUtils } from '../../../../../projects/aca-playwright-shared/src/utils/general-utils'; test.use({ storageState: getUserState('hruser') }); test.describe('Create Libraries ', () => { diff --git a/projects/aca-playwright-shared/src/utils/index.ts b/projects/aca-playwright-shared/src/utils/index.ts index cb79e01dc8..c25a5ee7fb 100644 --- a/projects/aca-playwright-shared/src/utils/index.ts +++ b/projects/aca-playwright-shared/src/utils/index.ts @@ -28,3 +28,4 @@ export * from './exclude-tests'; export * from './state-helper'; export * from './folder-errors'; export * from './library-errors'; +export * from './general-utils'; From c3fb008fe4c3ec878a294680258d143ee1fd374e Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Wed, 12 Jul 2023 07:48:06 +0200 Subject: [PATCH 16/54] updating after wrong rebase --- .../src/fixtures/page-initialization.ts | 2 +- .../src/page-objects/components/aca-header.component.ts | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index e2d42b70fd..364994534f 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -23,8 +23,8 @@ */ import { test as base } from '@playwright/test'; -import {MyLibrariesPage, NodesPage, PersonalFilesPage} from '../'; import { + MyLibrariesPage, FileActionsApi, NodesPage, PersonalFilesPage, diff --git a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts index 8b02615409..426a38bbb5 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts @@ -24,12 +24,6 @@ import { BaseComponent } from './base.component'; import { Page } from '@playwright/test'; - - export class AcaHeader extends BaseComponent { - private static rootElement = 'adf-toolbar'; - public createButton = this.getChild('[id="app.toolbar.create"]'); - public viewDetails = this.getChild('[title="View Details"]'); - export class AcaHeader extends BaseComponent { private static rootElement = 'adf-toolbar'; public createButton = this.getChild('[id="app.toolbar.create"]'); From c654361de967a5ad885e137499efeb2a85b71a39 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 7 Jul 2023 15:57:09 +0200 Subject: [PATCH 17/54] after rebase --- .../actions/src/tests/create-library.spec.ts | 250 ++++++++++++++++++ .../src/fixtures/page-initialization.ts | 7 +- .../components/aca-header.component.ts | 1 + .../components/adf-info-drawer.component.ts | 36 +++ .../breadcrumb/breadcrumb.component.ts | 36 +++ .../components/breadcrumb/index.ts | 25 ++ .../dataTable/mat-menu.component.ts | 1 + .../dialogs/adf-library-dialog.component.ts | 62 +++++ .../page-objects/components/dialogs/index.ts | 2 + .../src/page-objects/components/index.ts | 3 + .../src/page-objects/pages/index.ts | 1 + .../page-objects/pages/my-libraries.page.ts | 44 +++ .../aca-playwright-shared/src/utils/index.ts | 1 + .../src/utils/library-errors.ts | 29 ++ 14 files changed, 497 insertions(+), 1 deletion(-) create mode 100644 e2e/playwright/actions/src/tests/create-library.spec.ts create mode 100644 projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts create mode 100644 projects/aca-playwright-shared/src/page-objects/components/breadcrumb/breadcrumb.component.ts create mode 100644 projects/aca-playwright-shared/src/page-objects/components/breadcrumb/index.ts create mode 100644 projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts create mode 100644 projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts create mode 100644 projects/aca-playwright-shared/src/utils/library-errors.ts diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts new file mode 100644 index 0000000000..9f379e5d70 --- /dev/null +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -0,0 +1,250 @@ +/*! + * 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 { expect } from '@playwright/test'; +import { getUserState, test } from '@alfresco/playwright-shared'; +import { libraryErrors } from '../../../../../projects/aca-playwright-shared/src/utils/library-errors'; + +test.use({ storageState: getUserState('hruser') }); +test.describe('Create Libraries ', () => { + let randomLibraryName: string; + let randomLibraryId: string; + let randomLibraryDescription: string; + const libraryDialogTitle = 'Create Library'; + const libraryNameLebel = 'Name *'; + const libraryIdLebel = 'Library ID *'; + const libraryDescriptionLebel = 'Description'; + const publicVisibility = 'Public'; + const moderatedVisibility = 'Moderated'; + const privateVisibility = 'Private'; + const deleteAction = 'Delete'; + + test.beforeEach(async ({ myLibrariesPage }) => { + randomLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; + randomLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; + randomLibraryDescription = `libraryDescription-${(Math.random() + 1).toString(36).substring(6)}`; + await myLibrariesPage.navigate(); + }); + + test('[C280024] Create Library dialog UI', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + + await expect(myLibrariesPage.libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.getLabelText(libraryDescriptionLebel)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.getLabelText(publicVisibility)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.getLabelText(publicVisibility)).toBeChecked(); + await expect(myLibrariesPage.libraryDialog.getLabelText(privateVisibility)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.getLabelText(moderatedVisibility)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.cancelButton).toBeEnabled(); + await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); + }); + + test('[C280025] Create a public library', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await expect(myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel)).toHaveValue(randomLibraryName); + await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(randomLibraryName); + await myLibrariesPage.libraryDialog.createButton.click(); + + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + + await myLibrariesPage.navigate(); + await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(myLibrariesPage.dataTable.getCellByColumnNameAndRowItem(randomLibraryName, publicVisibility)).toBeVisible(); + + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + }); + + test('[C289880] Create a moderated library', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, moderatedVisibility); + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + + await myLibrariesPage.navigate(); + await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(myLibrariesPage.dataTable.getCellByColumnNameAndRowItem(randomLibraryName, moderatedVisibility)).toBeVisible(); + + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + }); + + test('[C289881] Create a private library', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, privateVisibility); + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + + await myLibrariesPage.navigate(); + await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(myLibrariesPage.dataTable.getCellByColumnNameAndRowItem(randomLibraryName, privateVisibility)).toBeVisible(); + + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + }); + + test('[C289882] Create a library with a given ID and description', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, randomLibraryDescription); + + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + + await myLibrariesPage.navigate(); + await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect( + myLibrariesPage.dataTable.getCellLinkByName(randomLibraryName).and(myLibrariesPage.page.getByTitle(randomLibraryDescription)) + ).toBeVisible(); + + await myLibrariesPage.dataTable.getRowByName(randomLibraryName).click(); + await myLibrariesPage.acaHeader.viewDetails.click(); + await expect(myLibrariesPage.viewDetails.getFieldData('Name').and(myLibrariesPage.viewDetails.getFieldData(randomLibraryName))).toBeVisible(); + await expect(myLibrariesPage.viewDetails.getFieldData('Library ID').and(myLibrariesPage.viewDetails.getFieldData(randomLibraryId))).toBeVisible(); + await expect( + myLibrariesPage.viewDetails.getFieldData('Visibility').and(myLibrariesPage.viewDetails.getFieldData(publicVisibility)) + ).toBeVisible(); + await expect( + myLibrariesPage.viewDetails.getFieldData(libraryDescriptionLebel).and(myLibrariesPage.viewDetails.getFieldData(randomLibraryDescription)) + ).toBeVisible(); + + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + }); + + test('[C280027] Duplicate library ID', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId); + + await myLibrariesPage.navigate(); + // duplicate library id + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName + '2'); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(randomLibraryId); + + await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); + await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.libraryIdIsNotAvailable)).toBeVisible(); + + await myLibrariesPage.libraryDialog.cancelButton.click(); + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + }); + + test('[C280028] Create library using the ID of a library from the Trashcan', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId); + + await myLibrariesPage.navigate(); + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + // library id from the trashcan + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName + '2'); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(randomLibraryId); + + await expect(myLibrariesPage.libraryDialog.createButton).toBeEnabled(); + await myLibrariesPage.libraryDialog.createButton.click(); + await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); + await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.libraryIdIsAlreadyUsed)).toBeVisible(); + + await myLibrariesPage.libraryDialog.cancelButton.click(); + }); + + test('[C280029] Cancel button', async ({ myLibrariesPage }) => { + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await expect(myLibrariesPage.libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await myLibrariesPage.libraryDialog.cancelButton.click(); + + await expect(myLibrariesPage.libraryDialog.getDialogTitle(libraryDialogTitle)).toBeHidden(); + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toHaveCount(0); + await expect(myLibrariesPage.dataTable.getRowByName(randomLibraryName)).toHaveCount(0); + }); + + test('[C280026] Library ID cannot contain special characters', async ({ myLibrariesPage }) => { + const idsWithSpecialChars = [ + 'a!a', + 'a@a', + 'a#a', + 'a%a', + 'a^a', + 'a&a', + 'a*a', + 'a(a', + 'a)a', + 'a"a', + 'aa', + `a\\a`, + 'a/a', + 'a?a', + 'a:a', + 'a|a' + ]; + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + + for (const specialLibraryId of idsWithSpecialChars) { + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); + await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); + await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.useNumbersAndLettersOnly)).toBeVisible(); + await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); + } + + await myLibrariesPage.libraryDialog.cancelButton.click(); + }); + + test('[C280030] Create 2 libraries with same name but different IDs', async ({ myLibrariesPage }) => { + const libraryName = randomLibraryName + ' (' + randomLibraryId + ')'; + const libraryName2 = randomLibraryName + ' (' + randomLibraryId + '2)'; + + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId); + await myLibrariesPage.navigate(); + + // duplicate library name but different id + await myLibrariesPage.acaHeader.createButton.click(); + await myLibrariesPage.matMenu.createLibrary.click(); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId + '2'); + + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + + await myLibrariesPage.navigate(); + await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(libraryName); + await expect(myLibrariesPage.dataTable.getRowByName(libraryName)).toBeVisible(); + await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(libraryName2); + await expect(myLibrariesPage.dataTable.getRowByName(libraryName2)).toBeVisible(); + + await myLibrariesPage.dataTable.performActionFromExpandableMenu(libraryName2, deleteAction); + await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + }); +}); diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index a30b775a1c..cbdf71531a 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -32,12 +32,14 @@ import { SharedPage, SearchPage, FavoritesPage, - FavoritesPageApi + FavoritesPageApi, + MyLibrariesPage } from '../'; interface Pages { personalFiles: PersonalFilesPage; nodesPage: NodesPage; + myLibrariesPage: MyLibrariesPage; recentFilesPage: RecentFilesPage; sharedPage: SharedPage; searchPage: SearchPage; @@ -80,5 +82,8 @@ export const test = base.extend({ // eslint-disable-next-line no-empty-pattern favoritesPageAction: async ({}, use) => { await use(await FavoritesPageApi.initialize('admin')); + }, + myLibrariesPage: async ({ page }, use) => { + await use(new MyLibrariesPage(page)); } }); diff --git a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts index 063aed6e8f..339b1bc2e7 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts @@ -30,6 +30,7 @@ export class AcaHeader extends BaseComponent { public createButton = this.getChild('[id="app.toolbar.create"]'); public viewButton = this.getChild('button[title="View"]'); public searchButton = this.getChild('button[title="Search"]'); + public viewDetails = this.getChild('[title="View Details"]'); constructor(page: Page) { super(page, AcaHeader.rootElement); 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 new file mode 100644 index 0000000000..71ad3e3aa8 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/components/adf-info-drawer.component.ts @@ -0,0 +1,36 @@ +/*! + * 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 } from '@playwright/test'; + +export class AdfInfoDrawerComponent extends BaseComponent { + private static rootElement = 'adf-info-drawer'; + + constructor(page: Page) { + super(page, AdfInfoDrawerComponent.rootElement); + } + + public getFieldData = (labelText: string) => this.getChild('.mat-form-field-wrapper', { hasText: labelText }); +} diff --git a/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/breadcrumb.component.ts b/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/breadcrumb.component.ts new file mode 100644 index 0000000000..2b88148f10 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/breadcrumb.component.ts @@ -0,0 +1,36 @@ +/*! + * 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 } from '@playwright/test'; + +export class AdfBreadcrumbComponent extends BaseComponent { + private static rootElement = 'adf-breadcrumb'; + + constructor(page: Page) { + super(page, AdfBreadcrumbComponent.rootElement); + } + + public getBreadcrumbItem = (text: string) => this.getChild('.adf-breadcrumb-item', { hasText: text }); +} diff --git a/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/index.ts b/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/index.ts new file mode 100644 index 0000000000..0d88c7dea3 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/index.ts @@ -0,0 +1,25 @@ +/*! + * 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 . + */ + +export * from './breadcrumb.component'; diff --git a/projects/aca-playwright-shared/src/page-objects/components/dataTable/mat-menu.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dataTable/mat-menu.component.ts index 82c4669068..a38e78e0ee 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dataTable/mat-menu.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dataTable/mat-menu.component.ts @@ -35,5 +35,6 @@ export class MatMenuComponent extends BaseComponent { public getMenuItemsLocator = this.getChild('button'); public getMenuItemTextLocator = this.getChild('[data-automation-id="menu-item-title"]'); public createFolder = this.getChild('[id="app.create.folder"]'); + public createLibrary = this.getChild('[id="app.create.library"]'); public getButtonByText = (text: string) => this.getChild('button', { hasText: text }); } diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts new file mode 100644 index 0000000000..e6ab268af1 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts @@ -0,0 +1,62 @@ +/*! + * 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 } from '@playwright/test'; + +export class AdfLibraryDialogComponent extends BaseComponent { + private static rootElement = 'adf-library-dialog'; + + public createButton = this.getChild('[data-automation-id="create-library-id"]'); + public cancelButton = this.getChild('[data-automation-id="cancel-library-id"]'); + + constructor(page: Page) { + super(page, AdfLibraryDialogComponent.rootElement); + } + + public getLabelText = (text: string) => this.getChild('label', { hasText: text }); + public getDialogTitle = (text: string) => this.getChild('.mat-dialog-title', { hasText: text }); + public getMatError = (text: string) => this.getChild('.mat-error', { hasText: text }); + + /** + * This method is used when we want to fill in Create Library Dialog and choose Create button + * + * @param nameInput input for the Name field + * @param libraryIdInput input for Library ID field + * @param descriptionInput input for Description field + * @param visibility visibility of the library + */ + async createLibraryWithNameAndId(nameInput: string, libraryIdInput: string, descriptionInput?: string, visibility?: string): Promise { + await this.getLabelText('Name *').fill(nameInput); + await this.getLabelText('Library ID *').clear(); + await this.getLabelText('Library ID *').fill(libraryIdInput); + if (descriptionInput) { + await this.getLabelText('Description').fill(descriptionInput); + } + if (visibility) { + await this.getLabelText(visibility).click(); + } + await this.createButton.click(); + } +} diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/index.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/index.ts index f659ffb7d3..1177660266 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dialogs/index.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/index.ts @@ -23,3 +23,5 @@ */ export * from './adf-folder-dialog.component'; +export * from './adf-library-dialog.component'; + diff --git a/projects/aca-playwright-shared/src/page-objects/components/index.ts b/projects/aca-playwright-shared/src/page-objects/components/index.ts index a3f04f1fb6..997e2da290 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/index.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/index.ts @@ -34,3 +34,6 @@ export * from './pagination.component'; export * from './viewer.component'; export * from './search/search-input.component'; export * from './search/search-overlay.components'; +export * from './breadcrumb'; +export * from './adf-info-drawer.component'; + diff --git a/projects/aca-playwright-shared/src/page-objects/pages/index.ts b/projects/aca-playwright-shared/src/page-objects/pages/index.ts index 72def0ece5..4e9a730348 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/index.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/index.ts @@ -26,6 +26,7 @@ export * from './base.page'; export * from './login.page'; export * from './nodes.page'; export * from './personal-files.page'; +export * from './my-libraries.page'; export * from './recent-files.page'; export * from './shared.page'; export * from './search.page'; diff --git a/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts new file mode 100644 index 0000000000..d94e755f3b --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts @@ -0,0 +1,44 @@ +/*! + * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. + * + * Alfresco Example Content Application + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * from Hyland Software. If not, see . + */ + + +import { Page } from '@playwright/test'; +import { BasePage } from './base.page'; +import { AcaHeader } from '../components/aca-header.component'; +import { AdfBreadcrumbComponent, AdfInfoDrawerComponent, AdfLibraryDialogComponent, DataTableComponent, MatMenuComponent } from '../components'; + +export class MyLibrariesPage extends BasePage { + private static pageUrl = 'libraries'; + + constructor(page: Page) { + super(page, MyLibrariesPage.pageUrl); + } + public acaHeader = new AcaHeader(this.page); + public matMenu = new MatMenuComponent(this.page); + public libraryDialog = new AdfLibraryDialogComponent(this.page); + public dataTable = new DataTableComponent(this.page); + public breadcrumb = new AdfBreadcrumbComponent(this.page); + public viewDetails = new AdfInfoDrawerComponent (this.page); + +} diff --git a/projects/aca-playwright-shared/src/utils/index.ts b/projects/aca-playwright-shared/src/utils/index.ts index f3bdc9b5fb..cb79e01dc8 100644 --- a/projects/aca-playwright-shared/src/utils/index.ts +++ b/projects/aca-playwright-shared/src/utils/index.ts @@ -27,3 +27,4 @@ export * from './timeouts'; export * from './exclude-tests'; export * from './state-helper'; export * from './folder-errors'; +export * from './library-errors'; diff --git a/projects/aca-playwright-shared/src/utils/library-errors.ts b/projects/aca-playwright-shared/src/utils/library-errors.ts new file mode 100644 index 0000000000..c0b5648ad5 --- /dev/null +++ b/projects/aca-playwright-shared/src/utils/library-errors.ts @@ -0,0 +1,29 @@ +/*! + * 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 . + */ + +export const libraryErrors = { + libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID`, + libraryIdIsAlreadyUsed: `This Library ID is already used. Check the trashcan.`, + useNumbersAndLettersOnly: `Use numbers and letters only` +} From 1eb2f8c8a2e83aa1e17c4cc089ce1049a59ae82c Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 7 Jul 2023 19:40:18 +0200 Subject: [PATCH 18/54] updating tests and adding before and after all --- .../actions/src/tests/create-library.spec.ts | 74 +++++++++---------- .../src/utils/library-errors.ts | 2 +- 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index 9f379e5d70..c5fc881c7a 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -23,11 +23,13 @@ */ import { expect } from '@playwright/test'; -import { getUserState, test } from '@alfresco/playwright-shared'; +import { ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; import { libraryErrors } from '../../../../../projects/aca-playwright-shared/src/utils/library-errors'; +import { SiteBodyCreate } from '@alfresco/js-api'; test.use({ storageState: getUserState('hruser') }); test.describe('Create Libraries ', () => { + const apiClientFactory = new ApiClientFactory(); let randomLibraryName: string; let randomLibraryId: string; let randomLibraryDescription: string; @@ -40,6 +42,22 @@ test.describe('Create Libraries ', () => { const privateVisibility = 'Private'; const deleteAction = 'Delete'; + const commonLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; + const commonLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; + const commonTrashLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; + const commonTrashLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; + + test.beforeAll(async () => { + await apiClientFactory.setUpAcaBackend('hruser'); + await apiClientFactory.sites.createSite({ id: commonLibraryId, title: commonLibraryName, visibility: SiteBodyCreate.VisibilityEnum.PUBLIC }); + await apiClientFactory.sites.createSite({ + id: commonTrashLibraryId, + title: commonTrashLibraryName, + visibility: SiteBodyCreate.VisibilityEnum.PUBLIC + }); + await apiClientFactory.sites.deleteSite(commonTrashLibraryId); + }); + test.beforeEach(async ({ myLibrariesPage }) => { randomLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; randomLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; @@ -47,6 +65,10 @@ test.describe('Create Libraries ', () => { await myLibrariesPage.navigate(); }); + test.afterAll(async () => { + await apiClientFactory.sites.deleteSite(commonLibraryId, { permanent: true }); + }); + test('[C280024] Create Library dialog UI', async ({ myLibrariesPage }) => { await myLibrariesPage.acaHeader.createButton.click(); await myLibrariesPage.matMenu.createLibrary.click(); @@ -70,7 +92,6 @@ test.describe('Create Libraries ', () => { await expect(myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel)).toHaveValue(randomLibraryName); await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(randomLibraryName); await myLibrariesPage.libraryDialog.createButton.click(); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); @@ -110,7 +131,6 @@ test.describe('Create Libraries ', () => { await myLibrariesPage.acaHeader.createButton.click(); await myLibrariesPage.matMenu.createLibrary.click(); await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, randomLibraryDescription); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); @@ -118,7 +138,6 @@ test.describe('Create Libraries ', () => { await expect( myLibrariesPage.dataTable.getCellLinkByName(randomLibraryName).and(myLibrariesPage.page.getByTitle(randomLibraryDescription)) ).toBeVisible(); - await myLibrariesPage.dataTable.getRowByName(randomLibraryName).click(); await myLibrariesPage.acaHeader.viewDetails.click(); await expect(myLibrariesPage.viewDetails.getFieldData('Name').and(myLibrariesPage.viewDetails.getFieldData(randomLibraryName))).toBeVisible(); @@ -130,49 +149,31 @@ test.describe('Create Libraries ', () => { myLibrariesPage.viewDetails.getFieldData(libraryDescriptionLebel).and(myLibrariesPage.viewDetails.getFieldData(randomLibraryDescription)) ).toBeVisible(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + await apiClientFactory.sites.deleteSite(randomLibraryId, { permanent: true }); }); test('[C280027] Duplicate library ID', async ({ myLibrariesPage }) => { await myLibrariesPage.acaHeader.createButton.click(); await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId); - - await myLibrariesPage.navigate(); - // duplicate library id - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName + '2'); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(randomLibraryId); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(commonLibraryId); await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.libraryIdIsNotAvailable)).toBeVisible(); - - await myLibrariesPage.libraryDialog.cancelButton.click(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); }); test('[C280028] Create library using the ID of a library from the Trashcan', async ({ myLibrariesPage }) => { await myLibrariesPage.acaHeader.createButton.click(); await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId); - - await myLibrariesPage.navigate(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); - // library id from the trashcan - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName + '2'); + await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(randomLibraryId); + await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(commonTrashLibraryId); await expect(myLibrariesPage.libraryDialog.createButton).toBeEnabled(); await myLibrariesPage.libraryDialog.createButton.click(); await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.libraryIdIsAlreadyUsed)).toBeVisible(); - - await myLibrariesPage.libraryDialog.cancelButton.click(); }); test('[C280029] Cancel button', async ({ myLibrariesPage }) => { @@ -218,25 +219,17 @@ test.describe('Create Libraries ', () => { await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.useNumbersAndLettersOnly)).toBeVisible(); await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); } - - await myLibrariesPage.libraryDialog.cancelButton.click(); }); test('[C280030] Create 2 libraries with same name but different IDs', async ({ myLibrariesPage }) => { - const libraryName = randomLibraryName + ' (' + randomLibraryId + ')'; - const libraryName2 = randomLibraryName + ' (' + randomLibraryId + '2)'; - - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId); - await myLibrariesPage.navigate(); + const libraryName = commonLibraryName + ' (' + commonLibraryId + ')'; + const libraryName2 = commonLibraryName + ' (' + randomLibraryId + ')'; - // duplicate library name but different id await myLibrariesPage.acaHeader.createButton.click(); await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId + '2'); + await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(commonLibraryName, randomLibraryId); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(commonLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(libraryName); @@ -244,7 +237,6 @@ test.describe('Create Libraries ', () => { await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(libraryName2); await expect(myLibrariesPage.dataTable.getRowByName(libraryName2)).toBeVisible(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(libraryName2, deleteAction); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + await apiClientFactory.sites.deleteSite(randomLibraryId, { permanent: true }); }); }); diff --git a/projects/aca-playwright-shared/src/utils/library-errors.ts b/projects/aca-playwright-shared/src/utils/library-errors.ts index c0b5648ad5..57d4619a41 100644 --- a/projects/aca-playwright-shared/src/utils/library-errors.ts +++ b/projects/aca-playwright-shared/src/utils/library-errors.ts @@ -23,7 +23,7 @@ */ export const libraryErrors = { - libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID`, + libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID.`, libraryIdIsAlreadyUsed: `This Library ID is already used. Check the trashcan.`, useNumbersAndLettersOnly: `Use numbers and letters only` } From 51109c0dd63b4a14ea38c55a93993abc89f270ad Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Mon, 10 Jul 2023 13:16:55 +0200 Subject: [PATCH 19/54] updating import statement --- e2e/playwright/actions/src/tests/create-library.spec.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index c5fc881c7a..e8efbcebb3 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -23,8 +23,7 @@ */ import { expect } from '@playwright/test'; -import { ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; -import { libraryErrors } from '../../../../../projects/aca-playwright-shared/src/utils/library-errors'; +import { libraryErrors, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; test.use({ storageState: getUserState('hruser') }); From d9d59709457a663797e5f97df3423ff84aa808d3 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Mon, 10 Jul 2023 22:01:13 +0200 Subject: [PATCH 20/54] update error locator --- .../components/dialogs/adf-library-dialog.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts index e6ab268af1..8b84b1c340 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts @@ -37,7 +37,7 @@ export class AdfLibraryDialogComponent extends BaseComponent { public getLabelText = (text: string) => this.getChild('label', { hasText: text }); public getDialogTitle = (text: string) => this.getChild('.mat-dialog-title', { hasText: text }); - public getMatError = (text: string) => this.getChild('.mat-error', { hasText: text }); + public getMatError = (text: string) => this.getChild('mat-error', { hasText: text }); /** * This method is used when we want to fill in Create Library Dialog and choose Create button From f82f4e541d41da15e90bdb370e23b6527fee9c84 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 09:16:34 +0200 Subject: [PATCH 21/54] adding random method in general utils --- .../actions/src/tests/create-library.spec.ts | 15 +++++---- .../src/utils/general-utils.ts | 33 +++++++++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 projects/aca-playwright-shared/src/utils/general-utils.ts diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index e8efbcebb3..8dc21679aa 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -25,6 +25,7 @@ import { expect } from '@playwright/test'; import { libraryErrors, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; +import { GeneralUtils } from '../../../../../projects/aca-playwright-shared/src/utils/general-utils'; test.use({ storageState: getUserState('hruser') }); test.describe('Create Libraries ', () => { @@ -41,10 +42,10 @@ test.describe('Create Libraries ', () => { const privateVisibility = 'Private'; const deleteAction = 'Delete'; - const commonLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; - const commonLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; - const commonTrashLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; - const commonTrashLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; + const commonLibraryName = `playwright-library-${GeneralUtils.random()}`; + const commonLibraryId = `libraryId-${GeneralUtils.random()}`; + const commonTrashLibraryName = `playwright-library-${GeneralUtils.random()}`; + const commonTrashLibraryId = `libraryId-${GeneralUtils.random()}`; test.beforeAll(async () => { await apiClientFactory.setUpAcaBackend('hruser'); @@ -58,9 +59,9 @@ test.describe('Create Libraries ', () => { }); test.beforeEach(async ({ myLibrariesPage }) => { - randomLibraryName = `playwright-library-${(Math.random() + 1).toString(36).substring(6)}`; - randomLibraryId = `libraryId-${(Math.random() + 1).toString(36).substring(6)}`; - randomLibraryDescription = `libraryDescription-${(Math.random() + 1).toString(36).substring(6)}`; + randomLibraryName = `playwright-library-${GeneralUtils.random()}`; + randomLibraryId = `libraryId-${GeneralUtils.random()}`; + randomLibraryDescription = `libraryDescription-${GeneralUtils.random()}`; await myLibrariesPage.navigate(); }); diff --git a/projects/aca-playwright-shared/src/utils/general-utils.ts b/projects/aca-playwright-shared/src/utils/general-utils.ts new file mode 100644 index 0000000000..9e30d8eea0 --- /dev/null +++ b/projects/aca-playwright-shared/src/utils/general-utils.ts @@ -0,0 +1,33 @@ +/*! + * 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 . + */ + + +export class GeneralUtils { + + + static random(): string { + return (Math.random() + 1).toString(36).substring(6); + } + +} From a29bdf9621ce48d3091815e6d4847407ce505401 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 7 Jul 2023 15:57:09 +0200 Subject: [PATCH 22/54] [ACS-511]-adding-library-tests --- .../aca-playwright-shared/src/fixtures/page-initialization.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index cbdf71531a..c6e0238713 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -85,5 +85,5 @@ export const test = base.extend({ }, myLibrariesPage: async ({ page }, use) => { await use(new MyLibrariesPage(page)); - } + }, }); From 48469e2df62dce4355c2b79c7e83331b868dfea1 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 13:47:05 +0200 Subject: [PATCH 23/54] comma deleted --- .../aca-playwright-shared/src/fixtures/page-initialization.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index c6e0238713..cbdf71531a 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -85,5 +85,5 @@ export const test = base.extend({ }, myLibrariesPage: async ({ page }, use) => { await use(new MyLibrariesPage(page)); - }, + } }); From 9c4722c37cc33eb319c9b10177457cf423ab281e Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 15:50:16 +0200 Subject: [PATCH 24/54] fix readability and indentation --- .../actions/src/tests/create-library.spec.ts | 213 ++++++++++-------- .../dialogs/adf-library-dialog.component.ts | 8 +- .../page-objects/pages/my-libraries.page.ts | 7 +- 3 files changed, 123 insertions(+), 105 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index 8dc21679aa..8d1e112208 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -70,125 +70,140 @@ test.describe('Create Libraries ', () => { }); test('[C280024] Create Library dialog UI', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - - await expect(myLibrariesPage.libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.getLabelText(libraryDescriptionLebel)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.getLabelText(publicVisibility)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.getLabelText(publicVisibility)).toBeChecked(); - await expect(myLibrariesPage.libraryDialog.getLabelText(privateVisibility)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.getLabelText(moderatedVisibility)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.cancelButton).toBeEnabled(); - await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); + const libraryDialog = myLibrariesPage.libraryDialog; + + await myLibrariesPage.selectCreateLibrary(); + + await expect(libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); + await expect(libraryDialog.getLabelText(libraryNameLebel)).toBeVisible(); + await expect(libraryDialog.getLabelText(libraryIdLebel)).toBeVisible(); + await expect(libraryDialog.getLabelText(libraryDescriptionLebel)).toBeVisible(); + await expect(libraryDialog.getLabelText(publicVisibility)).toBeVisible(); + await expect(libraryDialog.getLabelText(publicVisibility)).toBeChecked(); + await expect(libraryDialog.getLabelText(privateVisibility)).toBeVisible(); + await expect(libraryDialog.getLabelText(moderatedVisibility)).toBeVisible(); + await expect(libraryDialog.cancelButton).toBeEnabled(); + await expect(libraryDialog.createButton).toBeDisabled(); }); test('[C280025] Create a public library', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); - await expect(myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel)).toHaveValue(randomLibraryName); - await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(randomLibraryName); - await myLibrariesPage.libraryDialog.createButton.click(); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + const libraryDialog = myLibrariesPage.libraryDialog; + const libraryTable = myLibrariesPage.dataTable; + const libraryBreadcrumb = myLibrariesPage.breadcrumb; + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await expect(libraryDialog.getLabelText(libraryNameLebel)).toHaveValue(randomLibraryName); + await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(randomLibraryName); + await libraryDialog.createButton.click(); + await expect(libraryBreadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); - await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); - await expect(myLibrariesPage.dataTable.getCellByColumnNameAndRowItem(randomLibraryName, publicVisibility)).toBeVisible(); + await libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, publicVisibility)).toBeVisible(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + await libraryTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); }); test('[C289880] Create a moderated library', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, moderatedVisibility); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + const libraryDialog = myLibrariesPage.libraryDialog; + const libraryTable = myLibrariesPage.dataTable; + const libraryBreadcrumb = myLibrariesPage.breadcrumb; + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, moderatedVisibility); + await expect(libraryBreadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); - await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); - await expect(myLibrariesPage.dataTable.getCellByColumnNameAndRowItem(randomLibraryName, moderatedVisibility)).toBeVisible(); + await libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, moderatedVisibility)).toBeVisible(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + await libraryTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); }); test('[C289881] Create a private library', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, privateVisibility); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + const libraryDialog = myLibrariesPage.libraryDialog; + const libraryTable = myLibrariesPage.dataTable; + const libraryBreadcrumb = myLibrariesPage.breadcrumb; + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, privateVisibility); + await expect(libraryBreadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); - await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); - await expect(myLibrariesPage.dataTable.getCellByColumnNameAndRowItem(randomLibraryName, privateVisibility)).toBeVisible(); + await libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, privateVisibility)).toBeVisible(); - await myLibrariesPage.dataTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + await libraryTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); }); test('[C289882] Create a library with a given ID and description', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, randomLibraryDescription); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); + const libraryDialog = myLibrariesPage.libraryDialog; + const libraryTable = myLibrariesPage.dataTable; + const libraryBreadcrumb = myLibrariesPage.breadcrumb; + const libraryViewDetails = myLibrariesPage.acaHeader.viewDetails; + const libraryDetails = myLibrariesPage.libraryDetails; + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, randomLibraryDescription); + await expect(libraryBreadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); - await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); - await expect( - myLibrariesPage.dataTable.getCellLinkByName(randomLibraryName).and(myLibrariesPage.page.getByTitle(randomLibraryDescription)) - ).toBeVisible(); - await myLibrariesPage.dataTable.getRowByName(randomLibraryName).click(); - await myLibrariesPage.acaHeader.viewDetails.click(); - await expect(myLibrariesPage.viewDetails.getFieldData('Name').and(myLibrariesPage.viewDetails.getFieldData(randomLibraryName))).toBeVisible(); - await expect(myLibrariesPage.viewDetails.getFieldData('Library ID').and(myLibrariesPage.viewDetails.getFieldData(randomLibraryId))).toBeVisible(); - await expect( - myLibrariesPage.viewDetails.getFieldData('Visibility').and(myLibrariesPage.viewDetails.getFieldData(publicVisibility)) - ).toBeVisible(); - await expect( - myLibrariesPage.viewDetails.getFieldData(libraryDescriptionLebel).and(myLibrariesPage.viewDetails.getFieldData(randomLibraryDescription)) - ).toBeVisible(); + await libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await expect(libraryTable.getCellLinkByName(randomLibraryName).and(myLibrariesPage.page.getByTitle(randomLibraryDescription))).toBeVisible(); + await libraryTable.getRowByName(randomLibraryName).click(); + await libraryViewDetails.click(); + await expect(libraryDetails.getFieldData('Name').and(libraryDetails.getFieldData(randomLibraryName))).toBeVisible(); + await expect(libraryDetails.getFieldData('Library ID').and(libraryDetails.getFieldData(randomLibraryId))).toBeVisible(); + await expect(libraryDetails.getFieldData('Visibility').and(libraryDetails.getFieldData(publicVisibility))).toBeVisible(); + await expect(libraryDetails.getFieldData(libraryDescriptionLebel).and(libraryDetails.getFieldData(randomLibraryDescription))).toBeVisible(); await apiClientFactory.sites.deleteSite(randomLibraryId, { permanent: true }); }); test('[C280027] Duplicate library ID', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(commonLibraryId); - - await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); - await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.libraryIdIsNotAvailable)).toBeVisible(); + const libraryDialog = myLibrariesPage.libraryDialog; + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await libraryDialog.getLabelText(libraryIdLebel).clear(); + await libraryDialog.getLabelText(libraryIdLebel).fill(commonLibraryId); + + await expect(libraryDialog.createButton).toBeDisabled(); + await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsNotAvailable)).toBeVisible(); }); test('[C280028] Create library using the ID of a library from the Trashcan', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(commonTrashLibraryId); - - await expect(myLibrariesPage.libraryDialog.createButton).toBeEnabled(); - await myLibrariesPage.libraryDialog.createButton.click(); - await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); - await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.libraryIdIsAlreadyUsed)).toBeVisible(); + const libraryDialog = myLibrariesPage.libraryDialog; + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await libraryDialog.getLabelText(libraryIdLebel).clear(); + await libraryDialog.getLabelText(libraryIdLebel).fill(commonTrashLibraryId); + + await expect(libraryDialog.createButton).toBeEnabled(); + await libraryDialog.createButton.click(); + await expect(libraryDialog.createButton).toBeDisabled(); + await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsAlreadyUsed)).toBeVisible(); }); test('[C280029] Cancel button', async ({ myLibrariesPage }) => { - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await expect(myLibrariesPage.libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); - await myLibrariesPage.libraryDialog.cancelButton.click(); - - await expect(myLibrariesPage.libraryDialog.getDialogTitle(libraryDialogTitle)).toBeHidden(); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(randomLibraryName)).toHaveCount(0); - await expect(myLibrariesPage.dataTable.getRowByName(randomLibraryName)).toHaveCount(0); + const libraryDialog = myLibrariesPage.libraryDialog; + const libraryTable = myLibrariesPage.dataTable; + const libraryBreadcrumb = myLibrariesPage.breadcrumb; + + await myLibrariesPage.selectCreateLibrary(); + await expect(libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); + await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await libraryDialog.cancelButton.click(); + + await expect(libraryDialog.getDialogTitle(libraryDialogTitle)).toBeHidden(); + await expect(libraryBreadcrumb.getBreadcrumbItem(randomLibraryName)).toHaveCount(0); + await expect(libraryTable.getRowByName(randomLibraryName)).toHaveCount(0); }); test('[C280026] Library ID cannot contain special characters', async ({ myLibrariesPage }) => { + const libraryDialog = myLibrariesPage.libraryDialog; const idsWithSpecialChars = [ 'a!a', 'a@a', @@ -208,34 +223,36 @@ test.describe('Create Libraries ', () => { 'a:a', 'a|a' ]; - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); for (const specialLibraryId of idsWithSpecialChars) { - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).clear(); - await myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); - await expect(myLibrariesPage.libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); - await expect(myLibrariesPage.libraryDialog.getMatError(libraryErrors.useNumbersAndLettersOnly)).toBeVisible(); - await expect(myLibrariesPage.libraryDialog.createButton).toBeDisabled(); + await libraryDialog.getLabelText(libraryIdLebel).clear(); + await libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); + await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); + await expect(libraryDialog.getMatError(libraryErrors.useNumbersAndLettersOnly)).toBeVisible(); + await expect(libraryDialog.createButton).toBeDisabled(); } }); test('[C280030] Create 2 libraries with same name but different IDs', async ({ myLibrariesPage }) => { + const libraryDialog = myLibrariesPage.libraryDialog; + const libraryTable = myLibrariesPage.dataTable; + const libraryBreadcrumb = myLibrariesPage.breadcrumb; const libraryName = commonLibraryName + ' (' + commonLibraryId + ')'; const libraryName2 = commonLibraryName + ' (' + randomLibraryId + ')'; - await myLibrariesPage.acaHeader.createButton.click(); - await myLibrariesPage.matMenu.createLibrary.click(); - await myLibrariesPage.libraryDialog.createLibraryWithNameAndId(commonLibraryName, randomLibraryId); + await myLibrariesPage.selectCreateLibrary(); + await libraryDialog.createLibraryWithNameAndId(commonLibraryName, randomLibraryId); - await expect(myLibrariesPage.breadcrumb.getBreadcrumbItem(commonLibraryName)).toBeVisible(); + await expect(libraryBreadcrumb.getBreadcrumbItem(commonLibraryName)).toBeVisible(); await myLibrariesPage.navigate(); - await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(libraryName); - await expect(myLibrariesPage.dataTable.getRowByName(libraryName)).toBeVisible(); - await myLibrariesPage.dataTable.goThroughPagesLookingForRowWithName(libraryName2); - await expect(myLibrariesPage.dataTable.getRowByName(libraryName2)).toBeVisible(); + await libraryTable.goThroughPagesLookingForRowWithName(libraryName); + await expect(libraryTable.getRowByName(libraryName)).toBeVisible(); + await libraryTable.goThroughPagesLookingForRowWithName(libraryName2); + await expect(libraryTable.getRowByName(libraryName2)).toBeVisible(); await apiClientFactory.sites.deleteSite(randomLibraryId, { permanent: true }); }); diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts index 8b84b1c340..20de9e94c7 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts @@ -51,12 +51,8 @@ export class AdfLibraryDialogComponent extends BaseComponent { await this.getLabelText('Name *').fill(nameInput); await this.getLabelText('Library ID *').clear(); await this.getLabelText('Library ID *').fill(libraryIdInput); - if (descriptionInput) { - await this.getLabelText('Description').fill(descriptionInput); - } - if (visibility) { - await this.getLabelText(visibility).click(); - } + if (descriptionInput) { await this.getLabelText('Description').fill(descriptionInput); } + if (visibility) { await this.getLabelText(visibility).click(); } await this.createButton.click(); } } diff --git a/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts index d94e755f3b..46ba9d572a 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/my-libraries.page.ts @@ -39,6 +39,11 @@ export class MyLibrariesPage extends BasePage { public libraryDialog = new AdfLibraryDialogComponent(this.page); public dataTable = new DataTableComponent(this.page); public breadcrumb = new AdfBreadcrumbComponent(this.page); - public viewDetails = new AdfInfoDrawerComponent (this.page); + public libraryDetails = new AdfInfoDrawerComponent (this.page); + + async selectCreateLibrary(): Promise { + await this.acaHeader.createButton.click(); + await this.matMenu.createLibrary.click(); + } } From 78a33968c278dc40619866306aebf785c1da8c23 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 18:08:08 +0200 Subject: [PATCH 25/54] adding id to info drawer --- .../actions/src/tests/create-library.spec.ts | 10 ++++++---- .../library-metadata-form.component.html | 8 ++++---- .../components/adf-info-drawer.component.ts | 5 ++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index 8d1e112208..c45d706afc 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -153,10 +153,12 @@ test.describe('Create Libraries ', () => { await expect(libraryTable.getCellLinkByName(randomLibraryName).and(myLibrariesPage.page.getByTitle(randomLibraryDescription))).toBeVisible(); await libraryTable.getRowByName(randomLibraryName).click(); await libraryViewDetails.click(); - await expect(libraryDetails.getFieldData('Name').and(libraryDetails.getFieldData(randomLibraryName))).toBeVisible(); - await expect(libraryDetails.getFieldData('Library ID').and(libraryDetails.getFieldData(randomLibraryId))).toBeVisible(); - await expect(libraryDetails.getFieldData('Visibility').and(libraryDetails.getFieldData(publicVisibility))).toBeVisible(); - await expect(libraryDetails.getFieldData(libraryDescriptionLebel).and(libraryDetails.getFieldData(randomLibraryDescription))).toBeVisible(); + await expect(libraryDetails.getNameField('Name').and(libraryDetails.getNameField(randomLibraryName))).toBeVisible(); + await expect(libraryDetails.getIdField('Library ID').and(libraryDetails.getIdField(randomLibraryId))).toBeVisible(); + await expect(libraryDetails.getVisibilityField('Visibility').and(libraryDetails.getVisibilityField(publicVisibility))).toBeVisible(); + await expect( + libraryDetails.getDescriptionField(libraryDescriptionLebel).and(libraryDetails.getDescriptionField(randomLibraryDescription)) + ).toBeVisible(); await apiClientFactory.sites.deleteSite(randomLibraryId, { permanent: true }); }); diff --git a/projects/aca-content/src/lib/components/info-drawer/library-metadata-tab/library-metadata-form.component.html b/projects/aca-content/src/lib/components/info-drawer/library-metadata-tab/library-metadata-form.component.html index f11ba26e7d..febcac6b9c 100644 --- a/projects/aca-content/src/lib/components/info-drawer/library-metadata-tab/library-metadata-form.component.html +++ b/projects/aca-content/src/lib/components/info-drawer/library-metadata-tab/library-metadata-form.component.html @@ -1,7 +1,7 @@
-
+
@@ -19,7 +19,7 @@
-
+
@@ -37,7 +37,7 @@
-
+
@@ -55,7 +55,7 @@
-
+
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 71ad3e3aa8..0e859048eb 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 @@ -32,5 +32,8 @@ export class AdfInfoDrawerComponent extends BaseComponent { super(page, AdfInfoDrawerComponent.rootElement); } - public getFieldData = (labelText: string) => this.getChild('.mat-form-field-wrapper', { hasText: labelText }); + 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 getDescriptionField = (labelText: string) => this.getChild('[data-automation-id="library-description-properties-wrapper"]', { hasText: labelText }); } From bc73f54fe1307c1045b23b74eabcfd16d72bd8fb Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 22:28:19 +0200 Subject: [PATCH 26/54] adding index and updating import --- e2e/playwright/actions/src/tests/create-library.spec.ts | 3 +-- projects/aca-playwright-shared/src/utils/index.ts | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index c45d706afc..b0af0f0bc7 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -23,9 +23,8 @@ */ import { expect } from '@playwright/test'; -import { libraryErrors, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; +import { GeneralUtils, libraryErrors, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; -import { GeneralUtils } from '../../../../../projects/aca-playwright-shared/src/utils/general-utils'; test.use({ storageState: getUserState('hruser') }); test.describe('Create Libraries ', () => { diff --git a/projects/aca-playwright-shared/src/utils/index.ts b/projects/aca-playwright-shared/src/utils/index.ts index cb79e01dc8..c25a5ee7fb 100644 --- a/projects/aca-playwright-shared/src/utils/index.ts +++ b/projects/aca-playwright-shared/src/utils/index.ts @@ -28,3 +28,4 @@ export * from './exclude-tests'; export * from './state-helper'; export * from './folder-errors'; export * from './library-errors'; +export * from './general-utils'; From 7b7c7509fa29b8521bf24307f7993bcf6ab520b1 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Wed, 12 Jul 2023 07:48:06 +0200 Subject: [PATCH 27/54] next after rebase --- .../aca-playwright-shared/src/fixtures/page-initialization.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index cbdf71531a..37650ece6d 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -24,6 +24,7 @@ import { test as base } from '@playwright/test'; import { + MyLibrariesPage, FileActionsApi, NodesPage, PersonalFilesPage, From 61cec7271eeb1e8f68653ff9f210762e040fb681 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Wed, 12 Jul 2023 12:25:44 +0200 Subject: [PATCH 28/54] update delete in folder tests --- .../actions/src/tests/create-folder.spec.ts | 22 +++++++++---------- .../src/fixtures/page-initialization.ts | 6 +---- .../dataTable/data-table.component.ts | 5 +++++ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-folder.spec.ts b/e2e/playwright/actions/src/tests/create-folder.spec.ts index f15d098e3b..71fc4b5a4b 100644 --- a/e2e/playwright/actions/src/tests/create-folder.spec.ts +++ b/e2e/playwright/actions/src/tests/create-folder.spec.ts @@ -26,7 +26,7 @@ import { expect } from '@playwright/test'; import { folderErrors, getUserState, test } from '@alfresco/playwright-shared'; test.use({ storageState: getUserState('hruser') }); -test.describe('Create actions', () => { +test.describe('Create folders', () => { let randomFolderName: string; let randomFolderTitle: string; let randomFolderDescription: string; @@ -47,7 +47,7 @@ test.describe('Create actions', () => { await personalFiles.dataTable.goThroughPagesLookingForRowWithName(randomFolderName); await expect(personalFiles.dataTable.getRowByName(randomFolderName)).toBeVisible(); - await personalFiles.dataTable.performActionFromExpandableMenu(randomFolderName, 'Delete'); + await personalFiles.dataTable.performActionInExpandableMenu(randomFolderName, 'Delete'); }); test('[C216340] Create a folder with name, title and description', async ({ personalFiles }) => { @@ -59,14 +59,12 @@ test.describe('Create actions', () => { await personalFiles.folderDialog.createButton.click(); await personalFiles.dataTable.goThroughPagesLookingForRowWithName(randomFolderName); - await expect( - personalFiles.dataTable - .getCellLinkByName(randomFolderName) - .and(personalFiles.page.getByTitle(randomFolderTitle)) - .and(personalFiles.page.getByTitle(randomFolderDescription)) - ).toBeVisible(); - - await personalFiles.dataTable.performActionFromExpandableMenu(randomFolderName, 'Delete'); + await expect(personalFiles.dataTable.getCellLinkByName(randomFolderName)).toHaveAttribute( + 'title', + randomFolderTitle + `\n` + randomFolderDescription + ); + + await personalFiles.dataTable.performActionInExpandableMenu(randomFolderName, 'Delete'); }); test('[C216345] Create new folder dialog check', async ({ personalFiles }) => { @@ -152,7 +150,7 @@ test.describe('Create actions', () => { await expect(personalFiles.snackBar.getByMessageLocator(folderErrors.thereIsAlreadyAFolderWithThisName)).toBeVisible(); await personalFiles.folderDialog.cancelButton.click(); - await personalFiles.dataTable.performActionFromExpandableMenu(randomFolderName, 'Delete'); + await personalFiles.dataTable.performActionInExpandableMenu(randomFolderName, 'Delete'); }); test('[C216351] Folder created after trimmed ending spaces from a folder name', async ({ personalFiles }) => { @@ -164,6 +162,6 @@ test.describe('Create actions', () => { await personalFiles.dataTable.goThroughPagesLookingForRowWithName(randomFolderName); await expect(personalFiles.dataTable.getRowByName(randomFolderName)).toBeVisible(); - await personalFiles.dataTable.performActionFromExpandableMenu(randomFolderName, 'Delete'); + await personalFiles.dataTable.performActionInExpandableMenu(randomFolderName, 'Delete'); }); }); diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index b130231bda..364994534f 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -33,8 +33,7 @@ import { SharedPage, SearchPage, FavoritesPage, - FavoritesPageApi, - MyLibrariesPage + FavoritesPageApi } from '../'; interface Pages { @@ -86,8 +85,5 @@ export const test = base.extend({ // eslint-disable-next-line no-empty-pattern favoritesPageAction: async ({}, use) => { await use(await FavoritesPageApi.initialize('admin')); - }, - myLibrariesPage: async ({ page }, use) => { - await use(new MyLibrariesPage(page)); } }); diff --git a/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts index 8ae4a2b822..33b079a3cc 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts @@ -171,6 +171,11 @@ export class DataTableComponent extends BaseComponent { return this.contextMenuActions.getButtonByText(action); } + async performActionInExpandableMenu(name: string | number, action: string): Promise { + await this.getRowByName(name).click({ button: 'right' }); + await this.contextMenuActions.getButtonByText(action).click(); + } + async goThroughPagesLookingForRowWithName(name: string | number): Promise { await this.spinnerWaitForReload(); if (await this.getRowByName(name).isVisible()) { From dffe407fb69781dd9554292fd99ea238f9c331dd Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Wed, 12 Jul 2023 13:47:12 +0200 Subject: [PATCH 29/54] providing string as parameter --- .../actions/src/tests/create-library.spec.ts | 14 ++++----- .../components/aca-header.component.ts | 1 - .../aca-playwright-shared/src/utils/index.ts | 1 - .../src/utils/library-errors.ts | 29 ------------------- 4 files changed, 7 insertions(+), 38 deletions(-) delete mode 100644 projects/aca-playwright-shared/src/utils/library-errors.ts diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index b0af0f0bc7..fed0059b74 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -23,7 +23,7 @@ */ import { expect } from '@playwright/test'; -import { GeneralUtils, libraryErrors, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; +import { GeneralUtils, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; test.use({ storageState: getUserState('hruser') }); @@ -101,7 +101,7 @@ test.describe('Create Libraries ', () => { await libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, publicVisibility)).toBeVisible(); - await libraryTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + await libraryTable.performActionInExpandableMenu(randomLibraryName, deleteAction); }); test('[C289880] Create a moderated library', async ({ myLibrariesPage }) => { @@ -117,7 +117,7 @@ test.describe('Create Libraries ', () => { await libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, moderatedVisibility)).toBeVisible(); - await libraryTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + await libraryTable.performActionInExpandableMenu(randomLibraryName, deleteAction); }); test('[C289881] Create a private library', async ({ myLibrariesPage }) => { @@ -133,7 +133,7 @@ test.describe('Create Libraries ', () => { await libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, privateVisibility)).toBeVisible(); - await libraryTable.performActionFromExpandableMenu(randomLibraryName, deleteAction); + await libraryTable.performActionInExpandableMenu(randomLibraryName, deleteAction); }); test('[C289882] Create a library with a given ID and description', async ({ myLibrariesPage }) => { @@ -171,7 +171,7 @@ test.describe('Create Libraries ', () => { await libraryDialog.getLabelText(libraryIdLebel).fill(commonLibraryId); await expect(libraryDialog.createButton).toBeDisabled(); - await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsNotAvailable)).toBeVisible(); + await expect(libraryDialog.getMatError(`This Library ID isn't available. Try a different Library ID.`)).toBeVisible(); }); test('[C280028] Create library using the ID of a library from the Trashcan', async ({ myLibrariesPage }) => { @@ -185,7 +185,7 @@ test.describe('Create Libraries ', () => { await expect(libraryDialog.createButton).toBeEnabled(); await libraryDialog.createButton.click(); await expect(libraryDialog.createButton).toBeDisabled(); - await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsAlreadyUsed)).toBeVisible(); + await expect(libraryDialog.getMatError(`This Library ID is already used. Check the trashcan.`)).toBeVisible(); }); test('[C280029] Cancel button', async ({ myLibrariesPage }) => { @@ -232,7 +232,7 @@ test.describe('Create Libraries ', () => { await libraryDialog.getLabelText(libraryIdLebel).clear(); await libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); - await expect(libraryDialog.getMatError(libraryErrors.useNumbersAndLettersOnly)).toBeVisible(); + await expect(libraryDialog.getMatError(`Use numbers and letters only`)).toBeVisible(); await expect(libraryDialog.createButton).toBeDisabled(); } }); diff --git a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts index f037e4aab2..426a38bbb5 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts @@ -30,7 +30,6 @@ export class AcaHeader extends BaseComponent { public viewDetails = this.getChild('[title="View Details"]'); public viewButton = this.getChild('button[title="View"]'); public searchButton = this.getChild('button[title="Search"]'); - public viewDetails = this.getChild('[title="View Details"]'); constructor(page: Page) { super(page, AcaHeader.rootElement); diff --git a/projects/aca-playwright-shared/src/utils/index.ts b/projects/aca-playwright-shared/src/utils/index.ts index c25a5ee7fb..fa629b3a0a 100644 --- a/projects/aca-playwright-shared/src/utils/index.ts +++ b/projects/aca-playwright-shared/src/utils/index.ts @@ -27,5 +27,4 @@ export * from './timeouts'; export * from './exclude-tests'; export * from './state-helper'; export * from './folder-errors'; -export * from './library-errors'; export * from './general-utils'; diff --git a/projects/aca-playwright-shared/src/utils/library-errors.ts b/projects/aca-playwright-shared/src/utils/library-errors.ts deleted file mode 100644 index 57d4619a41..0000000000 --- a/projects/aca-playwright-shared/src/utils/library-errors.ts +++ /dev/null @@ -1,29 +0,0 @@ -/*! - * 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 . - */ - -export const libraryErrors = { - libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID.`, - libraryIdIsAlreadyUsed: `This Library ID is already used. Check the trashcan.`, - useNumbersAndLettersOnly: `Use numbers and letters only` -} From 3f385f9c6e9895af19cad9c9d8a06734d27af03b Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 7 Jul 2023 15:57:09 +0200 Subject: [PATCH 30/54] after rebase --- .../src/fixtures/page-initialization.ts | 6 +++- .../components/aca-header.component.ts | 1 + .../src/utils/library-errors.ts | 29 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 projects/aca-playwright-shared/src/utils/library-errors.ts diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index 364994534f..b130231bda 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -33,7 +33,8 @@ import { SharedPage, SearchPage, FavoritesPage, - FavoritesPageApi + FavoritesPageApi, + MyLibrariesPage } from '../'; interface Pages { @@ -85,5 +86,8 @@ export const test = base.extend({ // eslint-disable-next-line no-empty-pattern favoritesPageAction: async ({}, use) => { await use(await FavoritesPageApi.initialize('admin')); + }, + myLibrariesPage: async ({ page }, use) => { + await use(new MyLibrariesPage(page)); } }); diff --git a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts index 426a38bbb5..f037e4aab2 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts @@ -30,6 +30,7 @@ export class AcaHeader extends BaseComponent { public viewDetails = this.getChild('[title="View Details"]'); public viewButton = this.getChild('button[title="View"]'); public searchButton = this.getChild('button[title="Search"]'); + public viewDetails = this.getChild('[title="View Details"]'); constructor(page: Page) { super(page, AcaHeader.rootElement); diff --git a/projects/aca-playwright-shared/src/utils/library-errors.ts b/projects/aca-playwright-shared/src/utils/library-errors.ts new file mode 100644 index 0000000000..c0b5648ad5 --- /dev/null +++ b/projects/aca-playwright-shared/src/utils/library-errors.ts @@ -0,0 +1,29 @@ +/*! + * 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 . + */ + +export const libraryErrors = { + libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID`, + libraryIdIsAlreadyUsed: `This Library ID is already used. Check the trashcan.`, + useNumbersAndLettersOnly: `Use numbers and letters only` +} From 29d35064852c3c41dedf0d38b994ebc96be7367f Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 7 Jul 2023 19:40:18 +0200 Subject: [PATCH 31/54] updating tests and adding before and after all --- projects/aca-playwright-shared/src/utils/library-errors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/utils/library-errors.ts b/projects/aca-playwright-shared/src/utils/library-errors.ts index c0b5648ad5..57d4619a41 100644 --- a/projects/aca-playwright-shared/src/utils/library-errors.ts +++ b/projects/aca-playwright-shared/src/utils/library-errors.ts @@ -23,7 +23,7 @@ */ export const libraryErrors = { - libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID`, + libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID.`, libraryIdIsAlreadyUsed: `This Library ID is already used. Check the trashcan.`, useNumbersAndLettersOnly: `Use numbers and letters only` } From 0422c71a488f1deacc0929c049d6bce34972a270 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 09:16:34 +0200 Subject: [PATCH 32/54] adding random method in general utils --- e2e/playwright/actions/src/tests/create-library.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index fed0059b74..2aa8f5f9e9 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -25,6 +25,7 @@ import { expect } from '@playwright/test'; import { GeneralUtils, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; +import { GeneralUtils } from '../../../../../projects/aca-playwright-shared/src/utils/general-utils'; test.use({ storageState: getUserState('hruser') }); test.describe('Create Libraries ', () => { From f235eb2b6986675f9b1f30fb49bf9e614b2955d1 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 7 Jul 2023 15:57:09 +0200 Subject: [PATCH 33/54] [ACS-511]-adding-library-tests --- .../aca-playwright-shared/src/fixtures/page-initialization.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index b130231bda..52ba118f2a 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -89,5 +89,5 @@ export const test = base.extend({ }, myLibrariesPage: async ({ page }, use) => { await use(new MyLibrariesPage(page)); - } + }, }); From 33a1052509e46e8b125ebf126c0b29584220e46b Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 13:47:05 +0200 Subject: [PATCH 34/54] comma deleted --- .../aca-playwright-shared/src/fixtures/page-initialization.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index 52ba118f2a..b130231bda 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -89,5 +89,5 @@ export const test = base.extend({ }, myLibrariesPage: async ({ page }, use) => { await use(new MyLibrariesPage(page)); - }, + } }); From 72909ac2f1b487d143d2bb15639c6ca9418a69ff Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 7 Jul 2023 15:57:09 +0200 Subject: [PATCH 35/54] [ACS-511]-adding-library-tests --- .../src/fixtures/page-initialization.ts | 6 +----- .../src/page-objects/components/index.ts | 2 -- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index b130231bda..364994534f 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -33,8 +33,7 @@ import { SharedPage, SearchPage, FavoritesPage, - FavoritesPageApi, - MyLibrariesPage + FavoritesPageApi } from '../'; interface Pages { @@ -86,8 +85,5 @@ export const test = base.extend({ // eslint-disable-next-line no-empty-pattern favoritesPageAction: async ({}, use) => { await use(await FavoritesPageApi.initialize('admin')); - }, - myLibrariesPage: async ({ page }, use) => { - await use(new MyLibrariesPage(page)); } }); diff --git a/projects/aca-playwright-shared/src/page-objects/components/index.ts b/projects/aca-playwright-shared/src/page-objects/components/index.ts index 31e84f4965..df6a0f3ca3 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/index.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/index.ts @@ -36,6 +36,4 @@ export * from './adf-info-drawer.component'; export * from './viewer.component'; export * from './search/search-input.component'; export * from './search/search-overlay.components'; -export * from './breadcrumb'; -export * from './adf-info-drawer.component'; From a3407a6af71deea80838ef82a01f7211d9e350e7 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 22:28:19 +0200 Subject: [PATCH 36/54] adding index and updating import --- e2e/playwright/actions/src/tests/create-library.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index 2aa8f5f9e9..fed0059b74 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -25,7 +25,6 @@ import { expect } from '@playwright/test'; import { GeneralUtils, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; -import { GeneralUtils } from '../../../../../projects/aca-playwright-shared/src/utils/general-utils'; test.use({ storageState: getUserState('hruser') }); test.describe('Create Libraries ', () => { From e2f6d2b1cbc1f01ed97b4459a8da079cc39fc458 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Wed, 12 Jul 2023 13:47:12 +0200 Subject: [PATCH 37/54] providing string as parameter --- .../components/aca-header.component.ts | 1 - .../src/utils/library-errors.ts | 29 ------------------- 2 files changed, 30 deletions(-) delete mode 100644 projects/aca-playwright-shared/src/utils/library-errors.ts diff --git a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts index f037e4aab2..426a38bbb5 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts @@ -30,7 +30,6 @@ export class AcaHeader extends BaseComponent { public viewDetails = this.getChild('[title="View Details"]'); public viewButton = this.getChild('button[title="View"]'); public searchButton = this.getChild('button[title="Search"]'); - public viewDetails = this.getChild('[title="View Details"]'); constructor(page: Page) { super(page, AcaHeader.rootElement); diff --git a/projects/aca-playwright-shared/src/utils/library-errors.ts b/projects/aca-playwright-shared/src/utils/library-errors.ts deleted file mode 100644 index 57d4619a41..0000000000 --- a/projects/aca-playwright-shared/src/utils/library-errors.ts +++ /dev/null @@ -1,29 +0,0 @@ -/*! - * 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 . - */ - -export const libraryErrors = { - libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID.`, - libraryIdIsAlreadyUsed: `This Library ID is already used. Check the trashcan.`, - useNumbersAndLettersOnly: `Use numbers and letters only` -} From 1c7564b95fd80f97ffe40111fb36384f1b2f0a58 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Wed, 12 Jul 2023 15:52:37 +0200 Subject: [PATCH 38/54] delete protractor create-library tests --- .../actions/create/create-library.test.ts | 240 ------------------ 1 file changed, 240 deletions(-) delete mode 100755 e2e/protractor/suites/actions/create/create-library.test.ts diff --git a/e2e/protractor/suites/actions/create/create-library.test.ts b/e2e/protractor/suites/actions/create/create-library.test.ts deleted file mode 100755 index 874a1f702a..0000000000 --- a/e2e/protractor/suites/actions/create/create-library.test.ts +++ /dev/null @@ -1,240 +0,0 @@ -/*! - * 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 { - AdminActions, - SITE_VISIBILITY, - LoginPage, - BrowsingPage, - CreateLibraryDialog, - Utils, - RepoClient, - UserActions -} from '@alfresco/aca-testing-shared'; -import { BrowserActions } from '@alfresco/adf-testing'; - -describe('Create library', () => { - const username = `user-${Utils.random()}`; - - const site1Name = `site1-${Utils.random()}`; - const site2Name = `site2-${Utils.random()}`; - const site3Name = `site3-${Utils.random()}`; - - const site4 = { - name: `site4-${Utils.random()}`, - id: `site4-id-${Utils.random()}`, - description: 'site4 description' - }; - - const duplicateSite = { - name: `duplicate-${Utils.random()}`, - id: `duplicate-${Utils.random()}` - }; - - const siteInTrash = { - name: `site-trash-${Utils.random()}`, - id: `site-trash-id-${Utils.random()}` - }; - - const apis = { - user: new RepoClient(username, username) - }; - - const loginPage = new LoginPage(); - const page = new BrowsingPage(); - const createDialog = new CreateLibraryDialog(); - const { dataTable } = page; - const adminApiActions = new AdminActions(); - const userActions = new UserActions(); - - beforeAll(async () => { - await adminApiActions.createUser({ username }); - await apis.user.sites.createSite(duplicateSite.name, SITE_VISIBILITY.PRIVATE, '', duplicateSite.id); - await apis.user.sites.createSite(siteInTrash.name, SITE_VISIBILITY.PUBLIC, '', siteInTrash.id); - await apis.user.sites.deleteSite(siteInTrash.id, false); - - await loginPage.loginWith(username); - }); - - afterEach(async () => { - await Utils.pressEscape(); - }); - - afterAll(async () => { - await apis.user.sites.deleteAllUserSites(); - await userActions.login(username, username); - await userActions.emptyTrashcan(); - }); - - it('[C280024] Create Library dialog UI', async () => { - await page.goToMyLibrariesAndWait(); - - await page.toolbar.openCreateLibraryDialog(); - await createDialog.waitForDialogToOpen(); - - expect(await createDialog.getDialogTitle()).toMatch('Create Library'); - expect(await createDialog.nameInput.isDisplayed()).toBe(true, 'Name input is not displayed'); - expect(await createDialog.libraryIdInput.isDisplayed()).toBe(true, 'Library ID input is not displayed'); - expect(await createDialog.descriptionTextArea.isDisplayed()).toBe(true, 'Description field is not displayed'); - expect(await createDialog.visibilityPublic.isDisplayed()).toBe(true, 'Public option is not displayed'); - expect(await createDialog.visibilityModerated.isDisplayed()).toBe(true, 'Moderated option is not displayed'); - expect(await createDialog.visibilityPrivate.isDisplayed()).toBe(true, 'Private option is not displayed'); - expect(await createDialog.isPublicChecked()).toBe(true, 'Public option not checked'); - expect(await createDialog.isCreateEnabled()).toBe(false, 'Create button is not disabled'); - expect(await createDialog.isCancelEnabled()).toBe(true, 'Cancel button is not enabled'); - }); - - it('[C280025] Create a public library', async () => { - await page.goToMyLibrariesAndWait(); - - await page.toolbar.openCreateLibraryDialog(); - await createDialog.waitForDialogToOpen(); - await createDialog.enterName(site1Name); - await BrowserActions.click(createDialog.createButton); - await createDialog.waitForDialogToClose(); - - expect(await page.breadcrumb.currentItem.getText()).toEqual(site1Name, `Not navigated into ${site1Name}`); - await page.goToMyLibrariesAndWait(); - expect(await dataTable.isItemPresent(site1Name)).toBe(true, `${site1Name} not in the list`); - expect((await apis.user.sites.getSite(site1Name)).entry.visibility).toEqual(SITE_VISIBILITY.PUBLIC); - }); - - it('[C289880] Create a moderated library', async () => { - await page.goToMyLibrariesAndWait(); - - await page.toolbar.openCreateLibraryDialog(); - await createDialog.waitForDialogToOpen(); - await createDialog.enterName(site2Name); - await BrowserActions.click(createDialog.visibilityModerated); - await BrowserActions.click(createDialog.createButton); - await createDialog.waitForDialogToClose(); - - expect(await page.breadcrumb.currentItem.getText()).toEqual(site2Name, `Not navigated into ${site2Name}`); - await page.goToMyLibrariesAndWait(); - expect(await dataTable.isItemPresent(site2Name)).toBe(true, `${site2Name} not in the list`); - expect((await apis.user.sites.getSite(site2Name)).entry.visibility).toEqual(SITE_VISIBILITY.MODERATED); - }); - - it('[C289881] Create a private library', async () => { - await page.goToMyLibrariesAndWait(); - - await page.toolbar.openCreateLibraryDialog(); - await createDialog.waitForDialogToOpen(); - await createDialog.enterName(site3Name); - await BrowserActions.click(createDialog.visibilityPrivate); - await BrowserActions.click(createDialog.createButton); - await createDialog.waitForDialogToClose(); - - expect(await page.breadcrumb.currentItem.getText()).toEqual(site3Name, `Not navigated into ${site3Name}`); - await page.goToMyLibrariesAndWait(); - expect(await dataTable.isItemPresent(site3Name)).toBe(true, `${site3Name} not in the list`); - expect((await apis.user.sites.getSite(site3Name)).entry.visibility).toEqual(SITE_VISIBILITY.PRIVATE); - }); - - it('[C289882] Create a library with a given ID and description', async () => { - await page.goToMyLibrariesAndWait(); - - await page.toolbar.openCreateLibraryDialog(); - await createDialog.waitForDialogToOpen(); - await createDialog.enterName(site4.name); - await createDialog.enterLibraryId(site4.id); - await createDialog.enterDescription(site4.description); - await BrowserActions.click(createDialog.visibilityPublic); - await BrowserActions.click(createDialog.createButton); - await createDialog.waitForDialogToClose(); - - expect(await page.breadcrumb.currentItem.getText()).toEqual(site4.name, `Not navigated into ${site4.name}`); - await page.goToMyLibrariesAndWait(); - expect(await dataTable.isItemPresent(site4.name)).toBe(true, `${site4.name} not in the list`); - expect((await apis.user.sites.getSite(site4.id)).entry.visibility).toEqual(SITE_VISIBILITY.PUBLIC); - expect((await apis.user.sites.getSite(site4.id)).entry.description).toEqual(site4.description); - }); - - it('[C280027] Duplicate library ID', async () => { - await page.goToMyLibrariesAndWait(); - - await page.toolbar.openCreateLibraryDialog(); - await createDialog.waitForDialogToOpen(); - await createDialog.enterName(duplicateSite.name); - await createDialog.enterLibraryId(duplicateSite.id); - - expect(await createDialog.isCreateEnabled()).toBe(false, 'Create button not disabled'); - expect(await createDialog.getErrorMessage()).toEqual(`This Library ID isn't available. Try a different Library ID.`); - }); - - it('[C280028] Create library using the ID of a library from the Trashcan', async () => { - await page.goToMyLibrariesAndWait(); - - await page.toolbar.openCreateLibraryDialog(); - await createDialog.waitForDialogToOpen(); - await createDialog.enterName(siteInTrash.name); - await createDialog.enterLibraryId(siteInTrash.id); - await BrowserActions.click(createDialog.createButton); - - expect(await createDialog.getErrorMessage()).toEqual(`This Library ID is already used. Check the trashcan.`); - }); - - it('[C280029] Cancel button', async () => { - await page.goToMyLibrariesAndWait(); - - await page.toolbar.openCreateLibraryDialog(); - await createDialog.waitForDialogToOpen(); - await createDialog.enterName('test site'); - await createDialog.enterDescription('test description'); - await createDialog.clickCancel(); - - expect(await createDialog.isDialogOpen()).not.toBe(true, 'dialog is not closed'); - }); - - it('[C280026] Library ID cannot contain special characters', async () => { - const idWithSpecialChars = ['a*a', 'a"a', 'aa', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a']; - - await page.goToMyLibrariesAndWait(); - await page.toolbar.openCreateLibraryDialog(); - await createDialog.waitForDialogToOpen(); - await createDialog.enterName('test site'); - - for (const id of idWithSpecialChars) { - await createDialog.enterLibraryId(id); - expect(await createDialog.isCreateEnabled()).toBe(false, 'Create button is not disabled'); - expect(await createDialog.getErrorMessage()).toContain(`Use numbers and letters only`); - } - }); - - it('[C280030] Create 2 libraries with same name but different IDs', async () => { - await page.goToMyLibrariesAndWait(); - - await page.toolbar.openCreateLibraryDialog(); - await createDialog.waitForDialogToOpen(); - await createDialog.enterName(duplicateSite.name); - await createDialog.enterLibraryId(`${duplicateSite.id}-2`); - await BrowserActions.click(createDialog.createButton); - await createDialog.waitForDialogToClose(); - - expect(await page.breadcrumb.currentItem.getText()).toEqual(duplicateSite.name, `Not navigated into ${duplicateSite.name}`); - await page.goToMyLibrariesAndWait(); - expect(await dataTable.isItemPresent(`${duplicateSite.name} (${duplicateSite.id}-2)`)).toBe(true, `${duplicateSite.name} not in the list`); - expect((await apis.user.sites.getSite(`${duplicateSite.id}-2`)).entry.title).toEqual(duplicateSite.name); - }); -}); From 62c2ee32b3aa05ee5e09512900dcc999240e0f49 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Wed, 12 Jul 2023 20:24:02 +0200 Subject: [PATCH 39/54] update for calls in expect method --- .../actions/src/tests/create-library.spec.ts | 18 +++++------- .../breadcrumb/breadcrumb.component.ts | 2 +- .../dialogs/adf-library-dialog.component.ts | 2 +- .../aca-playwright-shared/src/utils/index.ts | 1 + .../src/utils/library-errors.ts | 29 +++++++++++++++++++ 5 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 projects/aca-playwright-shared/src/utils/library-errors.ts diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index fed0059b74..bcc1dc9654 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -23,7 +23,7 @@ */ import { expect } from '@playwright/test'; -import { GeneralUtils, ApiClientFactory, getUserState, test } from '@alfresco/playwright-shared'; +import { GeneralUtils, ApiClientFactory, getUserState, test, libraryErrors } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; test.use({ storageState: getUserState('hruser') }); @@ -152,12 +152,10 @@ test.describe('Create Libraries ', () => { await expect(libraryTable.getCellLinkByName(randomLibraryName).and(myLibrariesPage.page.getByTitle(randomLibraryDescription))).toBeVisible(); await libraryTable.getRowByName(randomLibraryName).click(); await libraryViewDetails.click(); - await expect(libraryDetails.getNameField('Name').and(libraryDetails.getNameField(randomLibraryName))).toBeVisible(); - await expect(libraryDetails.getIdField('Library ID').and(libraryDetails.getIdField(randomLibraryId))).toBeVisible(); - await expect(libraryDetails.getVisibilityField('Visibility').and(libraryDetails.getVisibilityField(publicVisibility))).toBeVisible(); - await expect( - libraryDetails.getDescriptionField(libraryDescriptionLebel).and(libraryDetails.getDescriptionField(randomLibraryDescription)) - ).toBeVisible(); + await expect(libraryDetails.getNameField('Name').getByText(randomLibraryName)).toBeVisible(); + await expect(libraryDetails.getIdField('Library ID').getByText(randomLibraryId)).toBeVisible(); + await expect(libraryDetails.getVisibilityField('Visibility').getByText(publicVisibility)).toBeVisible(); + await expect(libraryDetails.getDescriptionField(libraryDescriptionLebel).getByText(randomLibraryDescription)).toBeVisible(); await apiClientFactory.sites.deleteSite(randomLibraryId, { permanent: true }); }); @@ -171,7 +169,7 @@ test.describe('Create Libraries ', () => { await libraryDialog.getLabelText(libraryIdLebel).fill(commonLibraryId); await expect(libraryDialog.createButton).toBeDisabled(); - await expect(libraryDialog.getMatError(`This Library ID isn't available. Try a different Library ID.`)).toBeVisible(); + await expect(libraryDialog.getMatError()).toContainText(libraryErrors.libraryIdIsNotAvailable); }); test('[C280028] Create library using the ID of a library from the Trashcan', async ({ myLibrariesPage }) => { @@ -185,7 +183,7 @@ test.describe('Create Libraries ', () => { await expect(libraryDialog.createButton).toBeEnabled(); await libraryDialog.createButton.click(); await expect(libraryDialog.createButton).toBeDisabled(); - await expect(libraryDialog.getMatError(`This Library ID is already used. Check the trashcan.`)).toBeVisible(); + await expect(libraryDialog.getMatError()).toContainText(libraryErrors.libraryIdIsAlreadyUsed); }); test('[C280029] Cancel button', async ({ myLibrariesPage }) => { @@ -232,7 +230,7 @@ test.describe('Create Libraries ', () => { await libraryDialog.getLabelText(libraryIdLebel).clear(); await libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); - await expect(libraryDialog.getMatError(`Use numbers and letters only`)).toBeVisible(); + await expect(libraryDialog.getMatError()).toContainText(libraryErrors.useNumbersAndLettersOnly); await expect(libraryDialog.createButton).toBeDisabled(); } }); diff --git a/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/breadcrumb.component.ts b/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/breadcrumb.component.ts index 2b88148f10..d18462c820 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/breadcrumb.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/breadcrumb/breadcrumb.component.ts @@ -32,5 +32,5 @@ export class AdfBreadcrumbComponent extends BaseComponent { super(page, AdfBreadcrumbComponent.rootElement); } - public getBreadcrumbItem = (text: string) => this.getChild('.adf-breadcrumb-item', { hasText: text }); + public getBreadcrumbItem = (text: string) => this.getChild('.adf-breadcrumb-item-current', { hasText: text }); } diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts index 20de9e94c7..3a2a964d81 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts @@ -37,7 +37,7 @@ export class AdfLibraryDialogComponent extends BaseComponent { public getLabelText = (text: string) => this.getChild('label', { hasText: text }); public getDialogTitle = (text: string) => this.getChild('.mat-dialog-title', { hasText: text }); - public getMatError = (text: string) => this.getChild('mat-error', { hasText: text }); + public getMatError = () => this.getChild('mat-error'); /** * This method is used when we want to fill in Create Library Dialog and choose Create button diff --git a/projects/aca-playwright-shared/src/utils/index.ts b/projects/aca-playwright-shared/src/utils/index.ts index fa629b3a0a..d4679d4bde 100644 --- a/projects/aca-playwright-shared/src/utils/index.ts +++ b/projects/aca-playwright-shared/src/utils/index.ts @@ -28,3 +28,4 @@ export * from './exclude-tests'; export * from './state-helper'; export * from './folder-errors'; export * from './general-utils'; +export * from './library-errors'; diff --git a/projects/aca-playwright-shared/src/utils/library-errors.ts b/projects/aca-playwright-shared/src/utils/library-errors.ts new file mode 100644 index 0000000000..57d4619a41 --- /dev/null +++ b/projects/aca-playwright-shared/src/utils/library-errors.ts @@ -0,0 +1,29 @@ +/*! + * 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 . + */ + +export const libraryErrors = { + libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID.`, + libraryIdIsAlreadyUsed: `This Library ID is already used. Check the trashcan.`, + useNumbersAndLettersOnly: `Use numbers and letters only` +} From 67fbf41b217c2c61205d852c9538b819e610a9a1 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Wed, 12 Jul 2023 15:02:14 +0100 Subject: [PATCH 40/54] bump to 4.2.0 (#3334) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index db2bee3825..17b99a2163 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "alfresco-content-app", - "version": "4.1.0", + "version": "4.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "alfresco-content-app", - "version": "4.1.0", + "version": "4.2.0", "hasInstallScript": true, "license": "LGPL-3.0", "dependencies": { diff --git a/package.json b/package.json index 40423c505e..9894e9886c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alfresco-content-app", - "version": "4.1.0", + "version": "4.2.0", "license": "LGPL-3.0", "scripts": { "postinstall": "ngcc", From 36abb0b8cc92ee7f8bf3d52f6f511921f1ab60a5 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 09:16:34 +0200 Subject: [PATCH 41/54] adding random method in general utils --- e2e/playwright/actions/src/tests/create-library.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index bcc1dc9654..0544fbe5f0 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -25,6 +25,7 @@ import { expect } from '@playwright/test'; import { GeneralUtils, ApiClientFactory, getUserState, test, libraryErrors } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; +import { GeneralUtils } from '../../../../../projects/aca-playwright-shared/src/utils/general-utils'; test.use({ storageState: getUserState('hruser') }); test.describe('Create Libraries ', () => { From 3e9a701f05ac465131cded2b75f48763a2a44329 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 11 Jul 2023 22:28:19 +0200 Subject: [PATCH 42/54] adding index and updating import --- e2e/playwright/actions/src/tests/create-library.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index 0544fbe5f0..bcc1dc9654 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -25,7 +25,6 @@ import { expect } from '@playwright/test'; import { GeneralUtils, ApiClientFactory, getUserState, test, libraryErrors } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; -import { GeneralUtils } from '../../../../../projects/aca-playwright-shared/src/utils/general-utils'; test.use({ storageState: getUserState('hruser') }); test.describe('Create Libraries ', () => { From a7b0b89938327e2dd0b24c485410a888b0a79b59 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Wed, 12 Jul 2023 13:47:12 +0200 Subject: [PATCH 43/54] providing string as parameter --- .../src/utils/library-errors.ts | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 projects/aca-playwright-shared/src/utils/library-errors.ts diff --git a/projects/aca-playwright-shared/src/utils/library-errors.ts b/projects/aca-playwright-shared/src/utils/library-errors.ts deleted file mode 100644 index 57d4619a41..0000000000 --- a/projects/aca-playwright-shared/src/utils/library-errors.ts +++ /dev/null @@ -1,29 +0,0 @@ -/*! - * 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 . - */ - -export const libraryErrors = { - libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID.`, - libraryIdIsAlreadyUsed: `This Library ID is already used. Check the trashcan.`, - useNumbersAndLettersOnly: `Use numbers and letters only` -} From 62352e51cdc9cbf1cc2240a16c350bd3f45a1acf Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 7 Jul 2023 15:57:09 +0200 Subject: [PATCH 44/54] after rebase --- .../src/fixtures/page-initialization.ts | 6 +++- .../components/aca-header.component.ts | 1 + .../src/utils/library-errors.ts | 29 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 projects/aca-playwright-shared/src/utils/library-errors.ts diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index 364994534f..b130231bda 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -33,7 +33,8 @@ import { SharedPage, SearchPage, FavoritesPage, - FavoritesPageApi + FavoritesPageApi, + MyLibrariesPage } from '../'; interface Pages { @@ -85,5 +86,8 @@ export const test = base.extend({ // eslint-disable-next-line no-empty-pattern favoritesPageAction: async ({}, use) => { await use(await FavoritesPageApi.initialize('admin')); + }, + myLibrariesPage: async ({ page }, use) => { + await use(new MyLibrariesPage(page)); } }); diff --git a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts index 426a38bbb5..f037e4aab2 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts @@ -30,6 +30,7 @@ export class AcaHeader extends BaseComponent { public viewDetails = this.getChild('[title="View Details"]'); public viewButton = this.getChild('button[title="View"]'); public searchButton = this.getChild('button[title="Search"]'); + public viewDetails = this.getChild('[title="View Details"]'); constructor(page: Page) { super(page, AcaHeader.rootElement); diff --git a/projects/aca-playwright-shared/src/utils/library-errors.ts b/projects/aca-playwright-shared/src/utils/library-errors.ts new file mode 100644 index 0000000000..c0b5648ad5 --- /dev/null +++ b/projects/aca-playwright-shared/src/utils/library-errors.ts @@ -0,0 +1,29 @@ +/*! + * 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 . + */ + +export const libraryErrors = { + libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID`, + libraryIdIsAlreadyUsed: `This Library ID is already used. Check the trashcan.`, + useNumbersAndLettersOnly: `Use numbers and letters only` +} From dbffeb104af062b0f64afa6842b3299b8c723b74 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Wed, 12 Jul 2023 13:47:12 +0200 Subject: [PATCH 45/54] providing string as parameter --- .../src/page-objects/components/aca-header.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts index f037e4aab2..426a38bbb5 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts @@ -30,7 +30,6 @@ export class AcaHeader extends BaseComponent { public viewDetails = this.getChild('[title="View Details"]'); public viewButton = this.getChild('button[title="View"]'); public searchButton = this.getChild('button[title="Search"]'); - public viewDetails = this.getChild('[title="View Details"]'); constructor(page: Page) { super(page, AcaHeader.rootElement); From fedf5a58e704ce17731e9883946b4618816e5184 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Thu, 13 Jul 2023 09:55:52 +0200 Subject: [PATCH 46/54] update for tests C280026 and C280027 --- e2e/playwright/actions/src/tests/create-library.spec.ts | 7 ++++--- .../src/fixtures/page-initialization.ts | 6 +----- projects/aca-playwright-shared/src/utils/library-errors.ts | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index bcc1dc9654..a73a809895 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -167,9 +167,10 @@ test.describe('Create Libraries ', () => { await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); await libraryDialog.getLabelText(libraryIdLebel).clear(); await libraryDialog.getLabelText(libraryIdLebel).fill(commonLibraryId); + await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(commonLibraryId); await expect(libraryDialog.createButton).toBeDisabled(); - await expect(libraryDialog.getMatError()).toContainText(libraryErrors.libraryIdIsNotAvailable); + await expect(libraryDialog.getMatError()).toHaveText(libraryErrors.libraryIdIsNotAvailable); }); test('[C280028] Create library using the ID of a library from the Trashcan', async ({ myLibrariesPage }) => { @@ -183,7 +184,7 @@ test.describe('Create Libraries ', () => { await expect(libraryDialog.createButton).toBeEnabled(); await libraryDialog.createButton.click(); await expect(libraryDialog.createButton).toBeDisabled(); - await expect(libraryDialog.getMatError()).toContainText(libraryErrors.libraryIdIsAlreadyUsed); + await expect(libraryDialog.getMatError()).toHaveText(libraryErrors.libraryIdIsAlreadyUsed); }); test('[C280029] Cancel button', async ({ myLibrariesPage }) => { @@ -230,7 +231,7 @@ test.describe('Create Libraries ', () => { await libraryDialog.getLabelText(libraryIdLebel).clear(); await libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); - await expect(libraryDialog.getMatError()).toContainText(libraryErrors.useNumbersAndLettersOnly); + await expect(libraryDialog.getMatError()).toHaveText(libraryErrors.useNumbersAndLettersOnly); await expect(libraryDialog.createButton).toBeDisabled(); } }); diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index b130231bda..181f91d056 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -33,8 +33,7 @@ import { SharedPage, SearchPage, FavoritesPage, - FavoritesPageApi, - MyLibrariesPage + FavoritesPageApi } from '../'; interface Pages { @@ -60,9 +59,6 @@ export const test = base.extend({ nodesPage: async ({ page }, use) => { await use(new NodesPage(page)); }, - myLibrariesPage: async ({ page }, use) => { - await use(new MyLibrariesPage(page)); - }, recentFilesPage: async ({ page }, use) => { await use(new RecentFilesPage(page)); }, diff --git a/projects/aca-playwright-shared/src/utils/library-errors.ts b/projects/aca-playwright-shared/src/utils/library-errors.ts index c0b5648ad5..57d4619a41 100644 --- a/projects/aca-playwright-shared/src/utils/library-errors.ts +++ b/projects/aca-playwright-shared/src/utils/library-errors.ts @@ -23,7 +23,7 @@ */ export const libraryErrors = { - libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID`, + libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID.`, libraryIdIsAlreadyUsed: `This Library ID is already used. Check the trashcan.`, useNumbersAndLettersOnly: `Use numbers and letters only` } From d77ede7bffe07b8808666dea12ee17b974ee4a28 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Thu, 13 Jul 2023 17:46:05 +0200 Subject: [PATCH 47/54] raising time for visibility check --- e2e/playwright/actions/src/tests/create-library.spec.ts | 8 ++++---- .../components/dialogs/adf-library-dialog.component.ts | 2 +- projects/aca-playwright-shared/src/utils/timeouts.ts | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index a73a809895..f5cbd3ed84 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -23,7 +23,7 @@ */ import { expect } from '@playwright/test'; -import { GeneralUtils, ApiClientFactory, getUserState, test, libraryErrors } from '@alfresco/playwright-shared'; +import { GeneralUtils, ApiClientFactory, getUserState, test, libraryErrors, timeouts } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; test.use({ storageState: getUserState('hruser') }); @@ -170,7 +170,7 @@ test.describe('Create Libraries ', () => { await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(commonLibraryId); await expect(libraryDialog.createButton).toBeDisabled(); - await expect(libraryDialog.getMatError()).toHaveText(libraryErrors.libraryIdIsNotAvailable); + await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsNotAvailable)).toBeVisible({ timeout: timeouts.big }); }); test('[C280028] Create library using the ID of a library from the Trashcan', async ({ myLibrariesPage }) => { @@ -184,7 +184,7 @@ test.describe('Create Libraries ', () => { await expect(libraryDialog.createButton).toBeEnabled(); await libraryDialog.createButton.click(); await expect(libraryDialog.createButton).toBeDisabled(); - await expect(libraryDialog.getMatError()).toHaveText(libraryErrors.libraryIdIsAlreadyUsed); + await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsAlreadyUsed)).toBeVisible({ timeout: timeouts.big }); }); test('[C280029] Cancel button', async ({ myLibrariesPage }) => { @@ -231,7 +231,7 @@ test.describe('Create Libraries ', () => { await libraryDialog.getLabelText(libraryIdLebel).clear(); await libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); - await expect(libraryDialog.getMatError()).toHaveText(libraryErrors.useNumbersAndLettersOnly); + await expect(libraryDialog.getMatError(libraryErrors.useNumbersAndLettersOnly)).toBeVisible({ timeout: timeouts.big }); await expect(libraryDialog.createButton).toBeDisabled(); } }); diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts index 3a2a964d81..2362a83b56 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts @@ -37,7 +37,7 @@ export class AdfLibraryDialogComponent extends BaseComponent { public getLabelText = (text: string) => this.getChild('label', { hasText: text }); public getDialogTitle = (text: string) => this.getChild('.mat-dialog-title', { hasText: text }); - public getMatError = () => this.getChild('mat-error'); + public getMatError = (text: string) => this.getChild('.mat-error', { hasText: text }); /** * This method is used when we want to fill in Create Library Dialog and choose Create button diff --git a/projects/aca-playwright-shared/src/utils/timeouts.ts b/projects/aca-playwright-shared/src/utils/timeouts.ts index 31b43b13f4..8d86987f25 100644 --- a/projects/aca-playwright-shared/src/utils/timeouts.ts +++ b/projects/aca-playwright-shared/src/utils/timeouts.ts @@ -28,6 +28,7 @@ export const timeouts = { short: 1000, normal: 2000, medium: 5000, + big: 7500, large: 10000, extraLarge: 20 * 1000, globalTest: 45 * 1000, From ad1c2a92aeae31c0a291632e7e627bb119e5005d Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Thu, 13 Jul 2023 20:24:47 +0200 Subject: [PATCH 48/54] quotes change in error strings --- e2e/playwright/actions/src/tests/create-library.spec.ts | 8 ++++---- .../aca-playwright-shared/src/utils/library-errors.ts | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index f5cbd3ed84..5c14f969c5 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -23,7 +23,7 @@ */ import { expect } from '@playwright/test'; -import { GeneralUtils, ApiClientFactory, getUserState, test, libraryErrors, timeouts } from '@alfresco/playwright-shared'; +import { GeneralUtils, ApiClientFactory, getUserState, test, libraryErrors } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; test.use({ storageState: getUserState('hruser') }); @@ -170,7 +170,7 @@ test.describe('Create Libraries ', () => { await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(commonLibraryId); await expect(libraryDialog.createButton).toBeDisabled(); - await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsNotAvailable)).toBeVisible({ timeout: timeouts.big }); + await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsNotAvailable)).toBeVisible(); }); test('[C280028] Create library using the ID of a library from the Trashcan', async ({ myLibrariesPage }) => { @@ -184,7 +184,7 @@ test.describe('Create Libraries ', () => { await expect(libraryDialog.createButton).toBeEnabled(); await libraryDialog.createButton.click(); await expect(libraryDialog.createButton).toBeDisabled(); - await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsAlreadyUsed)).toBeVisible({ timeout: timeouts.big }); + await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsAlreadyUsed)).toBeVisible(); }); test('[C280029] Cancel button', async ({ myLibrariesPage }) => { @@ -231,7 +231,7 @@ test.describe('Create Libraries ', () => { await libraryDialog.getLabelText(libraryIdLebel).clear(); await libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); - await expect(libraryDialog.getMatError(libraryErrors.useNumbersAndLettersOnly)).toBeVisible({ timeout: timeouts.big }); + await expect(libraryDialog.getMatError(libraryErrors.useNumbersAndLettersOnly)).toBeVisible(); await expect(libraryDialog.createButton).toBeDisabled(); } }); diff --git a/projects/aca-playwright-shared/src/utils/library-errors.ts b/projects/aca-playwright-shared/src/utils/library-errors.ts index 57d4619a41..1ac8cb55d0 100644 --- a/projects/aca-playwright-shared/src/utils/library-errors.ts +++ b/projects/aca-playwright-shared/src/utils/library-errors.ts @@ -23,7 +23,7 @@ */ export const libraryErrors = { - libraryIdIsNotAvailable: `This Library ID isn't available. Try a different Library ID.`, - libraryIdIsAlreadyUsed: `This Library ID is already used. Check the trashcan.`, - useNumbersAndLettersOnly: `Use numbers and letters only` + libraryIdIsNotAvailable: "This Library ID isn't available. Try a different Library ID.", + libraryIdIsAlreadyUsed: "This Library ID is already used. Check the trashcan.", + useNumbersAndLettersOnly: "Use numbers and letters only" } From badb480042c0d9469b49ae52896fd6847a2d62e0 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 14 Jul 2023 08:26:36 +0200 Subject: [PATCH 49/54] adding waitFor method --- e2e/playwright/actions/src/tests/create-library.spec.ts | 7 ++++--- .../components/dialogs/adf-library-dialog.component.ts | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index 5c14f969c5..ead1bade29 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -40,6 +40,7 @@ test.describe('Create Libraries ', () => { const moderatedVisibility = 'Moderated'; const privateVisibility = 'Private'; const deleteAction = 'Delete'; + const errorMessageNotPresent = 'Error message is not displayed'; const commonLibraryName = `playwright-library-${GeneralUtils.random()}`; const commonLibraryId = `libraryId-${GeneralUtils.random()}`; @@ -170,7 +171,7 @@ test.describe('Create Libraries ', () => { await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(commonLibraryId); await expect(libraryDialog.createButton).toBeDisabled(); - await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsNotAvailable)).toBeVisible(); + expect(await libraryDialog.isErrorMessageDisplayed(libraryErrors.libraryIdIsNotAvailable), errorMessageNotPresent).toBe(true); }); test('[C280028] Create library using the ID of a library from the Trashcan', async ({ myLibrariesPage }) => { @@ -184,7 +185,7 @@ test.describe('Create Libraries ', () => { await expect(libraryDialog.createButton).toBeEnabled(); await libraryDialog.createButton.click(); await expect(libraryDialog.createButton).toBeDisabled(); - await expect(libraryDialog.getMatError(libraryErrors.libraryIdIsAlreadyUsed)).toBeVisible(); + expect(await libraryDialog.isErrorMessageDisplayed(libraryErrors.libraryIdIsAlreadyUsed), errorMessageNotPresent).toBe(true); }); test('[C280029] Cancel button', async ({ myLibrariesPage }) => { @@ -231,7 +232,7 @@ test.describe('Create Libraries ', () => { await libraryDialog.getLabelText(libraryIdLebel).clear(); await libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); - await expect(libraryDialog.getMatError(libraryErrors.useNumbersAndLettersOnly)).toBeVisible(); + expect(await libraryDialog.isErrorMessageDisplayed(libraryErrors.useNumbersAndLettersOnly), errorMessageNotPresent).toBe(true); await expect(libraryDialog.createButton).toBeDisabled(); } }); diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts index 2362a83b56..1ca6d9e363 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts @@ -22,6 +22,7 @@ * from Hyland Software. If not, see . */ +import { timeouts } from '../../../utils'; import { BaseComponent } from '../base.component'; import { Page } from '@playwright/test'; @@ -55,4 +56,9 @@ export class AdfLibraryDialogComponent extends BaseComponent { if (visibility) { await this.getLabelText(visibility).click(); } await this.createButton.click(); } + + async isErrorMessageDisplayed(errorText: string): Promise { + await this.getMatError(errorText).waitFor({ state: 'visible', timeout: timeouts.big }); + return await this.getMatError(errorText).isVisible(); + } } From 1abfc03251163e299ed3dce0be0bcafb1b16b69a Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 14 Jul 2023 12:16:29 +0200 Subject: [PATCH 50/54] raising timeout in isErrorMessageDisplayed method --- .../components/dialogs/adf-library-dialog.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts index 1ca6d9e363..36d514a51a 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts @@ -58,7 +58,7 @@ export class AdfLibraryDialogComponent extends BaseComponent { } async isErrorMessageDisplayed(errorText: string): Promise { - await this.getMatError(errorText).waitFor({ state: 'visible', timeout: timeouts.big }); + await this.getMatError(errorText).waitFor({ state: 'visible', timeout: timeouts.large }); return await this.getMatError(errorText).isVisible(); } } From 2ac78098600e7871c8b129afddbb5df1322b091a Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 14 Jul 2023 14:44:51 +0200 Subject: [PATCH 51/54] updating mat-error locator --- .../components/dialogs/adf-library-dialog.component.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts index 36d514a51a..25ae192926 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/adf-library-dialog.component.ts @@ -24,7 +24,7 @@ import { timeouts } from '../../../utils'; import { BaseComponent } from '../base.component'; -import { Page } from '@playwright/test'; +import { Locator, Page } from '@playwright/test'; export class AdfLibraryDialogComponent extends BaseComponent { private static rootElement = 'adf-library-dialog'; @@ -38,7 +38,7 @@ export class AdfLibraryDialogComponent extends BaseComponent { public getLabelText = (text: string) => this.getChild('label', { hasText: text }); public getDialogTitle = (text: string) => this.getChild('.mat-dialog-title', { hasText: text }); - public getMatError = (text: string) => this.getChild('.mat-error', { hasText: text }); + public getErrorByText = (text: string): Locator => this.page.locator('mat-error', {hasText: text}); /** * This method is used when we want to fill in Create Library Dialog and choose Create button @@ -58,7 +58,7 @@ export class AdfLibraryDialogComponent extends BaseComponent { } async isErrorMessageDisplayed(errorText: string): Promise { - await this.getMatError(errorText).waitFor({ state: 'visible', timeout: timeouts.large }); - return await this.getMatError(errorText).isVisible(); + await this.getErrorByText(errorText).waitFor({ state: 'visible', timeout: timeouts.large }); + return await this.getErrorByText(errorText).isVisible(); } } From 72af4253816bfe3f52ee84b5eae17c4a704acd51 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Fri, 14 Jul 2023 17:43:26 +0200 Subject: [PATCH 52/54] adding press tab after fill --- e2e/playwright/actions/src/tests/create-library.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index ead1bade29..6017da23f1 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -168,6 +168,7 @@ test.describe('Create Libraries ', () => { await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); await libraryDialog.getLabelText(libraryIdLebel).clear(); await libraryDialog.getLabelText(libraryIdLebel).fill(commonLibraryId); + await libraryDialog.page.keyboard.press('Tab'); await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(commonLibraryId); await expect(libraryDialog.createButton).toBeDisabled(); @@ -181,6 +182,7 @@ test.describe('Create Libraries ', () => { await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); await libraryDialog.getLabelText(libraryIdLebel).clear(); await libraryDialog.getLabelText(libraryIdLebel).fill(commonTrashLibraryId); + await libraryDialog.page.keyboard.press('Tab'); await expect(libraryDialog.createButton).toBeEnabled(); await libraryDialog.createButton.click(); @@ -231,6 +233,7 @@ test.describe('Create Libraries ', () => { for (const specialLibraryId of idsWithSpecialChars) { await libraryDialog.getLabelText(libraryIdLebel).clear(); await libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); + await libraryDialog.page.keyboard.press('Tab'); await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); expect(await libraryDialog.isErrorMessageDisplayed(libraryErrors.useNumbersAndLettersOnly), errorMessageNotPresent).toBe(true); await expect(libraryDialog.createButton).toBeDisabled(); From 22e1392903772ee89a9d5ce85acf4b9c1f386d38 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Mon, 17 Jul 2023 14:17:23 +0200 Subject: [PATCH 53/54] update general-utils to utils for random --- .../actions/src/tests/create-library.spec.ts | 16 ++++++++-------- .../aca-playwright-shared/src/utils/index.ts | 2 +- .../src/utils/{general-utils.ts => utils.ts} | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) rename projects/aca-playwright-shared/src/utils/{general-utils.ts => utils.ts} (88%) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index 6017da23f1..67c9378c73 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -23,7 +23,7 @@ */ import { expect } from '@playwright/test'; -import { GeneralUtils, ApiClientFactory, getUserState, test, libraryErrors } from '@alfresco/playwright-shared'; +import { Utils, ApiClientFactory, getUserState, test, libraryErrors } from '@alfresco/playwright-shared'; import { SiteBodyCreate } from '@alfresco/js-api'; test.use({ storageState: getUserState('hruser') }); @@ -42,10 +42,10 @@ test.describe('Create Libraries ', () => { const deleteAction = 'Delete'; const errorMessageNotPresent = 'Error message is not displayed'; - const commonLibraryName = `playwright-library-${GeneralUtils.random()}`; - const commonLibraryId = `libraryId-${GeneralUtils.random()}`; - const commonTrashLibraryName = `playwright-library-${GeneralUtils.random()}`; - const commonTrashLibraryId = `libraryId-${GeneralUtils.random()}`; + const commonLibraryName = `playwright-library-${Utils.random()}`; + const commonLibraryId = `libraryId-${Utils.random()}`; + const commonTrashLibraryName = `playwright-library-${Utils.random()}`; + const commonTrashLibraryId = `libraryId-${Utils.random()}`; test.beforeAll(async () => { await apiClientFactory.setUpAcaBackend('hruser'); @@ -59,9 +59,9 @@ test.describe('Create Libraries ', () => { }); test.beforeEach(async ({ myLibrariesPage }) => { - randomLibraryName = `playwright-library-${GeneralUtils.random()}`; - randomLibraryId = `libraryId-${GeneralUtils.random()}`; - randomLibraryDescription = `libraryDescription-${GeneralUtils.random()}`; + randomLibraryName = `playwright-library-${Utils.random()}`; + randomLibraryId = `libraryId-${Utils.random()}`; + randomLibraryDescription = `libraryDescription-${Utils.random()}`; await myLibrariesPage.navigate(); }); diff --git a/projects/aca-playwright-shared/src/utils/index.ts b/projects/aca-playwright-shared/src/utils/index.ts index d4679d4bde..d6ac3086e5 100644 --- a/projects/aca-playwright-shared/src/utils/index.ts +++ b/projects/aca-playwright-shared/src/utils/index.ts @@ -27,5 +27,5 @@ export * from './timeouts'; export * from './exclude-tests'; export * from './state-helper'; export * from './folder-errors'; -export * from './general-utils'; +export * from './utils'; export * from './library-errors'; diff --git a/projects/aca-playwright-shared/src/utils/general-utils.ts b/projects/aca-playwright-shared/src/utils/utils.ts similarity index 88% rename from projects/aca-playwright-shared/src/utils/general-utils.ts rename to projects/aca-playwright-shared/src/utils/utils.ts index 9e30d8eea0..575fb9f8d4 100644 --- a/projects/aca-playwright-shared/src/utils/general-utils.ts +++ b/projects/aca-playwright-shared/src/utils/utils.ts @@ -22,12 +22,12 @@ * from Hyland Software. If not, see . */ +const crypto = require('crypto'); -export class GeneralUtils { - +export class Utils { static random(): string { - return (Math.random() + 1).toString(36).substring(6); + return crypto.getRandomValues(new Uint32Array(1))[0].toString(36).substring(0, 5).toLowerCase(); } } From a9a9a98483d2b0cba804fbecd1a3f2d79a8345a6 Mon Sep 17 00:00:00 2001 From: "adam.zakrzewski" Date: Tue, 18 Jul 2023 07:47:25 +0200 Subject: [PATCH 54/54] updating label typo --- .../actions/src/tests/create-library.spec.ts | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index 67c9378c73..a54047e4e5 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -33,9 +33,9 @@ test.describe('Create Libraries ', () => { let randomLibraryId: string; let randomLibraryDescription: string; const libraryDialogTitle = 'Create Library'; - const libraryNameLebel = 'Name *'; - const libraryIdLebel = 'Library ID *'; - const libraryDescriptionLebel = 'Description'; + const libraryNameLabel = 'Name *'; + const libraryIdLabel = 'Library ID *'; + const libraryDescriptionLabel = 'Description'; const publicVisibility = 'Public'; const moderatedVisibility = 'Moderated'; const privateVisibility = 'Private'; @@ -75,9 +75,9 @@ test.describe('Create Libraries ', () => { await myLibrariesPage.selectCreateLibrary(); await expect(libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); - await expect(libraryDialog.getLabelText(libraryNameLebel)).toBeVisible(); - await expect(libraryDialog.getLabelText(libraryIdLebel)).toBeVisible(); - await expect(libraryDialog.getLabelText(libraryDescriptionLebel)).toBeVisible(); + await expect(libraryDialog.getLabelText(libraryNameLabel)).toBeVisible(); + await expect(libraryDialog.getLabelText(libraryIdLabel)).toBeVisible(); + await expect(libraryDialog.getLabelText(libraryDescriptionLabel)).toBeVisible(); await expect(libraryDialog.getLabelText(publicVisibility)).toBeVisible(); await expect(libraryDialog.getLabelText(publicVisibility)).toBeChecked(); await expect(libraryDialog.getLabelText(privateVisibility)).toBeVisible(); @@ -92,9 +92,9 @@ test.describe('Create Libraries ', () => { const libraryBreadcrumb = myLibrariesPage.breadcrumb; await myLibrariesPage.selectCreateLibrary(); - await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); - await expect(libraryDialog.getLabelText(libraryNameLebel)).toHaveValue(randomLibraryName); - await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(randomLibraryName); + await libraryDialog.getLabelText(libraryNameLabel).fill(randomLibraryName); + await expect(libraryDialog.getLabelText(libraryNameLabel)).toHaveValue(randomLibraryName); + await expect(libraryDialog.getLabelText(libraryIdLabel)).toHaveValue(randomLibraryName); await libraryDialog.createButton.click(); await expect(libraryBreadcrumb.getBreadcrumbItem(randomLibraryName)).toBeVisible(); @@ -156,7 +156,7 @@ test.describe('Create Libraries ', () => { await expect(libraryDetails.getNameField('Name').getByText(randomLibraryName)).toBeVisible(); await expect(libraryDetails.getIdField('Library ID').getByText(randomLibraryId)).toBeVisible(); await expect(libraryDetails.getVisibilityField('Visibility').getByText(publicVisibility)).toBeVisible(); - await expect(libraryDetails.getDescriptionField(libraryDescriptionLebel).getByText(randomLibraryDescription)).toBeVisible(); + await expect(libraryDetails.getDescriptionField(libraryDescriptionLabel).getByText(randomLibraryDescription)).toBeVisible(); await apiClientFactory.sites.deleteSite(randomLibraryId, { permanent: true }); }); @@ -165,11 +165,11 @@ test.describe('Create Libraries ', () => { const libraryDialog = myLibrariesPage.libraryDialog; await myLibrariesPage.selectCreateLibrary(); - await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); - await libraryDialog.getLabelText(libraryIdLebel).clear(); - await libraryDialog.getLabelText(libraryIdLebel).fill(commonLibraryId); + await libraryDialog.getLabelText(libraryNameLabel).fill(randomLibraryName); + await libraryDialog.getLabelText(libraryIdLabel).clear(); + await libraryDialog.getLabelText(libraryIdLabel).fill(commonLibraryId); await libraryDialog.page.keyboard.press('Tab'); - await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(commonLibraryId); + await expect(libraryDialog.getLabelText(libraryIdLabel)).toHaveValue(commonLibraryId); await expect(libraryDialog.createButton).toBeDisabled(); expect(await libraryDialog.isErrorMessageDisplayed(libraryErrors.libraryIdIsNotAvailable), errorMessageNotPresent).toBe(true); @@ -179,9 +179,9 @@ test.describe('Create Libraries ', () => { const libraryDialog = myLibrariesPage.libraryDialog; await myLibrariesPage.selectCreateLibrary(); - await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); - await libraryDialog.getLabelText(libraryIdLebel).clear(); - await libraryDialog.getLabelText(libraryIdLebel).fill(commonTrashLibraryId); + await libraryDialog.getLabelText(libraryNameLabel).fill(randomLibraryName); + await libraryDialog.getLabelText(libraryIdLabel).clear(); + await libraryDialog.getLabelText(libraryIdLabel).fill(commonTrashLibraryId); await libraryDialog.page.keyboard.press('Tab'); await expect(libraryDialog.createButton).toBeEnabled(); @@ -197,7 +197,7 @@ test.describe('Create Libraries ', () => { await myLibrariesPage.selectCreateLibrary(); await expect(libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); - await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await libraryDialog.getLabelText(libraryNameLabel).fill(randomLibraryName); await libraryDialog.cancelButton.click(); await expect(libraryDialog.getDialogTitle(libraryDialogTitle)).toBeHidden(); @@ -228,13 +228,13 @@ test.describe('Create Libraries ', () => { ]; await myLibrariesPage.selectCreateLibrary(); - await libraryDialog.getLabelText(libraryNameLebel).fill(randomLibraryName); + await libraryDialog.getLabelText(libraryNameLabel).fill(randomLibraryName); for (const specialLibraryId of idsWithSpecialChars) { - await libraryDialog.getLabelText(libraryIdLebel).clear(); - await libraryDialog.getLabelText(libraryIdLebel).fill(specialLibraryId); + await libraryDialog.getLabelText(libraryIdLabel).clear(); + await libraryDialog.getLabelText(libraryIdLabel).fill(specialLibraryId); await libraryDialog.page.keyboard.press('Tab'); - await expect(libraryDialog.getLabelText(libraryIdLebel)).toHaveValue(specialLibraryId); + await expect(libraryDialog.getLabelText(libraryIdLabel)).toHaveValue(specialLibraryId); expect(await libraryDialog.isErrorMessageDisplayed(libraryErrors.useNumbersAndLettersOnly), errorMessageNotPresent).toBe(true); await expect(libraryDialog.createButton).toBeDisabled(); }