mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACA-1920] automate tests for Create file from template (#1303)
* change component ancestor from ElementFinder to string for better usability better naming for some methods small code cleanup * add test components and automate tests for Create File from Template action * ignore e2e-downloads folder * add return types * enable check * enable check after issue got fixed
This commit is contained in:
committed by
Cilibiu Bogdan
parent
0bc4a3453b
commit
569ee98e8d
@@ -57,7 +57,6 @@ export class DataTable extends Component {
|
||||
|
||||
emptyListTitle: '.adf-empty-content__title',
|
||||
emptyListSubtitle: '.adf-empty-content__subtitle',
|
||||
emptyListText: '.adf-empty-content__text',
|
||||
|
||||
emptySearchText: '.empty-search__text',
|
||||
|
||||
@@ -73,55 +72,55 @@ export class DataTable extends Component {
|
||||
emptyFolderDragAndDrop: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyFolderDragAndDrop));
|
||||
emptyListTitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListTitle));
|
||||
emptyListSubtitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListSubtitle));
|
||||
emptyListText: ElementArrayFinder = this.component.all(by.css(DataTable.selectors.emptyListText));
|
||||
emptyListContainerText: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListContainer));
|
||||
|
||||
emptySearchText: ElementFinder = this.component.element(by.css(DataTable.selectors.emptySearchText));
|
||||
|
||||
menu: Menu = new Menu();
|
||||
|
||||
constructor(ancestor?: ElementFinder) {
|
||||
constructor(ancestor?: string) {
|
||||
super(DataTable.selectors.root, ancestor);
|
||||
}
|
||||
|
||||
// Wait methods (waits for elements)
|
||||
async waitForHeader() {
|
||||
async waitForHeader(): Promise<void> {
|
||||
await browser.wait(EC.presenceOf(this.head), BROWSER_WAIT_TIMEOUT, '--- timeout waitForHeader ---');
|
||||
}
|
||||
|
||||
async waitForBody() {
|
||||
async waitForBody(): Promise<void> {
|
||||
await browser.wait(EC.presenceOf(this.body), BROWSER_WAIT_TIMEOUT, '--- timeout waitForBody ---');
|
||||
}
|
||||
|
||||
async waitForEmptyState() {
|
||||
async waitForEmptyState(): Promise<void> {
|
||||
await browser.wait(EC.presenceOf(this.emptyList), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
|
||||
// Header/Column methods
|
||||
getColumnHeaders() {
|
||||
getColumnHeaders(): ElementArrayFinder {
|
||||
const locator = by.css(DataTable.selectors.columnHeader);
|
||||
return this.head.all(locator);
|
||||
}
|
||||
|
||||
async getColumnHeadersText() {
|
||||
async getColumnHeadersText(): Promise<string> {
|
||||
const el = this.getColumnHeaders();
|
||||
return el.getText();
|
||||
}
|
||||
|
||||
getNthColumnHeader(nth: number) {
|
||||
getNthColumnHeader(nth: number): ElementFinder {
|
||||
return this.getColumnHeaders().get(nth - 1);
|
||||
}
|
||||
|
||||
getColumnHeaderByLabel(label: string) {
|
||||
getColumnHeaderByLabel(label: string): ElementFinder {
|
||||
const locator = by.cssContainingText(DataTable.selectors.columnHeader, label);
|
||||
return this.head.element(locator);
|
||||
}
|
||||
|
||||
getSortedColumnHeader() {
|
||||
getSortedColumnHeader(): ElementFinder {
|
||||
const locator = by.css(DataTable.selectors.sortedColumnHeader);
|
||||
return this.head.element(locator);
|
||||
}
|
||||
|
||||
async getSortedColumnHeaderText() {
|
||||
async getSortedColumnHeaderText(): Promise<string> {
|
||||
return this.getSortedColumnHeader().getText();
|
||||
}
|
||||
|
||||
@@ -138,7 +137,7 @@ export class DataTable extends Component {
|
||||
return 'none';
|
||||
}
|
||||
|
||||
async sortByColumn(columnName: string) {
|
||||
async sortByColumn(columnName: string): Promise<void> {
|
||||
const column = this.getColumnHeaderByLabel(columnName);
|
||||
const click = browser.actions().mouseMove(column).click();
|
||||
|
||||
@@ -146,27 +145,38 @@ export class DataTable extends Component {
|
||||
}
|
||||
|
||||
// Rows methods
|
||||
getRows() {
|
||||
getRows(): ElementArrayFinder {
|
||||
return this.body.all(by.css(DataTable.selectors.row));
|
||||
}
|
||||
|
||||
async countRows() {
|
||||
async getRowsCount(): Promise<number> {
|
||||
return this.getRows().count();
|
||||
}
|
||||
|
||||
getSelectedRows() {
|
||||
async waitForRowToBeSelected(): Promise<void> {
|
||||
await browser.wait(EC.presenceOf(this.component.element(by.css(DataTable.selectors.selectedRow))), BROWSER_WAIT_TIMEOUT, 'timeout waiting for row to be selected');
|
||||
}
|
||||
|
||||
getSelectedRows(): ElementArrayFinder {
|
||||
return this.body.all(by.css(DataTable.selectors.selectedRow));
|
||||
}
|
||||
|
||||
async countSelectedRows() {
|
||||
async getSelectedRowsNames(): Promise<string[]> {
|
||||
const rowsText: string[] = await this.getSelectedRows().map((row) => {
|
||||
return row.element(by.css('.adf-datatable-cell[title="Name"]')).getText();
|
||||
});
|
||||
return rowsText;
|
||||
}
|
||||
|
||||
async getSelectedRowsCount(): Promise<number> {
|
||||
return this.getSelectedRows().count();
|
||||
}
|
||||
|
||||
getNthRow(nth: number) {
|
||||
getNthRow(nth: number): ElementFinder {
|
||||
return this.getRows().get(nth - 1);
|
||||
}
|
||||
|
||||
getRowByName(name: string, location: string = '') {
|
||||
getRowByName(name: string, location: string = ''): ElementFinder {
|
||||
if (location) {
|
||||
return this.body.all(by.cssContainingText(DataTable.selectors.row, name))
|
||||
.filter(async (elem) => await browser.isElementPresent(elem.element(by.cssContainingText(DataTable.selectors.cell, location))))
|
||||
@@ -175,46 +185,46 @@ export class DataTable extends Component {
|
||||
return this.body.element(by.cssContainingText(DataTable.selectors.row, name));
|
||||
}
|
||||
|
||||
getRowCells(name: string, location: string = '') {
|
||||
getRowCells(name: string, location: string = ''): ElementArrayFinder {
|
||||
return this.getRowByName(name, location).all(by.css(DataTable.selectors.cell));
|
||||
}
|
||||
|
||||
async getRowCellsCount(itemName: string) {
|
||||
async getRowCellsCount(itemName: string): Promise<number> {
|
||||
return this.getRowCells(itemName).count();
|
||||
}
|
||||
|
||||
getRowFirstCell(name: string, location: string = '') {
|
||||
getRowFirstCell(name: string, location: string = ''): ElementFinder {
|
||||
return this.getRowCells(name, location).get(0);
|
||||
}
|
||||
|
||||
getRowNameCell(name: string, location: string = '') {
|
||||
getRowNameCell(name: string, location: string = ''): ElementFinder {
|
||||
return this.getRowCells(name, location).get(1);
|
||||
}
|
||||
|
||||
getRowNameCellSpan(name: string, location: string = '') {
|
||||
getRowNameCellSpan(name: string, location: string = ''): ElementFinder {
|
||||
return this.getRowNameCell(name, location).$('span');
|
||||
}
|
||||
|
||||
async getItemNameTooltip(name: string, location: string = '') {
|
||||
async getItemNameTooltip(name: string, location: string = ''): Promise<string> {
|
||||
return this.getRowNameCellSpan(name, location).getAttribute('title');
|
||||
}
|
||||
|
||||
async hasCheckMarkIcon(itemName: string, location: string = '') {
|
||||
const row = this.getRowByName(itemName, location);
|
||||
async hasCheckMarkIcon(itemName: string, location: string = ''): Promise<boolean> {
|
||||
const row: ElementFinder = this.getRowByName(itemName, location);
|
||||
return row.element(by.css(DataTable.selectors.selectedIcon)).isPresent();
|
||||
}
|
||||
|
||||
async hasLockIcon(itemName: string, location: string = '') {
|
||||
const row = this.getRowByName(itemName, location);
|
||||
async hasLockIcon(itemName: string, location: string = ''): Promise<boolean> {
|
||||
const row: ElementFinder = this.getRowByName(itemName, location);
|
||||
return row.element(by.css(DataTable.selectors.lockIcon)).isPresent();
|
||||
}
|
||||
|
||||
async hasLockOwnerInfo(itemName: string, location: string = '') {
|
||||
const row = this.getRowByName(itemName, location);
|
||||
async hasLockOwnerInfo(itemName: string, location: string = ''): Promise<boolean> {
|
||||
const row: ElementFinder = this.getRowByName(itemName, location);
|
||||
return row.element(by.css(DataTable.selectors.lockOwner)).isPresent();
|
||||
}
|
||||
|
||||
async getLockOwner(itemName: string, location: string = '') {
|
||||
async getLockOwner(itemName: string, location: string = ''): Promise<string> {
|
||||
if (await this.hasLockOwnerInfo(itemName, location)) {
|
||||
const row = this.getRowByName(itemName, location);
|
||||
return row.$(DataTable.selectors.lockOwner).$('.locked_by--name').getText();
|
||||
@@ -222,16 +232,16 @@ export class DataTable extends Component {
|
||||
return '';
|
||||
}
|
||||
|
||||
getNameLink(itemName: string) {
|
||||
getNameLink(itemName: string): ElementFinder {
|
||||
return this.getRowNameCell(itemName).$(DataTable.selectors.nameLink);
|
||||
}
|
||||
|
||||
async hasLinkOnName(itemName: string) {
|
||||
async hasLinkOnName(itemName: string): Promise<boolean> {
|
||||
return this.getNameLink(itemName).isPresent();
|
||||
}
|
||||
|
||||
// Navigation/selection methods
|
||||
async doubleClickOnRowByName(name: string, location: string = '') {
|
||||
async doubleClickOnRowByName(name: string, location: string = ''): Promise<void> {
|
||||
try {
|
||||
const item = this.getRowFirstCell(name, location);
|
||||
await Utils.waitUntilElementClickable(item);
|
||||
@@ -242,7 +252,7 @@ export class DataTable extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
async selectItem(name: string, location: string = '') {
|
||||
async selectItem(name: string, location: string = ''): Promise<void> {
|
||||
const isSelected = await this.hasCheckMarkIcon(name, location);
|
||||
if (!isSelected) {
|
||||
try {
|
||||
@@ -253,19 +263,18 @@ export class DataTable extends Component {
|
||||
console.log('--- select item catch : ', e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async clickItem(name: string, location: string = '') {
|
||||
async clickItem(name: string, location: string = ''): Promise<void> {
|
||||
const item = this.getRowFirstCell(name, location);
|
||||
await item.click();
|
||||
}
|
||||
|
||||
async clickNameLink(itemName: string) {
|
||||
async clickNameLink(itemName: string): Promise<void> {
|
||||
await this.getNameLink(itemName).click();
|
||||
}
|
||||
|
||||
async selectMultipleItems(names: string[], location: string = '') {
|
||||
async selectMultipleItems(names: string[], location: string = ''): Promise<void> {
|
||||
await this.clearSelection();
|
||||
await browser.actions().sendKeys(protractor.Key.COMMAND).perform();
|
||||
for (const name of names) {
|
||||
@@ -274,9 +283,9 @@ export class DataTable extends Component {
|
||||
await browser.actions().sendKeys(protractor.Key.NULL).perform();
|
||||
}
|
||||
|
||||
async clearSelection() {
|
||||
async clearSelection(): Promise<void> {
|
||||
try {
|
||||
const count = await this.countSelectedRows();
|
||||
const count = await this.getSelectedRowsCount();
|
||||
if (count !== 0) {
|
||||
await browser.refresh();
|
||||
await this.wait();
|
||||
@@ -286,27 +295,27 @@ export class DataTable extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
async rightClickOnItem(itemName: string) {
|
||||
async rightClickOnItem(itemName: string): Promise<void> {
|
||||
const item = this.getRowFirstCell(itemName);
|
||||
await browser.actions().mouseMove(item).perform();
|
||||
await browser.actions().click(protractor.Button.RIGHT).perform();
|
||||
}
|
||||
|
||||
async rightClickOnMultipleSelection() {
|
||||
async rightClickOnMultipleSelection(): Promise<void> {
|
||||
const itemFromSelection = this.getSelectedRows().get(0);
|
||||
await browser.actions().mouseMove(itemFromSelection).perform();
|
||||
await browser.actions().click(protractor.Button.RIGHT).perform();
|
||||
}
|
||||
|
||||
getItemLocationEl(name: string) {
|
||||
getItemLocationEl(name: string): ElementFinder {
|
||||
return this.getRowByName(name).element(by.css(DataTable.selectors.locationLink));
|
||||
}
|
||||
|
||||
async getItemLocation(name: string) {
|
||||
async getItemLocation(name: string): Promise<string> {
|
||||
return this.getItemLocationEl(name).getText();
|
||||
}
|
||||
|
||||
async getItemLocationTooltip(name: string) {
|
||||
async getItemLocationTooltip(name: string): Promise<string> {
|
||||
const location = this.getItemLocationEl(name).$('a');
|
||||
const condition = () => location.getAttribute('title').then(value => value && value.length > 0);
|
||||
|
||||
@@ -316,16 +325,16 @@ export class DataTable extends Component {
|
||||
return location.getAttribute('title');
|
||||
}
|
||||
|
||||
async clickItemLocation(name: string) {
|
||||
async clickItemLocation(name: string): Promise<void> {
|
||||
await this.getItemLocationEl(name).click();
|
||||
}
|
||||
|
||||
// empty state methods
|
||||
async isEmptyList() {
|
||||
async isEmpty(): Promise<boolean> {
|
||||
return this.emptyList.isPresent();
|
||||
}
|
||||
|
||||
async isEmptyWithDragAndDrop() {
|
||||
async isEmptyWithDragAndDrop(): Promise<boolean> {
|
||||
return this.emptyFolderDragAndDrop.isDisplayed();
|
||||
}
|
||||
|
||||
@@ -334,66 +343,68 @@ export class DataTable extends Component {
|
||||
if (isEmpty) {
|
||||
return this.emptyFolderDragAndDrop.getText();
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
async getEmptyStateTitle(): Promise<string> {
|
||||
const isEmpty = await this.isEmptyList();
|
||||
const isEmpty = await this.isEmpty();
|
||||
if (isEmpty) {
|
||||
return this.emptyListTitle.getText();
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
async getEmptyStateSubtitle(): Promise<string> {
|
||||
const isEmpty = await this.isEmptyList();
|
||||
const isEmpty = await this.isEmpty();
|
||||
if (isEmpty) {
|
||||
return this.emptyListSubtitle.getText();
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
async getEmptyStateText(): Promise<string> {
|
||||
const isEmpty = await this.isEmptyList();
|
||||
async getEmptyListText(): Promise<string> {
|
||||
const isEmpty = await this.isEmpty();
|
||||
if (isEmpty) {
|
||||
return this.emptyListText.getText();
|
||||
return this.component.element(by.css('adf-custom-empty-content-template')).getText();
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
async getEmptySearchResultsText() {
|
||||
async getEmptySearchResultsText(): Promise<string> {
|
||||
return this.emptySearchText.getText();
|
||||
}
|
||||
|
||||
async getCellsContainingName(name: string) {
|
||||
const rows = this.getRows().all(by.cssContainingText(DataTable.selectors.cell, name));
|
||||
return rows.map(async cell => await cell.getText());
|
||||
async getCellsContainingName(name: string): Promise<string[]> {
|
||||
const rows: ElementArrayFinder = this.getRows().all(by.cssContainingText(DataTable.selectors.cell, name));
|
||||
const cellsText: string[] = await rows.map(async cell => {
|
||||
return cell.getText();
|
||||
});
|
||||
return cellsText;
|
||||
}
|
||||
|
||||
async hasContextMenu() {
|
||||
async hasContextMenu(): Promise<boolean> {
|
||||
const count = await this.menu.getItemsCount();
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
async getLibraryRole(name: string) {
|
||||
async getLibraryRole(name: string): Promise<string> {
|
||||
return this.getRowByName(name).element(by.css(DataTable.selectors.libraryRole)).getText();
|
||||
}
|
||||
|
||||
async isItemPresent(name: string, location? : string) {
|
||||
async isItemPresent(name: string, location? : string): Promise<boolean> {
|
||||
return this.getRowByName(name, location).isPresent();
|
||||
}
|
||||
|
||||
async getEntireDataTableText() {
|
||||
return this.getRows().map((row) => {
|
||||
return row.all(by.css(DataTable.selectors.cell)).map(async cell => await cell.getText());
|
||||
async getEntireDataTableText(): Promise<string[]> {
|
||||
const text: string[] = await this.getRows().map((row) => {
|
||||
return row.all(by.css(DataTable.selectors.cell)).map(async cell => {
|
||||
return cell.getText();
|
||||
});
|
||||
});
|
||||
return text;
|
||||
}
|
||||
|
||||
async getSitesNameAndVisibility() {
|
||||
async getSitesNameAndVisibility(): Promise<{}> {
|
||||
const data = await this.getEntireDataTableText();
|
||||
return data.reduce((acc, cell) => {
|
||||
acc[cell[1]] = cell[3].toUpperCase();
|
||||
@@ -401,7 +412,7 @@ export class DataTable extends Component {
|
||||
}, {});
|
||||
}
|
||||
|
||||
async getSitesNameAndRole() {
|
||||
async getSitesNameAndRole(): Promise<{}> {
|
||||
const data = await this.getEntireDataTableText();
|
||||
return data.reduce((acc, cell) => {
|
||||
acc[cell[1]] = cell[2];
|
||||
@@ -417,7 +428,7 @@ export class DataTable extends Component {
|
||||
return this.getSearchResultsRows().get(nth - 1);
|
||||
}
|
||||
|
||||
getSearchResultsRowByName(name: string, location: string = '') {
|
||||
getSearchResultsRowByName(name: string, location: string = ''): ElementFinder {
|
||||
if (location) {
|
||||
return this.body.all(by.cssContainingText(DataTable.selectors.searchResultsRow, name))
|
||||
.filter(async (elem) => await browser.isElementPresent(elem.element(by.cssContainingText(DataTable.selectors.searchResultsRowLine, location))))
|
||||
@@ -426,43 +437,43 @@ export class DataTable extends Component {
|
||||
return this.body.element(by.cssContainingText(DataTable.selectors.searchResultsRow, name));
|
||||
}
|
||||
|
||||
getSearchResultRowLines(name: string, location: string = '') {
|
||||
getSearchResultRowLines(name: string, location: string = ''): ElementArrayFinder {
|
||||
return this.getSearchResultsRowByName(name, location).all(by.css(DataTable.selectors.searchResultsRowLine));
|
||||
}
|
||||
|
||||
async getSearchResultLinesCount(name: string, location: string = '') {
|
||||
async getSearchResultLinesCount(name: string, location: string = ''): Promise<number> {
|
||||
return this.getSearchResultRowLines(name, location).count();
|
||||
}
|
||||
|
||||
getSearchResultNthLine(name: string, location: string = '', index: number) {
|
||||
getSearchResultNthLine(name: string, location: string = '', index: number): ElementFinder {
|
||||
return this.getSearchResultRowLines(name, location).get(index);
|
||||
}
|
||||
|
||||
async getSearchResultNameAndTitle(name: string, location: string = '') {
|
||||
async getSearchResultNameAndTitle(name: string, location: string = ''): Promise<string> {
|
||||
return this.getSearchResultNthLine(name, location, 0).getText();
|
||||
}
|
||||
|
||||
async getSearchResultDescription(name: string, location: string = '') {
|
||||
async getSearchResultDescription(name: string, location: string = ''): Promise<string> {
|
||||
return this.getSearchResultNthLine(name, location, 1).getText();
|
||||
}
|
||||
|
||||
async getSearchResultModified(name: string, location: string = '') {
|
||||
async getSearchResultModified(name: string, location: string = ''): Promise<string> {
|
||||
return this.getSearchResultNthLine(name, location, 2).getText();
|
||||
}
|
||||
|
||||
async getSearchResultLocation(name: string, location: string = '') {
|
||||
async getSearchResultLocation(name: string, location: string = ''): Promise<string> {
|
||||
return this.getSearchResultNthLine(name, location, 3).getText();
|
||||
}
|
||||
|
||||
getSearchResultNameLink(itemName: string, location: string = '') {
|
||||
getSearchResultNameLink(itemName: string, location: string = ''): ElementFinder {
|
||||
return this.getSearchResultsRowByName(itemName, location).$(DataTable.selectors.searchResultsNameLink);
|
||||
}
|
||||
|
||||
async hasLinkOnSearchResultName(itemName: string, location: string = '') {
|
||||
async hasLinkOnSearchResultName(itemName: string, location: string = ''): Promise<boolean> {
|
||||
return this.getSearchResultNameLink(itemName, location).isPresent();
|
||||
}
|
||||
|
||||
async clickSearchResultNameLink(itemName: string, location: string = '') {
|
||||
async clickSearchResultNameLink(itemName: string, location: string = ''): Promise<void> {
|
||||
await this.getSearchResultNameLink(itemName, location).click();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user