[ACS-8153] delete protractor e2e configuration and files (#3885)

* [ACS-8153] delete protractor e2e configuration and files

* [ACS-8153] util fix

* [ACS-8153] pr fix

* [ACS-81532] remove e2e package.json

* [ACS-81532] remove chrome configuration

* package-lock file
This commit is contained in:
Akash Rathod
2024-07-26 13:07:32 +02:00
committed by GitHub
parent dfd23265d1
commit 4e67a8d9b0
99 changed files with 131 additions and 7151 deletions

View File

@@ -26,7 +26,7 @@ import * as fs from 'fs';
import { ApiClientFactory } from './api-client-factory';
import { Utils } from '../utils';
import { NodeBodyCreate, NodeEntry, ResultSetPaging } from '@alfresco/js-api';
import { waitForApi } from '@alfresco/aca-testing-shared';
import { waitForApi } from '@alfresco/playwright-shared';
export class FileActionsApi {
private apiService: ApiClientFactory;

View File

@@ -23,7 +23,7 @@
*/
import { Page } from '@playwright/test';
import { GenericLogger, LoggerLike } from '@alfresco/aca-testing-shared';
import { GenericLogger, LoggerLike } from '@alfresco/playwright-shared';
export abstract class PlaywrightBase {
public page: Page;

View File

@@ -31,16 +31,16 @@ export async function waitForApi<T>(apiCall: ApiCall<T>, predicate: ApiResultPre
if (predicate(apiCallResult)) {
return Promise.resolve(apiCallResult);
} else {
return Promise.reject(apiCallResult);
return Promise.reject(new Error(`API call did not satisfy predicate: ${JSON.stringify(apiCallResult)}`));
}
};
return retryCall(apiCallWithPredicateChecking, retry, delay);
}
function retryCall(fn: () => Promise<any>, retry: number = 30, delay: number = 1000): Promise<any> {
function retryCall(fn: () => Promise<any>, retry: number = 30, delay: number = 1000): Promise<string> {
const pause = (duration) => new Promise((res) => setTimeout(res, duration));
const run = (retries) => fn().catch((err) => (retries > 1 ? pause(delay).then(() => run(retries - 1)) : Promise.reject(err)));
const run = (retries) => fn().catch((err) => (retries > 1 ? pause(delay).then(() => run(retries - 1)) : Promise.reject(new Error(`API call did not satisfy predicate: ${JSON.stringify(err)}`))));
return run(retry);
}

View File

@@ -30,3 +30,5 @@ export * from './utils';
export * from './library-errors';
export * from './config';
export * from './error-strings';
export * from './api';
export * from './logger';

View File

@@ -32,12 +32,12 @@ export const errorColor = '\x1b[31m%s\x1b[0m';
export type LOG_LEVEL = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'SILENT';
export class LogLevelsEnum extends Number {
static TRACE: number = 5;
static DEBUG: number = 4;
static INFO: number = 3;
static WARN: number = 2;
static ERROR: number = 1;
static SILENT: number = 0;
public static readonly TRACE: number = 5;
public static readonly DEBUG: number = 4;
public static readonly INFO: number = 3;
public static readonly WARN: number = 2;
public static readonly ERROR: number = 1;
public static readonly SILENT: number = 0;
}
export const logLevels: { level: LogLevelsEnum; name: LOG_LEVEL }[] = [
@@ -65,19 +65,19 @@ export class GenericLogger implements LoggerLike {
}
info(...messages: string[]): void {
if (this.level >= LogLevelsEnum.INFO) {
if (Number(this.level) >= LogLevelsEnum.INFO) {
console.log(infoColor, messages.join(''));
}
}
log(...messages: string[]): void {
if (this.level >= LogLevelsEnum.TRACE) {
if (Number(this.level) >= LogLevelsEnum.TRACE) {
console.log(logColor, messages.join(''));
}
}
warn(...messages: string[]): void {
if (this.level >= LogLevelsEnum.WARN) {
if (Number(this.level) >= LogLevelsEnum.WARN) {
console.log(warnColor, messages.join(''));
}
}

View File

@@ -1,13 +0,0 @@
{
"name": "aca-testing-shared",
"version": "3.0.0",
"license": "LGPL-3.0",
"main": "src/index.ts",
"dependencies": {
"tslib": "^2.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/Alfresco/alfresco-content-app.git"
}
}

View File

@@ -1,7 +0,0 @@
{
"name": "aca-testing-shared",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "projects/aca-testing-shared/src",
"projectType": "library",
"prefix": "lib"
}

View File

@@ -1,40 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component } from '../component';
export class Breadcrumb extends Component {
items = this.allByCss('.adf-breadcrumb-item');
constructor(ancestor?: string) {
super('adf-breadcrumb', ancestor);
}
async getAllItems(): Promise<string[]> {
return this.items.map(async (elem) => {
const str = await elem.getText();
return str.split('\nchevron_right')[0];
});
}
}

View File

@@ -1,60 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, browser, by, ElementArrayFinder, ProtractorBrowser } from 'protractor';
import { waitForPresence } from '../utilities';
export abstract class Component {
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 {
return root.element(by.cssContainingText(css, text));
}
protected byId(css: string, root: ElementFinder | ProtractorBrowser = this.component): ElementFinder {
return root.element(by.id(css));
}
protected byTitleAttr(title: string, root: ElementFinder | ProtractorBrowser = this.component): ElementFinder {
return root.element(by.css(`[title=${title}]`));
}
protected allByCss(css: string, root: ElementFinder | ProtractorBrowser = this.component): ElementArrayFinder {
return root.all(by.css(css));
}
protected constructor(selector: string, ancestor?: string) {
const locator = selector;
this.component = ancestor ? browser.$$(ancestor).first().$$(locator).first() : browser.$$(locator).first();
}
async wait() {
await waitForPresence(this.component);
}
}

View File

@@ -1,35 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export * from './login/login';
export * from './header/header';
export * from './pageLayoutHeader/pageLayoutHeader';
export * from './data-table/data-table';
export * from './dialog/confirm-dialog';
export * from './dialog/create-edit-folder-dialog';
export * from './pagination/pagination';
export * from './sidenav/sidenav';
export * from './toolbar/toolbar';
export * from './breadcrumb/breadcrumb';
export * from './viewer/viewer';

View File

@@ -1,251 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser, by, ElementArrayFinder, ElementFinder } from 'protractor';
import { Component } from '../component';
import { Menu } from '../menu/menu';
import { Utils, waitForPresence, waitUntilElementIsClickable } from '../../utilities';
export class DataTable extends Component {
private static selectors = {
columnHeader: '.adf-datatable-row .adf-datatable-cell-header .adf-datatable-cell-value',
sortedColumnHeader: `
.adf-datatable__header--sorted-asc .adf-datatable-cell-header-content .adf-datatable-cell-value,
.adf-datatable__header--sorted-desc .adf-datatable-cell-header-content .adf-datatable-cell-value
`,
row: '.adf-datatable-row[data-automation-id^="datatable-row"]',
cell: '.adf-datatable-cell-container',
lockOwner: '.aca-locked-by',
searchResultsRow: 'aca-search-results-row',
searchResultsRowLine: 'span'
};
head = this.byCss('.adf-datatable-header');
body = this.byCss('.adf-datatable-body');
emptyList = this.byCss('div.adf-no-content-container');
emptyListTitle = this.byCss('.adf-empty-content__title');
emptyListSubtitle = this.byCss('.adf-empty-content__subtitle');
emptySearchText = this.byCss('.empty-search__text');
selectedRow = this.byCss('.adf-datatable-row.adf-is-selected');
menu = new Menu();
constructor(ancestor?: string) {
super('adf-datatable', ancestor);
}
async waitForHeader(): Promise<void> {
return waitForPresence(this.head, '--- timeout waitForHeader ---');
}
async waitForBody(): Promise<void> {
return waitForPresence(this.body, '--- timeout waitForBody ---');
}
private getColumnHeaders(): ElementArrayFinder {
const locator = by.css(DataTable.selectors.columnHeader);
return this.head.all(locator);
}
async getColumnHeadersText(): Promise<string> {
return this.getColumnHeaders().getText();
}
private getRows(): ElementArrayFinder {
return this.body.all(by.css(DataTable.selectors.row));
}
async getRowsCount(): Promise<number> {
return this.getRows().count();
}
private getSelectedRows(): ElementArrayFinder {
return this.body.all(by.css('.adf-datatable-row.adf-is-selected'));
}
async getSelectedRowsCount(): Promise<number> {
return this.getSelectedRows().count();
}
getRowByName(name: string, location: string = ''): ElementFinder {
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))))
.first();
}
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));
}
private getRowFirstCell(name: string, location: string = ''): ElementFinder {
return this.getRowCells(name, location).get(0);
}
async hasCheckMarkIcon(itemName: string, location: string = ''): Promise<boolean> {
const row = this.getRowByName(itemName, location);
return row.element(by.css('.mat-icon[class*="selected"]')).isPresent();
}
async hasLockIcon(itemName: string, location: string = ''): Promise<boolean> {
const row = this.getRowByName(itemName, location);
return row.element(by.css('img[src*="lock"]')).isPresent();
}
private async hasLockOwnerInfo(itemName: string, location: string = ''): Promise<boolean> {
const row = this.getRowByName(itemName, location);
return row.element(by.css(DataTable.selectors.lockOwner)).isPresent();
}
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).$('.aca-locked-by--name').getText();
}
return '';
}
async doubleClickOnRowByName(name: string, location: string = ''): Promise<void> {
try {
const item = this.getRowFirstCell(name, location);
await waitUntilElementIsClickable(item);
await browser.actions().mouseMove(item).perform();
await browser.actions().doubleClick().perform();
} catch (error) {
console.error(`--- doubleClickOnRowByName catch : failed to double click on ${name} from location : ${location} : `, error);
}
}
async selectItem(name: string, location: string = ''): Promise<void> {
const isSelected = await this.hasCheckMarkIcon(name, location);
if (!isSelected) {
try {
const item = this.getRowFirstCell(name, location);
await item.click();
} catch (e) {
console.error(`--- select item catch : failed to select ${name} from location : ${location} : `, e);
}
}
}
async unselectItem(name: string, location: string = ''): Promise<void> {
const isSelected = await this.hasCheckMarkIcon(name, location);
if (isSelected) {
try {
const item = this.getRowFirstCell(name, location);
await item.click();
} catch (e) {
console.error(`--- unselect item catch : failed to unselect ${name} from location : ${location} : `, e);
}
}
}
async selectMultipleItems(names: string[], location: string = ''): Promise<void> {
await this.clearSelection();
await Utils.pressCmd();
for (const name of names) {
await this.selectItem(name, location);
}
await Utils.releaseKeyPressed();
}
async clearSelection(): Promise<void> {
try {
const count = await this.getSelectedRowsCount();
if (count > 0) {
await browser.refresh();
await this.wait();
}
} catch (error) {
console.error('------ clearSelection catch : ', error);
}
}
private getItemLocationEl(name: string): ElementFinder {
return this.getRowByName(name).element(by.css('.aca-location-link'));
}
async clickItemLocation(name: string): Promise<void> {
await this.getItemLocationEl(name).click();
}
async isEmpty(): Promise<boolean> {
return this.emptyList.isPresent();
}
async getEmptyStateTitle(): Promise<string> {
const isEmpty = await this.isEmpty();
if (isEmpty) {
return this.emptyListTitle.getText();
}
return '';
}
async getEmptyStateSubtitle(): Promise<string> {
const isEmpty = await this.isEmpty();
if (isEmpty) {
return this.emptyListSubtitle.getText();
}
return '';
}
async isItemPresent(name: string, location?: string): Promise<boolean> {
return this.getRowByName(name, location).isPresent();
}
private async getEntireDataTableText(): Promise<string[]> {
return this.getRows().map((row) => {
return row.all(by.css(DataTable.selectors.cell)).map(async (cell) => {
return cell.getText();
});
});
}
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<any> {
const data: string[] = await this.getEntireDataTableText();
return data.reduce((acc: any, cell) => {
acc[cell[1]] = cell[3];
return acc;
}, {});
}
private getSearchResultsRows(): ElementArrayFinder {
return this.body.all(by.css(DataTable.selectors.searchResultsRow));
}
getNthSearchResultsRow(nth: number): ElementFinder {
return this.getSearchResultsRows().get(nth - 1);
}
}

View File

@@ -1,49 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by } from 'protractor';
import { GenericDialog } from './generic-dialog';
import { isPresentAndEnabled } from '../../utilities';
export class ConfirmDialog extends GenericDialog {
cancelButton = this.childElement(by.buttonText('Cancel'));
keepButton = this.childElement(by.buttonText('Keep'));
deleteButton = this.childElement(by.buttonText('Delete'));
constructor() {
super('adf-confirm-dialog');
}
async getText(): Promise<string> {
return this.content.getText();
}
async isKeepEnabled(): Promise<boolean> {
return isPresentAndEnabled(this.keepButton);
}
async isDeleteEnabled(): Promise<boolean> {
return isPresentAndEnabled(this.deleteButton);
}
}

View File

@@ -1,70 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by, browser } from 'protractor';
import { GenericDialog } from './generic-dialog';
import { waitForStaleness, waitForPresence, click } from '../../utilities';
import { DataTable } from '../data-table/data-table';
export class ContentNodeSelectorDialog extends GenericDialog {
copyButton = this.childElement(by.cssContainingText('[data-automation-id="content-node-selector-actions-choose"]', 'Copy'));
locationDropDown = this.rootElem.element(by.id('site-dropdown-container'));
locationPersonalFiles = browser.element(by.cssContainingText('.mat-mdc-option .mdc-list-item__primary-text', 'Personal Files'));
locationFileLibraries = browser.element(by.cssContainingText('.mat-mdc-option .mdc-list-item__primary-text', 'My Libraries'));
searchInput = this.rootElem.element(by.css('#searchInput'));
dataTable = new DataTable('.adf-content-node-selector-dialog');
constructor() {
super('.adf-content-node-selector-dialog');
}
get content() {
return this.rootElem.element(by.css('.adf-content-node-selector-content'));
}
async waitForDropDownToClose(): Promise<void> {
await waitForStaleness(browser.$('.mat-mdc-option .mdc-list-item__primary-text'));
}
async selectLocation(location: string): Promise<void> {
await click(this.locationDropDown);
if (location === 'Personal Files') {
await click(this.locationPersonalFiles);
} else {
await click(this.locationFileLibraries);
}
await this.waitForDropDownToClose();
}
async selectDestination(folderName: string): Promise<void> {
const row = this.dataTable.getRowByName(folderName);
await click(row);
await waitForPresence(browser.element(by.css('.adf-is-selected')));
}
}

