[ACA-1920] automate tests for Create file from template (#1303)

* change component ancestor from ElementFinder to string for better usability
better naming for some methods
small code cleanup

* add test components and automate tests for Create File from Template action

* ignore e2e-downloads folder

* add return types

* enable check

* enable check after issue got fixed
This commit is contained in:
Adina Parpalita 2020-01-16 13:16:18 +02:00 committed by Cilibiu Bogdan
parent 0bc4a3453b
commit 569ee98e8d
61 changed files with 1262 additions and 416 deletions

1
.gitignore vendored
View File

@ -40,6 +40,7 @@ testem.log
/e2e/*.js /e2e/*.js
/e2e/*.map /e2e/*.map
/e2e-output /e2e-output
/e2e-downloads
# System Files # System Files
.DS_Store .DS_Store

View File

@ -36,7 +36,7 @@ export class Breadcrumb extends Component {
items: ElementArrayFinder = this.component.all(by.css(Breadcrumb.selectors.item)); items: ElementArrayFinder = this.component.all(by.css(Breadcrumb.selectors.item));
currentItem: ElementFinder = this.component.element(by.css(Breadcrumb.selectors.currentItem)); currentItem: ElementFinder = this.component.element(by.css(Breadcrumb.selectors.currentItem));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(Breadcrumb.selectors.root, ancestor); super(Breadcrumb.selectors.root, ancestor);
} }

View File

@ -0,0 +1,77 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2019 Alfresco Software Limited
*
* 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 <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, ElementArrayFinder, by, browser, ExpectedConditions as EC } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Component } from '../component';
export class DropDownBreadcrumb extends Component {
private static selectors = {
root: '.adf-dropdown-breadcrumb',
trigger: '.adf-dropdown-breadcrumb-trigger',
currentFolder: '.adf-current-folder',
pathOption: '.adf-dropdown-breadcrumb-path-option .mat-option-text'
};
trigger: ElementFinder = this.component.element(by.css(DropDownBreadcrumb.selectors.trigger));
pathItems: ElementArrayFinder = browser.$$(DropDownBreadcrumb.selectors.pathOption);
pathItemsContainer: ElementFinder = browser.element(by.css('.mat-select-panel'));
currentFolder: ElementFinder = this.component.element(by.css(DropDownBreadcrumb.selectors.currentFolder));
constructor(ancestor?: string) {
super(DropDownBreadcrumb.selectors.root, ancestor);
}
async waitForPathListDropdownToOpen(): Promise<void> {
await browser.wait(EC.presenceOf(this.pathItemsContainer), BROWSER_WAIT_TIMEOUT, 'Timeout waiting for breadcrumb dropdown to open');
}
async waitForPathListDropdownToClose(): Promise<void> {
await browser.wait(EC.stalenessOf(browser.$(DropDownBreadcrumb.selectors.pathOption)), BROWSER_WAIT_TIMEOUT, 'Timeout waiting for breadcrumb dropdown to close');
}
async getCurrentFolderName(): Promise<string> {
return this.currentFolder.getText();
}
async openPath(): Promise<void> {
await this.trigger.click();
await this.waitForPathListDropdownToOpen();
}
async clickPathItem(name: string): Promise<void> {
const elem = browser.element(by.cssContainingText(DropDownBreadcrumb.selectors.pathOption, name));
await elem.click();
}
async getPathItems(): Promise<string[]> {
const items: string[] = await this.pathItems.map(async elem => {
return elem.getText();
});
return items;
}
}

View File

@ -29,11 +29,11 @@ import { BROWSER_WAIT_TIMEOUT } from '../configs';
export abstract class Component { export abstract class Component {
component: ElementFinder; component: ElementFinder;
constructor(selector: string, ancestor?: ElementFinder) { constructor(selector: string, ancestor?: string) {
const locator = selector; const locator = selector;
this.component = ancestor this.component = ancestor
? ancestor.$$(locator).first() ? browser.$$(ancestor).first().$$(locator).first()
: browser.$$(locator).first(); : browser.$$(locator).first();
} }

View File

@ -57,7 +57,6 @@ export class DataTable extends Component {
emptyListTitle: '.adf-empty-content__title', emptyListTitle: '.adf-empty-content__title',
emptyListSubtitle: '.adf-empty-content__subtitle', emptyListSubtitle: '.adf-empty-content__subtitle',
emptyListText: '.adf-empty-content__text',
emptySearchText: '.empty-search__text', emptySearchText: '.empty-search__text',
@ -73,55 +72,55 @@ export class DataTable extends Component {
emptyFolderDragAndDrop: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyFolderDragAndDrop)); emptyFolderDragAndDrop: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyFolderDragAndDrop));
emptyListTitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListTitle)); emptyListTitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListTitle));
emptyListSubtitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListSubtitle)); emptyListSubtitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListSubtitle));
emptyListText: ElementArrayFinder = this.component.all(by.css(DataTable.selectors.emptyListText)); emptyListContainerText: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListContainer));
emptySearchText: ElementFinder = this.component.element(by.css(DataTable.selectors.emptySearchText)); emptySearchText: ElementFinder = this.component.element(by.css(DataTable.selectors.emptySearchText));
menu: Menu = new Menu(); menu: Menu = new Menu();
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(DataTable.selectors.root, ancestor); super(DataTable.selectors.root, ancestor);
} }
// Wait methods (waits for elements) // Wait methods (waits for elements)
async waitForHeader() { async waitForHeader(): Promise<void> {
await browser.wait(EC.presenceOf(this.head), BROWSER_WAIT_TIMEOUT, '--- timeout waitForHeader ---'); await browser.wait(EC.presenceOf(this.head), BROWSER_WAIT_TIMEOUT, '--- timeout waitForHeader ---');
} }
async waitForBody() { async waitForBody(): Promise<void> {
await browser.wait(EC.presenceOf(this.body), BROWSER_WAIT_TIMEOUT, '--- timeout waitForBody ---'); await browser.wait(EC.presenceOf(this.body), BROWSER_WAIT_TIMEOUT, '--- timeout waitForBody ---');
} }
async waitForEmptyState() { async waitForEmptyState(): Promise<void> {
await browser.wait(EC.presenceOf(this.emptyList), BROWSER_WAIT_TIMEOUT); await browser.wait(EC.presenceOf(this.emptyList), BROWSER_WAIT_TIMEOUT);
} }
// Header/Column methods // Header/Column methods
getColumnHeaders() { getColumnHeaders(): ElementArrayFinder {
const locator = by.css(DataTable.selectors.columnHeader); const locator = by.css(DataTable.selectors.columnHeader);
return this.head.all(locator); return this.head.all(locator);
} }
async getColumnHeadersText() { async getColumnHeadersText(): Promise<string> {
const el = this.getColumnHeaders(); const el = this.getColumnHeaders();
return el.getText(); return el.getText();
} }
getNthColumnHeader(nth: number) { getNthColumnHeader(nth: number): ElementFinder {
return this.getColumnHeaders().get(nth - 1); return this.getColumnHeaders().get(nth - 1);
} }
getColumnHeaderByLabel(label: string) { getColumnHeaderByLabel(label: string): ElementFinder {
const locator = by.cssContainingText(DataTable.selectors.columnHeader, label); const locator = by.cssContainingText(DataTable.selectors.columnHeader, label);
return this.head.element(locator); return this.head.element(locator);
} }
getSortedColumnHeader() { getSortedColumnHeader(): ElementFinder {
const locator = by.css(DataTable.selectors.sortedColumnHeader); const locator = by.css(DataTable.selectors.sortedColumnHeader);
return this.head.element(locator); return this.head.element(locator);
} }
async getSortedColumnHeaderText() { async getSortedColumnHeaderText(): Promise<string> {
return this.getSortedColumnHeader().getText(); return this.getSortedColumnHeader().getText();
} }
@ -138,7 +137,7 @@ export class DataTable extends Component {
return 'none'; return 'none';
} }
async sortByColumn(columnName: string) { async sortByColumn(columnName: string): Promise<void> {
const column = this.getColumnHeaderByLabel(columnName); const column = this.getColumnHeaderByLabel(columnName);
const click = browser.actions().mouseMove(column).click(); const click = browser.actions().mouseMove(column).click();
@ -146,27 +145,38 @@ export class DataTable extends Component {
} }
// Rows methods // Rows methods
getRows() { getRows(): ElementArrayFinder {
return this.body.all(by.css(DataTable.selectors.row)); return this.body.all(by.css(DataTable.selectors.row));
} }
async countRows() { async getRowsCount(): Promise<number> {
return this.getRows().count(); return this.getRows().count();
} }
getSelectedRows() { async waitForRowToBeSelected(): Promise<void> {
await browser.wait(EC.presenceOf(this.component.element(by.css(DataTable.selectors.selectedRow))), BROWSER_WAIT_TIMEOUT, 'timeout waiting for row to be selected');
}
getSelectedRows(): ElementArrayFinder {
return this.body.all(by.css(DataTable.selectors.selectedRow)); return this.body.all(by.css(DataTable.selectors.selectedRow));
} }
async countSelectedRows() { async getSelectedRowsNames(): Promise<string[]> {
const rowsText: string[] = await this.getSelectedRows().map((row) => {
return row.element(by.css('.adf-datatable-cell[title="Name"]')).getText();
});
return rowsText;
}
async getSelectedRowsCount(): Promise<number> {
return this.getSelectedRows().count(); return this.getSelectedRows().count();
} }
getNthRow(nth: number) { getNthRow(nth: number): ElementFinder {
return this.getRows().get(nth - 1); return this.getRows().get(nth - 1);
} }
getRowByName(name: string, location: string = '') { getRowByName(name: string, location: string = ''): ElementFinder {
if (location) { if (location) {
return this.body.all(by.cssContainingText(DataTable.selectors.row, name)) return this.body.all(by.cssContainingText(DataTable.selectors.row, name))
.filter(async (elem) => await browser.isElementPresent(elem.element(by.cssContainingText(DataTable.selectors.cell, location)))) .filter(async (elem) => await browser.isElementPresent(elem.element(by.cssContainingText(DataTable.selectors.cell, location))))
@ -175,46 +185,46 @@ export class DataTable extends Component {
return this.body.element(by.cssContainingText(DataTable.selectors.row, name)); return this.body.element(by.cssContainingText(DataTable.selectors.row, name));
} }
getRowCells(name: string, location: string = '') { getRowCells(name: string, location: string = ''): ElementArrayFinder {
return this.getRowByName(name, location).all(by.css(DataTable.selectors.cell)); return this.getRowByName(name, location).all(by.css(DataTable.selectors.cell));
} }
async getRowCellsCount(itemName: string) { async getRowCellsCount(itemName: string): Promise<number> {
return this.getRowCells(itemName).count(); return this.getRowCells(itemName).count();
} }
getRowFirstCell(name: string, location: string = '') { getRowFirstCell(name: string, location: string = ''): ElementFinder {
return this.getRowCells(name, location).get(0); return this.getRowCells(name, location).get(0);
} }
getRowNameCell(name: string, location: string = '') { getRowNameCell(name: string, location: string = ''): ElementFinder {
return this.getRowCells(name, location).get(1); return this.getRowCells(name, location).get(1);
} }
getRowNameCellSpan(name: string, location: string = '') { getRowNameCellSpan(name: string, location: string = ''): ElementFinder {
return this.getRowNameCell(name, location).$('span'); return this.getRowNameCell(name, location).$('span');
} }
async getItemNameTooltip(name: string, location: string = '') { async getItemNameTooltip(name: string, location: string = ''): Promise<string> {
return this.getRowNameCellSpan(name, location).getAttribute('title'); return this.getRowNameCellSpan(name, location).getAttribute('title');
} }
async hasCheckMarkIcon(itemName: string, location: string = '') { async hasCheckMarkIcon(itemName: string, location: string = ''): Promise<boolean> {
const row = this.getRowByName(itemName, location); const row: ElementFinder = this.getRowByName(itemName, location);
return row.element(by.css(DataTable.selectors.selectedIcon)).isPresent(); return row.element(by.css(DataTable.selectors.selectedIcon)).isPresent();
} }
async hasLockIcon(itemName: string, location: string = '') { async hasLockIcon(itemName: string, location: string = ''): Promise<boolean> {
const row = this.getRowByName(itemName, location); const row: ElementFinder = this.getRowByName(itemName, location);
return row.element(by.css(DataTable.selectors.lockIcon)).isPresent(); return row.element(by.css(DataTable.selectors.lockIcon)).isPresent();
} }
async hasLockOwnerInfo(itemName: string, location: string = '') { async hasLockOwnerInfo(itemName: string, location: string = ''): Promise<boolean> {
const row = this.getRowByName(itemName, location); const row: ElementFinder = this.getRowByName(itemName, location);
return row.element(by.css(DataTable.selectors.lockOwner)).isPresent(); return row.element(by.css(DataTable.selectors.lockOwner)).isPresent();
} }
async getLockOwner(itemName: string, location: string = '') { async getLockOwner(itemName: string, location: string = ''): Promise<string> {
if (await this.hasLockOwnerInfo(itemName, location)) { if (await this.hasLockOwnerInfo(itemName, location)) {
const row = this.getRowByName(itemName, location); const row = this.getRowByName(itemName, location);
return row.$(DataTable.selectors.lockOwner).$('.locked_by--name').getText(); return row.$(DataTable.selectors.lockOwner).$('.locked_by--name').getText();
@ -222,16 +232,16 @@ export class DataTable extends Component {
return ''; return '';
} }
getNameLink(itemName: string) { getNameLink(itemName: string): ElementFinder {
return this.getRowNameCell(itemName).$(DataTable.selectors.nameLink); return this.getRowNameCell(itemName).$(DataTable.selectors.nameLink);
} }
async hasLinkOnName(itemName: string) { async hasLinkOnName(itemName: string): Promise<boolean> {
return this.getNameLink(itemName).isPresent(); return this.getNameLink(itemName).isPresent();
} }
// Navigation/selection methods // Navigation/selection methods
async doubleClickOnRowByName(name: string, location: string = '') { async doubleClickOnRowByName(name: string, location: string = ''): Promise<void> {
try { try {
const item = this.getRowFirstCell(name, location); const item = this.getRowFirstCell(name, location);
await Utils.waitUntilElementClickable(item); await Utils.waitUntilElementClickable(item);
@ -242,7 +252,7 @@ export class DataTable extends Component {
} }
} }
async selectItem(name: string, location: string = '') { async selectItem(name: string, location: string = ''): Promise<void> {
const isSelected = await this.hasCheckMarkIcon(name, location); const isSelected = await this.hasCheckMarkIcon(name, location);
if (!isSelected) { if (!isSelected) {
try { try {
@ -253,19 +263,18 @@ export class DataTable extends Component {
console.log('--- select item catch : ', e); console.log('--- select item catch : ', e);
} }
} }
} }
async clickItem(name: string, location: string = '') { async clickItem(name: string, location: string = ''): Promise<void> {
const item = this.getRowFirstCell(name, location); const item = this.getRowFirstCell(name, location);
await item.click(); await item.click();
} }
async clickNameLink(itemName: string) { async clickNameLink(itemName: string): Promise<void> {
await this.getNameLink(itemName).click(); await this.getNameLink(itemName).click();
} }
async selectMultipleItems(names: string[], location: string = '') { async selectMultipleItems(names: string[], location: string = ''): Promise<void> {
await this.clearSelection(); await this.clearSelection();
await browser.actions().sendKeys(protractor.Key.COMMAND).perform(); await browser.actions().sendKeys(protractor.Key.COMMAND).perform();
for (const name of names) { for (const name of names) {
@ -274,9 +283,9 @@ export class DataTable extends Component {
await browser.actions().sendKeys(protractor.Key.NULL).perform(); await browser.actions().sendKeys(protractor.Key.NULL).perform();
} }
async clearSelection() { async clearSelection(): Promise<void> {
try { try {
const count = await this.countSelectedRows(); const count = await this.getSelectedRowsCount();
if (count !== 0) { if (count !== 0) {
await browser.refresh(); await browser.refresh();
await this.wait(); await this.wait();
@ -286,27 +295,27 @@ export class DataTable extends Component {
} }
} }
async rightClickOnItem(itemName: string) { async rightClickOnItem(itemName: string): Promise<void> {
const item = this.getRowFirstCell(itemName); const item = this.getRowFirstCell(itemName);
await browser.actions().mouseMove(item).perform(); await browser.actions().mouseMove(item).perform();
await browser.actions().click(protractor.Button.RIGHT).perform(); await browser.actions().click(protractor.Button.RIGHT).perform();
} }
async rightClickOnMultipleSelection() { async rightClickOnMultipleSelection(): Promise<void> {
const itemFromSelection = this.getSelectedRows().get(0); const itemFromSelection = this.getSelectedRows().get(0);
await browser.actions().mouseMove(itemFromSelection).perform(); await browser.actions().mouseMove(itemFromSelection).perform();
await browser.actions().click(protractor.Button.RIGHT).perform(); await browser.actions().click(protractor.Button.RIGHT).perform();
} }
getItemLocationEl(name: string) { getItemLocationEl(name: string): ElementFinder {
return this.getRowByName(name).element(by.css(DataTable.selectors.locationLink)); return this.getRowByName(name).element(by.css(DataTable.selectors.locationLink));
} }
async getItemLocation(name: string) { async getItemLocation(name: string): Promise<string> {
return this.getItemLocationEl(name).getText(); return this.getItemLocationEl(name).getText();
} }
async getItemLocationTooltip(name: string) { async getItemLocationTooltip(name: string): Promise<string> {
const location = this.getItemLocationEl(name).$('a'); const location = this.getItemLocationEl(name).$('a');
const condition = () => location.getAttribute('title').then(value => value && value.length > 0); const condition = () => location.getAttribute('title').then(value => value && value.length > 0);
@ -316,16 +325,16 @@ export class DataTable extends Component {
return location.getAttribute('title'); return location.getAttribute('title');
} }
async clickItemLocation(name: string) { async clickItemLocation(name: string): Promise<void> {
await this.getItemLocationEl(name).click(); await this.getItemLocationEl(name).click();
} }
// empty state methods // empty state methods
async isEmptyList() { async isEmpty(): Promise<boolean> {
return this.emptyList.isPresent(); return this.emptyList.isPresent();
} }
async isEmptyWithDragAndDrop() { async isEmptyWithDragAndDrop(): Promise<boolean> {
return this.emptyFolderDragAndDrop.isDisplayed(); return this.emptyFolderDragAndDrop.isDisplayed();
} }
@ -334,66 +343,68 @@ export class DataTable extends Component {
if (isEmpty) { if (isEmpty) {
return this.emptyFolderDragAndDrop.getText(); return this.emptyFolderDragAndDrop.getText();
} }
return ''; return '';
} }
async getEmptyStateTitle(): Promise<string> { async getEmptyStateTitle(): Promise<string> {
const isEmpty = await this.isEmptyList(); const isEmpty = await this.isEmpty();
if (isEmpty) { if (isEmpty) {
return this.emptyListTitle.getText(); return this.emptyListTitle.getText();
} }
return ''; return '';
} }
async getEmptyStateSubtitle(): Promise<string> { async getEmptyStateSubtitle(): Promise<string> {
const isEmpty = await this.isEmptyList(); const isEmpty = await this.isEmpty();
if (isEmpty) { if (isEmpty) {
return this.emptyListSubtitle.getText(); return this.emptyListSubtitle.getText();
} }
return ''; return '';
} }
async getEmptyStateText(): Promise<string> { async getEmptyListText(): Promise<string> {
const isEmpty = await this.isEmptyList(); const isEmpty = await this.isEmpty();
if (isEmpty) { if (isEmpty) {
return this.emptyListText.getText(); return this.component.element(by.css('adf-custom-empty-content-template')).getText();
} }
return ''; return '';
} }
async getEmptySearchResultsText() { async getEmptySearchResultsText(): Promise<string> {
return this.emptySearchText.getText(); return this.emptySearchText.getText();
} }
async getCellsContainingName(name: string) { async getCellsContainingName(name: string): Promise<string[]> {
const rows = this.getRows().all(by.cssContainingText(DataTable.selectors.cell, name)); const rows: ElementArrayFinder = this.getRows().all(by.cssContainingText(DataTable.selectors.cell, name));
return rows.map(async cell => await cell.getText()); const cellsText: string[] = await rows.map(async cell => {
return cell.getText();
});
return cellsText;
} }
async hasContextMenu() { async hasContextMenu(): Promise<boolean> {
const count = await this.menu.getItemsCount(); const count = await this.menu.getItemsCount();
return count > 0; return count > 0;
} }
async getLibraryRole(name: string) { async getLibraryRole(name: string): Promise<string> {
return this.getRowByName(name).element(by.css(DataTable.selectors.libraryRole)).getText(); return this.getRowByName(name).element(by.css(DataTable.selectors.libraryRole)).getText();
} }
async isItemPresent(name: string, location? : string) { async isItemPresent(name: string, location? : string): Promise<boolean> {
return this.getRowByName(name, location).isPresent(); return this.getRowByName(name, location).isPresent();
} }
async getEntireDataTableText() { async getEntireDataTableText(): Promise<string[]> {
return this.getRows().map((row) => { const text: string[] = await this.getRows().map((row) => {
return row.all(by.css(DataTable.selectors.cell)).map(async cell => await cell.getText()); return row.all(by.css(DataTable.selectors.cell)).map(async cell => {
return cell.getText();
});
}); });
return text;
} }
async getSitesNameAndVisibility() { async getSitesNameAndVisibility(): Promise<{}> {
const data = await this.getEntireDataTableText(); const data = await this.getEntireDataTableText();
return data.reduce((acc, cell) => { return data.reduce((acc, cell) => {
acc[cell[1]] = cell[3].toUpperCase(); acc[cell[1]] = cell[3].toUpperCase();
@ -401,7 +412,7 @@ export class DataTable extends Component {
}, {}); }, {});
} }
async getSitesNameAndRole() { async getSitesNameAndRole(): Promise<{}> {
const data = await this.getEntireDataTableText(); const data = await this.getEntireDataTableText();
return data.reduce((acc, cell) => { return data.reduce((acc, cell) => {
acc[cell[1]] = cell[2]; acc[cell[1]] = cell[2];
@ -417,7 +428,7 @@ export class DataTable extends Component {
return this.getSearchResultsRows().get(nth - 1); return this.getSearchResultsRows().get(nth - 1);
} }
getSearchResultsRowByName(name: string, location: string = '') { getSearchResultsRowByName(name: string, location: string = ''): ElementFinder {
if (location) { if (location) {
return this.body.all(by.cssContainingText(DataTable.selectors.searchResultsRow, name)) return this.body.all(by.cssContainingText(DataTable.selectors.searchResultsRow, name))
.filter(async (elem) => await browser.isElementPresent(elem.element(by.cssContainingText(DataTable.selectors.searchResultsRowLine, location)))) .filter(async (elem) => await browser.isElementPresent(elem.element(by.cssContainingText(DataTable.selectors.searchResultsRowLine, location))))
@ -426,43 +437,43 @@ export class DataTable extends Component {
return this.body.element(by.cssContainingText(DataTable.selectors.searchResultsRow, name)); return this.body.element(by.cssContainingText(DataTable.selectors.searchResultsRow, name));
} }
getSearchResultRowLines(name: string, location: string = '') { getSearchResultRowLines(name: string, location: string = ''): ElementArrayFinder {
return this.getSearchResultsRowByName(name, location).all(by.css(DataTable.selectors.searchResultsRowLine)); return this.getSearchResultsRowByName(name, location).all(by.css(DataTable.selectors.searchResultsRowLine));
} }
async getSearchResultLinesCount(name: string, location: string = '') { async getSearchResultLinesCount(name: string, location: string = ''): Promise<number> {
return this.getSearchResultRowLines(name, location).count(); return this.getSearchResultRowLines(name, location).count();
} }
getSearchResultNthLine(name: string, location: string = '', index: number) { getSearchResultNthLine(name: string, location: string = '', index: number): ElementFinder {
return this.getSearchResultRowLines(name, location).get(index); return this.getSearchResultRowLines(name, location).get(index);
} }
async getSearchResultNameAndTitle(name: string, location: string = '') { async getSearchResultNameAndTitle(name: string, location: string = ''): Promise<string> {
return this.getSearchResultNthLine(name, location, 0).getText(); return this.getSearchResultNthLine(name, location, 0).getText();
} }
async getSearchResultDescription(name: string, location: string = '') { async getSearchResultDescription(name: string, location: string = ''): Promise<string> {
return this.getSearchResultNthLine(name, location, 1).getText(); return this.getSearchResultNthLine(name, location, 1).getText();
} }
async getSearchResultModified(name: string, location: string = '') { async getSearchResultModified(name: string, location: string = ''): Promise<string> {
return this.getSearchResultNthLine(name, location, 2).getText(); return this.getSearchResultNthLine(name, location, 2).getText();
} }
async getSearchResultLocation(name: string, location: string = '') { async getSearchResultLocation(name: string, location: string = ''): Promise<string> {
return this.getSearchResultNthLine(name, location, 3).getText(); return this.getSearchResultNthLine(name, location, 3).getText();
} }
getSearchResultNameLink(itemName: string, location: string = '') { getSearchResultNameLink(itemName: string, location: string = ''): ElementFinder {
return this.getSearchResultsRowByName(itemName, location).$(DataTable.selectors.searchResultsNameLink); return this.getSearchResultsRowByName(itemName, location).$(DataTable.selectors.searchResultsNameLink);
} }
async hasLinkOnSearchResultName(itemName: string, location: string = '') { async hasLinkOnSearchResultName(itemName: string, location: string = ''): Promise<boolean> {
return this.getSearchResultNameLink(itemName, location).isPresent(); return this.getSearchResultNameLink(itemName, location).isPresent();
} }
async clickSearchResultNameLink(itemName: string, location: string = '') { async clickSearchResultNameLink(itemName: string, location: string = ''): Promise<void> {
await this.getSearchResultNameLink(itemName, location).click(); await this.getSearchResultNameLink(itemName, location).click();
} }

View File

@ -48,7 +48,7 @@ export class DateTimePicker extends Component {
headerYear: ElementFinder = this.component.element(by.css(DateTimePicker.selectors.year)); headerYear: ElementFinder = this.component.element(by.css(DateTimePicker.selectors.year));
dayPicker: ElementFinder = this.component.element(by.css(DateTimePicker.selectors.dayPicker)); dayPicker: ElementFinder = this.component.element(by.css(DateTimePicker.selectors.dayPicker));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(DateTimePicker.selectors.root, ancestor); super(DateTimePicker.selectors.root, ancestor);
} }

View File

@ -44,7 +44,7 @@ export class ConfirmDialog extends Component {
cancelButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.cancel)); cancelButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.cancel));
actionButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.actionButton)); actionButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.actionButton));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(ConfirmDialog.selectors.root, ancestor); super(ConfirmDialog.selectors.root, ancestor);
} }

View File

@ -33,31 +33,26 @@ export class CopyMoveDialog extends Component {
root: '.adf-content-node-selector-dialog', root: '.adf-content-node-selector-dialog',
title: '.mat-dialog-title', title: '.mat-dialog-title',
content: '.mat-dialog-content',
locationDropDown: 'site-dropdown-container', locationDropDown: 'site-dropdown-container',
locationOption: '.mat-option .mat-option-text', locationOption: '.mat-option .mat-option-text',
dataTable: '.adf-datatable-body', dataTable: '.adf-datatable-body',
row: '.adf-datatable-row[role]',
selectedRow: '.adf-is-selected', selectedRow: '.adf-is-selected',
button: '.mat-dialog-actions button' button: '.mat-dialog-actions button'
}; };
title: ElementFinder = this.component.element(by.css(CopyMoveDialog.selectors.title)); title: ElementFinder = this.component.element(by.css(CopyMoveDialog.selectors.title));
content: ElementFinder = this.component.element(by.css(CopyMoveDialog.selectors.content));
dataTable: ElementFinder = this.component.element(by.css(CopyMoveDialog.selectors.dataTable)); dataTable: ElementFinder = this.component.element(by.css(CopyMoveDialog.selectors.dataTable));
locationDropDown: ElementFinder = this.component.element(by.id(CopyMoveDialog.selectors.locationDropDown)); locationDropDown: ElementFinder = this.component.element(by.id(CopyMoveDialog.selectors.locationDropDown));
locationPersonalFiles: ElementFinder = browser.element(by.cssContainingText(CopyMoveDialog.selectors.locationOption, 'Personal Files')); locationPersonalFiles: ElementFinder = browser.element(by.cssContainingText(CopyMoveDialog.selectors.locationOption, 'Personal Files'));
locationFileLibraries: ElementFinder = browser.element(by.cssContainingText(CopyMoveDialog.selectors.locationOption, 'File Libraries')); locationFileLibraries: ElementFinder = browser.element(by.cssContainingText(CopyMoveDialog.selectors.locationOption, 'File Libraries'));
row: ElementFinder = this.component.element(by.css(CopyMoveDialog.selectors.row));
cancelButton: ElementFinder = this.component.element(by.cssContainingText(CopyMoveDialog.selectors.button, 'Cancel')); cancelButton: ElementFinder = this.component.element(by.cssContainingText(CopyMoveDialog.selectors.button, 'Cancel'));
copyButton: ElementFinder = this.component.element(by.cssContainingText(CopyMoveDialog.selectors.button, 'Copy')); copyButton: ElementFinder = this.component.element(by.cssContainingText(CopyMoveDialog.selectors.button, 'Copy'));
moveButton: ElementFinder = this.component.element(by.cssContainingText(CopyMoveDialog.selectors.button, 'Move')); moveButton: ElementFinder = this.component.element(by.cssContainingText(CopyMoveDialog.selectors.button, 'Move'));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(CopyMoveDialog.selectors.root, ancestor); super(CopyMoveDialog.selectors.root, ancestor);
} }

View File

@ -47,7 +47,7 @@ export class CreateOrEditFolderDialog extends Component {
updateButton: ElementFinder = this.component.element(by.cssContainingText(CreateOrEditFolderDialog.selectors.button, 'Update')); updateButton: ElementFinder = this.component.element(by.cssContainingText(CreateOrEditFolderDialog.selectors.button, 'Update'));
validationMessage: ElementFinder = this.component.element(by.css(CreateOrEditFolderDialog.selectors.validationMessage)); validationMessage: ElementFinder = this.component.element(by.css(CreateOrEditFolderDialog.selectors.validationMessage));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(CreateOrEditFolderDialog.selectors.root, ancestor); super(CreateOrEditFolderDialog.selectors.root, ancestor);
} }
@ -68,8 +68,8 @@ export class CreateOrEditFolderDialog extends Component {
return this.title.getText(); return this.title.getText();
} }
async isValidationMessageDisplayed() { async isValidationMessageDisplayed(): Promise<boolean> {
return this.validationMessage.isDisplayed(); return (await this.validationMessage.isPresent()) && (await this.validationMessage.isDisplayed());
} }
async isUpdateButtonEnabled() { async isUpdateButtonEnabled() {
@ -92,9 +92,12 @@ export class CreateOrEditFolderDialog extends Component {
return this.descriptionTextArea.isDisplayed(); return this.descriptionTextArea.isDisplayed();
} }
async getValidationMessage() { async getValidationMessage(): Promise<string> {
await this.isValidationMessageDisplayed(); if (await this.isValidationMessageDisplayed()) {
return this.validationMessage.getText(); return this.validationMessage.getText();
} else {
return '';
}
} }
async getName() { async getName() {

View File

@ -0,0 +1,140 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2019 Alfresco Software Limited
*
* 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 <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, protractor, ExpectedConditions as EC } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Component } from '../component';
export class CreateFromTemplateDialog extends Component {
private static selectors = {
root: '.aca-file-from-template-dialog',
title: '.mat-dialog-title',
nameInput: 'input[placeholder="Name" i]',
titleInput: 'input[placeholder="Title" i]',
descriptionTextArea: 'textarea[placeholder="Description" i]',
button: '.mat-dialog-actions button',
validationMessage: '.mat-error'
};
title: ElementFinder = this.component.element(by.css(CreateFromTemplateDialog.selectors.title));
nameInput: ElementFinder = this.component.element(by.css(CreateFromTemplateDialog.selectors.nameInput));
titleInput: ElementFinder = this.component.element(by.css(CreateFromTemplateDialog.selectors.titleInput));
descriptionTextArea: ElementFinder = this.component.element(by.css(CreateFromTemplateDialog.selectors.descriptionTextArea));
createButton: ElementFinder = this.component.element(by.cssContainingText(CreateFromTemplateDialog.selectors.button, 'Create'));
cancelButton: ElementFinder = this.component.element(by.cssContainingText(CreateFromTemplateDialog.selectors.button, 'CANCEL'));
validationMessage: ElementFinder = this.component.element(by.css(CreateFromTemplateDialog.selectors.validationMessage));
constructor(ancestor?: string) {
super(CreateFromTemplateDialog.selectors.root, ancestor);
}
async waitForDialogToOpen(): Promise<void> {
await browser.wait(EC.presenceOf(this.title), BROWSER_WAIT_TIMEOUT, 'timeout waiting for dialog title');
await browser.wait(EC.presenceOf(browser.element(by.css('.cdk-overlay-backdrop'))), BROWSER_WAIT_TIMEOUT, 'timeout waiting for overlay backdrop');
}
async waitForDialogToClose(): Promise<void> {
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT, '---- timeout waiting for dialog to close ----');
}
async isDialogOpen(): Promise<boolean> {
return browser.isElementPresent(by.css(CreateFromTemplateDialog.selectors.root));
}
async getTitle(): Promise<string> {
return this.title.getText();
}
async isValidationMessageDisplayed(): Promise<boolean> {
return (await this.validationMessage.isPresent()) && (await this.validationMessage.isDisplayed());
}
async isCreateButtonEnabled(): Promise<boolean> {
return this.createButton.isEnabled();
}
async isCancelButtonEnabled(): Promise<boolean> {
return this.cancelButton.isEnabled();
}
async isNameFieldDisplayed(): Promise<boolean> {
return this.nameInput.isDisplayed();
}
async isTitleFieldDisplayed(): Promise<boolean> {
return this.titleInput.isDisplayed();
}
async isDescriptionFieldDisplayed(): Promise<boolean> {
return this.descriptionTextArea.isDisplayed();
}
async getValidationMessage(): Promise<string> {
if (await this.isValidationMessageDisplayed()) {
return this.validationMessage.getText();
} else {
return '';
}
}
async getName(): Promise<string> {
return this.nameInput.getAttribute('value');
}
async getDescription(): Promise<string> {
return this.descriptionTextArea.getAttribute('value');
}
async enterName(name: string): Promise<void> {
await this.nameInput.clear();
await this.nameInput.sendKeys(name);
}
async enterTitle(title: string): Promise<void> {
await this.titleInput.clear();
await this.titleInput.sendKeys(title);
}
async enterDescription(description: string): Promise<void> {
await this.descriptionTextArea.clear();
await this.descriptionTextArea.sendKeys(description);
}
async deleteNameWithBackspace(): Promise<void> {
await this.nameInput.clear();
await this.nameInput.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE);
}
async clickCreate(): Promise<void> {
await this.createButton.click();
}
async clickCancel(): Promise<void> {
await this.cancelButton.click();
await this.waitForDialogToClose();
}
}

View File

@ -53,7 +53,7 @@ export class CreateLibraryDialog extends Component {
cancelButton: ElementFinder = this.component.element(by.cssContainingText(CreateLibraryDialog.selectors.button, 'Cancel')); cancelButton: ElementFinder = this.component.element(by.cssContainingText(CreateLibraryDialog.selectors.button, 'Cancel'));
errorMessage: ElementFinder = this.component.element(by.css(CreateLibraryDialog.selectors.errorMessage)); errorMessage: ElementFinder = this.component.element(by.css(CreateLibraryDialog.selectors.errorMessage));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(CreateLibraryDialog.selectors.root, ancestor); super(CreateLibraryDialog.selectors.root, ancestor);
} }

View File

@ -40,7 +40,7 @@ export class ManageVersionsDialog extends Component {
content: ElementFinder = this.component.element(by.css(ManageVersionsDialog.selectors.content)); content: ElementFinder = this.component.element(by.css(ManageVersionsDialog.selectors.content));
closeButton: ElementFinder = this.component.element(by.cssContainingText(ManageVersionsDialog.selectors.button, 'Close')); closeButton: ElementFinder = this.component.element(by.cssContainingText(ManageVersionsDialog.selectors.button, 'Close'));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(ManageVersionsDialog.selectors.root, ancestor); super(ManageVersionsDialog.selectors.root, ancestor);
} }

View File

@ -45,7 +45,7 @@ export class PasswordDialog extends Component {
closeButton: ElementFinder = this.component.element(by.buttonText('Close')); closeButton: ElementFinder = this.component.element(by.buttonText('Close'));
submitButton: ElementFinder = this.component.element(by.buttonText('Submit')); submitButton: ElementFinder = this.component.element(by.buttonText('Submit'));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(PasswordDialog.selectors.root, ancestor); super(PasswordDialog.selectors.root, ancestor);
} }

View File

@ -0,0 +1,86 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2019 Alfresco Software Limited
*
* 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 <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, ExpectedConditions as EC } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Component } from '../component';
import { DropDownBreadcrumb } from '../breadcrumb/dropdown-breadcrumb';
import { DataTable } from '../data-table/data-table';
export class SelectTemplateDialog extends Component {
private static selectors = {
root: '.aca-template-node-selector-dialog',
title: '.mat-dialog-title',
button: '.mat-dialog-actions button'
};
title: ElementFinder = this.component.element(by.css(SelectTemplateDialog.selectors.title));
nextButton: ElementFinder = this.component.element(by.cssContainingText(SelectTemplateDialog.selectors.button, 'Next'));
cancelButton: ElementFinder = this.component.element(by.cssContainingText(SelectTemplateDialog.selectors.button, 'Cancel'));
breadcrumb: DropDownBreadcrumb = new DropDownBreadcrumb();
dataTable: DataTable = new DataTable(SelectTemplateDialog.selectors.root);
constructor(ancestor?: string) {
super(SelectTemplateDialog.selectors.root, ancestor);
}
async waitForDialogToOpen(): Promise<void> {
await browser.wait(EC.presenceOf(this.title), BROWSER_WAIT_TIMEOUT, 'timeout waiting for dialog title');
await browser.wait(EC.presenceOf(browser.element(by.css('.cdk-overlay-backdrop'))), BROWSER_WAIT_TIMEOUT, 'timeout waiting for overlay backdrop');
}
async waitForDialogToClose(): Promise<void> {
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT, '---- timeout waiting for dialog to close ----');
}
async isDialogOpen(): Promise<boolean> {
return browser.isElementPresent(by.css(SelectTemplateDialog.selectors.root));
}
async getTitle(): Promise<string> {
return this.title.getText();
}
// action buttons
async isCancelButtonEnabled(): Promise<boolean> {
return this.cancelButton.isEnabled();
}
async isNextButtonEnabled(): Promise<boolean> {
return this.nextButton.isEnabled();
}
async clickCancel(): Promise<void> {
await this.cancelButton.click();
await this.waitForDialogToClose();
}
async clickNext(): Promise<void> {
await this.nextButton.click();
await this.waitForDialogToClose();
}
}

View File

@ -58,7 +58,7 @@ export class ShareDialog extends Component {
closeButton: ElementFinder = this.component.element(by.css(ShareDialog.selectors.button)); closeButton: ElementFinder = this.component.element(by.css(ShareDialog.selectors.button));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(ShareDialog.selectors.root, ancestor); super(ShareDialog.selectors.root, ancestor);
} }

View File

@ -51,7 +51,7 @@ export class UploadNewVersionDialog extends Component {
description: ElementFinder = this.component.element(by.css(UploadNewVersionDialog.selectors.descriptionTextArea)); description: ElementFinder = this.component.element(by.css(UploadNewVersionDialog.selectors.descriptionTextArea));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(UploadNewVersionDialog.selectors.root, ancestor); super(UploadNewVersionDialog.selectors.root, ancestor);
} }

View File

@ -47,12 +47,12 @@ export class Header extends Component {
moreActions: ElementFinder = browser.element(Header.selectors.moreActions); moreActions: ElementFinder = browser.element(Header.selectors.moreActions);
sidenavToggle: ElementFinder = this.component.element(by.css(Header.selectors.sidenavToggle)); sidenavToggle: ElementFinder = this.component.element(by.css(Header.selectors.sidenavToggle));
userInfo: UserInfo = new UserInfo(this.component); userInfo: UserInfo = new UserInfo();
menu: Menu = new Menu(); menu: Menu = new Menu();
toolbar: Toolbar = new Toolbar(); toolbar: Toolbar = new Toolbar();
searchInput: SearchInput = new SearchInput(); searchInput: SearchInput = new SearchInput();
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super('adf-layout-header', ancestor); super('adf-layout-header', ancestor);
} }

View File

@ -39,7 +39,7 @@ export class UserInfo extends Component {
menu: Menu = new Menu(); menu: Menu = new Menu();
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super('aca-current-user', ancestor); super('aca-current-user', ancestor);
} }

View File

@ -58,7 +58,7 @@ export class CommentsTab extends Component {
commentTime = by.id(CommentsTab.selectors.commentTime); commentTime = by.id(CommentsTab.selectors.commentTime);
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(CommentsTab.selectors.root, ancestor); super(CommentsTab.selectors.root, ancestor);
} }

View File

@ -53,7 +53,7 @@ export class ContentMetadata extends Component {
imagePropertiesPanel: ElementFinder = this.component.element(by.css(`[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE']`)); imagePropertiesPanel: ElementFinder = this.component.element(by.css(`[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE']`));
expandedImagePropertiesPanel: ElementFinder = this.component.element(by.css(`[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE'].mat-expanded`)); expandedImagePropertiesPanel: ElementFinder = this.component.element(by.css(`[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE'].mat-expanded`));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(ContentMetadata.selectors.root, ancestor); super(ContentMetadata.selectors.root, ancestor);
} }

View File

@ -58,7 +58,7 @@ export class LibraryMetadata extends Component {
error: ElementFinder = this.component.element(by.css(LibraryMetadata.selectors.error)); error: ElementFinder = this.component.element(by.css(LibraryMetadata.selectors.error));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(LibraryMetadata.selectors.root, ancestor); super(LibraryMetadata.selectors.root, ancestor);
} }

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { ElementFinder, ElementArrayFinder, by, browser, ExpectedConditions as EC, $ } from 'protractor'; import { ElementFinder, ElementArrayFinder, by, browser, ExpectedConditions as EC } from 'protractor';
import { Component } from '../component'; import { Component } from '../component';
import { BROWSER_WAIT_TIMEOUT } from '../../configs'; import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { CommentsTab } from './info-drawer-comments-tab'; import { CommentsTab } from './info-drawer-comments-tab';
@ -48,9 +48,9 @@ export class InfoDrawer extends Component {
headerTitle: '.adf-info-drawer-layout-header-title' headerTitle: '.adf-info-drawer-layout-header-title'
}; };
commentsTab = new CommentsTab($(InfoDrawer.selectors.root)); commentsTab = new CommentsTab(InfoDrawer.selectors.root);
aboutTab = new LibraryMetadata($(InfoDrawer.selectors.root)); aboutTab = new LibraryMetadata(InfoDrawer.selectors.root);
propertiesTab = new ContentMetadata($(InfoDrawer.selectors.root)); propertiesTab = new ContentMetadata(InfoDrawer.selectors.root);
header: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.header)); header: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.header));
headerTitle: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.headerTitle)); headerTitle: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.headerTitle));
@ -64,7 +64,7 @@ export class InfoDrawer extends Component {
previousButton: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.previous)); previousButton: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.previous));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(InfoDrawer.selectors.root, ancestor); super(InfoDrawer.selectors.root, ancestor);
} }

View File

@ -45,7 +45,7 @@ export class LoginComponent extends Component {
copyright: ElementFinder = this.component.element(LoginComponent.selectors.copyright); copyright: ElementFinder = this.component.element(LoginComponent.selectors.copyright);
passwordVisibility: ElementFinder = this.component.element(LoginComponent.selectors.passwordVisibility); passwordVisibility: ElementFinder = this.component.element(LoginComponent.selectors.passwordVisibility);
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(LoginComponent.selectors.root, ancestor); super(LoginComponent.selectors.root, ancestor);
} }

View File

@ -74,67 +74,89 @@ export class Menu extends Component {
shareEditAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'Shared Link Settings')); shareEditAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'Shared Link Settings'));
uploadFileAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'Upload File')); uploadFileAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'Upload File'));
uploadFolderAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'Upload Folder')); uploadFolderAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'Upload Folder'));
createFileFromTemplateAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'Create file from template'));
viewAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'View')); viewAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'View'));
viewDetailsAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'View Details')); viewDetailsAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'View Details'));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(Menu.selectors.root, ancestor); super(Menu.selectors.root, ancestor);
} }
async waitForMenuToOpen() { async waitForMenuToOpen(): Promise<void> {
await browser.wait(EC.presenceOf(browser.element(by.css('.cdk-overlay-container .mat-menu-panel'))), BROWSER_WAIT_TIMEOUT); await browser.wait(EC.presenceOf(browser.element(by.css('.cdk-overlay-container .mat-menu-panel'))), BROWSER_WAIT_TIMEOUT);
await browser.wait(EC.visibilityOf(this.items.get(0)), BROWSER_WAIT_TIMEOUT); await browser.wait(EC.visibilityOf(this.items.get(0)), BROWSER_WAIT_TIMEOUT);
} }
async waitForMenuToClose() { async waitForMenuToClose(): Promise<void> {
await browser.wait(EC.not(EC.presenceOf(browser.element(by.css('.cdk-overlay-container .mat-menu-panel')))), BROWSER_WAIT_TIMEOUT); await browser.wait(EC.not(EC.presenceOf(browser.element(by.css('.cdk-overlay-container .mat-menu-panel')))), BROWSER_WAIT_TIMEOUT);
} }
async closeMenu() { async closeMenu(): Promise<void> {
await Utils.pressEscape(); await Utils.pressEscape();
await this.waitForMenuToClose(); await this.waitForMenuToClose();
} }
getNthItem(nth: number) { getNthItem(nth: number): ElementFinder {
return this.items.get(nth - 1); return this.items.get(nth - 1);
} }
getItemByLabel(menuItem: string) { getItemByLabel(menuItem: string): ElementFinder {
return this.component.element(by.cssContainingText(Menu.selectors.item, menuItem)); return this.component.element(by.cssContainingText(Menu.selectors.item, menuItem));
} }
getSubItemByLabel(subMenuItem: string) { getSubItemByLabel(subMenuItem: string): ElementFinder {
return this.component.element(by.cssContainingText(Menu.selectors.submenu, subMenuItem)); return this.component.element(by.cssContainingText(Menu.selectors.submenu, subMenuItem));
} }
getItemById(id: string) { getItemById(id: string): ElementFinder {
return this.component.element(by.id(id)); return this.component.element(by.id(id));
} }
async getItemTooltip(menuItem: string) { async getItemTooltip(menuItem: string): Promise<string> {
return this.getItemByLabel(menuItem).getAttribute('title'); return this.getItemByLabel(menuItem).getAttribute('title');
} }
async getItemIconText(menuItem: string) { async getTooltipForUploadFile(): Promise<string> {
return this.getItemTooltip('Upload File');
}
async getTooltipForUploadFolder(): Promise<string> {
return this.getItemTooltip('Upload Folder');
}
async getTooltipForCreateFolder(): Promise<string> {
return this.getItemTooltip('Create Folder');
}
async getTooltipForCreateLibrary(): Promise<string> {
return this.getItemTooltip('Create Library');
}
async getTooltipForCreateFileFromTemplate(): Promise<string> {
return this.getItemTooltip('Create file from template');
}
async getItemIconText(menuItem: string): Promise<string> {
return this.getItemByLabel(menuItem).element(by.css(Menu.selectors.icon)).getText(); return this.getItemByLabel(menuItem).element(by.css(Menu.selectors.icon)).getText();
} }
async getItemIdAttribute(menuItem: string) { async getItemIdAttribute(menuItem: string): Promise<string> {
return this.getItemByLabel(menuItem).getAttribute('id'); return this.getItemByLabel(menuItem).getAttribute('id');
} }
async getItemsCount() { async getItemsCount(): Promise<number> {
return this.items.count(); return this.items.count();
} }
async getMenuItems(): Promise<string[]> { async getMenuItems(): Promise<string[]> {
return this.items.map(async (elem) => { const items: string[] = await this.items.map(async (elem) => {
const text = await elem.element(by.css('span')).getText(); const span: ElementFinder = elem.element(by.css('span'));
return text; return span.getText();
}); });
return items;
} }
async clickNthItem(nth: number) { async clickNthItem(nth: number): Promise<void> {
try { try {
const elem = this.getNthItem(nth); const elem = this.getNthItem(nth);
await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT, 'timeout waiting for menu item to be clickable'); await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT, 'timeout waiting for menu item to be clickable');
@ -146,7 +168,7 @@ export class Menu extends Component {
} }
} }
async clickMenuItem(menuItem: string) { async clickMenuItem(menuItem: string): Promise<void> {
try { try {
const elem = this.getItemByLabel(menuItem); const elem = this.getItemByLabel(menuItem);
await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT, 'timeout waiting for menu item to be clickable'); await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT, 'timeout waiting for menu item to be clickable');
@ -156,7 +178,7 @@ export class Menu extends Component {
} }
} }
async mouseOverMenuItem(menuItem: string) { async mouseOverMenuItem(menuItem: string): Promise<void> {
try { try {
const elem = this.getItemByLabel(menuItem); const elem = this.getItemByLabel(menuItem);
await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT); await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT);
@ -179,7 +201,7 @@ export class Menu extends Component {
} }
} }
async clickSubMenuItem(subMenuItem: string) { async clickSubMenuItem(subMenuItem: string): Promise<void> {
try { try {
const elem = this.getSubItemByLabel(subMenuItem); const elem = this.getSubItemByLabel(subMenuItem);
await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT); await browser.wait(EC.elementToBeClickable(elem), BROWSER_WAIT_TIMEOUT);
@ -189,15 +211,15 @@ export class Menu extends Component {
} }
} }
async isMenuItemPresent(title: string) { async isMenuItemPresent(title: string): Promise<boolean> {
return browser.element(by.cssContainingText(Menu.selectors.item, title)).isPresent(); return browser.element(by.cssContainingText(Menu.selectors.item, title)).isPresent();
} }
async isSubMenuItemPresent(title: string) { async isSubMenuItemPresent(title: string): Promise<boolean> {
return browser.element(by.cssContainingText(Menu.selectors.submenu, title)).isPresent(); return browser.element(by.cssContainingText(Menu.selectors.submenu, title)).isPresent();
} }
async getSubmenuItemsCount() { async getSubmenuItemsCount(): Promise<number> {
return this.submenus.count(); return this.submenus.count();
} }
@ -212,172 +234,158 @@ export class Menu extends Component {
} }
} }
uploadFile() { uploadFile(): ElementFinder {
return this.uploadFiles; return this.uploadFiles;
} }
async clickEditFolder() { async clickEditFolder(): Promise<void> {
await this.editFolderAction.click(); await this.editFolderAction.click();
} }
async clickShare() { async clickShare(): Promise<void> {
const action = this.shareAction; const action = this.shareAction;
await action.click(); await action.click();
} }
async clickSharedLinkSettings() { async clickSharedLinkSettings(): Promise<void> {
const action = this.shareEditAction; const action = this.shareEditAction;
await action.click(); await action.click();
} }
async isViewPresent(): Promise<boolean> {
async isViewPresent() {
return this.viewAction.isPresent(); return this.viewAction.isPresent();
} }
async isDownloadPresent() { async isDownloadPresent(): Promise<boolean> {
return this.downloadAction.isPresent(); return this.downloadAction.isPresent();
} }
async isEditFolderPresent() { async isEditFolderPresent(): Promise<boolean> {
return this.editFolderAction.isPresent(); return this.editFolderAction.isPresent();
} }
async isEditOfflinePresent() { async isEditOfflinePresent(): Promise<boolean> {
return this.editOfflineAction.isPresent(); return this.editOfflineAction.isPresent();
} }
async isCancelEditingPresent() { async isCancelEditingPresent(): Promise<boolean> {
return this.cancelEditingAction.isPresent(); return this.cancelEditingAction.isPresent();
} }
async isCopyPresent() { async isCopyPresent(): Promise<boolean> {
return this.copyAction.isPresent(); return this.copyAction.isPresent();
} }
async isMovePresent() { async isMovePresent(): Promise<boolean> {
return this.moveAction.isPresent(); return this.moveAction.isPresent();
} }
async isDeletePresent() { async isDeletePresent(): Promise<boolean> {
return this.deleteAction.isPresent(); return this.deleteAction.isPresent();
} }
async isManagePermissionsPresent() { async isManagePermissionsPresent(): Promise<boolean> {
return this.managePermissionsAction.isPresent(); return this.managePermissionsAction.isPresent();
} }
async isManageVersionsPresent() { async isManageVersionsPresent(): Promise<boolean> {
return this.manageVersionsAction.isPresent(); return this.manageVersionsAction.isPresent();
} }
async isUploadNewVersionPresent() { async isUploadNewVersionPresent(): Promise<boolean> {
return this.uploadNewVersionAction.isPresent(); return this.uploadNewVersionAction.isPresent();
} }
async isFavoritePresent() { async isFavoritePresent(): Promise<boolean> {
return this.favoriteAction.isPresent(); return this.favoriteAction.isPresent();
} }
async isRemoveFavoritePresent() { async isRemoveFavoritePresent(): Promise<boolean> {
return this.removeFavoriteAction.isPresent(); return this.removeFavoriteAction.isPresent();
} }
async isToggleFavoritePresent() { async isToggleFavoritePresent(): Promise<boolean> {
return this.toggleFavoriteAction.isPresent(); return this.toggleFavoriteAction.isPresent();
} }
async isToggleRemoveFavoritePresent() { async isToggleRemoveFavoritePresent(): Promise<boolean> {
return this.toggleRemoveFavoriteAction.isPresent(); return this.toggleRemoveFavoriteAction.isPresent();
} }
async isJoinLibraryPresent() { async isJoinLibraryPresent(): Promise<boolean> {
return this.joinAction.isPresent(); return this.joinAction.isPresent();
} }
async isCancelJoinPresent() { async isCancelJoinPresent(): Promise<boolean> {
return this.cancelJoinAction.isPresent(); return this.cancelJoinAction.isPresent();
} }
async isLeaveLibraryPresent() { async isLeaveLibraryPresent(): Promise<boolean> {
return this.leaveAction.isPresent(); return this.leaveAction.isPresent();
} }
async isPermanentDeletePresent() { async isPermanentDeletePresent(): Promise<boolean> {
return this.permanentDeleteAction.isPresent(); return this.permanentDeleteAction.isPresent();
} }
async isRestorePresent() { async isRestorePresent(): Promise<boolean> {
return this.restoreAction.isPresent(); return this.restoreAction.isPresent();
} }
async isSharePresent() { async isSharePresent(): Promise<boolean> {
return this.shareAction.isPresent(); return this.shareAction.isPresent();
} }
async isSharedLinkSettingsPresent() { async isSharedLinkSettingsPresent(): Promise<boolean> {
return this.shareEditAction.isPresent(); return this.shareEditAction.isPresent();
} }
async isViewDetailsPresent() { async isViewDetailsPresent(): Promise<boolean> {
return this.viewDetailsAction.isPresent(); return this.viewDetailsAction.isPresent();
} }
async isCreateFolderPresent() { async isCreateFolderEnabled(): Promise<boolean> {
return this.createFolderAction.isPresent(); return (await this.createFolderAction.isPresent()) && (await this.createFolderAction.isEnabled());
}
async isCreateFolderEnabled() {
return this.createFolderAction.isEnabled();
} }
async isCreateLibraryPresent() { async isCreateLibraryEnabled(): Promise<boolean> {
return this.createLibraryAction.isPresent(); return (await this.createLibraryAction.isPresent()) && (await this.createLibraryAction.isEnabled());
}
async isCreateLibraryEnabled() {
return this.createLibraryAction.isEnabled();
} }
async isUploadFilePresent() { async isUploadFileEnabled(): Promise<boolean> {
return this.uploadFileAction.isPresent(); return (await this.uploadFileAction.isPresent()) && (await this.uploadFileAction.isEnabled());
}
async isUploadFileEnabled() {
return this.uploadFileAction.isEnabled();
} }
async isUploadFolderPresent() { async isUploadFolderEnabled(): Promise<boolean> {
return this.uploadFolderAction.isPresent(); return (await this.uploadFolderAction.isPresent()) && (await this.uploadFolderAction.isEnabled());
}
async isUploadFolderEnabled() {
return this.uploadFolderAction.isEnabled();
} }
async isCancelEditingActionPresent(): Promise<boolean> { async isCreateFileFromTemplateEnabled(): Promise<boolean> {
return this.cancelEditingAction.isPresent(); return (await this.createFileFromTemplateAction.isPresent()) && (await this.createFileFromTemplateAction.isEnabled());
} }
async isEditOfflineActionPresent(): Promise<boolean> { async clickCreateFolder(): Promise<void> {
return this.editOfflineAction.isPresent();
}
async clickCreateFolder() {
const action = this.createFolderAction; const action = this.createFolderAction;
await action.click(); await action.click();
} }
async clickCreateLibrary() { async clickCreateLibrary(): Promise<void> {
const action = this.createLibraryAction; const action = this.createLibraryAction;
await action.click(); await action.click();
} }
async clickUploadFile() { async clickUploadFile(): Promise<void> {
const action = this.uploadFileAction; const action = this.uploadFileAction;
await action.click(); await action.click();
} }
async clickUploadFolder() { async clickUploadFolder(): Promise<void> {
const action = this.uploadFolderAction; const action = this.uploadFolderAction;
await action.click(); await action.click();
} }
async clickCreateFileFromTemplate(): Promise<void> {
const action = this.createFileFromTemplateAction;
await action.click();
}
} }

View File

@ -39,7 +39,7 @@ export class MetadataCard extends Component {
expandButton: ElementFinder = this.component.element(by.css(MetadataCard.selectors.expandButton)); expandButton: ElementFinder = this.component.element(by.css(MetadataCard.selectors.expandButton));
expansionPanels: ElementArrayFinder = this.component.all(by.css(MetadataCard.selectors.expansionPanel)); expansionPanels: ElementArrayFinder = this.component.all(by.css(MetadataCard.selectors.expansionPanel));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(MetadataCard.selectors.root, ancestor); super(MetadataCard.selectors.root, ancestor);
} }

View File

@ -53,7 +53,7 @@ export class Pagination extends Component {
menu: Menu = new Menu(); menu: Menu = new Menu();
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(Pagination.selectors.root, ancestor); super(Pagination.selectors.root, ancestor);
} }

View File

@ -45,7 +45,7 @@ export class SearchFilters extends Component {
location = new FacetFilter('Location'); location = new FacetFilter('Location');
modifiedDate = new FacetFilter('Modified date'); modifiedDate = new FacetFilter('Modified date');
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(SearchFilters.selectors.root, ancestor); super(SearchFilters.selectors.root, ancestor);
} }

View File

@ -50,7 +50,7 @@ export class SearchInput extends Component {
searchLibrariesOption: ElementFinder = this.searchOptionsArea.element(by.cssContainingText(SearchInput.selectors.optionCheckbox, 'Libraries')); searchLibrariesOption: ElementFinder = this.searchOptionsArea.element(by.cssContainingText(SearchInput.selectors.optionCheckbox, 'Libraries'));
clearSearchButton: ElementFinder = this.searchContainer.$(SearchInput.selectors.clearButton); clearSearchButton: ElementFinder = this.searchContainer.$(SearchInput.selectors.clearButton);
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(SearchInput.selectors.root, ancestor); super(SearchInput.selectors.root, ancestor);
} }

View File

@ -39,7 +39,7 @@ export class SearchSortingPicker extends Component {
sortByDropdownExpanded: ElementFinder = browser.element(by.css('.mat-select-panel')); sortByDropdownExpanded: ElementFinder = browser.element(by.css('.mat-select-panel'));
sortByList: ElementArrayFinder = this.sortByDropdownExpanded.all(by.css(SearchSortingPicker.selectors.sortByOption)); sortByList: ElementArrayFinder = this.sortByDropdownExpanded.all(by.css(SearchSortingPicker.selectors.sortByOption));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(SearchSortingPicker.selectors.root, ancestor); super(SearchSortingPicker.selectors.root, ancestor);
} }

View File

@ -68,11 +68,11 @@ export class Sidenav extends Component {
menu: Menu = new Menu(); menu: Menu = new Menu();
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(Sidenav.selectors.root, ancestor); super(Sidenav.selectors.root, ancestor);
} }
private async expandMenu(name: string) { private async expandMenu(name: string): Promise<void> {
try{ try{
if (await element(by.cssContainingText('.mat-expanded', name)).isPresent()) { if (await element(by.cssContainingText('.mat-expanded', name)).isPresent()) {
@ -89,37 +89,42 @@ export class Sidenav extends Component {
} }
} }
async openNewMenu() { async openNewMenu(): Promise<void> {
const { menu, newButton } = this; const { menu, newButton } = this;
await newButton.click(); await newButton.click();
await menu.waitForMenuToOpen(); await menu.waitForMenuToOpen();
} }
async openCreateFolderDialog() { async openCreateFolderDialog(): Promise<void> {
await this.openNewMenu(); await this.openNewMenu();
await this.menu.clickMenuItem('Create Folder'); await this.menu.clickMenuItem('Create Folder');
} }
async openCreateLibraryDialog() { async openCreateLibraryDialog(): Promise<void> {
await this.openNewMenu(); await this.openNewMenu();
await this.menu.clickMenuItem('Create Library'); await this.menu.clickMenuItem('Create Library');
} }
async isActive(name: string) { async openCreateFileFromTemplateDialog(): Promise<void> {
await this.openNewMenu();
await this.menu.clickMenuItem('Create file from template');
}
async isActive(name: string): Promise<boolean> {
return (await this.getLinkLabel(name).getAttribute('class')).includes(Sidenav.selectors.activeClassName); return (await this.getLinkLabel(name).getAttribute('class')).includes(Sidenav.selectors.activeClassName);
} }
async childIsActive(name: string) { async childIsActive(name: string): Promise<boolean> {
const childClass = await this.getLinkLabel(name).element(by.css('span')).getAttribute('class'); const childClass = await this.getLinkLabel(name).element(by.css('span')).getAttribute('class');
return childClass.includes(Sidenav.selectors.activeChild); return childClass.includes(Sidenav.selectors.activeChild);
} }
getLink(name: string) { getLink(name: string): ElementFinder {
return this.getLinkLabel(name).element(by.xpath('..')); return this.getLinkLabel(name).element(by.xpath('..'));
} }
getLinkLabel(name: string) { getLinkLabel(name: string): ElementFinder {
switch (name) { switch (name) {
case 'Personal Files': return this.personalFiles; case 'Personal Files': return this.personalFiles;
case 'File Libraries': return this.fileLibraries; case 'File Libraries': return this.fileLibraries;
@ -133,37 +138,35 @@ export class Sidenav extends Component {
} }
} }
getActiveLink() { getActiveLink(): ElementFinder {
return this.activeLink; return this.activeLink;
} }
async getLinkTooltip(name: string) { async getLinkTooltip(name: string): Promise<string> {
const link = this.getLinkLabel(name); const link = this.getLinkLabel(name);
const condition = () => link.getAttribute('title').then(value => value && value.length > 0); const condition = () => link.getAttribute('title').then(value => value && value.length > 0);
await browser.actions().mouseMove(link).perform(); await browser.actions().mouseMove(link).perform();
await browser.wait(condition, BROWSER_WAIT_TIMEOUT); await browser.wait(condition, BROWSER_WAIT_TIMEOUT);
return link.getAttribute('title'); return link.getAttribute('title');
} }
async clickLink(name: string) { async clickLink(name: string): Promise<void> {
try{ try{
const link = this.getLinkLabel(name); const link = this.getLinkLabel(name);
await Utils.waitUntilElementClickable(link); await Utils.waitUntilElementClickable(link);
return await link.click(); await link.click();
} catch (error) { } catch (error) {
console.log('---- sidebar navigation clickLink catch error: ', error); console.log('---- sidebar navigation clickLink catch error: ', error);
} }
} }
async isFileLibrariesMenuExpanded() { async isFileLibrariesMenuExpanded(): Promise<boolean> {
return element(by.cssContainingText('.mat-expanded', SIDEBAR_LABELS.FILE_LIBRARIES)).isPresent(); return element(by.cssContainingText('.mat-expanded', SIDEBAR_LABELS.FILE_LIBRARIES)).isPresent();
} }
async expandFileLibraries() { async expandFileLibraries(): Promise<void> {
await this.expandMenu(SIDEBAR_LABELS.FILE_LIBRARIES); await this.expandMenu(SIDEBAR_LABELS.FILE_LIBRARIES);
} }

View File

@ -64,7 +64,7 @@ export class Toolbar extends Component {
permanentlyDeleteButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.permanentlyDelete)); permanentlyDeleteButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.permanentlyDelete));
restoreButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.restore)); restoreButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.restore));
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(Toolbar.selectors.root, ancestor); super(Toolbar.selectors.root, ancestor);
} }

View File

@ -50,9 +50,9 @@ export class Viewer extends Component {
viewerExtensionContent: ElementFinder = this.component.element(by.css(Viewer.selectors.viewerExtensionContent)); viewerExtensionContent: ElementFinder = this.component.element(by.css(Viewer.selectors.viewerExtensionContent));
pdfViewerContentPages: ElementArrayFinder = this.component.all(by.css(Viewer.selectors.pdfViewerContentPage)); pdfViewerContentPages: ElementArrayFinder = this.component.all(by.css(Viewer.selectors.pdfViewerContentPage));
toolbar = new Toolbar(this.component); toolbar = new Toolbar(Viewer.selectors.root);
constructor(ancestor?: ElementFinder) { constructor(ancestor?: string) {
super(Viewer.selectors.root, ancestor); super(Viewer.selectors.root, ancestor);
} }

View File

@ -28,12 +28,12 @@ import { SIDEBAR_LABELS } from './../configs';
import { Page } from './page'; import { Page } from './page';
export class BrowsingPage extends Page { export class BrowsingPage extends Page {
header = new Header(this.app); header = new Header(this.appRoot);
sidenav = new Sidenav(this.app); sidenav = new Sidenav(this.appRoot);
toolbar = new Toolbar(this.app); toolbar = new Toolbar(this.appRoot);
breadcrumb = new Breadcrumb(this.app); breadcrumb = new Breadcrumb(this.appRoot);
dataTable = new DataTable(this.app); dataTable = new DataTable(this.appRoot);
pagination = new Pagination(this.app); pagination = new Pagination(this.appRoot);
async signOut() { async signOut() {
await this.header.userInfo.signOut(); await this.header.userInfo.signOut();

View File

@ -29,7 +29,7 @@ import { Page } from './page';
import { ADMIN_USERNAME, ADMIN_PASSWORD, BROWSER_WAIT_TIMEOUT, APP_ROUTES } from '../configs'; import { ADMIN_USERNAME, ADMIN_PASSWORD, BROWSER_WAIT_TIMEOUT, APP_ROUTES } from '../configs';
export class LoginPage extends Page { export class LoginPage extends Page {
login: LoginComponent = new LoginComponent(this.app); login: LoginComponent = new LoginComponent(this.appRoot);
/** @override */ /** @override */
constructor() { constructor() {

View File

@ -29,7 +29,7 @@ import { Utils } from '../utilities/utils';
export abstract class Page { export abstract class Page {
protected static locators = { protected static locators = {
app: 'app-root', root: 'app-root',
layout: 'app-layout', layout: 'app-layout',
overlay: '.cdk-overlay-container', overlay: '.cdk-overlay-container',
dialogContainer: '.mat-dialog-container', dialogContainer: '.mat-dialog-container',
@ -42,7 +42,8 @@ export abstract class Page {
genericErrorTitle: '.generic-error__title' genericErrorTitle: '.generic-error__title'
}; };
app: ElementFinder = browser.element(by.css(Page.locators.app)); appRoot: string = Page.locators.root;
layout: ElementFinder = browser.element(by.css(Page.locators.layout)); layout: ElementFinder = browser.element(by.css(Page.locators.layout));
overlay: ElementFinder = browser.element(by.css(Page.locators.overlay)); overlay: ElementFinder = browser.element(by.css(Page.locators.overlay));
snackBar: ElementFinder = browser.element(by.css(Page.locators.snackBar)); snackBar: ElementFinder = browser.element(by.css(Page.locators.snackBar));

View File

@ -44,8 +44,8 @@ export class SearchResultsPage extends BrowsingPage {
chipList: ElementFinder = this.root.element(by.css(SearchResultsPage.selectors.chipList)); chipList: ElementFinder = this.root.element(by.css(SearchResultsPage.selectors.chipList));
infoText: ElementFinder = this.root.element(by.css(SearchResultsPage.selectors.infoText)); infoText: ElementFinder = this.root.element(by.css(SearchResultsPage.selectors.infoText));
sortingPicker = new SearchSortingPicker(this.root); sortingPicker = new SearchSortingPicker(SearchResultsPage.selectors.root);
filters = new SearchFilters(this.root); filters = new SearchFilters(SearchResultsPage.selectors.root);
async waitForResults(): Promise<void> { async waitForResults(): Promise<void> {
await this.dataTable.waitForBody(); await this.dataTable.waitForBody();

View File

@ -187,7 +187,7 @@ describe('Generic tests : ', () => {
await dataTable.rightClickOnItem(file1); await dataTable.rightClickOnItem(file1);
expect(await dataTable.hasContextMenu()).toBe(true, `Context menu is not displayed for ${file1}`); expect(await dataTable.hasContextMenu()).toBe(true, `Context menu is not displayed for ${file1}`);
expect(await dataTable.countSelectedRows()).toEqual(1, 'incorrect number of selected rows'); expect(await dataTable.getSelectedRowsCount()).toEqual(1, 'incorrect number of selected rows');
expect(await contextMenu.isEditFolderPresent()).toBe(false, `Edit folder is displayed for ${file1}`); expect(await contextMenu.isEditFolderPresent()).toBe(false, `Edit folder is displayed for ${file1}`);
expect(await dataTable.hasCheckMarkIcon(file1)).toBe(true, `${file1} is not selected`); expect(await dataTable.hasCheckMarkIcon(file1)).toBe(true, `${file1} is not selected`);
expect(await dataTable.hasCheckMarkIcon(file2)).toBe(false, `${file2} is selected`); expect(await dataTable.hasCheckMarkIcon(file2)).toBe(false, `${file2} is selected`);
@ -197,11 +197,11 @@ describe('Generic tests : ', () => {
it('Unselect items with single click - [C280458]', async () => { it('Unselect items with single click - [C280458]', async () => {
await dataTable.selectMultipleItems([file1, file2, folder1, folder2]); await dataTable.selectMultipleItems([file1, file2, folder1, folder2]);
expect(await dataTable.countSelectedRows()).toEqual(4, 'incorrect selected rows number'); expect(await dataTable.getSelectedRowsCount()).toEqual(4, 'incorrect selected rows number');
await dataTable.clickItem(file1); await dataTable.clickItem(file1);
expect(await dataTable.countSelectedRows()).toEqual(1, 'incorrect selected rows number'); expect(await dataTable.getSelectedRowsCount()).toEqual(1, 'incorrect selected rows number');
}); });
it('Select / unselect items by CMD+click - [C217110]', async () => { it('Select / unselect items by CMD+click - [C217110]', async () => {
@ -212,13 +212,13 @@ describe('Generic tests : ', () => {
await dataTable.clickItem(folder2); await dataTable.clickItem(folder2);
await browser.actions().sendKeys(protractor.Key.NULL).perform(); await browser.actions().sendKeys(protractor.Key.NULL).perform();
expect(await dataTable.countSelectedRows()).toEqual(4, 'incorrect selected rows number'); expect(await dataTable.getSelectedRowsCount()).toEqual(4, 'incorrect selected rows number');
await browser.actions().sendKeys(protractor.Key.COMMAND).perform(); await browser.actions().sendKeys(protractor.Key.COMMAND).perform();
await dataTable.clickItem(file1); await dataTable.clickItem(file1);
await dataTable.clickItem(file2); await dataTable.clickItem(file2);
await browser.actions().sendKeys(protractor.Key.NULL).perform(); await browser.actions().sendKeys(protractor.Key.NULL).perform();
expect(await dataTable.countSelectedRows()).toEqual(2, 'incorrect selected rows number'); expect(await dataTable.getSelectedRowsCount()).toEqual(2, 'incorrect selected rows number');
}); });
}); });

View File

@ -631,7 +631,7 @@ describe('Copy content', () => {
expect(await dataTable.isItemPresent(fileName)).toBe(false, `${fileName} present in ${destination} folder`); expect(await dataTable.isItemPresent(fileName)).toBe(false, `${fileName} present in ${destination} folder`);
await page.clickTrash(); await page.clickTrash();
expect(await dataTable.isEmptyList()).toBe(true, 'Trash is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'Trash is not empty');
} }
async function undoCopyFolder(folderName: string, location: string = '', destination: string, doBefore = null) { async function undoCopyFolder(folderName: string, location: string = '', destination: string, doBefore = null) {
@ -654,7 +654,7 @@ describe('Copy content', () => {
expect(await dataTable.isItemPresent(folderName)).toBe(false, `${folderName} present in ${destination} folder`); expect(await dataTable.isItemPresent(folderName)).toBe(false, `${folderName} present in ${destination} folder`);
await page.clickTrash(); await page.clickTrash();
expect(await dataTable.isEmptyList()).toBe(true, 'Trash is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'Trash is not empty');
} }
async function undoCopyFileWithExistingName(fileName: string, location: string = '', destination: string, doBefore = null) { async function undoCopyFileWithExistingName(fileName: string, location: string = '', destination: string, doBefore = null) {
@ -681,7 +681,7 @@ describe('Copy content', () => {
expect(await dataTable.isItemPresent(`${fileInFolder2}-1`)).toBe(false, `${fileInFolder2}-1 is present in ${destination} folder`); expect(await dataTable.isItemPresent(`${fileInFolder2}-1`)).toBe(false, `${fileInFolder2}-1 is present in ${destination} folder`);
await page.clickTrash(); await page.clickTrash();
expect(await dataTable.isEmptyList()).toBe(true, 'Trash is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'Trash is not empty');
} }
async function undoCopyFolderWithExistingName(folderName: string, location: string = '', destination: string, doBefore = null) { async function undoCopyFolderWithExistingName(folderName: string, location: string = '', destination: string, doBefore = null) {
@ -708,7 +708,7 @@ describe('Copy content', () => {
expect(await dataTable.isItemPresent(file1InFolderExisting)).toBe(false, `${file1InFolderExisting} present in ${folderName} in ${destination} folder`); expect(await dataTable.isItemPresent(file1InFolderExisting)).toBe(false, `${file1InFolderExisting} present in ${folderName} in ${destination} folder`);
await page.clickTrash(); await page.clickTrash();
expect(await dataTable.isEmptyList()).toBe(true, 'Trash is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'Trash is not empty');
} }
}); });

View File

@ -0,0 +1,411 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2019 Alfresco Software Limited
*
* 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 <http://www.gnu.org/licenses/>.
*/
import { LoginPage, BrowsingPage } from '../../pages/pages';
import { SelectTemplateDialog } from '../../components/dialog/select-template-dialog';
import { CreateFromTemplateDialog } from '../../components/dialog/create-from-template-dialog';
import { Utils } from '../../utilities/utils';
import { AdminActions } from '../../utilities/admin-actions';
import { RepoClient, NodeContentTree } from '../../utilities/repo-client/repo-client';
describe('Create file from template', () => {
const random = Utils.random();
const username = `user-${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 template1InRootFolder = `template3-${random}.txt`;
const template2InRootFolder = `template4-${random}.txt`;
const parent = `parent-${random}`; let parentId;
const file1 = {
name: `file1-${random}.txt`
};
const file2 = {
name: `file2-${random}.txt`,
title: `file2 title`,
description: `file2 description`
};
const duplicateFileName = `duplicate-file-${random}.txt`;
const nameWithSpaces = ` file-${random}.txt `;
const siteName = `site-${random}`;
const fileSite = {
name: `file-site-${random}.txt`,
title: `file site title`,
description: `file site description`
};
const duplicateFileSite = `duplicate-file-site-${random}`;
let docLibUserSite: string;
const userApi = new RepoClient(username, username);
const adminApiActions = new AdminActions();
const loginPage = new LoginPage();
const page = new BrowsingPage();
const selectTemplateDialog = new SelectTemplateDialog();
const createFromTemplateDialog = new CreateFromTemplateDialog();
const { sidenav } = page;
beforeAll( async (done) => {
await adminApiActions.createUser({ username });
parentId = (await userApi.nodes.createFolder(parent)).entry.id;
await userApi.nodes.createFile(duplicateFileName, parentId);
await userApi.sites.createSite(siteName);
docLibUserSite = await userApi.sites.getDocLibId(siteName);
await userApi.nodes.createFolder(duplicateFileSite, docLibUserSite);
await loginPage.loginWith(username);
done();
});
afterAll(async (done) => {
await userApi.nodes.deleteNodeById(parentId);
await userApi.sites.deleteSite(siteName);
await adminApiActions.cleanNodeTemplatesFolder();
done();
});
beforeEach(async () => {
await page.closeOpenDialogs();
});
it('Select template - dialog UI - when no templates exist in the repo - [C325049]', async () => {
await sidenav.openCreateFileFromTemplateDialog();
await selectTemplateDialog.waitForDialogToOpen();
expect(await selectTemplateDialog.getTitle()).toEqual('Select a document template');
expect(await selectTemplateDialog.dataTable.isEmpty()).toBe(true, 'Datatable is not empty');
expect(await selectTemplateDialog.dataTable.getEmptyListText()).toEqual('No results found');
expect(await selectTemplateDialog.breadcrumb.getCurrentFolderName()).toEqual('Node Templates');
expect(await selectTemplateDialog.isNextButtonEnabled()).toBe(false, 'Next button is not disabled');
expect(await selectTemplateDialog.isCancelButtonEnabled()).toBe(true, 'Cancel button is not enabled');
});
describe('with existing templates', () => {
const templates: NodeContentTree = {
folders: [
{
name: templatesFolder1,
files: [template1InFolder1, template2InFolder1]
},
{
name: templatesFolder2,
folders: [
{
name: templatesSubFolder
}
],
files: [template1InFolder2]
},
{
name: restrictedTemplateFolder,
files: [templateInRestrictedFolder]
}
],
files: [template1InRootFolder, template2InRootFolder]
};
let link: string;
beforeAll(async (done) => {
await adminApiActions.createNodeTemplatesHierarchy(templates);
await adminApiActions.removeUserAccessOnNode(restrictedTemplateFolder);
link = (await adminApiActions.createLinkToFileName(template2InRootFolder, await adminApiActions.getNodeTemplatesFolderId())).entry.name;
done();
});
describe('Select Template dialog', () => {
beforeEach(async (done) => {
await sidenav.openCreateFileFromTemplateDialog();
await selectTemplateDialog.waitForDialogToOpen();
done();
});
it('Select template - dialog UI - with existing templates - [C325043]', async () => {
expect(await selectTemplateDialog.getTitle()).toEqual('Select a document template');
expect(await selectTemplateDialog.dataTable.isEmpty()).toBe(false, 'Datatable is empty');
expect(await selectTemplateDialog.dataTable.isItemPresent(templatesFolder1)).toBe(true, 'template folder not displayed');
expect(await selectTemplateDialog.dataTable.isItemPresent(templatesFolder2)).toBe(true, 'template folder not displayed');
expect(await selectTemplateDialog.dataTable.isItemPresent(template1InRootFolder)).toBe(true, 'template not displayed');
expect(await selectTemplateDialog.dataTable.isItemPresent(template2InRootFolder)).toBe(true, 'template not displayed');
expect(await selectTemplateDialog.breadcrumb.getCurrentFolderName()).toEqual('Node Templates');
expect(await selectTemplateDialog.isNextButtonEnabled()).toBe(false, 'Next button is not disabled');
expect(await selectTemplateDialog.isCancelButtonEnabled()).toBe(true, 'Cancel button is not enabled');
});
it(`Templates don't appear if user doesn't have permissions to see them - [C325044]`, async () => {
expect(await selectTemplateDialog.dataTable.isItemPresent(restrictedTemplateFolder)).toBe(false, 'restricted templates folder is displayed');
});
it('Navigate through the templates list with folder hierarchy - [C325045]', async () => {
expect(await selectTemplateDialog.dataTable.isItemPresent(templatesFolder2)).toBe(true, 'template folder not displayed');
await selectTemplateDialog.dataTable.doubleClickOnRowByName(templatesFolder2);
expect(await selectTemplateDialog.dataTable.isItemPresent(templatesSubFolder)).toBe(true, 'template sub-folder not displayed');
expect(await selectTemplateDialog.dataTable.isItemPresent(template1InFolder2)).toBe(true, 'template not displayed');
expect(await selectTemplateDialog.dataTable.isItemPresent(template1InRootFolder)).toBe(false, 'template is displayed');
expect(await selectTemplateDialog.dataTable.isItemPresent(template2InRootFolder)).toBe(false, 'template is displayed');
expect(await selectTemplateDialog.breadcrumb.getCurrentFolderName()).toEqual(templatesFolder2);
await selectTemplateDialog.dataTable.doubleClickOnRowByName(templatesSubFolder);
expect(await selectTemplateDialog.breadcrumb.getCurrentFolderName()).toEqual(templatesSubFolder);
expect(await selectTemplateDialog.dataTable.isEmpty()).toBe(true, 'datatable is not empty');
await selectTemplateDialog.breadcrumb.openPath();
expect(await selectTemplateDialog.breadcrumb.getPathItems()).toEqual([ templatesFolder2, 'Node Templates' ]);
});
it(`Templates list doesn't allow multiple selection - [C325047]`, async () => {
expect(await selectTemplateDialog.dataTable.getSelectedRowsCount()).toEqual(0, 'Incorrect number of selected rows');
await selectTemplateDialog.dataTable.selectItem(template1InRootFolder);
expect(await selectTemplateDialog.dataTable.getSelectedRowsCount()).toEqual(1, 'Incorrect number of selected rows');
expect(await selectTemplateDialog.dataTable.getSelectedRowsNames()).toEqual([ template1InRootFolder ], 'Incorrect selected item');
await Utils.pressCmd();
await selectTemplateDialog.dataTable.selectItem(template2InRootFolder);
await Utils.releaseKeyPressed();
expect(await selectTemplateDialog.dataTable.getSelectedRowsCount()).toEqual(1, 'Incorrect number of selected rows');
expect(await selectTemplateDialog.dataTable.getSelectedRowsNames()).toEqual([ template2InRootFolder ], 'Incorrect selected item');
});
it('Links to files are not displayed - [C325050]', async () => {
expect(await selectTemplateDialog.dataTable.isItemPresent(link)).toBe(false, 'Link to file is displayed');
});
it('Cancel the Select template dialog - [C325048]', async () => {
expect(await selectTemplateDialog.isCancelButtonEnabled()).toBe(true, 'Cancel button is not enabled');
await selectTemplateDialog.clickCancel();
expect(await selectTemplateDialog.isDialogOpen()).toBe(false, 'Select Template dialog is open');
});
it('Next button is disabled when selecting a folder - [C216339]', async () => {
expect(await selectTemplateDialog.isNextButtonEnabled()).toBe(false, 'Next button is enabled');
await selectTemplateDialog.dataTable.selectItem(templatesFolder1);
expect(await selectTemplateDialog.isNextButtonEnabled()).toBe(false, 'Next button is enabled');
});
});
describe('Create from template dialog', () => {
beforeEach(async (done) => {
await sidenav.openCreateFileFromTemplateDialog();
await selectTemplateDialog.waitForDialogToOpen();
await selectTemplateDialog.dataTable.selectItem(template1InRootFolder);
await selectTemplateDialog.clickNext();
await createFromTemplateDialog.waitForDialogToOpen();
done();
});
it('Create file from template - dialog UI - [C325020]', async () => {
expect(await createFromTemplateDialog.getTitle()).toEqual(`Create new document from '${template1InRootFolder}'`);
expect(await createFromTemplateDialog.isNameFieldDisplayed()).toBe(true, 'Name field not displayed');
expect(await createFromTemplateDialog.isTitleFieldDisplayed()).toBe(true, 'Title field not displayed');
expect(await createFromTemplateDialog.isDescriptionFieldDisplayed()).toBe(true, 'Description field not displayed');
expect(await createFromTemplateDialog.isCancelButtonEnabled()).toBe(true, 'Cancel button is not enabled');
expect(await createFromTemplateDialog.isCreateButtonEnabled()).toBe(true, 'Create button is not enabled');
});
it('File name is required - [C325031]', async () => {
expect(await createFromTemplateDialog.getName()).toEqual(template1InRootFolder);
await createFromTemplateDialog.deleteNameWithBackspace();
expect(await createFromTemplateDialog.getValidationMessage()).toEqual('File name is required');
expect(await createFromTemplateDialog.isCreateButtonEnabled()).toBe(false, 'Create button is not disabled');
});
it('Special characters in file name - [C325032]', async () => {
const namesWithSpecialChars = [ 'a*a', 'a"a', 'a<a', 'a>a', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ];
for (const name of namesWithSpecialChars) {
await createFromTemplateDialog.enterName(name);
expect(await createFromTemplateDialog.isCreateButtonEnabled()).toBe(false, 'Create button is not disabled');
expect(await createFromTemplateDialog.getValidationMessage()).toContain(`File name can't contain these characters`);
}
});
it('File name ending with a dot - [C325033]', async () => {
await createFromTemplateDialog.enterName('file-name.');
expect(await createFromTemplateDialog.isCreateButtonEnabled()).toBe(false, 'Create button is not disabled');
expect(await createFromTemplateDialog.getValidationMessage()).toMatch(`File name can't end with a period .`);
});
it('File name containing only spaces - [C325034]', async () => {
await createFromTemplateDialog.enterName(' ');
expect(await createFromTemplateDialog.isCreateButtonEnabled()).toBe(false, 'Create button is not disabled');
expect(await createFromTemplateDialog.getValidationMessage()).toMatch(`File name can't contain only spaces`);
});
it('Title too long - [C290146]', async () => {
await createFromTemplateDialog.enterTitle(Utils.string257);
await Utils.pressTab();
expect(await createFromTemplateDialog.isCreateButtonEnabled()).toBe(false, 'Create button is not disabled');
expect(await createFromTemplateDialog.getValidationMessage()).toMatch(`Use 256 characters or less for title`);
});
it('Description too long - [C290142]', async () => {
await createFromTemplateDialog.enterDescription(Utils.string513);
await Utils.pressTab();
expect(await createFromTemplateDialog.isCreateButtonEnabled()).toBe(false, 'Create button is not disabled');
expect(await createFromTemplateDialog.getValidationMessage()).toMatch(`Use 512 characters or less for description`);
});
});
describe('On Personal Files', () => {
beforeEach(async (done) => {
await page.clickPersonalFilesAndWait();
await page.dataTable.doubleClickOnRowByName(parent);
await sidenav.openCreateFileFromTemplateDialog();
await selectTemplateDialog.waitForDialogToOpen();
await selectTemplateDialog.dataTable.selectItem(template1InRootFolder);
await selectTemplateDialog.clickNext();
await createFromTemplateDialog.waitForDialogToOpen();
done();
});
it('Create a file from a template - with a new Name - [C325030]', async () => {
await createFromTemplateDialog.enterName(file1.name);
await createFromTemplateDialog.clickCreate();
await createFromTemplateDialog.waitForDialogToClose();
await page.dataTable.waitForHeader();
expect(await page.dataTable.isItemPresent(file1.name)).toBe(true, 'File not displayed in list view');
});
it('Create a file from a template - with a Name, Title and Description - [C325026]', async (done) => {
await createFromTemplateDialog.enterName(file2.name);
await createFromTemplateDialog.enterTitle(file2.title);
await createFromTemplateDialog.enterDescription(file2.description);
await createFromTemplateDialog.clickCreate();
await createFromTemplateDialog.waitForDialogToClose();
await page.dataTable.waitForHeader();
expect(await page.dataTable.isItemPresent(file2.name)).toBe(true, 'File not displayed in list view');
const desc = await userApi.nodes.getNodeDescription(file2.name, parentId);
expect(desc).toEqual(file2.description);
const title = await userApi.nodes.getNodeTitle(file2.name, parentId);
expect(title).toEqual(file2.title);
done();
});
it('Create a file with a duplicate name - [C325028]', async () => {
await createFromTemplateDialog.enterName(duplicateFileName);
await createFromTemplateDialog.clickCreate();
expect(await page.getSnackBarMessage()).toEqual(`This name is already in use, try a different name.`);
expect(await createFromTemplateDialog.isDialogOpen()).toBe(true, 'dialog is not present');
});
it('Cancel file creation - [C325027]', async () => {
await createFromTemplateDialog.enterName('test');
await createFromTemplateDialog.clickCancel();
expect(await createFromTemplateDialog.isDialogOpen()).not.toBe(true, 'dialog is not closed');
expect(await page.dataTable.isItemPresent('test')).toBe(false, 'File should not appear in the list');
});
it('Trim spaces from file Name - [C325042]', async () => {
await createFromTemplateDialog.enterName(nameWithSpaces);
await createFromTemplateDialog.clickCreate();
await createFromTemplateDialog.waitForDialogToClose();
await page.dataTable.waitForHeader();
expect(await page.dataTable.isItemPresent(nameWithSpaces.trim())).toBe(true, 'Folder not displayed in list view');
});
});
describe('On File Libraries', () => {
const fileLibrariesPage = new BrowsingPage();
beforeEach(async (done) => {
await fileLibrariesPage.goToMyLibrariesAndWait();
await page.dataTable.doubleClickOnRowByName(siteName);
await sidenav.openCreateFileFromTemplateDialog();
await selectTemplateDialog.waitForDialogToOpen();
await selectTemplateDialog.dataTable.selectItem(template1InRootFolder);
await selectTemplateDialog.clickNext();
await createFromTemplateDialog.waitForDialogToOpen();
done();
});
it('Create a file from a template - with Name, Title and Description - [C325023]', async (done) => {
await createFromTemplateDialog.enterName(fileSite.name);
await createFromTemplateDialog.enterTitle(fileSite.title);
await createFromTemplateDialog.enterDescription(fileSite.description);
await createFromTemplateDialog.clickCreate();
await createFromTemplateDialog.waitForDialogToClose();
await page.dataTable.waitForHeader();
expect(await page.dataTable.isItemPresent(fileSite.name)).toBe(true, 'File not displayed in list view');
const desc = await userApi.nodes.getNodeDescription(fileSite.name, docLibUserSite);
expect(desc).toEqual(fileSite.description);
const title = await userApi.nodes.getNodeTitle(fileSite.name, docLibUserSite);
expect(title).toEqual(fileSite.title);
done();
});
it('Cancel file creation - [C325024]', async () => {
await createFromTemplateDialog.enterName('test');
await createFromTemplateDialog.clickCancel();
expect(await createFromTemplateDialog.isDialogOpen()).not.toBe(true, 'dialog is not closed');
expect(await page.dataTable.isItemPresent('test')).toBe(false, 'File should not appear in the list');
});
it('Create a file with a duplicate name - [C325025]', async () => {
await createFromTemplateDialog.enterName(duplicateFileSite);
await createFromTemplateDialog.clickCreate();
expect(await page.getSnackBarMessage()).toEqual(`This name is already in use, try a different name.`);
expect(await createFromTemplateDialog.isDialogOpen()).toBe(true, 'dialog is not present');
});
});
});
});

View File

@ -23,7 +23,6 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { SITE_VISIBILITY, SITE_ROLES } from '../../configs';
import { LoginPage, BrowsingPage } from '../../pages/pages'; import { LoginPage, BrowsingPage } from '../../pages/pages';
import { CreateOrEditFolderDialog } from '../../components/dialog/create-edit-folder-dialog'; import { CreateOrEditFolderDialog } from '../../components/dialog/create-edit-folder-dialog';
import { Utils } from '../../utilities/utils'; import { Utils } from '../../utilities/utils';
@ -39,7 +38,6 @@ describe('Create folder', () => {
const duplicateFolderName = `folder-${Utils.random()}`; const duplicateFolderName = `folder-${Utils.random()}`;
const nameWithSpaces = ` folder-${Utils.random()} `; const nameWithSpaces = ` folder-${Utils.random()} `;
const sitePrivate = `site-private-${Utils.random()}`;
const siteName = `site-${Utils.random()}`; const siteName = `site-${Utils.random()}`;
const folderSite = `folder-site-${Utils.random()}`; const folderSite = `folder-site-${Utils.random()}`;
@ -59,11 +57,6 @@ describe('Create folder', () => {
beforeAll(async (done) => { beforeAll(async (done) => {
await apis.admin.people.createUser({ username }); await apis.admin.people.createUser({ username });
await apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE);
const docLibId = await apis.admin.sites.getDocLibId(sitePrivate);
await apis.admin.nodes.createFolder(folderName1, docLibId);
await apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE);
parentId = (await apis.user.nodes.createFolder(parent)).entry.id; parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
await apis.user.nodes.createFolder(duplicateFolderName, parentId); await apis.user.nodes.createFolder(duplicateFolderName, parentId);
@ -76,7 +69,6 @@ describe('Create folder', () => {
}); });
afterAll(async (done) => { afterAll(async (done) => {
await apis.admin.sites.deleteSite(sitePrivate);
await apis.user.sites.deleteSite(siteName); await apis.user.sites.deleteSite(siteName);
await apis.user.nodes.deleteNodeById(parentId); await apis.user.nodes.deleteNodeById(parentId);
done(); done();

View File

@ -126,7 +126,7 @@ describe('Delete and undo delete', () => {
}); });
it('delete a file and check notification - [C217125]', async () => { it('delete a file and check notification - [C217125]', async () => {
let items = await page.dataTable.countRows(); let items = await page.dataTable.getRowsCount();
await dataTable.selectItem(file1); await dataTable.selectItem(file1);
await toolbar.clickMoreActionsDelete(); await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage(); const message = await page.getSnackBarMessage();
@ -140,7 +140,7 @@ describe('Delete and undo delete', () => {
}); });
it('delete multiple files and check notification - [C280502]', async () => { it('delete multiple files and check notification - [C280502]', async () => {
let items = await page.dataTable.countRows(); let items = await page.dataTable.getRowsCount();
await dataTable.selectMultipleItems([file2, file3]); await dataTable.selectMultipleItems([file2, file3]);
await toolbar.clickMoreActionsDelete(); await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage(); const message = await page.getSnackBarMessage();
@ -155,7 +155,7 @@ describe('Delete and undo delete', () => {
}); });
it('delete a folder with content - [C217126]', async () => { it('delete a folder with content - [C217126]', async () => {
let items = await page.dataTable.countRows(); let items = await page.dataTable.getRowsCount();
await dataTable.selectItem(folder1); await dataTable.selectItem(folder1);
await toolbar.clickMoreActionsDelete(); await toolbar.clickMoreActionsDelete();
expect(await dataTable.isItemPresent(folder1)).toBe(false, 'Item was not removed from list'); expect(await dataTable.isItemPresent(folder1)).toBe(false, 'Item was not removed from list');
@ -195,7 +195,7 @@ describe('Delete and undo delete', () => {
}); });
it('undo delete of file - [C217132]', async () => { it('undo delete of file - [C217132]', async () => {
const items = await page.dataTable.countRows(); const items = await page.dataTable.getRowsCount();
await dataTable.selectItem(file5); await dataTable.selectItem(file5);
await toolbar.clickMoreActionsDelete(); await toolbar.clickMoreActionsDelete();
@ -206,7 +206,7 @@ describe('Delete and undo delete', () => {
}); });
it('undo delete of folder with content - [C280503]', async () => { it('undo delete of folder with content - [C280503]', async () => {
const items = await page.dataTable.countRows(); const items = await page.dataTable.getRowsCount();
await dataTable.selectItem(folder6); await dataTable.selectItem(folder6);
await toolbar.clickMoreActionsDelete(); await toolbar.clickMoreActionsDelete();
@ -218,7 +218,7 @@ describe('Delete and undo delete', () => {
}); });
it('undo delete of multiple files - [C280504]', async () => { it('undo delete of multiple files - [C280504]', async () => {
const items = await page.dataTable.countRows(); const items = await page.dataTable.getRowsCount();
await dataTable.selectMultipleItems([file6, file7]); await dataTable.selectMultipleItems([file6, file7]);
await toolbar.clickMoreActionsDelete(); await toolbar.clickMoreActionsDelete();
@ -393,7 +393,7 @@ describe('Delete and undo delete', () => {
}); });
it('delete a file and check notification - [C280516]', async () => { it('delete a file and check notification - [C280516]', async () => {
let items = await page.dataTable.countRows(); let items = await page.dataTable.getRowsCount();
await dataTable.selectItem(favFile1); await dataTable.selectItem(favFile1);
await toolbar.clickMoreActionsDelete(); await toolbar.clickMoreActionsDelete();
@ -408,7 +408,7 @@ describe('Delete and undo delete', () => {
}); });
it('delete multiple files and check notification - [C280517]', async () => { it('delete multiple files and check notification - [C280517]', async () => {
let items = await page.dataTable.countRows(); let items = await page.dataTable.getRowsCount();
await dataTable.selectMultipleItems([favFile2, favFile3]); await dataTable.selectMultipleItems([favFile2, favFile3]);
await toolbar.clickMoreActionsDelete(); await toolbar.clickMoreActionsDelete();
@ -425,7 +425,7 @@ describe('Delete and undo delete', () => {
}); });
it('delete a folder with content - [C280518]', async () => { it('delete a folder with content - [C280518]', async () => {
let items = await page.dataTable.countRows(); let items = await page.dataTable.getRowsCount();
await dataTable.selectItem(favFolder1); await dataTable.selectItem(favFolder1);
await toolbar.clickMoreActionsDelete(); await toolbar.clickMoreActionsDelete();
expect(await dataTable.isItemPresent(favFolder1)).toBe(false, 'Item was not removed from list'); expect(await dataTable.isItemPresent(favFolder1)).toBe(false, 'Item was not removed from list');
@ -464,7 +464,7 @@ describe('Delete and undo delete', () => {
}); });
it('undo delete of file - [C280524]', async () => { it('undo delete of file - [C280524]', async () => {
const items = await page.dataTable.countRows(); const items = await page.dataTable.getRowsCount();
await dataTable.selectItem(favFile5); await dataTable.selectItem(favFile5);
await toolbar.clickMoreActionsDelete(); await toolbar.clickMoreActionsDelete();
@ -474,7 +474,7 @@ describe('Delete and undo delete', () => {
}); });
it('undo delete of folder with content - [C280526]', async () => { it('undo delete of folder with content - [C280526]', async () => {
const items = await page.dataTable.countRows(); const items = await page.dataTable.getRowsCount();
await dataTable.selectItem(favFolder6); await dataTable.selectItem(favFolder6);
await toolbar.clickMoreActionsDelete(); await toolbar.clickMoreActionsDelete();
@ -486,7 +486,7 @@ describe('Delete and undo delete', () => {
}); });
it('undo delete of multiple files - [C280525]', async () => { it('undo delete of multiple files - [C280525]', async () => {
const items = await page.dataTable.countRows(); const items = await page.dataTable.getRowsCount();
await dataTable.selectMultipleItems([favFile6, favFile7]); await dataTable.selectMultipleItems([favFile6, favFile7]);
await toolbar.clickMoreActionsDelete(); await toolbar.clickMoreActionsDelete();

View File

@ -42,7 +42,7 @@ describe('New menu', () => {
const loginPage = new LoginPage(); const loginPage = new LoginPage();
const page = new BrowsingPage(); const page = new BrowsingPage();
const { dataTable, sidenav } = page; const { dataTable, sidenav } = page;
const { menu } = sidenav;
beforeAll(async (done) => { beforeAll(async (done) => {
await apis.admin.people.createUser({ username }); await apis.admin.people.createUser({ username });
@ -66,107 +66,87 @@ describe('New menu', () => {
done(); done();
}); });
it('has correct actions - [C286524]', async () => { it('Actions in Personal Files - [C286524]', async () => {
await page.clickPersonalFiles(); await page.clickPersonalFiles();
await sidenav.openNewMenu(); await sidenav.openNewMenu();
expect(await sidenav.menu.isCreateFolderPresent()).toBe(true, 'Create Folder option not present'); expect(await menu.isUploadFileEnabled()).toBe(true, 'Upload File option not enabled');
expect(await sidenav.menu.isCreateLibraryPresent()).toBe(true, 'Create Library option not present'); expect(await menu.isUploadFolderEnabled()).toBe(true, 'Upload Folder option not enabled');
expect(await sidenav.menu.isUploadFilePresent()).toBe(true, 'Upload File option not present');
expect(await sidenav.menu.isUploadFolderPresent()).toBe(true, 'Upload Folder option not present');
expect(await sidenav.menu.isCreateLibraryEnabled()).toBe(true, 'Create Library is not enabled'); expect(await menu.isCreateFolderEnabled()).toBe(true, 'Create Folder option not enabled');
expect(await menu.isCreateLibraryEnabled()).toBe(true, 'Create Library option not enabled');
expect(await menu.isCreateFileFromTemplateEnabled()).toBe(true, 'Create file from template is not enabled');
}); });
it('Create folder is enabled when having enough permissions - Personal Files - [C216339]', async () => { it('Actions in File Libraries - user with enough permissions - [C280393]', async () => {
await page.clickPersonalFiles();
await page.sidenav.openNewMenu();
expect(await sidenav.menu.isCreateFolderEnabled()).toBe(true, 'Create folder is not enabled');
});
it('Create folder is enabled when having enough permissions - File Libraries - [C280393]', async () => {
await page.goToMyLibrariesAndWait();
await page.dataTable.doubleClickOnRowByName(siteUser);
await page.sidenav.openNewMenu();
expect(await sidenav.menu.isCreateFolderEnabled()).toBe(true, 'Create folder is not enabled');
});
it('Create folder is disabled when not enough permissions - [C280397]', async () => {
await page.goToMyLibrariesAndWait();
await dataTable.doubleClickOnRowByName(siteAdmin);
await sidenav.openNewMenu();
expect(await sidenav.menu.isCreateFolderEnabled()).toBe(false, 'Create folder is not disabled');
});
it('Upload File option is enabled when having enough permissions - on Personal Files - [C217145]', async () => {
await page.clickPersonalFiles();
await sidenav.openNewMenu();
expect(await sidenav.menu.isUploadFileEnabled()).toBe(true, 'Upload file is not enabled in Personal Files');
});
it('Upload File option is enabled when having permissions - on File Libraries - [C290142]', async () => {
await page.goToMyLibrariesAndWait(); await page.goToMyLibrariesAndWait();
await dataTable.doubleClickOnRowByName(siteUser); await dataTable.doubleClickOnRowByName(siteUser);
await sidenav.openNewMenu(); await sidenav.openNewMenu();
expect(await sidenav.menu.isUploadFileEnabled()).toBe(true, 'Upload file is not enabled in File Libraries'); expect(await menu.isUploadFileEnabled()).toBe(true, 'Upload file is not enabled in File Libraries');
expect(await menu.isUploadFolderEnabled()).toBe(true, 'Upload folder is not enabled in File Libraries');
expect(await menu.isCreateFolderEnabled()).toBe(true, 'Create folder is not enabled');
expect(await menu.isCreateLibraryEnabled()).toBe(true, 'Create Library option not enabled');
expect(await menu.isCreateFileFromTemplateEnabled()).toBe(true, 'Create file from template is not enabled');
}); });
it('Upload File option is disabled when user cannot create content in that location - [C217146]', async () => { it('Actions in File Libraries - user without enough permissions - [C280397]', async () => {
await page.goToMyLibrariesAndWait(); await page.goToMyLibrariesAndWait();
await dataTable.doubleClickOnRowByName(siteAdmin); await dataTable.doubleClickOnRowByName(siteAdmin);
await sidenav.openNewMenu(); await sidenav.openNewMenu();
expect(await sidenav.menu.isUploadFileEnabled()).toBe(false, 'Upload file is not disabled'); expect(await menu.isUploadFileEnabled()).toBe(false, 'Upload file is not disabled');
expect(await menu.isUploadFolderEnabled()).toBe(false, 'Upload folder is not disabled');
expect(await menu.isCreateFolderEnabled()).toBe(false, 'Create folder is not disabled');
expect(await menu.isCreateLibraryEnabled()).toBe(true, 'Create Library option not enabled');
expect(await menu.isCreateFileFromTemplateEnabled()).toBe(false, 'Create file from template is not disabled');
}); });
it('Upload Folder option is enabled when having enough permissions - on Personal Files - [C213196]', async () => { it('Enabled actions tooltips - [C216342]', async () => {
await page.clickPersonalFiles(); await page.clickPersonalFiles();
await sidenav.openNewMenu(); await sidenav.openNewMenu();
expect(await sidenav.menu.isUploadFolderEnabled()).toBe(true, 'Upload folder is not enabled in Personal Files'); let tooltip: string;
});
it('Upload Folder option is enabled when having permissions - on File Libraries - [C290146]', async () => { tooltip = await menu.getTooltipForUploadFile();
await page.goToMyLibrariesAndWait(); expect(tooltip).toContain('Select files to upload');
await dataTable.doubleClickOnRowByName(siteUser);
await sidenav.openNewMenu();
expect(await sidenav.menu.isUploadFolderEnabled()).toBe(true, 'Upload folder is not enabled in File Libraries'); tooltip = await menu.getTooltipForUploadFolder();
}); expect(tooltip).toContain('Select folders to upload');
it('Upload Folder option is disabled when user cannot create content in that location - [C213193]', async () => { tooltip = await menu.getTooltipForCreateFolder();
await page.goToMyLibrariesAndWait();
await dataTable.doubleClickOnRowByName(siteAdmin);
await sidenav.openNewMenu();
expect(await sidenav.menu.isUploadFolderEnabled()).toBe(false, 'Upload folder is not disabled');
});
it('Create folder enabled button tooltip - [C216342]', async () => {
await page.clickPersonalFiles();
await sidenav.openNewMenu();
const tooltip = await sidenav.menu.getItemTooltip('Create Folder');
expect(tooltip).toContain('Create new folder'); expect(tooltip).toContain('Create new folder');
tooltip = await menu.getTooltipForCreateLibrary();
expect(tooltip).toContain('Create a new File Library');
tooltip = await menu.getTooltipForCreateFileFromTemplate();
expect(tooltip).toContain('Create file from template');
}); });
it('Create folder disabled button tooltip - [C280398]', async () => { it('Disabled actions tooltips - [C280398]', async () => {
await page.goToMyLibrariesAndWait(); await page.goToMyLibrariesAndWait();
await dataTable.doubleClickOnRowByName(siteAdmin); await dataTable.doubleClickOnRowByName(siteAdmin);
await sidenav.openNewMenu(); await sidenav.openNewMenu();
const tooltip = await sidenav.menu.getItemTooltip('Create Folder'); let tooltip: string;
expect(tooltip).toContain(`Folders cannot be created whilst viewing the current items`);
});
it('Create Library button tooltip - [C286526]', async () => { tooltip = await menu.getTooltipForUploadFile();
await sidenav.openNewMenu(); expect(tooltip).toContain('Files cannot be uploaded whilst viewing the current items');
const tooltip = await sidenav.menu.getItemTooltip('Create Library'); tooltip = await menu.getTooltipForUploadFolder();
expect(tooltip).toContain('Create a new File Library'); expect(tooltip).toContain('Folders cannot be uploaded whilst viewing the current items');
tooltip = await menu.getTooltipForCreateFolder();
expect(tooltip).toContain('Folders cannot be created whilst viewing the current items');
tooltip = await menu.getTooltipForCreateFileFromTemplate();
expect(tooltip).toContain('Files cannot be created whilst viewing the current items');
}); });
}); });

View File

@ -50,51 +50,51 @@ describe('Empty list views', () => {
it('empty Personal Files - [C280131]', async () => { it('empty Personal Files - [C280131]', async () => {
await page.clickPersonalFiles(); await page.clickPersonalFiles();
expect(await dataTable.isEmptyList()).toBe(true, 'list is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'list is not empty');
expect(await dataTable.getEmptyDragAndDropText()).toContain('Drag and drop'); expect(await dataTable.getEmptyDragAndDropText()).toContain('Drag and drop');
}); });
it('empty My Libraries - [C217099]', async () => { it('empty My Libraries - [C217099]', async () => {
await page.goToMyLibraries(); await page.goToMyLibraries();
expect(await dataTable.isEmptyList()).toBe(true, 'list is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'list is not empty');
expect(await dataTable.getEmptyStateTitle()).toContain(`You aren't a member of any File Libraries yet`); expect(await dataTable.getEmptyStateTitle()).toContain(`You aren't a member of any File Libraries yet`);
expect(await dataTable.getEmptyStateSubtitle()).toContain('Join libraries to upload, view, and share files.'); expect(await dataTable.getEmptyStateSubtitle()).toContain('Join libraries to upload, view, and share files.');
}); });
it('empty Favorite Libraries - [C289911]', async () => { it('empty Favorite Libraries - [C289911]', async () => {
await page.goToFavoriteLibraries(); await page.goToFavoriteLibraries();
expect(await dataTable.isEmptyList()).toBe(true, 'list is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'list is not empty');
expect(await dataTable.getEmptyStateTitle()).toContain(`No Favorite Libraries`); expect(await dataTable.getEmptyStateTitle()).toContain(`No Favorite Libraries`);
expect(await dataTable.getEmptyStateSubtitle()).toContain('Favorite a library that you want to find easily later.'); expect(await dataTable.getEmptyStateSubtitle()).toContain('Favorite a library that you want to find easily later.');
}); });
it('empty Shared Files - [C280132]', async () => { it('empty Shared Files - [C280132]', async () => {
await page.clickSharedFiles(); await page.clickSharedFiles();
expect(await dataTable.isEmptyList()).toBe(true, 'list is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'list is not empty');
expect(await dataTable.getEmptyStateTitle()).toContain('No shared files or folders'); expect(await dataTable.getEmptyStateTitle()).toContain('No shared files or folders');
expect(await dataTable.getEmptyStateSubtitle()).toContain('Items you share using the Share option are shown here.'); expect(await dataTable.getEmptyStateSubtitle()).toContain('Items you share using the Share option are shown here.');
}); });
it('empty Recent Files - [C213169]', async () => { it('empty Recent Files - [C213169]', async () => {
await page.clickRecentFiles(); await page.clickRecentFiles();
expect(await dataTable.isEmptyList()).toBe(true, 'list is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'list is not empty');
expect(await dataTable.getEmptyStateTitle()).toContain('No recent files'); expect(await dataTable.getEmptyStateTitle()).toContain('No recent files');
expect(await dataTable.getEmptyStateSubtitle()).toContain('Items you uploaded or edited in the last 30 days are shown here.'); expect(await dataTable.getEmptyStateSubtitle()).toContain('Items you uploaded or edited in the last 30 days are shown here.');
}); });
it('empty Favorites - [C280133]', async () => { it('empty Favorites - [C280133]', async () => {
await page.clickFavorites(); await page.clickFavorites();
expect(await dataTable.isEmptyList()).toBe(true, 'list is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'list is not empty');
expect(await dataTable.getEmptyStateTitle()).toContain('No favorite files or folders'); expect(await dataTable.getEmptyStateTitle()).toContain('No favorite files or folders');
expect(await dataTable.getEmptyStateSubtitle()).toContain('Favorite items that you want to easily find later.'); expect(await dataTable.getEmptyStateSubtitle()).toContain('Favorite items that you want to easily find later.');
}); });
it('empty Trash - [C280134]', async () => { it('empty Trash - [C280134]', async () => {
await page.clickTrash(); await page.clickTrash();
expect(await dataTable.isEmptyList()).toBe(true, 'list is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'list is not empty');
expect(await dataTable.getEmptyStateTitle()).toContain('Trash is empty'); expect(await dataTable.getEmptyStateTitle()).toContain('Trash is empty');
expect(await dataTable.getEmptyStateText()).toContain('Items you delete are moved to the Trash.'); expect(await dataTable.getEmptyListText()).toContain('Items you delete are moved to the Trash.');
expect(await dataTable.getEmptyStateText()).toContain('Empty Trash to permanently delete items.'); expect(await dataTable.getEmptyListText()).toContain('Empty Trash to permanently delete items.');
}); });
it('Favorites - pagination controls not displayed - [C280111]', async () => { it('Favorites - pagination controls not displayed - [C280111]', async () => {
@ -197,7 +197,7 @@ describe('Empty list views', () => {
await searchInput.searchFor('qwertyuiop'); await searchInput.searchFor('qwertyuiop');
await dataTable.waitForBody(); await dataTable.waitForBody();
expect(await dataTable.isEmptyList()).toBe(true, 'list is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'list is not empty');
expect(await dataTable.getEmptySearchResultsText()).toContain('Your search returned 0 results'); expect(await dataTable.getEmptySearchResultsText()).toContain('Your search returned 0 results');
}); });
@ -208,7 +208,7 @@ describe('Empty list views', () => {
await searchInput.searchFor('qwertyuiop'); await searchInput.searchFor('qwertyuiop');
await dataTable.waitForBody(); await dataTable.waitForBody();
expect(await dataTable.isEmptyList()).toBe(true, 'list is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'list is not empty');
expect(await dataTable.getEmptySearchResultsText()).toContain('Your search returned 0 results'); expect(await dataTable.getEmptySearchResultsText()).toContain('Your search returned 0 results');
}); });
}); });

View File

@ -95,7 +95,7 @@ describe('Favorites', () => {
}); });
it('displays the favorite files and folders - [C213226]', async () => { it('displays the favorite files and folders - [C213226]', async () => {
expect(await dataTable.countRows()).toEqual(4, 'Incorrect number of items displayed'); expect(await dataTable.getRowsCount()).toEqual(4, 'Incorrect number of items displayed');
expect(await dataTable.isItemPresent(fileName1)).toBe(true, `${fileName1} not displayed`); expect(await dataTable.isItemPresent(fileName1)).toBe(true, `${fileName1} not displayed`);
expect(await dataTable.isItemPresent(fileName2)).toBe(true, `${fileName2} not displayed`); expect(await dataTable.isItemPresent(fileName2)).toBe(true, `${fileName2} not displayed`);
expect(await dataTable.isItemPresent(favFolderName)).toBe(true, `${favFolderName} not displayed`); expect(await dataTable.isItemPresent(favFolderName)).toBe(true, `${favFolderName} not displayed`);

View File

@ -110,7 +110,7 @@ describe('File Libraries', () => {
}); });
it('User can see only the sites he is a member of - [C280501]', async () => { it('User can see only the sites he is a member of - [C280501]', async () => {
const sitesCount = await dataTable.countRows(); const sitesCount = await dataTable.getRowsCount();
expect(sitesCount).toEqual(10, 'Incorrect number of sites displayed'); expect(sitesCount).toEqual(10, 'Incorrect number of sites displayed');
expect(await dataTable.isItemPresent(adminSite5)).toBe(false, `${adminSite5} should not appear in the list`); expect(await dataTable.isItemPresent(adminSite5)).toBe(false, `${adminSite5} should not appear in the list`);
@ -150,10 +150,8 @@ describe('File Libraries', () => {
`${siteName} (${siteId1})`, `${siteName} (${siteId1})`,
`${siteName} (${siteId2})` `${siteName} (${siteId2})`
]; ];
const cells = await dataTable.getCellsContainingName(siteName); const actualSites = await dataTable.getCellsContainingName(siteName);
const expectedJSON = JSON.stringify(expectedSites.sort()); expect(actualSites.sort()).toEqual(expectedSites.sort());
const actualJSON = JSON.stringify(cells.sort());
expect(actualJSON).toEqual(expectedJSON);
}); });
it('Tooltip for sites without description - [C217096]', async () => { it('Tooltip for sites without description - [C217096]', async () => {
@ -181,7 +179,7 @@ describe('File Libraries', () => {
}); });
it('User can see only his favorite sites - [C289897]', async () => { it('User can see only his favorite sites - [C289897]', async () => {
const sitesCount = await dataTable.countRows(); const sitesCount = await dataTable.getRowsCount();
expect(sitesCount).toEqual(9, 'Incorrect number of sites displayed'); expect(sitesCount).toEqual(9, 'Incorrect number of sites displayed');
expect(await dataTable.isItemPresent(adminSite6)).toBe(false, `${adminSite6} should not appear`); expect(await dataTable.isItemPresent(adminSite6)).toBe(false, `${adminSite6} should not appear`);
@ -221,10 +219,8 @@ describe('File Libraries', () => {
`${siteName} (${siteId1})`, `${siteName} (${siteId1})`,
`${siteName} (${siteId2})` `${siteName} (${siteId2})`
]; ];
const cells = await dataTable.getCellsContainingName(siteName); const actualSites = await dataTable.getCellsContainingName(siteName);
const expectedJSON = JSON.stringify(expectedSites.sort()); expect(actualSites.sort()).toEqual(expectedSites.sort());
const actualJSON = JSON.stringify(cells.sort());
expect(actualJSON).toEqual(expectedJSON);
}); });
it('Tooltip for sites without description - [C289894]', async () => { it('Tooltip for sites without description - [C289894]', async () => {

View File

@ -80,26 +80,26 @@ describe('Special permissions', () => {
it('on Recent Files - [C213173]', async () => { it('on Recent Files - [C213173]', async () => {
await page.clickRecentFilesAndWait(); await page.clickRecentFilesAndWait();
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items');
await apis.admin.sites.deleteSiteMember(sitePrivate, username); await apis.admin.sites.deleteSiteMember(sitePrivate, username);
await page.refresh(); await page.refresh();
expect(await dataTable.isEmptyList()).toBe(true, 'Items are still displayed'); expect(await dataTable.isEmpty()).toBe(true, 'Items are still displayed');
}); });
it('on Favorites - [C213227]', async () => { it('on Favorites - [C213227]', async () => {
await page.clickFavoritesAndWait(); await page.clickFavoritesAndWait();
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items');
await apis.admin.sites.deleteSiteMember(sitePrivate, username); await apis.admin.sites.deleteSiteMember(sitePrivate, username);
await page.refresh(); await page.refresh();
expect(await dataTable.isEmptyList()).toBe(true, 'Items are still displayed'); expect(await dataTable.isEmpty()).toBe(true, 'Items are still displayed');
}); });
it('on Shared Files - [C213116]', async () => { it('on Shared Files - [C213116]', async () => {
await page.clickSharedFilesAndWait(); await page.clickSharedFilesAndWait();
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items');
await apis.admin.sites.deleteSiteMember(sitePrivate, username); await apis.admin.sites.deleteSiteMember(sitePrivate, username);
await page.refresh(); await page.refresh();
expect(await dataTable.isEmptyList()).toBe(true, 'Items are still displayed'); expect(await dataTable.isEmpty()).toBe(true, 'Items are still displayed');
}); });
it('on Search Results - [C290122]', async () => { it('on Search Results - [C290122]', async () => {
@ -147,19 +147,19 @@ describe('Special permissions', () => {
it(`on Recent Files - [C213178]`, async () => { it(`on Recent Files - [C213178]`, async () => {
await page.clickRecentFilesAndWait(); await page.clickRecentFilesAndWait();
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items');
expect(await dataTable.getItemLocation(fileName)).toEqual('Unknown'); expect(await dataTable.getItemLocation(fileName)).toEqual('Unknown');
}); });
it(`on Favorites - [C213672]`, async () => { it(`on Favorites - [C213672]`, async () => {
await page.clickFavoritesAndWait(); await page.clickFavoritesAndWait();
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items');
expect(await dataTable.getItemLocation(fileName)).toEqual('Unknown'); expect(await dataTable.getItemLocation(fileName)).toEqual('Unknown');
}); });
it(`on Shared Files - [C213668]`, async () => { it(`on Shared Files - [C213668]`, async () => {
await page.clickSharedFilesAndWait(); await page.clickSharedFilesAndWait();
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items');
expect(await dataTable.getItemLocation(fileName)).toEqual('Unknown'); expect(await dataTable.getItemLocation(fileName)).toEqual('Unknown');
}); });

View File

@ -93,7 +93,7 @@ describe('Recent Files', () => {
}); });
it('displays the files added by the current user in the last 30 days - [C213170]', async () => { it('displays the files added by the current user in the last 30 days - [C213170]', async () => {
expect(await dataTable.countRows()).toEqual(3, 'Incorrect number of files displayed'); expect(await dataTable.getRowsCount()).toEqual(3, 'Incorrect number of files displayed');
expect(await dataTable.isItemPresent(fileName1)).toBe(true, `${fileName1} not displayed`); expect(await dataTable.isItemPresent(fileName1)).toBe(true, `${fileName1} not displayed`);
expect(await dataTable.isItemPresent(fileName2)).toBe(true, `${fileName2} not displayed`); expect(await dataTable.isItemPresent(fileName2)).toBe(true, `${fileName2} not displayed`);
expect(await dataTable.isItemPresent(fileSite)).toBe(true, `${fileSite} not displayed`); expect(await dataTable.isItemPresent(fileSite)).toBe(true, `${fileSite} not displayed`);

View File

@ -106,7 +106,7 @@ describe('Trash', () => {
}); });
it('displays the files and folders deleted by everyone - [C280493]', async () => { it('displays the files and folders deleted by everyone - [C280493]', async () => {
expect(await dataTable.countRows()).toEqual(8, 'Incorrect number of deleted items displayed'); expect(await dataTable.getRowsCount()).toEqual(8, 'Incorrect number of deleted items displayed');
expect(await dataTable.isItemPresent(fileAdmin)).toBe(true, `${fileAdmin} not displayed`); expect(await dataTable.isItemPresent(fileAdmin)).toBe(true, `${fileAdmin} not displayed`);
expect(await dataTable.isItemPresent(folderAdmin)).toBe(true, `${folderAdmin} not displayed`); expect(await dataTable.isItemPresent(folderAdmin)).toBe(true, `${folderAdmin} not displayed`);
@ -135,7 +135,7 @@ describe('Trash', () => {
}); });
it('displays the files and folders deleted by the user - [C213218]', async () => { it('displays the files and folders deleted by the user - [C213218]', async () => {
expect(await dataTable.countRows()).toEqual(6, 'Incorrect number of deleted items displayed'); expect(await dataTable.getRowsCount()).toEqual(6, 'Incorrect number of deleted items displayed');
expect(await dataTable.isItemPresent(fileSite)).toBe(true, `${fileSite} not displayed`); expect(await dataTable.isItemPresent(fileSite)).toBe(true, `${fileSite} not displayed`);
expect(await dataTable.isItemPresent(fileUser)).toBe(true, `${fileUser} not displayed`); expect(await dataTable.isItemPresent(fileUser)).toBe(true, `${fileUser} not displayed`);

View File

@ -155,7 +155,7 @@ describe('Pagination on multiple pages on Favorites', () => {
it('Next button is disabled on last page - [C280118]', async () => { it('Next button is disabled on last page - [C280118]', async () => {
await pagination.openCurrentPageMenu(); await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5); await pagination.menu.clickNthItem(5);
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items on the last page');
expect(await pagination.getCurrentPage()).toContain('Page 5'); expect(await pagination.getCurrentPage()).toContain('Page 5');
expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page');
}); });

View File

@ -151,7 +151,7 @@ describe('Pagination on multiple pages', () => {
it('Next button is disabled on last page - [C280091]', async () => { it('Next button is disabled on last page - [C280091]', async () => {
await pagination.openCurrentPageMenu(); await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5); await pagination.menu.clickNthItem(5);
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items on the last page');
expect(await pagination.getCurrentPage()).toContain('Page 5'); expect(await pagination.getCurrentPage()).toContain('Page 5');
expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page');
}); });
@ -252,7 +252,7 @@ describe('Pagination on multiple pages', () => {
it('Next button is disabled on last page - [C291880]', async () => { it('Next button is disabled on last page - [C291880]', async () => {
await pagination.openCurrentPageMenu(); await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5); await pagination.menu.clickNthItem(5);
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items on the last page');
expect(await pagination.getCurrentPage()).toContain('Page 5'); expect(await pagination.getCurrentPage()).toContain('Page 5');
expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page');
}); });

View File

@ -153,7 +153,7 @@ describe('Pagination on multiple pages on Personal Files', () => {
it('Next button is disabled on last page - [C280082]', async () => { it('Next button is disabled on last page - [C280082]', async () => {
await pagination.openCurrentPageMenu(); await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5); await pagination.menu.clickNthItem(5);
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items on the last page');
expect(await pagination.getCurrentPage()).toContain('Page 5'); expect(await pagination.getCurrentPage()).toContain('Page 5');
expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page');
}); });

View File

@ -152,7 +152,7 @@ describe('Pagination on multiple pages on Recent Files', () => {
it('Next button is disabled on last page - [C280109]', async () => { it('Next button is disabled on last page - [C280109]', async () => {
await pagination.openCurrentPageMenu(); await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5); await pagination.menu.clickNthItem(5);
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items on the last page');
expect(await pagination.getCurrentPage()).toContain('Page 5'); expect(await pagination.getCurrentPage()).toContain('Page 5');
expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page');
}); });

View File

@ -151,7 +151,7 @@ describe('Pagination on multiple pages on Search Results', () => {
it('Next button is disabled on last page - [C290130]', async () => { it('Next button is disabled on last page - [C290130]', async () => {
await pagination.openCurrentPageMenu(); await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5); await pagination.menu.clickNthItem(5);
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items on the last page');
expect(await pagination.getCurrentPage()).toContain('Page 5'); expect(await pagination.getCurrentPage()).toContain('Page 5');
expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page');
}); });

View File

@ -155,7 +155,7 @@ describe('Pagination on multiple pages on Shared Files', () => {
it('Next button is disabled on last page - [C280100]', async () => { it('Next button is disabled on last page - [C280100]', async () => {
await pagination.openCurrentPageMenu(); await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5); await pagination.menu.clickNthItem(5);
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items on the last page');
expect(await pagination.getCurrentPage()).toContain('Page 5'); expect(await pagination.getCurrentPage()).toContain('Page 5');
expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page');
}); });

View File

@ -151,7 +151,7 @@ describe('Pagination on multiple pages on Trash', () => {
it('Next button is disabled on last page - [C280127]', async () => { it('Next button is disabled on last page - [C280127]', async () => {
await pagination.openCurrentPageMenu(); await pagination.openCurrentPageMenu();
await pagination.menu.clickNthItem(5); await pagination.menu.clickNthItem(5);
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page'); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items on the last page');
expect(await pagination.getCurrentPage()).toContain('Page 5'); expect(await pagination.getCurrentPage()).toContain('Page 5');
expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page');
}); });

View File

@ -155,7 +155,7 @@ describe('Search filters', () => {
await sizeFilter.expandPanel(); await sizeFilter.expandPanel();
await sizeFilter.checkSizeHuge(); await sizeFilter.checkSizeHuge();
expect(await dataTable.isEmptyList()).toBe(true, 'list is not empty'); expect(await dataTable.isEmpty()).toBe(true, 'list is not empty');
}); });
it('Filter by multiple size categories - [C279203]', async () => { it('Filter by multiple size categories - [C279203]', async () => {

View File

@ -225,13 +225,12 @@ describe('Viewer actions', () => {
}); });
it('Upload new version action when node is locked - [MNT-21058]', async () => { it('Upload new version action when node is locked - [MNT-21058]', async () => {
await dataTable.doubleClickOnRowByName(fileForUploadNewVersion2); await dataTable.doubleClickOnRowByName(fileForUploadNewVersion2);
await viewer.waitForViewerToOpen(); await viewer.waitForViewerToOpen();
await toolbar.openMoreMenu(); await toolbar.openMoreMenu();
expect(await toolbar.menu.isCancelEditingActionPresent()).toBe(true, `'Cancel Editing' button should be shown`); expect(await toolbar.menu.isCancelEditingPresent()).toBe(true, `'Cancel Editing' button should be shown`);
expect(await toolbar.menu.isEditOfflineActionPresent()).toBe(false, `'Edit Offline' shouldn't be shown`); expect(await toolbar.menu.isEditOfflinePresent()).toBe(false, `'Edit Offline' shouldn't be shown`);
await toolbar.menu.clickMenuItem('Upload New Version'); await toolbar.menu.clickMenuItem('Upload New Version');
await Utils.uploadFileNewVersion(docxFile); await Utils.uploadFileNewVersion(docxFile);
@ -240,8 +239,8 @@ describe('Viewer actions', () => {
await uploadNewVersionDialog.clickUpload(); await uploadNewVersionDialog.clickUpload();
await toolbar.openMoreMenu(); await toolbar.openMoreMenu();
expect(await toolbar.menu.isCancelEditingActionPresent()).toBe(false, `'Cancel Editing' button shouldn't be shown`); expect(await toolbar.menu.isCancelEditingPresent()).toBe(false, `'Cancel Editing' button shouldn't be shown`);
expect(await toolbar.menu.isEditOfflineActionPresent()).toBe(true, `'Edit Offline' should be shown`); expect(await toolbar.menu.isEditOfflinePresent()).toBe(true, `'Edit Offline' should be shown`);
}); });
it('Full screen action - [C279282]', async () => { it('Full screen action - [C279282]', async () => {

84
e2e/utilities/admin-actions.ts Executable file
View File

@ -0,0 +1,84 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2019 Alfresco Software Limited
*
* 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 <http://www.gnu.org/licenses/>.
*/
import { RepoClient, NodeContentTree } from './repo-client/repo-client';
import { PersonEntry, NodeEntry } from '@alfresco/js-api';
import { PersonModel } from './repo-client/apis/people/people-api-models';
export class AdminActions {
private adminApi: RepoClient;
constructor() {
this.adminApi = new RepoClient();
}
async getDataDictionaryId(): Promise<string> {
return await this.adminApi.nodes.getNodeIdFromParent('Data Dictionary', '-root-');
}
async getNodeTemplatesFolderId(): Promise<string> {
return await this.adminApi.nodes.getNodeIdFromParent('Node Templates', await this.getDataDictionaryId());
}
async createUser(user: PersonModel): Promise<PersonEntry> {
return await this.adminApi.people.createUser(user);
}
async createNodeTemplate(name: string, title: string = '', description: string = '', author: string = ''): Promise<NodeEntry> {
const templatesRootFolderId: string = await this.getNodeTemplatesFolderId();
return await this.adminApi.nodes.createFile(name, templatesRootFolderId, title, description, author);
}
async createNodeTemplatesHierarchy(hierarchy: NodeContentTree): Promise<any> {
return await this.adminApi.nodes.createContent(hierarchy, `Data Dictionary/Node Templates`);
}
async removeUserAccessOnNode(nodeName: string): Promise<NodeEntry> {
const templatesRootFolderId = await this.getNodeTemplatesFolderId();
const nodeId: string = await this.adminApi.nodes.getNodeIdFromParent(nodeName, templatesRootFolderId);
return await this.adminApi.nodes.setInheritPermissions(nodeId, false);
}
async cleanNodeTemplatesFolder(): Promise<void> {
return await this.adminApi.nodes.deleteNodeChildren(await this.getNodeTemplatesFolderId());
}
async createLinkToFileId(originalFileId: string, destinationParentId: string): Promise<NodeEntry> {
return await this.adminApi.nodes.createNodeLink(originalFileId, destinationParentId);
}
async createLinkToFileName(originalFileName: string, originalFileParentId: string, destinationParentId?: string): Promise<NodeEntry> {
if (!destinationParentId) {
destinationParentId = originalFileParentId
};
const nodeId = await this.adminApi.nodes.getNodeIdFromParent(originalFileName, originalFileParentId);
return await this.createLinkToFileId(nodeId, destinationParentId);
}
}

View File

@ -36,7 +36,7 @@ export class NodesApi extends RepoApi {
super(username, password); super(username, password);
} }
async getNodeByPath(relativePath: string = '/'): Promise<NodeEntry> { async getNodeByPath(relativePath: string = '/'): Promise<NodeEntry|null> {
try { try {
await this.apiAuth(); await this.apiAuth();
return await this.nodesApi.getNode('-my-', { relativePath }); return await this.nodesApi.getNode('-my-', { relativePath });
@ -46,7 +46,7 @@ export class NodesApi extends RepoApi {
} }
} }
async getNodeById(id: string): Promise<NodeEntry> { async getNodeById(id: string): Promise<NodeEntry|null> {
try { try {
await this.apiAuth(); await this.apiAuth();
const node = await this.nodesApi.getNode(id); const node = await this.nodesApi.getNode(id);
@ -77,7 +77,17 @@ export class NodesApi extends RepoApi {
} }
} }
async getNodeProperty(nodeId: string, property: string): Promise<any> { async getNodeTitle(name: string, parentId: string): Promise<string> {
try {
const children = (await this.getNodeChildren(parentId)).list.entries;
return children.find(elem => elem.entry.name === name).entry.properties['cm:title'] || '';
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getNodeTitle.name}`, error);
return '';
}
}
async getNodeProperty(nodeId: string, property: string): Promise<string> {
try { try {
const node = await this.getNodeById(nodeId); const node = await this.getNodeById(nodeId);
return (node.entry.properties && node.entry.properties[property]) || ''; return (node.entry.properties && node.entry.properties[property]) || '';
@ -179,7 +189,7 @@ export class NodesApi extends RepoApi {
} }
} }
async getNodeChildren(nodeId: string): Promise<NodeChildAssociationPaging> { async getNodeChildren(nodeId: string): Promise<NodeChildAssociationPaging|null> {
try { try {
const opts = { const opts = {
include: [ 'properties' ] include: [ 'properties' ]
@ -202,7 +212,7 @@ export class NodesApi extends RepoApi {
} }
} }
async createImageNode(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise<any> { async createImageNode(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise<NodeEntry|null> {
const imageProps = { const imageProps = {
'exif:pixelXDimension': 1000, 'exif:pixelXDimension': 1000,
'exif:pixelYDimension': 1200 'exif:pixelYDimension': 1200
@ -211,10 +221,30 @@ export class NodesApi extends RepoApi {
return await this.createNode('cm:content', name, parentId, title, description, imageProps); return await this.createNode('cm:content', name, parentId, title, description, imageProps);
} catch (error) { } catch (error) {
this.handleError(`${this.constructor.name} ${this.createImageNode.name}`, error); this.handleError(`${this.constructor.name} ${this.createImageNode.name}`, error);
return null;
} }
} }
async createNode(nodeType: string, name: string, parentId: string = '-my-', title: string = '', description: string = '', imageProps: any = null, author: string = '', majorVersion: boolean = true): Promise<any> { async createNodeLink(originalNodeId: string, destinationId: string): Promise<NodeEntry|null> {
const name = (await this.getNodeById(originalNodeId)).entry.name;
const nodeBody = {
name: `Link to ${name}.url`,
nodeType: 'app:filelink',
properties: {
'cm:destination': originalNodeId
}
}
try {
await this.apiAuth();
return await this.nodesApi.createNode(destinationId, nodeBody);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.createNode.name}`, error);
return null;
}
}
async createNode(nodeType: string, name: string, parentId: string = '-my-', title: string = '', description: string = '', imageProps: any = null, author: string = '', majorVersion: boolean = true): Promise<NodeEntry|null> {
const nodeBody = { const nodeBody = {
name, name,
nodeType, nodeType,
@ -234,34 +264,38 @@ export class NodesApi extends RepoApi {
return await this.nodesApi.createNode(parentId, nodeBody, { majorVersion }); return await this.nodesApi.createNode(parentId, nodeBody, { majorVersion });
} catch (error) { } catch (error) {
this.handleError(`${this.constructor.name} ${this.createNode.name}`, error); this.handleError(`${this.constructor.name} ${this.createNode.name}`, error);
return null;
} }
} }
async createFile(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = '', majorVersion: boolean = true): Promise<any> { async createFile(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = '', majorVersion: boolean = true): Promise<NodeEntry> {
try { try {
return await this.createNode('cm:content', name, parentId, title, description, null, author, majorVersion); return await this.createNode('cm:content', name, parentId, title, description, null, author, majorVersion);
} catch (error) { } catch (error) {
this.handleError(`${this.constructor.name} ${this.createFile.name}`, error); this.handleError(`${this.constructor.name} ${this.createFile.name}`, error);
return null;
} }
} }
async createImage(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise<any> { async createImage(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise<NodeEntry|null> {
try { try {
return await this.createImageNode(name, parentId, title, description); return await this.createImageNode(name, parentId, title, description);
} catch (error) { } catch (error) {
this.handleError(`${this.constructor.name} ${this.createImage.name}`, error); this.handleError(`${this.constructor.name} ${this.createImage.name}`, error);
return null;
} }
} }
async createFolder(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = ''): Promise<any> { async createFolder(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = ''): Promise<NodeEntry|null> {
try { try {
return await this.createNode('cm:folder', name, parentId, title, description, null, author); return await this.createNode('cm:folder', name, parentId, title, description, null, author);
} catch (error) { } catch (error) {
this.handleError(`${this.constructor.name} ${this.createFolder.name}`, error); this.handleError(`${this.constructor.name} ${this.createFolder.name}`, error);
return null;
} }
} }
async createChildren(data: NodeBodyCreate[]): Promise<any> { async createChildren(data: NodeBodyCreate[]): Promise<NodeEntry|any> {
try { try {
await this.apiAuth(); await this.apiAuth();
return await this.nodesApi.createNode('-my-', <any>data); return await this.nodesApi.createNode('-my-', <any>data);
@ -270,7 +304,7 @@ export class NodesApi extends RepoApi {
} }
} }
async createContent(content: NodeContentTree, relativePath: string = '/'): Promise<any> { async createContent(content: NodeContentTree, relativePath: string = '/'): Promise<NodeEntry|any> {
try { try {
return await this.createChildren(flattenNodeContentTree(content, relativePath)); return await this.createChildren(flattenNodeContentTree(content, relativePath));
} catch (error) { } catch (error) {
@ -278,7 +312,7 @@ export class NodesApi extends RepoApi {
} }
} }
async createFolders(names: string[], relativePath: string = '/'): Promise<any> { async createFolders(names: string[], relativePath: string = '/'): Promise<NodeEntry|any> {
try { try {
return await this.createContent({ folders: names }, relativePath); return await this.createContent({ folders: names }, relativePath);
} catch (error) { } catch (error) {
@ -286,7 +320,7 @@ export class NodesApi extends RepoApi {
} }
} }
async createFiles(names: string[], relativePath: string = '/'): Promise<any> { async createFiles(names: string[], relativePath: string = '/'): Promise<NodeEntry|any> {
try { try {
return await this.createContent({ files: names }, relativePath); return await this.createContent({ files: names }, relativePath);
} catch (error) { } catch (error) {
@ -325,6 +359,22 @@ export class NodesApi extends RepoApi {
} }
// node permissions // node permissions
async setInheritPermissions(nodeId: string, inheritPermissions: boolean): Promise<NodeEntry|null> {
const data = {
permissions: {
isInheritanceEnabled: inheritPermissions
}
};
try {
await this.apiAuth();
return await this.nodesApi.updateNode(nodeId, data);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.setGranularPermission.name}`, error);
return null;
}
}
async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string): Promise<NodeEntry|null> { async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string): Promise<NodeEntry|null> {
const data = { const data = {
permissions: { permissions: {
@ -372,7 +422,7 @@ export class NodesApi extends RepoApi {
} }
} }
async getLockType(nodeId: string): Promise<any> { async getLockType(nodeId: string): Promise<string> {
try { try {
const lockType = await this.getNodeProperty(nodeId, 'cm:lockType'); const lockType = await this.getNodeProperty(nodeId, 'cm:lockType');
return lockType || ''; return lockType || '';
@ -382,7 +432,7 @@ export class NodesApi extends RepoApi {
} }
} }
async getLockOwner(nodeId: string): Promise<any> { async getLockOwner(nodeId: string): Promise<string> {
try { try {
const lockOwner = await this.getNodeProperty(nodeId, 'cm:lockOwner'); const lockOwner = await this.getNodeProperty(nodeId, 'cm:lockOwner');
return lockOwner || ''; return lockOwner || '';

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { browser, protractor, promise, ElementFinder, ExpectedConditions as EC, by } from 'protractor'; import { browser, protractor, ElementFinder, ExpectedConditions as EC, by, logging } from 'protractor';
import { BROWSER_WAIT_TIMEOUT, E2E_ROOT_PATH, EXTENSIBILITY_CONFIGS } from '../configs'; import { BROWSER_WAIT_TIMEOUT, E2E_ROOT_PATH, EXTENSIBILITY_CONFIGS } from '../configs';
const path = require('path'); const path = require('path');
@ -41,35 +41,35 @@ export class Utils {
lighter track cinema tread tick climate lend summit singer radical flower visual negotiation promises cooperative live'; lighter track cinema tread tick climate lend summit singer radical flower visual negotiation promises cooperative live';
// generate a random value // generate a random value
static random() { static random(): string {
return Math.random().toString(36).substring(5, 10).toLowerCase(); return Math.random().toString(36).substring(5, 10).toLowerCase();
} }
// local storage // local storage
static clearLocalStorage(): promise.Promise<any> { static async clearLocalStorage(): Promise<void> {
return browser.executeScript('window.localStorage.clear();'); await browser.executeScript('window.localStorage.clear();');
} }
// session storage // session storage
static clearSessionStorage(): promise.Promise<any> { static async clearSessionStorage(): Promise<void> {
return browser.executeScript('window.sessionStorage.clear();'); await browser.executeScript('window.sessionStorage.clear();');
} }
static getSessionStorage() { static async getSessionStorage(): Promise<any> {
return browser.executeScript('return window.sessionStorage.getItem("app.extension.config");'); return await browser.executeScript('return window.sessionStorage.getItem("app.extension.config");');
} }
static setSessionStorageFromConfig(configFileName: string) { static async setSessionStorageFromConfig(configFileName: string): Promise<void> {
const configFile = `${E2E_ROOT_PATH}/resources/extensibility-configs/${configFileName}`; const configFile = `${E2E_ROOT_PATH}/resources/extensibility-configs/${configFileName}`;
const fileContent = JSON.stringify(fs.readFileSync(configFile, { encoding: 'utf8' })); const fileContent = JSON.stringify(fs.readFileSync(configFile, { encoding: 'utf8' }));
return browser.executeScript(`window.sessionStorage.setItem('app.extension.config', ${fileContent});`); await browser.executeScript(`window.sessionStorage.setItem('app.extension.config', ${fileContent});`);
} }
static resetExtensionConfig() { static async resetExtensionConfig(): Promise<void> {
const defConfig = `${E2E_ROOT_PATH}/resources/extensibility-configs/${EXTENSIBILITY_CONFIGS.DEFAULT_EXTENSIONS_CONFIG}`; const defConfig = `${E2E_ROOT_PATH}/resources/extensibility-configs/${EXTENSIBILITY_CONFIGS.DEFAULT_EXTENSIONS_CONFIG}`;
return this.setSessionStorageFromConfig(defConfig); await this.setSessionStorageFromConfig(defConfig);
} }
static retryCall(fn: () => Promise<any>, retry: number = 30, delay: number = 1000): Promise<any> { static retryCall(fn: () => Promise<any>, retry: number = 30, delay: number = 1000): Promise<any> {
@ -80,11 +80,11 @@ export class Utils {
return run(retry); return run(retry);
} }
static async waitUntilElementClickable(element: ElementFinder) { static async waitUntilElementClickable(element: ElementFinder): Promise<void> {
await browser.wait(EC.elementToBeClickable(element), BROWSER_WAIT_TIMEOUT).catch(Error); await browser.wait(EC.elementToBeClickable(element), BROWSER_WAIT_TIMEOUT).catch(Error);
} }
static async typeInField(elem: ElementFinder, value: string) { static async typeInField(elem: ElementFinder, value: string): Promise<void> {
for (let i = 0; i < value.length; i++) { for (let i = 0; i < value.length; i++) {
const c = value.charAt(i); const c = value.charAt(i);
await elem.sendKeys(c); await elem.sendKeys(c);
@ -99,7 +99,7 @@ export class Utils {
} }
} }
static async fileExistsOnOS(fileName: string, folderName: string = '', subFolderName: string = '') { static async fileExistsOnOS(fileName: string, folderName: string = '', subFolderName: string = ''): Promise<any> {
const config = await browser.getProcessedConfig(); const config = await browser.getProcessedConfig();
const filePath = path.join(config.params.downloadFolder, folderName, subFolderName, fileName); const filePath = path.join(config.params.downloadFolder, folderName, subFolderName, fileName);
@ -124,7 +124,7 @@ export class Utils {
}); });
} }
static async renameFile(oldName: string, newName: string) { static async renameFile(oldName: string, newName: string): Promise<void> {
const config = await browser.getProcessedConfig(); const config = await browser.getProcessedConfig();
const oldFilePath = path.join(config.params.downloadFolder, oldName); const oldFilePath = path.join(config.params.downloadFolder, oldName);
const newFilePath = path.join(config.params.downloadFolder, newName); const newFilePath = path.join(config.params.downloadFolder, newName);
@ -140,7 +140,7 @@ export class Utils {
} }
} }
static async unzip(filename: string, unzippedName: string = '') { static async unzip(filename: string, unzippedName: string = ''): Promise<void> {
const config = await browser.getProcessedConfig(); const config = await browser.getProcessedConfig();
const filePath = path.join(config.params.downloadFolder, filename); const filePath = path.join(config.params.downloadFolder, filename);
const output = path.join(config.params.downloadFolder, unzippedName ? unzippedName : ''); const output = path.join(config.params.downloadFolder, unzippedName ? unzippedName : '');
@ -162,23 +162,31 @@ export class Utils {
}); });
} }
static async pressEscape() { static async pressEscape(): Promise<void> {
await browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); await browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
} }
static async pressTab() { static async pressTab(): Promise<void> {
await browser.actions().sendKeys(protractor.Key.TAB).perform(); await browser.actions().sendKeys(protractor.Key.TAB).perform();
} }
static async getBrowserLog() { static async pressCmd(): Promise<void> {
await browser.actions().sendKeys(protractor.Key.COMMAND).perform();
}
static async releaseKeyPressed(): Promise<void> {
await browser.actions().sendKeys(protractor.Key.NULL).perform();
}
static async getBrowserLog(): Promise<logging.Entry[]> {
return browser.manage().logs().get('browser'); return browser.manage().logs().get('browser');
} }
static formatDate(date: string) { static formatDate(date: string): string {
return new Date(date).toLocaleDateString('en-US'); return new Date(date).toLocaleDateString('en-US');
} }
static async uploadFileNewVersion(fileFromOS: string) { static async uploadFileNewVersion(fileFromOS: string): Promise<void> {
const el = browser.element(by.id('app-upload-file-version')); const el = browser.element(by.id('app-upload-file-version'));
await el.sendKeys(`${E2E_ROOT_PATH}/resources/test-files/${fileFromOS}`); await el.sendKeys(`${E2E_ROOT_PATH}/resources/test-files/${fileFromOS}`);
} }

View File

@ -70,6 +70,7 @@ exports.config = {
'./e2e/suites/actions/new-menu.test.ts', './e2e/suites/actions/new-menu.test.ts',
'./e2e/suites/actions/create-folder.test.ts', './e2e/suites/actions/create-folder.test.ts',
'./e2e/suites/actions/create-library.test.ts', './e2e/suites/actions/create-library.test.ts',
'./e2e/suites/actions/create-file-from-template.test.ts',
'./e2e/suites/actions/upload-file.test.ts', './e2e/suites/actions/upload-file.test.ts',
'./e2e/suites/actions/upload-new-version.test.ts', './e2e/suites/actions/upload-new-version.test.ts',
'./e2e/suites/actions/delete-undo-delete.test.ts', './e2e/suites/actions/delete-undo-delete.test.ts',