UNPKG

tia

Version:

Time is All (logs driven test engine with ExtJs support)

537 lines 19.8 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const component_1 = require("./component"); const _ = __importStar(require("lodash")); const tia_extjs_query_1 = require("../tia-extjs-query"); const extjs_utils_1 = require("../../extjs-utils"); const compName = 'TableView'; function isByColumns(data) { return data.column !== undefined; } function prepareCellData(cellData) { // eslint-disable-next-line no-param-reassign cellData.row = cellData.row.map(item => [ gT.e.utils.locKeyToStr(item[0]), gT.e.utils.locKeyToStr(item[1]), ]); if (isByColumns(cellData)) { // eslint-disable-next-line no-param-reassign cellData.column = gT.e.utils.locKeyToStr(cellData.column); } else { // eslint-disable-next-line no-param-reassign cellData.field = gT.e.utils.locKeyToStr(cellData.field); } return cellData; } /** * gT.eC.tableview.a or gT.eC.tableview.actions */ class TableViewActions extends component_1.ComponentActions { // No, setSelection or setSelectionModel work unstable. // async selectRowByEJ(tEQ, rowData, idForLog, enableLog?: EnableLog) {}, /** * Left mouse button click on the specified group name. */ static async clickGroupRoot(tEQ, groupName, idForLog, enableLog) { const valueStr = gT.e.utils.locKeyToStrAndEscapeSlashes(groupName); return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const groupRootEl = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getGroupRoot(cmp, '${valueStr}');`, idForLog, enableLog: false, }); await groupRootEl.click(); }, actionDesc: `Click Group Root (${groupName})`, enableLog, }); } /** * Left mouse button click on the specified table cell. */ static async clickCellByColTexts(tEQ, cellData, idForLog, enableLog) { const cellDataArg = prepareCellData(_.cloneDeep(cellData)); return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getTableCellByColumnTexts(cmp, ${gIn.tU.v2s(cellDataArg)});`, idForLog, enableLog: false, }); await cell.click(); }, actionDesc: `Click cell by Col Texts: ${gIn.tU.v2s(cellData)}`, enableLog, }); } /** * Right mouse button click on the specified table cell. */ static async rClickCellByColTexts(tEQ, cellData, idForLog, enableLog) { const cellDataArg = prepareCellData(_.cloneDeep(cellData)); return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getTableCellByColumnTexts(cmp, ${gIn.tU.v2s(cellDataArg)});`, idForLog, enableLog: false, }); await gT.sOrig.driver .actions({ bridge: true }) .contextClick(cell) .perform(); }, actionDesc: `Right Click cell by Col Texts: ${gIn.tU.v2s(cellData)}`, enableLog, }); } /** * Left mouse button click on the specified column in the first table row. * @colText - the column header text or tooltip. */ static async clickFirstRowCellByColText(tEQ, colText, idForLog, enableLog) { const colTextArg = gT.e.utils.locKeyToStr(colText); return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getFirstRowCellByColumnText(cmp, '${colTextArg}');`, idForLog, enableLog: false, }); await cell.click(); }, actionDesc: `Click first row cell by Col Text: ${colText}`, enableLog, }); } /** * Right mouse button click on the specified column in the first table row. * @colText - the column header text or tooltip. */ static async rClickFirstRowCellByColText(tEQ, colText, idForLog, enableLog) { const colTextArg = gT.e.utils.locKeyToStr(colText); return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getFirstRowCellByColumnText(cmp, '${colTextArg}');`, idForLog, enableLog: false, }); await gT.sOrig.driver .actions({ bridge: true }) .contextClick(cell) .perform(); }, actionDesc: `Right Click first row cell by Col Text: ${colText}`, enableLog, }); } /** * Left mouse button click on the specified column in the last table row. * @colText - the column header text or tooltip. */ static async clickLastRowCellByColText(tEQ, colText, idForLog, enableLog) { const colTextArg = gT.e.utils.locKeyToStr(colText); return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getLastRowCellByColumnText(cmp, '${colTextArg}');`, idForLog, enableLog: false, }); await cell.click(); }, actionDesc: `Click last row cell by Col Text: ${colText}`, enableLog, }); } /** * Right mouse button click on the specified column in the last table row. * @colText - the column header text or tooltip. */ static async rClickLastRowCellByColText(tEQ, colText, idForLog, enableLog) { const colTextArg = gT.e.utils.locKeyToStr(colText); return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getLastRowCellByColumnText(cmp, '${colTextArg}');`, idForLog, enableLog: false, }); await gT.sOrig.driver .actions({ bridge: true }) .contextClick(cell) .perform(); }, actionDesc: `Right Click last row cell by Col Text: ${colText}`, enableLog, }); } /** * Left mouse button click on the specified column in the first table row. * The cell column is specified by the model field name. */ static async clickFirstRowCellByModelField(tEQ, fieldName, idForLog, enableLog) { return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getFirstRowCellByModelField(cmp, '${fieldName}');`, idForLog, enableLog: false, }); await cell.click(); }, actionDesc: `Click first row cell by Model Field: ${fieldName}`, enableLog, }); } /** * Right mouse button click on the specified column in the first table row. * The cell column is specified by the model field name. */ static async rClickFirstRowCellByModelField(tEQ, fieldName, idForLog, enableLog) { return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getFirstRowCellByModelField(cmp, '${fieldName}');`, idForLog, enableLog: false, }); await gT.sOrig.driver .actions({ bridge: true }) .contextClick(cell) .perform(); }, actionDesc: `Right Click first row cell by Model Field: ${fieldName}`, enableLog, }); } /** * Left mouse button click on the specified column in the last table row. * The cell column is specified by the model field name. */ static async clickLastRowCellByModelField(tEQ, fieldName, idForLog, enableLog) { return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getLastRowCellByModelField(cmp, '${fieldName}');`, idForLog, enableLog: false, }); await cell.click(); }, actionDesc: `Click last row cell by Model Field: ${fieldName}`, enableLog, }); } /** * Right mouse button click on the specified column in the last table row. * The cell column is specified by the model field name. */ static async rClickLastRowCellByModelField(tEQ, fieldName, idForLog, enableLog) { return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getLastRowCellByModelField(cmp, '${fieldName}');`, idForLog, enableLog: false, }); await gT.sOrig.driver .actions({ bridge: true }) .contextClick(cell) .perform(); }, actionDesc: `Right Click last row cell by Model Field: ${fieldName}`, enableLog, }); } /** * Left mouse button double click on the specified table cell. */ static async doubleClickCellByColTexts(tEQ, cellData, idForLog, enableLog) { const cellDataArg = prepareCellData(_.cloneDeep(cellData)); return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getTableCellByColumnTexts(cmp, ${gIn.tU.v2s(cellDataArg)});`, idForLog, enableLog: false, }); await gT.sOrig.driver .actions({ bridge: true }) .doubleClick(cell) .perform(); }, actionDesc: `Double Click cell by Col Texts: ${gIn.tU.v2s(cellData)}`, enableLog, }); } /** * Ctrl + Left mouse button click on the specified table cell. */ static async ctrlClickCellByColTexts(tEQ, cellData, idForLog, enableLog) { const cellDataArg = prepareCellData(_.cloneDeep(cellData)); return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getTableCellByColumnTexts(cmp, ${gIn.tU.v2s(cellDataArg)});`, idForLog, enableLog: false, }); await gT.sOrig.driver .actions({ bridge: true }) .keyDown(gT.sOrig.key.CONTROL) .click(cell) .keyUp(gT.sOrig.key.CONTROL) .perform(); }, actionDesc: `Ctrl + Click cell by Col Texts: ${gIn.tU.v2s(cellData)}`, enableLog, }); } /** * Multi-selection by Ctrl + Left mouse button click on the specified table cell on several rows. * * @param column - Column header text or tooltip, specifying column to click * @param values - array of values for cells in the specified column. */ /* eslint-disable-next-line max-params */ static async ctrlClickCellsByColTexts(tEQ, column, values, idForLog, enableLog) { for (const value of values) { await this.ctrlClickCellByColTexts(tEQ, { row: [[column, value]], column, }, idForLog, enableLog); } } /** * Left mouse button click on the specified table cell. */ static async clickCellByModelFields(tEQ, cellData, idForLog, enableLog) { const cellDataArg = prepareCellData(_.cloneDeep(cellData)); return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getTableCellByModelFields(cmp, ${gIn.tU.v2s(cellDataArg)});`, idForLog, enableLog: false, }); await cell.click(); }, actionDesc: `Click cell by Model Fields: ${gIn.tU.v2s(cellData)}`, enableLog, }); } /** * Right mouse button click on the specified table cell. */ static async rClickCellByModelFields(tEQ, cellData, idForLog, enableLog) { const cellDataArg = prepareCellData(_.cloneDeep(cellData)); return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getTableCellByModelFields(cmp, ${gIn.tU.v2s(cellDataArg)});`, idForLog, enableLog: false, }); await gT.sOrig.driver .actions({ bridge: true }) .doubleClick(cell) .perform(); }, actionDesc: `Right Click cell by Model Fields: ${gIn.tU.v2s(cellData)}`, enableLog, }); } /** * Left mouse button double click on the specified table cell. */ static async doubleClickCellByModelFields(tEQ, cellData, idForLog, enableLog) { const cellDataArg = prepareCellData(_.cloneDeep(cellData)); return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getTableCellByModelFields(cmp, ${gIn.tU.v2s(cellDataArg)});`, idForLog, enableLog: false, }); await gT.sOrig.driver .actions({ bridge: true }) .doubleClick(cell) .perform(); }, actionDesc: `Double Click cell by Model Fields: ${gIn.tU.v2s(cellData)}`, enableLog, }); } /** * Ctrl + Left mouse button click on the specified table cell. */ static async ctrlClickCellByModelFields(tEQ, cellData, idForLog, enableLog) { const cellDataArg = prepareCellData(_.cloneDeep(cellData)); return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { const cell = await tia_extjs_query_1.queryAndAction({ tEQ, action: `return tiaEJActs.getTableCellByModelFields(cmp, ${gIn.tU.v2s(cellDataArg)});`, idForLog, enableLog: false, }); await gT.sOrig.driver .actions({ bridge: true }) .keyDown(gT.sOrig.key.CONTROL) .click(cell) .keyUp(gT.sOrig.key.CONTROL) .perform(); }, actionDesc: `Ctrl + Click cell by Model Fields: ${gIn.tU.v2s(cellData)}`, enableLog, }); } /** * Multi-selection by Ctrl + Left mouse button click on the specified table cell on several rows. * * @param fieldName - field name. * @param values - array of values for cells in the column corresponding to the field name. */ /* eslint-disable-next-line max-params */ static async ctrlClickCellsByModelFields(tEQ, fieldName, values, idForLog, enableLog) { for (const value of values) { await this.ctrlClickCellByModelFields(tEQ, { row: [[fieldName, value]], field: fieldName, useRowIfCellAbsent: true, }, idForLog, enableLog); } } } TableViewActions.compName = compName; exports.TableViewActions = TableViewActions; /** * gT.eC.tableview.c or gT.eC.tableview.checks */ class TableViewChecks extends component_1.ComponentChecks { } TableViewChecks.compName = compName; exports.TableViewChecks = TableViewChecks; /** * gT.eC.tableview.g or gT.eC.tableview.grabs */ class TableViewGrabs extends component_1.ComponentGrabs { /** * Returns the table content to the test log. */ static async content(tEQ, idForLog) { const result = await tia_extjs_query_1.queryAndAction({ tEQ, action: 'return tiaEJ.ctByObj.getTable(cmp);', idForLog, enableLog: false, }); return extjs_utils_1.getCISContent('Content', tEQ, this.compName, idForLog, result, true); } } TableViewGrabs.compName = compName; exports.TableViewGrabs = TableViewGrabs; /** * gT.eC.tableview.l or gT.eC.tableview.logs */ class TableViewLogs extends component_1.ComponentLogs { /** * Prints the table content to the test log. */ static async content(tEQ, idForLog) { const str = await TableViewGrabs.content(tEQ, idForLog); gIn.logger.logln(str); } } TableViewLogs.compName = compName; exports.TableViewLogs = TableViewLogs; class TableViewAPI { } TableViewAPI.a = TableViewActions; TableViewAPI.actions = TableViewActions; TableViewAPI.c = TableViewChecks; TableViewAPI.checks = TableViewChecks; TableViewAPI.g = TableViewGrabs; TableViewAPI.grabs = TableViewGrabs; TableViewAPI.l = TableViewLogs; TableViewAPI.logs = TableViewLogs; exports.TableViewAPI = TableViewAPI; //# sourceMappingURL=tableview.js.map