UNPKG

tia

Version:

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

144 lines 5.14 kB
"use strict"; // https://stackoverflow.com/questions/11000087/how-to-select-a-combobox-value-in-extjs Object.defineProperty(exports, "__esModule", { value: true }); const form_field_base_1 = require("./form-field-base"); const tia_extjs_query_1 = require("../tia-extjs-query"); const extjs_utils_1 = require("../../extjs-utils"); const compName = 'ComboBox'; /** * gT.eC.combobox.a or gT.eC.combobox.actions */ class ComboBoxActions extends form_field_base_1.FormFieldBaseActions { /** * Ctrl + a, Send text by keys, and ENTER to the component. */ static async setByKbd(tEQ, text, idForLog, enableLog) { // Inherited from Component. await this.click(tEQ, idForLog, false); return this.sendCtrlAKeysEnter(tEQ, text, idForLog, enableLog); } /** * Set the text using expand() ExtJs API + mouse click in BoundList. * Note, that for tagfield setting already selected tag will reset this tag. */ static async setByMouse(tEQ, text, idForLog, enableLog) { const valueStr = gT.e.utils.locKeyToStrAndEscapeSlashes(text); let actionDesc = `Set by mouse: '${text}'`; if (valueStr !== text && gT.e.utils.debugLocale) { actionDesc += `("${valueStr}")`; } return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { // TODO: honestly I should change cmp.expand() to key.Down. const { id, fieldName } = await tia_extjs_query_1.queryAndAction({ tEQ, action: 'cmp.expand(); return { id: cmpInfo.constProps.realId, fieldName: cmp.displayField }', idForLog, enableLog: false, }); await gT.sOrig.driver.wait(() => gT.s.browser.executeScriptWrapper(`return tiaEJ.hEById.isCBPickerVisible('${id}');`), gT.engineConsts.cbBoundListTimeout); const el = await gT.s.browser.executeScriptWrapper(`return tiaEJ.hEById.getCBItemByField('${id}', ${gT.s.browser.valueToParameter(valueStr)}, '${fieldName}');`); await el.click(); await gT.e.wait.ajaxRequestsFinish(undefined, false); }, actionDesc, enableLog, }); } /** * Clears the combobox selection using ExtJs API. */ static async clearByEJ(tEQ, idForLog, enableLog) { return gT.e.q.wrap({ tEQ, compName, idForLog, act: async () => { await tia_extjs_query_1.queryAndAction({ tEQ, action: 'cmp.clearValue();', idForLog, enableLog: false, }); }, actionDesc: 'Clear by EJ', enableLog, }); } } ComboBoxActions.compName = compName; exports.ComboBoxActions = ComboBoxActions; /** * gT.eC.combobox.c or gT.eC.combobox.checks */ class ComboBoxChecks extends form_field_base_1.FormFieldBaseChecks { } ComboBoxChecks.compName = compName; exports.ComboBoxChecks = ComboBoxChecks; /** * gT.eC.combobox.g or gT.eC.combobox.grabs */ class ComboBoxGrabs extends form_field_base_1.FormFieldBaseGrabs { /** * Returns the selected value or values to the test log. */ static async rawValue(tEQ, idForLog) { const result = await tia_extjs_query_1.queryAndAction({ tEQ, action: 'return tiaEJ.ctByObj.getCBSelectedVals(cmp);', idForLog, enableLog: false, }); return extjs_utils_1.getCISRVal(tEQ, this.compName, idForLog, result); } /** * Returns the entire content to the test log. */ static async content(tEQ, idForLog) { const result = await tia_extjs_query_1.queryAndAction({ tEQ, action: 'return tiaEJ.ctByObj.getCB(cmp);', idForLog, enableLog: false, }); return extjs_utils_1.getCISContent('Content', tEQ, this.compName, idForLog, result); } } ComboBoxGrabs.compName = compName; exports.ComboBoxGrabs = ComboBoxGrabs; /** * gT.eC.combobox.l or gT.eC.combobox.logs */ class ComboBoxLogs extends form_field_base_1.FormFieldBaseLogs { /** * Prints the selected value or values to the test log. */ static async rawValue(tEQ, idForLog) { const str = await ComboBoxGrabs.rawValue(tEQ, idForLog); gIn.logger.logln(str); } /** * Prints the entire content to the test log. */ static async content(tEQ, idForLog) { const str = await ComboBoxGrabs.content(tEQ, idForLog); gIn.logger.logln(str); } } ComboBoxLogs.compName = compName; exports.ComboBoxLogs = ComboBoxLogs; class ComboBoxAPI { } ComboBoxAPI.a = ComboBoxActions; ComboBoxAPI.actions = ComboBoxActions; ComboBoxAPI.c = ComboBoxChecks; ComboBoxAPI.checks = ComboBoxChecks; ComboBoxAPI.g = ComboBoxGrabs; ComboBoxAPI.grabs = ComboBoxGrabs; ComboBoxAPI.l = ComboBoxLogs; ComboBoxAPI.logs = ComboBoxLogs; exports.ComboBoxAPI = ComboBoxAPI; //# sourceMappingURL=combobox.js.map