@progress/kendo-e2e
Version:
Kendo UI end-to-end test utilities.
405 lines • 19.4 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PivotGridColumnMenu = exports.PivotConfigurator = exports.PivotGrid = void 0;
const ui_component_1 = require("./ui-component");
const const_1 = require("./const");
const selenium_1 = require("../selenium");
const treeview_1 = require("./treeview");
const dropdownlist_1 = require("./dropdownlist");
class PivotGrid extends ui_component_1.UIComponent {
constructor(browser, locator = PivotGrid.SELECTOR, parentElement) {
super(browser, locator, parentElement);
this.parentElement = parentElement;
}
getColumnHeaderCell(row, column) {
return __awaiter(this, void 0, void 0, function* () {
const locator = `.k-pivotgrid-column-headers tr:nth-of-type(${row}) th:nth-of-type(${column})`;
return yield this.findChild(locator);
});
}
getColumnHeaderCellsCount() {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.findChildren('.k-pivotgrid-column-headers tr th', { waitForChild: false })).length;
});
}
getColumnHeaderCellToggle(row, column) {
return __awaiter(this, void 0, void 0, function* () {
const cell = yield this.getColumnHeaderCell(row, column);
yield (yield this.browser.findChild(cell, '.k-svg-icon')).click();
yield this.waitUntilLoaded({ timeout: 30000, pollTimeout: 100 });
});
}
getColumnHeaderCellText(row, column) {
return __awaiter(this, void 0, void 0, function* () {
return yield (yield this.getColumnHeaderCell(row, column)).getText();
});
}
columnHeaderIsExpanded(row, column) {
return __awaiter(this, void 0, void 0, function* () {
const icon = `.k-pivotgrid-column-headers tr:nth-of-type(${row}) th:nth-of-type(${column}) .k-svg-icon`;
const iconClass = yield (yield this.browser.find(icon)).getAttribute('class');
if (iconClass.includes('-up')) {
return true;
}
else if (iconClass.includes('-down')) {
return false;
}
else {
throw new Error('Can not determine if header cell is expanded!');
}
});
}
getRowHeaderCell(row, column) {
return __awaiter(this, void 0, void 0, function* () {
const locator = `.k-pivotgrid-row-headers tr:nth-of-type(${row}) th:nth-of-type(${column})`;
return yield this.findChild(locator);
});
}
getRowHeaderCellsCount() {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.findChildren('.k-pivotgrid-row-headers tr th', { waitForChild: false })).length;
});
}
getRowHeaderCellToggle(row, column) {
return __awaiter(this, void 0, void 0, function* () {
const cell = yield this.getRowHeaderCell(row, column);
yield (yield this.browser.findChild(cell, '.k-svg-icon')).click();
yield this.waitUntilLoaded({ timeout: 30000, pollTimeout: 100 });
});
}
getRowHeaderCellText(row, column) {
return __awaiter(this, void 0, void 0, function* () {
return yield (yield this.getRowHeaderCell(row, column)).getText();
});
}
rowHeaderIsExpanded(row, column) {
return __awaiter(this, void 0, void 0, function* () {
const icon = `.k-pivotgrid-row-headers tr:nth-of-type(${row}) th:nth-of-type(${column}) .k-svg-icon`;
const iconClass = yield (yield this.browser.find(icon)).getAttribute('class');
if (iconClass.includes('k-svg-i-caret-alt-down') || iconClass.includes('k-svg-i-chevron-up')) {
// legacy pivot use k-svg-i-caret-alt-down, new pivot use k-svg-i-chevron-up
return true;
}
else if (iconClass.includes('k-svg-i-caret-alt-right') || iconClass.includes('k-svg-i-chevron-down')) {
// legacy pivot use k-svg-i-caret-alt-right, new pivot use k-svg-i-chevron-down
return false;
}
else {
throw new Error('Can not determine if header cell is expanded!');
}
});
}
cell(row, column) {
return __awaiter(this, void 0, void 0, function* () {
const locator = `.k-pivotgrid-values tr:nth-of-type(${row}) td:nth-of-type(${column})`;
return yield this.findChild(locator);
});
}
cellText(row, column) {
return __awaiter(this, void 0, void 0, function* () {
return yield (yield this.cell(row, column)).getText();
});
}
}
exports.PivotGrid = PivotGrid;
PivotGrid.SELECTOR = const_1.SELECTORS.PIVOTGRID;
class PivotConfigurator extends ui_component_1.UIComponent {
constructor(browser, locator = PivotConfigurator.SELECTOR, parentElement) {
super(browser, locator, parentElement);
this.parentElement = parentElement;
}
fieldsList() {
return __awaiter(this, void 0, void 0, function* () {
return new treeview_1.TreeView(this.browser, '.k-treeview', '.k-fields-list-wrapper');
});
}
getColumnsItem(index) {
return __awaiter(this, void 0, void 0, function* () {
const columnFields = yield this.findChild(PivotConfigurator.COLUMNS_LIST);
return yield this.browser.findChild(columnFields, selenium_1.By.css(`.k-chip:nth-of-type(${index})`));
});
}
getColumnsItemLabel(index) {
return __awaiter(this, void 0, void 0, function* () {
const columnFields = yield this.findChild(PivotConfigurator.COLUMNS_LIST);
return yield this.browser.findChild(columnFields, selenium_1.By.css(`.k-chip:nth-of-type(${index}) .k-chip-label`));
});
}
getColumnsItemText(index) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.getColumnsItemLabel(index)).getText();
});
}
getRowsItem(index) {
return __awaiter(this, void 0, void 0, function* () {
const rowFields = yield this.findChild(PivotConfigurator.ROWS_LIST);
return yield this.browser.findChild(rowFields, selenium_1.By.css(`.k-chip:nth-of-type(${index})`));
});
}
getRowsItemLabel(index) {
return __awaiter(this, void 0, void 0, function* () {
const rowFields = yield this.findChild(PivotConfigurator.ROWS_LIST);
return yield this.browser.findChild(rowFields, selenium_1.By.css(`.k-chip:nth-of-type(${index}) .k-chip-label`));
});
}
getRowsItemText(index) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.getRowsItemLabel(index)).getText();
});
}
getValuesItem(index) {
return __awaiter(this, void 0, void 0, function* () {
const valueFields = yield this.findChild(PivotConfigurator.VALUES_LIST);
return yield this.browser.findChild(valueFields, selenium_1.By.css(`.k-chip:nth-of-type(${index})`));
});
}
getValuesItemLabel(index) {
return __awaiter(this, void 0, void 0, function* () {
const valueFields = yield this.findChild(PivotConfigurator.VALUES_LIST);
return yield this.browser.findChild(valueFields, selenium_1.By.css(`.k-chip:nth-of-type(${index}) .k-chip-label`));
});
}
getValuesItemText(index) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.getValuesItemLabel(index)).getText();
});
}
getColumnsCount() {
return __awaiter(this, arguments, void 0, function* ({ waitForItems = true } = {}) {
const columnFields = yield this.findChild(PivotConfigurator.COLUMNS_LIST);
return (yield this.browser.findChildren(columnFields, selenium_1.By.css('.k-chip'), { waitForChild: waitForItems })).length;
});
}
getRowsCount() {
return __awaiter(this, arguments, void 0, function* ({ waitForItems = true } = {}) {
const rowFields = yield this.findChild(PivotConfigurator.ROWS_LIST);
return (yield this.browser.findChildren(rowFields, selenium_1.By.css('.k-chip'), { waitForChild: waitForItems })).length;
});
}
getValuesCount() {
return __awaiter(this, arguments, void 0, function* ({ waitForItems = true } = {}) {
const valueFields = yield this.findChild(PivotConfigurator.VALUES_LIST);
return (yield this.browser.findChildren(valueFields, selenium_1.By.css('.k-chip'), { waitForChild: waitForItems })).length;
});
}
cancel() {
return __awaiter(this, void 0, void 0, function* () {
const locator = '.k-pivotgrid-configurator-actions .k-button:nth-of-type(1)';
yield (yield this.findChild(locator)).click();
});
}
apply() {
return __awaiter(this, void 0, void 0, function* () {
const locator = '.k-pivotgrid-configurator-actions .k-button:nth-of-type(2)';
yield (yield this.findChild(locator)).click();
});
}
openMenuForColumn(index) {
return __awaiter(this, void 0, void 0, function* () {
const columnFields = yield this.findChild(PivotConfigurator.COLUMNS_LIST);
const more = yield this.browser.findChild(columnFields, selenium_1.By.css(`.k-chip:nth-of-type(${index}) .k-svg-i-more-vertical`));
yield this.browser.waitForAnimationAndClick(more);
yield this.browser.waitForAnimation('.k-animation-container-shown .k-pivotgrid-column-menu');
return new PivotGridColumnMenu(this.browser, '.k-pivotgrid-column-menu', '.k-animation-container-shown');
});
}
openMenuForRow(index) {
return __awaiter(this, void 0, void 0, function* () {
const rowFields = yield this.findChild(PivotConfigurator.ROWS_LIST);
const more = yield this.browser.findChild(rowFields, selenium_1.By.css(`.k-chip:nth-of-type(${index}) .k-svg-i-more-vertical`));
yield this.browser.waitForAnimationAndClick(more);
yield this.browser.waitForAnimation('.k-animation-container-shown .k-pivotgrid-column-menu');
return new PivotGridColumnMenu(this.browser, '.k-pivotgrid-column-menu', '.k-animation-container-shown');
});
}
deleteRowsItem(index) {
return __awaiter(this, void 0, void 0, function* () {
const item = yield this.getRowsItem(index);
yield (yield this.browser.findChild(item, '.k-svg-i-x-circle')).click();
});
}
deleteColumnsItem(index) {
return __awaiter(this, void 0, void 0, function* () {
const item = yield this.getColumnsItem(index);
yield (yield this.browser.findChild(item, '.k-svg-i-x-circle')).click();
});
}
}
exports.PivotConfigurator = PivotConfigurator;
PivotConfigurator.SELECTOR = '.k-pivotgrid-configurator';
PivotConfigurator.COLUMNS_LIST = selenium_1.By.xpath('.//*[contains(@class, "k-column-fields")][1]');
PivotConfigurator.ROWS_LIST = selenium_1.By.xpath('.//*[contains(@class, "k-row-fields")]');
PivotConfigurator.VALUES_LIST = selenium_1.By.xpath('.//*[contains(@class, "k-column-fields")][2]');
class PivotGridColumnMenu extends ui_component_1.UIComponent {
constructor(browser, locator, parentElement) {
super(browser, locator, parentElement);
this.parentElement = parentElement;
}
sortAsc() {
return __awaiter(this, void 0, void 0, function* () {
const ascMenu = yield this.findChild('.k-svg-i-sort-asc-small');
yield this.browser.waitForAnimationAndClick(ascMenu);
yield this.browser.wait(selenium_1.EC.notInViewport(ascMenu), {
message: 'Failed to close pivot grid column menu on sort click.'
});
yield this.browser.sleep(200);
});
}
sortDesc() {
return __awaiter(this, void 0, void 0, function* () {
const descMenu = yield this.findChild('.k-svg-i-sort-desc-small');
yield this.browser.waitForAnimationAndClick(descMenu);
yield this.browser.wait(selenium_1.EC.notInViewport(descMenu), {
message: 'Failed to close pivot grid column menu on sort click.'
});
yield this.browser.sleep(200);
});
}
getItemByText(text) {
return __awaiter(this, void 0, void 0, function* () {
const locator = selenium_1.By.xpath(`.//*[contains(@class, "k-columnmenu-item") and .="${text}"]`);
return yield this.findChild(locator);
});
}
moveToColumnsElement() {
return __awaiter(this, void 0, void 0, function* () {
return this.getItemByText("Move to Columns");
});
}
moveToRowsElement() {
return __awaiter(this, void 0, void 0, function* () {
return this.getItemByText("Move to Rows");
});
}
moveAsNextElement() {
return __awaiter(this, void 0, void 0, function* () {
return this.getItemByText("Move next");
});
}
moveAsPreviousElement() {
return __awaiter(this, void 0, void 0, function* () {
return this.getItemByText("Move previous");
});
}
moveToColumns() {
return __awaiter(this, void 0, void 0, function* () {
const item = yield this.moveToColumnsElement();
yield this.browser.waitForAnimation(item);
yield item.click();
yield this.browser.isNotVisible(this.rootElement);
});
}
moveToRows() {
return __awaiter(this, void 0, void 0, function* () {
const item = yield this.moveToRowsElement();
yield this.browser.waitForAnimation(item);
yield item.click();
yield this.browser.isNotVisible(this.rootElement);
});
}
moveNext() {
return __awaiter(this, void 0, void 0, function* () {
const item = yield this.moveAsNextElement();
yield this.browser.waitForAnimation(item);
yield item.click();
yield this.browser.isNotVisible(this.rootElement);
});
}
movePrevious() {
return __awaiter(this, void 0, void 0, function* () {
const item = yield this.moveAsPreviousElement();
yield this.browser.waitForAnimation(item);
yield item.click();
yield this.browser.isNotVisible(this.rootElement);
});
}
openFilterMenu() {
return __awaiter(this, void 0, void 0, function* () {
const filterMenu = yield this.findChild('.k-columnmenu-item-wrapper:nth-of-type(3)');
yield this.browser.waitForAnimation(filterMenu);
const filterIcon = yield this.findChild('.k-columnmenu-item-wrapper:nth-of-type(3) .k-svg-i-filter');
yield this.browser.waitForAnimationAndClick(filterIcon);
yield this.browser.wait(() => __awaiter(this, void 0, void 0, function* () { return (yield filterMenu.findElements(selenium_1.By.css('.k-svg-i-chevron-up'))).length > 0; }), {
timeout: 5000, message: 'Failed to expand filter menu.'
});
});
}
filterMenuInput() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChild('.k-filter-menu-container .k-textbox input');
});
}
getValueFilterMenuInput() {
return __awaiter(this, void 0, void 0, function* () {
const input = yield this.filterMenuInput();
return yield input.getAttribute('value');
});
}
setValueFilterMenuInput(value) {
return __awaiter(this, void 0, void 0, function* () {
const input = yield this.filterMenuInput();
yield this.browser.waitForAnimation(input);
yield this.browser.type(input, value);
});
}
selectFilterOperators(index) {
return __awaiter(this, void 0, void 0, function* () {
const container = yield this.browser.find('.k-columnmenu-item-wrapper:nth-of-type(3) .k-expanded .k-column-menu-filter');
const dropDown = new dropdownlist_1.DropDownList(this.browser, '.k-dropdownlist', container);
yield dropDown.selectItemByIndex(index);
});
}
clearFilter() {
return __awaiter(this, void 0, void 0, function* () {
const button = yield this.findChild('.k-button-filter-clear');
yield this.browser.waitForAnimationAndClick(button);
yield this.browser.wait(selenium_1.EC.notVisible(button), { timeout: 5000, message: 'Failed to clear filter.' });
});
}
applyFilter() {
return __awaiter(this, void 0, void 0, function* () {
const button = yield this.findChild('.k-button-filter');
yield this.browser.waitForAnimationAndClick(button);
yield this.browser.wait(selenium_1.EC.notVisible(button), { timeout: 5000, message: 'Failed to filter.' });
});
}
openIncludeFields() {
return __awaiter(this, void 0, void 0, function* () {
const includeFields = yield this.findChild('.k-columnmenu-item-wrapper:nth-of-type(2)');
yield this.browser.waitForAnimation(includeFields);
const icon = yield this.findChild('.k-columnmenu-item-wrapper:nth-of-type(2) .k-svg-i-grid-layout');
yield this.browser.waitForAnimationAndClick(icon);
yield this.browser.wait(() => __awaiter(this, void 0, void 0, function* () { return (yield includeFields.findElements(selenium_1.By.css('.k-svg-i-chevron-up'))).length > 0; }), {
timeout: 5000, message: 'Failed to expand include fields.'
});
});
}
includeFieldsTreeView() {
return __awaiter(this, void 0, void 0, function* () {
return new treeview_1.TreeView(this.browser, '.k-treeview', yield this.root());
});
}
applyIncludes() {
return __awaiter(this, void 0, void 0, function* () {
const button = yield this.findChild('.k-button-includes-apply');
yield this.browser.waitForAnimationAndClick(button);
});
}
resetIncludes() {
return __awaiter(this, void 0, void 0, function* () {
const button = yield this.findChild('.k-button-includes-reset');
yield this.browser.waitForAnimationAndClick(button);
});
}
}
exports.PivotGridColumnMenu = PivotGridColumnMenu;
//# sourceMappingURL=pivotgrid.js.map