systelab-components-test
Version:
Widgets to be use in the E2E Tests based in Protractor
237 lines (236 loc) • 10.6 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var widget_1 = require("./widget");
var protractor_1 = require("protractor");
var context_menu_1 = require("./context-menu");
var Grid = /** @class */ (function (_super) {
tslib_1.__extends(Grid, _super);
function Grid() {
return _super !== null && _super.apply(this, arguments) || this;
}
Grid.prototype.getNumberOfRows = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.elem.element(protractor_1.by.className('ag-center-cols-container'))
.all(protractor_1.by.css('div[role=row]'))
.count()];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
Grid.prototype.getValuesInRow = function (row) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var content, cols, numberOfRows, i, text;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
content = [];
cols = this.elem.all(protractor_1.by.css("div[row-index=\"" + row + "\"] div.ag-cell-value"));
return [4 /*yield*/, cols.count()];
case 1:
numberOfRows = _a.sent();
i = 0;
_a.label = 2;
case 2:
if (!(i < numberOfRows)) return [3 /*break*/, 5];
return [4 /*yield*/, cols.get(i).getText()];
case 3:
text = _a.sent();
content.push(text);
_a.label = 4;
case 4:
i++;
return [3 /*break*/, 2];
case 5: return [2 /*return*/, content];
}
});
});
};
Grid.prototype.getValueInCell = function (row, columnName) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var cellSelector, gridCell;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
cellSelector = "[role='gridcell'][col-id='" + columnName + "']";
return [4 /*yield*/, protractor_1.element.all(protractor_1.by.css(cellSelector)).get(row)];
case 1:
gridCell = _a.sent();
return [4 /*yield*/, gridCell.getText()];
case 2: return [2 /*return*/, _a.sent()];
}
});
});
};
Grid.prototype.clickOnRowMenu = function (row) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.clickOnLeftPinnedCell(row, 'contextMenu')];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
Grid.prototype.clickOnRow = function (row, column) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.clickOnCell(row, column)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
Grid.prototype.clickOnHeader = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.elem.element(protractor_1.by.className('ag-header-container'))
.element(protractor_1.by.className('ag-header-row'))
.all(protractor_1.by.className('ag-header-cell'))
.click()];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
Grid.prototype.clickOnHeaderCell = function (columnIndex) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.elem.all(protractor_1.by.className('ag-header-cell-text'))
.get(columnIndex - 1)
.click()];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
Grid.prototype.clickOnCell = function (row, column) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.elem.element(protractor_1.by.className('ag-center-cols-container'))
.element(protractor_1.by.css("div[row-index=\"" + row + "\"]"))
.all(protractor_1.by.css("div[col-id=\"" + column + "\"]"))
.click()];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
Grid.prototype.clickOnLeftPinnedCell = function (row, column) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.elem.element(protractor_1.by.className('ag-pinned-left-cols-container'))
.element(protractor_1.by.css("div[row-index=\"" + row + "\"]"))
.all(protractor_1.by.css("div[col-id=\"" + column + "\"]"))
.click()];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
Grid.prototype.selectRow = function (row) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.elem.all(protractor_1.by.css("div[row-index=\"" + row + "\"] div[col-id=\"selectCol\"] input"))
.click()];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
};
Grid.prototype.getHeaderCaptions = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var content, cols, numberOfFields, i, text;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
content = [];
cols = this.elem.all(protractor_1.by.className('ag-header-cell'));
return [4 /*yield*/, cols.count()];
case 1:
numberOfFields = _a.sent();
i = 0;
_a.label = 2;
case 2:
if (!(i < numberOfFields)) return [3 /*break*/, 5];
return [4 /*yield*/, cols.get(i).getText()];
case 3:
text = _a.sent();
content.push(text);
_a.label = 4;
case 4:
i++;
return [3 /*break*/, 2];
case 5: return [2 /*return*/, content];
}
});
});
};
Grid.prototype.getHeaderCells = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var content, cols, numberOfFields, i, _a, _b;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0:
content = [];
cols = this.elem.all(protractor_1.by.className('ag-header-cell'));
return [4 /*yield*/, cols.count()];
case 1:
numberOfFields = _c.sent();
i = 0;
_c.label = 2;
case 2:
if (!(i < numberOfFields)) return [3 /*break*/, 5];
_b = (_a = content).push;
return [4 /*yield*/, cols.get(i)];
case 3:
_b.apply(_a, [_c.sent()]);
_c.label = 4;
case 4:
i++;
return [3 /*break*/, 2];
case 5: return [2 /*return*/, content];
}
});
});
};
Grid.prototype.getGridHeader = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var cols;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
cols = this.elem.all(protractor_1.by.css('.ag-header-row .ag-header-cell-label'));
return [4 /*yield*/, cols.getText()];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
Grid.prototype.getMenu = function () {
return new context_menu_1.ContextMenu(this.elem.element(protractor_1.by.tagName('systelab-grid-context-menu')));
};
return Grid;
}(widget_1.Widget));
exports.Grid = Grid;