diff --git a/e2e/playwright/actions/src/tests/create-folder-from-template.spec.ts b/e2e/playwright/actions/src/tests/create-folder-from-template.spec.ts new file mode 100644 index 0000000000..67c792f948 --- /dev/null +++ b/e2e/playwright/actions/src/tests/create-folder-from-template.spec.ts @@ -0,0 +1,416 @@ +/*! + * 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 { + AcaHeader, + ContentNodeSelectorDialog, + CreateFromTemplateDialogComponent, + DataTableComponent, + NodeContentTree, + NodesApi, + Utils, + errorStrings, + getUserState, + test +} from '@alfresco/playwright-shared'; + +test.use({ storageState: getUserState('hruser') }); +test.describe('Create folder from template', () => { + let selectFolderTemplateDialog: ContentNodeSelectorDialog; + let createFolderFromTemplateDialog: CreateFromTemplateDialogComponent; + let dataTable: DataTableComponent; + let toolbar: AcaHeader; + let randomFolderName: string; + let randomFolderTitle: string; + let randomFolderDescription: string; + let folderLink: string; + let folderId: string; + const selectDialogTitle = 'Select a folder template'; + const dialogBreadcrumb = 'Space Templates'; + const nameLabel = 'Name *'; + const titleLabel = 'Title'; + const descriptionLabel = 'Description'; + const emptyString = ''; + const tabKeyString = 'Tab'; + const dotString = '.'; + const spaceString = ' '; + const commandKey = 'Meta'; + const random = Utils.random(); + + const fileInRootFolder = `file-in-root-${random}.txt`; + const folderInRootFolder = `folder-in-root-${random}`; + + const templateFolder1 = `template-folder1-${random}`; + const fileInFolder1 = `file-1-${random}.txt`; + const templateSubFolder = `template-sub-folder-${random}`; + + const templateFolder2 = `template-folder2-${random}`; + const fileInFolder2 = `file-2-${random}.txt`; + + const restrictedTemplateFolder = `restricted-folder-${random}`; + const fileInRestrictedFolder = `restricted-file-${random}.txt`; + + const createDialogTitle = `Create new folder from '${templateFolder1}'`; + const commonFolderName = `playwright-folder-${Utils.random()}`; + + const templates: NodeContentTree = { + folders: [ + { + name: folderInRootFolder + }, + { + name: templateFolder1, + folders: [ + { + name: templateSubFolder + } + ], + files: [fileInFolder1] + }, + { + name: templateFolder2, + files: [fileInFolder2] + }, + { + name: restrictedTemplateFolder, + files: [fileInRestrictedFolder] + } + ], + files: [fileInRootFolder] + }; + + test.beforeAll(async ({ nodesApiAction }) => { + await nodesApiAction.createContent(templates, `Data Dictionary/Space Templates`); + await nodesApiAction.removeUserAccessOnSpaceTemplate(restrictedTemplateFolder); + folderLink = (await nodesApiAction.createLinkToFolderName(folderInRootFolder, await nodesApiAction.getSpaceTemplatesFolderId())).entry.name; + }); + + test.beforeEach(async ({ personalFiles }) => { + await personalFiles.navigate(); + }); + + test.afterAll(async ({ nodesApiAction }) => { + await nodesApiAction.cleanupSpaceTemplatesItems([ + folderInRootFolder, + templateFolder1, + templateFolder2, + restrictedTemplateFolder, + fileInRootFolder + ]); + }); + + test.describe('Personal Files page', () => { + test.beforeEach(async ({ personalFiles }) => { + selectFolderTemplateDialog = personalFiles.contentNodeSelector; + dataTable = personalFiles.dataTable; + toolbar = personalFiles.acaHeader; + await toolbar.clickCreateFolderFromTemplate(); + }); + + test.describe('Select Template dialog', () => { + test('[C325147] Select template - dialog UI - with existing templates', async () => { + await expect.soft(selectFolderTemplateDialog.getDialogTitle(selectDialogTitle)).toBeVisible(); + await expect.soft(selectFolderTemplateDialog.getBreadcrumb(dialogBreadcrumb)).toBeVisible(); + await expect.soft(dataTable.getRowByName(templateFolder1)).not.toBeEmpty(); + await expect.soft(dataTable.getRowByName(templateFolder1)).toBeVisible(); + await expect.soft(dataTable.getRowByName(templateFolder2)).toBeVisible(); + await expect.soft(dataTable.getRowByName(folderInRootFolder)).toBeVisible(); + await expect.soft(selectFolderTemplateDialog.cancelButton).toBeEnabled(); + await expect(selectFolderTemplateDialog.actionButton).toBeDisabled(); + }); + + test(`[C325148] Templates don't appear if user doesn't have permissions to see them`, async () => { + await expect(selectFolderTemplateDialog.getDialogTitle(selectDialogTitle)).toBeVisible(); + await expect(dataTable.getRowByName(restrictedTemplateFolder)).not.toBeVisible(); + }); + + test(`[C325149] Navigate through the templates list with folder hierarchy`, async () => { + await expect(selectFolderTemplateDialog.getBreadcrumb(dialogBreadcrumb)).toBeVisible(); + await expect(dataTable.getRowByName(templateFolder1)).toBeVisible(); + + await dataTable.getRowByName(templateFolder1).dblclick(); + await expect(selectFolderTemplateDialog.getBreadcrumb(templateFolder1)).toBeVisible(); + await expect(dataTable.getRowByName(templateSubFolder)).toBeVisible(); + await expect(dataTable.getRowByName(fileInFolder1)).toBeVisible(); + + await dataTable.getRowByName(templateSubFolder).dblclick(); + await expect(selectFolderTemplateDialog.getBreadcrumb(templateSubFolder)).toBeVisible(); + await expect(dataTable.getNoResultsFoundMessage).toBeVisible(); + + await selectFolderTemplateDialog.getFolderIcon.click(); + await expect(selectFolderTemplateDialog.getOptionLocator(templateFolder1)).toBeVisible(); + await expect(selectFolderTemplateDialog.getOptionLocator(dialogBreadcrumb)).toBeVisible(); + }); + + test(`[C325150] Templates list doesn't allow multiple selection`, async () => { + await expect(dataTable.getSelectedRow).toHaveCount(0); + + await dataTable.getRowByName(templateFolder1).click({ modifiers: [commandKey] }); + await expect(dataTable.getSelectedRow).toHaveCount(1); + await expect(dataTable.getSelectedRow).toContainText(templateFolder1); + + await dataTable.getRowByName(templateFolder2).click({ modifiers: [commandKey] }); + await expect(dataTable.getSelectedRow).not.toHaveCount(2); + await expect(dataTable.getSelectedRow).toHaveCount(1); + await expect(dataTable.getSelectedRow).toContainText(templateFolder2); + }); + + test('[C325153] Links to folders are not displayed', async () => { + await expect(dataTable.getRowByName(templateFolder1)).toBeVisible(); + await expect(dataTable.getRowByName(folderLink)).not.toBeVisible(); + }); + + test('[C325151] Cancel the Select template dialog', async () => { + await expect(selectFolderTemplateDialog.getDialogTitle(selectDialogTitle)).toBeVisible(); + + await selectFolderTemplateDialog.cancelButton.click(); + await expect(selectFolderTemplateDialog.getDialogTitle(selectDialogTitle)).toBeHidden(); + }); + + test('[C325139] Next button is disabled when selecting a file', async () => { + await expect(dataTable.getRowByName(fileInRootFolder)).toBeVisible(); + await expect(selectFolderTemplateDialog.actionButton).toBeDisabled(); + + await dataTable.getRowByName(fileInRootFolder).click(); + await expect(selectFolderTemplateDialog.actionButton).toBeDisabled(); + }); + }); + + test.describe('Create from template dialog', () => { + test.beforeAll(async () => { + const nodesApi = await NodesApi.initialize('hruser'); + folderId = (await nodesApi.createFolder(commonFolderName)).entry.id; + }); + + test.beforeEach(async ({ personalFiles }) => { + createFolderFromTemplateDialog = personalFiles.createFromTemplateDialogComponent; + await dataTable.getRowByName(templateFolder1).click(); + await selectFolderTemplateDialog.actionButton.click(); + }); + + test.afterAll(async ({ nodesApiAction }) => { + await nodesApiAction.deleteNodeById(folderId); + }); + + test('[C325142] Create folder from template - dialog UI', async () => { + await expect.soft(createFolderFromTemplateDialog.getDialogTitle(createDialogTitle)).toBeVisible(); + await expect.soft(createFolderFromTemplateDialog.getDialogLabel(nameLabel)).toBeVisible(); + await expect.soft(createFolderFromTemplateDialog.getDialogLabel(nameLabel)).toHaveValue(templateFolder1); + await expect.soft(createFolderFromTemplateDialog.getDialogLabel(titleLabel)).toBeVisible(); + await expect.soft(createFolderFromTemplateDialog.getDialogLabel(titleLabel)).toHaveValue(emptyString); + await expect.soft(createFolderFromTemplateDialog.getDialogLabel(descriptionLabel)).toBeVisible(); + await expect.soft(createFolderFromTemplateDialog.getDialogLabel(descriptionLabel)).toHaveValue(emptyString); + await expect.soft(createFolderFromTemplateDialog.cancelButton).toBeEnabled(); + await expect(createFolderFromTemplateDialog.createButton).toBeEnabled(); + }); + + test('[C325143] Folder name is required', async () => { + await expect(createFolderFromTemplateDialog.getDialogLabel(nameLabel)).toHaveValue(templateFolder1); + + await createFolderFromTemplateDialog.getDialogLabel(nameLabel).clear(); + await createFolderFromTemplateDialog.page.keyboard.press(tabKeyString); + await expect(createFolderFromTemplateDialog.getDialogLabel(nameLabel)).toHaveValue(emptyString); + expect + .soft(await createFolderFromTemplateDialog.isErrorMessageDisplayed(errorStrings.nameIsRequiredError), errorStrings.errorMessageNotPresent) + .toBe(true); + await expect(createFolderFromTemplateDialog.createButton).toBeDisabled(); + }); + + test('[C325144] Special characters in folder name', async () => { + const nameWithSpecialChars = ['a*a', 'a"a', 'aa', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a']; + + for (const specialFolderName of nameWithSpecialChars) { + await createFolderFromTemplateDialog.getDialogLabel(nameLabel).fill(specialFolderName); + await createFolderFromTemplateDialog.page.keyboard.press(tabKeyString); + await expect(createFolderFromTemplateDialog.getDialogLabel(nameLabel)).toHaveValue(specialFolderName); + expect + .soft( + await createFolderFromTemplateDialog.isErrorMessageDisplayed(errorStrings.nameWithSpecialCharactersError), + errorStrings.errorMessageNotPresent + ) + .toBe(true); + await expect(createFolderFromTemplateDialog.createButton).toBeDisabled(); + } + }); + + test('[C325145] Folder name ending with a dot', async () => { + await createFolderFromTemplateDialog.getDialogLabel(nameLabel).type(dotString); + await createFolderFromTemplateDialog.page.keyboard.press(tabKeyString); + await expect(createFolderFromTemplateDialog.getDialogLabel(nameLabel)).toHaveValue(templateFolder1 + dotString); + expect + .soft(await createFolderFromTemplateDialog.isErrorMessageDisplayed(errorStrings.nameEndWithDotError), errorStrings.errorMessageNotPresent) + .toBe(true); + await expect(createFolderFromTemplateDialog.createButton).toBeDisabled(); + }); + + test('[C325146] Folder name containing only spaces', async () => { + await createFolderFromTemplateDialog.getDialogLabel(nameLabel).clear(); + await createFolderFromTemplateDialog.getDialogLabel(nameLabel).fill(spaceString); + await createFolderFromTemplateDialog.page.keyboard.press(tabKeyString); + await expect(createFolderFromTemplateDialog.getDialogLabel(nameLabel)).toHaveValue(spaceString); + expect + .soft( + await createFolderFromTemplateDialog.isErrorMessageDisplayed(errorStrings.nameContainOnlySpacesError), + errorStrings.errorMessageNotPresent + ) + .toBe(true); + await expect(createFolderFromTemplateDialog.createButton).toBeDisabled(); + }); + + test('[C325141] Title too long', async () => { + await createFolderFromTemplateDialog.getDialogLabel(titleLabel).fill(Utils.string257Long); + await createFolderFromTemplateDialog.page.keyboard.press(tabKeyString); + await expect(createFolderFromTemplateDialog.getDialogLabel(titleLabel)).toHaveValue(Utils.string257Long); + expect + .soft(await createFolderFromTemplateDialog.isErrorMessageDisplayed(errorStrings.titleLengthLimitError), errorStrings.errorMessageNotPresent) + .toBe(true); + await expect(createFolderFromTemplateDialog.createButton).toBeDisabled(); + }); + + test('[C325140] Description too long', async () => { + await createFolderFromTemplateDialog.getDialogLabel(descriptionLabel).fill(Utils.string513Long); + await createFolderFromTemplateDialog.page.keyboard.press(tabKeyString); + await expect(createFolderFromTemplateDialog.getDialogLabel(descriptionLabel)).toHaveValue(Utils.string513Long); + expect + .soft( + await createFolderFromTemplateDialog.isErrorMessageDisplayed(errorStrings.descriptionLengthLimitError), + errorStrings.errorMessageNotPresent + ) + .toBe(true); + await expect(createFolderFromTemplateDialog.createButton).toBeDisabled(); + }); + + test('[C325156] Create a folder with a duplicate name', async ({ personalFiles }) => { + const snackBar = personalFiles.snackBar; + + await createFolderFromTemplateDialog.createNewFolderFromTemplate(commonFolderName); + await expect(snackBar.getByMessageLocator(errorStrings.nameAlreadyUsedError)).toBeVisible(); + await expect(createFolderFromTemplateDialog.getDialogTitle(createDialogTitle)).toBeVisible(); + }); + + test('[C325155] Cancel folder creation', async () => { + await expect(createFolderFromTemplateDialog.getDialogTitle(createDialogTitle)).toBeVisible(); + await createFolderFromTemplateDialog.cancelButton.click(); + await expect(createFolderFromTemplateDialog.getDialogTitle(createDialogTitle)).not.toBeVisible(); + }); + }); + + test.describe('Folder created from template on Personal Files', () => { + test.beforeEach(async ({ personalFiles }) => { + randomFolderName = `playwright-folder-${Utils.random()}`; + randomFolderTitle = `folder-title-${Utils.random()}`; + randomFolderDescription = `folder-description-${Utils.random()}`; + createFolderFromTemplateDialog = personalFiles.createFromTemplateDialogComponent; + await dataTable.getRowByName(templateFolder1).click(); + await selectFolderTemplateDialog.actionButton.click(); + }); + + test.afterEach(async () => { + const nodesApi = await NodesApi.initialize('hruser'); + folderId = await nodesApi.getNodeIdFromParent(randomFolderName, '-my-'); + await nodesApi.deleteNodeById(folderId); + }); + + test('[C325157] Create a folder from a template - with a new Name', async () => { + await createFolderFromTemplateDialog.createNewFolderFromTemplate(randomFolderName); + await dataTable.goThroughPagesLookingForRowWithName(randomFolderName); + await expect(dataTable.getRowByName(randomFolderName)).toBeVisible(); + + await dataTable.getRowByName(randomFolderName).dblclick(); + await expect(dataTable.getRowByName(templateSubFolder)).toBeVisible(); + await expect(dataTable.getRowByName(fileInFolder1)).toBeVisible(); + }); + + test('[C325154] Create a folder from a template - with a Name, Title and Description', async () => { + await createFolderFromTemplateDialog.createNewFolderFromTemplate(randomFolderName, randomFolderTitle, randomFolderDescription); + await dataTable.goThroughPagesLookingForRowWithName(randomFolderName); + await expect(dataTable.getCellLinkByName(randomFolderName)).toHaveAttribute(titleLabel, randomFolderTitle + `\n` + randomFolderDescription); + }); + + test('[C325158] Trim spaces from folder Name', async () => { + await createFolderFromTemplateDialog.createNewFolderFromTemplate(' ' + randomFolderName + ' '); + await dataTable.goThroughPagesLookingForRowWithName(randomFolderName); + await expect(dataTable.getRowByName(randomFolderName)).toBeVisible(); + }); + }); + }); + + test.describe('Folder created from template on Personal Files Libraries', () => { + const randomLibraryName = `playwright-library-${Utils.random()}`; + + test.beforeAll(async ({ sitesApiAction, nodesApiAction }) => { + await sitesApiAction.createSite(randomLibraryName); + const libraryGuId = await sitesApiAction.getDocLibId(randomLibraryName); + await nodesApiAction.createFolder(commonFolderName, libraryGuId); + }); + + test.beforeEach(async ({ myLibrariesPage }) => { + randomFolderName = `playwright-folder-${Utils.random()}`; + randomFolderTitle = `folder-title-${Utils.random()}`; + randomFolderDescription = `folder-description-${Utils.random()}`; + await myLibrariesPage.navigate(); + selectFolderTemplateDialog = myLibrariesPage.contentNodeSelector; + createFolderFromTemplateDialog = myLibrariesPage.createFromTemplateDialogComponent; + dataTable = myLibrariesPage.dataTable; + toolbar = myLibrariesPage.acaHeader; + await dataTable.goThroughPagesLookingForRowWithName(randomLibraryName); + await dataTable.getRowByName(randomLibraryName).dblclick(); + await dataTable.spinnerWaitForReload(); + await toolbar.clickCreateFolderFromTemplate(); + await dataTable.getRowByName(templateFolder1).click(); + await selectFolderTemplateDialog.actionButton.click(); + }); + + test.afterAll(async ({ sitesApiAction }) => { + await sitesApiAction.deleteSites([randomLibraryName]); + }); + + test('[C325161] Create a folder from a template from library - with Name, Title and Description', async () => { + await createFolderFromTemplateDialog.createNewFolderFromTemplate(randomFolderName, randomFolderTitle, randomFolderDescription); + await expect + .soft(dataTable.getCellLinkByName(randomFolderName)) + .toHaveAttribute(titleLabel, randomFolderTitle + `\n` + randomFolderDescription); + + await dataTable.getRowByName(randomFolderName).dblclick(); + await expect(dataTable.getRowByName(templateSubFolder)).toBeVisible(); + await expect(dataTable.getRowByName(fileInFolder1)).toBeVisible(); + }); + + test('[C325162] Cancel folder creation in a library', async () => { + await expect(createFolderFromTemplateDialog.getDialogTitle(createDialogTitle)).toBeVisible(); + await createFolderFromTemplateDialog.cancelButton.click(); + await expect(createFolderFromTemplateDialog.getDialogTitle(createDialogTitle)).not.toBeVisible(); + await expect(dataTable.getRowByName(randomFolderName)).not.toBeVisible(); + }); + + test('[C325163] Create a folder with a duplicate name in a library', async ({ myLibrariesPage }) => { + const snackBar = myLibrariesPage.snackBar; + + await createFolderFromTemplateDialog.createNewFolderFromTemplate(commonFolderName); + await expect(snackBar.getByMessageLocator(errorStrings.nameAlreadyUsedError)).toBeVisible(); + await expect(createFolderFromTemplateDialog.getDialogTitle(createDialogTitle)).toBeVisible(); + }); + }); +}); diff --git a/e2e/protractor/protractor.excludes.json b/e2e/protractor/protractor.excludes.json index effe33632b..62a5082678 100644 --- a/e2e/protractor/protractor.excludes.json +++ b/e2e/protractor/protractor.excludes.json @@ -17,5 +17,27 @@ "C279220": "will be fixed after protractor to playwright migration, see https://alfresco.atlassian.net/browse/ACS-5007", "C279221": "will be fixed after protractor to playwright migration, see https://alfresco.atlassian.net/browse/ACS-5007", "C325006": "will be fixed after protractor to playwright migration, see https://alfresco.atlassiana.net/browse/ACS-5007", - "C213097": "https://alfresco.atlassian.net/browse/ACS-5479" + "C213097": "https://alfresco.atlassian.net/browse/ACS-5479", + "C325147" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325148" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325149" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325150" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325153" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325151" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325139" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325142" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325143" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325144" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325145" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325146" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325141" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325140" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325157" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325154" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325156" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325155" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325158" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325161" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325162" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678", + "C325163" : "test migrated to playwright https://alfresco.atlassian.net/browse/ACS-5678" } diff --git a/projects/aca-content/src/lib/dialogs/node-template/create-from-template.dialog.html b/projects/aca-content/src/lib/dialogs/node-template/create-from-template.dialog.html index 993f504035..f05cda4add 100644 --- a/projects/aca-content/src/lib/dialogs/node-template/create-from-template.dialog.html +++ b/projects/aca-content/src/lib/dialogs/node-template/create-from-template.dialog.html @@ -42,7 +42,7 @@

- diff --git a/projects/aca-playwright-shared/src/api/nodes-api.ts b/projects/aca-playwright-shared/src/api/nodes-api.ts index 090e27d724..6fb68f96f6 100755 --- a/projects/aca-playwright-shared/src/api/nodes-api.ts +++ b/projects/aca-playwright-shared/src/api/nodes-api.ts @@ -154,6 +154,15 @@ export class NodesApi { } } + async getNodeById(id: string): Promise { + try { + return await this.apiService.nodes.getNode(id); + } catch (error) { + logger.error(`${this.constructor.name} ${this.getNodeById.name}`, error); + return null; + } + } + async getNodeIdFromParent(name: string, parentId: string): Promise { try { const children = (await this.getNodeChildren(parentId)).list.entries; @@ -214,4 +223,77 @@ export class NodesApi { } } + async removeUserAccessOnSpaceTemplate(nodeName: string): Promise { + try { + const templatesRootFolderId = await this.getSpaceTemplatesFolderId(); + const nodeId: string = await this.getNodeIdFromParent(nodeName, templatesRootFolderId); + + return this.setInheritPermissions(nodeId, false); + } catch (error) { + logger.error('Admin Actions - removeUserAccessOnSpaceTemplate failed : ', error); + return null; + } + } + + async setInheritPermissions(nodeId: string, inheritPermissions: boolean): Promise { + const data = { + permissions: { + isInheritanceEnabled: inheritPermissions + } + }; + + try { + return await this.apiService.nodes.updateNode(nodeId, data); + } catch (error) { + logger.error(`${this.constructor.name} ${this.setInheritPermissions.name}`, error); + return null; + } + } + + private async addAspects(nodeId: string, aspectNames: string[]): Promise { + try { + return this.apiService.nodes.updateNode(nodeId, { aspectNames }); + } catch (error) { + logger.error(`${this.constructor.name} ${this.addAspects.name}`, error); + return null; + } + } + + async createFolderLink(originalNodeId: string, destinationId: string): Promise { + const name = (await this.getNodeById(originalNodeId)).entry.name; + const nodeBody = { + name: `Link to ${name}.url`, + nodeType: 'app:folderlink', + properties: { + 'cm:title': `Link to ${name}.url`, + 'cm:destination': originalNodeId, + 'cm:description': `Link to ${name}.url`, + 'app:icon': 'space-icon-link' + } + }; + + try { + const link = await this.apiService.nodes.createNode(destinationId, nodeBody); + await this.addAspects(originalNodeId, ['app:linked']); + return link; + } catch (error) { + logger.error(`${this.constructor.name} ${this.createFolderLink.name}`, error); + return null; + } + } + + async createLinkToFolderName(originalFolderName: string, originalFolderParentId: string, destinationParentId?: string): Promise { + if (!destinationParentId) { + destinationParentId = originalFolderParentId; + } + + try { + const nodeId = await this.getNodeIdFromParent(originalFolderName, originalFolderParentId); + return this.createFolderLink(nodeId, destinationParentId); + } catch (error) { + logger.error('Admin Actions - createLinkToFolderName failed : ', error); + return null; + } + } + } 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 bbb1d9355c..f8b791d485 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 @@ -22,8 +22,9 @@ * from Hyland Software. If not, see . */ -import { BaseComponent } from './base.component'; import { Page } from '@playwright/test'; +import { MatMenuComponent } from './dataTable'; +import { BaseComponent } from './base.component'; export class AcaHeader extends BaseComponent { private static rootElement = 'aca-toolbar'; private moreActionsButton = this.getChild('button[id="app.viewer.toolbar.more"]'); @@ -38,9 +39,15 @@ export class AcaHeader extends BaseComponent { constructor(page: Page) { super(page, AcaHeader.rootElement); } + public matMenu = new MatMenuComponent(this.page); async clickViewerMoreActions(): Promise { await this.moreActionsButton.waitFor({ state: 'attached' }); await this.moreActionsButton.click(); } + + async clickCreateFolderFromTemplate(): Promise { + await this.createButton.click(); + await this.matMenu.createFolderFromTemplate.click(); + } } 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 11910754b1..4b16fe012d 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 @@ -56,7 +56,7 @@ export abstract class BaseComponent extends PlaywrightBase { async spinnerWaitForReload(): Promise { try { - await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: timeouts.normal }); + await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: timeouts.medium }); await this.page.locator('mat-progress-spinner').waitFor({ state: 'detached', timeout: timeouts.normal }); } catch (e) { this.logger.info('Spinner was not present'); 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 eb66e89699..51139cc0a9 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 @@ -39,10 +39,14 @@ export class DataTableComponent extends BaseComponent { getEmptyFolderLocator = this.getChild('.adf-empty-folder'); getEmptyContentTitleLocator = this.getChild('adf-empty-content .adf-empty-content__title'); getEmptyContentSubTitleLocator = this.getChild('adf-empty-content .adf-empty-content__subtitle'); + getSelectedRow = this.getChild('.adf-datatable-row.adf-is-selected'); /** Locator for row (or rows) */ getRowLocator = this.getChild(`adf-datatable-row`); + /** Locator to get "No results found" message */ + getNoResultsFoundMessage = this.getChild('adf-custom-empty-content-template', { hasText: "No results found" }); + /** * Method used in cases where we want to check that some record is visible in the datatable. It will consider whole row * 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 1f48038a6c..46bbe2d9b8 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,6 +35,7 @@ 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 createFolderFromTemplate = this.getChild('[id="app.create.folderFromTemplate"]'); 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/content-node-selector-dialog.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/content-node-selector-dialog.ts index 870d3b2f2c..cd29aff11f 100755 --- a/projects/aca-playwright-shared/src/page-objects/components/dialogs/content-node-selector-dialog.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/content-node-selector-dialog.ts @@ -28,16 +28,20 @@ import { BaseComponent } from '../base.component'; export class ContentNodeSelectorDialog extends BaseComponent { private static rootElement = 'adf-content-node-selector'; + constructor(page: Page) { + super(page, ContentNodeSelectorDialog.rootElement); + } + public cancelButton = this.getChild('[data-automation-id="content-node-selector-actions-cancel"]'); public actionButton = this.getChild('[data-automation-id="content-node-selector-actions-choose"]'); public locationDropDown = this.getChild('[id="site-dropdown-container"]'); private selectedRow = this.getChild('.adf-is-selected'); - private getOptionLocator = (optionName: string): Locator => this.page.locator('.mat-select-panel .mat-option-text', { hasText: optionName }); + getOptionLocator = (optionName: string): Locator => this.page.locator('.mat-select-panel .mat-option-text', { hasText: optionName }); private getRowByName = (name: string | number): Locator => this.getChild(`adf-datatable-row`, { hasText: name.toString() }); + getDialogTitle = (text: string) => this.getChild('.mat-dialog-title', { hasText: text }); + getBreadcrumb = (text: string) => this.getChild('[data-automation-id="current-folder"]', { hasText: text }); + getFolderIcon = this.getChild('mat-icon[role="img"]', { hasText: "folder" }); - constructor(page: Page) { - super(page, ContentNodeSelectorDialog.rootElement); - } async selectLocation(location: string): Promise { await this.locationDropDown.click(); diff --git a/projects/aca-playwright-shared/src/page-objects/components/dialogs/create-from-template-dialog-component.ts b/projects/aca-playwright-shared/src/page-objects/components/dialogs/create-from-template-dialog-component.ts new file mode 100644 index 0000000000..f92df80493 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/components/dialogs/create-from-template-dialog-component.ts @@ -0,0 +1,57 @@ +/*! + * Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved. + * + * Alfresco Example Content Application + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +import { Locator, Page } from '@playwright/test'; +import { BaseComponent } from '../base.component'; +import { timeouts } from '../../../utils'; + +export class CreateFromTemplateDialogComponent extends BaseComponent { + private static rootElement = 'ng-component'; + + constructor(page: Page) { + super(page, CreateFromTemplateDialogComponent.rootElement); + } + + cancelButton = this.getChild('[data-automation-id="cancel-folder-template-button"]'); + createButton = this.getChild('[data-automation-id="create-folder-template-button"]'); + getDialogTitle = (text: string) => this.getChild('.mat-dialog-title', { hasText: text }); + getDialogLabel = (text: string) => this.getChild('label', { hasText: text }); + getErrorByText = (text: string): Locator => this.page.locator('mat-error', {hasText: text}); + + + async isErrorMessageDisplayed(errorText: string): Promise { + await this.getErrorByText(errorText).waitFor({ state: 'visible', timeout: timeouts.large }); + return await this.getErrorByText(errorText).isVisible(); + } + + /** + * This method is used when we want to fill in Create new folder from template dialog and choose Create button + */ + async createNewFolderFromTemplate( nameInput: string, titleInput?: string, descriptionInput?: string): Promise { + await this.getDialogLabel('Name *').fill(nameInput); + if (titleInput) { await this.getDialogLabel('Title').fill(titleInput); } + if (descriptionInput) { await this.getDialogLabel('Description').fill(descriptionInput); } + 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 93e39fa9fe..c1504a172b 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 @@ -27,3 +27,4 @@ export * from './adf-library-dialog.component'; export * from './password-overlay-dialog.component'; export * from './viewer-overlay-dialog.component'; export * from './content-node-selector-dialog'; +export * from './create-from-template-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 567c0403f3..3083c6a25c 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/index.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/index.ts @@ -37,3 +37,4 @@ export * from './search/search-input.component'; export * from './search/search-overlay.components'; export * from './breadcrumb/breadcrumb.component'; export * from './sidenav.component'; +export * from './aca-header.component'; 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 b051482080..8fe5e44ba7 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 @@ -24,8 +24,8 @@ import { Page } from '@playwright/test'; import { BasePage } from './base.page'; -import { AcaHeader } from '../components/aca-header.component'; import { + AcaHeader, AdfInfoDrawerComponent, AdfLibraryDialogComponent, DataTableComponent, @@ -34,7 +34,8 @@ import { ViewerOverlayDialogComponent, ContentNodeSelectorDialog, Breadcrumb, - SidenavComponent + SidenavComponent, + CreateFromTemplateDialogComponent } from '../components'; export class MyLibrariesPage extends BasePage { @@ -53,6 +54,8 @@ export class MyLibrariesPage extends BasePage { public copyMoveDialog = new ContentNodeSelectorDialog(this.page); public breadcrumb = new Breadcrumb(this.page); public sidenav = new SidenavComponent(this.page); + public contentNodeSelector = new ContentNodeSelectorDialog(this.page); + public createFromTemplateDialogComponent = new CreateFromTemplateDialogComponent(this.page); async selectCreateLibrary(): Promise { await this.acaHeader.createButton.click(); diff --git a/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts index 9bae8882ba..4baaef79a7 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts @@ -24,9 +24,19 @@ import { Page } from '@playwright/test'; import { BasePage } from './base.page'; -import { Breadcrumb, DataTableComponent, MatMenuComponent, ViewerComponent, SidenavComponent } from '../components'; -import { AcaHeader } from '../components/aca-header.component'; -import { AdfFolderDialogComponent, PasswordOverlayDialogComponent, ViewerOverlayDialogComponent } from '../components/dialogs'; +import { + AcaHeader, + AdfFolderDialogComponent, + ContentNodeSelectorDialog, + CreateFromTemplateDialogComponent, + PasswordOverlayDialogComponent, + ViewerOverlayDialogComponent, + Breadcrumb, + DataTableComponent, + MatMenuComponent, + ViewerComponent, + SidenavComponent +} from '../components'; export class PersonalFilesPage extends BasePage { private static pageUrl = 'personal-files'; @@ -38,12 +48,14 @@ export class PersonalFilesPage extends BasePage { public acaHeader = new AcaHeader(this.page); public matMenu = new MatMenuComponent(this.page); public folderDialog = new AdfFolderDialogComponent(this.page); + public contentNodeSelector = new ContentNodeSelectorDialog(this.page); public dataTable = new DataTableComponent(this.page); public viewer = new ViewerComponent(this.page); public passwordDialog = new PasswordOverlayDialogComponent(this.page); public viewerDialog = new ViewerOverlayDialogComponent(this.page); public breadcrumb = new Breadcrumb(this.page); public sidenav = new SidenavComponent(this.page); + public createFromTemplateDialogComponent = new CreateFromTemplateDialogComponent(this.page); async selectCreateFolder(): Promise { await this.acaHeader.createButton.click(); diff --git a/projects/aca-playwright-shared/src/utils/error-strings.ts b/projects/aca-playwright-shared/src/utils/error-strings.ts new file mode 100644 index 0000000000..47b247762e --- /dev/null +++ b/projects/aca-playwright-shared/src/utils/error-strings.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 . + */ + +export const errorStrings = { + + errorMessageNotPresent: 'Error message is not displayed', + nameIsRequiredError: 'Name is required', + nameWithSpecialCharactersError: `Name can't contain these characters * " < > \\ / ? : |`, + nameEndWithDotError: `Name can't end with a period .`, + nameContainOnlySpacesError: `Name can't contain only spaces`, + titleLengthLimitError: 'Use 256 characters or less for title', + descriptionLengthLimitError: 'Use 512 characters or less for description', + nameAlreadyUsedError: 'This name is already in use, try a different name.' + +} diff --git a/projects/aca-playwright-shared/src/utils/index.ts b/projects/aca-playwright-shared/src/utils/index.ts index 0178ddfe69..9cfead78e9 100644 --- a/projects/aca-playwright-shared/src/utils/index.ts +++ b/projects/aca-playwright-shared/src/utils/index.ts @@ -30,3 +30,4 @@ export * from './folder-errors'; export * from './utils'; export * from './library-errors'; export * from './config'; +export * from './error-strings'; diff --git a/projects/aca-playwright-shared/src/utils/utils.ts b/projects/aca-playwright-shared/src/utils/utils.ts index c23779b4c5..d11ba3ed3f 100644 --- a/projects/aca-playwright-shared/src/utils/utils.ts +++ b/projects/aca-playwright-shared/src/utils/utils.ts @@ -25,6 +25,10 @@ const crypto = require('crypto'); export class Utils { + + static string257Long = 'x'.repeat(257); + static string513Long = 'x'.repeat(513); + static random(): string { return crypto.getRandomValues(new Uint32Array(1))[0].toString(36).substring(0, 5).toLowerCase(); }