View File

@@ -1,83 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by } from 'protractor';
import { GenericDialog } from './generic-dialog';
import { click, getInputValue, isPresentAndDisplayed, isPresentAndEnabled, typeText, waitUntilElementIsClickable } from '../../utilities';
export class CreateOrEditFolderDialog extends GenericDialog {
createButton = this.childElement(by.cssContainingText('.mat-mdc-dialog-actions button', 'Create'));
cancelButton = this.childElement(by.id('adf-folder-cancel-button'));
updateButton = this.childElement(by.cssContainingText('.mat-mdc-dialog-actions button', 'Update'));
nameInput = this.rootElem.element(by.id('adf-folder-name-input'));
descriptionTextArea = this.rootElem.element(by.id('adf-folder-description-input'));
validationMessage = this.rootElem.element(by.css('.mat-mdc-form-field-hint span'));
constructor() {
super('adf-folder-dialog');
}
async waitForDialogToOpen() {
await super.waitForDialogToOpen();
await waitUntilElementIsClickable(this.nameInput);
}
async isUpdateButtonEnabled(): Promise<boolean> {
return isPresentAndEnabled(this.updateButton);
}
async isCancelButtonEnabled(): Promise<boolean> {
return isPresentAndEnabled(this.cancelButton);
}
async getValidationMessage(): Promise<string> {
if (await isPresentAndDisplayed(this.validationMessage)) {
return this.validationMessage.getText();
} else {
return '';
}
}
async getName(): Promise<string> {
return getInputValue(this.nameInput);
}
async getDescription(): Promise<string> {
return getInputValue(this.descriptionTextArea);
}
async enterName(name: string): Promise<void> {
await typeText(this.nameInput, name);
}
async enterDescription(description: string): Promise<void> {
await typeText(this.descriptionTextArea, description);
}
async clickCancel(): Promise<void> {
await click(this.cancelButton);
await this.waitForDialogToClose();
}
}

View File

@@ -1,70 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, Locator } from 'protractor';
import { isPresentAndDisplayed, waitForPresence, waitForStaleness, waitUntilElementIsVisible } from '../../utilities';
export abstract class GenericDialog {
protected constructor(private rootCssSelector?: string) {}
get rootElem(): ElementFinder {
return browser.element(by.css(this.rootCssSelector));
}
get title(): ElementFinder {
return this.rootElem.element(by.css('.mat-mdc-dialog-title'));
}
get content(): ElementFinder {
return this.rootElem.element(by.css('.mat-mdc-dialog-content'));
}
async getText(): Promise<string> {
return this.content.getText();
}
async waitForDialogToOpen(): Promise<void> {
await waitForPresence(this.rootElem);
await waitUntilElementIsVisible(this.content);
await waitForPresence(browser.element(by.css('.cdk-overlay-backdrop')));
}
async waitForDialogToClose(): Promise<void> {
try {
await waitForStaleness(this.content);
} catch {}
}
async isDialogOpen(): Promise<boolean> {
return isPresentAndDisplayed(this.rootElem);
}
async getDialogTitle(): Promise<string> {
return this.title.getText();
}
protected childElement(selector: Locator): ElementFinder {
return this.rootElem.element(selector);
}
}

View File

@@ -1,32 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export * from './confirm-dialog';
export * from './content-node-selector-dialog';
export * from './create-edit-folder-dialog';
export * from './generic-dialog';
export * from './manage-versions-dialog';
export * from './share-dialog';
export * from './upload-new-version-dialog';
export * from './upload-files-dialog';

View File

@@ -1,46 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by } from 'protractor';
import { GenericDialog } from './generic-dialog';
import { Menu } from '../menu/menu';
import { click } from '../../utilities';
export class ManageVersionsDialog extends GenericDialog {
menu = new Menu();
constructor() {
super('.adf-new-version-uploader-dialog');
}
async clickActionButton(version: string): Promise<void> {
await click(this.childElement(by.id(`adf-version-list-action-menu-button-${version}`)));
await this.menu.waitForMenuToOpen();
}
async viewFileVersion(version: string): Promise<void> {
await this.clickActionButton(version);
await this.menu.clickMenuItem('View');
}
}

View File

@@ -1,41 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by } from 'protractor';
import { GenericDialog } from './generic-dialog';
export class ShareDialog extends GenericDialog {
labels = this.rootElem.all(by.css('.adf-share-link__label'));
url = this.childElement(by.css(`[data-automation-id='adf-share-link']`));
closeButton = this.childElement(by.css(`[data-automation-id='adf-share-dialog-close']`));
constructor() {
super('.adf-share-dialog');
}
async clickClose(): Promise<void> {
await this.closeButton.click();
await this.waitForDialogToClose();
}
}

View File

@@ -1,39 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { TestElement } from '../../utilities';
export class UploadFilesDialog {
uploadDialog = TestElement.byCss('.adf-upload-dialog');
closeUploadButton = TestElement.byCss('.adf-upload-dialog [id="adf-upload-dialog-close"]');
minimizeButton = TestElement.byCss('.adf-upload-dialog mat-icon[title="Minimize"]');
maximizeButton = TestElement.byCss('.adf-upload-dialog mat-icon[title="Maximize"]');
uploadedFiles = TestElement.byCss('.adf-file-uploading-row__name');
async closeUploadDialog(): Promise<void> {
if (await this.uploadDialog.isVisible()) {
await this.closeUploadButton.click();
}
}
}

View File

@@ -1,56 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by } from 'protractor';
import { GenericDialog } from './generic-dialog';
import { isPresentAndEnabled, typeText } from '../../utilities';
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'));
description = this.childElement(by.css('textarea'));
constructor() {
super('.adf-new-version-uploader-dialog');
}
async isCancelButtonEnabled(): Promise<boolean> {
return isPresentAndEnabled(this.cancelButton);
}
async isUploadButtonEnabled(): Promise<boolean> {
return isPresentAndEnabled(this.uploadButton);
}
async clickCancel(): Promise<void> {
await this.cancelButton.click();
await this.waitForDialogToClose();
}
async enterDescription(description: string): Promise<void> {
await typeText(this.description, description);
}
}

View File

@@ -1,60 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by, browser } from 'protractor';
import { Component } from '../component';
import { Menu } from '../menu/menu';
import { Toolbar } from '../toolbar/toolbar';
import { SearchInput } from '../search';
import { click, waitElement } from '../../utilities';
export class Header extends Component {
userMenuButton = this.byCss(`.aca-user-menu-button`);
sidenavToggle = this.byCss(`.aca-sidenav-header-title-logo`);
menu = new Menu();
toolbar = new Toolbar();
searchInput = new SearchInput();
constructor(ancestor?: string) {
super('app-sidenav-header', ancestor);
}
async openMoreMenu(): Promise<void> {
await click(this.userMenuButton);
await this.menu.waitForMenuToOpen();
}
async isSidenavExpanded(): Promise<boolean> {
return browser.isElementPresent(by.css(`[data-automation-id='expanded']`));
}
async expandSideNav(): Promise<void> {
const expanded = await this.isSidenavExpanded();
if (!expanded) {
await click(this.sidenavToggle);
await waitElement(`[data-automation-id='expanded']`);
}
}
}

View File

@@ -1,38 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export * from './breadcrumb/breadcrumb';
export * from './data-table/data-table';
export * from './dialog';
export * from './header/header';
export * from './info-drawer';
export * from './login/login';
export * from './menu/menu';
export * from './pagination/pagination';
export * from './search';
export * from './sidenav/sidenav';
export * from './toolbar/toolbar';
export * from './viewer/viewer';
export * from './component';
export * from './components';

View File

@@ -1,27 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export * from './info-drawer-comments-tab';
export * from './info-drawer-metadata-library';
export * from './info-drawer';

View File

@@ -1,115 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by, browser, until } from 'protractor';
import { Component } from '../component';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { click, typeText, waitUntilElementIsVisible } from '../../utilities';
export class CommentsTab extends Component {
commentsContainer = this.byCss('.adf-comments-container');
commentsHeader = this.byCss('.adf-comments-header');
commentTextarea = this.byCss('.adf-comments-input-container textarea');
addCommentButton = this.byCss('button.adf-comments-input-add');
commentListItem = by.css('.adf-comment-list-item');
commentUserAvatar = by.css('.adf-comment-img-container');
commentUser = by.css('.adf-comment-user-name');
commentText = by.css('.adf-comment-message');
commentTime = by.css('.adf-comment-message-time');
constructor(ancestor?: string) {
super('adf-comments', ancestor);
}
async waitForCommentsContainer() {
await waitUntilElementIsVisible(this.commentsContainer);
}
async getCommentsTabHeaderText(): Promise<string> {
return this.commentsHeader.getText();
}
async isCommentTextAreaDisplayed(): Promise<boolean> {
return browser.isElementPresent(this.commentTextarea);
}
async isAddCommentButtonEnabled(): Promise<boolean> {
const present = await browser.isElementPresent(this.addCommentButton);
if (present) {
return this.addCommentButton.isEnabled();
}
return false;
}
private async getCommentListItem() {
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 this.getCommentListItem();
}
async isCommentDisplayed(commentId?: string) {
return browser.isElementPresent(await this.getCommentById(commentId));
}
async isCommentUserAvatarDisplayed(commentId?: string) {
const commentElement = await this.getCommentById(commentId);
return browser.isElementPresent(commentElement.findElement(this.commentUserAvatar));
}
async getCommentText(commentId?: string) {
const commentElement = await this.getCommentById(commentId);
const message = await commentElement.findElement(this.commentText);
return message.getText();
}
async getCommentUserName(commentId?: string): Promise<string> {
const commentElement = await this.getCommentById(commentId);
const user = await commentElement.findElement(this.commentUser);
return user.getText();
}
async getCommentTime(commentId?: string): Promise<string> {
const commentElement = await this.getCommentById(commentId);
const time = await commentElement.findElement(this.commentTime);
return time.getText();
}
async getNthCommentText(index: number): Promise<string> {
const list = this.allByCss('mat-list-item .adf-comment-message');
return list.get(index - 1).getText();
}
async typeComment(text: string): Promise<void> {
await typeText(this.commentTextarea, text);
}
async clickAddButton(): Promise<void> {
await click(this.addCommentButton);
}
}

View File

@@ -1,217 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by, browser } from 'protractor';
import { Component } from '../component';
import { waitForPresence, waitForStaleness, typeText, click } from '../../utilities';
export class LibraryMetadata extends Component {
visibilityDropDown = this.component.element(by.css('.mat-mdc-select'));
visibilityPublic = this.byCssText('.mat-mdc-option .mdc-list-item__primary-text', 'Public', browser);
visibilityPrivate = this.byCssText('.mat-mdc-option .mdc-list-item__primary-text', 'Private', browser);
visibilityModerated = this.byCssText('.mat-mdc-option .mdc-list-item__primary-text', 'Moderated', browser);
visibilityValue = this.byCss('[data-automation-id="library-visibility-properties-wrapper"] .mat-mdc-select');
hint = this.byCss('.mat-mdc-form-field-hint');
error = this.byCss('.mat-mdc-form-field-error');
constructor(ancestor?: string) {
super('app-library-metadata-form', ancestor);
}
private getLabelWrapper(label: string) {
return this.byCssText('.mat-mdc-floating-label', label);
}
private getFieldByName(fieldName: string) {
const wrapper = this.getLabelWrapper(fieldName);
return wrapper.element(by.xpath('..')).element(by.css('.mat-mdc-input-element'));
}
private async isFieldDisplayed(fieldName: string) {
return browser.isElementPresent(this.getFieldByName(fieldName));
}
private async isInputEnabled(fieldName: string) {
return this.getFieldByName(fieldName).isEnabled();
}
private async getValueOfField(fieldName: string) {
return this.getFieldByName(fieldName).getAttribute('value');
}
private async enterTextInInput(fieldName: string, text: string) {
const input = this.getFieldByName(fieldName);
await typeText(input, text);
}
private getButton(button: string) {
return this.byCssText('.mat-mdc-card-actions .mat-mdc-button', button);
}
private async isButtonDisplayed(button: string) {
return browser.isElementPresent(this.getButton(button));
}
private async isButtonEnabled(button: string) {
return this.getButton(button).isEnabled();
}
private async clickButton(button: string) {
await click(this.getButton(button));
}
async waitForVisibilityDropDownToClose() {
await waitForStaleness(browser.$('.mat-mdc-option .mdc-list-item__primary-text'));
}
async isMessageDisplayed() {
return browser.isElementPresent(this.hint);
}
async getMessage() {
return this.hint.getText();
}
async isErrorDisplayed() {
return browser.isElementPresent(this.error);
}
async getError() {
return this.error.getText();
}
async isNameDisplayed() {
return this.isFieldDisplayed('Name');
}
async isNameEnabled() {
return this.isInputEnabled('Name');
}
async getName(): Promise<string> {
return this.getValueOfField('Name');
}
async enterName(name: string): Promise<void> {
await this.enterTextInInput('Name', name);
}
async isDescriptionDisplayed() {
return this.isFieldDisplayed('Description');
}
async isDescriptionEnabled() {
return this.isInputEnabled('Description');
}
async getDescription(): Promise<string> {
return this.getValueOfField('Description');
}
async enterDescription(desc: string) {
await this.enterTextInInput('Description', desc);
}
async isVisibilityEnabled() {
const wrapper = this.getLabelWrapper('Visibility');
const field = wrapper.element(by.xpath('..')).element(by.css('.mat-mdc-select'));
return field.isEnabled();
}
async isVisibilityDisplayed() {
return browser.isElementPresent(this.visibilityValue);
}
async getVisibility(): Promise<string> {
return this.visibilityValue.getText();
}
async setVisibility(visibility: string) {
const val = visibility.toLowerCase();
await click(this.visibilityDropDown);
await waitForPresence(this.visibilityDropDown);
if (val === 'public') {
await click(this.visibilityPublic);
} else if (val === 'private') {
await click(this.visibilityPrivate);
} else if (val === 'moderated') {
await click(this.visibilityModerated);
} else {
console.error('----- invalid visibility', val);
}
await this.waitForVisibilityDropDownToClose();
}
async isLibraryIdDisplayed() {
return this.isFieldDisplayed('Library ID');
}
async isLibraryIdEnabled() {
return this.isInputEnabled('Library ID');
}
async getLibraryId() {
return this.getValueOfField('Library ID');
}
async isEditLibraryPropertiesEnabled() {
return this.isButtonEnabled('Edit');
}
async isEditLibraryPropertiesDisplayed() {
return this.isButtonDisplayed('Edit');
}
async clickEditLibraryProperties() {
await this.clickButton('Edit');
}
async isUpdateEnabled() {
return this.isButtonEnabled('Update');
}
async isUpdateDisplayed() {
return this.isButtonDisplayed('Update');
}
async clickUpdate() {
await this.clickButton('Update');
}
async isCancelEnabled() {
return this.isButtonEnabled('Cancel');
}
async isCancelDisplayed() {
return this.isButtonDisplayed('Cancel');
}
async clickCancel() {
await this.clickButton('Cancel');
}
}

