mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
This reverts commit f27d62585b
.
This commit is contained in:
@@ -24,6 +24,7 @@ import { materialLocators } from './public-api';
|
||||
const MAX_LOADING_TIME = 120000;
|
||||
|
||||
export class DataTableComponentPage {
|
||||
|
||||
rootElement: ElementFinder;
|
||||
list: ElementArrayFinder;
|
||||
contents: ElementArrayFinder;
|
||||
@@ -38,22 +39,22 @@ export class DataTableComponentPage {
|
||||
noContentContainer: ElementFinder;
|
||||
mainMenuButton: ElementFinder;
|
||||
|
||||
rows = `adf-datatable tbody[class*='adf-datatable-body'] adf-datatable-row[class*='adf-datatable-row']`;
|
||||
rows = `adf-datatable div[class*='adf-datatable-body'] adf-datatable-row[class*='adf-datatable-row']`;
|
||||
|
||||
constructor(rootElement = $$('adf-datatable').first()) {
|
||||
this.rootElement = rootElement;
|
||||
this.list = this.rootElement.$$(`tbody[class*='adf-datatable-body'] adf-datatable-row[class*='adf-datatable-row']`);
|
||||
this.list = this.rootElement.$$(`div[class*='adf-datatable-body'] adf-datatable-row[class*='adf-datatable-row']`);
|
||||
this.contents = this.rootElement.$$('.adf-datatable-body span');
|
||||
this.tableBody = this.rootElement.$$(`.adf-datatable-body`).first();
|
||||
this.allColumns = this.rootElement.$$('div[data-automation-id*="auto_header_content_id"]');
|
||||
this.mainMenuButton = this.rootElement.$('[data-automation-id="adf-datatable-main-menu-button"]');
|
||||
this.selectedRowNumber = this.rootElement.$(`adf-datatable-row[class*='is-selected'] div[data-automation-id*='text_']`);
|
||||
this.allSelectedRows = this.rootElement.$$(`adf-datatable-row[class*='is-selected']`);
|
||||
this.selectAll = this.rootElement.$(`thead[class*='adf-datatable-header'] ${materialLocators.Checkbox.root}`);
|
||||
this.selectAll = this.rootElement.$(`div[class*='adf-datatable-header'] ${materialLocators.Checkbox.root}`);
|
||||
this.emptyList = this.rootElement.$(`adf-empty-content`);
|
||||
this.emptyListTitle = this.rootElement.$(`.adf-empty-content__title`);
|
||||
this.emptyListSubtitle = this.rootElement.$(`.adf-empty-content__subtitle`);
|
||||
this.noContentContainer = $(`td[class*='adf-no-content-container']`);
|
||||
this.noContentContainer = $(`div[class*='adf-no-content-container']`);
|
||||
}
|
||||
|
||||
geCellElementDetail(detail: string): ElementArrayFinder {
|
||||
@@ -113,23 +114,19 @@ export class DataTableComponentPage {
|
||||
}
|
||||
|
||||
async checkRowIsSelected(columnName: string, columnValue: string): Promise<void> {
|
||||
const selectedRow = this.getCellElementByValue(columnName, columnValue).element(
|
||||
by.xpath(`ancestor::adf-datatable-row[contains(@class, 'is-selected')]`)
|
||||
);
|
||||
const selectedRow = this.getCellElementByValue(columnName, columnValue).element(by.xpath(`ancestor::adf-datatable-row[contains(@class, 'is-selected')]`));
|
||||
await BrowserVisibility.waitUntilElementIsVisible(selectedRow);
|
||||
}
|
||||
|
||||
async checkRowIsNotSelected(columnName: string, columnValue: string): Promise<void> {
|
||||
const selectedRow = this.getCellElementByValue(columnName, columnValue).element(
|
||||
by.xpath(`ancestor::adf-datatable-row[contains(@class, 'is-selected')]`)
|
||||
);
|
||||
const selectedRow = this.getCellElementByValue(columnName, columnValue).element(by.xpath(`ancestor::adf-datatable-row[contains(@class, 'is-selected')]`));
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(selectedRow);
|
||||
}
|
||||
|
||||
async getColumnValueForRow(identifyingColumn: string, identifyingValue: string, columnName: string): Promise<string> {
|
||||
const row = this.getRow(identifyingColumn, identifyingValue);
|
||||
await BrowserVisibility.waitUntilElementIsVisible(row);
|
||||
const rowColumn = row.$(`td[title="${columnName}"] span`);
|
||||
const rowColumn = row.$(`div[title="${columnName}"] span`);
|
||||
return BrowserActions.getText(rowColumn);
|
||||
}
|
||||
|
||||
@@ -142,7 +139,7 @@ export class DataTableComponentPage {
|
||||
* @returns 'true' if the list is sorted as await expected and 'false' if it isn't
|
||||
*/
|
||||
async checkListIsSorted(sortOrder: string, columnTitle: string, listType: string = 'STRING'): Promise<any> {
|
||||
const column = $$(`td.adf-datatable-cell[title='${columnTitle}'] span`);
|
||||
const column = $$(`div.adf-datatable-cell[title='${columnTitle}'] span`);
|
||||
await BrowserVisibility.waitUntilElementIsVisible(column.first());
|
||||
const initialList: string[] = [];
|
||||
|
||||
@@ -232,14 +229,14 @@ export class DataTableComponentPage {
|
||||
|
||||
async getAllRowsColumnValues(column: string): Promise<string[]> {
|
||||
let columnValues: string[] = [];
|
||||
const columnLocator = $$(
|
||||
`adf-datatable tbody[class*='adf-datatable-body'] adf-datatable-row[class*='adf-datatable-row'] *[title="${column}"] span`
|
||||
);
|
||||
const columnLocator = $$(`adf-datatable div[class*='adf-datatable-body'] adf-datatable-row[class*='adf-datatable-row'] div[title="${column}"] span`);
|
||||
|
||||
await BrowserVisibility.waitUntilElementIsPresent(columnLocator.first(), 1000);
|
||||
try {
|
||||
await BrowserVisibility.waitUntilElementIsPresent(columnLocator.first(), 1000);
|
||||
columnValues = await columnLocator.filter(async (el) => el.isPresent()).map(async (el) => el.getText());
|
||||
columnValues = await columnLocator
|
||||
.filter(async (el) => el.isPresent())
|
||||
.map(async (el) => el.getText());
|
||||
} catch (error) {
|
||||
Logger.log(error);
|
||||
}
|
||||
@@ -248,7 +245,7 @@ export class DataTableComponentPage {
|
||||
}
|
||||
|
||||
async getRowsWithSameColumnValues(columnName: string, columnValue: string) {
|
||||
const columnLocator = `td[title='${columnName}'] div[data-automation-id="text_${columnValue}"] span`;
|
||||
const columnLocator = `div[title='${columnName}'] div[data-automation-id="text_${columnValue}"] span`;
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.rootElement.$$(columnLocator).first());
|
||||
return this.rootElement.$$(columnLocator).getText();
|
||||
}
|
||||
@@ -276,7 +273,7 @@ export class DataTableComponentPage {
|
||||
* @param titleColumn column title
|
||||
*/
|
||||
async sortByColumn(sortOrder: string, titleColumn: string): Promise<void> {
|
||||
const locator = $(`th[data-automation-id="auto_id_${titleColumn}"]`);
|
||||
const locator = $(`div[data-automation-id="auto_id_${titleColumn}"]`);
|
||||
await BrowserVisibility.waitUntilElementIsVisible(locator);
|
||||
const result = await BrowserActions.getAttribute(locator, 'class');
|
||||
|
||||
@@ -329,20 +326,12 @@ export class DataTableComponentPage {
|
||||
}
|
||||
|
||||
getRow(columnName: string, columnValue: string): ElementFinder {
|
||||
return this.rootElement
|
||||
.all(
|
||||
by.xpath(
|
||||
`//td[starts-with(@title, '${columnName}')]//div[contains(@data-automation-id, '${columnValue}')]//ancestor::adf-datatable-row[contains(@class, 'adf-datatable-row')]`
|
||||
)
|
||||
)
|
||||
.first();
|
||||
return this.rootElement.all(by.xpath(`//div[starts-with(@title, '${columnName}')]//div[contains(@data-automation-id, '${columnValue}')]//ancestor::adf-datatable-row[contains(@class, 'adf-datatable-row')]`)).first();
|
||||
}
|
||||
|
||||
// @deprecated use Playwright instead
|
||||
getRowByIndex(index: number): ElementFinder {
|
||||
return this.rootElement.element(
|
||||
by.xpath(`//div[contains(@class,'adf-datatable-body')]//adf-datatable-row[contains(@class,'adf-datatable-row')][${index}]`)
|
||||
);
|
||||
return this.rootElement.element(by.xpath(`//div[contains(@class,'adf-datatable-body')]//adf-datatable-row[contains(@class,'adf-datatable-row')][${index}]`));
|
||||
}
|
||||
|
||||
async contentInPosition(position: number): Promise<string> {
|
||||
@@ -351,7 +340,7 @@ export class DataTableComponentPage {
|
||||
}
|
||||
|
||||
getCellElementByValue(columnName: string, columnValue: string, columnPrefix = 'text_'): ElementFinder {
|
||||
return this.rootElement.$$(`td[title="${columnName}"] div[data-automation-id="${columnPrefix}${columnValue}"] span`).first();
|
||||
return this.rootElement.$$(`div[title="${columnName}"] div[data-automation-id="${columnPrefix}${columnValue}"] span`).first();
|
||||
}
|
||||
|
||||
async tableIsLoaded(): Promise<void> {
|
||||
@@ -361,27 +350,23 @@ export class DataTableComponentPage {
|
||||
async waitTillContentLoaded(): Promise<void> {
|
||||
if (await this.isSpinnerPresent()) {
|
||||
Logger.log('wait datatable loading spinner disappear');
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(
|
||||
this.rootElement.element(by.tagName(materialLocators.Progress.spinner.root)),
|
||||
MAX_LOADING_TIME
|
||||
);
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(this.rootElement.element(by.tagName(materialLocators.Progress.spinner.root)), MAX_LOADING_TIME);
|
||||
|
||||
if (await this.isEmpty()) {
|
||||
Logger.log('empty page');
|
||||
} else {
|
||||
await this.waitFirstElementPresent();
|
||||
}
|
||||
|
||||
} else if (await this.isEmpty()) {
|
||||
Logger.log('empty page');
|
||||
} else {
|
||||
try {
|
||||
Logger.log('wait datatable loading spinner is present');
|
||||
await BrowserVisibility.waitUntilElementIsVisible(this.rootElement.element(by.tagName(materialLocators.Progress.spinner.root)), 2000);
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(
|
||||
this.rootElement.element(by.tagName(materialLocators.Progress.spinner.root)),
|
||||
MAX_LOADING_TIME
|
||||
);
|
||||
} catch (error) {}
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(this.rootElement.element(by.tagName(materialLocators.Progress.spinner.root)), MAX_LOADING_TIME);
|
||||
} catch (error) {
|
||||
}
|
||||
|
||||
if (await this.isEmpty()) {
|
||||
Logger.log('empty page');
|
||||
@@ -407,7 +392,8 @@ export class DataTableComponentPage {
|
||||
try {
|
||||
Logger.log('wait datatable loading spinner is present');
|
||||
await BrowserVisibility.waitUntilElementIsVisible(element(by.tagName(materialLocators.Progress.bar.root)));
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
}
|
||||
if (await this.isEmpty()) {
|
||||
Logger.log('empty page');
|
||||
} else {
|
||||
@@ -418,10 +404,14 @@ export class DataTableComponentPage {
|
||||
|
||||
// @deprecated use Playwright instead
|
||||
async isColumnDisplayed(columnTitle: string): Promise<boolean> {
|
||||
return (await this.allColumns).some(async (column) => {
|
||||
const columnText = await column.getText();
|
||||
return columnText === columnTitle;
|
||||
});
|
||||
const isColumnDisplayed = (await this.allColumns).some(
|
||||
async column => {
|
||||
const columnText = await column.getText();
|
||||
return columnText === columnTitle;
|
||||
}
|
||||
);
|
||||
|
||||
return isColumnDisplayed;
|
||||
}
|
||||
|
||||
// @deprecated use Playwright instead
|
||||
@@ -434,11 +424,11 @@ export class DataTableComponentPage {
|
||||
}
|
||||
|
||||
getCellByRowNumberAndColumnName(rowNumber: number, columnName: string): ElementFinder {
|
||||
return this.list.get(rowNumber).$$(`td[title="${columnName}"] span`).first();
|
||||
return this.list.get(rowNumber).$$(`div[title="${columnName}"] span`).first();
|
||||
}
|
||||
|
||||
getCellByRowContentAndColumn(rowColumn: string, rowContent: string, columnName: string): ElementFinder {
|
||||
return this.getRow(rowColumn, rowContent).$(`td[title='${columnName}']`);
|
||||
return this.getRow(rowColumn, rowContent).$(`div[title='${columnName}']`);
|
||||
}
|
||||
|
||||
async selectRowByContent(content: string): Promise<void> {
|
||||
@@ -457,52 +447,42 @@ export class DataTableComponentPage {
|
||||
}
|
||||
|
||||
getCellByContent(content: string): ElementFinder {
|
||||
return this.rootElement
|
||||
.all(by.cssContainingText(`adf-datatable-row[class*='adf-datatable-row'] td[class*='adf-datatable-cell']`, content))
|
||||
.first();
|
||||
return this.rootElement.all(by.cssContainingText(`adf-datatable-row[class*='adf-datatable-row'] div[class*='adf-datatable-cell']`, content)).first();
|
||||
}
|
||||
|
||||
async checkCellByHighlightContent(content: string): Promise<void> {
|
||||
const cell = this.rootElement.element(
|
||||
by.cssContainingText(
|
||||
`adf-datatable-row[class*='adf-datatable-row'] div[class*='adf-name-location-cell-name'] span.adf-highlight`,
|
||||
content
|
||||
)
|
||||
);
|
||||
const cell = this.rootElement.element(by.cssContainingText(`adf-datatable-row[class*='adf-datatable-row'] div[class*='adf-name-location-cell-name'] span.adf-highlight`, content));
|
||||
await BrowserVisibility.waitUntilElementIsVisible(cell);
|
||||
}
|
||||
|
||||
async clickRowByContent(name: string): Promise<void> {
|
||||
const resultElement = this.rootElement.$$(`td[data-automation-id='${name}']`).first();
|
||||
const resultElement = this.rootElement.$$(`div[data-automation-id='${name}']`).first();
|
||||
await BrowserActions.click(resultElement);
|
||||
}
|
||||
|
||||
async clickRowByContentCheckbox(name: string): Promise<void> {
|
||||
const resultElement = this.rootElement
|
||||
.$$(`div[data-automation-id='${name}']`)
|
||||
.first()
|
||||
.element(by.xpath(`ancestor::adf-datatable-row/label/${materialLocators.Checkbox.root}`));
|
||||
const resultElement = this.rootElement.$$(`div[data-automation-id='${name}']`).first().element(by.xpath(`ancestor::adf-datatable-row/label/${materialLocators.Checkbox.root}`));
|
||||
browser.actions().mouseMove(resultElement);
|
||||
await BrowserActions.click(resultElement);
|
||||
}
|
||||
|
||||
async checkRowContentIsDisplayed(content: string): Promise<void> {
|
||||
const resultElement = this.rootElement.$$(`td[data-automation-id='${content}']`).first();
|
||||
const resultElement = this.rootElement.$$(`div[data-automation-id='${content}']`).first();
|
||||
await BrowserVisibility.waitUntilElementIsVisible(resultElement);
|
||||
}
|
||||
|
||||
async checkRowContentIsNotDisplayed(content: string): Promise<void> {
|
||||
const resultElement = this.rootElement.$$(`tr[data-automation-id='${content}']`).first();
|
||||
const resultElement = this.rootElement.$$(`div[data-automation-id='${content}']`).first();
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(resultElement);
|
||||
}
|
||||
|
||||
async checkRowContentIsDisabled(content: string): Promise<void> {
|
||||
const resultElement = this.rootElement.$$(`tr[data-automation-id='${content}'] div.adf-cell-value img[aria-label='Disabled']`).first();
|
||||
const resultElement = this.rootElement.$$(`div[data-automation-id='${content}'] div.adf-cell-value img[aria-label='Disabled']`).first();
|
||||
await BrowserVisibility.waitUntilElementIsVisible(resultElement);
|
||||
}
|
||||
|
||||
async doubleClickRowByContent(name: string): Promise<void> {
|
||||
const resultElement = this.rootElement.$$(`td[data-automation-id='${name}']`).first();
|
||||
const resultElement = this.rootElement.$$(`div[data-automation-id='${name}']`).first();
|
||||
await BrowserActions.click(resultElement);
|
||||
await browser.actions().sendKeys(protractor.Key.ENTER).perform();
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ export abstract class Column {
|
||||
columnName: string;
|
||||
columnType: string;
|
||||
|
||||
constructor(columnName: string, columnType: string) {
|
||||
constructor(columnName: string, columnType: string ) {
|
||||
this.columnName = columnName;
|
||||
this.columnType = columnType;
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ import { BrowserVisibility } from '../../utils/browser-visibility';
|
||||
export class DataTableItem {
|
||||
columns = new Array<Column>();
|
||||
rootElement: ElementFinder;
|
||||
rows = `tbody[class*='adf-datatable-body'] adf-datatable-row[class*='adf-datatable-row']`;
|
||||
rows = `div[class*='adf-datatable-body'] adf-datatable-row[class*='adf-datatable-row']`;
|
||||
|
||||
constructor(rootElement = $$('adf-datatable').first()) {
|
||||
this.rootElement = rootElement;
|
||||
@@ -34,16 +34,14 @@ export class DataTableItem {
|
||||
}
|
||||
|
||||
async getColumn(columnName: string): Promise<Column> {
|
||||
return this.columns.find((column) => column.getColumnName() === columnName);
|
||||
return this.columns.find(
|
||||
(column) => column.getColumnName() === columnName
|
||||
);
|
||||
}
|
||||
|
||||
async getRow(columnName: string, columnValue: string): Promise<ElementFinder> {
|
||||
console.log('getRow', '-------------------------------------------------------');
|
||||
const column = await this.getColumn(columnName);
|
||||
const locator =
|
||||
`//td[@title="${column.columnName}"]` +
|
||||
column.createLocator(columnValue) +
|
||||
`//ancestor::adf-datatable-row[contains(@class, 'adf-datatable-row')]`;
|
||||
const locator = `//div[@title="${column.columnName}"]` + column.createLocator(columnValue) + `//ancestor::adf-datatable-row[contains(@class, 'adf-datatable-row')]`;
|
||||
return this.rootElement.element(by.xpath(locator));
|
||||
}
|
||||
|
||||
@@ -73,26 +71,19 @@ export class DataTableItem {
|
||||
async getColumnValueForRow(identifyingColumnName: string, identifyingColumnValue: string, columnName: string): Promise<string> {
|
||||
const row = await this.getRow(identifyingColumnName, identifyingColumnValue);
|
||||
await BrowserVisibility.waitUntilElementIsVisible(row);
|
||||
const rowColumn = row.$(`td[title="${columnName}"] span`);
|
||||
const rowColumn = row.$(`div[title="${columnName}"] span`);
|
||||
return BrowserActions.getText(rowColumn);
|
||||
}
|
||||
|
||||
async checkRowIsSelected(columnName: string, columnValue: string): Promise<void> {
|
||||
console.log('checkRowIsSelected', '-------------------------------------------------------');
|
||||
const column = await this.getColumn(columnName);
|
||||
const locator =
|
||||
`//td[@title="${column.columnName}"]` +
|
||||
column.createLocator(columnValue) +
|
||||
`//ancestor::adf-datatable-row[contains(@class, 'is-selected')]`;
|
||||
const locator = `//div[@title="${column.columnName}"]` + column.createLocator(columnValue) + `//ancestor::adf-datatable-row[contains(@class, 'is-selected')]`;
|
||||
await BrowserVisibility.waitUntilElementIsVisible(element(by.xpath(locator)));
|
||||
}
|
||||
|
||||
async checkRowIsNotSelected(columnName: string, columnValue: string): Promise<void> {
|
||||
const column = await this.getColumn(columnName);
|
||||
const locator =
|
||||
`//div[@title="${column.columnName}"]` +
|
||||
column.createLocator(columnValue) +
|
||||
`//ancestor::adf-datatable-row[contains(@class, 'is-selected')]`;
|
||||
const locator = `//div[@title="${column.columnName}"]` + column.createLocator(columnValue) + `//ancestor::adf-datatable-row[contains(@class, 'is-selected')]`;
|
||||
await BrowserVisibility.waitUntilElementIsNotVisible(element(by.xpath(locator)));
|
||||
}
|
||||
|
||||
|
@@ -58,7 +58,7 @@ export class ViewerPage {
|
||||
unknownFormat = $(`adf-viewer-unknown-format .adf-viewer__unknown-format-view`);
|
||||
|
||||
async viewFile(fileName: string): Promise<void> {
|
||||
const fileView = $$(`#document-list-container td[data-automation-id="${fileName}"]`).first();
|
||||
const fileView = $$(`#document-list-container div[data-automation-id="${fileName}"]`).first();
|
||||
await BrowserActions.click(fileView);
|
||||
await browser.actions().sendKeys(protractor.Key.ENTER).perform();
|
||||
await this.waitTillContentLoaded();
|
||||
@@ -245,7 +245,7 @@ export class ViewerPage {
|
||||
}
|
||||
|
||||
async clickInfoButton(): Promise<void> {
|
||||
await BrowserActions.click(this.infoButton);
|
||||
await BrowserActions.click($('button[data-automation-id="adf-toolbar-sidebar"]'));
|
||||
}
|
||||
|
||||
async clickOnTab(tabName: string): Promise<void> {
|
||||
|
Reference in New Issue
Block a user