mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
Prettier upgrade and e2e type checks (#1522)
* upgrade prettier * noImplicitAny rule * fix type * update tsconfig * upgrade to 150 print width
This commit is contained in:
@@ -34,7 +34,7 @@ export class Breadcrumb extends Component {
|
||||
}
|
||||
|
||||
async getAllItems(): Promise<string[]> {
|
||||
const items: string[] = await this.items.map(async elem => {
|
||||
const items: string[] = await this.items.map(async (elem) => {
|
||||
const str = await elem.getText();
|
||||
return str.split('\nchevron_right')[0];
|
||||
});
|
||||
|
@@ -39,17 +39,11 @@ export class DropDownBreadcrumb extends Component {
|
||||
}
|
||||
|
||||
async waitForPathListDropdownToOpen(): Promise<void> {
|
||||
return waitForPresence(
|
||||
this.pathItemsContainer,
|
||||
'Timeout waiting for breadcrumb dropdown to open'
|
||||
);
|
||||
return waitForPresence(this.pathItemsContainer, 'Timeout waiting for breadcrumb dropdown to open');
|
||||
}
|
||||
|
||||
async waitForPathListDropdownToClose(): Promise<void> {
|
||||
return waitForStaleness(
|
||||
browser.$(this.pathOptionCss),
|
||||
'Timeout waiting for breadcrumb dropdown to close'
|
||||
);
|
||||
return waitForStaleness(browser.$(this.pathOptionCss), 'Timeout waiting for breadcrumb dropdown to close');
|
||||
}
|
||||
|
||||
async openPath(): Promise<void> {
|
||||
@@ -58,14 +52,12 @@ export class DropDownBreadcrumb extends Component {
|
||||
}
|
||||
|
||||
async clickPathItem(name: string): Promise<void> {
|
||||
const elem = browser.element(
|
||||
by.cssContainingText(this.pathOptionCss, name)
|
||||
);
|
||||
const elem = browser.element(by.cssContainingText(this.pathOptionCss, name));
|
||||
await elem.click();
|
||||
}
|
||||
|
||||
async getPathItems(): Promise<string[]> {
|
||||
const items: string[] = await this.pathItems.map(async elem => {
|
||||
const items: string[] = await this.pathItems.map(async (elem) => {
|
||||
return elem.getText();
|
||||
});
|
||||
return items;
|
||||
|
@@ -23,57 +23,32 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
ElementFinder,
|
||||
browser,
|
||||
by,
|
||||
ElementArrayFinder,
|
||||
ProtractorBrowser
|
||||
} from 'protractor';
|
||||
import { ElementFinder, browser, by, ElementArrayFinder, ProtractorBrowser } from 'protractor';
|
||||
import { waitForPresence } from '../utilities/utils';
|
||||
|
||||
export abstract class Component {
|
||||
component: ElementFinder;
|
||||
|
||||
protected byCss(
|
||||
css: string,
|
||||
root: ElementFinder | ProtractorBrowser = this.component
|
||||
): ElementFinder {
|
||||
protected byCss(css: string, root: ElementFinder | ProtractorBrowser = this.component): ElementFinder {
|
||||
return root.element(by.css(css));
|
||||
}
|
||||
|
||||
protected byCssText(
|
||||
css: string,
|
||||
text: string,
|
||||
root: ElementFinder | ProtractorBrowser = this.component
|
||||
): ElementFinder {
|
||||
protected byCssText(css: string, text: string, root: ElementFinder | ProtractorBrowser = this.component): ElementFinder {
|
||||
return root.element(by.cssContainingText(css, text));
|
||||
}
|
||||
|
||||
protected byId(
|
||||
css: string,
|
||||
root: ElementFinder | ProtractorBrowser = this.component
|
||||
): ElementFinder {
|
||||
protected byId(css: string, root: ElementFinder | ProtractorBrowser = this.component): ElementFinder {
|
||||
return root.element(by.id(css));
|
||||
}
|
||||
|
||||
protected allByCss(
|
||||
css: string,
|
||||
root: ElementFinder | ProtractorBrowser = this.component
|
||||
): ElementArrayFinder {
|
||||
protected allByCss(css: string, root: ElementFinder | ProtractorBrowser = this.component): ElementArrayFinder {
|
||||
return root.all(by.css(css));
|
||||
}
|
||||
|
||||
constructor(selector: string, ancestor?: string) {
|
||||
const locator = selector;
|
||||
|
||||
this.component = ancestor
|
||||
? browser
|
||||
.$$(ancestor)
|
||||
.first()
|
||||
.$$(locator)
|
||||
.first()
|
||||
: browser.$$(locator).first();
|
||||
this.component = ancestor ? browser.$$(ancestor).first().$$(locator).first() : browser.$$(locator).first();
|
||||
}
|
||||
|
||||
async wait() {
|
||||
|
@@ -23,27 +23,16 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
ElementFinder,
|
||||
ElementArrayFinder,
|
||||
by,
|
||||
browser,
|
||||
protractor
|
||||
} from 'protractor';
|
||||
import { ElementFinder, ElementArrayFinder, by, browser, protractor } from 'protractor';
|
||||
import { Logger } from '@alfresco/adf-testing';
|
||||
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
|
||||
import { Component } from '../component';
|
||||
import { Menu } from '../menu/menu';
|
||||
import {
|
||||
Utils,
|
||||
waitForPresence,
|
||||
waitForClickable
|
||||
} from '../../utilities/utils';
|
||||
import { Utils, waitForPresence, waitForClickable } from '../../utilities/utils';
|
||||
|
||||
export class DataTable extends Component {
|
||||
private static selectors = {
|
||||
columnHeader:
|
||||
'.adf-datatable-row .adf-datatable-cell-header .adf-datatable-cell-value',
|
||||
columnHeader: '.adf-datatable-row .adf-datatable-cell-header .adf-datatable-cell-value',
|
||||
sortedColumnHeader: `
|
||||
.adf-datatable__header--sorted-asc .adf-datatable-cell-value,
|
||||
.adf-datatable__header--sorted-desc .adf-datatable-cell-value
|
||||
@@ -58,9 +47,7 @@ export class DataTable extends Component {
|
||||
head = this.byCss('.adf-datatable-header');
|
||||
body = this.byCss('.adf-datatable-body');
|
||||
emptyList = this.byCss('div.adf-no-content-container');
|
||||
emptyFolderDragAndDrop = this.byCss(
|
||||
'.adf-empty-list_template .adf-empty-folder'
|
||||
);
|
||||
emptyFolderDragAndDrop = this.byCss('.adf-empty-list_template .adf-empty-folder');
|
||||
emptyListTitle = this.byCss('.adf-empty-content__title');
|
||||
emptyListSubtitle = this.byCss('.adf-empty-content__subtitle');
|
||||
emptySearchText = this.byCss('.empty-search__text');
|
||||
@@ -94,10 +81,7 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
getColumnHeaderByLabel(label: string): ElementFinder {
|
||||
const locator = by.cssContainingText(
|
||||
DataTable.selectors.columnHeader,
|
||||
label
|
||||
);
|
||||
const locator = by.cssContainingText(DataTable.selectors.columnHeader, label);
|
||||
return this.head.element(locator);
|
||||
}
|
||||
|
||||
@@ -111,9 +95,7 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async getSortingOrder(): Promise<string> {
|
||||
const str = await this.getSortedColumnHeader()
|
||||
.element(by.xpath('..'))
|
||||
.getAttribute('class');
|
||||
const str = await this.getSortedColumnHeader().element(by.xpath('..')).getAttribute('class');
|
||||
if (str.includes('asc')) {
|
||||
return 'asc';
|
||||
}
|
||||
@@ -138,7 +120,7 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async getSelectedRowsNames(): Promise<string[]> {
|
||||
const rowsText: string[] = await this.getSelectedRows().map(row => {
|
||||
const rowsText: string[] = await this.getSelectedRows().map((row) => {
|
||||
return row.element(by.css('.adf-datatable-cell[title="Name"]')).getText();
|
||||
});
|
||||
return rowsText;
|
||||
@@ -152,24 +134,14 @@ export class DataTable extends Component {
|
||||
if (location) {
|
||||
return this.body
|
||||
.all(by.cssContainingText(DataTable.selectors.row, name))
|
||||
.filter(async elem =>
|
||||
browser.isElementPresent(
|
||||
elem.element(
|
||||
by.cssContainingText(DataTable.selectors.cell, location)
|
||||
)
|
||||
)
|
||||
)
|
||||
.filter(async (elem) => browser.isElementPresent(elem.element(by.cssContainingText(DataTable.selectors.cell, location))))
|
||||
.first();
|
||||
}
|
||||
return this.body.element(
|
||||
by.cssContainingText(DataTable.selectors.row, name)
|
||||
);
|
||||
return this.body.element(by.cssContainingText(DataTable.selectors.row, name));
|
||||
}
|
||||
|
||||
getRowCells(name: string, location: string = ''): ElementArrayFinder {
|
||||
return this.getRowByName(name, location).all(
|
||||
by.css(DataTable.selectors.cell)
|
||||
);
|
||||
return this.getRowByName(name, location).all(by.css(DataTable.selectors.cell));
|
||||
}
|
||||
|
||||
async getRowCellsCount(itemName: string): Promise<number> {
|
||||
@@ -184,24 +156,15 @@ export class DataTable extends Component {
|
||||
return this.getRowCells(name, location).get(1);
|
||||
}
|
||||
|
||||
private getRowNameCellSpan(
|
||||
name: string,
|
||||
location: string = ''
|
||||
): ElementFinder {
|
||||
private getRowNameCellSpan(name: string, location: string = ''): ElementFinder {
|
||||
return this.getRowNameCell(name, location).$('span');
|
||||
}
|
||||
|
||||
async getItemNameTooltip(
|
||||
name: string,
|
||||
location: string = ''
|
||||
): Promise<string> {
|
||||
async getItemNameTooltip(name: string, location: string = ''): Promise<string> {
|
||||
return this.getRowNameCellSpan(name, location).getAttribute('title');
|
||||
}
|
||||
|
||||
async hasCheckMarkIcon(
|
||||
itemName: string,
|
||||
location: string = ''
|
||||
): Promise<boolean> {
|
||||
async hasCheckMarkIcon(itemName: string, location: string = ''): Promise<boolean> {
|
||||
const row = this.getRowByName(itemName, location);
|
||||
return row.element(by.css('.mat-icon[class*="selected"]')).isPresent();
|
||||
}
|
||||
@@ -211,10 +174,7 @@ export class DataTable extends Component {
|
||||
return row.element(by.css('img[src*="lock"]')).isPresent();
|
||||
}
|
||||
|
||||
private async hasLockOwnerInfo(
|
||||
itemName: string,
|
||||
location: string = ''
|
||||
): Promise<boolean> {
|
||||
private async hasLockOwnerInfo(itemName: string, location: string = ''): Promise<boolean> {
|
||||
const row = this.getRowByName(itemName, location);
|
||||
return row.element(by.css(DataTable.selectors.lockOwner)).isPresent();
|
||||
}
|
||||
@@ -222,10 +182,7 @@ export class DataTable extends Component {
|
||||
async getLockOwner(itemName: string, location: string = ''): Promise<string> {
|
||||
if (await this.hasLockOwnerInfo(itemName, location)) {
|
||||
const row = this.getRowByName(itemName, location);
|
||||
return row
|
||||
.$(DataTable.selectors.lockOwner)
|
||||
.$('.locked_by--name')
|
||||
.getText();
|
||||
return row.$(DataTable.selectors.lockOwner).$('.locked_by--name').getText();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@@ -238,21 +195,12 @@ export class DataTable extends Component {
|
||||
return this.getNameLink(itemName).isPresent();
|
||||
}
|
||||
|
||||
async doubleClickOnRowByName(
|
||||
name: string,
|
||||
location: string = ''
|
||||
): Promise<void> {
|
||||
async doubleClickOnRowByName(name: string, location: string = ''): Promise<void> {
|
||||
try {
|
||||
const item = this.getRowFirstCell(name, location);
|
||||
await waitForClickable(item);
|
||||
await browser
|
||||
.actions()
|
||||
.mouseMove(item)
|
||||
.perform();
|
||||
await browser
|
||||
.actions()
|
||||
.doubleClick()
|
||||
.perform();
|
||||
await browser.actions().mouseMove(item).perform();
|
||||
await browser.actions().doubleClick().perform();
|
||||
} catch (error) {
|
||||
Logger.error('--- catch: doubleClickOnRowByName', error);
|
||||
}
|
||||
@@ -291,10 +239,7 @@ export class DataTable extends Component {
|
||||
await this.getNameLink(itemName).click();
|
||||
}
|
||||
|
||||
async selectMultipleItems(
|
||||
names: string[],
|
||||
location: string = ''
|
||||
): Promise<void> {
|
||||
async selectMultipleItems(names: string[], location: string = ''): Promise<void> {
|
||||
await this.clearSelection();
|
||||
await Utils.pressCmd();
|
||||
for (const name of names) {
|
||||
@@ -317,26 +262,14 @@ export class DataTable extends Component {
|
||||
|
||||
async rightClickOnItem(itemName: string): Promise<void> {
|
||||
const item = this.getRowFirstCell(itemName);
|
||||
await browser
|
||||
.actions()
|
||||
.mouseMove(item)
|
||||
.perform();
|
||||
await browser
|
||||
.actions()
|
||||
.click(protractor.Button.RIGHT)
|
||||
.perform();
|
||||
await browser.actions().mouseMove(item).perform();
|
||||
await browser.actions().click(protractor.Button.RIGHT).perform();
|
||||
}
|
||||
|
||||
async rightClickOnMultipleSelection(): Promise<void> {
|
||||
const itemFromSelection = this.getSelectedRows().get(0);
|
||||
await browser
|
||||
.actions()
|
||||
.mouseMove(itemFromSelection)
|
||||
.perform();
|
||||
await browser
|
||||
.actions()
|
||||
.click(protractor.Button.RIGHT)
|
||||
.perform();
|
||||
await browser.actions().mouseMove(itemFromSelection).perform();
|
||||
await browser.actions().click(protractor.Button.RIGHT).perform();
|
||||
}
|
||||
|
||||
private getItemLocationEl(name: string): ElementFinder {
|
||||
@@ -349,13 +282,9 @@ export class DataTable extends Component {
|
||||
|
||||
async getItemLocationTooltip(name: string): Promise<string> {
|
||||
const location = this.getItemLocationEl(name).$('a');
|
||||
const condition = () =>
|
||||
location.getAttribute('title').then(value => value && value.length > 0);
|
||||
const condition = () => location.getAttribute('title').then((value) => value && value.length > 0);
|
||||
|
||||
await browser
|
||||
.actions()
|
||||
.mouseMove(location)
|
||||
.perform();
|
||||
await browser.actions().mouseMove(location).perform();
|
||||
|
||||
await browser.wait(condition, BROWSER_WAIT_TIMEOUT);
|
||||
return location.getAttribute('title');
|
||||
@@ -402,10 +331,8 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async getCellsContainingName(name: string): Promise<string[]> {
|
||||
const rows = this.getRows().all(
|
||||
by.cssContainingText(DataTable.selectors.cell, name)
|
||||
);
|
||||
const cellsText: string[] = await rows.map(async cell => {
|
||||
const rows = this.getRows().all(by.cssContainingText(DataTable.selectors.cell, name));
|
||||
const cellsText: string[] = await rows.map(async (cell) => {
|
||||
return cell.getText();
|
||||
});
|
||||
return cellsText;
|
||||
@@ -417,9 +344,7 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async getLibraryRole(name: string): Promise<string> {
|
||||
return this.getRowByName(name)
|
||||
.element(by.css('adf-library-role-column'))
|
||||
.getText();
|
||||
return this.getRowByName(name).element(by.css('adf-library-role-column')).getText();
|
||||
}
|
||||
|
||||
async isItemPresent(name: string, location?: string): Promise<boolean> {
|
||||
@@ -427,25 +352,25 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
private async getEntireDataTableText(): Promise<string[]> {
|
||||
const text: string[] = await this.getRows().map(row => {
|
||||
return row.all(by.css(DataTable.selectors.cell)).map(async cell => {
|
||||
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(): Promise<{}> {
|
||||
const data = await this.getEntireDataTableText();
|
||||
return data.reduce((acc, cell) => {
|
||||
async getSitesNameAndVisibility(): Promise<any> {
|
||||
const data: string[] = await this.getEntireDataTableText();
|
||||
return data.reduce((acc: any, cell) => {
|
||||
acc[cell[1]] = cell[4].toUpperCase();
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
async getSitesNameAndRole(): Promise<{}> {
|
||||
const data = await this.getEntireDataTableText();
|
||||
return data.reduce((acc, cell) => {
|
||||
async getSitesNameAndRole(): Promise<any> {
|
||||
const data: string[] = await this.getEntireDataTableText();
|
||||
return data.reduce((acc: any, cell) => {
|
||||
acc[cell[1]] = cell[3];
|
||||
return acc;
|
||||
}, {});
|
||||
@@ -459,100 +384,53 @@ export class DataTable extends Component {
|
||||
return this.getSearchResultsRows().get(nth - 1);
|
||||
}
|
||||
|
||||
private getSearchResultsRowByName(
|
||||
name: string,
|
||||
location: string = ''
|
||||
): ElementFinder {
|
||||
private getSearchResultsRowByName(name: string, location: string = ''): ElementFinder {
|
||||
if (location) {
|
||||
return this.body
|
||||
.all(by.cssContainingText(DataTable.selectors.searchResultsRow, name))
|
||||
.filter(async elem =>
|
||||
browser.isElementPresent(
|
||||
elem.element(
|
||||
by.cssContainingText(
|
||||
DataTable.selectors.searchResultsRowLine,
|
||||
location
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.filter(async (elem) => browser.isElementPresent(elem.element(by.cssContainingText(DataTable.selectors.searchResultsRowLine, location))))
|
||||
.first();
|
||||
}
|
||||
return this.body.element(
|
||||
by.cssContainingText(DataTable.selectors.searchResultsRow, name)
|
||||
);
|
||||
return this.body.element(by.cssContainingText(DataTable.selectors.searchResultsRow, name));
|
||||
}
|
||||
|
||||
private getSearchResultRowLines(
|
||||
name: string,
|
||||
location: string = ''
|
||||
): ElementArrayFinder {
|
||||
return this.getSearchResultsRowByName(name, location).all(
|
||||
by.css(DataTable.selectors.searchResultsRowLine)
|
||||
);
|
||||
private getSearchResultRowLines(name: string, location: string = ''): ElementArrayFinder {
|
||||
return this.getSearchResultsRowByName(name, location).all(by.css(DataTable.selectors.searchResultsRowLine));
|
||||
}
|
||||
|
||||
async getSearchResultLinesCount(
|
||||
name: string,
|
||||
location: string = ''
|
||||
): Promise<number> {
|
||||
async getSearchResultLinesCount(name: string, location: string = ''): Promise<number> {
|
||||
return this.getSearchResultRowLines(name, location).count();
|
||||
}
|
||||
|
||||
private getSearchResultNthLine(
|
||||
name: string,
|
||||
location: string = '',
|
||||
index: number
|
||||
): ElementFinder {
|
||||
private getSearchResultNthLine(name: string, location: string = '', index: number): ElementFinder {
|
||||
return this.getSearchResultRowLines(name, location).get(index);
|
||||
}
|
||||
|
||||
async getSearchResultNameAndTitle(
|
||||
name: string,
|
||||
location: string = ''
|
||||
): Promise<string> {
|
||||
async getSearchResultNameAndTitle(name: string, location: string = ''): Promise<string> {
|
||||
return this.getSearchResultNthLine(name, location, 0).getText();
|
||||
}
|
||||
|
||||
async getSearchResultDescription(
|
||||
name: string,
|
||||
location: string = ''
|
||||
): Promise<string> {
|
||||
async getSearchResultDescription(name: string, location: string = ''): Promise<string> {
|
||||
return this.getSearchResultNthLine(name, location, 1).getText();
|
||||
}
|
||||
|
||||
async getSearchResultModified(
|
||||
name: string,
|
||||
location: string = ''
|
||||
): Promise<string> {
|
||||
async getSearchResultModified(name: string, location: string = ''): Promise<string> {
|
||||
return this.getSearchResultNthLine(name, location, 2).getText();
|
||||
}
|
||||
|
||||
async getSearchResultLocation(
|
||||
name: string,
|
||||
location: string = ''
|
||||
): Promise<string> {
|
||||
async getSearchResultLocation(name: string, location: string = ''): Promise<string> {
|
||||
return this.getSearchResultNthLine(name, location, 3).getText();
|
||||
}
|
||||
|
||||
private getSearchResultNameLink(
|
||||
itemName: string,
|
||||
location: string = ''
|
||||
): ElementFinder {
|
||||
private getSearchResultNameLink(itemName: string, location: string = ''): ElementFinder {
|
||||
return this.getSearchResultsRowByName(itemName, location).$('.link');
|
||||
}
|
||||
|
||||
async hasLinkOnSearchResultName(
|
||||
itemName: string,
|
||||
location: string = ''
|
||||
): Promise<boolean> {
|
||||
async hasLinkOnSearchResultName(itemName: string, location: string = ''): Promise<boolean> {
|
||||
return this.getSearchResultNameLink(itemName, location).isPresent();
|
||||
}
|
||||
|
||||
async clickSearchResultNameLink(
|
||||
itemName: string,
|
||||
location: string = ''
|
||||
): Promise<void> {
|
||||
async clickSearchResultNameLink(itemName: string, location: string = ''): Promise<void> {
|
||||
await this.getSearchResultNameLink(itemName, location).click();
|
||||
}
|
||||
}
|
||||
|
@@ -25,8 +25,8 @@
|
||||
|
||||
import { by, browser } from 'protractor';
|
||||
import { Component } from '../component';
|
||||
import * as moment from 'moment';
|
||||
import { isPresentAndDisplayed, waitForStaleness } from '../../utilities/utils';
|
||||
const moment = require('moment');
|
||||
|
||||
export class DateTimePicker extends Component {
|
||||
calendar = this.byCss('.mat-datetimepicker-popup', browser);
|
||||
@@ -55,11 +55,8 @@ export class DateTimePicker extends Component {
|
||||
const dayOfTomorrow = tomorrow.date();
|
||||
const date = await this.headerDate.getText();
|
||||
const year = await this.headerYear.getText();
|
||||
const firstActiveDay =
|
||||
'.mat-datetimepicker-calendar-body-active .mat-datetimepicker-calendar-body-cell-content';
|
||||
const elem = this.dayPicker.element(
|
||||
by.cssContainingText(firstActiveDay, `${dayOfTomorrow}`)
|
||||
);
|
||||
const firstActiveDay = '.mat-datetimepicker-calendar-body-active .mat-datetimepicker-calendar-body-cell-content';
|
||||
const elem = this.dayPicker.element(by.cssContainingText(firstActiveDay, `${dayOfTomorrow}`));
|
||||
await elem.click();
|
||||
return `${date} ${year}`;
|
||||
}
|
||||
|
@@ -25,41 +25,18 @@
|
||||
|
||||
import { by, browser, protractor } from 'protractor';
|
||||
import { GenericDialog } from '../dialog/generic-dialog';
|
||||
import {
|
||||
Utils,
|
||||
isPresentAndDisplayed,
|
||||
waitForStaleness,
|
||||
waitForPresence,
|
||||
isPresentAndEnabled,
|
||||
waitForClickable
|
||||
} from '../../utilities/utils';
|
||||
import { Utils, isPresentAndDisplayed, waitForStaleness, waitForPresence, isPresentAndEnabled, waitForClickable } from '../../utilities/utils';
|
||||
import { DropDownBreadcrumb } from '../breadcrumb/dropdown-breadcrumb';
|
||||
import { DataTable } from '../data-table/data-table';
|
||||
|
||||
export class ContentNodeSelectorDialog extends GenericDialog {
|
||||
cancelButton = this.childElement(
|
||||
by.css('[data-automation-id="content-node-selector-actions-cancel"]')
|
||||
);
|
||||
copyButton = this.childElement(
|
||||
by.cssContainingText(
|
||||
'[data-automation-id="content-node-selector-actions-choose"]',
|
||||
'Copy'
|
||||
)
|
||||
);
|
||||
moveButton = this.childElement(
|
||||
by.cssContainingText(
|
||||
'[data-automation-id="content-node-selector-actions-choose"]',
|
||||
'Move'
|
||||
)
|
||||
);
|
||||
cancelButton = this.childElement(by.css('[data-automation-id="content-node-selector-actions-cancel"]'));
|
||||
copyButton = this.childElement(by.cssContainingText('[data-automation-id="content-node-selector-actions-choose"]', 'Copy'));
|
||||
moveButton = this.childElement(by.cssContainingText('[data-automation-id="content-node-selector-actions-choose"]', 'Move'));
|
||||
|
||||
locationDropDown = this.rootElem.element(by.id('site-dropdown-container'));
|
||||
locationPersonalFiles = browser.element(
|
||||
by.cssContainingText('.mat-option .mat-option-text', 'Personal Files')
|
||||
);
|
||||
locationFileLibraries = browser.element(
|
||||
by.cssContainingText('.mat-option .mat-option-text', 'My Libraries')
|
||||
);
|
||||
locationPersonalFiles = browser.element(by.cssContainingText('.mat-option .mat-option-text', 'Personal Files'));
|
||||
locationFileLibraries = browser.element(by.cssContainingText('.mat-option .mat-option-text', 'My Libraries'));
|
||||
|
||||
searchInput = this.rootElem.element(by.css('#searchInput'));
|
||||
toolbarTitle = this.rootElem.element(by.css('.adf-toolbar-title'));
|
||||
|
@@ -25,26 +25,15 @@
|
||||
|
||||
import { by } from 'protractor';
|
||||
import { GenericDialog } from '../dialog/generic-dialog';
|
||||
import {
|
||||
isPresentAndDisplayed,
|
||||
waitForClickable,
|
||||
isPresentAndEnabled,
|
||||
typeText
|
||||
} from '../../utilities/utils';
|
||||
import { isPresentAndDisplayed, waitForClickable, isPresentAndEnabled, typeText } from '../../utilities/utils';
|
||||
|
||||
export class CreateOrEditFolderDialog extends GenericDialog {
|
||||
createButton = this.childElement(
|
||||
by.cssContainingText('.mat-dialog-actions button', 'Create')
|
||||
);
|
||||
createButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'Create'));
|
||||
cancelButton = this.childElement(by.id('adf-folder-cancel-button'));
|
||||
updateButton = this.childElement(
|
||||
by.cssContainingText('.mat-dialog-actions button', 'Update')
|
||||
);
|
||||
updateButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'Update'));
|
||||
|
||||
nameInput = this.rootElem.element(by.css('input[placeholder="Name" i]'));
|
||||
descriptionTextArea = this.rootElem.element(
|
||||
by.css('textarea[placeholder="Description" i]')
|
||||
);
|
||||
descriptionTextArea = this.rootElem.element(by.css('textarea[placeholder="Description" i]'));
|
||||
validationMessage = this.rootElem.element(by.css('.mat-hint span'));
|
||||
|
||||
constructor() {
|
||||
|
@@ -25,25 +25,15 @@
|
||||
|
||||
import { by } from 'protractor';
|
||||
import { GenericDialog } from '../dialog/generic-dialog';
|
||||
import {
|
||||
isPresentAndDisplayed,
|
||||
isPresentAndEnabled,
|
||||
typeText
|
||||
} from '../../utilities/utils';
|
||||
import { isPresentAndDisplayed, isPresentAndEnabled, typeText } from '../../utilities/utils';
|
||||
|
||||
export class CreateFromTemplateDialog extends GenericDialog {
|
||||
createButton = this.childElement(
|
||||
by.cssContainingText('.mat-dialog-actions button', 'Create')
|
||||
);
|
||||
cancelButton = this.childElement(
|
||||
by.cssContainingText('.mat-dialog-actions button', 'CANCEL')
|
||||
);
|
||||
createButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'Create'));
|
||||
cancelButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'CANCEL'));
|
||||
|
||||
nameInput = this.childElement(by.css('input[placeholder="Name" i]'));
|
||||
titleInput = this.childElement(by.css('input[placeholder="Title" i]'));
|
||||
descriptionTextArea = this.childElement(
|
||||
by.css('textarea[placeholder="Description" i]')
|
||||
);
|
||||
descriptionTextArea = this.childElement(by.css('textarea[placeholder="Description" i]'));
|
||||
validationMessage = this.childElement(by.css('.mat-error'));
|
||||
|
||||
constructor() {
|
||||
|
@@ -25,36 +25,18 @@
|
||||
|
||||
import { by, ElementFinder } from 'protractor';
|
||||
import { GenericDialog } from '../dialog/generic-dialog';
|
||||
import {
|
||||
waitForClickable,
|
||||
isPresentAndEnabled,
|
||||
typeText
|
||||
} from '../../utilities/utils';
|
||||
import { waitForClickable, isPresentAndEnabled, typeText } from '../../utilities/utils';
|
||||
|
||||
export class CreateLibraryDialog extends GenericDialog {
|
||||
createButton = this.childElement(
|
||||
by.cssContainingText('.mat-dialog-actions button', 'Create')
|
||||
);
|
||||
cancelButton = this.childElement(
|
||||
by.cssContainingText('.mat-dialog-actions button', 'Cancel')
|
||||
);
|
||||
createButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'Create'));
|
||||
cancelButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'Cancel'));
|
||||
|
||||
nameInput = this.rootElem.element(by.css('input[placeholder="Name" i]'));
|
||||
libraryIdInput = this.rootElem.element(
|
||||
by.css('input[placeholder="Library ID" i]')
|
||||
);
|
||||
descriptionTextArea = this.rootElem.element(
|
||||
by.css('textarea[placeholder="Description" i]')
|
||||
);
|
||||
visibilityPublic = this.rootElem.element(
|
||||
by.cssContainingText('.mat-radio-label', 'Public')
|
||||
);
|
||||
visibilityModerated = this.rootElem.element(
|
||||
by.cssContainingText('.mat-radio-label', 'Moderated')
|
||||
);
|
||||
visibilityPrivate = this.rootElem.element(
|
||||
by.cssContainingText('.mat-radio-label', 'Private')
|
||||
);
|
||||
libraryIdInput = this.rootElem.element(by.css('input[placeholder="Library ID" i]'));
|
||||
descriptionTextArea = this.rootElem.element(by.css('textarea[placeholder="Description" i]'));
|
||||
visibilityPublic = this.rootElem.element(by.cssContainingText('.mat-radio-label', 'Public'));
|
||||
visibilityModerated = this.rootElem.element(by.cssContainingText('.mat-radio-label', 'Moderated'));
|
||||
visibilityPrivate = this.rootElem.element(by.cssContainingText('.mat-radio-label', 'Private'));
|
||||
|
||||
errorMessage = this.rootElem.element(by.css('.mat-error'));
|
||||
|
||||
@@ -100,9 +82,7 @@ export class CreateLibraryDialog extends GenericDialog {
|
||||
}
|
||||
|
||||
private async isChecked(target: ElementFinder): Promise<boolean> {
|
||||
const elemClass = await target
|
||||
.element(by.xpath('..'))
|
||||
.getAttribute('class');
|
||||
const elemClass = await target.element(by.xpath('..')).getAttribute('class');
|
||||
return elemClass.includes('mat-radio-checked');
|
||||
}
|
||||
|
||||
|
@@ -24,12 +24,7 @@
|
||||
*/
|
||||
|
||||
import { ElementFinder, by, browser, Locator } from 'protractor';
|
||||
import {
|
||||
isPresentAndDisplayed,
|
||||
waitForPresence,
|
||||
waitForVisibility,
|
||||
waitForStaleness
|
||||
} from '../../utilities/utils';
|
||||
import { isPresentAndDisplayed, waitForPresence, waitForVisibility, waitForStaleness } from '../../utilities/utils';
|
||||
|
||||
export abstract class GenericDialog {
|
||||
constructor(private rootCssSelector?: string) {}
|
||||
|
@@ -25,19 +25,11 @@
|
||||
|
||||
import { by, browser } from 'protractor';
|
||||
import { GenericDialog } from '../dialog/generic-dialog';
|
||||
import {
|
||||
waitForClickable,
|
||||
isPresentAndEnabled,
|
||||
typeText
|
||||
} from '../../utilities/utils';
|
||||
import { waitForClickable, isPresentAndEnabled, typeText } from '../../utilities/utils';
|
||||
|
||||
export class PasswordDialog extends GenericDialog {
|
||||
closeButton = this.childElement(
|
||||
by.css('[data-automation-id="adf-password-dialog-close"]')
|
||||
);
|
||||
submitButton = this.childElement(
|
||||
by.css('[data-automation-id="adf-password-dialog-submit"]')
|
||||
);
|
||||
closeButton = this.childElement(by.css('[data-automation-id="adf-password-dialog-close"]'));
|
||||
submitButton = this.childElement(by.css('[data-automation-id="adf-password-dialog-submit"]'));
|
||||
passwordInput = this.childElement(by.css('input[type="Password"]'));
|
||||
errorMessage = this.childElement(by.css('.mat-error'));
|
||||
|
||||
@@ -79,10 +71,7 @@ export class PasswordDialog extends GenericDialog {
|
||||
async isErrorDisplayed(): Promise<boolean> {
|
||||
try {
|
||||
await this.waitForDialogToOpen();
|
||||
return (
|
||||
(await this.errorMessage.isPresent()) &&
|
||||
(await this.errorMessage.isDisplayed())
|
||||
);
|
||||
return (await this.errorMessage.isPresent()) && (await this.errorMessage.isDisplayed());
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -30,13 +30,8 @@ import { DataTable } from '../data-table/data-table';
|
||||
import { isPresentAndEnabled } from '../../utilities/utils';
|
||||
|
||||
export class SelectTemplateDialog extends GenericDialog {
|
||||
nextButton = this.childElement(
|
||||
by.css('[data-automation-id="content-node-selector-actions-choose"]')
|
||||
);
|
||||
|
||||
cancelButton = this.childElement(
|
||||
by.css('[data-automation-id="content-node-selector-actions-cancel"]')
|
||||
);
|
||||
nextButton = this.childElement(by.css('[data-automation-id="content-node-selector-actions-choose"]'));
|
||||
cancelButton = this.childElement(by.css('[data-automation-id="content-node-selector-actions-cancel"]'));
|
||||
|
||||
breadcrumb = new DropDownBreadcrumb();
|
||||
dataTable = new DataTable('.aca-template-node-selector-dialog');
|
||||
|
@@ -31,27 +31,17 @@ import { isPresentAndEnabled } from '../../utilities/utils';
|
||||
export class ShareDialog extends GenericDialog {
|
||||
dateTimePicker = new DateTimePicker();
|
||||
|
||||
dialogTitle = this.childElement(
|
||||
by.css(`[data-automation-id='adf-share-dialog-title']`)
|
||||
);
|
||||
dialogTitle = this.childElement(by.css(`[data-automation-id='adf-share-dialog-title']`));
|
||||
infoText = this.childElement(by.css('.adf-share-link__info'));
|
||||
labels = this.rootElem.all(by.css('.adf-share-link__label'));
|
||||
shareToggle = this.childElement(
|
||||
by.css(`[data-automation-id='adf-share-toggle']`)
|
||||
);
|
||||
shareToggle = this.childElement(by.css(`[data-automation-id='adf-share-toggle']`));
|
||||
url = this.childElement(by.css(`[data-automation-id='adf-share-link']`));
|
||||
urlAction = this.childElement(by.css('.adf-input-action'));
|
||||
expireToggle = this.childElement(
|
||||
by.css(`[data-automation-id='adf-expire-toggle']`)
|
||||
);
|
||||
expireToggle = this.childElement(by.css(`[data-automation-id='adf-expire-toggle']`));
|
||||
expireInput = this.childElement(by.css('input[formcontrolname="time"]'));
|
||||
datetimePickerButton = this.childElement(
|
||||
by.css('.mat-datetimepicker-toggle')
|
||||
);
|
||||
datetimePickerButton = this.childElement(by.css('.mat-datetimepicker-toggle'));
|
||||
|
||||
closeButton = this.childElement(
|
||||
by.css(`[data-automation-id='adf-share-dialog-close']`)
|
||||
);
|
||||
closeButton = this.childElement(by.css(`[data-automation-id='adf-share-dialog-close']`));
|
||||
|
||||
constructor() {
|
||||
super('.adf-share-dialog');
|
||||
|
@@ -28,18 +28,10 @@ import { GenericDialog } from '../dialog/generic-dialog';
|
||||
import { isPresentAndEnabled, typeText } from '../../utilities/utils';
|
||||
|
||||
export class UploadNewVersionDialog extends GenericDialog {
|
||||
cancelButton = this.childElement(
|
||||
by.cssContainingText('.mat-button-wrapper', 'Cancel')
|
||||
);
|
||||
uploadButton = this.childElement(
|
||||
by.cssContainingText('.mat-button-wrapper', 'Upload')
|
||||
);
|
||||
majorOption = this.childElement(
|
||||
by.cssContainingText(`.mat-radio-label`, 'major')
|
||||
);
|
||||
minorOption = this.childElement(
|
||||
by.cssContainingText(`.mat-radio-label`, 'minor')
|
||||
);
|
||||
cancelButton = this.childElement(by.cssContainingText('.mat-button-wrapper', 'Cancel'));
|
||||
uploadButton = this.childElement(by.cssContainingText('.mat-button-wrapper', 'Upload'));
|
||||
majorOption = this.childElement(by.cssContainingText(`.mat-radio-label`, 'major'));
|
||||
minorOption = this.childElement(by.cssContainingText(`.mat-radio-label`, 'minor'));
|
||||
description = this.childElement(by.css('textarea'));
|
||||
|
||||
constructor() {
|
||||
|
@@ -64,18 +64,12 @@ export class CommentsTab extends Component {
|
||||
}
|
||||
|
||||
private async getCommentListItem() {
|
||||
return browser.wait(
|
||||
until.elementLocated(this.commentListItem),
|
||||
BROWSER_WAIT_TIMEOUT / 2
|
||||
);
|
||||
return browser.wait(until.elementLocated(this.commentListItem), BROWSER_WAIT_TIMEOUT / 2);
|
||||
}
|
||||
|
||||
async getCommentById(commentId?: string) {
|
||||
if (commentId) {
|
||||
return browser.wait(
|
||||
until.elementLocated(by.id(`adf-comment-${commentId}`)),
|
||||
BROWSER_WAIT_TIMEOUT / 2
|
||||
);
|
||||
return browser.wait(until.elementLocated(by.id(`adf-comment-${commentId}`)), BROWSER_WAIT_TIMEOUT / 2);
|
||||
}
|
||||
return this.getCommentListItem();
|
||||
}
|
||||
@@ -86,9 +80,7 @@ export class CommentsTab extends Component {
|
||||
|
||||
async isCommentUserAvatarDisplayed(commentId?: string) {
|
||||
const commentElement = await this.getCommentById(commentId);
|
||||
return browser.isElementPresent(
|
||||
commentElement.findElement(this.commentUserAvatar)
|
||||
);
|
||||
return browser.isElementPresent(commentElement.findElement(this.commentUserAvatar));
|
||||
}
|
||||
|
||||
async getCommentText(commentId?: string) {
|
||||
|
@@ -25,11 +25,7 @@
|
||||
|
||||
import { by, browser, ElementFinder } from 'protractor';
|
||||
import { Component } from '../component';
|
||||
import {
|
||||
isPresentAndEnabled,
|
||||
isPresentAndDisplayed,
|
||||
waitForVisibility
|
||||
} from '../../utilities/utils';
|
||||
import { isPresentAndEnabled, isPresentAndDisplayed, waitForVisibility } from '../../utilities/utils';
|
||||
|
||||
export class ContentMetadata extends Component {
|
||||
expandedPanel = this.byCss('.mat-expansion-panel.mat-expanded');
|
||||
@@ -37,20 +33,10 @@ export class ContentMetadata extends Component {
|
||||
propertyListElements = this.allByCss('.adf-property');
|
||||
propertyValue = this.byCss('.adf-property-value');
|
||||
editPropertiesButton = this.byCss(`button[title='Edit']`);
|
||||
lessInfoButton = this.byCssText(
|
||||
`[data-automation-id='meta-data-card-toggle-expand']`,
|
||||
'Less information'
|
||||
);
|
||||
moreInfoButton = this.byCssText(
|
||||
`[data-automation-id='meta-data-card-toggle-expand']`,
|
||||
'More information'
|
||||
);
|
||||
imagePropertiesPanel = this.byCss(
|
||||
`[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE']`
|
||||
);
|
||||
expandedImagePropertiesPanel = this.byCss(
|
||||
`[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE'].mat-expanded`
|
||||
);
|
||||
lessInfoButton = this.byCssText(`[data-automation-id='meta-data-card-toggle-expand']`, 'Less information');
|
||||
moreInfoButton = this.byCssText(`[data-automation-id='meta-data-card-toggle-expand']`, 'More information');
|
||||
imagePropertiesPanel = this.byCss(`[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE']`);
|
||||
expandedImagePropertiesPanel = this.byCss(`[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE'].mat-expanded`);
|
||||
|
||||
constructor(ancestor?: string) {
|
||||
super('adf-content-metadata-card', ancestor);
|
||||
@@ -66,14 +52,14 @@ export class ContentMetadata extends Component {
|
||||
|
||||
async getVisiblePropertiesLabels(): Promise<string[]> {
|
||||
return this.allByCss('.adf-property-label')
|
||||
.filter(async elem => elem.isDisplayed())
|
||||
.map(async elem => elem.getText());
|
||||
.filter(async (elem) => elem.isDisplayed())
|
||||
.map(async (elem) => elem.getText());
|
||||
}
|
||||
|
||||
async getVisiblePropertiesValues() {
|
||||
return this.allByCss('.adf-property-value')
|
||||
.filter(async elem => elem.isDisplayed())
|
||||
.map(async elem => {
|
||||
.filter(async (elem) => elem.isDisplayed())
|
||||
.map(async (elem) => {
|
||||
if (await elem.isElementPresent(by.css('.mat-checkbox'))) {
|
||||
if (await elem.isElementPresent(by.css('.mat-checkbox-checked'))) {
|
||||
return true;
|
||||
|
@@ -26,11 +26,7 @@
|
||||
import { by, browser } from 'protractor';
|
||||
import { Logger } from '@alfresco/adf-testing';
|
||||
import { Component } from '../component';
|
||||
import {
|
||||
waitForPresence,
|
||||
waitForStaleness,
|
||||
typeText
|
||||
} from '../../utilities/utils';
|
||||
import { waitForPresence, waitForStaleness, typeText } from '../../utilities/utils';
|
||||
|
||||
export class LibraryMetadata extends Component {
|
||||
metadataTabContent = this.byCss('.mat-card-content');
|
||||
@@ -38,21 +34,9 @@ export class LibraryMetadata extends Component {
|
||||
fieldLabelWrapper = this.byCss('.mat-form-field-label-wrapper');
|
||||
fieldInput = this.byCss('.mat-input-element');
|
||||
visibilityDropDown = this.component.element(by.css('.mat-select'));
|
||||
visibilityPublic = this.byCssText(
|
||||
'.mat-option .mat-option-text',
|
||||
'Public',
|
||||
browser
|
||||
);
|
||||
visibilityPrivate = this.byCssText(
|
||||
'.mat-option .mat-option-text',
|
||||
'Private',
|
||||
browser
|
||||
);
|
||||
visibilityModerated = this.byCssText(
|
||||
'.mat-option .mat-option-text',
|
||||
'Moderated',
|
||||
browser
|
||||
);
|
||||
visibilityPublic = this.byCssText('.mat-option .mat-option-text', 'Public', browser);
|
||||
visibilityPrivate = this.byCssText('.mat-option .mat-option-text', 'Private', browser);
|
||||
visibilityModerated = this.byCssText('.mat-option .mat-option-text', 'Moderated', browser);
|
||||
hint = this.byCss('.mat-hint');
|
||||
error = this.byCss('.mat-error');
|
||||
|
||||
@@ -66,9 +50,7 @@ export class LibraryMetadata extends Component {
|
||||
|
||||
private getFieldByName(fieldName: string) {
|
||||
const wrapper = this.getLabelWrapper(fieldName);
|
||||
return wrapper
|
||||
.element(by.xpath('..'))
|
||||
.element(by.css('.mat-input-element'));
|
||||
return wrapper.element(by.xpath('..')).element(by.css('.mat-input-element'));
|
||||
}
|
||||
|
||||
private async isFieldDisplayed(fieldName: string) {
|
||||
@@ -158,9 +140,7 @@ export class LibraryMetadata extends Component {
|
||||
|
||||
async isVisibilityEnabled() {
|
||||
const wrapper = this.getLabelWrapper('Visibility');
|
||||
const field = wrapper
|
||||
.element(by.xpath('..'))
|
||||
.element(by.css('.mat-select'));
|
||||
const field = wrapper.element(by.xpath('..')).element(by.css('.mat-select'));
|
||||
return field.isEnabled();
|
||||
}
|
||||
|
||||
|
@@ -29,11 +29,7 @@ import { Component } from '../component';
|
||||
import { CommentsTab } from './info-drawer-comments-tab';
|
||||
import { LibraryMetadata } from './info-drawer-metadata-library';
|
||||
import { ContentMetadata } from './info-drawer-metadata-content';
|
||||
import {
|
||||
waitForVisibility,
|
||||
waitForInvisibility,
|
||||
waitForPresence
|
||||
} from '../../utilities/utils';
|
||||
import { waitForVisibility, waitForInvisibility, waitForPresence } from '../../utilities/utils';
|
||||
|
||||
export class InfoDrawer extends Component {
|
||||
commentsTab = new CommentsTab('adf-info-drawer');
|
||||
@@ -44,15 +40,9 @@ export class InfoDrawer extends Component {
|
||||
tabLabel = this.byCss('.mat-tab-label-content');
|
||||
tabLabelsList = this.allByCss('.mat-tab-label-content');
|
||||
tabActiveLabel = this.byCss('.mat-tab-label-active');
|
||||
tabActiveContent = this.byCss(
|
||||
'.mat-tab-body-active .mat-tab-body-content adf-dynamic-tab'
|
||||
);
|
||||
nextButton = this.byCss(
|
||||
'.mat-tab-header-pagination-after .mat-tab-header-pagination-chevron'
|
||||
);
|
||||
previousButton = this.byCss(
|
||||
'.mat-tab-header-pagination-before .mat-tab-header-pagination-chevron'
|
||||
);
|
||||
tabActiveContent = this.byCss('.mat-tab-body-active .mat-tab-body-content adf-dynamic-tab');
|
||||
nextButton = this.byCss('.mat-tab-header-pagination-after .mat-tab-header-pagination-chevron');
|
||||
previousButton = this.byCss('.mat-tab-header-pagination-before .mat-tab-header-pagination-chevron');
|
||||
|
||||
constructor(ancestor?: string) {
|
||||
super('adf-info-drawer', ancestor);
|
||||
@@ -130,10 +120,7 @@ export class InfoDrawer extends Component {
|
||||
try {
|
||||
await this.getTabByTitle('Comments').click();
|
||||
await this.commentsTab.waitForCommentsContainer();
|
||||
await Promise.all([
|
||||
waitForVisibility(this.commentsTab.component),
|
||||
waitForInvisibility(this.propertiesTab.component)
|
||||
]);
|
||||
await Promise.all([waitForVisibility(this.commentsTab.component), waitForInvisibility(this.propertiesTab.component)]);
|
||||
} catch (error) {
|
||||
Logger.error('--- info-drawer clickCommentsTab catch error: ', error);
|
||||
}
|
||||
|
@@ -26,23 +26,14 @@
|
||||
import { ElementFinder, by, browser } from 'protractor';
|
||||
import { Logger } from '@alfresco/adf-testing';
|
||||
import { Component } from '../component';
|
||||
import {
|
||||
Utils,
|
||||
isPresentAndEnabled,
|
||||
waitForPresence,
|
||||
waitForVisibility,
|
||||
waitForStaleness,
|
||||
waitForClickable
|
||||
} from '../../utilities/utils';
|
||||
import { Utils, isPresentAndEnabled, waitForPresence, waitForVisibility, waitForStaleness, waitForClickable } from '../../utilities/utils';
|
||||
|
||||
export class Menu extends Component {
|
||||
items = this.allByCss('.mat-menu-item');
|
||||
backdrop = this.byCss('.cdk-overlay-backdrop', browser);
|
||||
|
||||
uploadFilesInput = this.byId('app-upload-files', browser);
|
||||
submenus = browser.element.all(
|
||||
by.css('app-context-menu-item .mat-menu-item')
|
||||
);
|
||||
submenus = browser.element.all(by.css('app-context-menu-item .mat-menu-item'));
|
||||
|
||||
uploadFileAction = this.byId('app.create.uploadFile');
|
||||
uploadFolderAction = this.byId('app.create.uploadFolder');
|
||||
@@ -61,23 +52,14 @@ export class Menu extends Component {
|
||||
favoriteAction = this.byCss(`.mat-menu-item[id$='favorite.add']`);
|
||||
removeFavoriteAction = this.byCss(`.mat-menu-item[id$='favorite.remove']`);
|
||||
toggleFavoriteAction = this.byCssText('.mat-menu-item', 'Favorite');
|
||||
toggleRemoveFavoriteAction = this.byCssText(
|
||||
'.mat-menu-item',
|
||||
'Remove Favorite'
|
||||
);
|
||||
toggleRemoveFavoriteAction = this.byCssText('.mat-menu-item', 'Remove Favorite');
|
||||
joinAction = this.byCssText('.mat-menu-item', 'Join');
|
||||
leaveAction = this.byCssText('.mat-menu-item', 'Leave');
|
||||
managePermissionsAction = this.byCssText('.mat-menu-item', 'Permissions');
|
||||
manageVersionsAction = this.byCssText('.mat-menu-item', 'Manage Versions');
|
||||
uploadNewVersionAction = this.byCssText(
|
||||
'.mat-menu-item',
|
||||
'Upload New Version'
|
||||
);
|
||||
uploadNewVersionAction = this.byCssText('.mat-menu-item', 'Upload New Version');
|
||||
moveAction = this.byCssText('.mat-menu-item', 'Move');
|
||||
permanentDeleteAction = this.byCssText(
|
||||
'.mat-menu-item',
|
||||
'Permanently Delete'
|
||||
);
|
||||
permanentDeleteAction = this.byCssText('.mat-menu-item', 'Permanently Delete');
|
||||
restoreAction = this.byCssText('.mat-menu-item', 'Restore');
|
||||
shareAction = this.byCssText('.mat-menu-item', 'Share');
|
||||
shareEditAction = this.byCssText('.mat-menu-item', 'Shared Link Settings');
|
||||
@@ -89,16 +71,12 @@ export class Menu extends Component {
|
||||
}
|
||||
|
||||
async waitForMenuToOpen(): Promise<void> {
|
||||
await waitForPresence(
|
||||
browser.element(by.css('.cdk-overlay-container .mat-menu-panel'))
|
||||
);
|
||||
await waitForPresence(browser.element(by.css('.cdk-overlay-container .mat-menu-panel')));
|
||||
await waitForVisibility(this.items.get(0));
|
||||
}
|
||||
|
||||
async waitForMenuToClose(): Promise<void> {
|
||||
await waitForStaleness(
|
||||
browser.element(by.css('.cdk-overlay-container .mat-menu-panel'))
|
||||
);
|
||||
await waitForStaleness(browser.element(by.css('.cdk-overlay-container .mat-menu-panel')));
|
||||
}
|
||||
|
||||
async closeMenu(): Promise<void> {
|
||||
@@ -127,9 +105,7 @@ export class Menu extends Component {
|
||||
}
|
||||
|
||||
async getItemIconText(menuItem: string): Promise<string> {
|
||||
return this.getItemByLabel(menuItem)
|
||||
.element(by.css('.mat-icon'))
|
||||
.getText();
|
||||
return this.getItemByLabel(menuItem).element(by.css('.mat-icon')).getText();
|
||||
}
|
||||
|
||||
async getItemIdAttribute(menuItem: string): Promise<string> {
|
||||
@@ -141,7 +117,7 @@ export class Menu extends Component {
|
||||
}
|
||||
|
||||
async getMenuItems(): Promise<string[]> {
|
||||
const items: string[] = await this.items.map(async elem => {
|
||||
const items: string[] = await this.items.map(async (elem) => {
|
||||
const span = elem.element(by.css('span'));
|
||||
return span.getText();
|
||||
});
|
||||
@@ -152,14 +128,8 @@ export class Menu extends Component {
|
||||
try {
|
||||
const elem = this.getNthItem(nth);
|
||||
await waitForClickable(elem);
|
||||
await browser
|
||||
.actions()
|
||||
.mouseMove(elem)
|
||||
.perform();
|
||||
await browser
|
||||
.actions()
|
||||
.click()
|
||||
.perform();
|
||||
await browser.actions().mouseMove(elem).perform();
|
||||
await browser.actions().click().perform();
|
||||
await this.waitForMenuToClose();
|
||||
} catch (e) {
|
||||
Logger.error('____ click nth menu item catch ___', e);
|
||||
@@ -180,10 +150,7 @@ export class Menu extends Component {
|
||||
try {
|
||||
const elem = this.getItemByLabel(menuItem);
|
||||
await waitForClickable(elem);
|
||||
await browser
|
||||
.actions()
|
||||
.mouseMove(elem)
|
||||
.perform();
|
||||
await browser.actions().mouseMove(elem).perform();
|
||||
await browser.sleep(500);
|
||||
} catch (error) {
|
||||
Logger.error('----- mouse over error: ', error);
|
||||
@@ -213,17 +180,11 @@ export class Menu extends Component {
|
||||
}
|
||||
|
||||
async isMenuItemPresent(title: string): Promise<boolean> {
|
||||
return browser
|
||||
.element(by.cssContainingText('.mat-menu-item', title))
|
||||
.isPresent();
|
||||
return browser.element(by.cssContainingText('.mat-menu-item', title)).isPresent();
|
||||
}
|
||||
|
||||
async isSubMenuItemPresent(title: string): Promise<boolean> {
|
||||
return browser
|
||||
.element(
|
||||
by.cssContainingText('app-context-menu-item .mat-menu-item', title)
|
||||
)
|
||||
.isPresent();
|
||||
return browser.element(by.cssContainingText('app-context-menu-item .mat-menu-item', title)).isPresent();
|
||||
}
|
||||
|
||||
async getSubmenuItemsCount(): Promise<number> {
|
||||
|
@@ -28,12 +28,8 @@ import { waitForPresence } from '../../utilities/utils';
|
||||
|
||||
export class MetadataCard extends Component {
|
||||
footer = this.byCss('.adf-content-metadata-card-footer');
|
||||
expandButton = this.byCss(
|
||||
'[data-automation-id="meta-data-card-toggle-expand"]'
|
||||
);
|
||||
expansionPanels = this.allByCss(
|
||||
'.adf-metadata-grouped-properties-container mat-expansion-panel'
|
||||
);
|
||||
expandButton = this.byCss('[data-automation-id="meta-data-card-toggle-expand"]');
|
||||
expansionPanels = this.allByCss('.adf-metadata-grouped-properties-container mat-expansion-panel');
|
||||
|
||||
constructor(ancestor?: string) {
|
||||
super('adf-content-metadata-card', ancestor);
|
||||
|
@@ -36,12 +36,8 @@ export class Pagination extends Component {
|
||||
totalPages = this.byCss('.adf-pagination__total-pages');
|
||||
previousButton = this.byCss('.adf-pagination__previous-button');
|
||||
nextButton = this.byCss('.adf-pagination__next-button');
|
||||
maxItemsButton = this.byCss(
|
||||
'.adf-pagination__max-items + button[mat-icon-button]'
|
||||
);
|
||||
pagesButton = this.byCss(
|
||||
'.adf-pagination__current-page + button[mat-icon-button]'
|
||||
);
|
||||
maxItemsButton = this.byCss('.adf-pagination__max-items + button[mat-icon-button]');
|
||||
pagesButton = this.byCss('.adf-pagination__current-page + button[mat-icon-button]');
|
||||
|
||||
menu: Menu = new Menu();
|
||||
|
||||
@@ -51,10 +47,7 @@ export class Pagination extends Component {
|
||||
|
||||
async openMaxItemsMenu() {
|
||||
try {
|
||||
await waitForClickable(
|
||||
this.maxItemsButton,
|
||||
'timeout waiting for maxItemsButton to be clickable'
|
||||
);
|
||||
await waitForClickable(this.maxItemsButton, 'timeout waiting for maxItemsButton to be clickable');
|
||||
await this.maxItemsButton.click();
|
||||
await this.menu.waitForMenuToOpen();
|
||||
} catch (error) {
|
||||
@@ -64,10 +57,7 @@ export class Pagination extends Component {
|
||||
|
||||
async openCurrentPageMenu() {
|
||||
try {
|
||||
await waitForClickable(
|
||||
this.pagesButton,
|
||||
'timeout waiting for pagesButton to be clickable'
|
||||
);
|
||||
await waitForClickable(this.pagesButton, 'timeout waiting for pagesButton to be clickable');
|
||||
await this.pagesButton.click();
|
||||
await this.menu.waitForMenuToOpen();
|
||||
} catch (error) {
|
||||
|
@@ -32,30 +32,14 @@ export class CreatedDateFilter extends GenericFilterPanel {
|
||||
super('Created date');
|
||||
}
|
||||
|
||||
fromField: ElementFinder = this.panelExpanded.element(
|
||||
by.cssContainingText('.adf-search-date-range .mat-form-field', 'From')
|
||||
);
|
||||
fromInput: ElementFinder = this.fromField.element(
|
||||
by.css(`[data-automation-id='date-range-from-input']`)
|
||||
);
|
||||
fromFieldError: ElementFinder = this.fromField.element(
|
||||
by.css(`[data-automation-id='date-range-from-error']`)
|
||||
);
|
||||
toField: ElementFinder = this.panelExpanded.element(
|
||||
by.cssContainingText('.adf-search-date-range .mat-form-field', 'To')
|
||||
);
|
||||
toInput: ElementFinder = this.toField.element(
|
||||
by.css(`[data-automation-id='date-range-to-input']`)
|
||||
);
|
||||
toFieldError: ElementFinder = this.toField.element(
|
||||
by.css(`[data-automation-id='date-range-to-error']`)
|
||||
);
|
||||
clearButton: ElementFinder = this.panel.element(
|
||||
by.css('.adf-facet-buttons [data-automation-id="date-range-clear-btn"]')
|
||||
);
|
||||
applyButton: ElementFinder = this.panel.element(
|
||||
by.css('.adf-facet-buttons [data-automation-id="date-range-apply-btn"]')
|
||||
);
|
||||
fromField: ElementFinder = this.panelExpanded.element(by.cssContainingText('.adf-search-date-range .mat-form-field', 'From'));
|
||||
fromInput: ElementFinder = this.fromField.element(by.css(`[data-automation-id='date-range-from-input']`));
|
||||
fromFieldError: ElementFinder = this.fromField.element(by.css(`[data-automation-id='date-range-from-error']`));
|
||||
toField: ElementFinder = this.panelExpanded.element(by.cssContainingText('.adf-search-date-range .mat-form-field', 'To'));
|
||||
toInput: ElementFinder = this.toField.element(by.css(`[data-automation-id='date-range-to-input']`));
|
||||
toFieldError: ElementFinder = this.toField.element(by.css(`[data-automation-id='date-range-to-error']`));
|
||||
clearButton: ElementFinder = this.panel.element(by.css('.adf-facet-buttons [data-automation-id="date-range-clear-btn"]'));
|
||||
applyButton: ElementFinder = this.panel.element(by.css('.adf-facet-buttons [data-automation-id="date-range-apply-btn"]'));
|
||||
|
||||
async isFromFieldDisplayed(): Promise<boolean> {
|
||||
return isPresentAndDisplayed(this.fromField);
|
||||
|
@@ -42,9 +42,7 @@ export class FacetFilter extends GenericFilterPanel {
|
||||
return this.panel.all(by.css(this.locators.checkboxChecked));
|
||||
}
|
||||
get clearButton(): ElementFinder {
|
||||
return this.panel.element(
|
||||
by.cssContainingText(this.locators.button, 'Clear all')
|
||||
);
|
||||
return this.panel.element(by.cssContainingText(this.locators.button, 'Clear all'));
|
||||
}
|
||||
get facetsFilter(): ElementFinder {
|
||||
return this.panelExpanded.element(by.css(this.locators.facetsFilter));
|
||||
@@ -54,14 +52,14 @@ export class FacetFilter extends GenericFilterPanel {
|
||||
}
|
||||
|
||||
async getFiltersValues(): Promise<string[]> {
|
||||
const list: string[] = await this.facets.map(option => {
|
||||
const list: string[] = await this.facets.map((option) => {
|
||||
return option.getText();
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
async getFiltersCheckedValues(): Promise<string[]> {
|
||||
const list: string[] = await this.selectedFacets.map(option => {
|
||||
const list: string[] = await this.selectedFacets.map((option) => {
|
||||
return option.getText();
|
||||
});
|
||||
return list;
|
||||
@@ -70,7 +68,7 @@ export class FacetFilter extends GenericFilterPanel {
|
||||
async resetPanel(): Promise<void> {
|
||||
if ((await this.selectedFacets.count()) > 0) {
|
||||
await this.expandPanel();
|
||||
await this.selectedFacets.each(async elem => {
|
||||
await this.selectedFacets.each(async (elem) => {
|
||||
await elem.click();
|
||||
});
|
||||
}
|
||||
@@ -96,18 +94,10 @@ export class FacetFilter extends GenericFilterPanel {
|
||||
}
|
||||
|
||||
async checkCategory(name: string): Promise<void> {
|
||||
const option = this.facets
|
||||
.filter(async elem => (await elem.getText()).includes(name))
|
||||
.first();
|
||||
const option = this.facets.filter(async (elem) => (await elem.getText()).includes(name)).first();
|
||||
await browser.executeScript(`arguments[0].scrollIntoView();`, option);
|
||||
await browser
|
||||
.actions()
|
||||
.mouseMove(option)
|
||||
.perform();
|
||||
await browser
|
||||
.actions()
|
||||
.click()
|
||||
.perform();
|
||||
await browser.actions().mouseMove(option).perform();
|
||||
await browser.actions().click().perform();
|
||||
}
|
||||
|
||||
async filterCategoriesBy(name: string): Promise<void> {
|
||||
|
@@ -42,14 +42,10 @@ export class GenericFilterPanel {
|
||||
};
|
||||
|
||||
get panel(): ElementFinder {
|
||||
return browser.element(
|
||||
by.cssContainingText(this.selectors.panel, this.filterName)
|
||||
);
|
||||
return browser.element(by.cssContainingText(this.selectors.panel, this.filterName));
|
||||
}
|
||||
get panelExpanded(): ElementFinder {
|
||||
return browser.element(
|
||||
by.cssContainingText(this.selectors.panelExpanded, this.filterName)
|
||||
);
|
||||
return browser.element(by.cssContainingText(this.selectors.panelExpanded, this.filterName));
|
||||
}
|
||||
get panelHeader(): ElementFinder {
|
||||
return this.panel.element(by.css(this.selectors.panelHeader));
|
||||
|
@@ -32,22 +32,18 @@ export class SizeFilter extends GenericFilterPanel {
|
||||
}
|
||||
|
||||
facets: ElementArrayFinder = this.panelExpanded.all(by.css('.mat-checkbox'));
|
||||
selectedFacets: ElementArrayFinder = this.panel.all(
|
||||
by.css('.mat-checkbox.mat-checkbox-checked')
|
||||
);
|
||||
clearButton: ElementFinder = this.panel.element(
|
||||
by.cssContainingText('.adf-facet-buttons button', 'Clear all')
|
||||
);
|
||||
selectedFacets: ElementArrayFinder = this.panel.all(by.css('.mat-checkbox.mat-checkbox-checked'));
|
||||
clearButton: ElementFinder = this.panel.element(by.cssContainingText('.adf-facet-buttons button', 'Clear all'));
|
||||
|
||||
async getFiltersValues(): Promise<string[]> {
|
||||
const list: string[] = await this.facets.map(option => {
|
||||
const list: string[] = await this.facets.map((option) => {
|
||||
return option.getText();
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
async getFiltersCheckedValues(): Promise<string[]> {
|
||||
const list: string[] = await this.selectedFacets.map(option => {
|
||||
const list: string[] = await this.selectedFacets.map((option) => {
|
||||
return option.getText();
|
||||
});
|
||||
return list;
|
||||
@@ -56,7 +52,7 @@ export class SizeFilter extends GenericFilterPanel {
|
||||
async resetPanel(): Promise<void> {
|
||||
if ((await this.selectedFacets.count()) > 0) {
|
||||
await this.expandPanel();
|
||||
await this.selectedFacets.each(async elem => {
|
||||
await this.selectedFacets.each(async (elem) => {
|
||||
await elem.click();
|
||||
});
|
||||
}
|
||||
@@ -74,30 +70,22 @@ export class SizeFilter extends GenericFilterPanel {
|
||||
}
|
||||
|
||||
async checkSizeSmall(): Promise<void> {
|
||||
const small = this.facets
|
||||
.filter(async elem => (await elem.getText()) === 'Small')
|
||||
.first();
|
||||
const small = this.facets.filter(async (elem) => (await elem.getText()) === 'Small').first();
|
||||
await small.click();
|
||||
}
|
||||
|
||||
async checkSizeMedium(): Promise<void> {
|
||||
const medium = this.facets
|
||||
.filter(async elem => (await elem.getText()) === 'Medium')
|
||||
.first();
|
||||
const medium = this.facets.filter(async (elem) => (await elem.getText()) === 'Medium').first();
|
||||
await medium.click();
|
||||
}
|
||||
|
||||
async checkSizeLarge(): Promise<void> {
|
||||
const large = this.facets
|
||||
.filter(async elem => (await elem.getText()) === 'Large')
|
||||
.first();
|
||||
const large = this.facets.filter(async (elem) => (await elem.getText()) === 'Large').first();
|
||||
await large.click();
|
||||
}
|
||||
|
||||
async checkSizeHuge(): Promise<void> {
|
||||
const huge = this.facets
|
||||
.filter(async elem => (await elem.getText()) === 'Huge')
|
||||
.first();
|
||||
const huge = this.facets.filter(async (elem) => (await elem.getText()) === 'Huge').first();
|
||||
await huge.click();
|
||||
}
|
||||
}
|
||||
|
@@ -25,12 +25,7 @@
|
||||
|
||||
import { browser, by, protractor } from 'protractor';
|
||||
import { Component } from '../component';
|
||||
import {
|
||||
Utils,
|
||||
waitForPresence,
|
||||
waitForClickable,
|
||||
waitElement
|
||||
} from '../../utilities/utils';
|
||||
import { Utils, waitForPresence, waitForClickable, waitElement } from '../../utilities/utils';
|
||||
|
||||
export class SearchInput extends Component {
|
||||
searchButton = this.component.element(by.css('.app-search-button'));
|
||||
@@ -38,15 +33,9 @@ export class SearchInput extends Component {
|
||||
searchControl = browser.element(by.css('.app-search-control'));
|
||||
searchInput = browser.element(by.css(`input[id='app-control-input']`));
|
||||
searchOptionsArea = browser.element(by.id('search-options'));
|
||||
searchFilesOption = this.searchOptionsArea.element(
|
||||
by.cssContainingText('.mat-checkbox', 'Files')
|
||||
);
|
||||
searchFoldersOption = this.searchOptionsArea.element(
|
||||
by.cssContainingText('.mat-checkbox', 'Folders')
|
||||
);
|
||||
searchLibrariesOption = this.searchOptionsArea.element(
|
||||
by.cssContainingText('.mat-checkbox', 'Libraries')
|
||||
);
|
||||
searchFilesOption = this.searchOptionsArea.element(by.cssContainingText('.mat-checkbox', 'Files'));
|
||||
searchFoldersOption = this.searchOptionsArea.element(by.cssContainingText('.mat-checkbox', 'Folders'));
|
||||
searchLibrariesOption = this.searchOptionsArea.element(by.cssContainingText('.mat-checkbox', 'Libraries'));
|
||||
clearSearchButton = this.searchContainer.$('.app-clear-icon');
|
||||
|
||||
constructor(ancestor?: string) {
|
||||
|
@@ -25,40 +25,23 @@
|
||||
|
||||
import { by, browser } from 'protractor';
|
||||
import { Component } from '../component';
|
||||
import {
|
||||
isPresentAndDisplayed,
|
||||
waitForVisibility
|
||||
} from '../../utilities/utils';
|
||||
|
||||
export type SortByType =
|
||||
| 'Relevance'
|
||||
| 'Title'
|
||||
| 'Filename'
|
||||
| 'Modified date'
|
||||
| 'Modifier'
|
||||
| 'Created date'
|
||||
| 'Size'
|
||||
| 'Type';
|
||||
import { isPresentAndDisplayed, waitForVisibility } from '../../utilities/utils';
|
||||
|
||||
export type SortByType = 'Relevance' | 'Title' | 'Filename' | 'Modified date' | 'Modifier' | 'Created date' | 'Size' | 'Type';
|
||||
export type SortOrderType = 'ASC' | 'DESC' | '';
|
||||
|
||||
export class SearchSortingPicker extends Component {
|
||||
sortOrderButton = this.byCss('button[mat-icon-button]');
|
||||
sortByDropdownCollapsed = this.byCss('.mat-select');
|
||||
sortByDropdownExpanded = browser.element(by.css('.mat-select-panel'));
|
||||
sortByList = this.sortByDropdownExpanded.all(
|
||||
by.css('.mat-option .mat-option-text')
|
||||
);
|
||||
sortByList = this.sortByDropdownExpanded.all(by.css('.mat-option .mat-option-text'));
|
||||
|
||||
constructor(ancestor?: string) {
|
||||
super('adf-search-sorting-picker', ancestor);
|
||||
}
|
||||
|
||||
async waitForSortByDropdownToExpand(): Promise<void> {
|
||||
await waitForVisibility(
|
||||
this.sortByDropdownExpanded,
|
||||
'Timeout waiting for sortBy dropdown to expand'
|
||||
);
|
||||
await waitForVisibility(this.sortByDropdownExpanded, 'Timeout waiting for sortBy dropdown to expand');
|
||||
}
|
||||
|
||||
async isSortOrderButtonDisplayed(): Promise<boolean> {
|
||||
@@ -95,7 +78,7 @@ export class SearchSortingPicker extends Component {
|
||||
}
|
||||
|
||||
async getSortByOptionsList(): Promise<string[]> {
|
||||
const list: string[] = await this.sortByList.map(async option => {
|
||||
const list: string[] = await this.sortByList.map(async (option) => {
|
||||
return option.getText();
|
||||
});
|
||||
return list;
|
||||
@@ -105,9 +88,7 @@ export class SearchSortingPicker extends Component {
|
||||
if (!(await this.isSortByDropdownExpanded())) {
|
||||
await this.clickSortByDropdown();
|
||||
}
|
||||
const elem = browser.element(
|
||||
by.cssContainingText('.mat-option .mat-option-text', option)
|
||||
);
|
||||
const elem = browser.element(by.cssContainingText('.mat-option .mat-option-text', option));
|
||||
await elem.click();
|
||||
}
|
||||
|
||||
|
@@ -35,17 +35,9 @@ export class Sidenav extends Component {
|
||||
activeLink = this.byCss('.action-button--active');
|
||||
newButton = this.allByCss('[data-automation-id="create-button"]');
|
||||
personalFiles = this.byCss(`[data-automation-id='app.navbar.personalFiles']`);
|
||||
fileLibraries = this.byCss(
|
||||
`[data-automation-id='app.navbar.libraries.menu']`
|
||||
);
|
||||
myLibraries = this.byCss(
|
||||
`[data-automation-id='app.navbar.libraries.files']`,
|
||||
browser
|
||||
);
|
||||
favoriteLibraries = this.byCss(
|
||||
`[data-automation-id='app.navbar.libraries.favorite']`,
|
||||
browser
|
||||
);
|
||||
fileLibraries = this.byCss(`[data-automation-id='app.navbar.libraries.menu']`);
|
||||
myLibraries = this.byCss(`[data-automation-id='app.navbar.libraries.files']`, browser);
|
||||
favoriteLibraries = this.byCss(`[data-automation-id='app.navbar.libraries.favorite']`, browser);
|
||||
shared = this.byCss(`[data-automation-id='app.navbar.shared']`);
|
||||
recentFiles = this.byCss(`[data-automation-id='app.navbar.recentFiles']`);
|
||||
favorites = this.byCss(`[data-automation-id='app.navbar.favorites']`);
|
||||
@@ -59,9 +51,7 @@ export class Sidenav extends Component {
|
||||
|
||||
private async expandMenu(name: string): Promise<void> {
|
||||
try {
|
||||
if (
|
||||
await element(by.cssContainingText('.mat-expanded', name)).isPresent()
|
||||
) {
|
||||
if (await element(by.cssContainingText('.mat-expanded', name)).isPresent()) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
const link = this.getLink(name);
|
||||
@@ -80,9 +70,7 @@ export class Sidenav extends Component {
|
||||
}
|
||||
|
||||
async closeNewMenu(): Promise<void> {
|
||||
await BrowserActions.click(
|
||||
element(by.css('button[data-automation-id="create-button"] span span'))
|
||||
);
|
||||
await BrowserActions.click(element(by.css('button[data-automation-id="create-button"] span span')));
|
||||
await this.menu.waitForMenuToClose();
|
||||
}
|
||||
|
||||
@@ -112,9 +100,7 @@ export class Sidenav extends Component {
|
||||
}
|
||||
|
||||
async childIsActive(name: string): Promise<boolean> {
|
||||
const childClass = await this.getLinkLabel(name)
|
||||
.element(by.css('span'))
|
||||
.getAttribute('class');
|
||||
const childClass = await this.getLinkLabel(name).element(by.css('span')).getAttribute('class');
|
||||
return childClass.includes('action-button--active');
|
||||
}
|
||||
|
||||
@@ -147,13 +133,9 @@ export class Sidenav extends Component {
|
||||
|
||||
async getLinkTooltip(name: string): Promise<string> {
|
||||
const link = this.getLinkLabel(name);
|
||||
const condition = () =>
|
||||
link.getAttribute('title').then(value => value && value.length > 0);
|
||||
const condition = () => link.getAttribute('title').then((value) => value && value.length > 0);
|
||||
|
||||
await browser
|
||||
.actions()
|
||||
.mouseMove(link)
|
||||
.perform();
|
||||
await browser.actions().mouseMove(link).perform();
|
||||
await browser.wait(condition, BROWSER_WAIT_TIMEOUT);
|
||||
|
||||
return link.getAttribute('title');
|
||||
@@ -170,9 +152,7 @@ export class Sidenav extends Component {
|
||||
}
|
||||
|
||||
async isFileLibrariesMenuExpanded(): Promise<boolean> {
|
||||
return element(
|
||||
by.cssContainingText('.mat-expanded', SIDEBAR_LABELS.FILE_LIBRARIES)
|
||||
).isPresent();
|
||||
return element(by.cssContainingText('.mat-expanded', SIDEBAR_LABELS.FILE_LIBRARIES)).isPresent();
|
||||
}
|
||||
|
||||
async expandFileLibraries(): Promise<void> {
|
||||
|
@@ -34,25 +34,17 @@ export class Toolbar extends Component {
|
||||
|
||||
buttons = this.allByCss('button');
|
||||
shareButton = this.byCss(`.mat-icon-button[title='Share']`);
|
||||
shareEditButton = this.byCss(
|
||||
`.mat-icon-button[title='Shared Link Settings']`
|
||||
);
|
||||
shareEditButton = this.byCss(`.mat-icon-button[title='Shared Link Settings']`);
|
||||
viewButton = this.byCss(`.mat-icon-button[title='View']`);
|
||||
searchFiltersToggleButton = this.byCss(
|
||||
`.mat-icon-button[title='Toggle search filter']`
|
||||
);
|
||||
searchFiltersToggleButton = this.byCss(`.mat-icon-button[title='Toggle search filter']`);
|
||||
downloadButton = this.byCss(`.mat-icon-button[title='Download']`);
|
||||
editFolderButton = this.byId('app.toolbar.editFolder');
|
||||
viewDetailsButton = this.byCss(`.mat-icon-button[title='View Details']`);
|
||||
printButton = this.byCss(`.mat-icon-button[title='Print']`);
|
||||
fullScreenButton = this.byCss(
|
||||
`.mat-icon-button[title='Activate full-screen mode']`
|
||||
);
|
||||
fullScreenButton = this.byCss(`.mat-icon-button[title='Activate full-screen mode']`);
|
||||
joinButton = this.byCss(`.mat-icon-button[title='Join']`);
|
||||
leaveButton = this.byCss(`.mat-icon-button[title='Leave Library']`);
|
||||
permanentlyDeleteButton = this.byCss(
|
||||
`.mat-icon-button[title='Permanently Delete']`
|
||||
);
|
||||
permanentlyDeleteButton = this.byCss(`.mat-icon-button[title='Permanently Delete']`);
|
||||
restoreButton = this.byCss(`.mat-icon-button[title='Restore']`);
|
||||
|
||||
constructor(ancestor?: string) {
|
||||
@@ -65,7 +57,7 @@ export class Toolbar extends Component {
|
||||
}
|
||||
|
||||
async getButtons(): Promise<string[]> {
|
||||
return this.buttons.map(async elem => {
|
||||
return this.buttons.map(async (elem) => {
|
||||
return elem.getAttribute('title');
|
||||
});
|
||||
}
|
||||
|
@@ -23,14 +23,7 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
Header,
|
||||
DataTable,
|
||||
Pagination,
|
||||
Toolbar,
|
||||
Breadcrumb,
|
||||
Sidenav
|
||||
} from '../components/components';
|
||||
import { Header, DataTable, Pagination, Toolbar, Breadcrumb, Sidenav } from '../components/components';
|
||||
import { SIDEBAR_LABELS } from './../configs';
|
||||
import { Page } from './page';
|
||||
|
||||
|
@@ -51,10 +51,7 @@ export class LoginPage extends Page {
|
||||
|
||||
async loginWithAdmin() {
|
||||
await this.load();
|
||||
return this.loginWith(
|
||||
browser.params.ADMIN_USERNAME,
|
||||
browser.params.ADMIN_PASSWORD
|
||||
);
|
||||
return this.loginWith(browser.params.ADMIN_USERNAME, browser.params.ADMIN_PASSWORD);
|
||||
}
|
||||
|
||||
async tryLoginWith(username: string, password?: string) {
|
||||
|
@@ -26,12 +26,7 @@
|
||||
import { browser, by, ElementFinder } from 'protractor';
|
||||
import { Logger } from '@alfresco/adf-testing';
|
||||
import { USE_HASH_STRATEGY } from './../configs';
|
||||
import {
|
||||
Utils,
|
||||
waitElement,
|
||||
waitForPresence,
|
||||
waitForVisibility
|
||||
} from '../utilities/utils';
|
||||
import { Utils, waitElement, waitForPresence, waitForVisibility } from '../utilities/utils';
|
||||
|
||||
export abstract class Page {
|
||||
appRoot = 'app-root';
|
||||
|
@@ -46,7 +46,7 @@ export class SearchResultsPage extends BrowsingPage {
|
||||
|
||||
async getResultsChipsValues(): Promise<string[]> {
|
||||
const chips = this.chipList.all(by.css('.mat-chip'));
|
||||
const chipsValues: string[] = await chips.map(async elem => {
|
||||
const chipsValues: string[] = await chips.map(async (elem) => {
|
||||
return (await elem.getText()).replace(`\ncancel`, '');
|
||||
});
|
||||
return chipsValues;
|
||||
|
@@ -51,95 +51,53 @@ export class AdminActions {
|
||||
}
|
||||
|
||||
async getNodeTemplatesFolderId(): Promise<string> {
|
||||
return this.adminApi.nodes.getNodeIdFromParent(
|
||||
'Node Templates',
|
||||
await this.getDataDictionaryId()
|
||||
);
|
||||
return this.adminApi.nodes.getNodeIdFromParent('Node Templates', await this.getDataDictionaryId());
|
||||
}
|
||||
|
||||
async getSpaceTemplatesFolderId(): Promise<string> {
|
||||
return this.adminApi.nodes.getNodeIdFromParent(
|
||||
'Space Templates',
|
||||
await this.getDataDictionaryId()
|
||||
);
|
||||
return this.adminApi.nodes.getNodeIdFromParent('Space Templates', await this.getDataDictionaryId());
|
||||
}
|
||||
|
||||
async createUser(user: PersonModel): Promise<PersonEntry> {
|
||||
return this.adminApi.people.createUser(user);
|
||||
}
|
||||
|
||||
async createNodeTemplate(
|
||||
name: string,
|
||||
title: string = '',
|
||||
description: string = '',
|
||||
author: string = ''
|
||||
): Promise<NodeEntry> {
|
||||
async createNodeTemplate(name: string, title: string = '', description: string = '', author: string = ''): Promise<NodeEntry> {
|
||||
const templatesRootFolderId: string = await this.getNodeTemplatesFolderId();
|
||||
|
||||
return this.adminApi.nodes.createFile(
|
||||
name,
|
||||
templatesRootFolderId,
|
||||
title,
|
||||
description,
|
||||
author
|
||||
);
|
||||
return this.adminApi.nodes.createFile(name, templatesRootFolderId, title, description, author);
|
||||
}
|
||||
|
||||
async createNodeTemplatesHierarchy(hierarchy: NodeContentTree): Promise<any> {
|
||||
return this.adminApi.nodes.createContent(
|
||||
hierarchy,
|
||||
`Data Dictionary/Node Templates`
|
||||
);
|
||||
return this.adminApi.nodes.createContent(hierarchy, `Data Dictionary/Node Templates`);
|
||||
}
|
||||
|
||||
async createSpaceTemplate(
|
||||
name: string,
|
||||
title: string = '',
|
||||
description: string = ''
|
||||
): Promise<NodeEntry> {
|
||||
async createSpaceTemplate(name: string, title: string = '', description: string = ''): Promise<NodeEntry> {
|
||||
const templatesRootFolderId: string = await this.getSpaceTemplatesFolderId();
|
||||
|
||||
return this.adminApi.nodes.createFolder(
|
||||
name,
|
||||
templatesRootFolderId,
|
||||
title,
|
||||
description
|
||||
);
|
||||
return this.adminApi.nodes.createFolder(name, templatesRootFolderId, title, description);
|
||||
}
|
||||
|
||||
async createSpaceTemplatesHierarchy(
|
||||
hierarchy: NodeContentTree
|
||||
): Promise<any> {
|
||||
return this.adminApi.nodes.createContent(
|
||||
hierarchy,
|
||||
`Data Dictionary/Space Templates`
|
||||
);
|
||||
async createSpaceTemplatesHierarchy(hierarchy: NodeContentTree): Promise<any> {
|
||||
return this.adminApi.nodes.createContent(hierarchy, `Data Dictionary/Space Templates`);
|
||||
}
|
||||
|
||||
async removeUserAccessOnNodeTemplate(nodeName: string): Promise<NodeEntry> {
|
||||
const templatesRootFolderId = await this.getNodeTemplatesFolderId();
|
||||
const nodeId: string = await this.adminApi.nodes.getNodeIdFromParent(
|
||||
nodeName,
|
||||
templatesRootFolderId
|
||||
);
|
||||
const nodeId: string = await this.adminApi.nodes.getNodeIdFromParent(nodeName, templatesRootFolderId);
|
||||
|
||||
return this.adminApi.nodes.setInheritPermissions(nodeId, false);
|
||||
}
|
||||
|
||||
async removeUserAccessOnSpaceTemplate(nodeName: string): Promise<NodeEntry> {
|
||||
const templatesRootFolderId = await this.getSpaceTemplatesFolderId();
|
||||
const nodeId: string = await this.adminApi.nodes.getNodeIdFromParent(
|
||||
nodeName,
|
||||
templatesRootFolderId
|
||||
);
|
||||
const nodeId: string = await this.adminApi.nodes.getNodeIdFromParent(nodeName, templatesRootFolderId);
|
||||
|
||||
return this.adminApi.nodes.setInheritPermissions(nodeId, false);
|
||||
}
|
||||
|
||||
async cleanupNodeTemplatesFolder(): Promise<void> {
|
||||
return this.adminApi.nodes.deleteNodeChildren(
|
||||
await this.getNodeTemplatesFolderId()
|
||||
);
|
||||
return this.adminApi.nodes.deleteNodeChildren(await this.getNodeTemplatesFolderId());
|
||||
}
|
||||
|
||||
async cleanupSpaceTemplatesFolder(): Promise<void> {
|
||||
@@ -147,68 +105,36 @@ export class AdminActions {
|
||||
|
||||
// folder links are deleted automatically when original folder is deleted
|
||||
// Software Engineering Project is the default folder template coming from ACS, should not be deleted
|
||||
const nodesToDelete = (
|
||||
await this.adminApi.nodes.getNodeChildren(spaceTemplatesNodeId)
|
||||
).list.entries
|
||||
.filter(
|
||||
node =>
|
||||
node.entry.nodeType !== 'app:folderlink' &&
|
||||
node.entry.name !== 'Software Engineering Project'
|
||||
)
|
||||
.map(node => node.entry.id);
|
||||
const nodesToDelete = (await this.adminApi.nodes.getNodeChildren(spaceTemplatesNodeId)).list.entries
|
||||
.filter((node) => node.entry.nodeType !== 'app:folderlink' && node.entry.name !== 'Software Engineering Project')
|
||||
.map((node) => node.entry.id);
|
||||
return this.adminApi.nodes.deleteNodesById(nodesToDelete);
|
||||
}
|
||||
|
||||
async createLinkToFileId(
|
||||
originalFileId: string,
|
||||
destinationParentId: string
|
||||
): Promise<NodeEntry> {
|
||||
return this.adminApi.nodes.createFileLink(
|
||||
originalFileId,
|
||||
destinationParentId
|
||||
);
|
||||
async createLinkToFileId(originalFileId: string, destinationParentId: string): Promise<NodeEntry> {
|
||||
return this.adminApi.nodes.createFileLink(originalFileId, destinationParentId);
|
||||
}
|
||||
|
||||
async createLinkToFileName(
|
||||
originalFileName: string,
|
||||
originalFileParentId: string,
|
||||
destinationParentId?: string
|
||||
): Promise<NodeEntry> {
|
||||
async createLinkToFileName(originalFileName: string, originalFileParentId: string, destinationParentId?: string): Promise<NodeEntry> {
|
||||
if (!destinationParentId) {
|
||||
destinationParentId = originalFileParentId;
|
||||
}
|
||||
|
||||
const nodeId = await this.adminApi.nodes.getNodeIdFromParent(
|
||||
originalFileName,
|
||||
originalFileParentId
|
||||
);
|
||||
const nodeId = await this.adminApi.nodes.getNodeIdFromParent(originalFileName, originalFileParentId);
|
||||
|
||||
return this.createLinkToFileId(nodeId, destinationParentId);
|
||||
}
|
||||
|
||||
async createLinkToFolderId(
|
||||
originalFolderId: string,
|
||||
destinationParentId: string
|
||||
): Promise<NodeEntry> {
|
||||
return this.adminApi.nodes.createFolderLink(
|
||||
originalFolderId,
|
||||
destinationParentId
|
||||
);
|
||||
async createLinkToFolderId(originalFolderId: string, destinationParentId: string): Promise<NodeEntry> {
|
||||
return this.adminApi.nodes.createFolderLink(originalFolderId, destinationParentId);
|
||||
}
|
||||
|
||||
async createLinkToFolderName(
|
||||
originalFolderName: string,
|
||||
originalFolderParentId: string,
|
||||
destinationParentId?: string
|
||||
): Promise<NodeEntry> {
|
||||
async createLinkToFolderName(originalFolderName: string, originalFolderParentId: string, destinationParentId?: string): Promise<NodeEntry> {
|
||||
if (!destinationParentId) {
|
||||
destinationParentId = originalFolderParentId;
|
||||
}
|
||||
|
||||
const nodeId = await this.adminApi.nodes.getNodeIdFromParent(
|
||||
originalFolderName,
|
||||
originalFolderParentId
|
||||
);
|
||||
const nodeId = await this.adminApi.nodes.getNodeIdFromParent(originalFolderName, originalFolderParentId);
|
||||
|
||||
return this.createLinkToFolderId(nodeId, destinationParentId);
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@
|
||||
import { RepoApi } from '../repo-api';
|
||||
|
||||
export class AuthenticationApi extends RepoApi {
|
||||
constructor(username?, password?) {
|
||||
constructor(username?: string, password?: string) {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,7 @@ import { CommentsApi as AdfCommentsApi } from '@alfresco/js-api';
|
||||
export class CommentsApi extends RepoApi {
|
||||
commentsApi = new AdfCommentsApi(this.alfrescoJsApi);
|
||||
|
||||
constructor(username?, password?) {
|
||||
constructor(username?: string, password?: string) {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
@@ -38,10 +38,7 @@ export class CommentsApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.commentsApi.listComments(nodeId);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getNodeComments.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeComments.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -51,10 +48,7 @@ export class CommentsApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.commentsApi.createComment(nodeId, { content: comment });
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.addComment.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.addComment.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -64,10 +58,7 @@ export class CommentsApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.commentsApi.createComment(nodeId, comment);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.addComments.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.addComments.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -27,17 +27,13 @@ import { RepoApi } from '../repo-api';
|
||||
import { Logger } from '@alfresco/adf-testing';
|
||||
import { RepoClient } from './../../repo-client';
|
||||
import { Utils } from '../../../../utilities/utils';
|
||||
import {
|
||||
FavoritesApi as AdfFavoritesApi,
|
||||
SitesApi as AdfSiteApi,
|
||||
FavoriteEntry
|
||||
} from '@alfresco/js-api';
|
||||
import { FavoritesApi as AdfFavoritesApi, SitesApi as AdfSiteApi, FavoriteEntry } from '@alfresco/js-api';
|
||||
|
||||
export class FavoritesApi extends RepoApi {
|
||||
favoritesApi = new AdfFavoritesApi(this.alfrescoJsApi);
|
||||
sitesApi = new AdfSiteApi(this.alfrescoJsApi);
|
||||
|
||||
constructor(username?, password?) {
|
||||
constructor(username?: string, password?: string) {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
@@ -53,18 +49,12 @@ export class FavoritesApi extends RepoApi {
|
||||
};
|
||||
return await this.favoritesApi.createFavorite('-me-', data);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.addFavorite.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.addFavorite.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async addFavoriteById(
|
||||
nodeType: 'file' | 'folder' | 'site',
|
||||
id: string
|
||||
): Promise<FavoriteEntry | null> {
|
||||
async addFavoriteById(nodeType: 'file' | 'folder' | 'site', id: string): Promise<FavoriteEntry | null> {
|
||||
let guid;
|
||||
try {
|
||||
await this.apiAuth();
|
||||
@@ -82,10 +72,7 @@ export class FavoritesApi extends RepoApi {
|
||||
};
|
||||
return await this.favoritesApi.createFavorite('-me-', data);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.addFavoriteById.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.addFavoriteById.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -97,10 +84,7 @@ export class FavoritesApi extends RepoApi {
|
||||
await this.addFavoriteById(nodeType, current);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.addFavoritesByIds.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.addFavoritesByIds.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,10 +93,7 @@ export class FavoritesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.favoritesApi.listFavorites(this.getUsername());
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getFavorites.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getFavorites.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -122,24 +103,16 @@ export class FavoritesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.favoritesApi.getFavorite('-me-', nodeId);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getFavoriteById.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getFavoriteById.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async isFavorite(nodeId: string) {
|
||||
try {
|
||||
return JSON.stringify((await this.getFavorites()).list.entries).includes(
|
||||
nodeId
|
||||
);
|
||||
return JSON.stringify((await this.getFavorites()).list.entries).includes(nodeId);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.isFavorite.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.isFavorite.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -167,10 +140,7 @@ export class FavoritesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.favoritesApi.deleteFavorite('-me-', nodeId);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.removeFavoriteById.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.removeFavoriteById.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,18 +151,14 @@ export class FavoritesApi extends RepoApi {
|
||||
await this.removeFavoriteById(current);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.removeFavoritesByIds.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.removeFavoritesByIds.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async waitForApi(data: { expect: number }) {
|
||||
try {
|
||||
const favoriteFiles = async () => {
|
||||
const totalItems = (await this.getFavorites()).list.pagination
|
||||
.totalItems;
|
||||
const totalItems = (await this.getFavorites()).list.pagination.totalItems;
|
||||
if (totalItems !== data.expect) {
|
||||
return Promise.reject(totalItems);
|
||||
} else {
|
||||
|
@@ -23,13 +23,7 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
NodeBodyCreate,
|
||||
NODE_TYPE_FILE,
|
||||
NODE_TYPE_FOLDER,
|
||||
NODE_TITLE,
|
||||
NODE_DESCRIPTION
|
||||
} from './node-body-create';
|
||||
import { NodeBodyCreate, NODE_TYPE_FILE, NODE_TYPE_FOLDER, NODE_TITLE, NODE_DESCRIPTION } from './node-body-create';
|
||||
|
||||
export interface NodeContentTree {
|
||||
name?: string;
|
||||
@@ -39,10 +33,7 @@ export interface NodeContentTree {
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export function flattenNodeContentTree(
|
||||
content: NodeContentTree,
|
||||
relativePath: string = '/'
|
||||
): NodeBodyCreate[] {
|
||||
export function flattenNodeContentTree(content: NodeContentTree, relativePath: string = '/'): NodeBodyCreate[] {
|
||||
const { name, files, folders, title, description } = content;
|
||||
const aspectNames: string[] = ['cm:versionable'];
|
||||
let data: NodeBodyCreate[] = [];
|
||||
@@ -63,23 +54,17 @@ export function flattenNodeContentTree(
|
||||
}
|
||||
]);
|
||||
|
||||
relativePath =
|
||||
relativePath === '/' ? `/${name}` : `${relativePath}/${name}`;
|
||||
relativePath = relativePath === '/' ? `/${name}` : `${relativePath}/${name}`;
|
||||
}
|
||||
|
||||
if (folders) {
|
||||
const foldersData: NodeBodyCreate[] = folders
|
||||
.map((folder: string | NodeContentTree): NodeBodyCreate[] => {
|
||||
const folderData: NodeContentTree =
|
||||
typeof folder === 'string' ? { name: folder } : folder;
|
||||
const folderData: NodeContentTree = typeof folder === 'string' ? { name: folder } : folder;
|
||||
|
||||
return flattenNodeContentTree(folderData, relativePath);
|
||||
})
|
||||
.reduce(
|
||||
(nodesData: NodeBodyCreate[], folderData: NodeBodyCreate[]) =>
|
||||
nodesData.concat(folderData),
|
||||
[]
|
||||
);
|
||||
.reduce((nodesData: NodeBodyCreate[], folderData: NodeBodyCreate[]) => nodesData.concat(folderData), []);
|
||||
|
||||
data = data.concat(foldersData);
|
||||
}
|
||||
|
@@ -26,18 +26,13 @@
|
||||
import { RepoApi } from '../repo-api';
|
||||
import { NodeBodyCreate } from './node-body-create';
|
||||
import { NodeContentTree, flattenNodeContentTree } from './node-content-tree';
|
||||
import {
|
||||
NodesApi as AdfNodeApi,
|
||||
NodeBodyLock,
|
||||
NodeEntry,
|
||||
NodeChildAssociationPaging
|
||||
} from '@alfresco/js-api';
|
||||
import { NodesApi as AdfNodeApi, NodeBodyLock, NodeEntry, NodeChildAssociationPaging } from '@alfresco/js-api';
|
||||
import { Utils } from '../../../../utilities/utils';
|
||||
|
||||
export class NodesApi extends RepoApi {
|
||||
nodesApi = new AdfNodeApi(this.alfrescoJsApi);
|
||||
|
||||
constructor(username?, password?) {
|
||||
constructor(username?: string, password?: string) {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
@@ -46,10 +41,7 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.getNode('-my-', { relativePath });
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getNodeByPath.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeByPath.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -60,10 +52,7 @@ export class NodesApi extends RepoApi {
|
||||
const node = await this.nodesApi.getNode(id);
|
||||
return node;
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getNodeById.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeById.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -71,12 +60,9 @@ export class NodesApi extends RepoApi {
|
||||
async getNodeIdFromParent(name: string, parentId: string): Promise<string> {
|
||||
try {
|
||||
const children = (await this.getNodeChildren(parentId)).list.entries;
|
||||
return children.find(elem => elem.entry.name === name).entry.id || '';
|
||||
return children.find((elem) => elem.entry.name === name).entry.id || '';
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getNodeIdFromParent.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeIdFromParent.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -84,16 +70,9 @@ export class NodesApi extends RepoApi {
|
||||
async getNodeDescription(name: string, parentId: string): Promise<string> {
|
||||
try {
|
||||
const children = (await this.getNodeChildren(parentId)).list.entries;
|
||||
return (
|
||||
children.find(elem => elem.entry.name === name).entry.properties[
|
||||
'cm:description'
|
||||
] || ''
|
||||
);
|
||||
return children.find((elem) => elem.entry.name === name).entry.properties['cm:description'] || '';
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getNodeDescription.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeDescription.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -101,16 +80,9 @@ export class NodesApi extends RepoApi {
|
||||
async getNodeTitle(name: string, parentId: string): Promise<string> {
|
||||
try {
|
||||
const children = (await this.getNodeChildren(parentId)).list.entries;
|
||||
return (
|
||||
children.find(elem => elem.entry.name === name).entry.properties[
|
||||
'cm:title'
|
||||
] || ''
|
||||
);
|
||||
return children.find((elem) => elem.entry.name === name).entry.properties['cm:title'] || '';
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getNodeTitle.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeTitle.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -120,10 +92,7 @@ export class NodesApi extends RepoApi {
|
||||
const node = await this.getNodeById(nodeId);
|
||||
return (node.entry.properties && node.entry.properties[property]) || '';
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getNodeProperty.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeProperty.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -133,10 +102,7 @@ export class NodesApi extends RepoApi {
|
||||
const prop = await this.getNodeProperty(nodeId, 'cm:versionType');
|
||||
return prop || '';
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getFileVersionType.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getFileVersionType.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -146,10 +112,7 @@ export class NodesApi extends RepoApi {
|
||||
const prop = await this.getNodeProperty(nodeId, 'cm:versionLabel');
|
||||
return prop || '';
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getFileVersionLabel.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getFileVersionLabel.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -159,26 +122,17 @@ export class NodesApi extends RepoApi {
|
||||
const sharedId = await this.getNodeProperty(nodeId, 'qshare:sharedId');
|
||||
return sharedId || '';
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getSharedId.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getSharedId.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async getSharedExpiryDate(nodeId: string): Promise<string> {
|
||||
try {
|
||||
const expiryDate = await this.getNodeProperty(
|
||||
nodeId,
|
||||
'qshare:expiryDate'
|
||||
);
|
||||
const expiryDate = await this.getNodeProperty(nodeId, 'qshare:expiryDate');
|
||||
return expiryDate || '';
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getSharedExpiryDate.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getSharedExpiryDate.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -188,10 +142,7 @@ export class NodesApi extends RepoApi {
|
||||
const sharedId = await this.getSharedId(nodeId);
|
||||
return sharedId !== '';
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.isFileShared.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.isFileShared.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -201,69 +152,42 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
await this.nodesApi.deleteNode(id, { permanent });
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.deleteNodeById.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteNodeById.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteNodeByPath(
|
||||
path: string,
|
||||
permanent: boolean = true
|
||||
): Promise<void> {
|
||||
async deleteNodeByPath(path: string, permanent: boolean = true): Promise<void> {
|
||||
try {
|
||||
const id = (await this.getNodeByPath(path)).entry.id;
|
||||
await this.deleteNodeById(id, permanent);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.deleteNodeByPath.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteNodeByPath.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteNodes(
|
||||
names: string[],
|
||||
relativePath: string = '',
|
||||
permanent: boolean = true
|
||||
): Promise<void> {
|
||||
async deleteNodes(names: string[], relativePath: string = '', permanent: boolean = true): Promise<void> {
|
||||
try {
|
||||
await names.reduce(async (previous, current) => {
|
||||
await previous;
|
||||
const req = await this.deleteNodeByPath(
|
||||
`${relativePath}/${current}`,
|
||||
permanent
|
||||
);
|
||||
const req = await this.deleteNodeByPath(`${relativePath}/${current}`, permanent);
|
||||
return req;
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.deleteNodes.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteNodes.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteNodesById(
|
||||
ids: string[],
|
||||
permanent: boolean = true
|
||||
): Promise<void> {
|
||||
async deleteNodesById(ids: string[], permanent: boolean = true): Promise<void> {
|
||||
try {
|
||||
for (const id of ids) {
|
||||
await this.deleteNodeById(id, permanent);
|
||||
}
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.deleteNodesById.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteNodesById.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async getNodeChildren(
|
||||
nodeId: string
|
||||
): Promise<NodeChildAssociationPaging | null> {
|
||||
async getNodeChildren(nodeId: string): Promise<NodeChildAssociationPaging | null> {
|
||||
try {
|
||||
const opts = {
|
||||
include: ['properties']
|
||||
@@ -271,61 +195,35 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.listNodeChildren(nodeId, opts);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getNodeChildren.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeChildren.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async deleteNodeChildren(
|
||||
parentId: string,
|
||||
exceptNodesNamed?: string[]
|
||||
): Promise<void> {
|
||||
async deleteNodeChildren(parentId: string, exceptNodesNamed?: string[]): Promise<void> {
|
||||
try {
|
||||
const listEntries = (await this.getNodeChildren(parentId)).list.entries;
|
||||
let nodeIds: string[];
|
||||
if (exceptNodesNamed) {
|
||||
nodeIds = listEntries
|
||||
.filter(entries => !exceptNodesNamed.includes(entries.entry.name))
|
||||
.map(entries => entries.entry.id);
|
||||
nodeIds = listEntries.filter((entries) => !exceptNodesNamed.includes(entries.entry.name)).map((entries) => entries.entry.id);
|
||||
} else {
|
||||
nodeIds = listEntries.map(entries => entries.entry.id);
|
||||
nodeIds = listEntries.map((entries) => entries.entry.id);
|
||||
}
|
||||
await this.deleteNodesById(nodeIds);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.deleteNodeChildren.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteNodeChildren.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createImageNode(
|
||||
name: string,
|
||||
parentId: string = '-my-',
|
||||
title: string = '',
|
||||
description: string = ''
|
||||
): Promise<NodeEntry | null> {
|
||||
async createImageNode(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise<NodeEntry | null> {
|
||||
const imageProps = {
|
||||
'exif:pixelXDimension': 1000,
|
||||
'exif:pixelYDimension': 1200
|
||||
};
|
||||
try {
|
||||
return await this.createNode(
|
||||
'cm:content',
|
||||
name,
|
||||
parentId,
|
||||
title,
|
||||
description,
|
||||
imageProps
|
||||
);
|
||||
return await this.createNode('cm:content', name, parentId, title, description, imageProps);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createImageNode.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createImageNode.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -364,10 +262,7 @@ export class NodesApi extends RepoApi {
|
||||
majorVersion
|
||||
});
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createNode.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createNode.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -382,39 +277,18 @@ export class NodesApi extends RepoApi {
|
||||
aspectNames: string[] = null
|
||||
): Promise<NodeEntry> {
|
||||
try {
|
||||
return await this.createNode(
|
||||
'cm:content',
|
||||
name,
|
||||
parentId,
|
||||
title,
|
||||
description,
|
||||
null,
|
||||
author,
|
||||
majorVersion,
|
||||
aspectNames
|
||||
);
|
||||
return await this.createNode('cm:content', name, parentId, title, description, null, author, majorVersion, aspectNames);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createFile.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createFile.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async createImage(
|
||||
name: string,
|
||||
parentId: string = '-my-',
|
||||
title: string = '',
|
||||
description: string = ''
|
||||
): Promise<NodeEntry | null> {
|
||||
async createImage(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise<NodeEntry | null> {
|
||||
try {
|
||||
return await this.createImageNode(name, parentId, title, description);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createImage.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createImage.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -428,22 +302,9 @@ export class NodesApi extends RepoApi {
|
||||
aspectNames: string[] = null
|
||||
): Promise<NodeEntry | null> {
|
||||
try {
|
||||
return await this.createNode(
|
||||
'cm:folder',
|
||||
name,
|
||||
parentId,
|
||||
title,
|
||||
description,
|
||||
null,
|
||||
author,
|
||||
null,
|
||||
aspectNames
|
||||
);
|
||||
return await this.createNode('cm:folder', name, parentId, title, description, null, author, null, aspectNames);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createFolder.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createFolder.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -453,54 +314,31 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.createNode('-my-', data as any);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createChildren.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createChildren.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createContent(
|
||||
content: NodeContentTree,
|
||||
relativePath: string = '/'
|
||||
): Promise<NodeEntry | any> {
|
||||
async createContent(content: NodeContentTree, relativePath: string = '/'): Promise<NodeEntry | any> {
|
||||
try {
|
||||
return await this.createChildren(
|
||||
flattenNodeContentTree(content, relativePath)
|
||||
);
|
||||
return await this.createChildren(flattenNodeContentTree(content, relativePath));
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createContent.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createContent.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createFolders(
|
||||
names: string[],
|
||||
relativePath: string = '/'
|
||||
): Promise<NodeEntry | any> {
|
||||
async createFolders(names: string[], relativePath: string = '/'): Promise<NodeEntry | any> {
|
||||
try {
|
||||
return await this.createContent({ folders: names }, relativePath);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createFolders.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createFolders.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createFiles(
|
||||
names: string[],
|
||||
relativePath: string = '/'
|
||||
): Promise<NodeEntry | any> {
|
||||
async createFiles(names: string[], relativePath: string = '/'): Promise<NodeEntry | any> {
|
||||
try {
|
||||
return await this.createContent({ files: names }, relativePath);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createFiles.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createFiles.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,18 +347,12 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.nodesApi.updateNode(nodeId, { aspectNames });
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.addAspects.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.addAspects.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async createFileLink(
|
||||
originalNodeId: string,
|
||||
destinationId: string
|
||||
): Promise<NodeEntry | null> {
|
||||
async createFileLink(originalNodeId: string, destinationId: string): Promise<NodeEntry | null> {
|
||||
const name = (await this.getNodeById(originalNodeId)).entry.name;
|
||||
const nodeBody = {
|
||||
name: `Link to ${name}.url`,
|
||||
@@ -536,18 +368,12 @@ export class NodesApi extends RepoApi {
|
||||
await this.addAspects(originalNodeId, ['app:linked']);
|
||||
return link;
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createFileLink.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createFileLink.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async createFolderLink(
|
||||
originalNodeId: string,
|
||||
destinationId: string
|
||||
): Promise<NodeEntry | null> {
|
||||
async createFolderLink(originalNodeId: string, destinationId: string): Promise<NodeEntry | null> {
|
||||
const name = (await this.getNodeById(originalNodeId)).entry.name;
|
||||
const nodeBody = {
|
||||
name: `Link to ${name}.url`,
|
||||
@@ -566,10 +392,7 @@ export class NodesApi extends RepoApi {
|
||||
await this.addAspects(originalNodeId, ['app:linked']);
|
||||
return link;
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createFolderLink.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createFolderLink.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -580,25 +403,16 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.getNodeContent(nodeId);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getNodeContent.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeContent.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async editNodeContent(
|
||||
nodeId: string,
|
||||
content: string
|
||||
): Promise<NodeEntry | null> {
|
||||
async editNodeContent(nodeId: string, content: string): Promise<NodeEntry | null> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.updateNodeContent(nodeId, content);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.editNodeContent.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.editNodeContent.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -608,19 +422,13 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.nodesApi.updateNode(nodeId, { name: newName });
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.renameNode.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.renameNode.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// node permissions
|
||||
async setInheritPermissions(
|
||||
nodeId: string,
|
||||
inheritPermissions: boolean
|
||||
): Promise<NodeEntry | null> {
|
||||
async setInheritPermissions(nodeId: string, inheritPermissions: boolean): Promise<NodeEntry | null> {
|
||||
const data = {
|
||||
permissions: {
|
||||
isInheritanceEnabled: inheritPermissions
|
||||
@@ -631,20 +439,12 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.updateNode(nodeId, data);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.setGranularPermission.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.setGranularPermission.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async setGranularPermission(
|
||||
nodeId: string,
|
||||
inheritPermissions: boolean = false,
|
||||
username: string,
|
||||
role: string
|
||||
): Promise<NodeEntry | null> {
|
||||
async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string): Promise<NodeEntry | null> {
|
||||
const data = {
|
||||
permissions: {
|
||||
isInheritanceEnabled: inheritPermissions,
|
||||
@@ -661,19 +461,13 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.updateNode(nodeId, data);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.setGranularPermission.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.setGranularPermission.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// lock node
|
||||
async lockFile(
|
||||
nodeId: string,
|
||||
lockType: string = 'ALLOW_OWNER_CHANGES'
|
||||
): Promise<NodeEntry | null> {
|
||||
async lockFile(nodeId: string, lockType: string = 'ALLOW_OWNER_CHANGES'): Promise<NodeEntry | null> {
|
||||
const data = {
|
||||
type: lockType
|
||||
} as NodeBodyLock;
|
||||
@@ -692,10 +486,7 @@ export class NodesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.unlockNode(nodeId);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.unlockFile.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.unlockFile.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -705,10 +496,7 @@ export class NodesApi extends RepoApi {
|
||||
const lockType = await this.getNodeProperty(nodeId, 'cm:lockType');
|
||||
return lockType || '';
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getLockType.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getLockType.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -718,10 +506,7 @@ export class NodesApi extends RepoApi {
|
||||
const lockOwner = await this.getNodeProperty(nodeId, 'cm:lockOwner');
|
||||
return lockOwner || '';
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getLockOwner.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getLockOwner.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -730,18 +515,12 @@ export class NodesApi extends RepoApi {
|
||||
try {
|
||||
return (await this.getLockType(nodeId)) === 'WRITE_LOCK';
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.isFileLockedWrite.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.isFileLockedWrite.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async isFileLockedWriteWithRetry(
|
||||
nodeId: string,
|
||||
expect: boolean
|
||||
): Promise<boolean> {
|
||||
async isFileLockedWriteWithRetry(nodeId: string, expect: boolean): Promise<boolean> {
|
||||
const data = {
|
||||
expect: expect,
|
||||
retry: 5
|
||||
@@ -758,26 +537,17 @@ export class NodesApi extends RepoApi {
|
||||
};
|
||||
return await Utils.retryCall(locked, data.retry);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.isFileLockedWriteWithRetry.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.isFileLockedWriteWithRetry.name}`, error);
|
||||
}
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
async isFileLockedByName(
|
||||
fileName: string,
|
||||
parentId: string
|
||||
): Promise<boolean> {
|
||||
async isFileLockedByName(fileName: string, parentId: string): Promise<boolean> {
|
||||
try {
|
||||
const id = await this.getNodeIdFromParent(fileName, parentId);
|
||||
return await this.isFileLockedWrite(id);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.isFileLockedByName.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.isFileLockedByName.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -40,10 +40,7 @@ export class PeopleApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.peopleApi.createPerson(person);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createUser.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createUser.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -63,10 +60,7 @@ export class PeopleApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.peopleApi.updatePerson(username, userDetails);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.updateUser.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.updateUser.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -75,10 +69,7 @@ export class PeopleApi extends RepoApi {
|
||||
try {
|
||||
return await this.updateUser(username, { enabled: false });
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.disableUser.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.disableUser.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -87,10 +78,7 @@ export class PeopleApi extends RepoApi {
|
||||
try {
|
||||
return await this.updateUser(username, { password: newPassword });
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.changePassword.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.changePassword.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -45,10 +45,7 @@ export class QueriesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.queriesApi.findSites(searchTerm, data);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.findSites.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.findSites.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -63,10 +60,7 @@ export class QueriesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.queriesApi.findNodes(searchTerm, data);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.findNodes.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.findNodes.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -74,8 +68,7 @@ export class QueriesApi extends RepoApi {
|
||||
async waitForSites(searchTerm: string, data: { expect: number }) {
|
||||
try {
|
||||
const sites = async () => {
|
||||
const totalItems = (await this.findSites(searchTerm)).list.pagination
|
||||
.totalItems;
|
||||
const totalItems = (await this.findSites(searchTerm)).list.pagination.totalItems;
|
||||
if (totalItems !== data.expect) {
|
||||
return Promise.reject(totalItems);
|
||||
} else {
|
||||
@@ -85,9 +78,7 @@ export class QueriesApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(sites);
|
||||
} catch (error) {
|
||||
Logger.error(
|
||||
`${this.constructor.name} ${this.waitForSites.name} catch: `
|
||||
);
|
||||
Logger.error(`${this.constructor.name} ${this.waitForSites.name} catch: `);
|
||||
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
}
|
||||
@@ -95,8 +86,7 @@ export class QueriesApi extends RepoApi {
|
||||
async waitForFilesAndFolders(searchTerm: string, data: { expect: number }) {
|
||||
try {
|
||||
const nodes = async () => {
|
||||
const totalItems = (await this.findNodes(searchTerm)).list.pagination
|
||||
.totalItems;
|
||||
const totalItems = (await this.findNodes(searchTerm)).list.pagination.totalItems;
|
||||
if (totalItems !== data.expect) {
|
||||
return Promise.reject(totalItems);
|
||||
} else {
|
||||
@@ -106,9 +96,7 @@ export class QueriesApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(nodes);
|
||||
} catch (error) {
|
||||
Logger.error(
|
||||
`${this.constructor.name} ${this.waitForFilesAndFolders.name} catch: `
|
||||
);
|
||||
Logger.error(`${this.constructor.name} ${this.waitForFilesAndFolders.name} catch: `);
|
||||
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
}
|
||||
|
@@ -30,10 +30,7 @@ import { Logger } from '@alfresco/adf-testing';
|
||||
export abstract class RepoApi {
|
||||
alfrescoJsApi = new AlfrescoApi();
|
||||
|
||||
constructor(
|
||||
private username: string = browser.params.ADMIN_USERNAME,
|
||||
private password: string = browser.params.ADMIN_PASSWORD
|
||||
) {
|
||||
constructor(private username: string = browser.params.ADMIN_USERNAME, private password: string = browser.params.ADMIN_PASSWORD) {
|
||||
this.alfrescoJsApi.setConfig(browser.params.config);
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@ import { SearchApi as AdfSearchApi } from '@alfresco/js-api';
|
||||
export class SearchApi extends RepoApi {
|
||||
searchApi = new AdfSearchApi(this.alfrescoJsApi);
|
||||
|
||||
constructor(username?, password?) {
|
||||
constructor(username?: string, password?: string) {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
@@ -52,10 +52,7 @@ export class SearchApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.searchApi.search(data);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.queryRecentFiles.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.queryRecentFiles.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -73,10 +70,7 @@ export class SearchApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.searchApi.search(data);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.queryNodesNames.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.queryNodesNames.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -94,10 +88,7 @@ export class SearchApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return this.searchApi.search(data);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.queryNodesExactNames.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.queryNodesExactNames.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -105,8 +96,7 @@ export class SearchApi extends RepoApi {
|
||||
async waitForApi(username: string, data: { expect: number }) {
|
||||
try {
|
||||
const recentFiles = async () => {
|
||||
const totalItems = (await this.queryRecentFiles(username)).list
|
||||
.pagination.totalItems;
|
||||
const totalItems = (await this.queryRecentFiles(username)).list.pagination.totalItems;
|
||||
if (totalItems !== data.expect) {
|
||||
return Promise.reject(totalItems);
|
||||
} else {
|
||||
@@ -124,8 +114,7 @@ export class SearchApi extends RepoApi {
|
||||
async waitForNodes(searchTerm: string, data: { expect: number }) {
|
||||
try {
|
||||
const nodes = async () => {
|
||||
const totalItems = (await this.queryNodesNames(searchTerm)).list
|
||||
.pagination.totalItems;
|
||||
const totalItems = (await this.queryNodesNames(searchTerm)).list.pagination.totalItems;
|
||||
if (totalItems !== data.expect) {
|
||||
return Promise.reject(totalItems);
|
||||
} else {
|
||||
@@ -135,9 +124,7 @@ export class SearchApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(nodes);
|
||||
} catch (error) {
|
||||
Logger.error(
|
||||
`${this.constructor.name} ${this.waitForNodes.name} catch: `
|
||||
);
|
||||
Logger.error(`${this.constructor.name} ${this.waitForNodes.name} catch: `);
|
||||
Logger.error(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
}
|
||||
|
@@ -26,22 +26,16 @@
|
||||
import { RepoApi } from '../repo-api';
|
||||
import { Logger } from '@alfresco/adf-testing';
|
||||
import { Utils } from '../../../../utilities/utils';
|
||||
import {
|
||||
SharedlinksApi as AdfSharedlinksApi,
|
||||
SharedLinkEntry
|
||||
} from '@alfresco/js-api';
|
||||
import { SharedlinksApi as AdfSharedlinksApi, SharedLinkEntry } from '@alfresco/js-api';
|
||||
|
||||
export class SharedLinksApi extends RepoApi {
|
||||
sharedlinksApi = new AdfSharedlinksApi(this.alfrescoJsApi);
|
||||
|
||||
constructor(username?, password?) {
|
||||
constructor(username?: string, password?: string) {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
async shareFileById(
|
||||
id: string,
|
||||
expireDate?: Date
|
||||
): Promise<SharedLinkEntry | null> {
|
||||
async shareFileById(id: string, expireDate?: Date): Promise<SharedLinkEntry | null> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
const data = {
|
||||
@@ -50,10 +44,7 @@ export class SharedLinksApi extends RepoApi {
|
||||
};
|
||||
return await this.sharedlinksApi.createSharedLink(data);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.shareFileById.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.shareFileById.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -65,25 +56,17 @@ export class SharedLinksApi extends RepoApi {
|
||||
return this.shareFileById(current);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.shareFilesByIds.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.shareFilesByIds.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async getSharedIdOfNode(name: string) {
|
||||
try {
|
||||
const sharedLinks = (await this.getSharedLinks()).list.entries;
|
||||
const found = sharedLinks.find(
|
||||
sharedLink => sharedLink.entry.name === name
|
||||
);
|
||||
const found = sharedLinks.find((sharedLink) => sharedLink.entry.name === name);
|
||||
return (found || { entry: { id: null } }).entry.id;
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getSharedIdOfNode.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getSharedIdOfNode.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -93,10 +76,7 @@ export class SharedLinksApi extends RepoApi {
|
||||
const id = await this.getSharedIdOfNode(name);
|
||||
return await this.sharedlinksApi.deleteSharedLink(id);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.unshareFile.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.unshareFile.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,10 +85,7 @@ export class SharedLinksApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sharedlinksApi.listSharedLinks();
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getSharedLinks.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getSharedLinks.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -116,8 +93,7 @@ export class SharedLinksApi extends RepoApi {
|
||||
async waitForApi(data: { expect: number }) {
|
||||
try {
|
||||
const sharedFiles = async () => {
|
||||
const totalItems = (await this.getSharedLinks()).list.pagination
|
||||
.totalItems;
|
||||
const totalItems = (await this.getSharedLinks()).list.pagination.totalItems;
|
||||
if (totalItems !== data.expect) {
|
||||
return Promise.reject(totalItems);
|
||||
} else {
|
||||
|
@@ -40,7 +40,7 @@ import { Utils } from '../../../../utilities/utils';
|
||||
export class SitesApi extends RepoApi {
|
||||
sitesApi = new AdfSiteApi(this.alfrescoJsApi);
|
||||
|
||||
constructor(username?, password?) {
|
||||
constructor(username?: string, password?: string) {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
@@ -57,9 +57,7 @@ export class SitesApi extends RepoApi {
|
||||
async getSites() {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.listSiteMembershipsForPerson(
|
||||
this.getUsername()
|
||||
);
|
||||
return await this.sitesApi.listSiteMembershipsForPerson(this.getUsername());
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getSites.name}`, error);
|
||||
return null;
|
||||
@@ -69,13 +67,9 @@ export class SitesApi extends RepoApi {
|
||||
async getDocLibId(siteId: string) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return (await this.sitesApi.listSiteContainers(siteId)).list.entries[0]
|
||||
.entry.id;
|
||||
return (await this.sitesApi.listSiteContainers(siteId)).list.entries[0].entry.id;
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getDocLibId.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getDocLibId.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -85,10 +79,7 @@ export class SitesApi extends RepoApi {
|
||||
const site = await this.getSite(siteId);
|
||||
return site.entry.visibility;
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getVisibility.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getVisibility.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -98,10 +89,7 @@ export class SitesApi extends RepoApi {
|
||||
const site = await this.getSite(siteId);
|
||||
return site.entry.description;
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getDescription.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getDescription.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -116,12 +104,7 @@ export class SitesApi extends RepoApi {
|
||||
}
|
||||
}
|
||||
|
||||
async createSite(
|
||||
title: string,
|
||||
visibility?: string,
|
||||
description?: string,
|
||||
siteId?: string
|
||||
): Promise<SiteEntry | null> {
|
||||
async createSite(title: string, visibility?: string, description?: string, siteId?: string): Promise<SiteEntry | null> {
|
||||
const site = {
|
||||
title,
|
||||
visibility: visibility || SITE_VISIBILITY.PUBLIC,
|
||||
@@ -133,33 +116,17 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.createSite(site);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createSite.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createSite.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async createSitePrivate(
|
||||
title: string,
|
||||
description?: string,
|
||||
siteId?: string
|
||||
): Promise<SiteEntry> {
|
||||
async createSitePrivate(title: string, description?: string, siteId?: string): Promise<SiteEntry> {
|
||||
return this.createSite(title, SITE_VISIBILITY.PRIVATE, description, siteId);
|
||||
}
|
||||
|
||||
async createSiteModerated(
|
||||
title: string,
|
||||
description?: string,
|
||||
siteId?: string
|
||||
): Promise<SiteEntry> {
|
||||
return this.createSite(
|
||||
title,
|
||||
SITE_VISIBILITY.MODERATED,
|
||||
description,
|
||||
siteId
|
||||
);
|
||||
async createSiteModerated(title: string, description?: string, siteId?: string): Promise<SiteEntry> {
|
||||
return this.createSite(title, SITE_VISIBILITY.MODERATED, description, siteId);
|
||||
}
|
||||
|
||||
async createSites(titles: string[], visibility?: string): Promise<any> {
|
||||
@@ -169,10 +136,7 @@ export class SitesApi extends RepoApi {
|
||||
return this.createSite(current, visibility);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.createSites.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.createSites.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,10 +149,7 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.deleteSite(siteId, { permanent });
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.deleteSite.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteSite.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,28 +160,20 @@ export class SitesApi extends RepoApi {
|
||||
return this.deleteSite(current, permanent);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.deleteSites.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteSites.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteAllUserSites(permanent: boolean = true) {
|
||||
try {
|
||||
const siteIds = (await this.getSites()).list.entries.map(
|
||||
entries => entries.entry.id
|
||||
);
|
||||
const siteIds = (await this.getSites()).list.entries.map((entries) => entries.entry.id);
|
||||
|
||||
return await siteIds.reduce(async (previous, current) => {
|
||||
await previous;
|
||||
return this.deleteSite(current, permanent);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.deleteAllUserSites.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteAllUserSites.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,10 +186,7 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.updateSiteMembership(siteId, userId, siteRole);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.updateSiteMember.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.updateSiteMember.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -251,43 +201,24 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.createSiteMembership(siteId, memberBody);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.addSiteMember.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.addSiteMember.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async addSiteConsumer(
|
||||
siteId: string,
|
||||
userId: string
|
||||
): Promise<SiteMemberEntry> {
|
||||
async addSiteConsumer(siteId: string, userId: string): Promise<SiteMemberEntry> {
|
||||
return this.addSiteMember(siteId, userId, SITE_ROLES.SITE_CONSUMER.ROLE);
|
||||
}
|
||||
|
||||
async addSiteContributor(
|
||||
siteId: string,
|
||||
userId: string
|
||||
): Promise<SiteMemberEntry> {
|
||||
async addSiteContributor(siteId: string, userId: string): Promise<SiteMemberEntry> {
|
||||
return this.addSiteMember(siteId, userId, SITE_ROLES.SITE_CONTRIBUTOR.ROLE);
|
||||
}
|
||||
|
||||
async addSiteCollaborator(
|
||||
siteId: string,
|
||||
userId: string
|
||||
): Promise<SiteMemberEntry> {
|
||||
return this.addSiteMember(
|
||||
siteId,
|
||||
userId,
|
||||
SITE_ROLES.SITE_COLLABORATOR.ROLE
|
||||
);
|
||||
async addSiteCollaborator(siteId: string, userId: string): Promise<SiteMemberEntry> {
|
||||
return this.addSiteMember(siteId, userId, SITE_ROLES.SITE_COLLABORATOR.ROLE);
|
||||
}
|
||||
|
||||
async addSiteManager(
|
||||
siteId: string,
|
||||
userId: string
|
||||
): Promise<SiteMemberEntry> {
|
||||
async addSiteManager(siteId: string, userId: string): Promise<SiteMemberEntry> {
|
||||
return this.addSiteMember(siteId, userId, SITE_ROLES.SITE_MANAGER.ROLE);
|
||||
}
|
||||
|
||||
@@ -296,31 +227,20 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.deleteSiteMembership(siteId, userId);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.deleteSiteMember.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.deleteSiteMember.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async requestToJoin(
|
||||
siteId: string
|
||||
): Promise<SiteMembershipRequestEntry | null> {
|
||||
async requestToJoin(siteId: string): Promise<SiteMembershipRequestEntry | null> {
|
||||
const body = {
|
||||
id: siteId
|
||||
};
|
||||
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.createSiteMembershipRequestForPerson(
|
||||
'-me-',
|
||||
body
|
||||
);
|
||||
return await this.sitesApi.createSiteMembershipRequestForPerson('-me-', body);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.requestToJoin.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.requestToJoin.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -328,15 +248,10 @@ export class SitesApi extends RepoApi {
|
||||
async hasMembershipRequest(siteId: string) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
const requests = (
|
||||
await this.sitesApi.getSiteMembershipRequests('-me-')
|
||||
).list.entries.map(e => e.entry.id);
|
||||
const requests = (await this.sitesApi.getSiteMembershipRequests('-me-')).list.entries.map((e) => e.entry.id);
|
||||
return requests.includes(siteId);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.hasMembershipRequest.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.hasMembershipRequest.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -40,10 +40,7 @@ export class TrashcanApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.trashcanApi.deleteDeletedNode(id);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.permanentlyDelete.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.permanentlyDelete.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,37 +62,28 @@ export class TrashcanApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.trashcanApi.listDeletedNodes(opts);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.getDeletedNodes.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.getDeletedNodes.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async emptyTrash() {
|
||||
try {
|
||||
const ids = (await this.getDeletedNodes()).list.entries.map(
|
||||
entries => entries.entry.id
|
||||
);
|
||||
const ids = (await this.getDeletedNodes()).list.entries.map((entries) => entries.entry.id);
|
||||
|
||||
return await ids.reduce(async (previous, current) => {
|
||||
await previous;
|
||||
return this.permanentlyDelete(current);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.emptyTrash.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.emptyTrash.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async waitForApi(data: { expect: number }) {
|
||||
try {
|
||||
const deletedFiles = async () => {
|
||||
const totalItems = (await this.getDeletedNodes()).list.pagination
|
||||
.totalItems;
|
||||
const totalItems = (await this.getDeletedNodes()).list.pagination.totalItems;
|
||||
if (totalItems !== data.expect) {
|
||||
return Promise.reject(totalItems);
|
||||
} else {
|
||||
|
@@ -26,23 +26,20 @@
|
||||
import { RepoApi } from '../repo-api';
|
||||
import { UploadApi as AdfUploadApi } from '@alfresco/js-api';
|
||||
import { browser } from 'protractor';
|
||||
|
||||
const fs = require('fs');
|
||||
import * as fs from 'fs';
|
||||
|
||||
export class UploadApi extends RepoApi {
|
||||
upload = new AdfUploadApi(this.alfrescoJsApi);
|
||||
e2eRootPath = browser.params.e2eRootPath;
|
||||
|
||||
constructor(username?, password?) {
|
||||
constructor(username?: string, password?: string) {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
async uploadFile(fileName: string, parentFolderId: string = '-my-') {
|
||||
const file = fs.createReadStream(
|
||||
`${this.e2eRootPath}/resources/test-files/${fileName}`
|
||||
);
|
||||
const file = fs.createReadStream(`${this.e2eRootPath}/resources/test-files/${fileName}`);
|
||||
const opts = {
|
||||
name: file.name,
|
||||
name: fileName,
|
||||
nodeType: 'cm:content'
|
||||
};
|
||||
|
||||
@@ -50,23 +47,12 @@ export class UploadApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.upload.uploadFile(file, '', parentFolderId, null, opts);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.uploadFile.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.uploadFile.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async uploadFileWithRename(
|
||||
fileName: string,
|
||||
parentId: string = '-my-',
|
||||
newName: string,
|
||||
title: string = '',
|
||||
description: string = ''
|
||||
) {
|
||||
const file = fs.createReadStream(
|
||||
`${this.e2eRootPath}/resources/test-files/${fileName}`
|
||||
);
|
||||
async uploadFileWithRename(fileName: string, parentId: string = '-my-', newName: string, title: string = '', description: string = '') {
|
||||
const file = fs.createReadStream(`${this.e2eRootPath}/resources/test-files/${fileName}`);
|
||||
const nodeProps = {
|
||||
properties: {
|
||||
'cm:title': title,
|
||||
@@ -83,10 +69,7 @@ export class UploadApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.upload.uploadFile(file, '', parentId, nodeProps, opts);
|
||||
} catch (error) {
|
||||
this.handleError(
|
||||
`${this.constructor.name} ${this.uploadFileWithRename.name}`,
|
||||
error
|
||||
);
|
||||
this.handleError(`${this.constructor.name} ${this.uploadFileWithRename.name}`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,10 +37,7 @@ import { UploadApi } from './apis/upload/upload-api';
|
||||
import { AuthenticationApi } from './apis/authentication/authentication-api';
|
||||
|
||||
export class RepoClient {
|
||||
constructor(
|
||||
private username: string = browser.params.ADMIN_USERNAME,
|
||||
private password: string = browser.params.ADMIN_PASSWORD
|
||||
) {}
|
||||
constructor(private username: string = browser.params.ADMIN_USERNAME, private password: string = browser.params.ADMIN_PASSWORD) {}
|
||||
|
||||
private get auth() {
|
||||
const { username, password } = this;
|
||||
|
@@ -23,116 +23,57 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
browser,
|
||||
protractor,
|
||||
ElementFinder,
|
||||
ExpectedConditions as EC,
|
||||
by,
|
||||
logging,
|
||||
until,
|
||||
WebElement
|
||||
} from 'protractor';
|
||||
import { browser, protractor, ElementFinder, ExpectedConditions as EC, by, logging, until, WebElement } from 'protractor';
|
||||
import { Logger } from '@alfresco/adf-testing';
|
||||
import { BROWSER_WAIT_TIMEOUT } from '../configs';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const StreamZip = require('node-stream-zip');
|
||||
|
||||
export async function typeText(
|
||||
element: ElementFinder,
|
||||
text: string
|
||||
): Promise<void> {
|
||||
export async function typeText(element: ElementFinder, text: string): Promise<void> {
|
||||
await element.clear();
|
||||
await element.sendKeys(text);
|
||||
}
|
||||
|
||||
export async function clearTextWithBackspace(
|
||||
element: ElementFinder
|
||||
): Promise<void> {
|
||||
export async function clearTextWithBackspace(element: ElementFinder): Promise<void> {
|
||||
await element.clear();
|
||||
await element.sendKeys(
|
||||
' ',
|
||||
protractor.Key.CONTROL,
|
||||
'a',
|
||||
protractor.Key.NULL,
|
||||
protractor.Key.BACK_SPACE
|
||||
);
|
||||
await element.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE);
|
||||
}
|
||||
|
||||
export async function waitElement(
|
||||
css: string,
|
||||
errorMessage?: string
|
||||
): Promise<WebElement> {
|
||||
return browser.wait(
|
||||
until.elementLocated(by.css(css)),
|
||||
BROWSER_WAIT_TIMEOUT,
|
||||
errorMessage || `Timeout waiting for element: ${css}`
|
||||
);
|
||||
export async function waitElement(css: string, errorMessage?: string): Promise<WebElement> {
|
||||
return browser.wait(until.elementLocated(by.css(css)), BROWSER_WAIT_TIMEOUT, errorMessage || `Timeout waiting for element: ${css}`);
|
||||
}
|
||||
|
||||
export async function waitForClickable(
|
||||
element: ElementFinder,
|
||||
errorMessage?: string
|
||||
): Promise<void> {
|
||||
export async function waitForClickable(element: ElementFinder, errorMessage?: string): Promise<void> {
|
||||
await browser.wait(
|
||||
EC.elementToBeClickable(element),
|
||||
BROWSER_WAIT_TIMEOUT,
|
||||
errorMessage ||
|
||||
`Timeout waiting for element to be clickable: ${element.locator()}`
|
||||
errorMessage || `Timeout waiting for element to be clickable: ${element.locator()}`
|
||||
);
|
||||
}
|
||||
|
||||
export async function waitForVisibility(
|
||||
element: ElementFinder,
|
||||
errorMessage?: string
|
||||
): Promise<void> {
|
||||
await browser.wait(
|
||||
EC.visibilityOf(element),
|
||||
BROWSER_WAIT_TIMEOUT,
|
||||
errorMessage ||
|
||||
`Timeout waiting for element visibility: ${element.locator()}`
|
||||
);
|
||||
export async function waitForVisibility(element: ElementFinder, errorMessage?: string): Promise<void> {
|
||||
await browser.wait(EC.visibilityOf(element), BROWSER_WAIT_TIMEOUT, errorMessage || `Timeout waiting for element visibility: ${element.locator()}`);
|
||||
}
|
||||
|
||||
export async function waitForInvisibility(
|
||||
element: ElementFinder,
|
||||
errorMessage?: string
|
||||
): Promise<void> {
|
||||
export async function waitForInvisibility(element: ElementFinder, errorMessage?: string): Promise<void> {
|
||||
await browser.wait(
|
||||
EC.invisibilityOf(element),
|
||||
BROWSER_WAIT_TIMEOUT,
|
||||
errorMessage ||
|
||||
`Timeout waiting for element visibility: ${element.locator()}`
|
||||
errorMessage || `Timeout waiting for element visibility: ${element.locator()}`
|
||||
);
|
||||
}
|
||||
|
||||
export async function waitForPresence(
|
||||
element: ElementFinder,
|
||||
errorMessage?: string
|
||||
): Promise<void> {
|
||||
await browser.wait(
|
||||
EC.presenceOf(element),
|
||||
BROWSER_WAIT_TIMEOUT,
|
||||
errorMessage || `Timeout waiting for element presence: ${element.locator()}`
|
||||
);
|
||||
export async function waitForPresence(element: ElementFinder, errorMessage?: string): Promise<void> {
|
||||
await browser.wait(EC.presenceOf(element), BROWSER_WAIT_TIMEOUT, errorMessage || `Timeout waiting for element presence: ${element.locator()}`);
|
||||
}
|
||||
|
||||
export async function waitForStaleness(
|
||||
element: ElementFinder,
|
||||
errorMessage?: string
|
||||
): Promise<void> {
|
||||
await browser.wait(
|
||||
EC.stalenessOf(element),
|
||||
BROWSER_WAIT_TIMEOUT,
|
||||
errorMessage || `Timeout waiting element staleness: ${element.locator()}`
|
||||
);
|
||||
export async function waitForStaleness(element: ElementFinder, errorMessage?: string): Promise<void> {
|
||||
await browser.wait(EC.stalenessOf(element), BROWSER_WAIT_TIMEOUT, errorMessage || `Timeout waiting element staleness: ${element.locator()}`);
|
||||
}
|
||||
|
||||
export const isPresentAndEnabled = async (
|
||||
element: ElementFinder
|
||||
): Promise<boolean> => {
|
||||
export const isPresentAndEnabled = async (element: ElementFinder): Promise<boolean> => {
|
||||
const isPresent = await element.isPresent();
|
||||
|
||||
if (isPresent) {
|
||||
@@ -142,9 +83,7 @@ export const isPresentAndEnabled = async (
|
||||
return false;
|
||||
};
|
||||
|
||||
export const isPresentAndDisplayed = async (
|
||||
element: ElementFinder
|
||||
): Promise<boolean> => {
|
||||
export const isPresentAndDisplayed = async (element: ElementFinder): Promise<boolean> => {
|
||||
const isPresent = await element.isPresent();
|
||||
|
||||
if (isPresent) {
|
||||
@@ -166,42 +105,25 @@ export class Utils {
|
||||
lighter track cinema tread tick climate lend summit singer radical flower visual negotiation promises cooperative live';
|
||||
|
||||
static random(): string {
|
||||
return Math.random()
|
||||
.toString(36)
|
||||
.substring(5, 10)
|
||||
.toLowerCase();
|
||||
return Math.random().toString(36).substring(5, 10).toLowerCase();
|
||||
}
|
||||
|
||||
static async clearLocalStorage(): Promise<void> {
|
||||
await browser.executeScript('window.localStorage.clear();');
|
||||
}
|
||||
|
||||
static async setSessionStorageFromConfig(
|
||||
configFileName: string
|
||||
): Promise<void> {
|
||||
static async setSessionStorageFromConfig(configFileName: string): Promise<void> {
|
||||
const configFile = `${browser.params.e2eRootPath}/resources/extensibility-configs/${configFileName}`;
|
||||
const fileContent = JSON.stringify(
|
||||
fs.readFileSync(configFile, { encoding: 'utf8' })
|
||||
);
|
||||
const fileContent = JSON.stringify(fs.readFileSync(configFile, { encoding: 'utf8' }));
|
||||
|
||||
await browser.executeScript(
|
||||
`window.sessionStorage.setItem('app.extension.config', ${fileContent});`
|
||||
);
|
||||
await browser.executeScript(`window.sessionStorage.setItem('app.extension.config', ${fileContent});`);
|
||||
}
|
||||
|
||||
static retryCall(
|
||||
fn: () => Promise<any>,
|
||||
retry: number = 30,
|
||||
delay: number = 1000
|
||||
): Promise<any> {
|
||||
const pause = duration => new Promise(res => setTimeout(res, duration));
|
||||
static retryCall(fn: () => Promise<any>, retry: number = 30, delay: number = 1000): Promise<any> {
|
||||
const pause = (duration: number) => new Promise((res) => setTimeout(res, duration));
|
||||
|
||||
const run = retries => {
|
||||
return fn().catch(err =>
|
||||
retries > 1
|
||||
? pause(delay).then(() => run(retries - 1))
|
||||
: Promise.reject(err)
|
||||
);
|
||||
const run = (retries: number): Promise<any> => {
|
||||
return fn().catch((err) => (retries > 1 ? pause(delay).then(() => run(retries - 1)) : Promise.reject(err)));
|
||||
};
|
||||
|
||||
return run(retry);
|
||||
@@ -214,24 +136,15 @@ export class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
static async fileExistsOnOS(
|
||||
fileName: string,
|
||||
folderName: string = '',
|
||||
subFolderName: string = ''
|
||||
): Promise<any> {
|
||||
static async fileExistsOnOS(fileName: string, folderName: string = '', subFolderName: string = ''): Promise<any> {
|
||||
const config = await browser.getProcessedConfig();
|
||||
const filePath = path.join(
|
||||
config.params.downloadFolder,
|
||||
folderName,
|
||||
subFolderName,
|
||||
fileName
|
||||
);
|
||||
const filePath = path.join(config.params.downloadFolder, folderName, subFolderName, fileName);
|
||||
|
||||
let tries = 15;
|
||||
|
||||
return new Promise(function(resolve) {
|
||||
return new Promise(function (resolve) {
|
||||
const checkExist = setInterval(() => {
|
||||
fs.access(filePath, function(error) {
|
||||
fs.access(filePath, function (error: any) {
|
||||
tries--;
|
||||
|
||||
if (error && tries === 0) {
|
||||
@@ -256,7 +169,7 @@ export class Utils {
|
||||
const fileExists = await this.fileExistsOnOS(oldName);
|
||||
|
||||
if (fileExists) {
|
||||
fs.rename(oldFilePath, newFilePath, function(err) {
|
||||
fs.rename(oldFilePath, newFilePath, function (err: any) {
|
||||
if (err) {
|
||||
Logger.error('==== rename err: ', err);
|
||||
}
|
||||
@@ -264,23 +177,17 @@ export class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
static async unzip(
|
||||
filename: string,
|
||||
unzippedName: string = ''
|
||||
): Promise<void> {
|
||||
static async unzip(filename: string, unzippedName: string = ''): Promise<void> {
|
||||
const config = await browser.getProcessedConfig();
|
||||
const filePath = path.join(config.params.downloadFolder, filename);
|
||||
const output = path.join(
|
||||
config.params.downloadFolder,
|
||||
unzippedName ? unzippedName : ''
|
||||
);
|
||||
const output = path.join(config.params.downloadFolder, unzippedName ? unzippedName : '');
|
||||
|
||||
const zip = new StreamZip({
|
||||
file: filePath,
|
||||
storeEntries: true
|
||||
});
|
||||
|
||||
await zip.on('error', err => {
|
||||
await zip.on('error', (err: any) => {
|
||||
Logger.error('=== unzip err: ', err);
|
||||
});
|
||||
|
||||
@@ -295,38 +202,23 @@ export class Utils {
|
||||
}
|
||||
|
||||
static async pressEscape(): Promise<void> {
|
||||
await browser
|
||||
.actions()
|
||||
.sendKeys(protractor.Key.ESCAPE)
|
||||
.perform();
|
||||
await browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
|
||||
}
|
||||
|
||||
static async pressTab(): Promise<void> {
|
||||
await browser
|
||||
.actions()
|
||||
.sendKeys(protractor.Key.TAB)
|
||||
.perform();
|
||||
await browser.actions().sendKeys(protractor.Key.TAB).perform();
|
||||
}
|
||||
|
||||
static async pressCmd(): Promise<void> {
|
||||
await browser
|
||||
.actions()
|
||||
.sendKeys(protractor.Key.COMMAND)
|
||||
.perform();
|
||||
await browser.actions().sendKeys(protractor.Key.COMMAND).perform();
|
||||
}
|
||||
|
||||
static async releaseKeyPressed(): Promise<void> {
|
||||
await browser
|
||||
.actions()
|
||||
.sendKeys(protractor.Key.NULL)
|
||||
.perform();
|
||||
await browser.actions().sendKeys(protractor.Key.NULL).perform();
|
||||
}
|
||||
|
||||
static async getBrowserLog(): Promise<logging.Entry[]> {
|
||||
return browser
|
||||
.manage()
|
||||
.logs()
|
||||
.get('browser');
|
||||
return browser.manage().logs().get('browser');
|
||||
}
|
||||
|
||||
static formatDate(date: string): string {
|
||||
@@ -335,8 +227,6 @@ export class Utils {
|
||||
|
||||
static async uploadFileNewVersion(fileFromOS: string): Promise<void> {
|
||||
const el = browser.element(by.id('app-upload-file-version'));
|
||||
await el.sendKeys(
|
||||
`${browser.params.e2eRootPath}/resources/test-files/${fileFromOS}`
|
||||
);
|
||||
await el.sendKeys(`${browser.params.e2eRootPath}/resources/test-files/${fileFromOS}`);
|
||||
}
|
||||
}
|
||||
|
@@ -12,10 +12,7 @@
|
||||
"experimentalDecorators": true,
|
||||
"importHelpers": true,
|
||||
"types": [],
|
||||
"lib": [
|
||||
"dom",
|
||||
"es2018"
|
||||
]
|
||||
"lib": ["dom", "es2018"]
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"skipTemplateCodegen": true,
|
||||
@@ -24,8 +21,5 @@
|
||||
"strictInjectionParameters": true,
|
||||
"enableResourceInlining": true
|
||||
},
|
||||
"exclude": [
|
||||
"src/test.ts",
|
||||
"**/*.spec.ts"
|
||||
]
|
||||
"exclude": ["node_modules", "src/test.ts", "**/*.spec.ts"]
|
||||
}
|
||||
|
Reference in New Issue
Block a user