View File

@@ -1,97 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { Component } from '../component';
import { CommentsTab } from './info-drawer-comments-tab';
import { LibraryMetadata } from './info-drawer-metadata-library';
import { click, TestElement, waitForPresence, waitUntilElementIsVisible } from '../../utilities';
import { Toolbar } from '../toolbar/toolbar';
export class InfoDrawer extends Component {
commentsTab = new CommentsTab('adf-info-drawer');
aboutTab = new LibraryMetadata('adf-info-drawer');
header = this.byCss('.adf-info-drawer-layout-header');
headerTitle = this.byCss('.adf-info-drawer-layout-header-title > div');
tabActiveLabel = this.byCss('.mat-tab-label-active');
expandDetailsButton = TestElement.byCss(`button[title='Expand panel']`);
selectedTab = TestElement.byCss(`.mat-tab-list [aria-selected='true'] div`);
expandedDetailsPermissionsTab = TestElement.byText('.aca-details-container .mat-tab-label-content', 'Permissions');
previewButton = TestElement.byCss(`button[title='Preview File']`);
toolbar = new Toolbar('adf-info-drawer');
constructor(ancestor?: string) {
super('adf-info-drawer', ancestor);
}
async waitForInfoDrawerToOpen() {
await waitForPresence(this.header);
}
async isOpen() {
return browser.isElementPresent(this.header);
}
getTabByTitle(title: string) {
return this.byCssText('.mat-tab-label-content', title);
}
async getTabsCount(): Promise<number> {
return this.allByCss('.mat-tab-label-content').count();
}
async isTabDisplayed(title: string): Promise<boolean> {
if (await browser.isElementPresent(this.getTabByTitle(title))) {
return this.getTabByTitle(title).isDisplayed();
}
return false;
}
async getActiveTabTitle(): Promise<string> {
return this.tabActiveLabel.getText();
}
async getHeaderTitle(): Promise<string> {
return this.headerTitle.getText();
}
async isPropertiesTabDisplayed() {
return this.isTabDisplayed('Properties');
}
async isCommentsTabDisplayed() {
return this.isTabDisplayed('Comments');
}
async clickCommentsTab() {
try {
await click(this.getTabByTitle('Comments'));
await this.commentsTab.waitForCommentsContainer();
await waitUntilElementIsVisible(this.commentsTab.component);
} catch (error) {
console.error('--- info-drawer clickCommentsTab catch error: ', error);
}
}
}

View File

@@ -1,50 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component } from '../component';
import { typeText } from '../../utilities';
export class LoginComponent extends Component {
usernameInput = this.byCss('input#username');
passwordInput = this.byCss('input#password');
submitButton = this.byCss('button#login-button');
copyright = this.byCss('.adf-copyright');
constructor(ancestor?: string) {
super('adf-login', ancestor);
}
async enterUsername(username: string): Promise<void> {
await typeText(this.usernameInput, username);
}
async enterPassword(password: string): Promise<void> {
await typeText(this.passwordInput, password);
}
async enterCredentials(username: string, password: string): Promise<void> {
await this.enterUsername(username);
await this.enterPassword(password);
}
}

View File

@@ -1,66 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser } from 'protractor';
import { Component } from '../component';
import { click, waitForPresence, waitForStaleness, waitUntilElementIsVisible } from '../../utilities';
export class Menu extends Component {
items = this.allByCss('.mat-mdc-menu-item');
uploadFilesInput = this.byId('app-upload-files', browser);
cancelEditingAction = this.byCss(`.mat-mdc-menu-item[title='Cancel Editing']`);
copyAction = this.byTitleAttr('Copy');
editFolderAction = this.byCss(`.mat-mdc-menu-item[id$='editFolder']`);
editOfflineAction = this.byCss(`.mat-mdc-menu-item[title='Edit Offline']`);
constructor(ancestor?: string) {
super('.mat-mdc-menu-panel', ancestor);
}
async waitForMenuToOpen(): Promise<void> {
await waitForPresence(browser.element(by.css('.cdk-overlay-container .mat-mdc-menu-panel')));
await waitUntilElementIsVisible(this.items.get(0));
}
async waitForMenuToClose(): Promise<void> {
await waitForStaleness(browser.element(by.css('.cdk-overlay-container .mat-mdc-menu-panel')));
}
private getItemByLabel(menuItem: string): ElementFinder {
return this.byCssText('.mat-mdc-menu-item', menuItem);
}
async getItemIconText(menuItem: string): Promise<string> {
return this.getItemByLabel(menuItem).element(by.css('.mat-icon')).getText();
}
async clickMenuItem(menuItem: string): Promise<void> {
try {
const elem = this.getItemByLabel(menuItem);
await click(elem);
} catch (e) {
console.error(`___click menu item catch : failed to click on ${menuItem}___`, e);
}
}
}

View File

@@ -1,39 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component } from '../component';
import { Menu } from '../menu/menu';
import { Toolbar } from '../toolbar/toolbar';
import { SearchInput } from '../search/search-input';
export class PageLayoutHeader extends Component {
menu = new Menu();
toolbar = new Toolbar();
searchInput = new SearchInput();
constructor(ancestor?: string) {
super('aca-page-layout', ancestor);
}
}

View File

@@ -1,69 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Menu } from '../menu/menu';
import { Component } from '../component';
export class Pagination extends Component {
range = this.byCss('.adf-pagination__range');
maxItems = this.byCss('.adf-pagination__max-items');
currentPage = this.byCss('.adf-pagination__current-page');
totalPages = this.byCss('.adf-pagination__total-pages');
previousButton = this.byCss('.adf-pagination__previous-button');
nextButton = this.byCss('.adf-pagination__next-button');
menu: Menu = new Menu();
constructor(ancestor?: string) {
super('adf-pagination', ancestor);
}
async isRangePresent() {
return this.range.isPresent();
}
async isMaxItemsPresent() {
return this.maxItems.isPresent();
}
async isCurrentPagePresent() {
return this.currentPage.isPresent();
}
async isTotalPagesPresent() {
return this.totalPages.isPresent();
}
async isPreviousButtonPresent() {
return this.previousButton.isPresent();
}
async isNextButtonPresent() {
return this.nextButton.isPresent();
}
async getRange() {
return this.range.getText();
}
}

View File

@@ -1,58 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser, by, ElementArrayFinder, ElementFinder, protractor } from 'protractor';
import { GenericFilter } from './generic-filter';
export class AutocompleteChipsFilter extends GenericFilter {
private readonly locators = {
selectedOption: '.mat-mdc-chip span',
input: '.mat-mdc-menu-content input',
};
constructor(filterName: string) {
super(filterName);
}
selectedOptions: ElementArrayFinder = this.filterDialogOpened.all(by.css(this.locators.selectedOption));
get filterInput(): ElementFinder {
return this.filterDialogOpened.element(by.css(this.locators.input));
}
async getFiltersSelectedValues(): Promise<string[]> {
return this.selectedOptions.map((option) => {
return option.getText();
});
}
async isFilterAutocompleteInputDisplayed(): Promise<boolean> {
return this.filterInput.isDisplayed();
}
async setAutocompleteInputValue(value: string): Promise<void> {
await this.filterInput.sendKeys(value);
await browser.actions().sendKeys(protractor.Key.ENTER).perform();
}
}

View File

@@ -1,74 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, ElementArrayFinder, by, browser } from 'protractor';
import { GenericFilter } from './generic-filter';
export class FacetFilter extends GenericFilter {
private readonly locators = {
checkbox: '.mat-mdc-menu-content .mat-mdc-checkbox',
checkboxChecked: '.mat-mdc-menu-content .mat-mdc-checkbox.mat-mdc-checkbox-checked',
categoryInput: '.mat-mdc-menu-content input[data-automation-id^="facet-result-filter"]',
facetsFilter: '.mat-mdc-menu-content .adf-facet-result-filter'
};
get facets(): ElementArrayFinder {
return this.filterDialogOpened.all(by.css(this.locators.checkbox));
}
get selectedFacets(): ElementArrayFinder {
return this.filterDialogOpened.all(by.css(this.locators.checkboxChecked));
}
get facetsFilter(): ElementFinder {
return this.filterDialogOpened.element(by.css(this.locators.facetsFilter));
}
get filterCategoryInput(): ElementFinder {
return this.facetsFilter.element(by.css(this.locators.categoryInput));
}
async getFiltersValues(): Promise<string[]> {
return this.facets.map((option) => {
return option.getText();
});
}
async getFiltersCheckedValues(): Promise<string[]> {
return this.selectedFacets.map((option) => {
return option.getText();
});
}
async isFilterCategoryInputDisplayed(): Promise<boolean> {
return this.filterCategoryInput.isDisplayed();
}
async checkCategory(name: string): Promise<void> {
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();
}
async filterCategoriesBy(name: string): Promise<void> {
await this.filterCategoryInput.sendKeys(name);
}
}

View File

@@ -1,91 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, ElementArrayFinder, by, browser, protractor, element } from 'protractor';
import { GenericFilter } from './generic-filter';
import { waitUntilElementHasText } from '../../../utilities';
export class FacetTabbedFilter extends GenericFilter {
private readonly locators = {
tabs: '.mat-tab-list .mat-tab-label',
chipList: '.mat-tab-body-active .adf-chip-list',
chipListInput: '.mat-tab-body-active .adf-chip-list input',
currentTabLabel: '.mat-tab-label-active .mat-tab-label-content',
chip: '.mat-mdc-chip span',
option: '.mdc-list-item__primary-text'
};
chips: ElementArrayFinder = this.filterDialogOpened.all(by.css(this.locators.chip));
get tabs(): ElementArrayFinder {
return this.filterDialogOpened.all(by.css(this.locators.tabs));
}
get chipList(): ElementFinder {
return this.filterDialogOpened.element(by.css(this.locators.chipList));
}
get chipListInput(): ElementFinder {
return this.filterDialogOpened.element(by.css(this.locators.chipListInput));
}
get options(): ElementArrayFinder {
return element.all(by.css(this.locators.option));
}
async getCurrentTabLabel(): Promise<string> {
const label = this.filterDialogOpened.element(by.css(this.locators.currentTabLabel));
return await label.getText();
}
async changeTabToModifier(): Promise<void> {
await this.tabs.get(1).click();
await waitUntilElementHasText(await this.filterDialogOpened.element(by.css(this.locators.currentTabLabel)), 'Modifier');
}
async changeTabToCreator(): Promise<void> {
await this.tabs.get(0).click();
await waitUntilElementHasText(await this.filterDialogOpened.element(by.css(this.locators.currentTabLabel)), 'Creator');
}
async isChipListDisplayed(): Promise<boolean> {
return this.chipList.isDisplayed();
}
async getSelectedValues(): Promise<string[]> {
return this.chips.map((option) => {
return option.getText();
});
}
async selectChip(name: string): Promise<void> {
await this.chipListInput.sendKeys(name);
await browser.actions().sendKeys(protractor.Key.ENTER).perform();
}
async getAutocompleteOptions(filterValue: string): Promise<string[]> {
await this.chipListInput.sendKeys(filterValue);
return this.options.map((option) => option.getText());
}
}

View File

@@ -1,92 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, element } from 'protractor';
import { isPresentAndDisplayed, Utils, waitUntilElementIsVisible, waitUntilElementIsNotVisible, TestElement } from '../../../utilities';
async function waitUntilActionMenuIsVisible(): Promise<void> {
const actionMenu = element.all(by.css('div[role="menu"]')).first();
await waitUntilElementIsVisible(actionMenu);
}
async function waitUntilActionMenuIsNotVisible(): Promise<void> {
const actionMenu = element.all(by.css('div[role="menu"]')).first();
await waitUntilElementIsNotVisible(actionMenu);
}
export class GenericFilter {
private readonly filterName: string;
constructor(filterName: string) {
this.filterName = filterName;
}
private readonly selectors = {
root: 'adf-search-filter-chips',
chip: '.mat-mdc-chip',
chipDialog: '.mat-mdc-menu-content .adf-search-filter-menu-card'
};
get chip(): ElementFinder {
return browser.element(by.cssContainingText(this.selectors.chip, this.filterName));
}
get filterDialogOpened(): ElementFinder {
return browser.element(by.cssContainingText(this.selectors.chipDialog, this.filterName));
}
async getChipTitle(): Promise<string> {
return browser.element(by.cssContainingText(`${this.selectors.root} ${this.selectors.chip}`, this.filterName)).getAttribute('title');
}
async clickApplyButton(): Promise<void> {
await TestElement.byId('apply-filter-button').click();
}
async clickResetButton(): Promise<void> {
await TestElement.byId('cancel-filter-button').click();
}
async isDisplayed(): Promise<boolean> {
return isPresentAndDisplayed(this.chip);
}
async isDialogPresent(): Promise<boolean> {
return isPresentAndDisplayed(this.filterDialogOpened);
}
async openDialog(): Promise<void> {
if (!(await this.isDialogPresent())) {
await this.chip.click();
await waitUntilActionMenuIsVisible();
}
}
async closeDialog(): Promise<void> {
if (await this.isDialogPresent()) {
await Utils.pressEscape();
await waitUntilActionMenuIsNotVisible();
}
}
}

