[ACS-6575] code fix and split action suite (#3604)

* code split and fix

* code split and fix

* code split and fix

* [ACS-6575]code fix in workflow
This commit is contained in:
Akash Rathod
2024-01-19 13:09:07 +05:30
committed by GitHub
parent c77528c530
commit 608e6c5eb4
19 changed files with 134 additions and 10 deletions

View File

@@ -0,0 +1,26 @@
{
"extends": "../../../.eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"e2e/playwright/create-actions/tsconfig.e2e.json"
],
"createDefaultProgram": true
},
"plugins": [
"rxjs",
"unicorn"
],
"rules": {
"@typescript-eslint/no-floating-promises": "off"
}
}
]
}

View File

@@ -0,0 +1 @@
{}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
import { PlaywrightTestConfig } from '@playwright/test';
import { CustomConfig, getGlobalConfig, getExcludedTestsRegExpArray } from '@alfresco/playwright-shared';
import EXCLUDED_JSON from './exclude.tests.json';
const config: PlaywrightTestConfig<CustomConfig> = {
...getGlobalConfig,
grepInvert: getExcludedTestsRegExpArray(EXCLUDED_JSON, 'Create Actions'),
projects: [
{
name: 'Create Actions',
testDir: './src/tests',
use: {
users: ['hruser']
}
}
]
};
export default config;

View File

@@ -0,0 +1,22 @@
{
"name": "create-actions-e2e",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/playwright/create-actions",
"projectType": "application",
"targets": {
"e2e": {
"executor": "nx:run-commands",
"options": {
"commands": ["npx playwright test --config=e2e/playwright/create-actions/playwright.config.ts"]
},
"configurations": {
"production": {
"devServerTarget": "content-ce:serve:production"
}
}
},
"lint": {
"executor": "@angular-eslint/builder:lint"
}
}
}

View File

