-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [ACS-511]-adding-library-tests * updating tests and adding before and after all * spinner timeouts update * updating import statement * update error locator * adding random method in general utils * [ACA-4715] break dependency on envsubst (#3325) * remove BPM host * break dependency on envsubst * remove prebuild script * cleanup package.json * [ACS-511]-adding-library-tests * adding lost MyLibrariesPage import * rebase page initialization merge * [ACS-511]-adding-library-tests * comma deleted * fix readability and indentation * adding id to info drawer * adding index and updating import * updating after wrong rebase * after rebase * updating tests and adding before and after all * updating import statement * update error locator * adding random method in general utils * [ACS-511]-adding-library-tests * comma deleted * fix readability and indentation * adding id to info drawer * adding index and updating import * next after rebase * update delete in folder tests * providing string as parameter * after rebase * updating tests and adding before and after all * adding random method in general utils * [ACS-511]-adding-library-tests * comma deleted * [ACS-511]-adding-library-tests * adding index and updating import * providing string as parameter * delete protractor create-library tests * update for calls in expect method * bump to 4.2.0 (#3334) * adding random method in general utils * adding index and updating import * providing string as parameter * after rebase * providing string as parameter * update for tests C280026 and C280027 * raising time for visibility check * quotes change in error strings * adding waitFor method * raising timeout in isErrorMessageDisplayed method * updating mat-error locator * adding press tab after fill * update general-utils to utils for random * updating label typo --------- Co-authored-by: Denys Vuika <[email protected]>
- Loading branch information
1 parent
a89c30f
commit 4ded3b2
Showing
20 changed files
with
573 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
263 changes: 263 additions & 0 deletions
263
e2e/playwright/actions/src/tests/create-library.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,263 @@ | ||
/*! | ||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. | ||
* | ||
* Alfresco Example Content Application | ||
* | ||
* This file is part of the Alfresco Example Content Application. | ||
* If the software was purchased under a paid Alfresco license, the terms of | ||
* the paid license agreement will prevail. Otherwise, the software is | ||
* provided under the following open source license terms: | ||
* | ||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The Alfresco Example Content Application is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { expect } from '@playwright/test'; | ||
import { Utils, ApiClientFactory, getUserState, test, libraryErrors } from '@alfresco/playwright-shared'; | ||
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; | ||
const libraryDialogTitle = 'Create Library'; | ||
const libraryNameLabel = 'Name *'; | ||
const libraryIdLabel = 'Library ID *'; | ||
const libraryDescriptionLabel = 'Description'; | ||
const publicVisibility = 'Public'; | ||
const moderatedVisibility = 'Moderated'; | ||
const privateVisibility = 'Private'; | ||
const deleteAction = 'Delete'; | ||
const errorMessageNotPresent = 'Error message is not displayed'; | ||
|
||
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'); | ||
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-${Utils.random()}`; | ||
randomLibraryId = `libraryId-${Utils.random()}`; | ||
randomLibraryDescription = `libraryDescription-${Utils.random()}`; | ||
await myLibrariesPage.navigate(); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await apiClientFactory.sites.deleteSite(commonLibraryId, { permanent: true }); | ||
}); | ||
|
||
test('[C280024] Create Library dialog UI', async ({ myLibrariesPage }) => { | ||
const libraryDialog = myLibrariesPage.libraryDialog; | ||
|
||
await myLibrariesPage.selectCreateLibrary(); | ||
|
||
await expect(libraryDialog.getDialogTitle(libraryDialogTitle)).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(); | ||
await expect(libraryDialog.getLabelText(moderatedVisibility)).toBeVisible(); | ||
await expect(libraryDialog.cancelButton).toBeEnabled(); | ||
await expect(libraryDialog.createButton).toBeDisabled(); | ||
}); | ||
|
||
test('[C280025] Create a public library', async ({ myLibrariesPage }) => { | ||
const libraryDialog = myLibrariesPage.libraryDialog; | ||
const libraryTable = myLibrariesPage.dataTable; | ||
const libraryBreadcrumb = myLibrariesPage.breadcrumb; | ||
|
||
await myLibrariesPage.selectCreateLibrary(); | ||
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(); | ||
|
||
await myLibrariesPage.navigate(); | ||
await libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); | ||
await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, publicVisibility)).toBeVisible(); | ||
|
||
await libraryTable.performActionInExpandableMenu(randomLibraryName, deleteAction); | ||
}); | ||
|
||
test('[C289880] Create a moderated library', async ({ myLibrariesPage }) => { | ||
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 libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); | ||
await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, moderatedVisibility)).toBeVisible(); | ||
|
||
await libraryTable.performActionInExpandableMenu(randomLibraryName, deleteAction); | ||
}); | ||
|
||
test('[C289881] Create a private library', async ({ myLibrariesPage }) => { | ||
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 libraryTable.goThroughPagesLookingForRowWithName(randomLibraryName); | ||
await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, privateVisibility)).toBeVisible(); | ||
|
||
await libraryTable.performActionInExpandableMenu(randomLibraryName, deleteAction); | ||
}); | ||
|
||
test('[C289882] Create a library with a given ID and description', async ({ myLibrariesPage }) => { | ||
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 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.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(libraryDescriptionLabel).getByText(randomLibraryDescription)).toBeVisible(); | ||
|
||
await apiClientFactory.sites.deleteSite(randomLibraryId, { permanent: true }); | ||
}); | ||
|
||
test('[C280027] Duplicate library ID', async ({ myLibrariesPage }) => { | ||
const libraryDialog = myLibrariesPage.libraryDialog; | ||
|
||
await myLibrariesPage.selectCreateLibrary(); | ||
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(libraryIdLabel)).toHaveValue(commonLibraryId); | ||
|
||
await expect(libraryDialog.createButton).toBeDisabled(); | ||
expect(await libraryDialog.isErrorMessageDisplayed(libraryErrors.libraryIdIsNotAvailable), errorMessageNotPresent).toBe(true); | ||
}); | ||
|
||
test('[C280028] Create library using the ID of a library from the Trashcan', async ({ myLibrariesPage }) => { | ||
const libraryDialog = myLibrariesPage.libraryDialog; | ||
|
||
await myLibrariesPage.selectCreateLibrary(); | ||
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(); | ||
await libraryDialog.createButton.click(); | ||
await expect(libraryDialog.createButton).toBeDisabled(); | ||
expect(await libraryDialog.isErrorMessageDisplayed(libraryErrors.libraryIdIsAlreadyUsed), errorMessageNotPresent).toBe(true); | ||
}); | ||
|
||
test('[C280029] Cancel button', async ({ myLibrariesPage }) => { | ||
const libraryDialog = myLibrariesPage.libraryDialog; | ||
const libraryTable = myLibrariesPage.dataTable; | ||
const libraryBreadcrumb = myLibrariesPage.breadcrumb; | ||
|
||
await myLibrariesPage.selectCreateLibrary(); | ||
await expect(libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible(); | ||
await libraryDialog.getLabelText(libraryNameLabel).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', | ||
'a#a', | ||
'a%a', | ||
'a^a', | ||
'a&a', | ||
'a*a', | ||
'a(a', | ||
'a)a', | ||
'a"a', | ||
'a<a', | ||
'a>a', | ||
`a\\a`, | ||
'a/a', | ||
'a?a', | ||
'a:a', | ||
'a|a' | ||
]; | ||
|
||
await myLibrariesPage.selectCreateLibrary(); | ||
await libraryDialog.getLabelText(libraryNameLabel).fill(randomLibraryName); | ||
|
||
for (const specialLibraryId of idsWithSpecialChars) { | ||
await libraryDialog.getLabelText(libraryIdLabel).clear(); | ||
await libraryDialog.getLabelText(libraryIdLabel).fill(specialLibraryId); | ||
await libraryDialog.page.keyboard.press('Tab'); | ||
await expect(libraryDialog.getLabelText(libraryIdLabel)).toHaveValue(specialLibraryId); | ||
expect(await libraryDialog.isErrorMessageDisplayed(libraryErrors.useNumbersAndLettersOnly), errorMessageNotPresent).toBe(true); | ||
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.selectCreateLibrary(); | ||
await libraryDialog.createLibraryWithNameAndId(commonLibraryName, randomLibraryId); | ||
|
||
await expect(libraryBreadcrumb.getBreadcrumbItem(commonLibraryName)).toBeVisible(); | ||
|
||
await myLibrariesPage.navigate(); | ||
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 }); | ||
}); | ||
}); |
Oops, something went wrong.