View File

@@ -1,103 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { GenericFilter } from './generic-filter';
import { by, element, ElementArrayFinder, ElementFinder } from 'protractor';
export enum SizeOperator {
AT_LEAST = 'At Least',
AT_MOST = 'At Most',
EXACTLY = 'Exactly'
}
export class PropertiesFilter extends GenericFilter {
private readonly locators = {
fileSizeOperatorSelect: '[data-automation-id=adf-search-properties-file-size-operator-select]',
fileSizeOperatorOption: '.mdc-list-item__primary-text',
selectedFileSizeOperatorOption: '.mat-mdc-select-min-line',
fileSizeInput: '[data-automation-id=adf-search-properties-file-size-input]',
fileTypeInput: '[data-automation-id=adf-search-chip-autocomplete-input]',
fileTypeOption: '.mdc-list-item__primary-text',
selectedFileTypeOption: 'adf-search-chip-autocomplete-input .mat-mdc-chip span'
};
constructor() {
super('Properties');
}
get fileTypeInput(): ElementFinder {
return this.filterDialogOpened.element(by.css(this.locators.fileTypeInput));
}
get fileTypeOptions(): ElementArrayFinder {
return element.all(by.css(this.locators.fileTypeOption));
}
get fileSizeInput(): ElementFinder {
return this.filterDialogOpened.element(by.css(this.locators.fileSizeInput));
}
get fileSizeOperatorSelect(): ElementFinder {
return this.filterDialogOpened.element(by.css(this.locators.fileSizeOperatorSelect));
}
get fileTypeOperatorOptions(): ElementArrayFinder {
return element.all(by.css(this.locators.fileSizeOperatorOption));
}
get selectedFileTypeOperatorOption(): ElementFinder {
return this.filterDialogOpened.element(by.css(this.locators.selectedFileSizeOperatorOption));
}
async getFileTypesValues(filterValue: string): Promise<string[]> {
await this.fileTypeInput.sendKeys(filterValue);
return this.fileTypeOptions.map((option) => option.getText());
}
async selectFileType(option: string): Promise<void> {
await this.fileTypeInput.sendKeys(option);
return this.fileTypeOptions.filter(async (element) => (await element.getText()) === option).click();
}
async getSelectedFileTypeOptions(): Promise<string[]> {
return this.filterDialogOpened.all(by.css(this.locators.selectedFileTypeOption)).map((option) => option.getText());
}
async typeFileSize(fileSize: string): Promise<void> {
await this.fileSizeInput.sendKeys(fileSize);
}
async selectFileSizeOperator(option: string): Promise<void> {
await this.fileSizeOperatorSelect.click();
await this.fileTypeOperatorOptions.filter(async (element) => (await element.getText() === option)).click();
}
async getFileSizeOperatorValue(): Promise<string> {
return this.selectedFileTypeOperatorOption.getText();
}
async getFileSizeValue(): Promise<string> {
return this.fileSizeInput.getAttribute('value');
}
}

View File

@@ -1,31 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export * from './filters/autocomplete-chips-filter';
export * from './filters/facet-filter';
export * from './filters/generic-filter';
export * from './filters/properties-filter';
export * from './search-filters';
export * from './search-input';
export * from './search-sorting-picker';

View File

@@ -1,43 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by, browser } from 'protractor';
import { Component } from '../component';
import { FacetFilter } from './filters/facet-filter';
import { AutocompleteChipsFilter } from './filters/autocomplete-chips-filter';
import { PropertiesFilter } from './filters/properties-filter';
import { FacetTabbedFilter } from './filters/facet-tabbed-filter';
export class SearchFilters extends Component {
resetAllButton = browser.element(by.css('button[adf-reset-search]'));
fileType = new PropertiesFilter();
people = new FacetTabbedFilter('People');
location = new AutocompleteChipsFilter('Location');
modifiedDate = new FacetFilter('Modified date');
constructor(ancestor?: string) {
super('adf-search-filter', ancestor);
}
}

View File

@@ -1,172 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser, by } from 'protractor';
import { Component } from '../component';
import { click, waitElement, waitForPresence, waitUntilElementIsClickable, getUrl, TestElement } from '../../utilities';
export class SearchInput extends Component {
get searchButton() {
return browser.element(by.css('aca-search-input .app-search-button'));
}
searchContainer = browser.element(by.css('.app-search-container'));
searchControl = browser.element(by.css('.app-search-control'));
searchInput = TestElement.byCss('input[id="app-control-input"]');
searchResult = TestElement.byCss('.search-file-name');
searchOptionsArea = browser.element(by.id('search-options'));
searchFilesOption = this.searchOptionsArea.element(by.cssContainingText('.mat-mdc-checkbox', 'Files'));
searchFoldersOption = this.searchOptionsArea.element(by.cssContainingText('.mat-mdc-checkbox', 'Folders'));
searchLibrariesOption = this.searchOptionsArea.element(by.cssContainingText('.mat-mdc-checkbox', 'Libraries'));
constructor(ancestor?: string) {
super('aca-search-input', ancestor);
}
async waitForSearchControl() {
await waitForPresence(this.searchControl);
}
async isSearchContainerDisplayed() {
const isContainerDisplayed = await this.searchContainer.isDisplayed();
const isSearchButtonDisplayed = await this.searchButton.isDisplayed();
return isContainerDisplayed && isSearchButtonDisplayed;
}
async clickSearchButton() {
await click(this.searchButton);
await this.waitForSearchControl();
}
async isOptionsAreaDisplayed() {
await waitElement('.app-search-control');
return browser.isElementPresent(this.searchOptionsArea);
}
async clickFilesOption() {
await click(this.searchFilesOption);
}
async clickFoldersOption() {
await click(this.searchFoldersOption);
}
async clickLibrariesOption() {
await click(this.searchLibrariesOption);
}
async isFilesOptionEnabled() {
const optClass = await this.searchFilesOption.getAttribute('class');
return !optClass.includes('.mat-mdc-checkbox-disabled');
}
async isFoldersOptionEnabled() {
const optClass = await this.searchFoldersOption.getAttribute('class');
return !optClass.includes('.mat-mdc-checkbox-disabled');
}
async isLibrariesOptionEnabled() {
const optClass = await this.searchLibrariesOption.getAttribute('class');
return !optClass.includes('.mat-mdc-checkbox-disabled');
}
async isFilesOptionChecked() {
const optClass = await this.searchFilesOption.getAttribute('class');
return optClass.includes('.mat-mdc-checkbox-checked');
}
async isFoldersOptionChecked() {
const optClass = await this.searchFoldersOption.getAttribute('class');
return optClass.includes('.mat-mdc-checkbox-checked');
}
async isLibrariesOptionChecked() {
const optClass = await this.searchLibrariesOption.getAttribute('class');
return optClass.includes('.mat-mdc-checkbox-checked');
}
async clearOptions() {
if (await this.isFilesOptionChecked()) {
await this.clickFilesOption();
}
if (await this.isFoldersOptionChecked()) {
await this.clickFoldersOption();
}
if (await this.isLibrariesOptionChecked()) {
await this.clickLibrariesOption();
}
}
async checkOnlyFiles() {
await this.clearOptions();
await this.clickFilesOption();
}
async checkOnlyFolders() {
await this.clearOptions();
await this.clickFoldersOption();
}
async checkFilesAndFolders() {
await this.clearOptions();
await this.clickFilesOption();
await this.clickFoldersOption();
}
async checkLibraries() {
await this.clearOptions();
await this.clickLibrariesOption();
}
async searchForLibrary(text: string) {
await waitUntilElementIsClickable(this.searchInput.elementFinder);
await this.searchInput.typeText(text);
}
async searchFor(text: string) {
await waitUntilElementIsClickable(this.searchInput.elementFinder);
await this.searchInput.typeText(text);
await click(this.searchButton);
}
async searchByURL(text: string) {
const query = Buffer.from(text, 'utf-8').toString();
await getUrl(`#/search;q=${query}`);
}
async searchUntilResult(text: string, methodType: 'URL' | 'UI', waitPerSearch: number = 2000, timeout: number = 20000) {
const attempts = Math.round(timeout / waitPerSearch);
let loopCount = 0;
return new Promise((resolve, reject) => {
const check = async () => {
loopCount++;
loopCount >= attempts ? reject('File not found') : methodType === 'UI' ? await this.searchFor(text) : await this.searchByURL(text);
(await this.searchResult.isPresent(waitPerSearch)) ? resolve('File found') : setTimeout(check, waitPerSearch);
};
return check();
});
}
}

View File

@@ -1,73 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by, browser } from 'protractor';
import { Component } from '../component';
import { isPresentAndDisplayed, waitUntilElementIsVisible, click } from '../../utilities';
export type SortByType = 'Relevance' | 'Title' | 'Filename' | 'Modified date' | 'Modifier' | 'Created date' | 'Size' | 'Type';
export class SearchSortingPicker extends Component {
actionMenu = browser.element(by.css('aca-search-action-menu > button'));
sortOrderButton = browser.element(by.css('#aca-button-sorting-menu'));
sortByDropdownExpanded = browser.element.all(by.css('.mat-mdc-menu-panel')).get(1);
sortByList = this.sortByDropdownExpanded.all(by.css('button'));
constructor(ancestor?: string) {
super('aca-button-action-menu', ancestor);
}
async waitForSortByDropdownToExpand(): Promise<void> {
await waitUntilElementIsVisible(this.sortByDropdownExpanded);
}
async isSortOrderButtonDisplayed(): Promise<boolean> {
return isPresentAndDisplayed(this.actionMenu);
}
async isSortByDropdownExpanded(): Promise<boolean> {
return isPresentAndDisplayed(this.sortByDropdownExpanded);
}
async clickSortByDropdown(): Promise<void> {
await click(this.actionMenu);
await click(this.sortOrderButton);
await this.waitForSortByDropdownToExpand();
}
async getSortByOptionsList(): Promise<string[]> {
return this.sortByList.map(async (option) => {
return option.getText();
});
}
async sortBy(option: SortByType, direction: string): Promise<void> {
if (!(await this.isSortByDropdownExpanded())) {
await this.clickSortByDropdown();
}
const elem = browser.element(by.cssContainingText('.mat-mdc-menu-item', option));
const optionId = await elem.getAttribute('id');
await click(elem);
const directionSortElement = browser.element(by.id(`${optionId}-${direction.toLocaleLowerCase()}`));
await click(directionSortElement);
}
}

View File

@@ -1,83 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser } from 'protractor';
import { Menu } from '../menu/menu';
import { Component } from '../component';
import { click } from '../../utilities';
export class Sidenav extends Component {
links = this.component.all(by.css('.item'));
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);
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']`);
trash = this.byCss(`[data-automation-id='app.navbar.trashcan']`);
menu: Menu = new Menu();
constructor(ancestor?: string) {
super('app-sidenav', ancestor);
}
async isActive(name: string): Promise<boolean> {
const cssClass = await this.getLinkLabel(name).getAttribute('class');
return cssClass.includes('action-button--active');
}
private getLinkLabel(name: string): ElementFinder {
switch (name) {
case 'Personal Files':
return this.personalFiles;
case 'File Libraries':
return this.fileLibraries;
case 'My Libraries':
return this.myLibraries;
case 'Favorite Libraries':
return this.favoriteLibraries;
case 'Shared':
return this.shared;
case 'Recent Files':
return this.recentFiles;
case 'Favorites':
return this.favorites;
case 'Trash':
return this.trash;
default:
return this.personalFiles;
}
}
async clickLink(name: string): Promise<void> {
try {
const link = this.getLinkLabel(name);
await click(link);
} catch (error) {
console.error(`---- clickLink catch : sidebar navigation failed to click on - ${name} : `, error);
}
}
}

View File