@@ -0,0 +1,428 @@
/*!
* 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 {
AcaHeader,
ApiClientFactory,
ContentNodeSelectorDialog,
CreateFromTemplateDialogComponent,
DataTableComponent,
NodeContentTree,
NodesApi,
SitesApi,
Utils,
errorStrings,
test
} from '@alfresco/playwright-shared';
test.describe('Create file from template', () => {
let nodesApi: NodesApi;
let selectFileTemplateDialog: ContentNodeSelectorDialog;
let createFileFromTemplateDialog: CreateFromTemplateDialogComponent;
let dataTable: DataTableComponent;
let toolbar: AcaHeader;
let randomFileName: string;
let randomFileTitle: string;
let randomFileDescription: string;
let fileLink: string;
const selectDialogTitle = 'Select a document template';
const dialogBreadcrumb = 'Node 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 username = `user-${Utils.random()}`;
const restrictedTemplateFolder = `restricted-templates-${random}`;
const templateInRestrictedFolder = `template-restricted-${random}.txt`;
const templatesFolder1 = `templates-folder1-${random}`;
const template1InFolder1 = `template1-1-${random}.txt`;
const template2InFolder1 = `template1-2-${random}.txt`;
const templatesFolder2 = `templates-folder2-${random}`;
const template1InFolder2 = `template2-1-${random}.txt`;
const templatesSubFolder = `template-subFolder-${random}`;
const template1InRoot = `template3-${random}.txt`;
const template2InRoot = `template4-${random}.txt`;
const createDialogTitle = `Create new document from '${template1InRoot}'`;
const commonFileName = `playwright-file-${Utils.random()}`;
const templates: NodeContentTree = {
folders: [
{
name: templatesFolder1,
folders: [
{
name: templatesSubFolder,
files: [template1InFolder1, template2InFolder1]
}
]
},
{
name: templatesFolder2,
files: [template1InFolder2]
},
{
name: restrictedTemplateFolder,
files: [templateInRestrictedFolder]
}
],
files: [template1InRoot, template2InRoot]
};
test.beforeAll(async ({ nodesApiAction }) => {
const apiService = new ApiClientFactory();
await apiService.setUpAcaBackend('admin');
await apiService.createUser({ username: username });
await nodesApiAction.createContent(templates, `Data Dictionary/Node Templates`);
await nodesApiAction.removeUserAccessOnNodeTemplate(restrictedTemplateFolder);
fileLink = (await nodesApiAction.createLinkToFileName(template2InRoot, await nodesApiAction.getNodeTemplatesFolderId())).entry.name;
nodesApi = await NodesApi.initialize(username, username);
});
test.beforeEach(async ({ loginPage, personalFiles }) => {
try {
await loginPage.loginUser(
{ username: username, password: username },
{
withNavigation: true,
waitForLoading: true
}
);
await personalFiles.navigate();
} catch (error) {
console.error(`Main beforeEach failed: ${error}`);
}
});
test.afterAll(async ({ nodesApiAction }) => {
await nodesApiAction.cleanupNodeTemplatesItems([templatesFolder1, templatesFolder2, restrictedTemplateFolder, template1InRoot, template2InRoot]);
await nodesApi.deleteCurrentUserNodes();
});
test.describe('Personal Files page', () => {
test.beforeEach(async ({ personalFiles }) => {
try {
selectFileTemplateDialog = personalFiles.contentNodeSelector;
dataTable = personalFiles.dataTable;
toolbar = personalFiles.acaHeader;
await toolbar.clickCreateFileFromTemplate();
await selectFileTemplateDialog.loadMoreNodes();
} catch (error) {
console.error(`Personal Files page, beforeEach failed: ${error}`);
}
});
test.describe('Select Template dialog', () => {
test('[C325043] Select template - dialog UI - with existing templates', async () => {
await expect.soft(selectFileTemplateDialog.getDialogTitle(selectDialogTitle)).toBeVisible();
await expect.soft(selectFileTemplateDialog.getBreadcrumb(dialogBreadcrumb)).toBeVisible();
await expect.soft(dataTable.getRowByName(templatesFolder1)).not.toBeEmpty();
await expect.soft(dataTable.getRowByName(templatesFolder1)).toBeVisible();
await expect.soft(dataTable.getRowByName(templatesFolder2)).toBeVisible();
await expect.soft(dataTable.getRowByName(template1InRoot)).toBeVisible();
await expect.soft(selectFileTemplateDialog.cancelButton).toBeEnabled();
await expect(selectFileTemplateDialog.actionButton).toBeDisabled();
});
test(`[C325044] Templates don't appear if user doesn't have permissions to see them`, async () => {
await expect(selectFileTemplateDialog.getDialogTitle(selectDialogTitle)).toBeVisible();
await expect(dataTable.getRowByName(restrictedTemplateFolder)).not.toBeVisible();
await expect(dataTable.getRowByName(templateInRestrictedFolder)).not.toBeVisible();
});
test(`[C325045] Navigate through the templates list with folder hierarchy`, async () => {
await expect(selectFileTemplateDialog.getBreadcrumb(dialogBreadcrumb)).toBeVisible();
await expect(dataTable.getRowByName(templatesFolder1)).toBeVisible();
await expect(dataTable.getRowByName(templatesFolder2)).toBeVisible();
await expect(dataTable.getRowByName(template1InRoot)).toBeVisible();
await dataTable.getRowByName(templatesFolder1).dblclick();
await expect(selectFileTemplateDialog.getBreadcrumb(templatesFolder1)).toBeVisible();
await expect(dataTable.getRowByName(templatesSubFolder)).toBeVisible();
await dataTable.getRowByName(templatesSubFolder).dblclick();
await expect(selectFileTemplateDialog.getBreadcrumb(templatesSubFolder)).toBeVisible();
await expect(dataTable.getRowByName(template1InFolder1)).toBeVisible();
await expect(dataTable.getRowByName(template2InFolder1)).toBeVisible();
await selectFileTemplateDialog.getFolderIcon.click();
await expect(selectFileTemplateDialog.getOptionLocator(templatesFolder1)).toBeVisible();
await expect(selectFileTemplateDialog.getOptionLocator(dialogBreadcrumb)).toBeVisible();
});
test(`[C325047] Templates list doesn't allow multiple selection`, async () => {
await expect(dataTable.getSelectedRow).toHaveCount(0);
await dataTable.getRowByName(template1InRoot).click({ modifiers: [commandKey] });
await expect(dataTable.getSelectedRow).toHaveCount(1);
await expect(dataTable.getSelectedRow).toContainText(template1InRoot);
await dataTable.getRowByName(template2InRoot).click({ modifiers: [commandKey] });
await expect(dataTable.getSelectedRow).not.toHaveCount(2);
await expect(dataTable.getSelectedRow).toHaveCount(1);
await expect(dataTable.getSelectedRow).toContainText(template2InRoot);
});
test('[C325050] Links to files are not displayed', async () => {
await expect(dataTable.getRowByName(template1InRoot)).toBeVisible();
await expect(dataTable.getRowByName(template2InRoot)).toBeVisible();
await expect(dataTable.getRowByName(fileLink)).not.toBeVisible();
});
test('[C325048] Cancel the Select template dialog', async () => {
await expect(selectFileTemplateDialog.getDialogTitle(selectDialogTitle)).toBeVisible();
await selectFileTemplateDialog.cancelButton.click();
await expect(selectFileTemplateDialog.getDialogTitle(selectDialogTitle)).toBeHidden();
});
test('[C216339] Next button is disabled when selecting a folder', async () => {
await expect(dataTable.getRowByName(templatesFolder1)).toBeVisible();
await expect(selectFileTemplateDialog.actionButton).toBeDisabled();
await dataTable.getRowByName(templatesFolder1).click();
await expect(selectFileTemplateDialog.actionButton).toBeDisabled();
});
});
test.describe('Create document from template dialog', () => {
test.beforeAll(async () => {
await nodesApi.createFile(commonFileName);
});
test.beforeEach(async ({ personalFiles }) => {
try {
createFileFromTemplateDialog = personalFiles.createFromTemplateDialogComponent;
await dataTable.getRowByName(template1InRoot).click();
await selectFileTemplateDialog.actionButton.click();
} catch (error) {
console.error(`Create document from template dialog, beforeEach failed: ${error}`);
}
});
test('[C325020] Create file from template - dialog UI', async () => {
await expect.soft(createFileFromTemplateDialog.getDialogTitle(createDialogTitle)).toBeVisible();
await expect.soft(createFileFromTemplateDialog.getDialogLabel(nameLabel)).toBeVisible();
await expect.soft(createFileFromTemplateDialog.getDialogLabel(nameLabel)).toHaveValue(template1InRoot);
await expect.soft(createFileFromTemplateDialog.getDialogLabel(titleLabel)).toBeVisible();
await expect.soft(createFileFromTemplateDialog.getDialogLabel(titleLabel)).toHaveValue(emptyString);
await expect.soft(createFileFromTemplateDialog.getDialogLabel(descriptionLabel)).toBeVisible();
await expect.soft(createFileFromTemplateDialog.getDialogLabel(descriptionLabel)).toHaveValue(emptyString);
await expect.soft(createFileFromTemplateDialog.cancelButton).toBeEnabled();
await expect(createFileFromTemplateDialog.createButton).toBeEnabled();
});
test('[C325031] File name is required', async () => {
await expect(createFileFromTemplateDialog.getDialogLabel(nameLabel)).toHaveValue(template1InRoot);
await createFileFromTemplateDialog.getDialogLabel(nameLabel).clear();
await createFileFromTemplateDialog.page.keyboard.press(tabKeyString);
await expect(createFileFromTemplateDialog.getDialogLabel(nameLabel)).toHaveValue(emptyString);
expect
.soft(await createFileFromTemplateDialog.isErrorMessageDisplayed(errorStrings.nameIsRequiredError), errorStrings.errorMessageNotPresent)
.toBe(true);
await expect(createFileFromTemplateDialog.createButton).toBeDisabled();
});
test('[C325032] Special characters in file name', async () => {
const nameWithSpecialChars = ['a*a', 'a"a', 'a<a', 'a>a', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a'];
for (const specialFileName of nameWithSpecialChars) {
await createFileFromTemplateDialog.getDialogLabel(nameLabel).fill(specialFileName);
await createFileFromTemplateDialog.page.keyboard.press(tabKeyString);
await expect(createFileFromTemplateDialog.getDialogLabel(nameLabel)).toHaveValue(specialFileName);
expect
.soft(
await createFileFromTemplateDialog.isErrorMessageDisplayed(errorStrings.nameWithSpecialCharactersError),
errorStrings.errorMessageNotPresent
)
.toBe(true);
await expect(createFileFromTemplateDialog.createButton).toBeDisabled();
}
});
test('[C325033] File name ending with a dot', async () => {
await createFileFromTemplateDialog.getDialogLabel(nameLabel).type(dotString);
await createFileFromTemplateDialog.page.keyboard.press(tabKeyString);
await expect(createFileFromTemplateDialog.getDialogLabel(nameLabel)).toHaveValue(template1InRoot + dotString);
expect
.soft(await createFileFromTemplateDialog.isErrorMessageDisplayed(errorStrings.nameEndWithDotError), errorStrings.errorMessageNotPresent)
.toBe(true);
await expect(createFileFromTemplateDialog.createButton).toBeDisabled();
});
test('[C325034] File name containing only spaces', async () => {
await createFileFromTemplateDialog.getDialogLabel(nameLabel).clear();
await createFileFromTemplateDialog.getDialogLabel(nameLabel).fill(spaceString);
await createFileFromTemplateDialog.page.keyboard.press(tabKeyString);
await expect(createFileFromTemplateDialog.getDialogLabel(nameLabel)).toHaveValue(spaceString);
expect
.soft(
await createFileFromTemplateDialog.isErrorMessageDisplayed(errorStrings.nameContainOnlySpacesError),
errorStrings.errorMessageNotPresent
)
.toBe(true);
await expect(createFileFromTemplateDialog.createButton).toBeDisabled();
});
test('[C290146] File title too long', async () => {
await createFileFromTemplateDialog.getDialogLabel(titleLabel).fill(Utils.string257Long);
await createFileFromTemplateDialog.page.keyboard.press(tabKeyString);
await expect(createFileFromTemplateDialog.getDialogLabel(titleLabel)).toHaveValue(Utils.string257Long);
expect
.soft(await createFileFromTemplateDialog.isErrorMessageDisplayed(errorStrings.titleLengthLimitError), errorStrings.errorMessageNotPresent)
.toBe(true);
await expect(createFileFromTemplateDialog.createButton).toBeDisabled();
});
test('[C290142] Description too long', async () => {
await createFileFromTemplateDialog.getDialogLabel(descriptionLabel).fill(Utils.string513Long);
await createFileFromTemplateDialog.page.keyboard.press(tabKeyString);
await expect(createFileFromTemplateDialog.getDialogLabel(descriptionLabel)).toHaveValue(Utils.string513Long);
expect
.soft(
await createFileFromTemplateDialog.isErrorMessageDisplayed(errorStrings.descriptionLengthLimitError),
errorStrings.errorMessageNotPresent
)
.toBe(true);
await expect(createFileFromTemplateDialog.createButton).toBeDisabled();
});
test('[C325028] Create a file with a duplicate name', async ({ personalFiles }) => {
const snackBar = personalFiles.snackBar;
await createFileFromTemplateDialog.createFromTemplateAction(commonFileName);
await expect(snackBar.getByMessageLocator(errorStrings.nameAlreadyUsedError)).toBeVisible();
await expect(createFileFromTemplateDialog.getDialogTitle(createDialogTitle)).toBeVisible();
});
test('[C325027] Cancel file creation', async () => {
await expect(createFileFromTemplateDialog.getDialogTitle(createDialogTitle)).toBeVisible();
await createFileFromTemplateDialog.cancelButton.click();
await expect(createFileFromTemplateDialog.getDialogTitle(createDialogTitle)).not.toBeVisible();
});
});
test.describe('File created from template on Personal Files', () => {
test.beforeEach(async ({ personalFiles }) => {
try {
randomFileName = `playwright-file-${Utils.random()}`;
randomFileTitle = `file-title-${Utils.random()}`;
randomFileDescription = `file-description-${Utils.random()}`;
createFileFromTemplateDialog = personalFiles.createFromTemplateDialogComponent;
await dataTable.getRowByName(template1InRoot).click();
await selectFileTemplateDialog.actionButton.click();
} catch (error) {
console.error(`File created from template on Personal Files, beforeEach failed: ${error}`);
}
});
test('[C325030] Create a file from a template - with a new Name', async () => {
await createFileFromTemplateDialog.createFromTemplateAction(randomFileName);
await dataTable.goThroughPagesLookingForRowWithName(randomFileName);
await expect(dataTable.getRowByName(randomFileName)).toBeVisible();
});
test('[C325026] Create a file from a template - with a Name, Title and Description', async () => {
await createFileFromTemplateDialog.createFromTemplateAction(randomFileName, randomFileTitle, randomFileDescription);
await dataTable.goThroughPagesLookingForRowWithName(randomFileName);
await expect(dataTable.getCellLinkByName(randomFileName)).toHaveAttribute(titleLabel, randomFileTitle + `\n` + randomFileDescription);
});
test('[C325042] Trim spaces from file Name', async () => {
await createFileFromTemplateDialog.createFromTemplateAction(' ' + randomFileName + ' ');
await dataTable.goThroughPagesLookingForRowWithName(randomFileName);
await expect(dataTable.getRowByName(randomFileName)).toBeVisible();
});
});
});
test.describe('File created from template on Personal Files Libraries', () => {
const randomLibraryName = `playwright-library-${Utils.random()}`;
let sitesApi: SitesApi;
test.beforeAll(async () => {
sitesApi = await SitesApi.initialize(username, username);
await sitesApi.createSite(randomLibraryName);
const libraryGuId = await sitesApi.getDocLibId(randomLibraryName);
await nodesApi.createFile(commonFileName, libraryGuId);
});
test.beforeEach(async ({ myLibrariesPage }) => {
try {
randomFileName = `playwright-file-${Utils.random()}`;
randomFileTitle = `file-title-${Utils.random()}`;
randomFileDescription = `file-description-${Utils.random()}`;
await myLibrariesPage.navigate();
selectFileTemplateDialog = myLibrariesPage.contentNodeSelector;
createFileFromTemplateDialog = myLibrariesPage.createFromTemplateDialogComponent;
dataTable = myLibrariesPage.dataTable;
toolbar = myLibrariesPage.acaHeader;
await dataTable.getRowByName(randomLibraryName).dblclick();
await dataTable.spinnerWaitForReload();
await toolbar.clickCreateFileFromTemplate();
await selectFileTemplateDialog.loadMoreNodes();
await dataTable.getRowByName(template1InRoot).click();
await selectFileTemplateDialog.actionButton.click();
} catch (error) {
console.error(`File created from template on Personal Files Libraries, beforeEach failed: ${error}`);
}
});
test.afterAll(async () => {
await sitesApi.deleteSites([randomLibraryName]);
});
test('[C325023] Create a file from a template from library - with Name, Title and Description', async () => {
await createFileFromTemplateDialog.createFromTemplateAction(randomFileName, randomFileTitle, randomFileDescription);
await expect(dataTable.getCellLinkByName(randomFileName)).toHaveAttribute(titleLabel, randomFileTitle + `\n` + randomFileDescription);
});
test('[C325024] Cancel file creation in a library', async () => {
await expect(createFileFromTemplateDialog.getDialogTitle(createDialogTitle)).toBeVisible();
await createFileFromTemplateDialog.cancelButton.click();
await expect(createFileFromTemplateDialog.getDialogTitle(createDialogTitle)).not.toBeVisible();
await expect(dataTable.getRowByName(randomFileName)).not.toBeVisible();
});
test('[C325025] Create a file with a duplicate name in a library', async ({ myLibrariesPage }) => {
const snackBar = myLibrariesPage.snackBar;
await createFileFromTemplateDialog.createFromTemplateAction(commonFileName);
await expect(snackBar.getByMessageLocator(errorStrings.nameAlreadyUsedError)).toBeVisible();
await expect(createFileFromTemplateDialog.getDialogTitle(createDialogTitle)).toBeVisible();
});
});
});

View File

@@ -0,0 +1,476 @@
/*!
* 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 {
AcaHeader,
ApiClientFactory,
ContentNodeSelectorDialog,
CreateFromTemplateDialogComponent,
DataTableComponent,
NodeContentTree,
NodesApi,
SitesApi,
Utils,
errorStrings,
test
} from '@alfresco/playwright-shared';
test.describe('Create folder from template', () => {
const apiClientFactory = new ApiClientFactory();
let nodesApi: NodesApi;
let selectFolderTemplateDialog: ContentNodeSelectorDialog;
let createFolderFromTemplateDialog: CreateFromTemplateDialogComponent;
let dataTable: DataTableComponent;
let toolbar: AcaHeader;
let randomFolderName: string;
let randomFolderTitle: string;
let randomFolderDescription: string;
let folderLink: 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 username = `user-${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 }) => {
try {
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username: username });
await nodesApiAction.createContent(templates, `Data Dictionary/Space Templates`);
await nodesApiAction.removeUserAccessOnSpaceTemplate(restrictedTemplateFolder);
folderLink = (await nodesApiAction.createLinkToFolderName(folderInRootFolder, await nodesApiAction.getSpaceTemplatesFolderId())).entry.name;
} catch (error) {
console.error(`Main beforeAll failed : ${error}`);
}
});
test.beforeEach(async ({ loginPage, personalFiles }) => {
try {
await loginPage.loginUser(
{ username: username, password: username },
{
withNavigation: true,
waitForLoading: true
}
);
await personalFiles.navigate();
} catch (error) {
console.error(`Main beforeEach failed : ${error}`);
}
});
test.afterAll(async ({ nodesApiAction }) => {
try {
await nodesApiAction.cleanupSpaceTemplatesItems([
folderInRootFolder,
templateFolder1,
templateFolder2,
restrictedTemplateFolder,
fileInRootFolder
]);
} catch (error) {
console.error(`Main afterAll failed : ${error}`);
}
});
test.describe('Personal Files page', () => {
test.beforeAll(async () => {
try {
nodesApi = await NodesApi.initialize(username, username);
} catch (error) {
console.error(`Personal Files page, beforeAll failed : ${error}`);
}
});
test.beforeEach(async ({ personalFiles }) => {
try {
selectFolderTemplateDialog = personalFiles.contentNodeSelector;
dataTable = personalFiles.dataTable;
toolbar = personalFiles.acaHeader;
await toolbar.clickCreateFolderFromTemplate();
await selectFolderTemplateDialog.loadMoreNodes();
} catch (error) {
console.error(`Personal Files page, beforeEach failed : ${error}`);
}
});
test.afterAll(async () => {
try {
await nodesApi.deleteCurrentUserNodes();
} catch (error) {
console.error(`Personal Files page, afterAll failed : ${error}`);
}
});
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 () => {
try {
await nodesApi.createFolder(commonFolderName);
} catch (error) {
console.error(`Create from template dialog, beforeAll failed : ${error}`);
}
});
test.beforeEach(async ({ personalFiles }) => {
try {
createFolderFromTemplateDialog = personalFiles.createFromTemplateDialogComponent;
await dataTable.getRowByName(templateFolder1).click();
await selectFolderTemplateDialog.actionButton.click();
} catch (error) {
console.error(`Create from template dialog, beforeEach failed : ${error}`);
}
});
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', 'a<a', 'a>a', `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.createFromTemplateAction(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 }) => {
try {
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();
} catch (error) {
console.error(`Folder created from template on Personal Files, beforeEach failed : ${error}`);
}
});
test('[C325157] Create a folder from a template - with a new Name', async () => {
await createFolderFromTemplateDialog.createFromTemplateAction(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.createFromTemplateAction(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.createFromTemplateAction(' ' + 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()}`;
let sitesApi: SitesApi;
test.beforeAll(async () => {
try {
sitesApi = await SitesApi.initialize(username, username);
await sitesApi.createSite(randomLibraryName);
const libraryGuId = await sitesApi.getDocLibId(randomLibraryName);
await nodesApi.createFolder(commonFolderName, libraryGuId);
} catch (error) {
console.error(`Folder created from template on Personal Files Libraries, beforeAll failed : ${error}`);
}
});
test.beforeEach(async ({ myLibrariesPage }) => {
try {
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 selectFolderTemplateDialog.loadMoreNodes();
await dataTable.getRowByName(templateFolder1).click();
await selectFolderTemplateDialog.actionButton.click();
} catch (error) {
console.error(`Folder created from template on Personal Files Libraries, beforeEach failed : ${error}`);
}
});
test.afterAll(async () => {
try {
await sitesApi.deleteSites([randomLibraryName]);
} catch (error) {
console.error(`Folder created from template on Personal Files Libraries, afterAll failed : ${error}`);
}
});
test('[C325161] Create a folder from a template from library - with Name, Title and Description', async () => {
await createFolderFromTemplateDialog.createFromTemplateAction(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.createFromTemplateAction(commonFolderName);
await expect(snackBar.getByMessageLocator(errorStrings.nameAlreadyUsedError)).toBeVisible();
await expect(createFolderFromTemplateDialog.getDialogTitle(createDialogTitle)).toBeVisible();
});
});
});

View File

@@ -0,0 +1,177 @@
/*!
* 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 {
AdfFolderDialogComponent,
ApiClientFactory,
DataTableComponent,
LoginPage,
NodesApi,
Utils,
errorStrings,
test
} from '@alfresco/playwright-shared';
test.describe('Create folders', () => {
const apiClientFactory = new ApiClientFactory();
let nodesApi: NodesApi;
let folderDialog: AdfFolderDialogComponent;
let folderTable: DataTableComponent;
let randomFolderName: string;
let randomFolderTitle: string;
let randomFolderDescription: string;
const dialogString = 'dialog';
const createNewFolderString = 'Create new folder';
const spacesString = ' ';
const commonFolderName = `playwright-folder-${Utils.random()}`;
const username = `user-${Utils.random()}`;
test.beforeAll(async () => {
try {
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
nodesApi = await NodesApi.initialize(username, username);
await nodesApi.createFolder(commonFolderName);
} catch (error) {
console.error(`beforeAll failed : ${error}`);
}
});
test.beforeEach(async ({ personalFiles, page }) => {
randomFolderName = `playwright-folder-${Utils.random()}`;
randomFolderTitle = `folder-title-${Utils.random()}`;
randomFolderDescription = `folder-description-${Utils.random()}`;
folderDialog = personalFiles.folderDialog;
const loginPage = new LoginPage(page);
try {
await loginPage.loginUser(
{ username, password: username },
{
withNavigation: true,
waitForLoading: true
}
);
await personalFiles.navigate();
await personalFiles.selectCreateFolder();
} catch (error) {
console.error(`beforeEach failed : ${error}`);
}
});
test.afterAll(async () => {
try {
await nodesApi.deleteCurrentUserNodes();
} catch (error) {
console.error(`afterAll failed : ${error}`);
}
});
test('[C216345] Create new folder dialog check', async () => {
await expect(folderDialog.getLabelText('Name')).toBeVisible();
await expect(folderDialog.getLabelText('*')).toBeVisible();
await expect(folderDialog.folderNameInputLocator).toBeVisible();
await expect(folderDialog.getLabelText('Title')).toBeVisible();
await expect(folderDialog.folderTitleInput).toBeVisible();
await expect(folderDialog.getLabelText('Description')).toBeVisible();
await expect(folderDialog.folderDescriptionInput).toBeVisible();
await expect(folderDialog.cancelButton).toBeEnabled();
await expect(folderDialog.createButton).toBeDisabled();
});
test('[C216346] Create a folder without a name', async () => {
await folderDialog.folderNameInputLocator.fill(randomFolderName);
await expect(folderDialog.folderNameInputLocator).toHaveValue(randomFolderName);
await expect(folderDialog.createButton).toBeEnabled();
await folderDialog.folderNameInputLocator.clear();
await expect(folderDialog.folderNameInputLocator).toBeEmpty();
await expect(folderDialog.folderNameInputHint).toContainText(errorStrings.folderNameIsRequired);
await expect(folderDialog.createButton).toBeDisabled();
});
test('[C216348] Create folder when a name that ends with a dot "."', async () => {
await folderDialog.folderNameInputLocator.fill(randomFolderName + '.');
await expect(folderDialog.createButton).toBeDisabled();
await expect(folderDialog.folderNameInputHint).toContainText(errorStrings.folderNameCantEndWithAPeriod);
});
test('[C216347] Create folder with a name containing special characters', async () => {
const namesWithSpecialChars = ['a*a', 'a"a', 'a<a', 'a>a', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a'];
for (const folderName of namesWithSpecialChars) {
await folderDialog.folderNameInputLocator.fill(folderName);
await expect(folderDialog.createButton).toBeDisabled();
await expect(folderDialog.folderNameInputHint).toContainText(errorStrings.folderNameCantContainTheseCharacters);
}
});
test('[C280406] Create a folder with a name containing only spaces', async () => {
await folderDialog.folderNameInputLocator.fill(spacesString);
await expect(folderDialog.createButton).toBeDisabled();
await expect(folderDialog.folderNameInputHint).toContainText(errorStrings.folderNameCantContainOnlySpaces);
});
test('[C216349] Cancel folder creation', async ({ personalFiles }) => {
await expect(personalFiles.page.getByRole(dialogString, { name: createNewFolderString })).toBeVisible();
await folderDialog.folderNameInputLocator.fill(randomFolderName);
await folderDialog.cancelButton.click();
await expect(personalFiles.page.getByRole(dialogString, { name: createNewFolderString })).toBeHidden();
});
test('[C216350] Duplicate folder name error', async ({ personalFiles }) => {
const folderSnackBar = personalFiles.snackBar;
await folderDialog.createNewFolderDialog(commonFolderName);
await expect(folderSnackBar.getByMessageLocator(errorStrings.thereIsAlreadyAFolderWithThisName)).toBeVisible();
});
test.describe('On Personal Files dataTable', () => {
test.beforeEach(async ({ personalFiles }) => {
folderTable = personalFiles.dataTable;
});
test('[C216341] Create a folder with name only', async () => {
await folderDialog.createNewFolderDialog(randomFolderName);
await expect(folderTable.getRowByName(randomFolderName)).toBeVisible();
});
test('[C216340] Create a folder with name, title and description', async () => {
await folderDialog.createNewFolderDialog(randomFolderName, randomFolderTitle, randomFolderDescription);
await expect(folderTable.getCellLinkByName(randomFolderName)).toHaveAttribute('title', randomFolderTitle + `\n` + randomFolderDescription);
});
test('[C216351] Folder created after trimmed ending spaces from a folder name', async () => {
await folderDialog.createNewFolderDialog(randomFolderName + spacesString);
await expect(folderTable.getRowByName(randomFolderName)).toBeVisible();
});
});
});

View File

@@ -0,0 +1,258 @@
/*!
* 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,
test,
libraryErrors,
LoginPage,
SitesApi,
AdfLibraryDialogComponent,
DataTableComponent,
Breadcrumb,
TrashcanApi
} from '@alfresco/playwright-shared';
test.describe('Create Libraries ', () => {
const apiClientFactory = new ApiClientFactory();
let sitesApi: SitesApi;
let libraryDialog: AdfLibraryDialogComponent;
let libraryTable: DataTableComponent;
let libraryBreadcrumb: Breadcrumb;
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 errorMessageNotPresent = 'Error message is not displayed';
const tabKeyString = 'Tab';
const username = `user-${Utils.random()}`;
const commonLibraryName = `playwright-library-${Utils.random()}`;
const commonTrashLibraryName = `playwright-library-${Utils.random()}`;
const createdLibrariesIds: string[] = [];
test.beforeAll(async () => {
try {
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
sitesApi = await SitesApi.initialize(username, username);
await sitesApi.createSite(commonLibraryName);
createdLibrariesIds.push(commonLibraryName);
await sitesApi.createSite(commonTrashLibraryName);
await sitesApi.deleteSites([commonTrashLibraryName], false);
} catch (error) {
console.error(`beforeAll failed : ${error}`);
}
});
test.beforeEach(async ({ myLibrariesPage, page }) => {
randomLibraryName = `playwright-library-${Utils.random()}`;
randomLibraryId = `libraryId-${Utils.random()}`;
randomLibraryDescription = `libraryDescription-${Utils.random()}`;
libraryDialog = myLibrariesPage.libraryDialog;
const loginPage = new LoginPage(page);
try {
await loginPage.loginUser(
{ username: username, password: username },
{
withNavigation: true,
waitForLoading: true
}
);
await myLibrariesPage.navigate();
await myLibrariesPage.selectCreateLibrary();
} catch (error) {
console.error(`beforeEach failed : ${error}`);
}
});
test.afterAll(async () => {
try {
await sitesApi.deleteSites(createdLibrariesIds);
const trashcanApi = await TrashcanApi.initialize(username, username);
await trashcanApi.emptyTrashcan();
} catch (error) {
console.error(`afterAll failed : ${error}`);
}
});
test('[C280024] Create Library dialog UI', async () => {
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.describe('On My Libraries dataTable', () => {
test.beforeEach(async ({ myLibrariesPage }) => {
libraryTable = myLibrariesPage.dataTable;
libraryBreadcrumb = myLibrariesPage.breadcrumb;
});
test('[C280025] Create a public library', async ({ myLibrariesPage }) => {
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.getItemByTitle(randomLibraryName)).toBeVisible();
await myLibrariesPage.navigate();
await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, publicVisibility)).toBeVisible();
createdLibrariesIds.push(randomLibraryName);
});
test('[C289880] Create a moderated library', async ({ myLibrariesPage }) => {
await libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, moderatedVisibility);
await expect(libraryBreadcrumb.getItemByTitle(randomLibraryName)).toBeVisible();
await myLibrariesPage.navigate();
await libraryTable.spinnerWaitForReload();
await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, moderatedVisibility)).toBeVisible();
createdLibrariesIds.push(randomLibraryId);
});
test('[C289881] Create a private library', async ({ myLibrariesPage }) => {
await libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, null, privateVisibility);
await expect(libraryBreadcrumb.getItemByTitle(randomLibraryName)).toBeVisible();
await myLibrariesPage.navigate();
await expect(libraryTable.getCellByColumnNameAndRowItem(randomLibraryName, privateVisibility)).toBeVisible();
createdLibrariesIds.push(randomLibraryId);
});
test('[C289882] Create a library with a given ID and description', async ({ myLibrariesPage }) => {
const libraryViewDetails = myLibrariesPage.acaHeader.viewDetails;
const libraryDetails = myLibrariesPage.libraryDetails;
await libraryDialog.createLibraryWithNameAndId(randomLibraryName, randomLibraryId, randomLibraryDescription);
await expect(libraryBreadcrumb.getItemByTitle(randomLibraryName)).toBeVisible();
await myLibrariesPage.navigate();
await expect(libraryTable.getCellLinkByName(randomLibraryName).and(myLibrariesPage.page.getByTitle(randomLibraryDescription))).toBeVisible();
await libraryTable.getRowByName(randomLibraryName).click();
await libraryViewDetails.click();
expect(await libraryDetails.getNameField('Name').locator('input').inputValue()).toBe(randomLibraryName);
expect(await libraryDetails.getIdField('Library ID').locator('input').inputValue()).toBe(randomLibraryId);
await expect(libraryDetails.getVisibilityField('Visibility').locator('.mat-select-value').getByText(publicVisibility)).toBeVisible();
expect(await libraryDetails.getDescriptionField.inputValue()).toBe(randomLibraryDescription);
createdLibrariesIds.push(randomLibraryId);
});
test('[C280029] Cancel button', async () => {
await expect(libraryDialog.getDialogTitle(libraryDialogTitle)).toBeVisible();
await libraryDialog.getLabelText(libraryNameLabel).fill(randomLibraryName);
await libraryDialog.cancelButton.click();
await expect(libraryDialog.getDialogTitle(libraryDialogTitle)).toBeHidden();
await expect(libraryTable.getRowByName(randomLibraryName)).toHaveCount(0);
});
test('[C280030] Create 2 libraries with same name but different IDs', async ({ myLibrariesPage }) => {
const libraryName = commonLibraryName + ' (' + commonLibraryName + ')';
const libraryName2 = commonLibraryName + ' (' + randomLibraryId + ')';
await libraryDialog.createLibraryWithNameAndId(commonLibraryName, randomLibraryId);
await expect(libraryBreadcrumb.getItemByTitle(commonLibraryName)).toBeVisible();
await myLibrariesPage.navigate();
await expect(libraryTable.getRowByName(libraryName)).toBeVisible();
await expect(libraryTable.getRowByName(libraryName2)).toBeVisible();
createdLibrariesIds.push(randomLibraryId);
});
});
test('[C280026] Library ID cannot contain special characters', async () => {
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 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(tabKeyString);
await expect(libraryDialog.getLabelText(libraryIdLabel)).toHaveValue(specialLibraryId);
expect(await libraryDialog.isErrorMessageDisplayed(libraryErrors.useNumbersAndLettersOnly), errorMessageNotPresent).toBe(true);
await expect(libraryDialog.createButton).toBeDisabled();
}
});
test('[C280027] Duplicate library ID', async () => {
await libraryDialog.getLabelText(libraryNameLabel).fill(randomLibraryName);
await libraryDialog.getLabelText(libraryIdLabel).clear();
await libraryDialog.getLabelText(libraryIdLabel).fill(commonLibraryName);
await libraryDialog.page.keyboard.press(tabKeyString);
await expect(libraryDialog.getLabelText(libraryIdLabel)).toHaveValue(commonLibraryName);
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 () => {
await libraryDialog.getLabelText(libraryNameLabel).fill(randomLibraryName);
await libraryDialog.getLabelText(libraryIdLabel).clear();
await libraryDialog.getLabelText(libraryIdLabel).fill(commonTrashLibraryName);
await libraryDialog.page.keyboard.press(tabKeyString);
await expect(libraryDialog.createButton).toBeEnabled();
await libraryDialog.createButton.click();
await expect(libraryDialog.createButton).toBeDisabled();
expect(await libraryDialog.isErrorMessageDisplayed(libraryErrors.libraryIdIsAlreadyUsed), errorMessageNotPresent).toBe(true);
});
});

View File

@@ -0,0 +1,15 @@
{
"extends": "../../../tsconfig.adf.json",
"compilerOptions": {
"outDir": "../../out-tsc/e2e",
"baseUrl": "./",
"module": "commonjs",
"target": "es2017",
"types": ["jasmine", "jasminewd2", "node"],
"skipLibCheck": true,
"paths": {
"@alfresco/playwright-shared": ["../../../projects/aca-playwright-shared/src/index.ts"]
}
},
"exclude": ["node_modules"]
}

View File

@@ -0,0 +1,15 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/e2e",
"baseUrl": "./",
"module": "commonjs",
"target": "es2017",
"types": ["jasmine", "jasminewd2", "node", "@playwright/test"],
"skipLibCheck": true,
"paths": {
"@alfresco/playwright-shared": ["../../../projects/aca-playwright-shared/src/index.ts"]
}
},
"exclude": ["node_modules"]
}