mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
* [ADF-3696] Create an automated test to cover the search filter buckets * Removing comments * Removing spaces and xit * Minor changes * Add spaces where needed * Changing locator * Changes on the splitting of names * Changing to single quotes
387 lines
15 KiB
JavaScript
387 lines
15 KiB
JavaScript
/*!
|
|
* @license
|
|
* Copyright 2016 Alfresco Software, Ltd.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
var Util = require('../../../util/util');
|
|
|
|
var ContentList = function () {
|
|
|
|
var deleteContent = element(by.css("button[data-automation-id*='DELETE']"));
|
|
var metadataAction = element(by.css("button[data-automation-id*='METADATA']"));
|
|
var versionManagerAction = element(by.css("button[data-automation-id*='VERSIONS']"));
|
|
var moveContent = element(by.css("button[data-automation-id*='MOVE']"));
|
|
var copyContent = element(by.css("button[data-automation-id*='COPY']"));
|
|
var downloadContent = element(by.css("button[data-automation-id*='DOWNLOAD']"));
|
|
var actionMenu = element(by.css("div[role='menu']"));
|
|
var optionButton = by.css("button[data-automation-id*='action_menu_']");
|
|
var rowByRowName = by.xpath("ancestor::div[contains(@class, 'adf-datatable-row')]");
|
|
var nameColumn = by.css('div[class*="datatable-body"] div[class*="adf-data-table-cell"][title="Display name"]');
|
|
var nameColumnHeader = by.css("div[data-automation-id='auto_id_name']");
|
|
var createdByColumn = by.css("div[class*='--text'][title='Created by'] span");
|
|
var sizeColumn = by.css("div[id*='document-list-container'] div[class*='adf-datatable-row'] .adf-filesize-cell");
|
|
var createdByColumnHeader = by.css("div[data-automation-id*='auto_id_createdByUser']");
|
|
var createdColumn = by.css("div[class*='--date'] span");
|
|
var createdColumnHeader = by.css("div[data-automation-id*='auto_id_createdAt']");
|
|
var rows = by.css("div[id='document-list-container'] div[class*='adf-datatable-body'] div[class*='adf-datatable-row']");
|
|
var emptyFolderMessage = element(by.css("div[class='adf-empty-folder-this-space-is-empty']"));
|
|
var table = element(by.css("div[class*='upload-border']"));
|
|
|
|
this.getRowsName = function (content) {
|
|
var row = element.all(by.xpath("//div[@id='document-list-container']//div[@filename='" + content + "']")).first();
|
|
Util.waitUntilElementIsVisible(row);
|
|
return row;
|
|
};
|
|
|
|
this.getRowByRowName = function (content) {
|
|
Util.waitUntilElementIsOnPage(this.getRowsName(content).element(rowByRowName));
|
|
Util.waitUntilElementIsVisible(this.getRowsName(content).element(rowByRowName));
|
|
return this.getRowsName(content).element(rowByRowName);
|
|
};
|
|
|
|
this.getAllDisplayedRows = function () {
|
|
return element.all(rows).count();
|
|
};
|
|
|
|
this.getAllRowsNameColumn = function () {
|
|
return this.getAllRowsColumnValues(nameColumn);
|
|
};
|
|
|
|
this.getAllRowsColumnValues = function (locator) {
|
|
var deferred = protractor.promise.defer();
|
|
Util.waitUntilElementIsVisible(element.all(locator).first());
|
|
var initialList = [];
|
|
|
|
element.all(locator).each(function (element) {
|
|
element.getText().then(function (text) {
|
|
if (text !== '') {
|
|
initialList.push(text);
|
|
}
|
|
});
|
|
}).then(function () {
|
|
deferred.fulfill(initialList);
|
|
});
|
|
|
|
return deferred.promise;
|
|
};
|
|
|
|
this.deleteContent = function (content) {
|
|
this.clickOnActionMenu(content);
|
|
this.waitForContentOptions();
|
|
deleteContent.click();
|
|
};
|
|
|
|
this.checkDeleteIsDisabled = function (content) {
|
|
this.clickOnActionMenu(content);
|
|
this.waitForContentOptions();
|
|
let disabledDelete = element(by.css("button[data-automation-id*='DELETE'][disabled='true']"));
|
|
Util.waitUntilElementIsVisible(disabledDelete);
|
|
};
|
|
|
|
this.metadataContent = function (content) {
|
|
this.clickOnActionMenu(content);
|
|
this.waitForContentOptions();
|
|
metadataAction.click();
|
|
};
|
|
|
|
this.versionManagerContent = function (content) {
|
|
this.clickOnActionMenu(content);
|
|
this.waitForContentOptions();
|
|
versionManagerAction.click();
|
|
};
|
|
|
|
this.moveContent = function (content) {
|
|
this.clickOnActionMenu(content);
|
|
moveContent.click();
|
|
};
|
|
|
|
this.copyContent = function (content) {
|
|
this.clickOnActionMenu(content);
|
|
copyContent.click();
|
|
};
|
|
|
|
this.waitForContentOptions = function () {
|
|
Util.waitUntilElementIsVisible(copyContent);
|
|
Util.waitUntilElementIsVisible(moveContent);
|
|
Util.waitUntilElementIsVisible(deleteContent);
|
|
Util.waitUntilElementIsVisible(downloadContent);
|
|
};
|
|
|
|
this.clickOnActionMenu = function (content) {
|
|
this.getRowByRowName(content).element(optionButton).click();
|
|
Util.waitUntilElementIsVisible(actionMenu);
|
|
return this;
|
|
};
|
|
|
|
this.sortByColumn = function (sortOrder, locator) {
|
|
Util.waitUntilElementIsVisible(element(locator));
|
|
return element(locator).getAttribute('class').then(function (result) {
|
|
if (sortOrder === true) {
|
|
if (!result.includes('sorted-asc')) {
|
|
if (result.includes('sorted-desc') || result.includes('sortable')) {
|
|
element(locator).click();
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
if (result.includes('sorted-asc')) {
|
|
element(locator).click();
|
|
} else if (result.includes('sortable')) {
|
|
element(locator).click();
|
|
element(locator).click();
|
|
}
|
|
}
|
|
|
|
return Promise.resolve();
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Sort the list by name column.
|
|
*
|
|
* @param sortOrder: 'true' to sort the list ascendant and 'false' for descendant
|
|
*/
|
|
this.sortByName = function (sortOrder) {
|
|
this.sortByColumn(sortOrder, nameColumnHeader);
|
|
};
|
|
|
|
/**
|
|
* Sort the list by author column.
|
|
*
|
|
* @param sortOrder: 'true' to sort the list ascendant and 'false' for descendant
|
|
*/
|
|
this.sortByAuthor = function (sortOrder) {
|
|
this.sortByColumn(sortOrder, createdByColumnHeader);
|
|
};
|
|
|
|
/**
|
|
* Sort the list by created column.
|
|
*
|
|
* @param sortOrder: 'true' to sort the list ascendant and 'false' for descendant
|
|
*/
|
|
this.sortByCreated = function (sortOrder) {
|
|
this.sortByColumn(sortOrder, createdColumnHeader);
|
|
};
|
|
|
|
/**
|
|
* Check the list is sorted by name column.
|
|
*
|
|
* @param sortOrder: 'true' if the list is expected to be sorted ascendant and 'false' for descendant
|
|
* @return sorted : 'true' if the list is sorted as expected and 'false' if it isn't
|
|
*/
|
|
this.checkListIsOrderedByNameColumn = function (sortOrder) {
|
|
var deferred = protractor.promise.defer();
|
|
deferred.fulfill(this.checkListIsSorted(sortOrder, nameColumn));
|
|
return deferred.promise;
|
|
};
|
|
|
|
/**
|
|
* Check the list is sorted by author column.
|
|
*
|
|
* @param sortOrder: 'true' if the list is expected to be sorted ascendant and 'false' for descendant
|
|
* @return sorted : 'true' if the list is sorted as expected and 'false' if it isn't
|
|
*/
|
|
this.checkListIsOrderedByAuthorColumn = function (sortOrder) {
|
|
var deferred = protractor.promise.defer();
|
|
deferred.fulfill(this.checkListIsSorted(sortOrder, createdByColumn));
|
|
return deferred.promise;
|
|
};
|
|
|
|
this.checkListIsOrderedBySizeColumn = function (sortOrder) {
|
|
var deferred = protractor.promise.defer();
|
|
deferred.fulfill(this.checkListIsSorted(sortOrder, sizeColumn));
|
|
return deferred.promise;
|
|
};
|
|
|
|
/**
|
|
* Check the list is sorted by created column.
|
|
*
|
|
* @param sortOrder: 'true' if the list is expected to be sorted ascendant and 'false' for descendant
|
|
* @return sorted : 'true' if the list is sorted as expected and 'false' if it isn't
|
|
*/
|
|
this.checkListIsOrderedByCreatedColumn = function (sortOrder) {
|
|
var deferred = protractor.promise.defer();
|
|
var lastValue;
|
|
var sorted = true;
|
|
|
|
element.all(createdColumn).map(function (element) {
|
|
return element.getText();
|
|
}).then(function (texts) {
|
|
texts.forEach(function (text) {
|
|
if (lastValue !== undefined) {
|
|
var currentDate = new Date(text);
|
|
var lastDate = new Date(lastValue);
|
|
if (sortOrder === true && currentDate.getTime() < lastDate.getTime()) {
|
|
sorted = false;
|
|
}
|
|
if (sortOrder === false && currentDate.getTime() > lastDate.getTime()) {
|
|
sorted = false;
|
|
}
|
|
}
|
|
lastValue = text;
|
|
});
|
|
deferred.fulfill(sorted);
|
|
});
|
|
return deferred.promise;
|
|
};
|
|
|
|
/**
|
|
* Check the list is sorted.
|
|
*
|
|
* @param sortOrder: 'true' if the list is expected to be sorted ascendant and 'false' for descendant
|
|
* @param locator: locator for column
|
|
* @return 'true' if the list is sorted as expected and 'false' if it isn't
|
|
*/
|
|
this.checkListIsSorted = function (sortOrder, locator) {
|
|
var deferred = protractor.promise.defer();
|
|
Util.waitUntilElementIsVisible(element.all(locator).first());
|
|
var initialList = [];
|
|
element.all(locator).each(function (element) {
|
|
element.getText().then(function (text) {
|
|
initialList.push(text);
|
|
});
|
|
}).then(function () {
|
|
var sortedList = initialList;
|
|
sortedList = sortedList.sort();
|
|
if (sortOrder === false) {
|
|
sortedList = sortedList.reverse();
|
|
}
|
|
deferred.fulfill(initialList.toString() === sortedList.toString());
|
|
});
|
|
return deferred.promise;
|
|
};
|
|
|
|
this.navigateToFolder = function (folder) {
|
|
var row = this.getRowsName(folder);
|
|
Util.waitUntilElementIsVisible(row);
|
|
Util.waitUntilElementIsOnPage(row);
|
|
row.click();
|
|
this.checkRowIsSelected(folder);
|
|
browser.actions().sendKeys(protractor.Key.ENTER).perform();
|
|
return this;
|
|
};
|
|
|
|
this.doubleClickRow = function (selectRow) {
|
|
var row = this.getRowsName(selectRow);
|
|
Util.waitUntilElementIsVisible(row);
|
|
Util.waitUntilElementIsClickable(row);
|
|
row.click();
|
|
Util.waitUntilElementIsVisible(this.getRowByRowName(selectRow).element(by.css("div[class*='--image'] mat-icon[svgicon*='selected']")));
|
|
browser.actions().sendKeys(protractor.Key.ENTER).perform();
|
|
return this;
|
|
};
|
|
|
|
this.doubleClickEntireRow = function (selectRow) {
|
|
var row = this.getRowByRowName(selectRow);
|
|
Util.waitUntilElementIsVisible(row);
|
|
Util.waitUntilElementIsClickable(row);
|
|
row.click();
|
|
Util.waitUntilElementIsVisible(this.getRowByRowName(selectRow).element(by.css("div[class*='--image'] mat-icon[svgicon*='selected']")));
|
|
browser.actions().sendKeys(protractor.Key.ENTER).perform();
|
|
return this;
|
|
};
|
|
|
|
this.checkRowIsSelected = function (content) {
|
|
var isRowSelected = this.getRowsName(content).element(by.xpath("ancestor::div[contains(@class, 'is-selected')]"));
|
|
Util.waitUntilElementIsVisible(isRowSelected);
|
|
};
|
|
|
|
this.checkContentIsDisplayed = function (content) {
|
|
Util.waitUntilElementIsVisible(this.getRowByRowName(content));
|
|
return this;
|
|
};
|
|
|
|
this.checkContentIsNotDisplayed = function (filename) {
|
|
Util.waitUntilElementIsNotVisible(element.all(by.xpath("//div[@id='document-list-container']//div[@filename='" + filename + "']")).first());
|
|
return this;
|
|
};
|
|
|
|
this.getNodeIdByFilename = function (filename) {
|
|
var nodeIdColumn = element.all(by.xpath("//div[@id='document-list-container']//div[@filename='" + filename + "' and @title='Node id']"));
|
|
var text = nodeIdColumn.getText();
|
|
return text;
|
|
};
|
|
|
|
this.getAllNodeIdInList = async function (filename) {
|
|
var nodeIdColumns = await element.all(by.xpath("//div[@id='document-list-container']//div[@title='Node id']"));
|
|
return await nodeIdColumns.map(async (currentElement) => {
|
|
return await currentElement.getText().then((nodeText)=>{
|
|
return nodeText;
|
|
});
|
|
});
|
|
};
|
|
|
|
this.checkEmptyFolderMessageIsDisplayed = function () {
|
|
Util.waitUntilElementIsVisible(emptyFolderMessage);
|
|
return this;
|
|
};
|
|
|
|
this.tableIsLoaded = function () {
|
|
Util.waitUntilElementIsVisible(table);
|
|
return this;
|
|
};
|
|
|
|
this.checkIconColumn = function (file, extension) {
|
|
var row = this.getRowByRowName(file);
|
|
Util.waitUntilElementIsVisible(row.element(by.css("div[class*='--image'] img[alt*='" + extension + "']")));
|
|
};
|
|
|
|
this.rightClickOnRowNamed = function (rowName) {
|
|
let row = this.getRowByRowName(rowName);
|
|
browser.actions().click(row, protractor.Button.RIGHT).perform();
|
|
Util.waitUntilElementIsVisible(element(by.id('adf-context-menu-content')));
|
|
};
|
|
|
|
this.checkContextActionIsVisible = function (actionName) {
|
|
let actionButton = element(by.css(`button[data-automation-id="context-${actionName}"`));
|
|
Util.waitUntilElementIsVisible(actionButton);
|
|
Util.waitUntilElementIsClickable(actionButton);
|
|
return actionButton;
|
|
};
|
|
|
|
this.pressContextMenuActionNamed = function (actionName) {
|
|
let actionButton = this.checkContextActionIsVisible(actionName);
|
|
actionButton.click();
|
|
};
|
|
|
|
this.clickRowToSelect = function (rowName) {
|
|
let row = this.getRowByRowName(rowName);
|
|
browser.actions().keyDown(protractor.Key.COMMAND).click(row).perform();
|
|
this.checkRowIsSelected(rowName);
|
|
return this;
|
|
};
|
|
|
|
this.clickContentLockIcon = function (content) {
|
|
var lockIcon = element(by.css('div[filename="'+ content +'"] button'));
|
|
Util.waitUntilElementIsClickable(lockIcon);
|
|
lockIcon.click();
|
|
return this;
|
|
};
|
|
|
|
this.checkLockedIcon = function (content) {
|
|
var lockIcon = element(by.cssContainingText('div[filename="'+ content +'"] mat-icon', 'lock'));
|
|
Util.waitUntilElementIsVisible(lockIcon);
|
|
return this;
|
|
};
|
|
|
|
this.checkUnlockedIcon = function (content) {
|
|
var lockIcon = element(by.cssContainingText('div[filename="'+ content +'"] mat-icon', 'lock_open'));
|
|
Util.waitUntilElementIsVisible(lockIcon);
|
|
return this;
|
|
};
|
|
|
|
};
|
|
module.exports = ContentList;
|