@@ -1,118 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by, browser, By, element } from 'protractor';
import { Menu } from '../menu/menu';
import { Component } from '../component';
import { click, Utils } from '../../utilities';
export class Toolbar extends Component {
menu = new Menu();
buttons = this.allByCss('button');
createButton = element(By.css('[id="app.toolbar.create"]'));
uploadButton = element(By.css('[id="app.toolbar.upload"]'));
downloadButton = element(By.css(`.mat-icon-button[title='Download']`));
viewDetailsButton = element(By.css(`button[title='View Details']`));
permanentlyDeleteButton = element(By.css(`button[title='Permanently Delete']`));
restoreButton = element(By.css(`button[title='Restore']`));
searchIconButton = element(By.css(`button[title='Search']`));
viewerDownloadButton = element(By.css('[id="app.viewer.download"]'));
constructor(ancestor?: string) {
super('aca-toolbar', ancestor);
}
async isButtonPresent(title: string) {
const element = this.byCss(`button[title="${title}"]`);
return element.isPresent();
}
async clickSearchIconButton() {
await click(this.searchIconButton);
}
async openMoreMenu(): Promise<void> {
const btnMoreActions = element(By.css('button[id="app.toolbar.more"]'));
await btnMoreActions.isPresent();
await click(btnMoreActions);
await this.menu.waitForMenuToOpen();
await browser.sleep(500);
}
async closeMoreMenu() {
await Utils.pressEscape();
}
async openUploadMenu(): Promise<void> {
await click(this.uploadButton);
await this.menu.waitForMenuToOpen();
}
async closeUploadMenu(): Promise<void> {
await click(element(by.css('button[id="app.toolbar.upload"]')));
await this.menu.waitForMenuToClose();
}
async clickMoreActionsFavorite(): Promise<void> {
await this.openMoreMenu();
await this.menu.clickMenuItem('Favorite');
}
async clickMoreActionsRemoveFavorite(): Promise<void> {
await this.openMoreMenu();
await this.menu.clickMenuItem('Remove Favorite');
}
async clickMoreActionsDelete(): Promise<void> {
await this.openMoreMenu();
await this.menu.clickMenuItem('Delete');
}
async clickMoreActionsManageVersions(): Promise<void> {
await this.openMoreMenu();
await this.menu.clickMenuItem('Manage Versions');
}
async clickMoreActionsCopy(): Promise<void> {
await this.openMoreMenu();
await this.menu.copyAction.click();
}
async clickMoreActionsEditOffline(): Promise<void> {
await this.openMoreMenu();
await this.menu.clickMenuItem('Edit Offline');
}
async clickMoreActionsCancelEditing(): Promise<void> {
await this.openMoreMenu();
await this.menu.clickMenuItem('Cancel Editing');
}
async clickMoreActionsUploadNewVersion(): Promise<void> {
await this.openMoreMenu();
await this.menu.clickMenuItem('Upload New Version');
}
}

View File

@@ -1,68 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { Component } from '../component';
import { Toolbar } from '../toolbar/toolbar';
import { waitForPresence } from '../../utilities';
export class Viewer extends Component {
root = browser.$('adf-viewer');
viewerLayout = this.byCss('.adf-viewer-render-layout-content');
viewerContainer = this.byCss('.adf-viewer-render-content-container');
closeButton = this.byCss('.adf-viewer-close-button');
fileTitle = this.byCss('.adf-viewer__file-title');
toolbar = new Toolbar('adf-viewer');
constructor(ancestor?: string) {
super('adf-viewer', ancestor);
}
async waitForViewerToOpen(): Promise<void> {
try {
await waitForPresence(this.viewerContainer);
await waitForPresence(this.viewerLayout);
} catch (error) {
console.error('\n-----> catch waitForViewerToOpen <-----\n', error);
}
}
async waitForFileTitleToBeDisplayed(fileTitle: string): Promise<void> {
try {
const fileName = this.byCssText('.adf-viewer__display-name', `${fileTitle}`);
await waitForPresence(fileName);
} catch (error) {
console.error('\n-----> catch waitForFileTitle <-----\n', error);
}
}
async isViewerOpened() {
return browser.isElementPresent(this.viewerLayout);
}
async getFileTitle(): Promise<string> {
return this.fileTitle.getText();
}
}

View File

@@ -1,96 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export const BROWSER_WAIT_TIMEOUT = 10000;
// Application configs
export const USE_HASH_STRATEGY = true;
// Application Routes
export const APP_ROUTES = {
FAVORITES: '/favorites',
MY_LIBRARIES: '/libraries',
FAVORITE_LIBRARIES: '/favorite/libraries',
LOGIN: '/login',
LOGOUT: '/logout',
PERSONAL_FILES: '/personal-files',
RECENT_FILES: '/recent-files',
SHARED_FILES: '/shared',
TRASHCAN: '/trashcan'
};
// Sidebar labels
export const SIDEBAR_LABELS = {
PERSONAL_FILES: 'Personal Files',
MY_LIBRARIES: 'My Libraries',
FAVORITE_LIBRARIES: 'Favorite Libraries',
SHARED_FILES: 'Shared',
RECENT_FILES: 'Recent Files',
FAVORITES: 'Favorites',
TRASH: 'Trash'
};
// Site visibility
export const SITE_VISIBILITY = {
PUBLIC: 'PUBLIC',
MODERATED: 'MODERATED',
PRIVATE: 'PRIVATE'
};
// Site roles
export const SITE_ROLES = {
SITE_CONSUMER: {
ROLE: 'SiteConsumer',
LABEL: 'Consumer'
},
SITE_COLLABORATOR: {
ROLE: 'SiteCollaborator',
LABEL: 'Collaborator'
},
SITE_CONTRIBUTOR: {
ROLE: 'SiteContributor',
LABEL: 'Contributor'
},
SITE_MANAGER: {
ROLE: 'SiteManager',
LABEL: 'Manager'
},
NONE: {
LABEL: 'Not a member'
}
};
export const FILES = {
docxFile: 'file-docx.docx',
docxFile2: 'file2-docx.docx',
xlsxFile: 'file-xlsx.xlsx',
xlsxFile2: 'file2-xlsx.xlsx',
pdfFile: 'file-pdf.pdf',
unsupportedFile: 'file_unsupported.3DS',
protectedFile: {
name: 'protected.pdf',
password: '0000'
},
jpgFile: 'file-jpg.jpg'
};

View File

@@ -1,28 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export * from './components';
export * from './pages';
export * from './utilities';
export * from './configs';

View File

@@ -1,95 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Header, DataTable, Pagination, Toolbar, Breadcrumb, Sidenav, PageLayoutHeader } from '../components';
import { SIDEBAR_LABELS } from '../configs';
import { Page } from './page';
export class BrowsingPage extends Page {
header = new Header(this.appRoot);
sidenav = new Sidenav(this.appRoot);
toolbar = new Toolbar('.aca-page-layout');
breadcrumb = new Breadcrumb(this.appRoot);
pageLayoutHeader = new PageLayoutHeader(this.appRoot);
dataTable = new DataTable(this.appRoot);
pagination = new Pagination(this.appRoot);
async clickPersonalFiles(): Promise<void> {
await this.sidenav.clickLink(SIDEBAR_LABELS.PERSONAL_FILES);
}
async clickPersonalFilesAndWait(): Promise<void> {
await this.clickPersonalFiles();
await this.dataTable.waitForHeader();
}
async goToFavoriteLibraries(): Promise<void> {
await this.sidenav.clickLink(SIDEBAR_LABELS.FAVORITE_LIBRARIES);
}
async goToMyLibraries(): Promise<void> {
await this.sidenav.clickLink(SIDEBAR_LABELS.MY_LIBRARIES);
}
async goToMyLibrariesAndWait(): Promise<void> {
await this.goToMyLibraries();
await this.dataTable.waitForHeader();
}
async clickRecentFiles(): Promise<void> {
await this.sidenav.clickLink(SIDEBAR_LABELS.RECENT_FILES);
}
async clickRecentFilesAndWait(): Promise<void> {
await this.clickRecentFiles();
await this.dataTable.waitForHeader();
}
async clickSharedFiles(): Promise<void> {
await this.sidenav.clickLink(SIDEBAR_LABELS.SHARED_FILES);
}
async clickSharedFilesAndWait(): Promise<void> {
await this.clickSharedFiles();
await this.dataTable.waitForHeader();
}
async clickFavorites(): Promise<void> {
await this.sidenav.clickLink(SIDEBAR_LABELS.FAVORITES);
}
async clickFavoritesAndWait(): Promise<void> {
await this.clickFavorites();
await this.dataTable.waitForHeader();
}
async clickTrash(): Promise<void> {
await this.sidenav.clickLink(SIDEBAR_LABELS.TRASH);
}
async clickTrashAndWait(): Promise<void> {
await this.clickTrash();
await this.dataTable.waitForHeader();
}
}

View File

@@ -1,27 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export * from './browsing-page';
export * from './login-page';
export * from './search-results-page';

View File

@@ -1,65 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { LoginComponent } from '../components';
import { Page } from './page';
import { APP_ROUTES } from '../configs';
import { click, waitForPresence } from '../utilities';
export class LoginPage extends Page {
login = new LoginComponent(this.appRoot);
constructor() {
super(APP_ROUTES.LOGIN);
}
async load() {
await super.load();
if (await this.isLoggedIn()) {
await this.signOut();
}
await waitForPresence(this.login.submitButton);
}
async loginWith(username: string, password?: string) {
try {
const pass = password || username;
await this.load();
await this.login.enterCredentials(username, pass);
await click(this.login.submitButton);
await this.waitForApp();
} catch (error) {
console.error(`----- loginWith catch : failed to login with user: ${username} : ${error}`);
}
}
async loginWithAdmin() {
await this.loginWith(browser.params.ADMIN_USERNAME, browser.params.ADMIN_PASSWORD);
}
}

View File

@@ -1,113 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser, by, ElementFinder, WebElement } from 'protractor';
import { APP_ROUTES, USE_HASH_STRATEGY } from '../configs';
import { Utils, waitElement, waitForPresence, isPresentAndDisplayed, waitUntilElementIsPresent, waitUntilElementIsVisible } from '../utilities';
import { Header } from '../components';
import { UploadFilesDialog } from '../components/dialog/upload-files-dialog';
export abstract class Page {
appRoot = 'app-root';
layout = this.byCss('app-shell');
overlay = this.byCss('.cdk-overlay-container');
snackBar = this.byCss(`[data-automation-id='adf-snackbar-message-content-action-button']`);
dialogContainer = this.byCss('.mat-dialog-container');
uploadFilesDialog = new UploadFilesDialog();
constructor(public url: string = '') {}
protected byCss(css: string): ElementFinder {
return browser.element(by.css(css));
}
async load(relativeUrl: string = '') {
const hash = USE_HASH_STRATEGY ? '#' : '';
const path = `${browser.baseUrl}${hash}${this.url}${relativeUrl}`;
return browser.get(path);
}
async waitForApp(): Promise<void> {
await waitForPresence(this.layout);
}
async signOut(): Promise<void> {
const header = new Header();
await header.openMoreMenu();
await header.menu.clickMenuItem('Sign out');
await waitUntilElementIsPresent(browser.element(by.css('[class*="login-content"] input#username')));
}
async waitForDialog(): Promise<void> {
await waitUntilElementIsVisible(this.dialogContainer);
}
async isDialogOpen(): Promise<boolean> {
return isPresentAndDisplayed(this.dialogContainer);
}
async closeOpenDialogs(): Promise<void> {
while (await this.isDialogOpen()) {
await Utils.pressEscape();
}
}
async refresh(): Promise<void> {
await browser.refresh();
await this.waitForApp();
}
async getSnackBarMessage(): Promise<string> {
const elem = await waitElement(`[data-automation-id='adf-snackbar-message-content']`);
const attributeValue: string = await browser.executeScript(`return arguments[0].innerText`, elem);
return attributeValue || '';
}
async getSnackBarAction(): Promise<string> {
let elem: WebElement;
try {
elem = await waitElement(`[data-automation-id='adf-snackbar-message-content-action-button']`);
} catch (e) {
return '';
}
const attributeValue: string = await browser.executeScript(`return arguments[0].innerText`, elem);
return attributeValue || '';
}
async clickSnackBarAction(): Promise<void> {
try {
const action = await waitElement(`[data-automation-id='adf-snackbar-message-content-action-button']`);
await action.click();
} catch (e) {
console.error(e, '.......failed on click snack bar action.........');
}
}
async isLoggedIn(): Promise<boolean> {
const url = await browser.driver.getCurrentUrl();
return !url.includes(APP_ROUTES.LOGIN);
}
}

View File

@@ -1,36 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { BrowsingPage } from './browsing-page';
import { SearchSortingPicker, SearchFilters } from '../components';
export class SearchResultsPage extends BrowsingPage {
root = this.byCss('aca-search-results');
sortingPicker = new SearchSortingPicker('aca-search-results');
filters = new SearchFilters('aca-search-results');
async waitForResults(): Promise<void> {
await this.dataTable.waitForBody();
}
}

View File

@@ -1,52 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { PersonEntry, PeopleApi } from '@alfresco/js-api';
import { PersonModel, SitesApi, UploadApi, NodesApi, Person, SharedLinksApi } from './repo-client/apis';
import { UserActions } from './user-actions';
import { browser } from 'protractor';
export class AdminActions extends UserActions {
sites: SitesApi = new SitesApi();
upload: UploadApi = new UploadApi();
nodes: NodesApi = new NodesApi();
shared: SharedLinksApi = new SharedLinksApi();
async login(username?: string, password?: string) {
return super.login(username || browser.params.ADMIN_USERNAME, password || browser.params.ADMIN_PASSWORD);
}
async createUser(user: PersonModel): Promise<PersonEntry> {
const person = new Person(user);
const peopleApi = new PeopleApi(this.alfrescoApi);
await this.login();
try {
return peopleApi.createPerson(person);
} catch (error) {
super.handleError('Admin Actions - createUser failed : ', error);
return null;
}
}
}

View File

@@ -1,84 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser, ElementFinder, protractor } from 'protractor';
import { waitUntilElementHasValue, waitUntilElementIsClickable, waitUntilElementIsVisible } from './browser-visibility';
export async function click(elementToClick: ElementFinder): Promise<void> {
try {
await waitUntilElementIsVisible(elementToClick);
await waitUntilElementIsClickable(elementToClick);
await elementToClick.click();
} catch (clickErr) {
await clickScript(elementToClick);
}
}
export async function rightClick(elementFinder: ElementFinder): Promise<void> {
await browser.actions().mouseMove(elementFinder).mouseDown().mouseMove(elementFinder).perform();
await browser.actions().click(elementFinder, protractor.Button.RIGHT).perform();
}
async function clickScript(elementToClick: ElementFinder): Promise<void> {
await browser.executeScript(`arguments[0].scrollIntoView();`, elementToClick);
await browser.executeScript(`arguments[0].click();`, elementToClick);
}
export async function getInputValue(elementFinder: ElementFinder): Promise<string> {
const present = await waitUntilElementIsVisible(elementFinder);
if (present) {
return browser.executeScript(`return arguments[0].value`, elementFinder);
} else {
console.error(`Get Input value ${elementFinder.locator().toString()} not present`);
return '';
}
}
export async function getUrl(url: string, timeout: number = 10000): Promise<any> {
return browser.get(url, timeout);
}
export async function clearSendKeys(elementFinder: ElementFinder, text: string = '', sleepTime: number = 0): Promise<void> {
await click(elementFinder);
await elementFinder.sendKeys('');
await elementFinder.clear();
if (sleepTime === 0) {
await elementFinder.sendKeys(text);
} else {
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < text.length; i++) {
await elementFinder.sendKeys(text[i]);
await browser.sleep(sleepTime);
}
}
try {
if (text !== protractor.Key.SPACE && text !== protractor.Key.ENTER) {
await waitUntilElementHasValue(elementFinder, text, 1000);
}
} catch (e) {
console.info(`Set value different from the input`);
}
}

