Files
alfresco-ng2-components/e2e/content-services/directives/edit-folder-directive.e2e.ts
Eugenio Romano a78f24ada1 [ACS-259] refactor login page (#5733)
* refator login page

* refator login page

* remove obsolete classes and move what is needed in the test pck

* fix const

* revert modify

* remove duplicate browser property

* fix build

* fix

* fix

* fix lint

* move drop action in testing
remove not necessary space
js-api centralize content

* first refactor use js-api

* fix protractor

* refactor test config

* simplify properties
fix namings

* ps cloud simplify
remove unused js files

* id fix

* fix search test
simplify environment var step 1

* fix lint

* first user iteration fix

* fix model

* unify use of apiService

* first step automatic user creation Identity

* refactor creation user content-services

* refactor creation user search

* refactor creation user core

* process service refactoring 1

* process service refactoring 1

* process service refactoring 2

* fix process

* appconfig

* fix process util

* fix gallery

* fix "this" reference issues

* fix incorrect import paths

* fix core

* some fixes

* allign

* fix some test
remove structure folder and move in actions

* fixes

* move folders in the right place

* fix

* fix rebase

* solve build issue

* fix e2e

* change init aae

* order api and some fixes

* fix possible not valid password

* fix some ps test

* replace host port also in objects

* Update app-config.service.ts

* fix process

* fix process test

* process service cloud fix

* fiexs

* modify init script

* fix two test

* remove unused property

* host issue

* not use npx

* fix ps cloud test

Co-authored-by: Denys Vuika <denys.vuika@gmail.com>
2020-06-04 14:41:30 +01:00

243 lines
14 KiB
TypeScript

/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
ApiService,
BrowserActions,
LoginSSOPage,
NotificationHistoryPage,
StringUtil,
UploadActions, UserModel
} from '@alfresco/adf-testing';
import { ContentServicesPage } from '../../pages/adf/content-services.page';
import { FolderDialogPage } from '../../pages/adf/dialog/folder-dialog.page';
import { browser, protractor } from 'protractor';
import { NavigationBarPage } from '../../pages/adf/navigation-bar.page';
import { FileModel } from '../../models/ACS/file.model';
import { UsersActions } from '../../actions/users.actions';
describe('Edit folder directive', () => {
const loginPage = new LoginSSOPage();
const contentServicesPage = new ContentServicesPage();
const editFolderDialog = new FolderDialogPage();
const acsUser = new UserModel();
const anotherAcsUser = new UserModel();
const navigationBarPage = new NavigationBarPage();
const notificationHistoryPage = new NotificationHistoryPage();
const apiService = new ApiService();
const usersActions = new UsersActions(apiService);
const pdfFile = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.PDF.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.PDF.file_path
});
const uploadActions = new UploadActions(apiService);
const updateFolderName = StringUtil.generateRandomString(5);
let editFolder, anotherFolder, filePdfNode, subFolder;
beforeAll(async () => {
await apiService.getInstance().login(browser.params.testConfig.admin.email, browser.params.testConfig.admin.password);
await usersActions.createUser(acsUser);
await usersActions.createUser(anotherAcsUser);
await apiService.getInstance().login(acsUser.email, acsUser.password);
editFolder = await uploadActions.createFolder(StringUtil.generateRandomString(5), '-my-');
anotherFolder = await uploadActions.createFolder(StringUtil.generateRandomString(5), '-my-');
subFolder = await uploadActions.createFolder(StringUtil.generateRandomString(5), editFolder.entry.id);
filePdfNode = await uploadActions.uploadFile(pdfFile.location, pdfFile.name, '-my-');
await apiService.getInstance().core.nodesApi.updateNode(editFolder.entry.id,
{
permissions: {
locallySet: [{
authorityId: anotherAcsUser.email,
name: 'Consumer',
accessStatus: 'ALLOWED'
}]
}
});
await loginPage.login(acsUser.email, acsUser.password);
});
afterAll(async () => {
await navigationBarPage.clickLogoutButton();
await apiService.getInstance().login(browser.params.testConfig.admin.email, browser.params.testConfig.admin.password);
await uploadActions.deleteFileOrFolder(editFolder.entry.id);
await uploadActions.deleteFileOrFolder(anotherFolder.entry.id);
await uploadActions.deleteFileOrFolder(filePdfNode.entry.id);
});
beforeEach(async () => {
await navigationBarPage.clickHomeButton();
await navigationBarPage.clickContentServicesButton();
await contentServicesPage.getDocumentList().dataTablePage().waitTillContentLoaded();
});
afterEach(async () => {
await BrowserActions.closeMenuAndDialogs();
});
it('[C260161] Update folder - Cancel button', async () => {
await contentServicesPage.getDocumentList().dataTablePage().selectRow('Display name', editFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().checkRowIsSelected('Display name', editFolder.entry.name);
await contentServicesPage.clickOnEditFolder();
await editFolderDialog.checkFolderDialogIsDisplayed();
await expect(await editFolderDialog.getDialogTitle()).toBe('Edit folder');
await expect(await editFolderDialog.getFolderName()).toBe(editFolder.entry.name);
await editFolderDialog.checkCreateUpdateBtnIsEnabled();
await editFolderDialog.checkCancelBtnIsEnabled();
await editFolderDialog.clickOnCancelButton();
await editFolderDialog.checkFolderDialogIsNotDisplayed();
});
it('[C260162] Update folder - Introducing letters', async () => {
await contentServicesPage.getDocumentList().dataTablePage().checkContentIsDisplayed('Display name', editFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().selectRow('Display name', editFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().checkRowIsSelected('Display name', editFolder.entry.name);
await expect(await contentServicesPage.isEditFolderButtonEnabled()).toBe(true);
await contentServicesPage.clickOnEditFolder();
await editFolderDialog.checkFolderDialogIsDisplayed();
await editFolderDialog.checkCreateUpdateBtnIsEnabled();
await editFolderDialog.addFolderName(editFolder.entry.name + 'a');
await editFolderDialog.checkCreateUpdateBtnIsEnabled();
await editFolderDialog.clickOnCancelButton();
await editFolderDialog.checkFolderDialogIsNotDisplayed();
await contentServicesPage.getDocumentList().dataTablePage().checkContentIsDisplayed('Display name', editFolder.entry.name);
});
it('[C260163] Update folder name with an existing one', async () => {
await contentServicesPage.getDocumentList().dataTablePage().checkContentIsDisplayed('Display name', editFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().selectRow('Display name', editFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().checkRowIsSelected('Display name', editFolder.entry.name);
await expect(await contentServicesPage.isEditFolderButtonEnabled()).toBe(true);
await contentServicesPage.clickOnEditFolder();
await editFolderDialog.checkFolderDialogIsDisplayed();
await editFolderDialog.checkCreateUpdateBtnIsEnabled();
await editFolderDialog.addFolderName(anotherFolder.entry.name);
await editFolderDialog.checkCreateUpdateBtnIsEnabled();
await editFolderDialog.clickOnCreateUpdateButton();
await editFolderDialog.checkFolderDialogIsDisplayed();
await notificationHistoryPage.checkNotifyContains('There\'s already a folder with this name. Try a different name.');
});
it('[C260164] Edit Folder - Unsupported characters', async () => {
await contentServicesPage.getDocumentList().dataTablePage().checkContentIsDisplayed('Display name', editFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().selectRow('Display name', editFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().checkRowIsSelected('Display name', editFolder.entry.name);
await contentServicesPage.clickOnEditFolder();
await editFolderDialog.checkFolderDialogIsDisplayed();
await editFolderDialog.addFolderName('a*"<>\\/?:|');
await expect(await editFolderDialog.getValidationMessage()).toBe('Folder name can\'t contain these characters * " < > \\ / ? : |');
await editFolderDialog.checkCreateUpdateBtnIsDisabled();
await editFolderDialog.addFolderName('a.a');
await editFolderDialog.checkValidationMessageIsNotDisplayed();
await editFolderDialog.checkCreateUpdateBtnIsEnabled();
await editFolderDialog.addFolderName('a.');
await expect(await editFolderDialog.getValidationMessage()).toBe('Folder name can\'t end with a period .');
await editFolderDialog.checkCreateUpdateBtnIsDisabled();
await BrowserActions.clearSendKeys(editFolderDialog.getFolderNameField(), protractor.Key.SPACE);
await expect(await editFolderDialog.getValidationMessage()).toBe('Folder name can\'t contain only spaces');
await editFolderDialog.checkCreateUpdateBtnIsDisabled();
await editFolderDialog.addFolderName(editFolder.entry.name);
await editFolderDialog.addFolderDescription('a*"<>\\/?:|');
await editFolderDialog.checkValidationMessageIsNotDisplayed();
await editFolderDialog.checkCreateUpdateBtnIsEnabled();
await editFolderDialog.addFolderDescription('a.');
await editFolderDialog.checkValidationMessageIsNotDisplayed();
await editFolderDialog.checkCreateUpdateBtnIsEnabled();
await editFolderDialog.addFolderDescription('a.a');
await editFolderDialog.checkValidationMessageIsNotDisplayed();
await editFolderDialog.checkCreateUpdateBtnIsEnabled();
await editFolderDialog.getFolderDescriptionField().sendKeys(protractor.Key.SPACE);
await editFolderDialog.checkValidationMessageIsNotDisplayed();
await editFolderDialog.checkCreateUpdateBtnIsEnabled();
await editFolderDialog.clickOnCancelButton();
await editFolderDialog.checkFolderDialogIsNotDisplayed();
});
it('[C260166] Enable/Disable edit folder icon - when file selected', async () => {
await expect(await contentServicesPage.getDocumentList().dataTablePage().getNumberOfSelectedRows()).toBe(0);
await expect(await contentServicesPage.isEditFolderButtonEnabled()).toBe(false);
await contentServicesPage.getDocumentList().dataTablePage().checkContentIsDisplayed('Display name', filePdfNode.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().selectRow('Display name', filePdfNode.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().checkRowIsSelected('Display name', filePdfNode.entry.name);
await expect(await contentServicesPage.isEditFolderButtonEnabled()).toBe(false);
});
it('[C260166] Enable/Disable edit folder icon - when multiple folders selected', async () => {
await contentServicesPage.clickMultiSelectToggle();
await contentServicesPage.getDocumentList().dataTablePage().waitTillContentLoaded();
await contentServicesPage.getDocumentList().dataTablePage().checkAllRowsButtonIsDisplayed();
await contentServicesPage.getDocumentList().dataTablePage().checkAllRows();
await contentServicesPage.getDocumentList().dataTablePage().waitTillContentLoaded();
await contentServicesPage.getDocumentList().dataTablePage().checkRowIsChecked('Display name', editFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().checkRowIsChecked('Display name', anotherFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().clickCheckbox('Display name', filePdfNode.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().checkRowIsNotChecked('Display name', filePdfNode.entry.name);
await expect(await contentServicesPage.getDocumentList().dataTablePage().getNumberOfSelectedRows()).toBe(2);
await expect(await contentServicesPage.isEditFolderButtonEnabled()).toBe(false);
});
it('[C260166] Enable/Disable edit folder icon - when single folder selected', async () => {
await expect(await contentServicesPage.getDocumentList().dataTablePage().getNumberOfSelectedRows()).toBe(0);
await contentServicesPage.getDocumentList().dataTablePage().selectRow('Display name', editFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().checkRowIsSelected('Display name', editFolder.entry.name);
await expect(await contentServicesPage.getDocumentList().dataTablePage().getNumberOfSelectedRows()).toBe(1);
await expect(await contentServicesPage.isEditFolderButtonEnabled()).toBe(true);
});
it('[C260165] Update folder name with non-existing one', async () => {
await contentServicesPage.getDocumentList().dataTablePage().checkContentIsDisplayed('Display name', editFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().selectRow('Display name', editFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().checkRowIsSelected('Display name', editFolder.entry.name);
await contentServicesPage.clickOnEditFolder();
await editFolderDialog.checkFolderDialogIsDisplayed();
await editFolderDialog.addFolderName(updateFolderName);
await editFolderDialog.checkCreateUpdateBtnIsEnabled();
await editFolderDialog.clickOnCreateUpdateButton();
await editFolderDialog.checkFolderDialogIsNotDisplayed();
await contentServicesPage.getDocumentList().dataTablePage().checkContentIsDisplayed('Display name', updateFolderName);
});
describe('Edit Folder - no permission', () => {
beforeEach(async () => {
await loginPage.login(anotherAcsUser.email, anotherAcsUser.password);
await BrowserActions.getUrl(browser.params.testConfig.adf.url + '/files/' + editFolder.entry.id);
await contentServicesPage.getDocumentList().dataTablePage().waitTillContentLoaded();
});
it('[C260167] Edit folder without permission', async () => {
await contentServicesPage.getDocumentList().dataTablePage().checkContentIsDisplayed('Display name', subFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().selectRow('Display name', subFolder.entry.name);
await contentServicesPage.getDocumentList().dataTablePage().checkRowIsSelected('Display name', subFolder.entry.name);
await expect(await contentServicesPage.isEditFolderButtonEnabled()).toBe(false);
});
});
});