Skip to content

Commit

Permalink
ACS-6323 Fixed e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksanderSklorz committed Dec 10, 2023
1 parent 0bb9c05 commit 2294506
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import { Utils, waitForPresence } from '../../utilities/utils';

export class DataTable extends Component {
private static selectors = {
columnHeader: '.adf-datatable-row .adf-datatable-cell-header .adf-datatable-cell-value',
columnHeader: '.adf-datatable-cell-header',
columnHeaderLabel: '.adf-datatable-row .adf-datatable-cell-header .adf-datatable-cell-value',
sortedColumnHeader: `
.adf-datatable__header--sorted-asc .adf-datatable-cell-header-content .adf-datatable-cell-value,
.adf-datatable__header--sorted-desc .adf-datatable-cell-header-content .adf-datatable-cell-value
Expand Down Expand Up @@ -76,7 +77,7 @@ export class DataTable extends Component {
}

private getColumnHeaders(): ElementArrayFinder {
const locator = by.css(DataTable.selectors.columnHeader);
const locator = by.css(DataTable.selectors.columnHeaderLabel);
return this.head.all(locator);
}

Expand All @@ -85,20 +86,29 @@ export class DataTable extends Component {
}

getColumnHeaderByLabel(label: string): ElementFinder {
const locator = by.cssContainingText(DataTable.selectors.columnHeader, label);
return this.head.element(locator).element(by.xpath('ancestor::div[contains(@class, "adf-datatable-cell-header")]'))
.element(by.css(DataTable.selectors.dragIcon));
const locator = by.cssContainingText(DataTable.selectors.columnHeaderLabel, label);
return this.head.element(locator);
}

async sortBy(label: string, order: 'asc' | 'desc'): Promise<void> {
const sortColumn = await this.getSortedColumnHeaderText();
let sortOrder = await this.getSortingOrder();
if (sortColumn !== label) {
await this.getColumnHeaderByLabel(label).click();
const columnHeader = this.getColumnHeaderByLabel(label);
browser.actions().mouseMove(this.head.element(by.css(DataTable.selectors.columnHeader))).perform();
const dragIcon = columnHeader.element(by.xpath('ancestor::div[contains(@class, "adf-datatable-cell-header")]'))
.element(by.css(DataTable.selectors.dragIcon));
await BrowserVisibility.waitUntilElementIsVisible(dragIcon);
await dragIcon.click();
sortOrder = await this.getSortingOrder();
}
if (sortOrder !== order) {
await this.getColumnHeaderByLabel(label).click();
const columnHeader = this.getColumnHeaderByLabel(label);
browser.actions().mouseMove(this.head.element(by.css(DataTable.selectors.columnHeader))).perform();
const dragIcon = columnHeader.element(by.xpath('ancestor::div[contains(@class, "adf-datatable-cell-header")]'))
.element(by.css(DataTable.selectors.dragIcon));
await BrowserVisibility.waitUntilElementIsVisible(dragIcon);
await dragIcon.click();
}
}

Expand Down

0 comments on commit 2294506

Please sign in to comment.