View File

@@ -1,80 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser, ElementFinder, protractor } from 'protractor';
import { falseIfMissing } from 'protractor/built/util';
export async function waitUntilElementIsVisible(
elementToCheck: ElementFinder,
waitTimeout: number = 10000,
message: string = 'Element is not visible'
): Promise<any> {
return browser.wait(protractor.ExpectedConditions.visibilityOf(elementToCheck), waitTimeout, message + elementToCheck.locator());
}
export async function waitUntilElementIsNotVisible(elementToCheck: ElementFinder, waitTimeout: number = 10000): Promise<any> {
return browser.wait(
protractor.ExpectedConditions.invisibilityOf(elementToCheck),
waitTimeout,
'Element is Visible and it should not' + elementToCheck.locator()
);
}
export async function waitUntilElementIsClickable(elementToCheck: ElementFinder, waitTimeout: number = 10000): Promise<any> {
return browser.wait(
protractor.ExpectedConditions.elementToBeClickable(elementToCheck),
waitTimeout,
'Element is not Clickable ' + elementToCheck.locator()
);
}
export async function waitUntilElementIsPresent(elementToCheck: ElementFinder, waitTimeout: number = 10000): Promise<any> {
return browser.wait(protractor.ExpectedConditions.presenceOf(elementToCheck), waitTimeout, 'Element is not present ' + elementToCheck.locator());
}
export async function waitUntilElementIsNotPresent(elementToCheck: ElementFinder, waitTimeout: number = 10000): Promise<any> {
return browser.wait(protractor.ExpectedConditions.stalenessOf(elementToCheck), waitTimeout, 'Element is present ' + elementToCheck.locator());
}
function textToBePresentInElementValue(elementFinder: ElementFinder, text: string) {
const hasText = async () =>
browser.executeScript(`return arguments[0].value`, elementFinder).then((actualText: string) => actualText.indexOf(text) > -1, falseIfMissing);
return protractor.ExpectedConditions.and(protractor.ExpectedConditions.presenceOf(elementFinder), hasText);
}
export async function waitUntilElementHasValue(elementToCheck: ElementFinder, elementValue, waitTimeout: number = 10000): Promise<any> {
return browser.wait(
textToBePresentInElementValue(elementToCheck, elementValue),
waitTimeout,
`Element doesn't have a value ${elementValue} ${elementToCheck.locator()}`
);
}
export async function waitUntilElementHasText(elementToCheck: ElementFinder, text, waitTimeout: number = 10000): Promise<any> {
return browser.wait(
protractor.ExpectedConditions.textToBePresentInElement(elementToCheck, text),
waitTimeout,
`Element doesn't have the text ${text} ${elementToCheck.locator()}`
);
}

View File

@@ -1,34 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export * from './repo-client/apis';
export * from './repo-client/repo-client';
export * from './admin-actions';
export * from './user-actions';
export * from './utils';
export * from './browser-visibility';
export * from './browser-actions';
export * from './api';
export * from './logger';
export * from './test-element';

View File

@@ -1,156 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { RepoApi } from '../repo-api';
import { Utils } from '../../../utils';
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?: string, password?: string) {
super(username, password);
}
async addFavoriteById(nodeType: 'file' | 'folder' | 'site', id: string): Promise<FavoriteEntry | null> {
let guid;
try {
await this.apiAuth();
if (nodeType === 'site') {
guid = (await this.sitesApi.getSite(id)).entry.guid;
} else {
guid = id;
}
const data = {
target: {
[nodeType]: {
guid: guid
}
}
};
return await this.favoritesApi.createFavorite('-me-', data);
} catch (error) {
this.handleError(`FavoritesApi addFavoriteById : catch : `, error);
return null;
}
}
async addFavoritesByIds(nodeType: 'file' | 'folder' | 'site', ids: string[]): Promise<FavoriteEntry[]> {
const favorites: FavoriteEntry[] = [];
try {
if (ids && ids.length > 0) {
for (const id of ids) {
const favorite = await this.addFavoriteById(nodeType, id);
favorites.push(favorite);
}
}
} catch (error) {
this.handleError(`FavoritesApi addFavoritesByIds : catch : `, error);
}
return favorites;
}
private async getFavorites() {
try {
await this.apiAuth();
return await this.favoritesApi.listFavorites(this.username);
} catch (error) {
this.handleError(`FavoritesApi getFavorites : catch : `, error);
return null;
}
}
async getFavoritesTotalItems(): Promise<number> {
try {
await this.apiAuth();
return (await this.favoritesApi.listFavorites(this.username)).list.pagination.totalItems;
} catch (error) {
this.handleError(`FavoritesApi getFavoritesTotalItems : catch : `, error);
return -1;
}
}
async isFavorite(nodeId: string) {
try {
return JSON.stringify((await this.getFavorites()).list.entries).includes(nodeId);
} catch (error) {
this.handleError(`FavoritesApi isFavorite : catch : `, error);
return null;
}
}
async isFavoriteWithRetry(nodeId: string, data: { expect: boolean }) {
try {
const favorite = async () => {
let isFavorite = await this.isFavorite(nodeId);
if (isFavorite !== data.expect) {
return Promise.reject(isFavorite);
} else {
return Promise.resolve(isFavorite);
}
};
return await Utils.retryCall(favorite);
} catch {
return false;
}
}
private async removeFavoriteById(nodeId: string) {
try {
await this.apiAuth();
return await this.favoritesApi.deleteFavorite('-me-', nodeId);
} catch (error) {
this.handleError(`FavoritesApi removeFavoriteById : catch : `, error);
}
}
async removeFavoritesByIds(ids: string[]) {
try {
return await ids.reduce(async (previous, current) => {
await previous;
await this.removeFavoriteById(current);
}, Promise.resolve());
} catch (error) {
this.handleError(`FavoritesApi removeFavoritesByIds : catch : `, error);
}
}
async waitForApi(data: { expect: number }) {
try {
const favoriteFiles = async () => {
const totalItems = await this.getFavoritesTotalItems();
if (totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
return await Utils.retryCall(favoriteFiles);
} catch (error) {
console.error(`FavoritesApi waitForApi : catch : `);
console.error(`\tExpected: ${data.expect} items, but found ${error}`);
}
}
}

View File

@@ -1,34 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export * from './favorites/favorites-api';
export * from './nodes/node-content-tree';
export * from './nodes/nodes-api';
export * from './people/people-api-models';
export * from './queries/queries-api';
export * from './search/search-api';
export * from './shared-links/shared-links-api';
export * from './sites/sites-api';
export * from './upload/upload-api';
export * from './repo-api';

View File

@@ -1,96 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
const NODE_TYPE_FILE = 'cm:content';
const NODE_TYPE_FOLDER = 'cm:folder';
const NODE_TITLE = 'cm:title';
const NODE_DESCRIPTION = 'cm:description';
export interface NodeContentTree {
name?: string;
files?: string[];
folders?: (string | NodeContentTree)[];
title?: string;
description?: string;
}
export interface NodeBodyCreate {
name: string;
nodeType: string;
relativePath: string;
aspectNames?: string[];
properties?: any[];
}
export function flattenNodeContentTree(content: NodeContentTree, relativePath: string = '/'): NodeBodyCreate[] {
const { name, files, folders, title, description } = content;
const aspectNames: string[] = ['cm:versionable'];
let data: NodeBodyCreate[] = [];
let properties: any;
properties = {
[NODE_TITLE]: title,
[NODE_DESCRIPTION]: description
};
if (name) {
data = data.concat([
{
nodeType: NODE_TYPE_FOLDER,
name,
relativePath,
properties
}
]);
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;
return flattenNodeContentTree(folderData, relativePath);
})
.reduce((nodesData: NodeBodyCreate[], folderData: NodeBodyCreate[]) => nodesData.concat(folderData), []);
data = data.concat(foldersData);
}
if (files) {
const filesData: NodeBodyCreate[] = files.map(
(filename: string): NodeBodyCreate => ({
nodeType: NODE_TYPE_FILE,
name: filename,
relativePath,
aspectNames
})
);
data = data.concat(filesData);
}
return data;
}

View File

@@ -1,449 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { RepoApi } from '../repo-api';
import { flattenNodeContentTree, NodeContentTree } from './node-content-tree';
import { NodeChildAssociationPaging, NodeEntry, NodesApi as AdfNodeApi } from '@alfresco/js-api';
import { Utils } from '../../../../utilities/utils';
export class NodesApi extends RepoApi {
private nodesApi = new AdfNodeApi(this.alfrescoJsApi);
constructor(username?: string, password?: string) {
super(username, password);
}
async getNodeByPath(relativePath: string = '/', parentFolderId: string = '-my-'): Promise<NodeEntry | null> {
try {
await this.apiAuth();
return await this.nodesApi.getNode(parentFolderId, { relativePath });
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getNodeByPath.name}`, error);
return null;
}
}
async getNodeById(id: string): Promise<NodeEntry | null> {
try {
await this.apiAuth();
return await this.nodesApi.getNode(id);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getNodeById.name}`, error);
return null;
}
}
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 || '';
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getNodeIdFromParent.name}`, error);
return '';
}
}
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'];
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getNodeDescription.name}`, error);
return '';
}
}
async getNodeProperty(nodeId: string, property: string): Promise<string> {
try {
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);
return '';
}
}
async getFileVersionType(nodeId: string): Promise<string> {
try {
const prop = await this.getNodeProperty(nodeId, 'cm:versionType');
return prop || '';
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getFileVersionType.name}`, error);
return '';
}
}
async getFileVersionLabel(nodeId: string): Promise<string> {
try {
const prop = await this.getNodeProperty(nodeId, 'cm:versionLabel');
return prop || '';
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getFileVersionLabel.name}`, error);
return '';
}
}
async getSharedId(nodeId: string): Promise<string> {
try {
const sharedId = await this.getNodeProperty(nodeId, 'qshare:sharedId');
return sharedId || '';
} catch (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');
return expiryDate || '';
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getSharedExpiryDate.name}`, error);
return '';
}
}
async isFileShared(nodeId: string): Promise<boolean> {
try {
const sharedId = await this.getSharedId(nodeId);
return sharedId !== '';
} catch (error) {
this.handleError(`${this.constructor.name} ${this.isFileShared.name}`, error);
return null;
}
}
async deleteNodeById(id: string, permanent: boolean = true): Promise<void> {
try {
await this.apiAuth();
await this.nodesApi.deleteNode(id, { permanent });
} catch (error) {
this.handleError(`${this.constructor.name} ${this.deleteNodeById.name}`, error);
}
}
async deleteNodeByPath(path: string, permanent: boolean = true, parentFolderId?: string): Promise<void> {
try {
const id = (await this.getNodeByPath(path, parentFolderId)).entry.id;
await this.deleteNodeById(id, permanent);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.deleteNodeByPath.name}`, error);
}
}
async deleteNodes(names: string[], relativePath: string = '', permanent: boolean = true): Promise<void> {
try {
await names.reduce(async (previous, current) => {
await previous;
return await this.deleteNodeByPath(`${relativePath}/${current}`, permanent);
}, Promise.resolve());
} catch (error) {
this.handleError(`${this.constructor.name} ${this.deleteNodes.name}`, error);
}
}
async deleteNodesById(ids: string[], permanent: boolean = true): Promise<void> {
try {
await this.apiAuth();
await this.nodesApi.deleteNodes(ids, { permanent });
} catch (error) {
this.handleError(`${this.constructor.name} ${this.deleteNodesById.name}`, error);
}
}
private async getNodeChildren(nodeId: string): Promise<NodeChildAssociationPaging | null> {
try {
const opts = {
include: ['properties']
};
await this.apiAuth();
return await this.nodesApi.listNodeChildren(nodeId, opts);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getNodeChildren.name}`, error);
return null;
}
}
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);
} else {
nodeIds = listEntries.map((entries) => entries.entry.id);
}
await this.deleteNodesById(nodeIds);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.deleteNodeChildren.name}`, error);
}
}
private 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);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.createImageNode.name}`, error);
return null;
}
}
private async createNode(
nodeType: string,
name: string,
parentId: string = '-my-',
title: string = '',
description: string = '',
imageProps: any = null,
author: string = '',
majorVersion: boolean = true,
aspectNames: string[] = null
): Promise<NodeEntry | null> {
if (!aspectNames) {
aspectNames = ['cm:versionable']; // workaround for REPO-4772
}
const nodeBody = {
name,
nodeType,
properties: {
'cm:title': title,
'cm:description': description,
'cm:author': author
},
aspectNames
};
if (imageProps) {
nodeBody.properties = Object.assign(nodeBody.properties, imageProps);
}
try {
await this.apiAuth();
return await this.nodesApi.createNode(parentId, nodeBody, {
majorVersion
});
} catch (error) {
this.handleError(`${this.constructor.name} ${this.createNode.name}`, error);
return null;
}
}
async createFile(
name: string,
parentId: string = '-my-',
title: string = '',
description: string = '',
author: string = '',
majorVersion: boolean = true,
aspectNames: string[] = null
): Promise<NodeEntry> {
try {
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);
return 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);
return null;
}
}
async createFolder(
name: string,
parentId: string = '-my-',
title: string = '',
description: string = '',
author: string = '',
aspectNames: string[] = null
): Promise<NodeEntry | null> {
try {
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);
return null;
}
}
async createContent(content: NodeContentTree, relativePath: string = '/'): Promise<NodeEntry | any> {
try {
await this.apiAuth();
return await this.nodesApi.createNode('-my-', flattenNodeContentTree(content, relativePath) as any);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.createContent.name}`, error);
}
}
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);
}
}
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);
}
}
private async addAspects(nodeId: string, aspectNames: string[]): Promise<NodeEntry> {
try {
await this.apiAuth();
return this.nodesApi.updateNode(nodeId, { aspectNames });
} catch (error) {
this.handleError(`${this.constructor.name} ${this.addAspects.name}`, error);
return 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`,
nodeType: 'app:folderlink',
properties: {
'cm:title': `Link to ${name}.url`,
'cm:destination': originalNodeId,
'cm:description': `Link to ${name}.url`,
'app:icon': 'space-icon-link'
}
};
try {
await this.apiAuth();
const link = await this.nodesApi.createNode(destinationId, nodeBody);
await this.addAspects(originalNodeId, ['app:linked']);
return link;
} catch (error) {
this.handleError(`${this.constructor.name} ${this.createFolderLink.name}`, error);
return null;
}
}
async updateNodeContent(
nodeId: string,
content: string,
majorVersion: boolean = true,
comment?: string,
newName?: string
): Promise<NodeEntry | null> {
try {
const opts = {
majorVersion,
comment,
name: newName
};
await this.apiAuth();
return await this.nodesApi.updateNodeContent(nodeId, content, opts);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.updateNodeContent.name}`, error);
return null;
}
}
async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string): Promise<NodeEntry | null> {
const data = {
permissions: {
isInheritanceEnabled: inheritPermissions,
locallySet: [
{
authorityId: username,
name: role
}
]
}
};
try {
await this.apiAuth();
return await this.nodesApi.updateNode(nodeId, data);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.setGranularPermission.name}`, error);
return null;
}
}
private async getLockType(nodeId: string): Promise<string> {
try {
const lockType = await this.getNodeProperty(nodeId, 'cm:lockType');
return lockType || '';
} catch (error) {
this.handleError(`${this.constructor.name} ${this.getLockType.name}`, error);
return '';
}
}
async isFileLockedWrite(nodeId: string): Promise<boolean> {
try {
return (await this.getLockType(nodeId)) === 'WRITE_LOCK';
} catch (error) {
this.handleError(`${this.constructor.name} ${this.isFileLockedWrite.name}`, error);
return null;
}
}
async isFileLockedWriteWithRetry(nodeId: string, expect: boolean): Promise<boolean> {
const data = {
expect: expect,
retry: 5
};
let isLocked = false;
try {
const locked = async () => {
isLocked = (await this.getLockType(nodeId)) === 'WRITE_LOCK';
if (isLocked !== data.expect) {
return Promise.reject(isLocked);
} else {
return Promise.resolve(isLocked);
}
};
return await Utils.retryCall(locked, data.retry);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.isFileLockedWriteWithRetry.name}`, error);
}
return isLocked;
}
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);
return null;
}
}
}

