mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-06-30 18:14:45 +00:00
Merge pull request #1230 from Alfresco/adina-refactor
[ACA-2775] e2e remove some redundant awaits
This commit is contained in:
commit
bd81c496d8
@ -45,11 +45,11 @@ export class Breadcrumb extends Component {
|
||||
}
|
||||
|
||||
async getNthItemName(nth: number) {
|
||||
return await this.getNthItem(nth).getText();
|
||||
return this.getNthItem(nth).getText();
|
||||
}
|
||||
|
||||
async getItemsCount() {
|
||||
return await this.items.count();
|
||||
return this.items.count();
|
||||
}
|
||||
|
||||
async getAllItems() {
|
||||
@ -60,7 +60,7 @@ export class Breadcrumb extends Component {
|
||||
}
|
||||
|
||||
async getFirstItemName() {
|
||||
return await this.items.get(0).getText();
|
||||
return this.items.get(0).getText();
|
||||
}
|
||||
|
||||
getCurrentItem() {
|
||||
@ -68,7 +68,7 @@ export class Breadcrumb extends Component {
|
||||
}
|
||||
|
||||
async getCurrentItemName() {
|
||||
return await this.currentItem.getText();
|
||||
return this.currentItem.getText();
|
||||
}
|
||||
|
||||
async clickItem(name: string) {
|
||||
@ -81,6 +81,6 @@ export class Breadcrumb extends Component {
|
||||
}
|
||||
|
||||
async getNthItemTooltip(nth: number) {
|
||||
return await this.getNthItem(nth).getAttribute('title');
|
||||
return this.getNthItem(nth).getAttribute('title');
|
||||
}
|
||||
}
|
||||
|
@ -85,11 +85,11 @@ export class DataTable extends Component {
|
||||
|
||||
// Wait methods (waits for elements)
|
||||
async waitForHeader() {
|
||||
return await browser.wait(EC.presenceOf(this.head), BROWSER_WAIT_TIMEOUT, '--- timeout waitForHeader ---');
|
||||
await browser.wait(EC.presenceOf(this.head), BROWSER_WAIT_TIMEOUT, '--- timeout waitForHeader ---');
|
||||
}
|
||||
|
||||
async waitForBody() {
|
||||
return await browser.wait(EC.presenceOf(this.body), BROWSER_WAIT_TIMEOUT, '--- timeout waitForBody ---');
|
||||
await browser.wait(EC.presenceOf(this.body), BROWSER_WAIT_TIMEOUT, '--- timeout waitForBody ---');
|
||||
}
|
||||
|
||||
async waitForEmptyState() {
|
||||
@ -104,7 +104,7 @@ export class DataTable extends Component {
|
||||
|
||||
async getColumnHeadersText() {
|
||||
const el = this.getColumnHeaders();
|
||||
return await el.getText();
|
||||
return el.getText();
|
||||
}
|
||||
|
||||
getNthColumnHeader(nth: number) {
|
||||
@ -122,7 +122,7 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async getSortedColumnHeaderText() {
|
||||
return await this.getSortedColumnHeader().getText();
|
||||
return this.getSortedColumnHeader().getText();
|
||||
}
|
||||
|
||||
async getSortingOrder(): Promise<string> {
|
||||
@ -151,7 +151,7 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async countRows() {
|
||||
return await this.getRows().count();
|
||||
return this.getRows().count();
|
||||
}
|
||||
|
||||
getSelectedRows() {
|
||||
@ -159,7 +159,7 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async countSelectedRows() {
|
||||
return await this.getSelectedRows().count();
|
||||
return this.getSelectedRows().count();
|
||||
}
|
||||
|
||||
getNthRow(nth: number) {
|
||||
@ -180,7 +180,7 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async getRowCellsCount(itemName: string) {
|
||||
return await this.getRowCells(itemName).count();
|
||||
return this.getRowCells(itemName).count();
|
||||
}
|
||||
|
||||
getRowFirstCell(name: string, location: string = '') {
|
||||
@ -196,28 +196,28 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async getItemNameTooltip(name: string, location: string = '') {
|
||||
return await this.getRowNameCellSpan(name, location).getAttribute('title');
|
||||
return this.getRowNameCellSpan(name, location).getAttribute('title');
|
||||
}
|
||||
|
||||
async hasCheckMarkIcon(itemName: string, location: string = '') {
|
||||
const row = this.getRowByName(itemName, location);
|
||||
return await row.element(by.css(DataTable.selectors.selectedIcon)).isPresent();
|
||||
return row.element(by.css(DataTable.selectors.selectedIcon)).isPresent();
|
||||
}
|
||||
|
||||
async hasLockIcon(itemName: string, location: string = '') {
|
||||
const row = this.getRowByName(itemName, location);
|
||||
return await row.element(by.css(DataTable.selectors.lockIcon)).isPresent();
|
||||
return row.element(by.css(DataTable.selectors.lockIcon)).isPresent();
|
||||
}
|
||||
|
||||
async hasLockOwnerInfo(itemName: string, location: string = '') {
|
||||
const row = this.getRowByName(itemName, location);
|
||||
return await row.element(by.css(DataTable.selectors.lockOwner)).isPresent();
|
||||
return row.element(by.css(DataTable.selectors.lockOwner)).isPresent();
|
||||
}
|
||||
|
||||
async getLockOwner(itemName: string, location: string = '') {
|
||||
if (await this.hasLockOwnerInfo(itemName, location)) {
|
||||
const row = this.getRowByName(itemName, location);
|
||||
return await row.$(DataTable.selectors.lockOwner).$('.locked_by--name').getText();
|
||||
return row.$(DataTable.selectors.lockOwner).$('.locked_by--name').getText();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@ -227,7 +227,7 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async hasLinkOnName(itemName: string) {
|
||||
return await this.getNameLink(itemName).isPresent();
|
||||
return this.getNameLink(itemName).isPresent();
|
||||
}
|
||||
|
||||
// Navigation/selection methods
|
||||
@ -303,7 +303,7 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async getItemLocation(name: string) {
|
||||
return await this.getItemLocationEl(name).getText();
|
||||
return this.getItemLocationEl(name).getText();
|
||||
}
|
||||
|
||||
async getItemLocationTooltip(name: string) {
|
||||
@ -313,7 +313,7 @@ export class DataTable extends Component {
|
||||
await browser.actions().mouseMove(location).perform();
|
||||
|
||||
await browser.wait(condition, BROWSER_WAIT_TIMEOUT);
|
||||
return await location.getAttribute('title');
|
||||
return location.getAttribute('title');
|
||||
}
|
||||
|
||||
async clickItemLocation(name: string) {
|
||||
@ -322,17 +322,17 @@ export class DataTable extends Component {
|
||||
|
||||
// empty state methods
|
||||
async isEmptyList() {
|
||||
return await this.emptyList.isPresent();
|
||||
return this.emptyList.isPresent();
|
||||
}
|
||||
|
||||
async isEmptyWithDragAndDrop() {
|
||||
return await this.emptyFolderDragAndDrop.isDisplayed();
|
||||
return this.emptyFolderDragAndDrop.isDisplayed();
|
||||
}
|
||||
|
||||
async getEmptyDragAndDropText(): Promise<string> {
|
||||
const isEmpty = await this.isEmptyWithDragAndDrop();
|
||||
if (isEmpty) {
|
||||
return await this.emptyFolderDragAndDrop.getText();
|
||||
return this.emptyFolderDragAndDrop.getText();
|
||||
}
|
||||
|
||||
return '';
|
||||
@ -341,7 +341,7 @@ export class DataTable extends Component {
|
||||
async getEmptyStateTitle(): Promise<string> {
|
||||
const isEmpty = await this.isEmptyList();
|
||||
if (isEmpty) {
|
||||
return await this.emptyListTitle.getText();
|
||||
return this.emptyListTitle.getText();
|
||||
}
|
||||
|
||||
return '';
|
||||
@ -350,7 +350,7 @@ export class DataTable extends Component {
|
||||
async getEmptyStateSubtitle(): Promise<string> {
|
||||
const isEmpty = await this.isEmptyList();
|
||||
if (isEmpty) {
|
||||
return await this.emptyListSubtitle.getText();
|
||||
return this.emptyListSubtitle.getText();
|
||||
}
|
||||
|
||||
return '';
|
||||
@ -359,14 +359,14 @@ export class DataTable extends Component {
|
||||
async getEmptyStateText(): Promise<string> {
|
||||
const isEmpty = await this.isEmptyList();
|
||||
if (isEmpty) {
|
||||
return await this.emptyListText.getText();
|
||||
return this.emptyListText.getText();
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
async getEmptySearchResultsText() {
|
||||
return await this.emptySearchText.getText();
|
||||
return this.emptySearchText.getText();
|
||||
}
|
||||
|
||||
async getCellsContainingName(name: string) {
|
||||
@ -380,11 +380,11 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async getLibraryRole(name: string) {
|
||||
return await this.getRowByName(name).element(by.css(DataTable.selectors.libraryRole)).getText();
|
||||
return this.getRowByName(name).element(by.css(DataTable.selectors.libraryRole)).getText();
|
||||
}
|
||||
|
||||
async isItemPresent(name: string, location? : string) {
|
||||
return await this.getRowByName(name, location).isPresent();
|
||||
return this.getRowByName(name, location).isPresent();
|
||||
}
|
||||
|
||||
async getEntireDataTableText() {
|
||||
@ -423,7 +423,7 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async getSearchResultLinesCount(name: string, location: string = '') {
|
||||
return await this.getSearchResultRowLines(name, location).count();
|
||||
return this.getSearchResultRowLines(name, location).count();
|
||||
}
|
||||
|
||||
getSearchResultNthLine(name: string, location: string = '', index: number) {
|
||||
@ -431,19 +431,19 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async getSearchResultNameAndTitle(name: string, location: string = '') {
|
||||
return await this.getSearchResultNthLine(name, location, 0).getText();
|
||||
return this.getSearchResultNthLine(name, location, 0).getText();
|
||||
}
|
||||
|
||||
async getSearchResultDescription(name: string, location: string = '') {
|
||||
return await this.getSearchResultNthLine(name, location, 1).getText();
|
||||
return this.getSearchResultNthLine(name, location, 1).getText();
|
||||
}
|
||||
|
||||
async getSearchResultModified(name: string, location: string = '') {
|
||||
return await this.getSearchResultNthLine(name, location, 2).getText();
|
||||
return this.getSearchResultNthLine(name, location, 2).getText();
|
||||
}
|
||||
|
||||
async getSearchResultLocation(name: string, location: string = '') {
|
||||
return await this.getSearchResultNthLine(name, location, 3).getText();
|
||||
return this.getSearchResultNthLine(name, location, 3).getText();
|
||||
}
|
||||
|
||||
getSearchResultNameLink(itemName: string, location: string = '') {
|
||||
@ -451,7 +451,7 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
async hasLinkOnSearchResultName(itemName: string, location: string = '') {
|
||||
return await this.getSearchResultNameLink(itemName, location).isPresent();
|
||||
return this.getSearchResultNameLink(itemName, location).isPresent();
|
||||
}
|
||||
|
||||
async clickSearchResultNameLink(itemName: string, location: string = '') {
|
||||
|
@ -61,15 +61,15 @@ export class DateTimePicker extends Component {
|
||||
}
|
||||
|
||||
async isCalendarOpen() {
|
||||
return await browser.isElementPresent(by.css(DateTimePicker.selectors.root));
|
||||
return browser.isElementPresent(by.css(DateTimePicker.selectors.root));
|
||||
}
|
||||
|
||||
async getDate() {
|
||||
return await this.headerDate.getText();
|
||||
return this.headerDate.getText();
|
||||
}
|
||||
|
||||
async getYear() {
|
||||
return await this.headerYear.getText();
|
||||
return this.headerYear.getText();
|
||||
}
|
||||
|
||||
async setDefaultDay() {
|
||||
|
@ -57,15 +57,15 @@ export class ConfirmDialog extends Component {
|
||||
}
|
||||
|
||||
async isDialogOpen() {
|
||||
return await browser.isElementPresent(by.css(ConfirmDialog.selectors.root));
|
||||
return browser.isElementPresent(by.css(ConfirmDialog.selectors.root));
|
||||
}
|
||||
|
||||
async getTitle() {
|
||||
return await this.title.getText();
|
||||
return this.title.getText();
|
||||
}
|
||||
|
||||
async getText() {
|
||||
return await this.content.getText();
|
||||
return this.content.getText();
|
||||
}
|
||||
|
||||
getButtonByName(name: string) {
|
||||
@ -79,49 +79,49 @@ export class ConfirmDialog extends Component {
|
||||
|
||||
async isButtonEnabled(name: string) {
|
||||
const button = this.getButtonByName(name);
|
||||
return await button.isEnabled();
|
||||
return button.isEnabled();
|
||||
}
|
||||
|
||||
|
||||
async isOkEnabled() {
|
||||
return await this.isButtonEnabled('OK');
|
||||
return this.isButtonEnabled('OK');
|
||||
}
|
||||
|
||||
async isCancelEnabled() {
|
||||
return await this.isButtonEnabled('Cancel');
|
||||
return this.isButtonEnabled('Cancel');
|
||||
}
|
||||
|
||||
async isKeepEnabled() {
|
||||
return await this.isButtonEnabled('Keep');
|
||||
return this.isButtonEnabled('Keep');
|
||||
}
|
||||
|
||||
async isDeleteEnabled() {
|
||||
return await this.isButtonEnabled('Delete');
|
||||
return this.isButtonEnabled('Delete');
|
||||
}
|
||||
|
||||
async isRemoveEnabled() {
|
||||
return await this.isButtonEnabled('Remove');
|
||||
return this.isButtonEnabled('Remove');
|
||||
}
|
||||
|
||||
|
||||
async clickOk() {
|
||||
return await this.clickButton('OK');
|
||||
await this.clickButton('OK');
|
||||
}
|
||||
|
||||
async clickCancel() {
|
||||
return await this.cancelButton.click();
|
||||
await this.cancelButton.click();
|
||||
}
|
||||
|
||||
async clickKeep() {
|
||||
return await this.clickButton('Keep');
|
||||
await this.clickButton('Keep');
|
||||
}
|
||||
|
||||
async clickDelete() {
|
||||
return await this.clickButton('Delete');
|
||||
await this.clickButton('Delete');
|
||||
}
|
||||
|
||||
async clickRemove() {
|
||||
return await this.clickButton('Remove');
|
||||
await this.clickButton('Remove');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -78,11 +78,11 @@ export class CopyMoveDialog extends Component {
|
||||
}
|
||||
|
||||
async isDialogOpen() {
|
||||
return await browser.$(CopyMoveDialog.selectors.root).isDisplayed();
|
||||
return browser.$(CopyMoveDialog.selectors.root).isDisplayed();
|
||||
}
|
||||
|
||||
async getTitle() {
|
||||
return await this.title.getText();
|
||||
return this.title.getText();
|
||||
}
|
||||
|
||||
async clickCancel() {
|
||||
|
@ -61,15 +61,15 @@ export class CreateOrEditFolderDialog extends Component {
|
||||
}
|
||||
|
||||
async isDialogOpen() {
|
||||
return await browser.isElementPresent(by.css(CreateOrEditFolderDialog.selectors.root));
|
||||
return browser.isElementPresent(by.css(CreateOrEditFolderDialog.selectors.root));
|
||||
}
|
||||
|
||||
async getTitle() {
|
||||
return await this.title.getText();
|
||||
return this.title.getText();
|
||||
}
|
||||
|
||||
async isValidationMessageDisplayed() {
|
||||
return await this.validationMessage.isDisplayed();
|
||||
return this.validationMessage.isDisplayed();
|
||||
}
|
||||
|
||||
async isUpdateButtonEnabled() {
|
||||
@ -85,24 +85,24 @@ export class CreateOrEditFolderDialog extends Component {
|
||||
}
|
||||
|
||||
async isNameDisplayed() {
|
||||
return await this.nameInput.isDisplayed();
|
||||
return this.nameInput.isDisplayed();
|
||||
}
|
||||
|
||||
async isDescriptionDisplayed() {
|
||||
return await this.descriptionTextArea.isDisplayed();
|
||||
return this.descriptionTextArea.isDisplayed();
|
||||
}
|
||||
|
||||
async getValidationMessage() {
|
||||
await this.isValidationMessageDisplayed();
|
||||
return await this.validationMessage.getText();
|
||||
return this.validationMessage.getText();
|
||||
}
|
||||
|
||||
async getName() {
|
||||
return await this.nameInput.getAttribute('value');
|
||||
return this.nameInput.getAttribute('value');
|
||||
}
|
||||
|
||||
async getDescription() {
|
||||
return await this.descriptionTextArea.getAttribute('value');
|
||||
return this.descriptionTextArea.getAttribute('value');
|
||||
}
|
||||
|
||||
async enterName(name: string) {
|
||||
|
@ -67,44 +67,44 @@ export class CreateLibraryDialog extends Component {
|
||||
}
|
||||
|
||||
async isDialogOpen() {
|
||||
return await browser.isElementPresent(by.css(CreateLibraryDialog.selectors.root));
|
||||
return browser.isElementPresent(by.css(CreateLibraryDialog.selectors.root));
|
||||
}
|
||||
|
||||
async getTitle() {
|
||||
return await this.title.getText();
|
||||
return this.title.getText();
|
||||
}
|
||||
|
||||
async isErrorMessageDisplayed() {
|
||||
return await this.errorMessage.isDisplayed();
|
||||
return this.errorMessage.isDisplayed();
|
||||
}
|
||||
|
||||
async getErrorMessage() {
|
||||
await this.isErrorMessageDisplayed();
|
||||
return await this.errorMessage.getText();
|
||||
return this.errorMessage.getText();
|
||||
}
|
||||
|
||||
async isNameDisplayed() {
|
||||
return await this.nameInput.isDisplayed();
|
||||
return this.nameInput.isDisplayed();
|
||||
}
|
||||
|
||||
async isLibraryIdDisplayed() {
|
||||
return await this.libraryIdInput.isDisplayed();
|
||||
return this.libraryIdInput.isDisplayed();
|
||||
}
|
||||
|
||||
async isDescriptionDisplayed() {
|
||||
return await this.descriptionTextArea.isDisplayed();
|
||||
return this.descriptionTextArea.isDisplayed();
|
||||
}
|
||||
|
||||
async isPublicDisplayed() {
|
||||
return await this.visibilityPublic.isDisplayed();
|
||||
return this.visibilityPublic.isDisplayed();
|
||||
}
|
||||
|
||||
async isModeratedDisplayed() {
|
||||
return await this.visibilityModerated.isDisplayed();
|
||||
return this.visibilityModerated.isDisplayed();
|
||||
}
|
||||
|
||||
async isPrivateDisplayed() {
|
||||
return await this.visibilityPrivate.isDisplayed();
|
||||
return this.visibilityPrivate.isDisplayed();
|
||||
}
|
||||
|
||||
async enterName(name: string) {
|
||||
@ -128,11 +128,11 @@ export class CreateLibraryDialog extends Component {
|
||||
}
|
||||
|
||||
async isCreateEnabled() {
|
||||
return await this.createButton.isEnabled();
|
||||
return this.createButton.isEnabled();
|
||||
}
|
||||
|
||||
async isCancelEnabled() {
|
||||
return await this.cancelButton.isEnabled();
|
||||
return this.cancelButton.isEnabled();
|
||||
}
|
||||
|
||||
async clickCreate() {
|
||||
@ -146,17 +146,17 @@ export class CreateLibraryDialog extends Component {
|
||||
|
||||
async isPublicChecked() {
|
||||
const elemClass = await this.visibilityPublic.element(by.xpath('..')).getAttribute('class');
|
||||
return await elemClass.includes(CreateLibraryDialog.selectors.radioChecked);
|
||||
return elemClass.includes(CreateLibraryDialog.selectors.radioChecked);
|
||||
}
|
||||
|
||||
async isModeratedChecked() {
|
||||
const elemClass = await this.visibilityModerated.element(by.xpath('..')).getAttribute('class');
|
||||
return await elemClass.includes(CreateLibraryDialog.selectors.radioChecked);
|
||||
return elemClass.includes(CreateLibraryDialog.selectors.radioChecked);
|
||||
}
|
||||
|
||||
async isPrivateChecked() {
|
||||
const elemClass = await this.visibilityPrivate.element(by.xpath('..')).getAttribute('class');
|
||||
return await elemClass.includes(CreateLibraryDialog.selectors.radioChecked);
|
||||
return elemClass.includes(CreateLibraryDialog.selectors.radioChecked);
|
||||
}
|
||||
|
||||
async selectPublic() {
|
||||
|
@ -45,19 +45,19 @@ export class ManageVersionsDialog extends Component {
|
||||
}
|
||||
|
||||
async waitForDialogToClose() {
|
||||
return await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT);
|
||||
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
|
||||
async isDialogOpen() {
|
||||
return await browser.$(ManageVersionsDialog.selectors.root).isDisplayed();
|
||||
return browser.$(ManageVersionsDialog.selectors.root).isDisplayed();
|
||||
}
|
||||
|
||||
async getTitle() {
|
||||
return await this.title.getText();
|
||||
return this.title.getText();
|
||||
}
|
||||
|
||||
async getText() {
|
||||
return await this.content.getText();
|
||||
return this.content.getText();
|
||||
}
|
||||
|
||||
async clickClose() {
|
||||
|
@ -58,33 +58,33 @@ export class PasswordDialog extends Component {
|
||||
}
|
||||
|
||||
async isDialogOpen() {
|
||||
return await browser.isElementPresent(by.css(PasswordDialog.selectors.root));
|
||||
return browser.isElementPresent(by.css(PasswordDialog.selectors.root));
|
||||
}
|
||||
|
||||
async getTitle() {
|
||||
return await this.title.getText();
|
||||
return this.title.getText();
|
||||
}
|
||||
|
||||
async isCloseEnabled() {
|
||||
return await this.closeButton.isEnabled();
|
||||
return this.closeButton.isEnabled();
|
||||
}
|
||||
|
||||
async isSubmitEnabled() {
|
||||
return await this.submitButton.isEnabled();
|
||||
return this.submitButton.isEnabled();
|
||||
}
|
||||
|
||||
async clickClose() {
|
||||
return await this.closeButton.click();
|
||||
await this.closeButton.click();
|
||||
}
|
||||
|
||||
async clickSubmit() {
|
||||
return await this.submitButton.click();
|
||||
await this.submitButton.click();
|
||||
}
|
||||
|
||||
async isPasswordInputDisplayed() {
|
||||
const present = await browser.isElementPresent(this.passwordInput);
|
||||
if (present) {
|
||||
return await this.passwordInput.isDisplayed();
|
||||
return this.passwordInput.isDisplayed();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -92,12 +92,12 @@ export class PasswordDialog extends Component {
|
||||
|
||||
async isErrorDisplayed() {
|
||||
const elem = await browser.wait(until.elementLocated(by.css(PasswordDialog.selectors.errorMessage)), BROWSER_WAIT_TIMEOUT, '------- timeout waiting for error message to appear')
|
||||
return await browser.isElementPresent(elem);
|
||||
return browser.isElementPresent(elem);
|
||||
}
|
||||
|
||||
async getErrorMessage() {
|
||||
if (await this.isErrorDisplayed()) {
|
||||
return await this.errorMessage.getText();
|
||||
return this.errorMessage.getText();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
@ -71,15 +71,15 @@ export class ShareDialog extends Component {
|
||||
}
|
||||
|
||||
async isDialogOpen() {
|
||||
return await browser.isElementPresent(by.css(ShareDialog.selectors.root));
|
||||
return browser.isElementPresent(by.css(ShareDialog.selectors.root));
|
||||
}
|
||||
|
||||
async getTitle() {
|
||||
return await this.title.getText();
|
||||
return this.title.getText();
|
||||
}
|
||||
|
||||
async getInfoText() {
|
||||
return await this.infoText.getText();
|
||||
return this.infoText.getText();
|
||||
}
|
||||
|
||||
getLabels() {
|
||||
@ -87,15 +87,15 @@ export class ShareDialog extends Component {
|
||||
}
|
||||
|
||||
async getLinkUrl() {
|
||||
return await this.url.getAttribute('value');
|
||||
return this.url.getAttribute('value');
|
||||
}
|
||||
|
||||
async isUrlReadOnly() {
|
||||
return await this.url.getAttribute('readonly');
|
||||
return this.url.getAttribute('readonly');
|
||||
}
|
||||
|
||||
async isCloseEnabled() {
|
||||
return await this.closeButton.isEnabled();
|
||||
return this.closeButton.isEnabled();
|
||||
}
|
||||
|
||||
async clickClose() {
|
||||
@ -131,21 +131,21 @@ export class ShareDialog extends Component {
|
||||
}
|
||||
|
||||
async copyUrl() {
|
||||
return await this.urlAction.click();
|
||||
await this.urlAction.click();
|
||||
}
|
||||
|
||||
async openDatetimePicker() {
|
||||
return await this.datetimePickerButton.click();
|
||||
await this.datetimePickerButton.click();
|
||||
}
|
||||
|
||||
async closeDatetimePicker() {
|
||||
if (await this.dateTimePicker.isCalendarOpen()) {
|
||||
return await this.datetimePickerButton.click();
|
||||
await this.datetimePickerButton.click();
|
||||
}
|
||||
}
|
||||
|
||||
async getExpireDate() {
|
||||
return await this.getExpireInput().getAttribute('value');
|
||||
return this.getExpireInput().getAttribute('value');
|
||||
}
|
||||
|
||||
async clickExpirationToggle() {
|
||||
|
@ -56,32 +56,32 @@ export class UploadNewVersionDialog extends Component {
|
||||
}
|
||||
|
||||
async waitForDialogToClose() {
|
||||
return await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT);
|
||||
await browser.wait(EC.stalenessOf(this.title), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
|
||||
async isDialogOpen() {
|
||||
return await browser.$(UploadNewVersionDialog.selectors.root).isDisplayed();
|
||||
return browser.$(UploadNewVersionDialog.selectors.root).isDisplayed();
|
||||
}
|
||||
|
||||
async getTitle() {
|
||||
return await this.title.getText();
|
||||
return this.title.getText();
|
||||
}
|
||||
|
||||
async getText() {
|
||||
return await this.content.getText();
|
||||
return this.content.getText();
|
||||
}
|
||||
|
||||
|
||||
async isDescriptionDisplayed() {
|
||||
return await this.description.isDisplayed();
|
||||
return this.description.isDisplayed();
|
||||
}
|
||||
|
||||
async isMinorOptionDisplayed() {
|
||||
return await this.minorOption.isDisplayed();
|
||||
return this.minorOption.isDisplayed();
|
||||
}
|
||||
|
||||
async isMajorOptionDisplayed() {
|
||||
return await this.majorOption.isDisplayed();
|
||||
return this.majorOption.isDisplayed();
|
||||
}
|
||||
|
||||
async isCancelButtonEnabled() {
|
||||
@ -105,11 +105,11 @@ export class UploadNewVersionDialog extends Component {
|
||||
|
||||
|
||||
async clickMajor() {
|
||||
return await this.majorOption.click();
|
||||
await this.majorOption.click();
|
||||
}
|
||||
|
||||
async clickMinor() {
|
||||
return await this.minorOption.click();
|
||||
await this.minorOption.click();
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,19 +62,19 @@ export class Header extends Component {
|
||||
}
|
||||
|
||||
async isSignOutDisplayed() {
|
||||
return await this.userInfo.menu.isMenuItemPresent('Sign out');
|
||||
return this.userInfo.menu.isMenuItemPresent('Sign out');
|
||||
}
|
||||
|
||||
async clickSidenavToggle() {
|
||||
await this.sidenavToggle.click();
|
||||
}
|
||||
|
||||
async isExpandedSidenav() {
|
||||
return await browser.isElementPresent(Header.selectors.expandedSidenav);
|
||||
async isSidenavExpanded() {
|
||||
return browser.isElementPresent(Header.selectors.expandedSidenav);
|
||||
}
|
||||
|
||||
async expandSideNav() {
|
||||
const expanded = await this.isExpandedSidenav();
|
||||
const expanded = await this.isSidenavExpanded();
|
||||
if ( !expanded ) {
|
||||
await this.clickSidenavToggle();
|
||||
await browser.wait(until.elementLocated(Header.selectors.expandedSidenav), BROWSER_WAIT_TIMEOUT, '--- timeout waiting for expanded sidenav' );
|
||||
@ -82,7 +82,7 @@ export class Header extends Component {
|
||||
}
|
||||
|
||||
async collapseSideNav() {
|
||||
const expanded = await this.isExpandedSidenav();
|
||||
const expanded = await this.isSidenavExpanded();
|
||||
if ( expanded ) {
|
||||
await this.clickSidenavToggle();
|
||||
await browser.wait(until.elementLocated(Header.selectors.collapsedSidenav), BROWSER_WAIT_TIMEOUT, '--- timeout waiting for collapsed sidenav')
|
||||
|
@ -67,73 +67,73 @@ export class CommentsTab extends Component {
|
||||
}
|
||||
|
||||
async getCommentsTabHeaderText() {
|
||||
return await this.commentsHeader.getText();
|
||||
return this.commentsHeader.getText();
|
||||
}
|
||||
|
||||
async isCommentTextAreaDisplayed() {
|
||||
return await browser.isElementPresent(this.commentTextarea);
|
||||
return browser.isElementPresent(this.commentTextarea);
|
||||
}
|
||||
|
||||
async isAddCommentButtonEnabled() {
|
||||
const present = await browser.isElementPresent(this.addCommentButton);
|
||||
if (present) {
|
||||
return await this.addCommentButton.isEnabled();
|
||||
return this.addCommentButton.isEnabled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async getCommentListItem() {
|
||||
return await browser.wait(until.elementLocated(this.commentListItem), BROWSER_WAIT_TIMEOUT / 2);
|
||||
return browser.wait(until.elementLocated(this.commentListItem), BROWSER_WAIT_TIMEOUT / 2);
|
||||
}
|
||||
|
||||
async getCommentById(commentId?: string) {
|
||||
if (commentId) {
|
||||
return await browser.wait(until.elementLocated(by.id(`${CommentsTab.selectors.commentById}${commentId}`)), BROWSER_WAIT_TIMEOUT / 2);
|
||||
return browser.wait(until.elementLocated(by.id(`${CommentsTab.selectors.commentById}${commentId}`)), BROWSER_WAIT_TIMEOUT / 2);
|
||||
}
|
||||
return await this.getCommentListItem();
|
||||
return this.getCommentListItem();
|
||||
}
|
||||
|
||||
async isCommentDisplayed(commentId?: string) {
|
||||
return await browser.isElementPresent(await this.getCommentById(commentId));
|
||||
return browser.isElementPresent(await this.getCommentById(commentId));
|
||||
}
|
||||
|
||||
async isCommentUserAvatarDisplayed(commentId?: string) {
|
||||
const commentElement = await this.getCommentById(commentId);
|
||||
return await browser.isElementPresent(commentElement.findElement(this.commentUserAvatar));
|
||||
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 await message.getText();
|
||||
return message.getText();
|
||||
}
|
||||
|
||||
async getCommentUserName(commentId?: string) {
|
||||
const commentElement = await this.getCommentById(commentId);
|
||||
const user = await commentElement.findElement(this.commentUser);
|
||||
return await user.getText();
|
||||
return user.getText();
|
||||
}
|
||||
|
||||
async getCommentTime(commentId?: string) {
|
||||
const commentElement = await this.getCommentById(commentId);
|
||||
const time = await commentElement.findElement(this.commentTime);
|
||||
return await time.getText();
|
||||
return time.getText();
|
||||
}
|
||||
|
||||
async getNthCommentId(index: number) {
|
||||
return await this.commentsList.get(index - 1).getAttribute('id');
|
||||
return this.commentsList.get(index - 1).getAttribute('id');
|
||||
}
|
||||
|
||||
async typeComment(text: string) {
|
||||
return await this.commentTextarea.sendKeys(text);
|
||||
await this.commentTextarea.sendKeys(text);
|
||||
}
|
||||
|
||||
async clickAddButton() {
|
||||
return await this.addCommentButton.click();
|
||||
await this.addCommentButton.click();
|
||||
}
|
||||
|
||||
async getCommentTextFromTextArea() {
|
||||
return await this.commentTextarea.getAttribute('value');
|
||||
return this.commentTextarea.getAttribute('value');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,11 +58,11 @@ export class ContentMetadata extends Component {
|
||||
}
|
||||
|
||||
async isPropertiesListExpanded() {
|
||||
return await browser.isElementPresent(this.expandedPanel);
|
||||
return browser.isElementPresent(this.expandedPanel);
|
||||
}
|
||||
|
||||
async waitForImagePropertiesPanelToExpand() {
|
||||
return await browser.wait(EC.visibilityOf(this.expandedImagePropertiesPanel), BROWSER_WAIT_TIMEOUT);
|
||||
await browser.wait(EC.visibilityOf(this.expandedImagePropertiesPanel), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
|
||||
async getVisiblePropertiesLabels() {
|
||||
@ -98,19 +98,19 @@ export class ContentMetadata extends Component {
|
||||
}
|
||||
|
||||
async isLessInfoButtonDisplayed() {
|
||||
return await browser.isElementPresent(this.lessInfoButton);
|
||||
return browser.isElementPresent(this.lessInfoButton);
|
||||
}
|
||||
|
||||
async isMoreInfoButtonDisplayed() {
|
||||
return await browser.isElementPresent(this.moreInfoButton);
|
||||
return browser.isElementPresent(this.moreInfoButton);
|
||||
}
|
||||
|
||||
async clickLessInformationButton() {
|
||||
return await this.lessInfoButton.click();
|
||||
await this.lessInfoButton.click();
|
||||
}
|
||||
|
||||
async clickMoreInformationButton() {
|
||||
return await this.moreInfoButton.click();
|
||||
await this.moreInfoButton.click();
|
||||
}
|
||||
|
||||
async isImagePropertiesPanelDisplayed() {
|
||||
@ -118,7 +118,7 @@ export class ContentMetadata extends Component {
|
||||
}
|
||||
|
||||
async clickImagePropertiesPanel() {
|
||||
return await this.imagePropertiesPanel.click();
|
||||
await this.imagePropertiesPanel.click();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ export class LibraryMetadata extends Component {
|
||||
}
|
||||
|
||||
async isFieldDisplayed(fieldName: string) {
|
||||
return await browser.isElementPresent(this.getFieldByName(fieldName));
|
||||
return browser.isElementPresent(this.getFieldByName(fieldName));
|
||||
}
|
||||
|
||||
async isInputEnabled(fieldName: string) {
|
||||
@ -80,13 +80,13 @@ export class LibraryMetadata extends Component {
|
||||
}
|
||||
|
||||
async getValueOfField(fieldName: string) {
|
||||
return await this.getFieldByName(fieldName).getText();
|
||||
return this.getFieldByName(fieldName).getText();
|
||||
}
|
||||
|
||||
async enterTextInInput(fieldName: string, text: string) {
|
||||
const input = this.getFieldByName(fieldName);
|
||||
await input.clear();
|
||||
return await input.sendKeys(text);
|
||||
await input.sendKeys(text);
|
||||
}
|
||||
|
||||
|
||||
@ -99,11 +99,11 @@ export class LibraryMetadata extends Component {
|
||||
}
|
||||
|
||||
async isButtonEnabled(button: string) {
|
||||
return await this.getButton(button).isEnabled();
|
||||
return this.getButton(button).isEnabled();
|
||||
}
|
||||
|
||||
async clickButton(button: string) {
|
||||
return await this.getButton(button).click();
|
||||
await this.getButton(button).click();
|
||||
}
|
||||
|
||||
async waitForVisibilityDropDownToOpen() {
|
||||
@ -115,68 +115,68 @@ export class LibraryMetadata extends Component {
|
||||
}
|
||||
|
||||
async isMessageDisplayed() {
|
||||
return await browser.isElementPresent(this.hint);
|
||||
return browser.isElementPresent(this.hint);
|
||||
}
|
||||
|
||||
async getMessage() {
|
||||
return await this.hint.getText();
|
||||
return this.hint.getText();
|
||||
}
|
||||
|
||||
async isErrorDisplayed() {
|
||||
return await browser.isElementPresent(this.error);
|
||||
return browser.isElementPresent(this.error);
|
||||
}
|
||||
|
||||
async getError() {
|
||||
return await this.error.getText();
|
||||
return this.error.getText();
|
||||
}
|
||||
|
||||
|
||||
async isNameDisplayed() {
|
||||
return await this.isFieldDisplayed('Name');
|
||||
return this.isFieldDisplayed('Name');
|
||||
}
|
||||
|
||||
async isNameEnabled() {
|
||||
return await this.isInputEnabled('Name');
|
||||
return this.isInputEnabled('Name');
|
||||
}
|
||||
|
||||
async getName() {
|
||||
return await this.getValueOfField('Name');
|
||||
return this.getValueOfField('Name');
|
||||
}
|
||||
|
||||
async enterName(name: string) {
|
||||
return await this.enterTextInInput('Name', name);
|
||||
await this.enterTextInInput('Name', name);
|
||||
}
|
||||
|
||||
|
||||
async isDescriptionDisplayed() {
|
||||
return await this.isFieldDisplayed('Description');
|
||||
return this.isFieldDisplayed('Description');
|
||||
}
|
||||
|
||||
async isDescriptionEnabled() {
|
||||
return await this.isInputEnabled('Description');
|
||||
return this.isInputEnabled('Description');
|
||||
}
|
||||
|
||||
async getDescription() {
|
||||
return await this.getValueOfField('Description');
|
||||
return this.getValueOfField('Description');
|
||||
}
|
||||
|
||||
async enterDescription(desc: string) {
|
||||
return await this.enterTextInInput('Description', desc);
|
||||
await this.enterTextInInput('Description', desc);
|
||||
}
|
||||
|
||||
|
||||
async isVisibilityEnabled() {
|
||||
const wrapper = this.getLabelWrapper('Visibility');
|
||||
const field = wrapper.element(by.xpath('..')).element(by.css(LibraryMetadata.selectors.dropDown));
|
||||
return await field.isEnabled();
|
||||
return field.isEnabled();
|
||||
}
|
||||
|
||||
async isVisibilityDisplayed() {
|
||||
return await this.isFieldDisplayed('Visibility');
|
||||
return this.isFieldDisplayed('Visibility');
|
||||
}
|
||||
|
||||
async getVisibility() {
|
||||
return await this.getValueOfField('Visibility');
|
||||
return this.getValueOfField('Visibility');
|
||||
}
|
||||
|
||||
async setVisibility(visibility: string) {
|
||||
@ -200,54 +200,54 @@ export class LibraryMetadata extends Component {
|
||||
|
||||
|
||||
async isLibraryIdDisplayed() {
|
||||
return await this.isFieldDisplayed('Library ID');
|
||||
return this.isFieldDisplayed('Library ID');
|
||||
}
|
||||
|
||||
async isLibraryIdEnabled() {
|
||||
return await this.isInputEnabled('Library ID');
|
||||
return this.isInputEnabled('Library ID');
|
||||
}
|
||||
|
||||
async getLibraryId() {
|
||||
return await this.getValueOfField('Library ID');
|
||||
return this.getValueOfField('Library ID');
|
||||
}
|
||||
|
||||
|
||||
async isEditLibraryPropertiesEnabled() {
|
||||
return await this.isButtonEnabled('Edit');
|
||||
return this.isButtonEnabled('Edit');
|
||||
}
|
||||
|
||||
async isEditLibraryPropertiesDisplayed() {
|
||||
return await this.isButtonDisplayed('Edit');
|
||||
return this.isButtonDisplayed('Edit');
|
||||
}
|
||||
|
||||
async clickEditLibraryProperties() {
|
||||
return await this.clickButton('Edit');
|
||||
await this.clickButton('Edit');
|
||||
}
|
||||
|
||||
|
||||
async isUpdateEnabled() {
|
||||
return await this.isButtonEnabled('Update');
|
||||
return this.isButtonEnabled('Update');
|
||||
}
|
||||
|
||||
async isUpdateDisplayed() {
|
||||
return await this.isButtonDisplayed('Update');
|
||||
return this.isButtonDisplayed('Update');
|
||||
}
|
||||
|
||||
async clickUpdate() {
|
||||
return await this.clickButton('Update');
|
||||
await this.clickButton('Update');
|
||||
}
|
||||
|
||||
|
||||
async isCancelEnabled() {
|
||||
return await this.isButtonEnabled('Cancel');
|
||||
return this.isButtonEnabled('Cancel');
|
||||
}
|
||||
|
||||
async isCancelDisplayed() {
|
||||
return await this.isButtonDisplayed('Cancel');
|
||||
return this.isButtonDisplayed('Cancel');
|
||||
}
|
||||
|
||||
async clickCancel() {
|
||||
return await this.clickButton('Cancel');
|
||||
await this.clickButton('Cancel');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -69,11 +69,11 @@ export class InfoDrawer extends Component {
|
||||
}
|
||||
|
||||
async waitForInfoDrawerToOpen() {
|
||||
return await browser.wait(EC.presenceOf(this.header), BROWSER_WAIT_TIMEOUT);
|
||||
await browser.wait(EC.presenceOf(this.header), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
|
||||
async isOpen() {
|
||||
return await browser.isElementPresent(this.header);
|
||||
return browser.isElementPresent(this.header);
|
||||
}
|
||||
|
||||
async isEmpty() {
|
||||
@ -85,27 +85,27 @@ export class InfoDrawer extends Component {
|
||||
}
|
||||
|
||||
async getTabsCount() {
|
||||
return await this.component.all(by.css(InfoDrawer.selectors.tabLabel)).count();
|
||||
return this.component.all(by.css(InfoDrawer.selectors.tabLabel)).count();
|
||||
}
|
||||
|
||||
async isTabPresent(title: string) {
|
||||
return await this.getTabByTitle(title).isPresent();
|
||||
return this.getTabByTitle(title).isPresent();
|
||||
}
|
||||
|
||||
async isTabDisplayed(title: string): Promise<boolean> {
|
||||
if (await browser.isElementPresent(this.getTabByTitle(title))) {
|
||||
return await this.getTabByTitle(title).isDisplayed();
|
||||
return this.getTabByTitle(title).isDisplayed();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
async getTabTitle(index: number) {
|
||||
return await this.tabLabelsList.get(index - 1).getAttribute('innerText');
|
||||
return this.tabLabelsList.get(index - 1).getAttribute('innerText');
|
||||
}
|
||||
|
||||
async getActiveTabTitle() {
|
||||
return await this.tabActiveLabel.getText();
|
||||
return this.tabActiveLabel.getText();
|
||||
}
|
||||
|
||||
async clickTab(title: string) {
|
||||
@ -113,19 +113,19 @@ export class InfoDrawer extends Component {
|
||||
}
|
||||
|
||||
async getComponentIdOfTab() {
|
||||
return await this.tabActiveContent.getAttribute('data-automation-id');
|
||||
return this.tabActiveContent.getAttribute('data-automation-id');
|
||||
}
|
||||
|
||||
async getHeaderTitle() {
|
||||
return await this.headerTitle.getText();
|
||||
return this.headerTitle.getText();
|
||||
}
|
||||
|
||||
async isAboutTabDisplayed() {
|
||||
return await this.isTabDisplayed('About');
|
||||
return this.isTabDisplayed('About');
|
||||
}
|
||||
|
||||
async isPropertiesTabDisplayed() {
|
||||
return await this.isTabDisplayed('Properties');
|
||||
return this.isTabDisplayed('Properties');
|
||||
}
|
||||
|
||||
async isPropertiesTabActive() {
|
||||
@ -133,7 +133,7 @@ export class InfoDrawer extends Component {
|
||||
}
|
||||
|
||||
async isCommentsTabDisplayed() {
|
||||
return await this.isTabDisplayed('Comments');
|
||||
return this.isTabDisplayed('Comments');
|
||||
}
|
||||
|
||||
async clickCommentsTab() {
|
||||
@ -145,8 +145,7 @@ export class InfoDrawer extends Component {
|
||||
browser.wait(EC.invisibilityOf(this.propertiesTab.component), BROWSER_WAIT_TIMEOUT)
|
||||
]);
|
||||
} catch (error) {
|
||||
console.error('--- catch error on clickCommentsTab ---');
|
||||
throw error;
|
||||
console.error('--- info-drawer clickCommentsTab catch error: ', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ export class LoginComponent extends Component {
|
||||
}
|
||||
|
||||
async clickPasswordVisibility() {
|
||||
return await this.passwordVisibility.click();
|
||||
await this.passwordVisibility.click();
|
||||
}
|
||||
|
||||
async getPasswordVisibility(): Promise<boolean> {
|
||||
@ -105,15 +105,15 @@ export class LoginComponent extends Component {
|
||||
}
|
||||
|
||||
async isUsernameEnabled() {
|
||||
return await this.usernameInput.isEnabled();
|
||||
return this.usernameInput.isEnabled();
|
||||
}
|
||||
|
||||
async isPasswordEnabled() {
|
||||
return await this.passwordInput.isEnabled();
|
||||
return this.passwordInput.isEnabled();
|
||||
}
|
||||
|
||||
async isSubmitEnabled() {
|
||||
return await this.submitButton.isEnabled();
|
||||
return this.submitButton.isEnabled();
|
||||
}
|
||||
|
||||
async isPasswordHidden() {
|
||||
|
@ -112,19 +112,19 @@ export class Menu extends Component {
|
||||
}
|
||||
|
||||
async getItemTooltip(menuItem: string) {
|
||||
return await this.getItemByLabel(menuItem).getAttribute('title');
|
||||
return this.getItemByLabel(menuItem).getAttribute('title');
|
||||
}
|
||||
|
||||
async getItemIconText(menuItem: string) {
|
||||
return await this.getItemByLabel(menuItem).element(by.css(Menu.selectors.icon)).getText();
|
||||
return this.getItemByLabel(menuItem).element(by.css(Menu.selectors.icon)).getText();
|
||||
}
|
||||
|
||||
async getItemIdAttribute(menuItem: string) {
|
||||
return await this.getItemByLabel(menuItem).getAttribute('id');
|
||||
return this.getItemByLabel(menuItem).getAttribute('id');
|
||||
}
|
||||
|
||||
async getItemsCount() {
|
||||
return await this.items.count();
|
||||
return this.items.count();
|
||||
}
|
||||
|
||||
async getMenuItems(): Promise<string[]> {
|
||||
@ -190,15 +190,15 @@ export class Menu extends Component {
|
||||
}
|
||||
|
||||
async isMenuItemPresent(title: string) {
|
||||
return await browser.element(by.cssContainingText(Menu.selectors.item, title)).isPresent();
|
||||
return browser.element(by.cssContainingText(Menu.selectors.item, title)).isPresent();
|
||||
}
|
||||
|
||||
async isSubMenuItemPresent(title: string) {
|
||||
return await browser.element(by.cssContainingText(Menu.selectors.submenu, title)).isPresent();
|
||||
return browser.element(by.cssContainingText(Menu.selectors.submenu, title)).isPresent();
|
||||
}
|
||||
|
||||
async getSubmenuItemsCount() {
|
||||
return await this.submenus.count();
|
||||
return this.submenus.count();
|
||||
}
|
||||
|
||||
async isMenuItemDisabled(title: string): Promise<string | null> {
|
||||
@ -217,7 +217,7 @@ export class Menu extends Component {
|
||||
}
|
||||
|
||||
async clickEditFolder() {
|
||||
return await this.editFolderAction.click();
|
||||
await this.editFolderAction.click();
|
||||
}
|
||||
|
||||
async clickShare() {
|
||||
@ -232,127 +232,126 @@ export class Menu extends Component {
|
||||
|
||||
|
||||
async isViewPresent() {
|
||||
return await this.viewAction.isPresent();
|
||||
return this.viewAction.isPresent();
|
||||
}
|
||||
|
||||
async isDownloadPresent() {
|
||||
return await this.downloadAction.isPresent();
|
||||
return this.downloadAction.isPresent();
|
||||
}
|
||||
|
||||
async isEditFolderPresent() {
|
||||
return await this.editFolderAction.isPresent();
|
||||
return this.editFolderAction.isPresent();
|
||||
}
|
||||
|
||||
async isEditOfflinePresent() {
|
||||
return await this.editOfflineAction.isPresent();
|
||||
return this.editOfflineAction.isPresent();
|
||||
}
|
||||
|
||||
async isCancelEditingPresent() {
|
||||
return await this.cancelEditingAction.isPresent();
|
||||
return this.cancelEditingAction.isPresent();
|
||||
}
|
||||
|
||||
async isCopyPresent() {
|
||||
return await this.copyAction.isPresent();
|
||||
return this.copyAction.isPresent();
|
||||
}
|
||||
|
||||
async isMovePresent() {
|
||||
return await this.moveAction.isPresent();
|
||||
return this.moveAction.isPresent();
|
||||
}
|
||||
|
||||
async isDeletePresent() {
|
||||
return await this.deleteAction.isPresent();
|
||||
return this.deleteAction.isPresent();
|
||||
}
|
||||
|
||||
async isManagePermissionsPresent() {
|
||||
return await this.managePermissionsAction.isPresent();
|
||||
return this.managePermissionsAction.isPresent();
|
||||
}
|
||||
|
||||
async isManageVersionsPresent() {
|
||||
return await this.manageVersionsAction.isPresent();
|
||||
return this.manageVersionsAction.isPresent();
|
||||
}
|
||||
|
||||
async isUploadNewVersionPresent() {
|
||||
return await this.uploadNewVersionAction.isPresent();
|
||||
return this.uploadNewVersionAction.isPresent();
|
||||
}
|
||||
|
||||
async isFavoritePresent() {
|
||||
return await this.favoriteAction.isPresent();
|
||||
return this.favoriteAction.isPresent();
|
||||
}
|
||||
|
||||
async isRemoveFavoritePresent() {
|
||||
return await this.removeFavoriteAction.isPresent();
|
||||
return this.removeFavoriteAction.isPresent();
|
||||
}
|
||||
|
||||
async isToggleFavoritePresent() {
|
||||
return await this.toggleFavoriteAction.isPresent();
|
||||
return this.toggleFavoriteAction.isPresent();
|
||||
}
|
||||
|
||||
async isToggleRemoveFavoritePresent() {
|
||||
return await this.toggleRemoveFavoriteAction.isPresent();
|
||||
return this.toggleRemoveFavoriteAction.isPresent();
|
||||
}
|
||||
|
||||
async isJoinLibraryPresent() {
|
||||
return await this.joinAction.isPresent();
|
||||
return this.joinAction.isPresent();
|
||||
}
|
||||
|
||||
async isCancelJoinPresent() {
|
||||
return await this.cancelJoinAction.isPresent();
|
||||
return this.cancelJoinAction.isPresent();
|
||||
}
|
||||
|
||||
async isLeaveLibraryPresent() {
|
||||
return await this.leaveAction.isPresent();
|
||||
return this.leaveAction.isPresent();
|
||||
}
|
||||
|
||||
async isPermanentDeletePresent() {
|
||||
return await this.permanentDeleteAction.isPresent();
|
||||
return this.permanentDeleteAction.isPresent();
|
||||
}
|
||||
|
||||
async isRestorePresent() {
|
||||
return await this.restoreAction.isPresent();
|
||||
return this.restoreAction.isPresent();
|
||||
}
|
||||
|
||||
async isSharePresent() {
|
||||
return await this.shareAction.isPresent();
|
||||
return this.shareAction.isPresent();
|
||||
}
|
||||
|
||||
async isSharedLinkSettingsPresent() {
|
||||
return await this.shareEditAction.isPresent();
|
||||
return this.shareEditAction.isPresent();
|
||||
}
|
||||
|
||||
async isViewDetailsPresent() {
|
||||
return await this.viewDetailsAction.isPresent();
|
||||
return this.viewDetailsAction.isPresent();
|
||||
}
|
||||
|
||||
async isCreateFolderPresent() {
|
||||
return await this.createFolderAction.isPresent();
|
||||
return this.createFolderAction.isPresent();
|
||||
}
|
||||
async isCreateFolderEnabled() {
|
||||
return await this.createFolderAction.isEnabled();
|
||||
return this.createFolderAction.isEnabled();
|
||||
}
|
||||
|
||||
async isCreateLibraryPresent() {
|
||||
return await this.createLibraryAction.isPresent();
|
||||
return this.createLibraryAction.isPresent();
|
||||
}
|
||||
async isCreateLibraryEnabled() {
|
||||
return await this.createLibraryAction.isEnabled();
|
||||
return this.createLibraryAction.isEnabled();
|
||||
}
|
||||
|
||||
async isUploadFilePresent() {
|
||||
return await this.uploadFileAction.isPresent();
|
||||
return this.uploadFileAction.isPresent();
|
||||
}
|
||||
async isUploadFileEnabled() {
|
||||
return await this.uploadFileAction.isEnabled();
|
||||
return this.uploadFileAction.isEnabled();
|
||||
}
|
||||
|
||||
async isUploadFolderPresent() {
|
||||
return await this.uploadFolderAction.isPresent();
|
||||
return this.uploadFolderAction.isPresent();
|
||||
}
|
||||
async isUploadFolderEnabled() {
|
||||
return await this.uploadFolderAction.isEnabled();
|
||||
return this.uploadFolderAction.isEnabled();
|
||||
}
|
||||
|
||||
|
||||
|
||||
async clickCreateFolder() {
|
||||
const action = this.createFolderAction;
|
||||
await action.click();
|
||||
|
@ -44,7 +44,7 @@ export class MetadataCard extends Component {
|
||||
}
|
||||
|
||||
async isExpandPresent() {
|
||||
return await this.expandButton.isPresent();
|
||||
return this.expandButton.isPresent();
|
||||
}
|
||||
|
||||
async clickExpandButton() {
|
||||
@ -52,15 +52,15 @@ export class MetadataCard extends Component {
|
||||
}
|
||||
|
||||
async waitForFirstExpansionPanel() {
|
||||
return await browser.wait(EC.presenceOf(this.expansionPanels.get(0)), BROWSER_WAIT_TIMEOUT);
|
||||
await browser.wait(EC.presenceOf(this.expansionPanels.get(0)), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
|
||||
async isExpansionPanelPresent(index) {
|
||||
return await this.expansionPanels.get(index).isPresent();
|
||||
return this.expansionPanels.get(index).isPresent();
|
||||
}
|
||||
|
||||
async getComponentIdOfPanel(index) {
|
||||
return await this.expansionPanels.get(index).getAttribute('data-automation-id');
|
||||
return this.expansionPanels.get(index).getAttribute('data-automation-id');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,54 +110,54 @@ export class Pagination extends Component {
|
||||
}
|
||||
|
||||
async isNextEnabled() {
|
||||
return await this.nextButton.isEnabled();
|
||||
return this.nextButton.isEnabled();
|
||||
}
|
||||
|
||||
async isPreviousEnabled() {
|
||||
return await this.previousButton.isEnabled();
|
||||
return this.previousButton.isEnabled();
|
||||
}
|
||||
|
||||
async isPagesButtonPresent() {
|
||||
return await browser.isElementPresent(this.pagesButton);
|
||||
return browser.isElementPresent(this.pagesButton);
|
||||
}
|
||||
|
||||
async isRangePresent() {
|
||||
return await this.range.isPresent();
|
||||
return this.range.isPresent();
|
||||
}
|
||||
|
||||
async isMaxItemsPresent() {
|
||||
return await this.maxItems.isPresent();
|
||||
return this.maxItems.isPresent();
|
||||
}
|
||||
|
||||
async isCurrentPagePresent() {
|
||||
return await this.currentPage.isPresent();
|
||||
return this.currentPage.isPresent();
|
||||
}
|
||||
|
||||
async isTotalPagesPresent() {
|
||||
return await this.totalPages.isPresent();
|
||||
return this.totalPages.isPresent();
|
||||
}
|
||||
|
||||
async isPreviousButtonPresent() {
|
||||
return await this.previousButton.isPresent();
|
||||
return this.previousButton.isPresent();
|
||||
}
|
||||
|
||||
async isNextButtonPresent() {
|
||||
return await this.nextButton.isPresent();
|
||||
return this.nextButton.isPresent();
|
||||
}
|
||||
|
||||
async getCurrentPage() {
|
||||
return await this.currentPage.getText();
|
||||
return this.currentPage.getText();
|
||||
}
|
||||
|
||||
async getRange() {
|
||||
return await this.range.getText();
|
||||
return this.range.getText();
|
||||
}
|
||||
|
||||
async getMaxItems() {
|
||||
return await this.maxItems.getText();
|
||||
return this.maxItems.getText();
|
||||
}
|
||||
|
||||
async getTotalPages() {
|
||||
return await this.totalPages.getText();
|
||||
return this.totalPages.getText();
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ export class SearchInput extends Component {
|
||||
}
|
||||
|
||||
async waitForSearchControl() {
|
||||
return await browser.wait(EC.presenceOf(this.searchControl), BROWSER_WAIT_TIMEOUT, '--- timeout waitForSearchControl ---');
|
||||
await browser.wait(EC.presenceOf(this.searchControl), BROWSER_WAIT_TIMEOUT, '--- timeout waitForSearchControl ---');
|
||||
}
|
||||
|
||||
async isSearchContainerDisplayed() {
|
||||
@ -70,22 +70,22 @@ export class SearchInput extends Component {
|
||||
|
||||
async isOptionsAreaDisplayed() {
|
||||
await browser.wait(until.elementLocated(by.css(SearchInput.selectors.searchControl)), BROWSER_WAIT_TIMEOUT);
|
||||
return await browser.isElementPresent(this.searchOptionsArea);
|
||||
return browser.isElementPresent(this.searchOptionsArea);
|
||||
}
|
||||
|
||||
async clickFilesOption() {
|
||||
await browser.wait(EC.elementToBeClickable(this.searchFilesOption), BROWSER_WAIT_TIMEOUT, '--- timeout waiting for Files to be clickable');
|
||||
return await this.searchFilesOption.click();
|
||||
await this.searchFilesOption.click();
|
||||
}
|
||||
|
||||
async clickFoldersOption() {
|
||||
await browser.wait(EC.elementToBeClickable(this.searchFoldersOption), BROWSER_WAIT_TIMEOUT, '--- timeout waiting for Folders to be clickable');
|
||||
return await this.searchFoldersOption.click();
|
||||
await this.searchFoldersOption.click();
|
||||
}
|
||||
|
||||
async clickLibrariesOption() {
|
||||
await browser.wait(EC.elementToBeClickable(this.searchLibrariesOption), BROWSER_WAIT_TIMEOUT, '--- timeout waiting for Libraries to be clickable');
|
||||
return await this.searchLibrariesOption.click();
|
||||
await this.searchLibrariesOption.click();
|
||||
}
|
||||
|
||||
async isFilesOptionEnabled() {
|
||||
@ -131,12 +131,12 @@ export class SearchInput extends Component {
|
||||
}
|
||||
|
||||
async isClearSearchButtonPresent() {
|
||||
return await browser.isElementPresent(this.clearSearchButton);
|
||||
return browser.isElementPresent(this.clearSearchButton);
|
||||
}
|
||||
|
||||
async clickClearSearchButton() {
|
||||
if (await this.isClearSearchButtonPresent()) {
|
||||
return await this.clearSearchButton.click();
|
||||
await this.clearSearchButton.click();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ export class Sidenav extends Component {
|
||||
|
||||
await browser.wait(condition, BROWSER_WAIT_TIMEOUT);
|
||||
|
||||
return await link.getAttribute('title');
|
||||
return link.getAttribute('title');
|
||||
}
|
||||
|
||||
async clickLink(name: string) {
|
||||
@ -154,18 +154,17 @@ export class Sidenav extends Component {
|
||||
const link = this.getLinkLabel(name);
|
||||
await Utils.waitUntilElementClickable(link);
|
||||
return await link.click();
|
||||
|
||||
} catch (e){
|
||||
console.log('---- sidebar navigation catch clickLink: ', e);
|
||||
} catch (error) {
|
||||
console.log('---- sidebar navigation clickLink catch error: ', error);
|
||||
}
|
||||
}
|
||||
|
||||
async isFileLibrariesMenuExpanded() {
|
||||
return await element(by.cssContainingText('.mat-expanded', SIDEBAR_LABELS.FILE_LIBRARIES)).isPresent();
|
||||
return element(by.cssContainingText('.mat-expanded', SIDEBAR_LABELS.FILE_LIBRARIES)).isPresent();
|
||||
}
|
||||
|
||||
async expandFileLibraries() {
|
||||
return await this.expandMenu(SIDEBAR_LABELS.FILE_LIBRARIES);
|
||||
await this.expandMenu(SIDEBAR_LABELS.FILE_LIBRARIES);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ export class Toolbar extends Component {
|
||||
}
|
||||
|
||||
async numberOfAvailableActions() {
|
||||
return await this.buttons.count();
|
||||
return this.buttons.count();
|
||||
}
|
||||
|
||||
async getButtons(): Promise<string[]> {
|
||||
@ -85,7 +85,7 @@ export class Toolbar extends Component {
|
||||
|
||||
async isButtonPresent(title: string) {
|
||||
const elem = this.component.element(by.css(`${Toolbar.selectors.button}[title="${title}"]`));
|
||||
return await elem.isPresent();
|
||||
return elem.isPresent();
|
||||
}
|
||||
|
||||
getButtonByLabel(label: string) {
|
||||
@ -112,7 +112,7 @@ export class Toolbar extends Component {
|
||||
}
|
||||
|
||||
async getButtonTooltip(button: ElementFinder) {
|
||||
return await button.getAttribute('title');
|
||||
return button.getAttribute('title');
|
||||
}
|
||||
|
||||
async clickButton(title: string) {
|
||||
@ -122,47 +122,47 @@ export class Toolbar extends Component {
|
||||
|
||||
|
||||
async isSharedLinkSettingsPresent() {
|
||||
return await browser.isElementPresent(this.shareEditButton);
|
||||
return browser.isElementPresent(this.shareEditButton);
|
||||
}
|
||||
|
||||
async isSharePresent() {
|
||||
return await browser.isElementPresent(this.shareButton);
|
||||
return browser.isElementPresent(this.shareButton);
|
||||
}
|
||||
|
||||
async isViewPresent() {
|
||||
return await browser.isElementPresent(this.viewButton);
|
||||
return browser.isElementPresent(this.viewButton);
|
||||
}
|
||||
|
||||
async isToggleSearchFiltersPresent() {
|
||||
return await browser.isElementPresent(this.searchFiltersToggleButton);
|
||||
return browser.isElementPresent(this.searchFiltersToggleButton);
|
||||
}
|
||||
|
||||
async isDownloadPresent() {
|
||||
return await browser.isElementPresent(this.downloadButton);
|
||||
return browser.isElementPresent(this.downloadButton);
|
||||
}
|
||||
|
||||
async isPermanentlyDeletePresent() {
|
||||
return await browser.isElementPresent(this.permanentlyDeleteButton);
|
||||
return browser.isElementPresent(this.permanentlyDeleteButton);
|
||||
}
|
||||
|
||||
async isRestorePresent() {
|
||||
return await browser.isElementPresent(this.restoreButton);
|
||||
return browser.isElementPresent(this.restoreButton);
|
||||
}
|
||||
|
||||
async isEditFolderPresent() {
|
||||
return await browser.isElementPresent(this.editFolderButton);
|
||||
return browser.isElementPresent(this.editFolderButton);
|
||||
}
|
||||
|
||||
async isViewDetailsPresent() {
|
||||
return await browser.isElementPresent(this.viewDetailsButton);
|
||||
return browser.isElementPresent(this.viewDetailsButton);
|
||||
}
|
||||
|
||||
async isPrintPresent() {
|
||||
return await browser.isElementPresent(this.printButton);
|
||||
return browser.isElementPresent(this.printButton);
|
||||
}
|
||||
|
||||
async isFullScreenPresent() {
|
||||
return await browser.isElementPresent(this.fullScreenButton);
|
||||
return browser.isElementPresent(this.fullScreenButton);
|
||||
}
|
||||
|
||||
|
||||
@ -177,84 +177,84 @@ export class Toolbar extends Component {
|
||||
}
|
||||
|
||||
async clickView() {
|
||||
return await this.viewButton.click();
|
||||
await this.viewButton.click();
|
||||
}
|
||||
|
||||
async clickEditFolder() {
|
||||
return await this.editFolderButton.click();
|
||||
await this.editFolderButton.click();
|
||||
}
|
||||
|
||||
async clickViewDetails() {
|
||||
return await this.viewDetailsButton.click();
|
||||
await this.viewDetailsButton.click();
|
||||
}
|
||||
|
||||
async clickDownload() {
|
||||
return await this.downloadButton.click();
|
||||
await this.downloadButton.click();
|
||||
}
|
||||
|
||||
async clickJoin() {
|
||||
return await this.joinButton.click();
|
||||
await this.joinButton.click();
|
||||
}
|
||||
|
||||
async clickLeave() {
|
||||
return await this.leaveButton.click();
|
||||
await this.leaveButton.click();
|
||||
}
|
||||
|
||||
async clickPermanentlyDelete() {
|
||||
return await this.permanentlyDeleteButton.click();
|
||||
await this.permanentlyDeleteButton.click();
|
||||
}
|
||||
async clickRestore() {
|
||||
return await this.restoreButton.click();
|
||||
await this.restoreButton.click();
|
||||
}
|
||||
|
||||
|
||||
async clickMoreActionsFavorite() {
|
||||
await this.openMoreMenu();
|
||||
return await this.menu.clickMenuItem('Favorite');
|
||||
await this.menu.clickMenuItem('Favorite');
|
||||
}
|
||||
|
||||
async clickMoreActionsRemoveFavorite() {
|
||||
await this.openMoreMenu();
|
||||
return await this.menu.clickMenuItem('Remove Favorite');
|
||||
await this.menu.clickMenuItem('Remove Favorite');
|
||||
}
|
||||
|
||||
async clickMoreActionsDelete() {
|
||||
await this.openMoreMenu();
|
||||
return await this.menu.clickMenuItem('Delete');
|
||||
await this.menu.clickMenuItem('Delete');
|
||||
}
|
||||
|
||||
async clickMoreActionsManageVersions() {
|
||||
await this.openMoreMenu();
|
||||
return await this.menu.clickMenuItem('Manage Versions');
|
||||
await this.menu.clickMenuItem('Manage Versions');
|
||||
}
|
||||
|
||||
async clickMoreActionsMove() {
|
||||
await this.openMoreMenu();
|
||||
return await this.menu.clickMenuItem('Move');
|
||||
await this.menu.clickMenuItem('Move');
|
||||
}
|
||||
|
||||
async clickMoreActionsCopy() {
|
||||
await this.openMoreMenu();
|
||||
return await this.menu.clickMenuItem('Copy');
|
||||
await this.menu.clickMenuItem('Copy');
|
||||
}
|
||||
|
||||
async clickMoreActionsEditOffline() {
|
||||
await this.openMoreMenu();
|
||||
return await this.menu.clickMenuItem('Edit Offline');
|
||||
await this.menu.clickMenuItem('Edit Offline');
|
||||
}
|
||||
|
||||
async clickMoreActionsCancelEditing() {
|
||||
await this.openMoreMenu();
|
||||
return await this.menu.clickMenuItem('Cancel Editing');
|
||||
await this.menu.clickMenuItem('Cancel Editing');
|
||||
}
|
||||
|
||||
async clickMoreActionsUploadNewVersion() {
|
||||
await this.openMoreMenu();
|
||||
return await this.menu.clickMenuItem('Upload New Version');
|
||||
await this.menu.clickMenuItem('Upload New Version');
|
||||
}
|
||||
|
||||
async clickFullScreen() {
|
||||
return await this.fullScreenButton.click();
|
||||
await this.fullScreenButton.click();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -65,23 +65,23 @@ export class Viewer extends Component {
|
||||
}
|
||||
|
||||
async isViewerOpened() {
|
||||
return await browser.isElementPresent(this.viewerLayout);
|
||||
return browser.isElementPresent(this.viewerLayout);
|
||||
}
|
||||
|
||||
async isViewerContentDisplayed() {
|
||||
return await browser.isElementPresent(this.viewerContainer);
|
||||
return browser.isElementPresent(this.viewerContainer);
|
||||
}
|
||||
|
||||
async isViewerToolbarDisplayed() {
|
||||
return await browser.isElementPresent(this.toolbar.component);
|
||||
return browser.isElementPresent(this.toolbar.component);
|
||||
}
|
||||
|
||||
async isCloseButtonDisplayed() {
|
||||
return await browser.isElementPresent(this.closeButton);
|
||||
return browser.isElementPresent(this.closeButton);
|
||||
}
|
||||
|
||||
async isFileTitleDisplayed() {
|
||||
return await browser.isElementPresent(this.fileTitle);
|
||||
return browser.isElementPresent(this.fileTitle);
|
||||
}
|
||||
|
||||
async clickClose() {
|
||||
@ -89,23 +89,23 @@ export class Viewer extends Component {
|
||||
}
|
||||
|
||||
async getCloseButtonTooltip() {
|
||||
return await this.toolbar.getButtonTooltip(this.closeButton);
|
||||
return this.toolbar.getButtonTooltip(this.closeButton);
|
||||
}
|
||||
|
||||
async getFileTitle() {
|
||||
return await this.fileTitle.getText();
|
||||
return this.fileTitle.getText();
|
||||
}
|
||||
|
||||
async isCustomContentPresent() {
|
||||
return await browser.isElementPresent(this.viewerExtensionContent);
|
||||
return browser.isElementPresent(this.viewerExtensionContent);
|
||||
}
|
||||
|
||||
async getComponentIdOfView(): Promise<string|null> {
|
||||
async getComponentIdOfView(): Promise<string> {
|
||||
if (await this.isCustomContentPresent()) {
|
||||
return await this.viewerExtensionContent.getAttribute('data-automation-id');
|
||||
return this.viewerExtensionContent.getAttribute('data-automation-id');
|
||||
}
|
||||
|
||||
return null;
|
||||
return '';
|
||||
}
|
||||
|
||||
async isPdfViewerContentDisplayed() {
|
||||
|
@ -57,21 +57,21 @@ export abstract class Page {
|
||||
constructor(public url: string = '') {}
|
||||
|
||||
async getTitle() {
|
||||
return await browser.getTitle();
|
||||
return browser.getTitle();
|
||||
}
|
||||
|
||||
async load(relativeUrl: string = '') {
|
||||
const hash = USE_HASH_STRATEGY ? '/#' : '';
|
||||
const path = `${browser.baseUrl}${hash}${this.url}${relativeUrl}`;
|
||||
return await browser.get(path);
|
||||
return browser.get(path);
|
||||
}
|
||||
|
||||
async waitForApp() {
|
||||
return await browser.wait(EC.presenceOf(this.layout), BROWSER_WAIT_TIMEOUT);
|
||||
await browser.wait(EC.presenceOf(this.layout), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
|
||||
async waitForSnackBarToAppear() {
|
||||
return await browser.wait(until.elementLocated(by.css('.mat-snack-bar-container')), BROWSER_WAIT_TIMEOUT, '------- timeout waiting for snackbar to appear');
|
||||
return browser.wait(until.elementLocated(by.css('.mat-snack-bar-container')), BROWSER_WAIT_TIMEOUT, '------- timeout waiting for snackbar to appear');
|
||||
}
|
||||
|
||||
async waitForSnackBarToClose() {
|
||||
@ -83,7 +83,7 @@ export abstract class Page {
|
||||
}
|
||||
|
||||
async isDialogOpen() {
|
||||
return await browser.isElementPresent(this.dialogContainer);
|
||||
return browser.isElementPresent(this.dialogContainer);
|
||||
}
|
||||
|
||||
async closeOpenDialogs() {
|
||||
@ -99,24 +99,24 @@ export abstract class Page {
|
||||
|
||||
async getSnackBarMessage() {
|
||||
const elem = await this.waitForSnackBarToAppear();
|
||||
return await elem.getAttribute('innerText');
|
||||
return elem.getAttribute('innerText');
|
||||
}
|
||||
|
||||
async clickSnackBarAction() {
|
||||
try {
|
||||
const action = browser.wait(until.elementLocated(by.css('.mat-simple-snackbar-action button')), BROWSER_WAIT_TIMEOUT, '------- timeout waiting for snack action to appear');
|
||||
return await action.click();
|
||||
const action = await browser.wait(until.elementLocated(by.css('.mat-simple-snackbar-action button')), BROWSER_WAIT_TIMEOUT, '------- timeout waiting for snack action to appear');
|
||||
await action.click();
|
||||
} catch (e) {
|
||||
console.log(e, '.......failed on click snack bar action.........');
|
||||
}
|
||||
}
|
||||
|
||||
async isGenericErrorDisplayed() {
|
||||
return await this.genericError.isDisplayed();
|
||||
return this.genericError.isDisplayed();
|
||||
}
|
||||
|
||||
async getGenericErrorTitle() {
|
||||
return await this.genericErrorTitle.getText();
|
||||
return this.genericErrorTitle.getText();
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,10 +50,10 @@ export class SearchResultsPage extends BrowsingPage {
|
||||
};
|
||||
|
||||
async waitForResults() {
|
||||
return await this.dataTable.waitForBody();
|
||||
await this.dataTable.waitForBody();
|
||||
}
|
||||
|
||||
async getResultsHeader() {
|
||||
return await browser.element(by.css(SearchResultsPage.selectors.resultsContentHeader)).getText();
|
||||
return browser.element(by.css(SearchResultsPage.selectors.resultsContentHeader)).getText();
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ describe('Mark items as favorites', () => {
|
||||
const fileFav4 = `fileFav4-${Utils.random()}.txt`;
|
||||
const folder = `folder-${Utils.random()}`;
|
||||
|
||||
let fileNotFavUIId, fileFavUIId, fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id, folderId, parentId;
|
||||
let fileFavUIId, fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id, folderId, parentId;
|
||||
|
||||
const fileSearchNotFav1 = `search-fileNotFav1-${Utils.random()}.txt`;
|
||||
const fileSearchNotFav2 = `search-fileNotFav2-${Utils.random()}.txt`;
|
||||
@ -75,7 +75,7 @@ describe('Mark items as favorites', () => {
|
||||
|
||||
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
|
||||
|
||||
fileNotFavUIId = (await apis.user.nodes.createFile(fileNotFavUI, parentId)).entry.id;
|
||||
await apis.user.nodes.createFile(fileNotFavUI, parentId);
|
||||
fileFavUIId = (await apis.user.nodes.createFile(fileFavUI, parentId)).entry.id;
|
||||
fileNotFav1Id = (await apis.user.nodes.createFile(fileNotFav1, parentId)).entry.id;
|
||||
fileNotFav2Id = (await apis.user.nodes.createFile(fileNotFav2, parentId)).entry.id;
|
||||
@ -121,10 +121,13 @@ describe('Mark items as favorites', () => {
|
||||
|
||||
describe('on Personal Files', () => {
|
||||
afterAll(async (done) => {
|
||||
try {
|
||||
await apis.user.favorites.addFavoritesByIds('file', [ fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
|
||||
await apis.user.favorites.addFavoriteById('folder', folderId);
|
||||
await apis.user.favorites.removeFavoritesByIds([ fileNotFavUIId , fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
|
||||
await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
|
||||
await apis.user.favorites.waitForApi({ expect: 10 });
|
||||
} catch (error) {
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
@ -204,9 +207,12 @@ describe('Mark items as favorites', () => {
|
||||
|
||||
describe('on Recent Files', () => {
|
||||
afterAll(async (done) => {
|
||||
try {
|
||||
await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
|
||||
await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
|
||||
await apis.user.favorites.waitForApi({ expect: 10 });
|
||||
} catch (error) {
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
@ -257,9 +263,12 @@ describe('Mark items as favorites', () => {
|
||||
|
||||
describe('on Shared Files', () => {
|
||||
afterAll(async (done) => {
|
||||
try {
|
||||
await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
|
||||
await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
|
||||
await apis.user.favorites.waitForApi({ expect: 10 });
|
||||
} catch (error) {
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
@ -310,9 +319,11 @@ describe('Mark items as favorites', () => {
|
||||
|
||||
describe('on Favorites', () => {
|
||||
afterAll(async (done) => {
|
||||
try {
|
||||
await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]);
|
||||
await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]);
|
||||
await apis.user.favorites.waitForApi({ expect: 10 });
|
||||
} catch (error) {
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
|
@ -250,7 +250,7 @@ describe('Share a file', () => {
|
||||
expect(await shareDialog.getExpireDate()).toBe('', 'Expire date input is not empty');
|
||||
|
||||
await shareDialog.clickClose();
|
||||
expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe(undefined, `${file7} link still has expiration`);
|
||||
expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe('', `${file7} link still has expiration`);
|
||||
});
|
||||
|
||||
it('Shared file URL is not changed when Share dialog is closed and opened again - [C286335]', async () => {
|
||||
@ -430,7 +430,7 @@ describe('Share a file', () => {
|
||||
expect(await shareDialog.getExpireDate()).toBe('', 'Expire date input is not empty');
|
||||
|
||||
await shareDialog.clickClose();
|
||||
expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe(undefined, `${file7} link still has expiration`);
|
||||
expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe('', `${file7} link still has expiration`);
|
||||
});
|
||||
|
||||
it('Shared file URL is not changed when Share dialog is closed and opened again - [C286646]', async () => {
|
||||
@ -607,7 +607,7 @@ describe('Share a file', () => {
|
||||
expect(await shareDialog.getExpireDate()).toBe('', 'Expire date input is not empty');
|
||||
|
||||
await shareDialog.clickClose();
|
||||
expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe(undefined, `${file7} link still has expiration`);
|
||||
expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe('', `${file7} link still has expiration`);
|
||||
});
|
||||
|
||||
it('Shared file URL is not changed when Share dialog is closed and opened again - [C286664]', async () => {
|
||||
@ -753,7 +753,7 @@ describe('Share a file', () => {
|
||||
expect(await shareDialog.getExpireDate()).toBe('', 'Expire date input is not empty');
|
||||
|
||||
await shareDialog.clickClose();
|
||||
expect(await apis.user.nodes.getSharedExpiryDate(file5Id)).toBe(undefined, `${file5} link still has expiration`);
|
||||
expect(await apis.user.nodes.getSharedExpiryDate(file5Id)).toBe('', `${file5} link still has expiration`);
|
||||
});
|
||||
|
||||
it('Shared file URL is not changed when Share dialog is closed and opened again - [C286655]', async () => {
|
||||
@ -946,7 +946,7 @@ describe('Share a file', () => {
|
||||
expect(await shareDialog.getExpireDate()).toBe('', 'Expire date input is not empty');
|
||||
|
||||
await shareDialog.clickClose();
|
||||
expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe(undefined, `${file7} link still has expiration`);
|
||||
expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe('', `${file7} link still has expiration`);
|
||||
});
|
||||
|
||||
it('Shared file URL is not changed when Share dialog is closed and opened again - [C286673]', async () => {
|
||||
@ -1082,7 +1082,7 @@ describe('Share a file', () => {
|
||||
expect(await shareDialog.getExpireDate()).toBe('', 'Expire date input is not empty');
|
||||
|
||||
await shareDialog.clickClose();
|
||||
expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe(undefined, `${file7} link still has expiration`);
|
||||
expect(await apis.user.nodes.getSharedExpiryDate(file7Id)).toBe('', `${file7} link still has expiration`);
|
||||
});
|
||||
|
||||
it('Share a file from the context menu - [C306981]', async () => {
|
||||
|
@ -176,26 +176,26 @@ describe('Sidebar', () => {
|
||||
});
|
||||
|
||||
it('default state is expanded - [C269095]', async () => {
|
||||
expect(await header.isExpandedSidenav()).toBe(true, 'Sidebar not expanded');
|
||||
expect(await header.isSidenavExpanded()).toBe(true, 'Sidebar not expanded');
|
||||
});
|
||||
|
||||
it('sidebar toggle - [C269096]', async () => {
|
||||
await header.collapseSideNav();
|
||||
expect(await header.isExpandedSidenav()).toBe(false, 'Sidebar not collapsed');
|
||||
expect(await header.isSidenavExpanded()).toBe(false, 'Sidebar not collapsed');
|
||||
|
||||
await header.expandSideNav();
|
||||
expect(await header.isExpandedSidenav()).toBe(true, 'Sidebar not expanded');
|
||||
expect(await header.isSidenavExpanded()).toBe(true, 'Sidebar not expanded');
|
||||
});
|
||||
|
||||
it('sidebar state is preserved on page refresh - [C269100]', async () => {
|
||||
expect(await header.isExpandedSidenav()).toBe(true, 'Sidebar not expanded');
|
||||
expect(await header.isSidenavExpanded()).toBe(true, 'Sidebar not expanded');
|
||||
await page.refresh();
|
||||
expect(await header.isExpandedSidenav()).toBe(true, 'Sidebar not expanded');
|
||||
expect(await header.isSidenavExpanded()).toBe(true, 'Sidebar not expanded');
|
||||
|
||||
await header.collapseSideNav();
|
||||
expect(await header.isExpandedSidenav()).toBe(false, 'Sidebar not collapsed');
|
||||
expect(await header.isSidenavExpanded()).toBe(false, 'Sidebar not collapsed');
|
||||
await page.refresh();
|
||||
expect(await header.isExpandedSidenav()).toBe(false, 'Sidebar not collapsed');
|
||||
expect(await header.isSidenavExpanded()).toBe(false, 'Sidebar not collapsed');
|
||||
});
|
||||
|
||||
it('sidebar state is preserved after logout / login - [C269102]', async () => {
|
||||
@ -203,7 +203,7 @@ describe('Sidebar', () => {
|
||||
await page.signOut();
|
||||
await loginPage.loginWithAdmin();
|
||||
|
||||
expect(await header.isExpandedSidenav()).toBe(false, 'Sidebar not collapsed');
|
||||
expect(await header.isSidenavExpanded()).toBe(false, 'Sidebar not collapsed');
|
||||
});
|
||||
|
||||
it('sidebar is collapsed automatically when Search Results opens - [C277223]', async () => {
|
||||
@ -212,7 +212,7 @@ describe('Sidebar', () => {
|
||||
await searchInput.searchFor('qwertyuiop');
|
||||
await searchResultsPage.waitForResults();
|
||||
|
||||
expect(await header.isExpandedSidenav()).toBe(false, 'Sidebar not collapsed');
|
||||
expect(await header.isSidenavExpanded()).toBe(false, 'Sidebar not collapsed');
|
||||
});
|
||||
|
||||
it('sidenav returns to the default state when navigating away from the Search Results page - [C277224]', async () => {
|
||||
@ -222,7 +222,7 @@ describe('Sidebar', () => {
|
||||
await searchResultsPage.waitForResults();
|
||||
await page.clickFavorites();
|
||||
|
||||
expect(await header.isExpandedSidenav()).toBe(true, 'Sidebar not expanded');
|
||||
expect(await header.isSidenavExpanded()).toBe(true, 'Sidebar not expanded');
|
||||
});
|
||||
|
||||
it('sidenav can be expanded when search results page is displayed - [C277230]', async () => {
|
||||
@ -232,6 +232,6 @@ describe('Sidebar', () => {
|
||||
await searchResultsPage.waitForResults();
|
||||
await header.expandSideNav();
|
||||
|
||||
expect(await header.isExpandedSidenav()).toBe(true, 'Sidebar not expanded');
|
||||
expect(await header.isSidenavExpanded()).toBe(true, 'Sidebar not expanded');
|
||||
});
|
||||
});
|
||||
|
@ -459,6 +459,7 @@ describe('Viewer actions', () => {
|
||||
|
||||
beforeAll(async (done) => {
|
||||
await apis.user.search.waitForApi(username, {expect: 0});
|
||||
|
||||
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
|
||||
destinationId = (await apis.user.nodes.createFolder(destination)).entry.id;
|
||||
docxFileId = (await apis.user.upload.uploadFileWithRename(docxFile, parentId, docxRecentFiles)).entry.id;
|
||||
@ -476,7 +477,7 @@ describe('Viewer actions', () => {
|
||||
await apis.user.upload.uploadFileWithRename(xlsxFileForMove, parentId, xlsxRecentFiles);
|
||||
await apis.user.upload.uploadFileWithRename(pdfFileForDelete, parentId, pdfRecentFiles);
|
||||
|
||||
await apis.user.search.waitForApi(username, {expect: 8});
|
||||
await apis.user.search.waitForApi(username, {expect: 7});
|
||||
|
||||
await loginPage.loginWith(username);
|
||||
done();
|
||||
@ -654,9 +655,8 @@ describe('Viewer actions', () => {
|
||||
await apis.user.nodes.lockFile(fileForCancelEditingId);
|
||||
await apis.user.nodes.lockFile(fileForUploadNewVersionId);
|
||||
|
||||
|
||||
await apis.user.shared.shareFilesByIds([docxFileId, xlsxFileId, pdfFileId, fileForCancelEditingId, fileForEditOfflineId, fileForUploadNewVersionId, fileSharedId])
|
||||
await apis.user.shared.waitForApi({expect: 8});
|
||||
await apis.user.shared.waitForApi({expect: 7});
|
||||
|
||||
await loginPage.loginWith(username);
|
||||
done();
|
||||
@ -668,6 +668,7 @@ describe('Viewer actions', () => {
|
||||
});
|
||||
|
||||
afterEach(async (done) => {
|
||||
await page.closeOpenDialogs();
|
||||
await Utils.pressEscape();
|
||||
done();
|
||||
});
|
||||
@ -687,7 +688,7 @@ describe('Viewer actions', () => {
|
||||
expect(await Utils.fileExistsOnOS(docxSharedFiles)).toBe(true, 'File not found in download location');
|
||||
});
|
||||
|
||||
it('Copy action - [C286377]', async (done) => {
|
||||
it('Copy action - [C286377]', async () => {
|
||||
await dataTable.doubleClickOnRowByName(docxSharedFiles);
|
||||
expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened');
|
||||
|
||||
@ -704,7 +705,6 @@ describe('Viewer actions', () => {
|
||||
expect(await dataTable.isItemPresent(docxSharedFiles)).toBe(true, 'Item is not present in destination');
|
||||
|
||||
await apis.user.nodes.deleteNodeChildren(destinationId);
|
||||
done();
|
||||
});
|
||||
|
||||
it('Move action - [C286378]', async () => {
|
||||
@ -838,7 +838,7 @@ describe('Viewer actions', () => {
|
||||
|
||||
|
||||
await apis.user.favorites.addFavoritesByIds('file', [docxFileId, xlsxFileId, pdfFileId, fileForEditOfflineId, fileForCancelEditingId, fileForUploadNewVersionId, fileFavId])
|
||||
await apis.user.favorites.waitForApi({expect: 8});
|
||||
await apis.user.favorites.waitForApi({expect: 7});
|
||||
|
||||
await loginPage.loginWith(username);
|
||||
done();
|
||||
|
@ -32,7 +32,11 @@ export class AuthenticationApi extends RepoApi {
|
||||
}
|
||||
|
||||
async logout() {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.alfrescoJsApi.logout();
|
||||
await this.alfrescoJsApi.logout();
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.logout.name}`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,16 +34,32 @@ export class CommentsApi extends RepoApi {
|
||||
}
|
||||
|
||||
async getNodeComments(nodeId: string) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.commentsApi.listComments(nodeId);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeComments.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async addComment(nodeId: string, comment: string) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.commentsApi.createComment(nodeId, { "content": comment });
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.addComment.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async addComments(nodeId: string, comment: any) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.commentsApi.createComment(nodeId, comment);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.addComments.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ export class FavoritesApi extends RepoApi {
|
||||
}
|
||||
|
||||
async addFavorite(api: RepoClient, nodeType: string, name: string) {
|
||||
try {
|
||||
const nodeId = (await api.nodes.getNodeByPath(name)).entry.id;
|
||||
const data = {
|
||||
target: {
|
||||
@ -46,12 +47,16 @@ export class FavoritesApi extends RepoApi {
|
||||
}
|
||||
};
|
||||
return await this.favoritesApi.createFavorite('-me-', data);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.addFavorite.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -64,37 +69,55 @@ export class FavoritesApi extends RepoApi {
|
||||
}
|
||||
}
|
||||
};
|
||||
try {
|
||||
return await this.favoritesApi.createFavorite('-me-', data);
|
||||
} catch (error) {
|
||||
console.log('--- add favorite by id catch ');
|
||||
this.handleError(`${this.constructor.name} ${this.addFavoriteById.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async addFavoritesByIds(nodeType: 'file' | 'folder' | 'site', ids: string[]) {
|
||||
try {
|
||||
return await ids.reduce(async (previous, current) => {
|
||||
await previous;
|
||||
await this.addFavoriteById(nodeType, current);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.addFavoritesByIds.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async getFavorites() {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.favoritesApi.listFavorites(this.getUsername());
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getFavorites.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getFavoriteById(nodeId: string) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.favoritesApi.getFavorite('-me-', nodeId);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getFavoriteById.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async isFavorite(nodeId: string) {
|
||||
try {
|
||||
return JSON.stringify((await this.getFavorites()).list.entries).includes(nodeId);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.isFavorite.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async isFavoriteWithRetry(nodeId: string, data) {
|
||||
let isFavorite;
|
||||
async isFavoriteWithRetry(nodeId: string, data: { expect: boolean }) {
|
||||
let isFavorite: boolean;
|
||||
try {
|
||||
const favorite = async () => {
|
||||
isFavorite = await this.isFavorite(nodeId);
|
||||
@ -104,31 +127,34 @@ export class FavoritesApi extends RepoApi {
|
||||
return Promise.resolve(isFavorite);
|
||||
}
|
||||
};
|
||||
|
||||
return await Utils.retryCall(favorite);
|
||||
} catch (error) {
|
||||
console.log('-----> catch isFavoriteWithRetry: ', error);
|
||||
// this.handleError(`${this.constructor.name} ${this.isFavoriteWithRetry.name}`, error);
|
||||
}
|
||||
return isFavorite;
|
||||
}
|
||||
|
||||
async removeFavoriteById(nodeId: string) {
|
||||
await this.apiAuth();
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.favoritesApi.deleteFavorite('-me-', nodeId);
|
||||
} catch (error) {
|
||||
console.log('--- remove favorite by id catch ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.removeFavoriteById.name}`, 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(`${this.constructor.name} ${this.removeFavoritesByIds.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async waitForApi(data) {
|
||||
async waitForApi(data: { expect: number }) {
|
||||
try {
|
||||
const favoriteFiles = async () => {
|
||||
const totalItems = (await this.getFavorites()).list.pagination.totalItems;
|
||||
@ -138,10 +164,10 @@ export class FavoritesApi extends RepoApi {
|
||||
return Promise.resolve(totalItems);
|
||||
}
|
||||
};
|
||||
|
||||
return await Utils.retryCall(favoriteFiles);
|
||||
} catch (error) {
|
||||
console.log('-----> catch favorites: ', error);
|
||||
console.log(`${this.constructor.name} ${this.waitForApi.name} catch: `);
|
||||
console.log(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
import { RepoApi } from '../repo-api';
|
||||
import { NodeBodyCreate } from './node-body-create';
|
||||
import { NodeContentTree, flattenNodeContentTree } from './node-content-tree';
|
||||
import { NodesApi as AdfNodeApi, NodeBodyLock} from '@alfresco/js-api';
|
||||
import { NodesApi as AdfNodeApi, NodeBodyLock, NodeEntry, NodeChildAssociationPaging } from '@alfresco/js-api';
|
||||
import { Utils } from '../../../../utilities/utils';
|
||||
|
||||
export class NodesApi extends RepoApi {
|
||||
@ -36,113 +36,185 @@ export class NodesApi extends RepoApi {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
async getNodeByPath(relativePath: string = '/') {
|
||||
async getNodeByPath(relativePath: string = '/'): Promise<NodeEntry> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.getNode('-my-', { relativePath });
|
||||
}
|
||||
|
||||
async getNodeById(id: string) {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.getNode(id);
|
||||
}
|
||||
|
||||
async getNodeIdFromParent(name: string, parentId: string) {
|
||||
const children = (await this.getNodeChildren(parentId)).list.entries;
|
||||
return children.find(elem => elem.entry.name === name).entry.id;
|
||||
}
|
||||
|
||||
async getNodeDescription(name: string, parentId: string) {
|
||||
const children = (await this.getNodeChildren(parentId)).list.entries;
|
||||
return children.find(elem => elem.entry.name === name).entry.properties['cm:description'];
|
||||
}
|
||||
|
||||
async getNodeProperty(nodeId: string, property: string) {
|
||||
const node = await this.getNodeById(nodeId);
|
||||
if (node.entry.properties) {
|
||||
return node.entry.properties[property];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
async getFileVersionType(nodeId: string) {
|
||||
const prop = await this.getNodeProperty(nodeId, 'cm:versionType');
|
||||
if ( prop ) {
|
||||
return prop;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
async getFileVersionLabel(nodeId: string) {
|
||||
const prop = await this.getNodeProperty(nodeId, 'cm:versionLabel');
|
||||
if ( prop ) {
|
||||
return prop;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
async getSharedId(nodeId: string) {
|
||||
return await this.getNodeProperty(nodeId, 'qshare:sharedId');
|
||||
}
|
||||
|
||||
async getSharedExpiryDate(nodeId: string) {
|
||||
return await this.getNodeProperty(nodeId, 'qshare:expiryDate');
|
||||
}
|
||||
|
||||
async isFileShared(nodeId: string) {
|
||||
return (await this.getSharedId(nodeId)) !== '';
|
||||
}
|
||||
|
||||
async deleteNodeById(id: string, permanent: boolean = true) {
|
||||
await this.apiAuth();
|
||||
try {
|
||||
return await this.nodesApi.deleteNode(id, { permanent });
|
||||
} catch (error) {
|
||||
console.log('------ deleteNodeById failed ');
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeByPath.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async deleteNodeByPath(path: string, permanent: boolean = true) {
|
||||
async getNodeById(id: string): Promise<NodeEntry> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
const node = await this.nodesApi.getNode(id);
|
||||
return node;
|
||||
} 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<any> {
|
||||
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): Promise<void> {
|
||||
try {
|
||||
const id = (await this.getNodeByPath(path)).entry.id;
|
||||
return await this.deleteNodeById(id, permanent);
|
||||
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) {
|
||||
return await names.reduce(async (previous, current) => {
|
||||
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);
|
||||
const req = await this.deleteNodeByPath(`${relativePath}/${current}`, permanent);
|
||||
return req;
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.deleteNodes.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteNodesById(ids: string[], permanent: boolean = true) {
|
||||
return await ids.reduce(async (previous, current) => {
|
||||
async deleteNodesById(ids: string[], permanent: boolean = true): Promise<void> {
|
||||
try {
|
||||
await ids.reduce(async (previous, current) => {
|
||||
await previous;
|
||||
return await this.deleteNodeById(current, permanent);
|
||||
const req = await this.deleteNodeById(current, permanent);
|
||||
return req;
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.deleteNodesById.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async getNodeChildren(nodeId: string) {
|
||||
async getNodeChildren(nodeId: string): Promise<NodeChildAssociationPaging> {
|
||||
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) {
|
||||
async deleteNodeChildren(parentId: string): Promise<void> {
|
||||
try {
|
||||
const listEntries = (await this.getNodeChildren(parentId)).list.entries;
|
||||
const nodeIds = listEntries.map(entries => entries.entry.id);
|
||||
return await this.deleteNodesById(nodeIds);
|
||||
await this.deleteNodesById(nodeIds);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.deleteNodeChildren.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createImageNode(nodeType: string, name: string, parentId: string = '-my-', title: string = '', description: string = '') {
|
||||
async createImageNode(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise<any> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
async createNode(nodeType: string, name: string, parentId: string = '-my-', title: string = '', description: string = '', imageProps: any = null, author: string = '', majorVersion: boolean = true) {
|
||||
async createNode(nodeType: string, name: string, parentId: string = '-my-', title: string = '', description: string = '', imageProps: any = null, author: string = '', majorVersion: boolean = true): Promise<any> {
|
||||
const nodeBody = {
|
||||
name,
|
||||
nodeType,
|
||||
@ -156,71 +228,103 @@ export class NodesApi extends RepoApi {
|
||||
nodeBody.properties = Object.assign(nodeBody.properties, imageProps);
|
||||
}
|
||||
|
||||
await this.apiAuth();
|
||||
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.createNode(parentId, nodeBody, { majorVersion });
|
||||
} catch (error) {
|
||||
console.log('===========> API create node catch ===========');
|
||||
this.handleError(`${this.constructor.name} ${this.createNode.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async createFile(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = '', majorVersion: boolean = true) {
|
||||
async createFile(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = '', majorVersion: boolean = true): Promise<any> {
|
||||
try {
|
||||
return await this.createNode('cm:content', name, parentId, title, description, null, author, majorVersion);
|
||||
} catch (error) {
|
||||
console.log('==== catch createFile: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createFile.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createImage(name: string, parentId: string = '-my-', title: string = '', description: string = '') {
|
||||
return await this.createImageNode('cm:content', name, parentId, title, description);
|
||||
async createImage(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise<any> {
|
||||
try {
|
||||
return await this.createImageNode(name, parentId, title, description);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.createImage.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createFolder(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = '') {
|
||||
async createFolder(name: string, parentId: string = '-my-', title: string = '', description: string = '', author: string = ''): Promise<any> {
|
||||
try {
|
||||
return await this.createNode('cm:folder', name, parentId, title, description, null, author);
|
||||
} catch (error) {
|
||||
console.log('======> API create folder catch ==========');
|
||||
this.handleError(`${this.constructor.name} ${this.createFolder.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createChildren(data: NodeBodyCreate[]) {
|
||||
async createChildren(data: NodeBodyCreate[]): Promise<any> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.createNode('-my-', <any>data);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.createChildren.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createContent(content: NodeContentTree, relativePath: string = '/') {
|
||||
async createContent(content: NodeContentTree, relativePath: string = '/'): Promise<any> {
|
||||
try {
|
||||
return await this.createChildren(flattenNodeContentTree(content, relativePath));
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.createContent.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async createFolders(names: string[], relativePath: string = '/') {
|
||||
async createFolders(names: string[], relativePath: string = '/'): Promise<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 = '/') {
|
||||
async createFiles(names: string[], relativePath: string = '/'): Promise<any> {
|
||||
try {
|
||||
return await this.createContent({ files: names }, relativePath);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.createFiles.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
// node content
|
||||
async getNodeContent(nodeId: string) {
|
||||
async getNodeContent(nodeId: string): Promise<any> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.getNodeContent(nodeId);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getNodeContent.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async editNodeContent(nodeId: string, content: string) {
|
||||
async editNodeContent(nodeId: string, content: string): Promise<NodeEntry|null> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.updateNodeContent(nodeId, content);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.editNodeContent.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async renameNode(nodeId: string, newName: string) {
|
||||
async renameNode(nodeId: string, newName: string): Promise<NodeEntry|null> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return this.nodesApi.updateNode(nodeId, { name: newName });
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.renameNode.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// node permissions
|
||||
async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string) {
|
||||
async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string): Promise<NodeEntry|null> {
|
||||
const data = {
|
||||
permissions: {
|
||||
isInheritanceEnabled: inheritPermissions,
|
||||
@ -233,48 +337,75 @@ export class NodesApi extends RepoApi {
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.updateNode(nodeId, data);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.setGranularPermission.name}`, error);
|
||||
return null;
|
||||
}
|
||||
|
||||
async getNodePermissions(nodeId: string) {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.getNode(nodeId, { include: ['permissions'] });
|
||||
}
|
||||
|
||||
// lock node
|
||||
async lockFile(nodeId: string, lockType: string = 'ALLOW_OWNER_CHANGES') {
|
||||
async lockFile(nodeId: string, lockType: string = 'ALLOW_OWNER_CHANGES'): Promise<NodeEntry|null> {
|
||||
const data = <NodeBodyLock>{
|
||||
type: lockType
|
||||
};
|
||||
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.lockNode(nodeId, data );
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.lockFile.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async unlockFile(nodeId: string) {
|
||||
async unlockFile(nodeId: string): Promise<NodeEntry|null> {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.nodesApi.unlockNode(nodeId);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.unlockFile.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getLockType(nodeId: string) {
|
||||
return await this.getNodeProperty(nodeId, 'cm:lockType');
|
||||
async getLockType(nodeId: string): Promise<any> {
|
||||
try {
|
||||
const lockType = await this.getNodeProperty(nodeId, 'cm:lockType');
|
||||
return lockType || '';
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getLockType.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async getLockOwner(nodeId: string) {
|
||||
return await this.getNodeProperty(nodeId, 'cm:lockOwner');
|
||||
async getLockOwner(nodeId: string): Promise<any> {
|
||||
try {
|
||||
const lockOwner = await this.getNodeProperty(nodeId, 'cm:lockOwner');
|
||||
return lockOwner || '';
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getLockOwner.name}`, error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async isFileLockedWrite(nodeId: string) {
|
||||
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) {
|
||||
async isFileLockedWriteWithRetry(nodeId: string, expect: boolean): Promise<boolean> {
|
||||
const data = {
|
||||
expect: expect,
|
||||
retry: 5
|
||||
};
|
||||
let isLocked;
|
||||
let isLocked: boolean;
|
||||
try {
|
||||
const locked = async () => {
|
||||
isLocked = (await this.getLockType(nodeId)) === 'WRITE_LOCK';
|
||||
@ -286,13 +417,18 @@ export class NodesApi extends RepoApi {
|
||||
}
|
||||
return await Utils.retryCall(locked, data.retry);
|
||||
} catch (error) {
|
||||
console.log('-----> catch isLockedWriteWithRetry: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.isFileLockedWriteWithRetry.name}`, error);
|
||||
}
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
async isFileLockedByName(fileName: string, parentId: string) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,31 +30,56 @@ import { PeopleApi as AdfPeopleApi} from '@alfresco/js-api';
|
||||
export class PeopleApi extends RepoApi {
|
||||
peopleApi = new AdfPeopleApi(this.alfrescoJsApi);
|
||||
|
||||
constructor(username?, password?) {
|
||||
constructor(username?: string, password?: string) {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
async createUser(user: PersonModel) {
|
||||
try {
|
||||
const person = new Person(user);
|
||||
await this.apiAuth();
|
||||
return await this.peopleApi.createPerson(person);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.createUser.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getUser(username: string) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.peopleApi.getPerson(username);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getUser.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async updateUser(username: string, userDetails?: PersonModel) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return this.peopleApi.updatePerson(username, userDetails);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.updateUser.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async disableUser(username: string) {
|
||||
try {
|
||||
return await this.updateUser(username, { enabled: false });
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.disableUser.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async changePassword(username: string, newPassword: string) {
|
||||
try {
|
||||
return await this.updateUser(username, { password: newPassword });
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.changePassword.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,13 @@ export class QueriesApi extends RepoApi {
|
||||
fields: ['title']
|
||||
};
|
||||
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return this.queriesApi.findSites(searchTerm, data);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.findSites.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async findNodes(searchTerm: string) {
|
||||
@ -50,11 +55,16 @@ export class QueriesApi extends RepoApi {
|
||||
fields: ['name']
|
||||
};
|
||||
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return this.queriesApi.findNodes(searchTerm, data);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.findNodes.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async waitForSites(searchTerm: string, data: any) {
|
||||
async waitForSites(searchTerm: string, data: { expect: number }) {
|
||||
try {
|
||||
const sites = async () => {
|
||||
const totalItems = (await this.findSites(searchTerm)).list.pagination.totalItems;
|
||||
@ -67,11 +77,12 @@ export class QueriesApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(sites);
|
||||
} catch (error) {
|
||||
console.log('-----> catch queries findSites: ', error);
|
||||
console.log(`${this.constructor.name} ${this.waitForSites.name} catch: `);
|
||||
console.log(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
async waitForFilesAndFolders(searchTerm: string, data: any) {
|
||||
async waitForFilesAndFolders(searchTerm: string, data: { expect: number }) {
|
||||
try {
|
||||
const nodes = async () => {
|
||||
const totalItems = (await this.findNodes(searchTerm)).list.pagination.totalItems;
|
||||
@ -84,7 +95,8 @@ export class QueriesApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(nodes);
|
||||
} catch (error) {
|
||||
console.log('-----> catch queries findFilesAndFolders: ', error);
|
||||
console.log(`${this.constructor.name} ${this.waitForFilesAndFolders.name} catch: `);
|
||||
console.log(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,4 +48,20 @@ export abstract class RepoApi {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
protected handleError(message: string, response: any) {
|
||||
console.log(`\n--- ${message} error :`);
|
||||
if ( response.status && response.response ) {
|
||||
try {
|
||||
console.log('\t>>> Status: ', response.status);
|
||||
console.log('\t>>> Text: ', response.response.text);
|
||||
console.log('\t>>> Method: ', response.response.error.method);
|
||||
console.log('\t>>> Path: ', response.response.error.path);
|
||||
} catch {
|
||||
console.log('\t>>> ', response);
|
||||
}
|
||||
}
|
||||
else console.log('\t>>> ', response);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -47,8 +47,13 @@ export class SearchApi extends RepoApi {
|
||||
]
|
||||
};
|
||||
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return this.searchApi.search(data);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.queryRecentFiles.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async queryNodesNames(searchTerm: string) {
|
||||
@ -62,8 +67,13 @@ export class SearchApi extends RepoApi {
|
||||
]
|
||||
};
|
||||
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return this.searchApi.search(data);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.queryNodesNames.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async queryNodesExactNames(searchTerm: string) {
|
||||
@ -77,11 +87,16 @@ export class SearchApi extends RepoApi {
|
||||
]
|
||||
};
|
||||
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return this.searchApi.search(data);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.queryNodesExactNames.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async waitForApi(username, data) {
|
||||
async waitForApi(username: string, data: { expect: number }) {
|
||||
try {
|
||||
const recentFiles = async () => {
|
||||
const totalItems = (await this.queryRecentFiles(username)).list.pagination.totalItems;
|
||||
@ -94,11 +109,12 @@ export class SearchApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(recentFiles);
|
||||
} catch (error) {
|
||||
console.log('-----> catch search: ', error);
|
||||
console.log(`${this.constructor.name} ${this.waitForApi.name} catch: `);
|
||||
console.log(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
async waitForNodes(searchTerm: string, data) {
|
||||
async waitForNodes(searchTerm: string, data: { expect: number }) {
|
||||
try {
|
||||
const nodes = async () => {
|
||||
const totalItems = (await this.queryNodesNames(searchTerm)).list.pagination.totalItems;
|
||||
@ -111,7 +127,8 @@ export class SearchApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(nodes);
|
||||
} catch (error) {
|
||||
console.log('-----> catch search nodes: ', error);
|
||||
console.log(`${this.constructor.name} ${this.waitForNodes.name} catch: `);
|
||||
console.log(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,35 +43,53 @@ export class SharedLinksApi extends RepoApi {
|
||||
};
|
||||
return await this.sharedlinksApi.createSharedLink(data);
|
||||
} catch (error) {
|
||||
console.log('---- shareFileById error: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.shareFileById.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async shareFilesByIds(ids: string[]) {
|
||||
try {
|
||||
return await ids.reduce(async (previous: any, current: any) => {
|
||||
await previous;
|
||||
return await this.shareFileById(current);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.shareFilesByIds.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async getSharedIdOfNode(name: string) {
|
||||
try {
|
||||
const sharedLinks = (await this.getSharedLinks()).list.entries;
|
||||
const found = sharedLinks.find(sharedLink => sharedLink.entry.name === name);
|
||||
return (found || { entry: { id: null } }).entry.id;
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getSharedIdOfNode.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async unshareFile(name: string) {
|
||||
try {
|
||||
const id = await this.getSharedIdOfNode(name);
|
||||
return await this.sharedlinksApi.deleteSharedLink(id);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.unshareFile.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async getSharedLinks() {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.sharedlinksApi.listSharedLinks();
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getSharedLinks.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async waitForApi(data) {
|
||||
async waitForApi(data: { expect: number }) {
|
||||
try {
|
||||
const sharedFiles = async () => {
|
||||
const totalItems = (await this.getSharedLinks()).list.pagination.totalItems;
|
||||
@ -84,7 +102,8 @@ export class SharedLinksApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(sharedFiles);
|
||||
} catch (error) {
|
||||
console.log('-----> catch shared: ', error);
|
||||
console.log(`${this.constructor.name} ${this.waitForApi.name} catch: `);
|
||||
console.log(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,33 +37,63 @@ export class SitesApi extends RepoApi {
|
||||
}
|
||||
|
||||
async getSite(siteId: string) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.getSite(siteId);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getSite.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getSites() {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.listSiteMembershipsForPerson(this.getUsername());
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getSites.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getDocLibId(siteId: string) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return (await this.sitesApi.listSiteContainers(siteId)).list.entries[0].entry.id;
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getDocLibId.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getVisibility(siteId: string) {
|
||||
try {
|
||||
const site = await this.getSite(siteId);
|
||||
return site.entry.visibility;
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getVisibility.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getDescription(siteId: string) {
|
||||
try {
|
||||
const site = await this.getSite(siteId);
|
||||
return site.entry.description;
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getDescription.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getTitle(siteId: string) {
|
||||
try {
|
||||
const site = await this.getSite(siteId);
|
||||
return site.entry.title;
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getTitle.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async createSite(title: string, visibility?: string, description?: string, siteId?: string): Promise<SiteEntry|null> {
|
||||
@ -78,37 +108,53 @@ export class SitesApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.createSite(site);
|
||||
} catch (error) {
|
||||
console.log('=== create site catch: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.createSite.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async createSites(titles: string[], visibility?: string) {
|
||||
try {
|
||||
return titles.reduce(async (previous: any, current: any) => {
|
||||
await previous;
|
||||
return await this.createSite(current, visibility);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.createSites.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteSite(siteId: string, permanent: boolean = true) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.deleteSite(siteId, { permanent });
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.deleteSite.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteSites(siteIds: string[], permanent: boolean = true) {
|
||||
try {
|
||||
return siteIds.reduce(async (previous, current) => {
|
||||
await previous;
|
||||
return await this.deleteSite(current, permanent);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.deleteSites.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteAllUserSites(permanent: boolean = true) {
|
||||
try {
|
||||
const siteIds = (await this.getSites()).list.entries.map(entries => entries.entry.id);
|
||||
|
||||
return await siteIds.reduce(async (previous, current) => {
|
||||
await previous;
|
||||
return await this.deleteSite(current, permanent);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.deleteAllUserSites.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async updateSiteMember(siteId: string, userId: string, role: string) {
|
||||
@ -116,8 +162,13 @@ export class SitesApi extends RepoApi {
|
||||
role: role
|
||||
};
|
||||
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.updateSiteMembership(siteId, userId, siteRole);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.updateSiteMember.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async addSiteMember(siteId: string, userId: string, role: string) {
|
||||
@ -126,35 +177,50 @@ export class SitesApi extends RepoApi {
|
||||
role: role
|
||||
};
|
||||
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.createSiteMembership(siteId, memberBody);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.addSiteMember.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async deleteSiteMember(siteId: string, userId: string) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.deleteSiteMembership(siteId, userId);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.deleteSiteMember.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async requestToJoin(siteId: string): Promise<SiteMembershipRequestEntry|null> {
|
||||
const body = {
|
||||
id: siteId
|
||||
};
|
||||
await this.apiAuth();
|
||||
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.sitesApi.createSiteMembershipRequestForPerson('-me-', body);
|
||||
} catch (error) {
|
||||
console.log('====== requestToJoin catch ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.requestToJoin.name}`, error);
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
async hasMembershipRequest(siteId: string) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
const requests = (await this.sitesApi.getSiteMembershipRequests('-me-')).list.entries.map(e => e.entry.id);
|
||||
return requests.includes(siteId);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.hasMembershipRequest.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async waitForApi(data) {
|
||||
async waitForApi(data: { expect: number }) {
|
||||
try {
|
||||
const sites = async () => {
|
||||
const totalItems = (await this.getSites()).list.pagination.totalItems;
|
||||
@ -167,7 +233,8 @@ export class SitesApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(sites);
|
||||
} catch (error) {
|
||||
console.log('-----> catch sites: ', error);
|
||||
console.log(`${this.constructor.name} ${this.waitForApi.name} catch: `);
|
||||
console.log(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,33 +35,51 @@ export class TrashcanApi extends RepoApi {
|
||||
}
|
||||
|
||||
async permanentlyDelete(id: string) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.trashcanApi.deleteDeletedNode(id);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.permanentlyDelete.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async restore(id: string) {
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.trashcanApi.restoreDeletedNode(id);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.restore.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getDeletedNodes() {
|
||||
const opts = {
|
||||
maxItems: 1000
|
||||
};
|
||||
try {
|
||||
await this.apiAuth();
|
||||
return await this.trashcanApi.listDeletedNodes(opts);
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.getDeletedNodes.name}`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async emptyTrash() {
|
||||
try {
|
||||
const ids = (await this.getDeletedNodes()).list.entries.map(entries => entries.entry.id);
|
||||
|
||||
return await ids.reduce(async (previous, current) => {
|
||||
await previous;
|
||||
return await this.permanentlyDelete(current);
|
||||
}, Promise.resolve());
|
||||
} catch (error) {
|
||||
this.handleError(`${this.constructor.name} ${this.emptyTrash.name}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
async waitForApi(data) {
|
||||
async waitForApi(data: { expect: number }) {
|
||||
try {
|
||||
const deletedFiles = async () => {
|
||||
const totalItems = (await this.getDeletedNodes()).list.pagination.totalItems;
|
||||
@ -74,7 +92,8 @@ export class TrashcanApi extends RepoApi {
|
||||
|
||||
return await Utils.retryCall(deletedFiles);
|
||||
} catch (error) {
|
||||
console.log('-----> catch trash: ', error);
|
||||
console.log(`${this.constructor.name} ${this.waitForApi.name} catch: `);
|
||||
console.log(`\tExpected: ${data.expect} items, but found ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,8 +43,12 @@ export class UploadApi extends RepoApi {
|
||||
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, parentFolderId: string = '-my-', newName: string) {
|
||||
@ -58,11 +62,8 @@ export class UploadApi extends RepoApi {
|
||||
await this.apiAuth();
|
||||
return await this.upload.uploadFile(file, '', parentFolderId, null, opts);
|
||||
} catch (error) {
|
||||
console.log('=== catch upload file with rename: ', error);
|
||||
this.handleError(`${this.constructor.name} ${this.uploadFileWithRename.name}`, error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ export class Utils {
|
||||
}
|
||||
|
||||
static async waitUntilElementClickable(element: ElementFinder) {
|
||||
return await browser.wait(EC.elementToBeClickable(element), BROWSER_WAIT_TIMEOUT).catch(Error);
|
||||
await browser.wait(EC.elementToBeClickable(element), BROWSER_WAIT_TIMEOUT).catch(Error);
|
||||
}
|
||||
|
||||
static async typeInField(elem: ElementFinder, value: string) {
|
||||
@ -156,22 +156,21 @@ export class Utils {
|
||||
}
|
||||
|
||||
static async pressEscape() {
|
||||
return await browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
|
||||
await browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
|
||||
}
|
||||
|
||||
static async pressTab() {
|
||||
return await browser.actions().sendKeys(protractor.Key.TAB).perform();
|
||||
await browser.actions().sendKeys(protractor.Key.TAB).perform();
|
||||
}
|
||||
|
||||
static async getBrowserLog() {
|
||||
return await browser.manage().logs().get('browser');
|
||||
return browser.manage().logs().get('browser');
|
||||
}
|
||||
|
||||
static formatDate(date: string) {
|
||||
return new Date(date).toLocaleDateString('en-US');
|
||||
}
|
||||
|
||||
|
||||
static async uploadFileNewVersion(fileFromOS: string) {
|
||||
const el = browser.element(by.id('app-upload-file-version'));
|
||||
await el.sendKeys(`${E2E_ROOT_PATH}/resources/test-files/${fileFromOS}`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user