diff --git a/.gitignore b/.gitignore index 082d3efc1..3a5b6bbee 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,7 @@ testem.log /e2e/*.js /e2e/*.map /e2e-output +/e2e-downloads # System Files .DS_Store diff --git a/e2e/components/breadcrumb/breadcrumb.ts b/e2e/components/breadcrumb/breadcrumb.ts index b32e29c22..4fc9efb4f 100755 --- a/e2e/components/breadcrumb/breadcrumb.ts +++ b/e2e/components/breadcrumb/breadcrumb.ts @@ -36,7 +36,7 @@ export class Breadcrumb extends Component { items: ElementArrayFinder = this.component.all(by.css(Breadcrumb.selectors.item)); currentItem: ElementFinder = this.component.element(by.css(Breadcrumb.selectors.currentItem)); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(Breadcrumb.selectors.root, ancestor); } diff --git a/e2e/components/breadcrumb/dropdown-breadcrumb.ts b/e2e/components/breadcrumb/dropdown-breadcrumb.ts new file mode 100755 index 000000000..52b3129d0 --- /dev/null +++ b/e2e/components/breadcrumb/dropdown-breadcrumb.ts @@ -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 . + */ + +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 { + await browser.wait(EC.presenceOf(this.pathItemsContainer), BROWSER_WAIT_TIMEOUT, 'Timeout waiting for breadcrumb dropdown to open'); + } + + async waitForPathListDropdownToClose(): Promise { + await browser.wait(EC.stalenessOf(browser.$(DropDownBreadcrumb.selectors.pathOption)), BROWSER_WAIT_TIMEOUT, 'Timeout waiting for breadcrumb dropdown to close'); + } + + async getCurrentFolderName(): Promise { + return this.currentFolder.getText(); + } + + async openPath(): Promise { + await this.trigger.click(); + await this.waitForPathListDropdownToOpen(); + } + + async clickPathItem(name: string): Promise { + const elem = browser.element(by.cssContainingText(DropDownBreadcrumb.selectors.pathOption, name)); + await elem.click(); + } + + async getPathItems(): Promise { + const items: string[] = await this.pathItems.map(async elem => { + return elem.getText(); + }); + return items; + } +} diff --git a/e2e/components/component.ts b/e2e/components/component.ts index a4153987c..487255d2b 100755 --- a/e2e/components/component.ts +++ b/e2e/components/component.ts @@ -29,11 +29,11 @@ import { BROWSER_WAIT_TIMEOUT } from '../configs'; export abstract class Component { component: ElementFinder; - constructor(selector: string, ancestor?: ElementFinder) { + constructor(selector: string, ancestor?: string) { const locator = selector; this.component = ancestor - ? ancestor.$$(locator).first() + ? browser.$$(ancestor).first().$$(locator).first() : browser.$$(locator).first(); } diff --git a/e2e/components/data-table/data-table.ts b/e2e/components/data-table/data-table.ts index 69395b507..cbfc213f9 100755 --- a/e2e/components/data-table/data-table.ts +++ b/e2e/components/data-table/data-table.ts @@ -57,7 +57,6 @@ export class DataTable extends Component { emptyListTitle: '.adf-empty-content__title', emptyListSubtitle: '.adf-empty-content__subtitle', - emptyListText: '.adf-empty-content__text', emptySearchText: '.empty-search__text', @@ -73,55 +72,55 @@ export class DataTable extends Component { emptyFolderDragAndDrop: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyFolderDragAndDrop)); emptyListTitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListTitle)); 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)); menu: Menu = new Menu(); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(DataTable.selectors.root, ancestor); } // Wait methods (waits for elements) - async waitForHeader() { + async waitForHeader(): Promise { await browser.wait(EC.presenceOf(this.head), BROWSER_WAIT_TIMEOUT, '--- timeout waitForHeader ---'); } - async waitForBody() { + async waitForBody(): Promise { await browser.wait(EC.presenceOf(this.body), BROWSER_WAIT_TIMEOUT, '--- timeout waitForBody ---'); } - async waitForEmptyState() { + async waitForEmptyState(): Promise { await browser.wait(EC.presenceOf(this.emptyList), BROWSER_WAIT_TIMEOUT); } // Header/Column methods - getColumnHeaders() { + getColumnHeaders(): ElementArrayFinder { const locator = by.css(DataTable.selectors.columnHeader); return this.head.all(locator); } - async getColumnHeadersText() { + async getColumnHeadersText(): Promise { const el = this.getColumnHeaders(); return el.getText(); } - getNthColumnHeader(nth: number) { + getNthColumnHeader(nth: number): ElementFinder { return this.getColumnHeaders().get(nth - 1); } - getColumnHeaderByLabel(label: string) { + getColumnHeaderByLabel(label: string): ElementFinder { const locator = by.cssContainingText(DataTable.selectors.columnHeader, label); return this.head.element(locator); } - getSortedColumnHeader() { + getSortedColumnHeader(): ElementFinder { const locator = by.css(DataTable.selectors.sortedColumnHeader); return this.head.element(locator); } - async getSortedColumnHeaderText() { + async getSortedColumnHeaderText(): Promise { return this.getSortedColumnHeader().getText(); } @@ -138,7 +137,7 @@ export class DataTable extends Component { return 'none'; } - async sortByColumn(columnName: string) { + async sortByColumn(columnName: string): Promise { const column = this.getColumnHeaderByLabel(columnName); const click = browser.actions().mouseMove(column).click(); @@ -146,27 +145,38 @@ export class DataTable extends Component { } // Rows methods - getRows() { + getRows(): ElementArrayFinder { return this.body.all(by.css(DataTable.selectors.row)); } - async countRows() { + async getRowsCount(): Promise { return this.getRows().count(); } - getSelectedRows() { + async waitForRowToBeSelected(): Promise { + 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)); } - async countSelectedRows() { + async getSelectedRowsNames(): Promise { + const rowsText: string[] = await this.getSelectedRows().map((row) => { + return row.element(by.css('.adf-datatable-cell[title="Name"]')).getText(); + }); + return rowsText; + } + + async getSelectedRowsCount(): Promise { return this.getSelectedRows().count(); } - getNthRow(nth: number) { + getNthRow(nth: number): ElementFinder { return this.getRows().get(nth - 1); } - getRowByName(name: string, location: string = '') { + getRowByName(name: string, location: string = ''): ElementFinder { if (location) { return this.body.all(by.cssContainingText(DataTable.selectors.row, name)) .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)); } - getRowCells(name: string, location: string = '') { + getRowCells(name: string, location: string = ''): ElementArrayFinder { return this.getRowByName(name, location).all(by.css(DataTable.selectors.cell)); } - async getRowCellsCount(itemName: string) { + async getRowCellsCount(itemName: string): Promise { return this.getRowCells(itemName).count(); } - getRowFirstCell(name: string, location: string = '') { + getRowFirstCell(name: string, location: string = ''): ElementFinder { 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); } - getRowNameCellSpan(name: string, location: string = '') { + getRowNameCellSpan(name: string, location: string = ''): ElementFinder { return this.getRowNameCell(name, location).$('span'); } - async getItemNameTooltip(name: string, location: string = '') { + async getItemNameTooltip(name: string, location: string = ''): Promise { return this.getRowNameCellSpan(name, location).getAttribute('title'); } - async hasCheckMarkIcon(itemName: string, location: string = '') { - const row = this.getRowByName(itemName, location); + async hasCheckMarkIcon(itemName: string, location: string = ''): Promise { + const row: ElementFinder = this.getRowByName(itemName, location); return row.element(by.css(DataTable.selectors.selectedIcon)).isPresent(); } - async hasLockIcon(itemName: string, location: string = '') { - const row = this.getRowByName(itemName, location); + async hasLockIcon(itemName: string, location: string = ''): Promise { + const row: ElementFinder = this.getRowByName(itemName, location); return row.element(by.css(DataTable.selectors.lockIcon)).isPresent(); } - async hasLockOwnerInfo(itemName: string, location: string = '') { - const row = this.getRowByName(itemName, location); + async hasLockOwnerInfo(itemName: string, location: string = ''): Promise { + const row: ElementFinder = this.getRowByName(itemName, location); return row.element(by.css(DataTable.selectors.lockOwner)).isPresent(); } - async getLockOwner(itemName: string, location: string = '') { + async getLockOwner(itemName: string, location: string = ''): Promise { if (await this.hasLockOwnerInfo(itemName, location)) { const row = this.getRowByName(itemName, location); return row.$(DataTable.selectors.lockOwner).$('.locked_by--name').getText(); @@ -222,16 +232,16 @@ export class DataTable extends Component { return ''; } - getNameLink(itemName: string) { + getNameLink(itemName: string): ElementFinder { return this.getRowNameCell(itemName).$(DataTable.selectors.nameLink); } - async hasLinkOnName(itemName: string) { + async hasLinkOnName(itemName: string): Promise { return this.getNameLink(itemName).isPresent(); } // Navigation/selection methods - async doubleClickOnRowByName(name: string, location: string = '') { + async doubleClickOnRowByName(name: string, location: string = ''): Promise { try { const item = this.getRowFirstCell(name, location); 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 { const isSelected = await this.hasCheckMarkIcon(name, location); if (!isSelected) { try { @@ -253,19 +263,18 @@ export class DataTable extends Component { console.log('--- select item catch : ', e); } } - } - async clickItem(name: string, location: string = '') { + async clickItem(name: string, location: string = ''): Promise { const item = this.getRowFirstCell(name, location); await item.click(); } - async clickNameLink(itemName: string) { + async clickNameLink(itemName: string): Promise { await this.getNameLink(itemName).click(); } - async selectMultipleItems(names: string[], location: string = '') { + async selectMultipleItems(names: string[], location: string = ''): Promise { await this.clearSelection(); await browser.actions().sendKeys(protractor.Key.COMMAND).perform(); for (const name of names) { @@ -274,9 +283,9 @@ export class DataTable extends Component { await browser.actions().sendKeys(protractor.Key.NULL).perform(); } - async clearSelection() { + async clearSelection(): Promise { try { - const count = await this.countSelectedRows(); + const count = await this.getSelectedRowsCount(); if (count !== 0) { await browser.refresh(); await this.wait(); @@ -286,27 +295,27 @@ export class DataTable extends Component { } } - async rightClickOnItem(itemName: string) { + async rightClickOnItem(itemName: string): Promise { const item = this.getRowFirstCell(itemName); await browser.actions().mouseMove(item).perform(); await browser.actions().click(protractor.Button.RIGHT).perform(); } - async rightClickOnMultipleSelection() { + async rightClickOnMultipleSelection(): Promise { const itemFromSelection = this.getSelectedRows().get(0); await browser.actions().mouseMove(itemFromSelection).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)); } - async getItemLocation(name: string) { + async getItemLocation(name: string): Promise { return this.getItemLocationEl(name).getText(); } - async getItemLocationTooltip(name: string) { + async getItemLocationTooltip(name: string): Promise { const location = this.getItemLocationEl(name).$('a'); const condition = () => location.getAttribute('title').then(value => value && value.length > 0); @@ -316,16 +325,16 @@ export class DataTable extends Component { return location.getAttribute('title'); } - async clickItemLocation(name: string) { + async clickItemLocation(name: string): Promise { await this.getItemLocationEl(name).click(); } // empty state methods - async isEmptyList() { + async isEmpty(): Promise { return this.emptyList.isPresent(); } - async isEmptyWithDragAndDrop() { + async isEmptyWithDragAndDrop(): Promise { return this.emptyFolderDragAndDrop.isDisplayed(); } @@ -334,66 +343,68 @@ export class DataTable extends Component { if (isEmpty) { return this.emptyFolderDragAndDrop.getText(); } - return ''; } async getEmptyStateTitle(): Promise { - const isEmpty = await this.isEmptyList(); + const isEmpty = await this.isEmpty(); if (isEmpty) { return this.emptyListTitle.getText(); } - return ''; } async getEmptyStateSubtitle(): Promise { - const isEmpty = await this.isEmptyList(); + const isEmpty = await this.isEmpty(); if (isEmpty) { return this.emptyListSubtitle.getText(); } - return ''; } - async getEmptyStateText(): Promise { - const isEmpty = await this.isEmptyList(); + async getEmptyListText(): Promise { + const isEmpty = await this.isEmpty(); if (isEmpty) { - return this.emptyListText.getText(); + return this.component.element(by.css('adf-custom-empty-content-template')).getText(); } - return ''; } - async getEmptySearchResultsText() { + async getEmptySearchResultsText(): Promise { return this.emptySearchText.getText(); } - async getCellsContainingName(name: string) { - const rows = this.getRows().all(by.cssContainingText(DataTable.selectors.cell, name)); - return rows.map(async cell => await cell.getText()); + async getCellsContainingName(name: string): Promise { + const rows: ElementArrayFinder = this.getRows().all(by.cssContainingText(DataTable.selectors.cell, name)); + const cellsText: string[] = await rows.map(async cell => { + return cell.getText(); + }); + return cellsText; } - async hasContextMenu() { + async hasContextMenu(): Promise { const count = await this.menu.getItemsCount(); return count > 0; } - async getLibraryRole(name: string) { + async getLibraryRole(name: string): Promise { return this.getRowByName(name).element(by.css(DataTable.selectors.libraryRole)).getText(); } - async isItemPresent(name: string, location? : string) { + async isItemPresent(name: string, location? : string): Promise { return this.getRowByName(name, location).isPresent(); } - async getEntireDataTableText() { - return this.getRows().map((row) => { - return row.all(by.css(DataTable.selectors.cell)).map(async cell => await cell.getText()); + async getEntireDataTableText(): Promise { + const text: string[] = await this.getRows().map((row) => { + 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(); return data.reduce((acc, cell) => { 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(); return data.reduce((acc, cell) => { acc[cell[1]] = cell[2]; @@ -417,7 +428,7 @@ export class DataTable extends Component { return this.getSearchResultsRows().get(nth - 1); } - getSearchResultsRowByName(name: string, location: string = '') { + getSearchResultsRowByName(name: string, location: string = ''): ElementFinder { if (location) { return this.body.all(by.cssContainingText(DataTable.selectors.searchResultsRow, name)) .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)); } - getSearchResultRowLines(name: string, location: string = '') { + getSearchResultRowLines(name: string, location: string = ''): ElementArrayFinder { return this.getSearchResultsRowByName(name, location).all(by.css(DataTable.selectors.searchResultsRowLine)); } - async getSearchResultLinesCount(name: string, location: string = '') { + async getSearchResultLinesCount(name: string, location: string = ''): Promise { 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); } - async getSearchResultNameAndTitle(name: string, location: string = '') { + async getSearchResultNameAndTitle(name: string, location: string = ''): Promise { return this.getSearchResultNthLine(name, location, 0).getText(); } - async getSearchResultDescription(name: string, location: string = '') { + async getSearchResultDescription(name: string, location: string = ''): Promise { return this.getSearchResultNthLine(name, location, 1).getText(); } - async getSearchResultModified(name: string, location: string = '') { + async getSearchResultModified(name: string, location: string = ''): Promise { return this.getSearchResultNthLine(name, location, 2).getText(); } - async getSearchResultLocation(name: string, location: string = '') { + async getSearchResultLocation(name: string, location: string = ''): Promise { 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); } - async hasLinkOnSearchResultName(itemName: string, location: string = '') { + async hasLinkOnSearchResultName(itemName: string, location: string = ''): Promise { return this.getSearchResultNameLink(itemName, location).isPresent(); } - async clickSearchResultNameLink(itemName: string, location: string = '') { + async clickSearchResultNameLink(itemName: string, location: string = ''): Promise { await this.getSearchResultNameLink(itemName, location).click(); } diff --git a/e2e/components/datetime-picker/datetime-picker.ts b/e2e/components/datetime-picker/datetime-picker.ts index 6716c635b..dd6a4446e 100755 --- a/e2e/components/datetime-picker/datetime-picker.ts +++ b/e2e/components/datetime-picker/datetime-picker.ts @@ -48,7 +48,7 @@ export class DateTimePicker extends Component { headerYear: ElementFinder = this.component.element(by.css(DateTimePicker.selectors.year)); dayPicker: ElementFinder = this.component.element(by.css(DateTimePicker.selectors.dayPicker)); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(DateTimePicker.selectors.root, ancestor); } diff --git a/e2e/components/dialog/confirm-dialog.ts b/e2e/components/dialog/confirm-dialog.ts index 0c008ec05..290357c3c 100755 --- a/e2e/components/dialog/confirm-dialog.ts +++ b/e2e/components/dialog/confirm-dialog.ts @@ -44,7 +44,7 @@ export class ConfirmDialog extends Component { cancelButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.cancel)); actionButton: ElementFinder = this.component.element(by.id(ConfirmDialog.selectors.actionButton)); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(ConfirmDialog.selectors.root, ancestor); } diff --git a/e2e/components/dialog/copy-move-dialog.ts b/e2e/components/dialog/copy-move-dialog.ts index 6f5321c46..a5f628619 100755 --- a/e2e/components/dialog/copy-move-dialog.ts +++ b/e2e/components/dialog/copy-move-dialog.ts @@ -33,31 +33,26 @@ export class CopyMoveDialog extends Component { root: '.adf-content-node-selector-dialog', title: '.mat-dialog-title', - content: '.mat-dialog-content', locationDropDown: 'site-dropdown-container', locationOption: '.mat-option .mat-option-text', dataTable: '.adf-datatable-body', - row: '.adf-datatable-row[role]', selectedRow: '.adf-is-selected', button: '.mat-dialog-actions button' }; 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)); locationDropDown: ElementFinder = this.component.element(by.id(CopyMoveDialog.selectors.locationDropDown)); locationPersonalFiles: ElementFinder = browser.element(by.cssContainingText(CopyMoveDialog.selectors.locationOption, 'Personal Files')); 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')); copyButton: ElementFinder = this.component.element(by.cssContainingText(CopyMoveDialog.selectors.button, 'Copy')); moveButton: ElementFinder = this.component.element(by.cssContainingText(CopyMoveDialog.selectors.button, 'Move')); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(CopyMoveDialog.selectors.root, ancestor); } diff --git a/e2e/components/dialog/create-edit-folder-dialog.ts b/e2e/components/dialog/create-edit-folder-dialog.ts index 467404bae..b94f49c46 100755 --- a/e2e/components/dialog/create-edit-folder-dialog.ts +++ b/e2e/components/dialog/create-edit-folder-dialog.ts @@ -47,7 +47,7 @@ export class CreateOrEditFolderDialog extends Component { updateButton: ElementFinder = this.component.element(by.cssContainingText(CreateOrEditFolderDialog.selectors.button, 'Update')); validationMessage: ElementFinder = this.component.element(by.css(CreateOrEditFolderDialog.selectors.validationMessage)); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(CreateOrEditFolderDialog.selectors.root, ancestor); } @@ -68,8 +68,8 @@ export class CreateOrEditFolderDialog extends Component { return this.title.getText(); } - async isValidationMessageDisplayed() { - return this.validationMessage.isDisplayed(); + async isValidationMessageDisplayed(): Promise { + return (await this.validationMessage.isPresent()) && (await this.validationMessage.isDisplayed()); } async isUpdateButtonEnabled() { @@ -92,9 +92,12 @@ export class CreateOrEditFolderDialog extends Component { return this.descriptionTextArea.isDisplayed(); } - async getValidationMessage() { - await this.isValidationMessageDisplayed(); - return this.validationMessage.getText(); + async getValidationMessage(): Promise { + if (await this.isValidationMessageDisplayed()) { + return this.validationMessage.getText(); + } else { + return ''; + } } async getName() { diff --git a/e2e/components/dialog/create-from-template-dialog.ts b/e2e/components/dialog/create-from-template-dialog.ts new file mode 100755 index 000000000..4bca2e05a --- /dev/null +++ b/e2e/components/dialog/create-from-template-dialog.ts @@ -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 . + */ + +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 { + 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 { + await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT, '---- timeout waiting for dialog to close ----'); + } + + async isDialogOpen(): Promise { + return browser.isElementPresent(by.css(CreateFromTemplateDialog.selectors.root)); + } + + async getTitle(): Promise { + return this.title.getText(); + } + + async isValidationMessageDisplayed(): Promise { + return (await this.validationMessage.isPresent()) && (await this.validationMessage.isDisplayed()); + } + + async isCreateButtonEnabled(): Promise { + return this.createButton.isEnabled(); + } + + async isCancelButtonEnabled(): Promise { + return this.cancelButton.isEnabled(); + } + + async isNameFieldDisplayed(): Promise { + return this.nameInput.isDisplayed(); + } + + async isTitleFieldDisplayed(): Promise { + return this.titleInput.isDisplayed(); + } + + async isDescriptionFieldDisplayed(): Promise { + return this.descriptionTextArea.isDisplayed(); + } + + async getValidationMessage(): Promise { + if (await this.isValidationMessageDisplayed()) { + return this.validationMessage.getText(); + } else { + return ''; + } + } + + async getName(): Promise { + return this.nameInput.getAttribute('value'); + } + + async getDescription(): Promise { + return this.descriptionTextArea.getAttribute('value'); + } + + async enterName(name: string): Promise { + await this.nameInput.clear(); + await this.nameInput.sendKeys(name); + } + + async enterTitle(title: string): Promise { + await this.titleInput.clear(); + await this.titleInput.sendKeys(title); + } + + async enterDescription(description: string): Promise { + await this.descriptionTextArea.clear(); + await this.descriptionTextArea.sendKeys(description); + } + + async deleteNameWithBackspace(): Promise { + await this.nameInput.clear(); + await this.nameInput.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE); + } + + async clickCreate(): Promise { + await this.createButton.click(); + } + + async clickCancel(): Promise { + await this.cancelButton.click(); + await this.waitForDialogToClose(); + } + +} diff --git a/e2e/components/dialog/create-library-dialog.ts b/e2e/components/dialog/create-library-dialog.ts index c6929acf9..e8ff5a96c 100755 --- a/e2e/components/dialog/create-library-dialog.ts +++ b/e2e/components/dialog/create-library-dialog.ts @@ -53,7 +53,7 @@ export class CreateLibraryDialog extends Component { cancelButton: ElementFinder = this.component.element(by.cssContainingText(CreateLibraryDialog.selectors.button, 'Cancel')); errorMessage: ElementFinder = this.component.element(by.css(CreateLibraryDialog.selectors.errorMessage)); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(CreateLibraryDialog.selectors.root, ancestor); } diff --git a/e2e/components/dialog/manage-versions-dialog.ts b/e2e/components/dialog/manage-versions-dialog.ts index 15e4e3ca0..f36bd72f2 100755 --- a/e2e/components/dialog/manage-versions-dialog.ts +++ b/e2e/components/dialog/manage-versions-dialog.ts @@ -40,7 +40,7 @@ export class ManageVersionsDialog extends Component { content: ElementFinder = this.component.element(by.css(ManageVersionsDialog.selectors.content)); closeButton: ElementFinder = this.component.element(by.cssContainingText(ManageVersionsDialog.selectors.button, 'Close')); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(ManageVersionsDialog.selectors.root, ancestor); } diff --git a/e2e/components/dialog/password-dialog.ts b/e2e/components/dialog/password-dialog.ts index f451e9288..2614b38d0 100755 --- a/e2e/components/dialog/password-dialog.ts +++ b/e2e/components/dialog/password-dialog.ts @@ -45,7 +45,7 @@ export class PasswordDialog extends Component { closeButton: ElementFinder = this.component.element(by.buttonText('Close')); submitButton: ElementFinder = this.component.element(by.buttonText('Submit')); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(PasswordDialog.selectors.root, ancestor); } diff --git a/e2e/components/dialog/select-template-dialog.ts b/e2e/components/dialog/select-template-dialog.ts new file mode 100755 index 000000000..971c2cfbe --- /dev/null +++ b/e2e/components/dialog/select-template-dialog.ts @@ -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 . + */ + +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 { + 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 { + await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT, '---- timeout waiting for dialog to close ----'); + } + + async isDialogOpen(): Promise { + return browser.isElementPresent(by.css(SelectTemplateDialog.selectors.root)); + } + + async getTitle(): Promise { + return this.title.getText(); + } + + // action buttons + + async isCancelButtonEnabled(): Promise { + return this.cancelButton.isEnabled(); + } + + async isNextButtonEnabled(): Promise { + return this.nextButton.isEnabled(); + } + + async clickCancel(): Promise { + await this.cancelButton.click(); + await this.waitForDialogToClose(); + } + + async clickNext(): Promise { + await this.nextButton.click(); + await this.waitForDialogToClose(); + } +} diff --git a/e2e/components/dialog/share-dialog.ts b/e2e/components/dialog/share-dialog.ts index c7c284158..c9c7c1a25 100755 --- a/e2e/components/dialog/share-dialog.ts +++ b/e2e/components/dialog/share-dialog.ts @@ -58,7 +58,7 @@ export class ShareDialog extends Component { closeButton: ElementFinder = this.component.element(by.css(ShareDialog.selectors.button)); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(ShareDialog.selectors.root, ancestor); } diff --git a/e2e/components/dialog/upload-new-version-dialog.ts b/e2e/components/dialog/upload-new-version-dialog.ts index 2e88c17da..3c7cfdae8 100755 --- a/e2e/components/dialog/upload-new-version-dialog.ts +++ b/e2e/components/dialog/upload-new-version-dialog.ts @@ -51,7 +51,7 @@ export class UploadNewVersionDialog extends Component { description: ElementFinder = this.component.element(by.css(UploadNewVersionDialog.selectors.descriptionTextArea)); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(UploadNewVersionDialog.selectors.root, ancestor); } diff --git a/e2e/components/header/header.ts b/e2e/components/header/header.ts index 9cfed3b87..5dbd90655 100755 --- a/e2e/components/header/header.ts +++ b/e2e/components/header/header.ts @@ -47,12 +47,12 @@ export class Header extends Component { moreActions: ElementFinder = browser.element(Header.selectors.moreActions); sidenavToggle: ElementFinder = this.component.element(by.css(Header.selectors.sidenavToggle)); - userInfo: UserInfo = new UserInfo(this.component); + userInfo: UserInfo = new UserInfo(); menu: Menu = new Menu(); toolbar: Toolbar = new Toolbar(); searchInput: SearchInput = new SearchInput(); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super('adf-layout-header', ancestor); } diff --git a/e2e/components/header/user-info.ts b/e2e/components/header/user-info.ts index 71c77b548..690c4a917 100755 --- a/e2e/components/header/user-info.ts +++ b/e2e/components/header/user-info.ts @@ -39,7 +39,7 @@ export class UserInfo extends Component { menu: Menu = new Menu(); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super('aca-current-user', ancestor); } diff --git a/e2e/components/info-drawer/info-drawer-comments-tab.ts b/e2e/components/info-drawer/info-drawer-comments-tab.ts index 8f8f5da49..d1c7fb787 100755 --- a/e2e/components/info-drawer/info-drawer-comments-tab.ts +++ b/e2e/components/info-drawer/info-drawer-comments-tab.ts @@ -58,7 +58,7 @@ export class CommentsTab extends Component { commentTime = by.id(CommentsTab.selectors.commentTime); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(CommentsTab.selectors.root, ancestor); } diff --git a/e2e/components/info-drawer/info-drawer-metadata-content.ts b/e2e/components/info-drawer/info-drawer-metadata-content.ts index dda4a77ba..c64e169ef 100755 --- a/e2e/components/info-drawer/info-drawer-metadata-content.ts +++ b/e2e/components/info-drawer/info-drawer-metadata-content.ts @@ -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']`)); 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); } diff --git a/e2e/components/info-drawer/info-drawer-metadata-library.ts b/e2e/components/info-drawer/info-drawer-metadata-library.ts index b60546f37..b21599fc4 100755 --- a/e2e/components/info-drawer/info-drawer-metadata-library.ts +++ b/e2e/components/info-drawer/info-drawer-metadata-library.ts @@ -58,7 +58,7 @@ export class LibraryMetadata extends Component { error: ElementFinder = this.component.element(by.css(LibraryMetadata.selectors.error)); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(LibraryMetadata.selectors.root, ancestor); } diff --git a/e2e/components/info-drawer/info-drawer.ts b/e2e/components/info-drawer/info-drawer.ts index fe9f65663..b6f81226e 100755 --- a/e2e/components/info-drawer/info-drawer.ts +++ b/e2e/components/info-drawer/info-drawer.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -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 { BROWSER_WAIT_TIMEOUT } from '../../configs'; import { CommentsTab } from './info-drawer-comments-tab'; @@ -48,9 +48,9 @@ export class InfoDrawer extends Component { headerTitle: '.adf-info-drawer-layout-header-title' }; - commentsTab = new CommentsTab($(InfoDrawer.selectors.root)); - aboutTab = new LibraryMetadata($(InfoDrawer.selectors.root)); - propertiesTab = new ContentMetadata($(InfoDrawer.selectors.root)); + commentsTab = new CommentsTab(InfoDrawer.selectors.root); + aboutTab = new LibraryMetadata(InfoDrawer.selectors.root); + propertiesTab = new ContentMetadata(InfoDrawer.selectors.root); header: ElementFinder = this.component.element(by.css(InfoDrawer.selectors.header)); 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)); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(InfoDrawer.selectors.root, ancestor); } diff --git a/e2e/components/login/login.ts b/e2e/components/login/login.ts index 3c7f4cd42..1ac1afdce 100755 --- a/e2e/components/login/login.ts +++ b/e2e/components/login/login.ts @@ -45,7 +45,7 @@ export class LoginComponent extends Component { copyright: ElementFinder = this.component.element(LoginComponent.selectors.copyright); passwordVisibility: ElementFinder = this.component.element(LoginComponent.selectors.passwordVisibility); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(LoginComponent.selectors.root, ancestor); } diff --git a/e2e/components/menu/menu.ts b/e2e/components/menu/menu.ts index 3397e1c58..252190de0 100755 --- a/e2e/components/menu/menu.ts +++ b/e2e/components/menu/menu.ts @@ -74,67 +74,89 @@ export class Menu extends Component { 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')); 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')); viewDetailsAction: ElementFinder = this.component.element(by.cssContainingText(Menu.selectors.item, 'View Details')); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(Menu.selectors.root, ancestor); } - async waitForMenuToOpen() { + async waitForMenuToOpen(): Promise { 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); } - async waitForMenuToClose() { + async waitForMenuToClose(): Promise { 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 { await Utils.pressEscape(); await this.waitForMenuToClose(); } - getNthItem(nth: number) { + getNthItem(nth: number): ElementFinder { return this.items.get(nth - 1); } - getItemByLabel(menuItem: string) { + getItemByLabel(menuItem: string): ElementFinder { 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)); } - getItemById(id: string) { + getItemById(id: string): ElementFinder { return this.component.element(by.id(id)); } - async getItemTooltip(menuItem: string) { + async getItemTooltip(menuItem: string): Promise { return this.getItemByLabel(menuItem).getAttribute('title'); } - async getItemIconText(menuItem: string) { + async getTooltipForUploadFile(): Promise { + return this.getItemTooltip('Upload File'); + } + + async getTooltipForUploadFolder(): Promise { + return this.getItemTooltip('Upload Folder'); + } + + async getTooltipForCreateFolder(): Promise { + return this.getItemTooltip('Create Folder'); + } + + async getTooltipForCreateLibrary(): Promise { + return this.getItemTooltip('Create Library'); + } + + async getTooltipForCreateFileFromTemplate(): Promise { + return this.getItemTooltip('Create file from template'); + } + + async getItemIconText(menuItem: string): Promise { return this.getItemByLabel(menuItem).element(by.css(Menu.selectors.icon)).getText(); } - async getItemIdAttribute(menuItem: string) { + async getItemIdAttribute(menuItem: string): Promise { return this.getItemByLabel(menuItem).getAttribute('id'); } - async getItemsCount() { + async getItemsCount(): Promise { return this.items.count(); } async getMenuItems(): Promise { - return this.items.map(async (elem) => { - const text = await elem.element(by.css('span')).getText(); - return text; + const items: string[] = await this.items.map(async (elem) => { + const span: ElementFinder = elem.element(by.css('span')); + return span.getText(); }); + return items; } - async clickNthItem(nth: number) { + async clickNthItem(nth: number): Promise { try { const elem = this.getNthItem(nth); 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 { try { const elem = this.getItemByLabel(menuItem); 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 { try { const elem = this.getItemByLabel(menuItem); 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 { try { const elem = this.getSubItemByLabel(subMenuItem); 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 { return browser.element(by.cssContainingText(Menu.selectors.item, title)).isPresent(); } - async isSubMenuItemPresent(title: string) { + async isSubMenuItemPresent(title: string): Promise { return browser.element(by.cssContainingText(Menu.selectors.submenu, title)).isPresent(); } - async getSubmenuItemsCount() { + async getSubmenuItemsCount(): Promise { return this.submenus.count(); } @@ -212,172 +234,158 @@ export class Menu extends Component { } } - uploadFile() { + uploadFile(): ElementFinder { return this.uploadFiles; } - async clickEditFolder() { + async clickEditFolder(): Promise { await this.editFolderAction.click(); } - async clickShare() { + async clickShare(): Promise { const action = this.shareAction; await action.click(); } - async clickSharedLinkSettings() { + async clickSharedLinkSettings(): Promise { const action = this.shareEditAction; await action.click(); } - - async isViewPresent() { + async isViewPresent(): Promise { return this.viewAction.isPresent(); } - async isDownloadPresent() { + async isDownloadPresent(): Promise { return this.downloadAction.isPresent(); } - async isEditFolderPresent() { + async isEditFolderPresent(): Promise { return this.editFolderAction.isPresent(); } - async isEditOfflinePresent() { + async isEditOfflinePresent(): Promise { return this.editOfflineAction.isPresent(); } - async isCancelEditingPresent() { + async isCancelEditingPresent(): Promise { return this.cancelEditingAction.isPresent(); } - async isCopyPresent() { + async isCopyPresent(): Promise { return this.copyAction.isPresent(); } - async isMovePresent() { + async isMovePresent(): Promise { return this.moveAction.isPresent(); } - async isDeletePresent() { + async isDeletePresent(): Promise { return this.deleteAction.isPresent(); } - async isManagePermissionsPresent() { + async isManagePermissionsPresent(): Promise { return this.managePermissionsAction.isPresent(); } - async isManageVersionsPresent() { + async isManageVersionsPresent(): Promise { return this.manageVersionsAction.isPresent(); } - async isUploadNewVersionPresent() { + async isUploadNewVersionPresent(): Promise { return this.uploadNewVersionAction.isPresent(); } - async isFavoritePresent() { + async isFavoritePresent(): Promise { return this.favoriteAction.isPresent(); } - async isRemoveFavoritePresent() { + async isRemoveFavoritePresent(): Promise { return this.removeFavoriteAction.isPresent(); } - async isToggleFavoritePresent() { + async isToggleFavoritePresent(): Promise { return this.toggleFavoriteAction.isPresent(); } - async isToggleRemoveFavoritePresent() { + async isToggleRemoveFavoritePresent(): Promise { return this.toggleRemoveFavoriteAction.isPresent(); } - async isJoinLibraryPresent() { + async isJoinLibraryPresent(): Promise { return this.joinAction.isPresent(); } - async isCancelJoinPresent() { + async isCancelJoinPresent(): Promise { return this.cancelJoinAction.isPresent(); } - async isLeaveLibraryPresent() { + async isLeaveLibraryPresent(): Promise { return this.leaveAction.isPresent(); } - async isPermanentDeletePresent() { + async isPermanentDeletePresent(): Promise { return this.permanentDeleteAction.isPresent(); } - async isRestorePresent() { + async isRestorePresent(): Promise { return this.restoreAction.isPresent(); } - async isSharePresent() { + async isSharePresent(): Promise { return this.shareAction.isPresent(); } - async isSharedLinkSettingsPresent() { + async isSharedLinkSettingsPresent(): Promise { return this.shareEditAction.isPresent(); } - async isViewDetailsPresent() { + async isViewDetailsPresent(): Promise { return this.viewDetailsAction.isPresent(); } - async isCreateFolderPresent() { - return this.createFolderAction.isPresent(); - } - async isCreateFolderEnabled() { - return this.createFolderAction.isEnabled(); + async isCreateFolderEnabled(): Promise { + return (await this.createFolderAction.isPresent()) && (await this.createFolderAction.isEnabled()); } - async isCreateLibraryPresent() { - return this.createLibraryAction.isPresent(); - } - async isCreateLibraryEnabled() { - return this.createLibraryAction.isEnabled(); + async isCreateLibraryEnabled(): Promise { + return (await this.createLibraryAction.isPresent()) && (await this.createLibraryAction.isEnabled()); } - async isUploadFilePresent() { - return this.uploadFileAction.isPresent(); - } - async isUploadFileEnabled() { - return this.uploadFileAction.isEnabled(); + async isUploadFileEnabled(): Promise { + return (await this.uploadFileAction.isPresent()) && (await this.uploadFileAction.isEnabled()); } - async isUploadFolderPresent() { - return this.uploadFolderAction.isPresent(); - } - async isUploadFolderEnabled() { - return this.uploadFolderAction.isEnabled(); + async isUploadFolderEnabled(): Promise { + return (await this.uploadFolderAction.isPresent()) && (await this.uploadFolderAction.isEnabled()); } - async isCancelEditingActionPresent(): Promise { - return this.cancelEditingAction.isPresent(); + async isCreateFileFromTemplateEnabled(): Promise { + return (await this.createFileFromTemplateAction.isPresent()) && (await this.createFileFromTemplateAction.isEnabled()); } - async isEditOfflineActionPresent(): Promise { - return this.editOfflineAction.isPresent(); - } - - - async clickCreateFolder() { + async clickCreateFolder(): Promise { const action = this.createFolderAction; await action.click(); } - async clickCreateLibrary() { + async clickCreateLibrary(): Promise { const action = this.createLibraryAction; await action.click(); } - async clickUploadFile() { + async clickUploadFile(): Promise { const action = this.uploadFileAction; await action.click(); } - async clickUploadFolder() { + async clickUploadFolder(): Promise { const action = this.uploadFolderAction; await action.click(); } + async clickCreateFileFromTemplate(): Promise { + const action = this.createFileFromTemplateAction; + await action.click(); + } } diff --git a/e2e/components/metadata-card/metadata-card.ts b/e2e/components/metadata-card/metadata-card.ts index b451bb380..b0590da7e 100644 --- a/e2e/components/metadata-card/metadata-card.ts +++ b/e2e/components/metadata-card/metadata-card.ts @@ -39,7 +39,7 @@ export class MetadataCard extends Component { expandButton: ElementFinder = this.component.element(by.css(MetadataCard.selectors.expandButton)); expansionPanels: ElementArrayFinder = this.component.all(by.css(MetadataCard.selectors.expansionPanel)); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(MetadataCard.selectors.root, ancestor); } diff --git a/e2e/components/pagination/pagination.ts b/e2e/components/pagination/pagination.ts index 49e05a198..365515dbe 100755 --- a/e2e/components/pagination/pagination.ts +++ b/e2e/components/pagination/pagination.ts @@ -53,7 +53,7 @@ export class Pagination extends Component { menu: Menu = new Menu(); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(Pagination.selectors.root, ancestor); } diff --git a/e2e/components/search/search-filters.ts b/e2e/components/search/search-filters.ts index ffda3151c..db1ab67d2 100755 --- a/e2e/components/search/search-filters.ts +++ b/e2e/components/search/search-filters.ts @@ -45,7 +45,7 @@ export class SearchFilters extends Component { location = new FacetFilter('Location'); modifiedDate = new FacetFilter('Modified date'); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(SearchFilters.selectors.root, ancestor); } diff --git a/e2e/components/search/search-input.ts b/e2e/components/search/search-input.ts index b2f18529d..761c8cff3 100755 --- a/e2e/components/search/search-input.ts +++ b/e2e/components/search/search-input.ts @@ -50,7 +50,7 @@ export class SearchInput extends Component { searchLibrariesOption: ElementFinder = this.searchOptionsArea.element(by.cssContainingText(SearchInput.selectors.optionCheckbox, 'Libraries')); clearSearchButton: ElementFinder = this.searchContainer.$(SearchInput.selectors.clearButton); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(SearchInput.selectors.root, ancestor); } diff --git a/e2e/components/search/search-sorting-picker.ts b/e2e/components/search/search-sorting-picker.ts index e274a95e3..386c4d899 100755 --- a/e2e/components/search/search-sorting-picker.ts +++ b/e2e/components/search/search-sorting-picker.ts @@ -39,7 +39,7 @@ export class SearchSortingPicker extends Component { sortByDropdownExpanded: ElementFinder = browser.element(by.css('.mat-select-panel')); sortByList: ElementArrayFinder = this.sortByDropdownExpanded.all(by.css(SearchSortingPicker.selectors.sortByOption)); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(SearchSortingPicker.selectors.root, ancestor); } diff --git a/e2e/components/sidenav/sidenav.ts b/e2e/components/sidenav/sidenav.ts index 6a57252b2..2b4d83ef3 100755 --- a/e2e/components/sidenav/sidenav.ts +++ b/e2e/components/sidenav/sidenav.ts @@ -68,11 +68,11 @@ export class Sidenav extends Component { menu: Menu = new Menu(); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(Sidenav.selectors.root, ancestor); } - private async expandMenu(name: string) { + private async expandMenu(name: string): Promise { try{ if (await element(by.cssContainingText('.mat-expanded', name)).isPresent()) { @@ -89,37 +89,42 @@ export class Sidenav extends Component { } } - async openNewMenu() { + async openNewMenu(): Promise { const { menu, newButton } = this; await newButton.click(); await menu.waitForMenuToOpen(); } - async openCreateFolderDialog() { + async openCreateFolderDialog(): Promise { await this.openNewMenu(); await this.menu.clickMenuItem('Create Folder'); } - async openCreateLibraryDialog() { + async openCreateLibraryDialog(): Promise { await this.openNewMenu(); await this.menu.clickMenuItem('Create Library'); } - async isActive(name: string) { + async openCreateFileFromTemplateDialog(): Promise { + await this.openNewMenu(); + await this.menu.clickMenuItem('Create file from template'); + } + + async isActive(name: string): Promise { return (await this.getLinkLabel(name).getAttribute('class')).includes(Sidenav.selectors.activeClassName); } - async childIsActive(name: string) { + async childIsActive(name: string): Promise { const childClass = await this.getLinkLabel(name).element(by.css('span')).getAttribute('class'); return childClass.includes(Sidenav.selectors.activeChild); } - getLink(name: string) { + getLink(name: string): ElementFinder { return this.getLinkLabel(name).element(by.xpath('..')); } - getLinkLabel(name: string) { + getLinkLabel(name: string): ElementFinder { switch (name) { case 'Personal Files': return this.personalFiles; case 'File Libraries': return this.fileLibraries; @@ -133,37 +138,35 @@ export class Sidenav extends Component { } } - getActiveLink() { + getActiveLink(): ElementFinder { return this.activeLink; } - async getLinkTooltip(name: string) { + async getLinkTooltip(name: string): Promise { const link = this.getLinkLabel(name); - const condition = () => link.getAttribute('title').then(value => value && value.length > 0); await browser.actions().mouseMove(link).perform(); - await browser.wait(condition, BROWSER_WAIT_TIMEOUT); return link.getAttribute('title'); } - async clickLink(name: string) { + async clickLink(name: string): Promise { try{ const link = this.getLinkLabel(name); await Utils.waitUntilElementClickable(link); - return await link.click(); + await link.click(); } catch (error) { console.log('---- sidebar navigation clickLink catch error: ', error); } } - async isFileLibrariesMenuExpanded() { + async isFileLibrariesMenuExpanded(): Promise { return element(by.cssContainingText('.mat-expanded', SIDEBAR_LABELS.FILE_LIBRARIES)).isPresent(); } - async expandFileLibraries() { + async expandFileLibraries(): Promise { await this.expandMenu(SIDEBAR_LABELS.FILE_LIBRARIES); } diff --git a/e2e/components/toolbar/toolbar.ts b/e2e/components/toolbar/toolbar.ts index 7c5627512..7312bcfdf 100755 --- a/e2e/components/toolbar/toolbar.ts +++ b/e2e/components/toolbar/toolbar.ts @@ -64,7 +64,7 @@ export class Toolbar extends Component { permanentlyDeleteButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.permanentlyDelete)); restoreButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.restore)); - constructor(ancestor?: ElementFinder) { + constructor(ancestor?: string) { super(Toolbar.selectors.root, ancestor); } diff --git a/e2e/components/viewer/viewer.ts b/e2e/components/viewer/viewer.ts index ed6af6c02..da16cc507 100755 --- a/e2e/components/viewer/viewer.ts +++ b/e2e/components/viewer/viewer.ts @@ -50,9 +50,9 @@ export class Viewer extends Component { viewerExtensionContent: ElementFinder = this.component.element(by.css(Viewer.selectors.viewerExtensionContent)); 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); } diff --git a/e2e/pages/browsing-page.ts b/e2e/pages/browsing-page.ts index f11b78f20..bea08b884 100755 --- a/e2e/pages/browsing-page.ts +++ b/e2e/pages/browsing-page.ts @@ -28,12 +28,12 @@ import { SIDEBAR_LABELS } from './../configs'; import { Page } from './page'; export class BrowsingPage extends Page { - header = new Header(this.app); - sidenav = new Sidenav(this.app); - toolbar = new Toolbar(this.app); - breadcrumb = new Breadcrumb(this.app); - dataTable = new DataTable(this.app); - pagination = new Pagination(this.app); + header = new Header(this.appRoot); + sidenav = new Sidenav(this.appRoot); + toolbar = new Toolbar(this.appRoot); + breadcrumb = new Breadcrumb(this.appRoot); + dataTable = new DataTable(this.appRoot); + pagination = new Pagination(this.appRoot); async signOut() { await this.header.userInfo.signOut(); diff --git a/e2e/pages/login-page.ts b/e2e/pages/login-page.ts index 4bcc34750..50ede4289 100755 --- a/e2e/pages/login-page.ts +++ b/e2e/pages/login-page.ts @@ -29,7 +29,7 @@ import { Page } from './page'; import { ADMIN_USERNAME, ADMIN_PASSWORD, BROWSER_WAIT_TIMEOUT, APP_ROUTES } from '../configs'; export class LoginPage extends Page { - login: LoginComponent = new LoginComponent(this.app); + login: LoginComponent = new LoginComponent(this.appRoot); /** @override */ constructor() { diff --git a/e2e/pages/page.ts b/e2e/pages/page.ts index 541a271b7..34ffeb5f0 100755 --- a/e2e/pages/page.ts +++ b/e2e/pages/page.ts @@ -29,7 +29,7 @@ import { Utils } from '../utilities/utils'; export abstract class Page { protected static locators = { - app: 'app-root', + root: 'app-root', layout: 'app-layout', overlay: '.cdk-overlay-container', dialogContainer: '.mat-dialog-container', @@ -42,7 +42,8 @@ export abstract class Page { 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)); overlay: ElementFinder = browser.element(by.css(Page.locators.overlay)); snackBar: ElementFinder = browser.element(by.css(Page.locators.snackBar)); diff --git a/e2e/pages/search-results-page.ts b/e2e/pages/search-results-page.ts index c6895a645..4ea97d3f2 100755 --- a/e2e/pages/search-results-page.ts +++ b/e2e/pages/search-results-page.ts @@ -44,8 +44,8 @@ export class SearchResultsPage extends BrowsingPage { chipList: ElementFinder = this.root.element(by.css(SearchResultsPage.selectors.chipList)); infoText: ElementFinder = this.root.element(by.css(SearchResultsPage.selectors.infoText)); - sortingPicker = new SearchSortingPicker(this.root); - filters = new SearchFilters(this.root); + sortingPicker = new SearchSortingPicker(SearchResultsPage.selectors.root); + filters = new SearchFilters(SearchResultsPage.selectors.root); async waitForResults(): Promise { await this.dataTable.waitForBody(); diff --git a/e2e/suites/actions-available/generic.test.ts b/e2e/suites/actions-available/generic.test.ts index 467b2d5c2..b0f4517bc 100755 --- a/e2e/suites/actions-available/generic.test.ts +++ b/e2e/suites/actions-available/generic.test.ts @@ -187,7 +187,7 @@ describe('Generic tests : ', () => { await dataTable.rightClickOnItem(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 dataTable.hasCheckMarkIcon(file1)).toBe(true, `${file1} is not 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 () => { 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); - 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 () => { @@ -212,13 +212,13 @@ describe('Generic tests : ', () => { await dataTable.clickItem(folder2); 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 dataTable.clickItem(file1); await dataTable.clickItem(file2); 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'); }); }); diff --git a/e2e/suites/actions/copy.test.ts b/e2e/suites/actions/copy.test.ts index aa1b0267d..791228ac1 100755 --- a/e2e/suites/actions/copy.test.ts +++ b/e2e/suites/actions/copy.test.ts @@ -631,7 +631,7 @@ describe('Copy content', () => { expect(await dataTable.isItemPresent(fileName)).toBe(false, `${fileName} present in ${destination} folder`); 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) { @@ -654,7 +654,7 @@ describe('Copy content', () => { expect(await dataTable.isItemPresent(folderName)).toBe(false, `${folderName} present in ${destination} folder`); 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) { @@ -681,7 +681,7 @@ describe('Copy content', () => { expect(await dataTable.isItemPresent(`${fileInFolder2}-1`)).toBe(false, `${fileInFolder2}-1 is present in ${destination} folder`); 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) { @@ -708,7 +708,7 @@ describe('Copy content', () => { expect(await dataTable.isItemPresent(file1InFolderExisting)).toBe(false, `${file1InFolderExisting} present in ${folderName} in ${destination} folder`); await page.clickTrash(); - expect(await dataTable.isEmptyList()).toBe(true, 'Trash is not empty'); + expect(await dataTable.isEmpty()).toBe(true, 'Trash is not empty'); } }); diff --git a/e2e/suites/actions/create-file-from-template.test.ts b/e2e/suites/actions/create-file-from-template.test.ts new file mode 100755 index 000000000..89feeb9f7 --- /dev/null +++ b/e2e/suites/actions/create-file-from-template.test.ts @@ -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 . + */ + +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', 'aa', `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'); + }); + }); + }); + +}); diff --git a/e2e/suites/actions/create-folder.test.ts b/e2e/suites/actions/create-folder.test.ts index b42370425..484aca615 100755 --- a/e2e/suites/actions/create-folder.test.ts +++ b/e2e/suites/actions/create-folder.test.ts @@ -23,7 +23,6 @@ * along with Alfresco. If not, see . */ -import { SITE_VISIBILITY, SITE_ROLES } from '../../configs'; import { LoginPage, BrowsingPage } from '../../pages/pages'; import { CreateOrEditFolderDialog } from '../../components/dialog/create-edit-folder-dialog'; import { Utils } from '../../utilities/utils'; @@ -39,7 +38,6 @@ describe('Create folder', () => { const duplicateFolderName = `folder-${Utils.random()}`; const nameWithSpaces = ` folder-${Utils.random()} `; - const sitePrivate = `site-private-${Utils.random()}`; const siteName = `site-${Utils.random()}`; const folderSite = `folder-site-${Utils.random()}`; @@ -59,11 +57,6 @@ describe('Create folder', () => { beforeAll(async (done) => { 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; await apis.user.nodes.createFolder(duplicateFolderName, parentId); @@ -76,7 +69,6 @@ describe('Create folder', () => { }); afterAll(async (done) => { - await apis.admin.sites.deleteSite(sitePrivate); await apis.user.sites.deleteSite(siteName); await apis.user.nodes.deleteNodeById(parentId); done(); diff --git a/e2e/suites/actions/delete-undo-delete.test.ts b/e2e/suites/actions/delete-undo-delete.test.ts index f478e5df5..0b5e09951 100755 --- a/e2e/suites/actions/delete-undo-delete.test.ts +++ b/e2e/suites/actions/delete-undo-delete.test.ts @@ -126,7 +126,7 @@ describe('Delete and undo delete', () => { }); 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 toolbar.clickMoreActionsDelete(); const message = await page.getSnackBarMessage(); @@ -140,7 +140,7 @@ describe('Delete and undo delete', () => { }); 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 toolbar.clickMoreActionsDelete(); const message = await page.getSnackBarMessage(); @@ -155,7 +155,7 @@ describe('Delete and undo delete', () => { }); 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 toolbar.clickMoreActionsDelete(); 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 () => { - const items = await page.dataTable.countRows(); + const items = await page.dataTable.getRowsCount(); await dataTable.selectItem(file5); await toolbar.clickMoreActionsDelete(); @@ -206,7 +206,7 @@ describe('Delete and undo delete', () => { }); 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 toolbar.clickMoreActionsDelete(); @@ -218,7 +218,7 @@ describe('Delete and undo delete', () => { }); 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 toolbar.clickMoreActionsDelete(); @@ -393,7 +393,7 @@ describe('Delete and undo delete', () => { }); 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 toolbar.clickMoreActionsDelete(); @@ -408,7 +408,7 @@ describe('Delete and undo delete', () => { }); 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 toolbar.clickMoreActionsDelete(); @@ -425,7 +425,7 @@ describe('Delete and undo delete', () => { }); 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 toolbar.clickMoreActionsDelete(); 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 () => { - const items = await page.dataTable.countRows(); + const items = await page.dataTable.getRowsCount(); await dataTable.selectItem(favFile5); await toolbar.clickMoreActionsDelete(); @@ -474,7 +474,7 @@ describe('Delete and undo delete', () => { }); 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 toolbar.clickMoreActionsDelete(); @@ -486,7 +486,7 @@ describe('Delete and undo delete', () => { }); 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 toolbar.clickMoreActionsDelete(); diff --git a/e2e/suites/actions/new-menu.test.ts b/e2e/suites/actions/new-menu.test.ts index e5b1349cc..0e4f5a6c6 100755 --- a/e2e/suites/actions/new-menu.test.ts +++ b/e2e/suites/actions/new-menu.test.ts @@ -42,7 +42,7 @@ describe('New menu', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, sidenav } = page; - + const { menu } = sidenav; beforeAll(async (done) => { await apis.admin.people.createUser({ username }); @@ -66,107 +66,87 @@ describe('New menu', () => { done(); }); - it('has correct actions - [C286524]', async () => { + it('Actions in Personal Files - [C286524]', async () => { await page.clickPersonalFiles(); await sidenav.openNewMenu(); - expect(await sidenav.menu.isCreateFolderPresent()).toBe(true, 'Create Folder option not present'); - expect(await sidenav.menu.isCreateLibraryPresent()).toBe(true, 'Create Library option not present'); - 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 menu.isUploadFileEnabled()).toBe(true, 'Upload File option not enabled'); + expect(await menu.isUploadFolderEnabled()).toBe(true, 'Upload Folder option not enabled'); - 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 () => { - 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 () => { + it('Actions in File Libraries - user with enough permissions - [C280393]', async () => { await page.goToMyLibrariesAndWait(); await dataTable.doubleClickOnRowByName(siteUser); 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 dataTable.doubleClickOnRowByName(siteAdmin); 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 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 () => { - await page.goToMyLibrariesAndWait(); - await dataTable.doubleClickOnRowByName(siteUser); - await sidenav.openNewMenu(); + tooltip = await menu.getTooltipForUploadFile(); + expect(tooltip).toContain('Select files to upload'); - 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 () => { - 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'); + tooltip = await menu.getTooltipForCreateFolder(); 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 dataTable.doubleClickOnRowByName(siteAdmin); await sidenav.openNewMenu(); - const tooltip = await sidenav.menu.getItemTooltip('Create Folder'); - expect(tooltip).toContain(`Folders cannot be created whilst viewing the current items`); - }); + let tooltip: string; - it('Create Library button tooltip - [C286526]', async () => { - await sidenav.openNewMenu(); + tooltip = await menu.getTooltipForUploadFile(); + expect(tooltip).toContain('Files cannot be uploaded whilst viewing the current items'); - const tooltip = await sidenav.menu.getItemTooltip('Create Library'); - expect(tooltip).toContain('Create a new File Library'); + tooltip = await menu.getTooltipForUploadFolder(); + 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'); }); }); diff --git a/e2e/suites/list-views/empty-list.test.ts b/e2e/suites/list-views/empty-list.test.ts index 7c06ebdb0..2118b6a5d 100755 --- a/e2e/suites/list-views/empty-list.test.ts +++ b/e2e/suites/list-views/empty-list.test.ts @@ -50,51 +50,51 @@ describe('Empty list views', () => { it('empty Personal Files - [C280131]', async () => { 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'); }); it('empty My Libraries - [C217099]', async () => { 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.getEmptyStateSubtitle()).toContain('Join libraries to upload, view, and share files.'); }); it('empty Favorite Libraries - [C289911]', async () => { 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.getEmptyStateSubtitle()).toContain('Favorite a library that you want to find easily later.'); }); it('empty Shared Files - [C280132]', async () => { 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.getEmptyStateSubtitle()).toContain('Items you share using the Share option are shown here.'); }); it('empty Recent Files - [C213169]', async () => { 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.getEmptyStateSubtitle()).toContain('Items you uploaded or edited in the last 30 days are shown here.'); }); it('empty Favorites - [C280133]', async () => { 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.getEmptyStateSubtitle()).toContain('Favorite items that you want to easily find later.'); }); it('empty Trash - [C280134]', async () => { 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.getEmptyStateText()).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('Items you delete are moved to the Trash.'); + expect(await dataTable.getEmptyListText()).toContain('Empty Trash to permanently delete items.'); }); it('Favorites - pagination controls not displayed - [C280111]', async () => { @@ -197,7 +197,7 @@ describe('Empty list views', () => { await searchInput.searchFor('qwertyuiop'); 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'); }); @@ -208,7 +208,7 @@ describe('Empty list views', () => { await searchInput.searchFor('qwertyuiop'); 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'); }); }); diff --git a/e2e/suites/list-views/favorites.test.ts b/e2e/suites/list-views/favorites.test.ts index dbef1d15e..b1b552cf6 100755 --- a/e2e/suites/list-views/favorites.test.ts +++ b/e2e/suites/list-views/favorites.test.ts @@ -95,7 +95,7 @@ describe('Favorites', () => { }); 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(fileName2)).toBe(true, `${fileName2} not displayed`); expect(await dataTable.isItemPresent(favFolderName)).toBe(true, `${favFolderName} not displayed`); diff --git a/e2e/suites/list-views/file-libraries.test.ts b/e2e/suites/list-views/file-libraries.test.ts index 7ff6e3847..6233e95a1 100755 --- a/e2e/suites/list-views/file-libraries.test.ts +++ b/e2e/suites/list-views/file-libraries.test.ts @@ -110,7 +110,7 @@ describe('File Libraries', () => { }); 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(await dataTable.isItemPresent(adminSite5)).toBe(false, `${adminSite5} should not appear in the list`); @@ -150,10 +150,8 @@ describe('File Libraries', () => { `${siteName} (${siteId1})`, `${siteName} (${siteId2})` ]; - const cells = await dataTable.getCellsContainingName(siteName); - const expectedJSON = JSON.stringify(expectedSites.sort()); - const actualJSON = JSON.stringify(cells.sort()); - expect(actualJSON).toEqual(expectedJSON); + const actualSites = await dataTable.getCellsContainingName(siteName); + expect(actualSites.sort()).toEqual(expectedSites.sort()); }); 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 () => { - const sitesCount = await dataTable.countRows(); + const sitesCount = await dataTable.getRowsCount(); expect(sitesCount).toEqual(9, 'Incorrect number of sites displayed'); expect(await dataTable.isItemPresent(adminSite6)).toBe(false, `${adminSite6} should not appear`); @@ -221,10 +219,8 @@ describe('File Libraries', () => { `${siteName} (${siteId1})`, `${siteName} (${siteId2})` ]; - const cells = await dataTable.getCellsContainingName(siteName); - const expectedJSON = JSON.stringify(expectedSites.sort()); - const actualJSON = JSON.stringify(cells.sort()); - expect(actualJSON).toEqual(expectedJSON); + const actualSites = await dataTable.getCellsContainingName(siteName); + expect(actualSites.sort()).toEqual(expectedSites.sort()); }); it('Tooltip for sites without description - [C289894]', async () => { diff --git a/e2e/suites/list-views/permissions.test.ts b/e2e/suites/list-views/permissions.test.ts index 0e42c6efd..c74b488a2 100755 --- a/e2e/suites/list-views/permissions.test.ts +++ b/e2e/suites/list-views/permissions.test.ts @@ -80,26 +80,26 @@ describe('Special permissions', () => { it('on Recent Files - [C213173]', async () => { 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 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 () => { 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 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 () => { 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 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 () => { @@ -147,19 +147,19 @@ describe('Special permissions', () => { it(`on Recent Files - [C213178]`, async () => { 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'); }); it(`on Favorites - [C213672]`, async () => { 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'); }); it(`on Shared Files - [C213668]`, async () => { 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'); }); diff --git a/e2e/suites/list-views/recent-files.test.ts b/e2e/suites/list-views/recent-files.test.ts index c9ee41353..5a2685708 100755 --- a/e2e/suites/list-views/recent-files.test.ts +++ b/e2e/suites/list-views/recent-files.test.ts @@ -93,7 +93,7 @@ describe('Recent Files', () => { }); 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(fileName2)).toBe(true, `${fileName2} not displayed`); expect(await dataTable.isItemPresent(fileSite)).toBe(true, `${fileSite} not displayed`); diff --git a/e2e/suites/list-views/trash.test.ts b/e2e/suites/list-views/trash.test.ts index 63216feb6..f7304d1ec 100755 --- a/e2e/suites/list-views/trash.test.ts +++ b/e2e/suites/list-views/trash.test.ts @@ -106,7 +106,7 @@ describe('Trash', () => { }); 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(folderAdmin)).toBe(true, `${folderAdmin} not displayed`); @@ -135,7 +135,7 @@ describe('Trash', () => { }); 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(fileUser)).toBe(true, `${fileUser} not displayed`); diff --git a/e2e/suites/pagination/pag-favorites.test.ts b/e2e/suites/pagination/pag-favorites.test.ts index 0a94f9ab9..bb02a7537 100755 --- a/e2e/suites/pagination/pag-favorites.test.ts +++ b/e2e/suites/pagination/pag-favorites.test.ts @@ -155,7 +155,7 @@ describe('Pagination on multiple pages on Favorites', () => { it('Next button is disabled on last page - [C280118]', async () => { await pagination.openCurrentPageMenu(); 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.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); }); diff --git a/e2e/suites/pagination/pag-file-libraries.test.ts b/e2e/suites/pagination/pag-file-libraries.test.ts index 91edddffc..0bb155a3e 100755 --- a/e2e/suites/pagination/pag-file-libraries.test.ts +++ b/e2e/suites/pagination/pag-file-libraries.test.ts @@ -151,7 +151,7 @@ describe('Pagination on multiple pages', () => { it('Next button is disabled on last page - [C280091]', async () => { await pagination.openCurrentPageMenu(); 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.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 () => { await pagination.openCurrentPageMenu(); 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.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); }); diff --git a/e2e/suites/pagination/pag-personal-files.test.ts b/e2e/suites/pagination/pag-personal-files.test.ts index 18a0a948b..4a2b8882c 100755 --- a/e2e/suites/pagination/pag-personal-files.test.ts +++ b/e2e/suites/pagination/pag-personal-files.test.ts @@ -153,7 +153,7 @@ describe('Pagination on multiple pages on Personal Files', () => { it('Next button is disabled on last page - [C280082]', async () => { await pagination.openCurrentPageMenu(); 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.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); }); diff --git a/e2e/suites/pagination/pag-recent-files.test.ts b/e2e/suites/pagination/pag-recent-files.test.ts index 32e377dcf..25ee6728f 100755 --- a/e2e/suites/pagination/pag-recent-files.test.ts +++ b/e2e/suites/pagination/pag-recent-files.test.ts @@ -152,7 +152,7 @@ describe('Pagination on multiple pages on Recent Files', () => { it('Next button is disabled on last page - [C280109]', async () => { await pagination.openCurrentPageMenu(); 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.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); }); diff --git a/e2e/suites/pagination/pag-search-results.test.ts b/e2e/suites/pagination/pag-search-results.test.ts index dd9fa015b..6fa4cbbee 100755 --- a/e2e/suites/pagination/pag-search-results.test.ts +++ b/e2e/suites/pagination/pag-search-results.test.ts @@ -151,7 +151,7 @@ describe('Pagination on multiple pages on Search Results', () => { it('Next button is disabled on last page - [C290130]', async () => { await pagination.openCurrentPageMenu(); 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.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); }); diff --git a/e2e/suites/pagination/pag-shared-files.test.ts b/e2e/suites/pagination/pag-shared-files.test.ts index 4a2695cc3..e63b22c14 100755 --- a/e2e/suites/pagination/pag-shared-files.test.ts +++ b/e2e/suites/pagination/pag-shared-files.test.ts @@ -155,7 +155,7 @@ describe('Pagination on multiple pages on Shared Files', () => { it('Next button is disabled on last page - [C280100]', async () => { await pagination.openCurrentPageMenu(); 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.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); }); diff --git a/e2e/suites/pagination/pag-trash.test.ts b/e2e/suites/pagination/pag-trash.test.ts index bebb729d7..d9ca473d3 100755 --- a/e2e/suites/pagination/pag-trash.test.ts +++ b/e2e/suites/pagination/pag-trash.test.ts @@ -151,7 +151,7 @@ describe('Pagination on multiple pages on Trash', () => { it('Next button is disabled on last page - [C280127]', async () => { await pagination.openCurrentPageMenu(); 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.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); }); diff --git a/e2e/suites/search/search-filters.test.ts b/e2e/suites/search/search-filters.test.ts index 80989f148..2549954ec 100644 --- a/e2e/suites/search/search-filters.test.ts +++ b/e2e/suites/search/search-filters.test.ts @@ -155,7 +155,7 @@ describe('Search filters', () => { await sizeFilter.expandPanel(); 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 () => { diff --git a/e2e/suites/viewer/viewer-actions.test.ts b/e2e/suites/viewer/viewer-actions.test.ts index 2b2ab8b91..ae7a4ba69 100755 --- a/e2e/suites/viewer/viewer-actions.test.ts +++ b/e2e/suites/viewer/viewer-actions.test.ts @@ -225,13 +225,12 @@ describe('Viewer actions', () => { }); it('Upload new version action when node is locked - [MNT-21058]', async () => { - await dataTable.doubleClickOnRowByName(fileForUploadNewVersion2); await viewer.waitForViewerToOpen(); await toolbar.openMoreMenu(); - expect(await toolbar.menu.isCancelEditingActionPresent()).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.isCancelEditingPresent()).toBe(true, `'Cancel Editing' button should be shown`); + expect(await toolbar.menu.isEditOfflinePresent()).toBe(false, `'Edit Offline' shouldn't be shown`); await toolbar.menu.clickMenuItem('Upload New Version'); await Utils.uploadFileNewVersion(docxFile); @@ -240,8 +239,8 @@ describe('Viewer actions', () => { await uploadNewVersionDialog.clickUpload(); await toolbar.openMoreMenu(); - expect(await toolbar.menu.isCancelEditingActionPresent()).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.isCancelEditingPresent()).toBe(false, `'Cancel Editing' button shouldn't be shown`); + expect(await toolbar.menu.isEditOfflinePresent()).toBe(true, `'Edit Offline' should be shown`); }); it('Full screen action - [C279282]', async () => { diff --git a/e2e/utilities/admin-actions.ts b/e2e/utilities/admin-actions.ts new file mode 100755 index 000000000..dc0a5c63a --- /dev/null +++ b/e2e/utilities/admin-actions.ts @@ -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 . + */ + +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 { + return await this.adminApi.nodes.getNodeIdFromParent('Data Dictionary', '-root-'); + } + + async getNodeTemplatesFolderId(): Promise { + return await this.adminApi.nodes.getNodeIdFromParent('Node Templates', await this.getDataDictionaryId()); + } + + async createUser(user: PersonModel): Promise { + return await this.adminApi.people.createUser(user); + } + + async createNodeTemplate(name: string, title: string = '', description: string = '', author: string = ''): Promise { + const templatesRootFolderId: string = await this.getNodeTemplatesFolderId(); + + return await this.adminApi.nodes.createFile(name, templatesRootFolderId, title, description, author); + } + + async createNodeTemplatesHierarchy(hierarchy: NodeContentTree): Promise { + return await this.adminApi.nodes.createContent(hierarchy, `Data Dictionary/Node Templates`); + } + + async removeUserAccessOnNode(nodeName: string): Promise { + 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 { + return await this.adminApi.nodes.deleteNodeChildren(await this.getNodeTemplatesFolderId()); + } + + async createLinkToFileId(originalFileId: string, destinationParentId: string): Promise { + return await this.adminApi.nodes.createNodeLink(originalFileId, destinationParentId); + } + + async createLinkToFileName(originalFileName: string, originalFileParentId: string, destinationParentId?: string): Promise { + if (!destinationParentId) { + destinationParentId = originalFileParentId + }; + + const nodeId = await this.adminApi.nodes.getNodeIdFromParent(originalFileName, originalFileParentId); + + return await this.createLinkToFileId(nodeId, destinationParentId); + } + +} diff --git a/e2e/utilities/repo-client/apis/nodes/nodes-api.ts b/e2e/utilities/repo-client/apis/nodes/nodes-api.ts index e7535ee36..95d160149 100755 --- a/e2e/utilities/repo-client/apis/nodes/nodes-api.ts +++ b/e2e/utilities/repo-client/apis/nodes/nodes-api.ts @@ -36,7 +36,7 @@ export class NodesApi extends RepoApi { super(username, password); } - async getNodeByPath(relativePath: string = '/'): Promise { + async getNodeByPath(relativePath: string = '/'): Promise { try { await this.apiAuth(); return await this.nodesApi.getNode('-my-', { relativePath }); @@ -46,7 +46,7 @@ export class NodesApi extends RepoApi { } } - async getNodeById(id: string): Promise { + async getNodeById(id: string): Promise { try { await this.apiAuth(); const node = await this.nodesApi.getNode(id); @@ -77,7 +77,17 @@ export class NodesApi extends RepoApi { } } - async getNodeProperty(nodeId: string, property: string): Promise { + async getNodeTitle(name: string, parentId: string): Promise { + 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 { try { const node = await this.getNodeById(nodeId); return (node.entry.properties && node.entry.properties[property]) || ''; @@ -179,7 +189,7 @@ export class NodesApi extends RepoApi { } } - async getNodeChildren(nodeId: string): Promise { + async getNodeChildren(nodeId: string): Promise { try { const opts = { include: [ 'properties' ] @@ -202,7 +212,7 @@ export class NodesApi extends RepoApi { } } - async createImageNode(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise { + async createImageNode(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise { const imageProps = { 'exif:pixelXDimension': 1000, 'exif:pixelYDimension': 1200 @@ -211,10 +221,30 @@ export class NodesApi extends RepoApi { return await this.createNode('cm:content', name, parentId, title, description, imageProps); } catch (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 { + async createNodeLink(originalNodeId: string, destinationId: string): Promise { + 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 { const nodeBody = { name, nodeType, @@ -234,34 +264,38 @@ export class NodesApi extends RepoApi { return await this.nodesApi.createNode(parentId, nodeBody, { majorVersion }); } catch (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 { + async createFile(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = '', majorVersion: boolean = true): Promise { try { return await this.createNode('cm:content', name, parentId, title, description, null, author, majorVersion); } catch (error) { this.handleError(`${this.constructor.name} ${this.createFile.name}`, error); + return null; } } - async createImage(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise { + async createImage(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise { try { return await this.createImageNode(name, parentId, title, description); } catch (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 { + async createFolder(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = ''): Promise { try { return await this.createNode('cm:folder', name, parentId, title, description, null, author); } catch (error) { this.handleError(`${this.constructor.name} ${this.createFolder.name}`, error); + return null; } } - async createChildren(data: NodeBodyCreate[]): Promise { + async createChildren(data: NodeBodyCreate[]): Promise { try { await this.apiAuth(); return await this.nodesApi.createNode('-my-', data); @@ -270,7 +304,7 @@ export class NodesApi extends RepoApi { } } - async createContent(content: NodeContentTree, relativePath: string = '/'): Promise { + async createContent(content: NodeContentTree, relativePath: string = '/'): Promise { try { return await this.createChildren(flattenNodeContentTree(content, relativePath)); } catch (error) { @@ -278,7 +312,7 @@ export class NodesApi extends RepoApi { } } - async createFolders(names: string[], relativePath: string = '/'): Promise { + async createFolders(names: string[], relativePath: string = '/'): Promise { try { return await this.createContent({ folders: names }, relativePath); } catch (error) { @@ -286,7 +320,7 @@ export class NodesApi extends RepoApi { } } - async createFiles(names: string[], relativePath: string = '/'): Promise { + async createFiles(names: string[], relativePath: string = '/'): Promise { try { return await this.createContent({ files: names }, relativePath); } catch (error) { @@ -325,6 +359,22 @@ export class NodesApi extends RepoApi { } // node permissions + async setInheritPermissions(nodeId: string, inheritPermissions: boolean): Promise { + 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 { const data = { permissions: { @@ -372,7 +422,7 @@ export class NodesApi extends RepoApi { } } - async getLockType(nodeId: string): Promise { + async getLockType(nodeId: string): Promise { try { const lockType = await this.getNodeProperty(nodeId, 'cm:lockType'); return lockType || ''; @@ -382,7 +432,7 @@ export class NodesApi extends RepoApi { } } - async getLockOwner(nodeId: string): Promise { + async getLockOwner(nodeId: string): Promise { try { const lockOwner = await this.getNodeProperty(nodeId, 'cm:lockOwner'); return lockOwner || ''; diff --git a/e2e/utilities/utils.ts b/e2e/utilities/utils.ts index fba5052fd..842f258c7 100755 --- a/e2e/utilities/utils.ts +++ b/e2e/utilities/utils.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -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'; 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'; // generate a random value - static random() { + static random(): string { return Math.random().toString(36).substring(5, 10).toLowerCase(); } // local storage - static clearLocalStorage(): promise.Promise { - return browser.executeScript('window.localStorage.clear();'); + static async clearLocalStorage(): Promise { + await browser.executeScript('window.localStorage.clear();'); } // session storage - static clearSessionStorage(): promise.Promise { - return browser.executeScript('window.sessionStorage.clear();'); + static async clearSessionStorage(): Promise { + await browser.executeScript('window.sessionStorage.clear();'); } - static getSessionStorage() { - return browser.executeScript('return window.sessionStorage.getItem("app.extension.config");'); + static async getSessionStorage(): Promise { + return await browser.executeScript('return window.sessionStorage.getItem("app.extension.config");'); } - static setSessionStorageFromConfig(configFileName: string) { + static async setSessionStorageFromConfig(configFileName: string): Promise { const configFile = `${E2E_ROOT_PATH}/resources/extensibility-configs/${configFileName}`; 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 { 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, retry: number = 30, delay: number = 1000): Promise { @@ -80,11 +80,11 @@ export class Utils { return run(retry); } - static async waitUntilElementClickable(element: ElementFinder) { + static async waitUntilElementClickable(element: ElementFinder): Promise { 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 { for (let i = 0; i < value.length; i++) { const c = value.charAt(i); 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 { const config = await browser.getProcessedConfig(); 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 { const config = await browser.getProcessedConfig(); const oldFilePath = path.join(config.params.downloadFolder, oldName); 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 { const config = await browser.getProcessedConfig(); const filePath = path.join(config.params.downloadFolder, filename); const output = path.join(config.params.downloadFolder, unzippedName ? unzippedName : ''); @@ -162,23 +162,31 @@ export class Utils { }); } - static async pressEscape() { + static async pressEscape(): Promise { await browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); } - static async pressTab() { + static async pressTab(): Promise { await browser.actions().sendKeys(protractor.Key.TAB).perform(); } - static async getBrowserLog() { + static async pressCmd(): Promise { + await browser.actions().sendKeys(protractor.Key.COMMAND).perform(); + } + + static async releaseKeyPressed(): Promise { + await browser.actions().sendKeys(protractor.Key.NULL).perform(); + } + + static async getBrowserLog(): Promise { return browser.manage().logs().get('browser'); } - static formatDate(date: string) { + static formatDate(date: string): string { return new Date(date).toLocaleDateString('en-US'); } - static async uploadFileNewVersion(fileFromOS: string) { + static async uploadFileNewVersion(fileFromOS: string): Promise { const el = browser.element(by.id('app-upload-file-version')); await el.sendKeys(`${E2E_ROOT_PATH}/resources/test-files/${fileFromOS}`); } diff --git a/protractor.conf.js b/protractor.conf.js index 5b4226e30..2e7c2adf2 100755 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -70,6 +70,7 @@ exports.config = { './e2e/suites/actions/new-menu.test.ts', './e2e/suites/actions/create-folder.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-new-version.test.ts', './e2e/suites/actions/delete-undo-delete.test.ts',