View File

@@ -1,52 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export interface PersonModel {
username?: string;
password?: string;
firstName?: string;
lastName?: string;
email?: string;
enabled?: boolean;
properties?: any;
}
export class Person {
id: string;
password: string;
firstName: string;
lastName: string;
email: string;
enabled: boolean;
properties: any;
constructor(user: PersonModel) {
this.id = user.username;
this.password = user.password || user.username;
this.firstName = user.firstName || user.username;
this.lastName = user.lastName || user.username;
this.email = user.email || `${user.username}@alfresco.com`;
this.enabled = user.enabled || true;
}
}

View File

@@ -1,70 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { RepoApi } from '../repo-api';
import { Utils } from '../../../utils';
import { QueriesApi as AdfQueriesApi } from '@alfresco/js-api';
export class QueriesApi extends RepoApi {
queriesApi = new AdfQueriesApi(this.alfrescoJsApi);
constructor(username?: string, password?: string) {
super(username, password);
}
private async findSitesTotalItems(searchTerm: string): Promise<number> {
try {
await this.apiAuth();
const opts = {
term: searchTerm,
fields: ['title']
};
const sites = await this.queriesApi.findSites(searchTerm, opts);
return sites.list.pagination.totalItems;
} catch (error) {
this.handleError(`QueriesApi findSitesTotalItems : catch :`, error);
return -1;
}
}
async waitForSites(searchTerm: string, data: { expect: number }) {
try {
const sites = async () => {
const totalItems = await this.findSitesTotalItems(searchTerm);
if (totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
return await Utils.retryCall(sites);
} catch (error) {
console.error(`QueriesApi waitForSites : catch : `);
console.error(`\tExpected: ${data.expect} items, but found ${error}`);
}
}
}

View File

@@ -1,54 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { AlfrescoApi } from '@alfresco/js-api';
export abstract class RepoApi {
alfrescoJsApi = new AlfrescoApi();
protected constructor(public username: string = browser.params.ADMIN_USERNAME, private password: string = browser.params.ADMIN_PASSWORD) {
this.alfrescoJsApi.setConfig(browser.params.config);
}
apiAuth(): Promise<any> {
return this.alfrescoJsApi.login(this.username, this.password);
}
protected handleError(message: string, response: any) {
console.error(`\n--- ${message} error :`);
console.error('\t>>> username: ', this.username);
console.error('\t>>> JSON: ', JSON.stringify(browser.params.config));
if (response.status && response.response) {
try {
console.error('\t>>> Status: ', response.status);
console.error('\t>>> Text: ', response.response.text);
console.error('\t>>> Method: ', response.response.error.method);
console.error('\t>>> Path: ', response.response.error.path);
} catch {
console.error('\t>>> ', response);
}
} else console.error('\t>>> ', response);
}
}

View File

@@ -1,122 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { RepoApi } from '../repo-api';
import { Utils } from '../../../utils';
import { waitForApi } from '../../../api';
import { SearchApi as AdfSearchApi } from '@alfresco/js-api';
export class SearchApi extends RepoApi {
searchApi = new AdfSearchApi(this.alfrescoJsApi);
constructor(username?: string, password?: string) {
super(username, password);
}
private async queryRecentFiles(username: string) {
const data = {
query: {
query: '*',
language: 'afts'
},
filterQueries: [
{ query: `cm:modified:[NOW/DAY-30DAYS TO NOW/DAY+1DAY]` },
{ query: `cm:modifier:${username} OR cm:creator:${username}` },
{ query: `TYPE:"content" AND -TYPE:"app:filelink" AND -TYPE:"fm:post"` }
]
};
try {
await this.apiAuth();
return this.searchApi.search(data);
} catch (error) {
this.handleError(`SearchApi queryRecentFiles : catch : `, error);
return null;
}
}
async getTotalItems(username: string): Promise<number> {
try {
return (await this.queryRecentFiles(username)).list.pagination.totalItems;
} catch (error) {
this.handleError(`SearchApi getTotalItems : catch : `, error);
return -1;
}
}
private async queryNodesNames(searchTerm: string) {
const data = {
query: {
query: `cm:name:\"${searchTerm}*\"`,
language: 'afts'
},
filterQueries: [{ query: `+TYPE:'cm:folder' OR +TYPE:'cm:content'` }]
};
try {
await this.apiAuth();
return this.searchApi.search(data);
} catch (error) {
this.handleError(`SearchApi queryNodesNames : catch : `, error);
return null;
}
}
async waitForApi(username: string, data: { expect: number }) {
try {
const recentFiles = async () => {
const totalItems = await this.getTotalItems(username);
if (totalItems !== data.expect) {
return Promise.reject(totalItems);
} else {
return Promise.resolve(totalItems);
}
};
return await Utils.retryCall(recentFiles);
} catch (error) {
console.error(`SearchApi waitForApi : catch : `);
console.error(`\tExpected: ${data.expect} items, but found ${error}`);
}
}
async waitForNodes(searchTerm: string, data: { expect: number }) {
const predicate = (totalItems: number) => totalItems === data.expect;
const apiCall = async () => {
try {
return (await this.queryNodesNames(searchTerm)).list.pagination.totalItems;
} catch (error) {
return 0;
}
};
try {
await waitForApi(apiCall, predicate, 30, 2500);
} catch (error) {
console.error(`SearchApi waitForNodes : catch : `);
console.error(`\tExpected: ${data.expect} items, but found ${error}`);
}
}
}

View File

@@ -1,94 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { RepoApi } from '../repo-api';
import { Utils } from '../../../utils';
import { SharedlinksApi as AdfSharedlinksApi, SharedLinkEntry, SharedLinkPaging } from '@alfresco/js-api';
export class SharedLinksApi extends RepoApi {
sharedlinksApi = new AdfSharedlinksApi(this.alfrescoJsApi);
constructor(username?: string, password?: string) {
super(username, password);
}
async shareFileById(id: string, expireDate?: Date): Promise<SharedLinkEntry | null> {
try {
await this.apiAuth();
const data = {
nodeId: id,
expiresAt: expireDate
};
return await this.sharedlinksApi.createSharedLink(data);
} catch (error) {
this.handleError(`SharedLinksApi shareFileById : catch : `, error);
return null;
}
}
async shareFilesByIds(ids: string[]): Promise<SharedLinkEntry[]> {
const sharedLinks: SharedLinkEntry[] = [];
try {
if (ids && ids.length > 0) {
for (const id of ids) {
const sharedLink = await this.shareFileById(id);
sharedLinks.push(sharedLink);
}
}
} catch (error) {
this.handleError(`SharedLinksApi shareFilesByIds : catch : `, error);
}
return sharedLinks;
}
private async getSharedLinks(maxItems: number = 250): Promise<SharedLinkPaging | null> {
try {
await this.apiAuth();
const opts = {
maxItems
};
return await this.sharedlinksApi.listSharedLinks(opts);
} catch (error) {
this.handleError(`SharedLinksApi getSharedLinks : catch : `, error);
return null;
}
}
async waitForFilesToBeShared(filesIds: string[]): Promise<any> {
const sharedFile = async () => {
const sharedFiles = (await this.getSharedLinks()).list.entries.map((link) => link.entry.nodeId);
const foundItems = filesIds.every((id) => sharedFiles.includes(id));
if (foundItems) {
return Promise.resolve(foundItems);
} else {
return Promise.reject(foundItems);
}
};
return Utils.retryCall(sharedFile).catch((error) => {
console.error(`SharedLinksApi waitForFilesToBeShared : catch : ${error}`);
console.error(`\tWait timeout reached waiting for files to be shared`);
});
}
}

View File

@@ -1,150 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { RepoApi } from '../repo-api';
import { SiteBodyCreate, SiteMembershipBodyUpdate, SiteMembershipBodyCreate, SiteEntry, SitesApi as AdfSiteApi } from '@alfresco/js-api';
import { SITE_VISIBILITY } from '../../../../configs';
import { Utils } from '../../../utils';
export class SitesApi extends RepoApi {
sitesApi = new AdfSiteApi(this.alfrescoJsApi);
constructor(username?: string, password?: string) {
super(username, password);
}
async getSite(siteId: string) {
try {
await this.apiAuth();
return await this.sitesApi.getSite(siteId);
} catch (error) {
this.handleError(`SitesApi getSite : catch : `, error);
return null;
}
}
async getDocLibId(siteId: string): Promise<string> {
try {
await this.apiAuth();
return (await this.sitesApi.listSiteContainers(siteId)).list.entries[0].entry.id;
} catch (error) {
this.handleError(`SitesApi getDocLibId : catch : `, error);
return null;
}
}
async createSite(title: string, visibility?: string, description?: string, siteId?: string): Promise<SiteEntry | null> {
const site = {
title,
visibility: visibility || SITE_VISIBILITY.PUBLIC,
description: description,
id: siteId || title
} as SiteBodyCreate;
try {
await this.apiAuth();
return await this.sitesApi.createSite(site);
} catch (error) {
this.handleError(`SitesApi createSite : catch : `, error);
return null;
}
}
async deleteSite(siteId: string, permanent: boolean = true) {
try {
await this.apiAuth();
return await this.sitesApi.deleteSite(siteId, { permanent });
} catch (error) {
this.handleError(`SitesApi deleteSite : catch : `, error);
}
}
async deleteSites(siteIds: string[], permanent: boolean = true) {
try {
if (siteIds && siteIds.length > 0) {
await this.apiAuth();
for (const siteId of siteIds) {
await this.sitesApi.deleteSite(siteId, { permanent });
}
}
} catch (error) {
this.handleError(`SitesApi deleteSites : catch : `, error);
}
}
async updateSiteMember(siteId: string, userId: string, role: string) {
const siteRole = {
role: role
} as SiteMembershipBodyUpdate;
try {
await this.apiAuth();
return await this.sitesApi.updateSiteMembership(siteId, userId, siteRole);
} catch (error) {
this.handleError(`SitesApi updateSiteMember : catch : `, error);
return null;
}
}
async addSiteMember(siteId: string, userId: string, role: string) {
const memberBody = {
id: userId,
role: role
} as SiteMembershipBodyCreate;
try {
await this.apiAuth();
return await this.sitesApi.createSiteMembership(siteId, memberBody);
} catch (error) {
if (error.status === 409) {
return this.updateSiteMember(siteId, userId, role);
} else {
this.handleError(`SitesApi addSiteMember : catch : `, error);
return null;
}
}
}
async waitForSitesToBeCreated(sitesIds: string[]) {
try {
const site = async () => {
await this.apiAuth();
const sites = await this.sitesApi.listSiteMembershipsForPerson(this.username);
const sitesList = sites.list.entries.map((link) => link.entry.id);
const foundItems = sitesIds.every((id) => sitesList.includes(id));
if (foundItems) {
return Promise.resolve(foundItems);
} else {
return Promise.reject(foundItems);
}
};
return await Utils.retryCall(site);
} catch (error) {
console.error(`SitesApi waitForSitesToBeCreated : catch : ${error}`);
console.error(`\tWait timeout reached waiting for sites to be created`);
}
}
}

View File

@@ -1,74 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { RepoApi } from '../repo-api';
import { NodeBodyCreate, UploadApi as AdfUploadApi } from '@alfresco/js-api';
import { browser } from 'protractor';
import * as fs from 'fs';
export class UploadApi extends RepoApi {
private upload = new AdfUploadApi(this.alfrescoJsApi);
private e2eRootPath = browser.params.e2eRootPath;
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 opts = {
name: fileName,
nodeType: 'cm:content'
};
try {
await this.apiAuth();
return await this.upload.uploadFile(file, '', parentFolderId, null, opts);
} catch (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}`);
const nodeProps = {
properties: {
'cm:title': title,
'cm:description': description
}
};
const opts = {
name: newName,
nodeType: 'cm:content'
};
try {
await this.apiAuth();
return await this.upload.uploadFile(file, '', parentId, nodeProps as NodeBodyCreate, opts);
} catch (error) {
this.handleError(`${this.constructor.name} ${this.uploadFileWithRename.name}`, error);
}
}
}

View File

@@ -1,81 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { NodesApi, SitesApi, FavoritesApi, QueriesApi, SharedLinksApi, SearchApi, UploadApi } from './apis';
import { AlfrescoApi } from '@alfresco/js-api';
/**
* @deprecated Use {AdminActions} or {UserActions} instead.
*/
export class RepoClient {
alfrescoApi: AlfrescoApi;
constructor(private username: string = browser.params.ADMIN_USERNAME, private password: string = browser.params.ADMIN_PASSWORD) {
this.alfrescoApi = new AlfrescoApi();
this.alfrescoApi.setConfig(browser.params.config);
}
apiAuth(): Promise<any> {
return this.alfrescoApi.login(this.username, this.password);
}
get nodes(): NodesApi {
return new NodesApi(this.username, this.password);
}
get sites(): SitesApi {
return new SitesApi(this.username, this.password);
}
get favorites(): FavoritesApi {
return new FavoritesApi(this.username, this.password);
}
get shared(): SharedLinksApi {
return new SharedLinksApi(this.username, this.password);
}
get search(): SearchApi {
return new SearchApi(this.username, this.password);
}
get queries(): QueriesApi {
return new QueriesApi(this.username, this.password);
}
get upload(): UploadApi {
return new UploadApi(this.username, this.password);
}
async createFolder(name: string, parentId?: string): Promise<string> {
const response = await this.nodes.createFolder(name, parentId);
return response.entry.id;
}
async createFile(name: string, parentId?: string): Promise<string> {
const response = await this.nodes.createFile(name, parentId);
return response.entry.id;
}
}

View File

@@ -1,155 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by, element, ElementFinder, $, browser } from 'protractor';
import { clearSendKeys, click } from './browser-actions';
import { waitUntilElementIsNotVisible, waitUntilElementIsPresent, waitUntilElementIsVisible } from './browser-visibility';
async function getText(elementFinder: ElementFinder): Promise<string> {
const present = await waitUntilElementIsVisible(elementFinder);
if (present) {
let text = await elementFinder.getText();
if (text === '') {
// DO NOT REMOVE BUG sometime wrongly return empty text for cdk elements
console.info(`Use backup get text script`);
text = await browser.executeScript(`return arguments[0].textContent`, elementFinder);
return text?.trim();
}
return text;
} else {
console.error(`Get Text ${elementFinder.locator().toString()} not present`);
return '';
}
}
/**
* Provides a wrapper for the most common operations with the page elements.
*/
export class TestElement {
constructor(public elementFinder: ElementFinder) {}
/**
* Create a new instance with the element located by the id
*
* @param id The id of the element
* @returns test element wrapper
*/
static byId(id: string): TestElement {
return new TestElement(element(by.id(id)));
}
/**
* Create a new instance with the element located by the CSS class name
*
* @param selector The CSS class name to lookup
* @returns test element wrapper
*/
static byCss(selector: string): TestElement {
return new TestElement($(selector));
}
/**
* Create a new instance with the element that contains specific text
*
* @param selector the CSS selector
* @param text the text within the target element
* @returns test element wrapper
*/
static byText(selector: string, text: string): TestElement {
return new TestElement(element(by.cssContainingText(selector, text)));
}
/**
* Performs a click on this element
*/
async click() {
return click(this.elementFinder);
}
/**
* Checks that an element is present on the DOM of a page and visible
*
* @param waitTimeout How long to wait for the condition to be true
*/
async isVisible(waitTimeout?: number): Promise<boolean> {
try {
await waitUntilElementIsVisible(this.elementFinder, waitTimeout);
return true;
} catch {
return false;
}
}
/**
* Waits until the element is present on the DOM of a page and visible
*
* @param waitTimeout How long to wait for the condition to be true
*/
async waitVisible(waitTimeout?: number): Promise<any> {
return waitUntilElementIsVisible(this.elementFinder, waitTimeout);
}
/**
* Waits until the element is either invisible or not present on the DOM
*
* @param waitTimeout How long to wait for the condition to be true
*/
async waitNotVisible(waitTimeout?: number): Promise<any> {
return waitUntilElementIsNotVisible(this.elementFinder, waitTimeout);
}
/**
* Checks that an element is present on the DOM of a page
*
* @param waitTimeout How long to wait for the condition to be true
*/
async isPresent(waitTimeout?: number): Promise<boolean> {
try {
await waitUntilElementIsPresent(this.elementFinder, waitTimeout);
return true;
} catch {
return false;
}
}
/**
* Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace.
*/
async getText(): Promise<string> {
return getText(this.elementFinder);
}
/**
* Enter the text
*
* @param text the text to enter
*/
async typeText(text: string): Promise<void> {
await clearSendKeys(this.elementFinder, text);
}
}

View File

@@ -1,169 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { AlfrescoApi, Comment, CommentsApi, NodesApi, TrashcanApi, SitesApi, SharedlinksApi } from '@alfresco/js-api';
import { browser } from 'protractor';
export class UserActions {
protected readonly alfrescoApi: AlfrescoApi;
readonly commentsApi: CommentsApi;
readonly nodesApi: NodesApi;
readonly trashcanApi: TrashcanApi;
readonly sitesApi: SitesApi;
readonly sharedLinksApi: SharedlinksApi;
protected username: string;
protected password: string;
constructor() {
this.alfrescoApi = new AlfrescoApi();
this.alfrescoApi.setConfig(browser.params.config);
this.commentsApi = new CommentsApi(this.alfrescoApi);
this.nodesApi = new NodesApi(this.alfrescoApi);
this.trashcanApi = new TrashcanApi(this.alfrescoApi);
this.sitesApi = new SitesApi(this.alfrescoApi);
this.sharedLinksApi = new SharedlinksApi(this.alfrescoApi);
}
async login(username: string, password: string) {
this.username = username || this.username;
this.password = password || this.password;
try {
return this.alfrescoApi.login(this.username, this.password);
} catch (error) {
this.handleError('User Actions - login failed : ', error);
}
}
async createComment(nodeId: string, content: string): Promise<Comment | null> {
try {
const comment = await this.commentsApi.createComment(nodeId, { content });
return comment?.entry;
} catch (error) {
this.handleError('User Actions - createComment failed : ', error);
return null;
}
}
/**
* Empties the trashcan. Uses multiple batches 1000 nodes each.
*/
async emptyTrashcan(): Promise<any> {
try {
const nodes = await this.trashcanApi.listDeletedNodes({
maxItems: 1000
});
if (nodes?.list?.entries && nodes?.list?.entries?.length > 0) {
const ids = nodes.list.entries.map((entries) => entries.entry.id);
for (const nodeId of ids) {
await this.trashcanApi.deleteDeletedNode(nodeId);
}
await this.emptyTrashcan();
}
} catch (error) {
this.handleError('User Actions - emptyTrashcan failed : ', error);
}
}
async lockNodes(nodeIds: string[], lockType: string = 'ALLOW_OWNER_CHANGES') {
try {
for (const nodeId of nodeIds) {
await this.nodesApi.lockNode(nodeId, { type: lockType });
}
} catch (error) {
this.handleError('User Actions - lockNodes failed : ', error);
}
}
/**
* Unlock multiple nodes.
* @param nodeIds The list of node IDs to unlock.
*/
async unlockNodes(nodeIds: string[]): Promise<any> {
try {
for (const nodeId of nodeIds) {
await this.nodesApi.unlockNode(nodeId);
}
} catch (error) {
this.handleError('User Actions - unlockNodes failed : ', error);
}
}
/**
* Delete multiple sites/libraries.
* @param siteIds The list of the site/library IDs to delete.
* @param permanent Delete permanently, without moving to the trashcan? (default: true)
*/
async deleteSites(siteIds: string[], permanent: boolean = true) {
try {
if (siteIds && siteIds.length > 0) {
for (const siteId of siteIds) {
await this.sitesApi.deleteSite(siteId, { permanent });
}
}
} catch (error) {
this.handleError('User Actions - deleteSites failed : ', error);
}
}
/**
* Creates shared links for the given nodes.
* @param nodeIds The list of node IDs to share.
* @param expiresAt (optional) Expiration date.
*/
async shareNodes(nodeIds: string[], expiresAt?: Date): Promise<any> {
try {
for (const nodeId of nodeIds) {
await this.sharedLinksApi.createSharedLink({
nodeId,
expiresAt
});
}
} catch (error) {
this.handleError('User Actions - shareNodes failed : ', error);
}
}
protected handleError(message: string, response: any) {
console.error(`\n--- ${message} error :`);
console.error('\t>>> username: ', this.username);
console.error('\t>>> JSON: ', JSON.stringify(browser.params.config));
if (response.status && response.response) {
try {
console.error('\t>>> Status: ', response.status);
console.error('\t>>> Text: ', response.response.text);
console.error('\t>>> Method: ', response.response.error.method);
console.error('\t>>> Path: ', response.response.error.path);
} catch {
console.error('\t>>> ', response);
}
} else console.error('\t>>> ', response);
}
}

View File

@@ -1,184 +0,0 @@
/*!
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser, protractor, ElementFinder, ExpectedConditions as EC, by, until, WebElement } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../configs';
import * as path from 'path';
import * as fs from 'fs';
import { waitUntilElementIsPresent, waitUntilElementIsVisible } from './browser-visibility';
const StreamZip = require('node-stream-zip');
const crypto = require('crypto');
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> {
await element.clear();
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 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 const isPresentAndEnabled = async (element: ElementFinder): Promise<boolean> => {
try {
await waitUntilElementIsPresent(element);
return element.isEnabled();
} catch (error) {
return false;
}
};
export const isPresentAndDisplayed = async (element: ElementFinder): Promise<boolean> => {
try {
await waitUntilElementIsVisible(element);
return true;
} catch (error) {
return false;
}
};
export class Utils {
static string257 =
'assembly doctor offender limit clearance inspiration baker fraud active apples trait brainstorm concept breaks down presidential \
reluctance summary communication patience books opponent banana economist head develop project swear unanimous read conservation';
static string513 =
'great indirect brain tune other expectation fun silver drain tumble rhythm harmful wander picture distribute opera complication copyright \
explosion snack ride pool machinery pair frog joint wrestle video referee drive window cage falsify happen tablet horror thank conception \
extension decay dismiss platform respect ceremony applaud absorption presentation dominate race courtship soprano body \
lighter track cinema tread tick climate lend summit singer radical flower visual negotiation promises cooperative live';
static random(): string {
return crypto.getRandomValues(new Uint32Array(1))[0].toString(36).substring(0, 5).toLowerCase();
}
static retryCall(fn: () => Promise<any>, retry: number = 30, delay: number = 1500): Promise<any> {
const pause = (duration: number) => new Promise((res) => setTimeout(res, duration));
const run = (retries: number): Promise<any> => {
return fn().catch((err) => (retries > 1 ? pause(delay).then(() => run(retries - 1)) : Promise.reject(err)));
};
return run(retry);
}
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);
let tries = 15;
return new Promise(function (resolve) {
const checkExist = setInterval(() => {
fs.access(filePath, function (error: any) {
tries--;
if (error && tries === 0) {
clearInterval(checkExist);
resolve(false);
}
if (!error) {
clearInterval(checkExist);
resolve(true);
}
});
}, 500);
});
}
static async renameFile(oldName: string, newName: string): Promise<void> {
const config = await browser.getProcessedConfig();
const oldFilePath = path.join(config.params.downloadFolder, oldName);
const newFilePath = path.join(config.params.downloadFolder, newName);
const fileExists = await this.fileExistsOnOS(oldName);
if (fileExists) {
fs.rename(oldFilePath, newFilePath, function (err: any) {
if (err) {
console.error(`==== rename err : failed to rename file from ${oldName} to ${newName} : `, err);
}
});
}
}
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 zip = new StreamZip({
file: filePath,
storeEntries: true
});
await zip.on('error', (err: any) => {
console.error(`=== unzip err : failed to unzip ${filename} - ${unzippedName} :`, err);
});
await zip.on('ready', async () => {
if (unzippedName) {
await fs.mkdirSync(output);
}
await zip.extract(null, output, async () => {
await zip.close();
});
});
}
static async pressEscape(): Promise<void> {
await browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
}
static async pressTab(): Promise<void> {
await browser.actions().sendKeys(protractor.Key.TAB).perform();
}
static async pressCmd(): Promise<void> {
await browser.actions().sendKeys(protractor.Key.COMMAND).perform();
}
static async releaseKeyPressed(): Promise<void> {
await browser.actions().sendKeys(protractor.Key.NULL).perform();
}
static async 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}`);
}
}

View File

@@ -1,25 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/aca-testing",
"target": "es2015",
"module": "es2015",
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
"inlineSources": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"types": [],
"lib": ["dom", "es2018"]
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
},
"exclude": ["node_modules", "src/test.ts", "**/*.spec.ts"]
}