tia
Version:
Time is All (logs driven test engine with ExtJs support)
345 lines • 13.5 kB
JavaScript
;
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 _ = __importStar(require("lodash"));
const tia_extjs_query_1 = require("../tia-extjs-query");
const extjs_utils_1 = require("../../extjs-utils");
const compName = 'Component';
/**
* gT.eC.component.a or gT.eC.component.actions
*/
class ComponentActions {
/**
* Left mouse button click on Component.
* Default actionDesc is 'Click Cmp'.
* Note: if it does not work, try clickInput().
*/
static async click(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Click Cmp ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.clickById(id, false);
},
});
}
/**
* Right mouse button click on Component.
* Default actionDesc is 'Right Click Cmp'.
* Note: if it does not work, try clickInput().
*/
static async rClick(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Right Click Cmp ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.rClickById(id, false);
},
});
}
/**
* Left mouse button double click on Component.
* Default actionDesc is 'Click Cmp'.
* * Note: if it does not work, try dblClickInput().
*/
static async dblClick(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Dbl Click Cmp ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.dblClickById(id, false);
},
});
}
/**
* Left mouse button click on Component's input element by WebElement.
* Note: not all Components have an input element.
* Default actionDesc is 'Click Input'.
*/
static async clickInput(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Click Cmp Input ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInput({ tEQ, idForLog, enableLog: false });
await gT.s.uA.clickById(id, false);
},
});
}
/**
* Right mouse button click on Component's input element by WebElement.
* Note: not all Components have an input element.
* Default actionDesc is 'Click Input'.
*/
static async rClickInput(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Right Click Cmp Input ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInput({ tEQ, idForLog, enableLog: false });
await gT.s.uA.rClickById(id, false);
},
});
}
/**
* Left mouse button double click on Component's input element by WebElement.
* Note: not all Components have an input element.
* Default actionDesc is 'Click Input'.
*/
static async dblClickInput(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Dbl Click Cmp Input ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInput({ tEQ, idForLog, enableLog: false });
await gT.s.uA.dblClickById(id, false);
},
});
}
/**
* Moves the mouse cursor to the center of the specified Component.
* Default actionDesc is 'Move mouse to Cmp'.
* Note: if it does not work, try moveMouseToInput().
*/
static async moveMouse(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Move mouse to Cmp ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.moveMouseById(id, false);
},
});
}
/**
* Moves the mouse cursor to the center of the Component's input element.
* Note: not all Components have an input element.
* Default actionDesc is 'Move mouse to Cmp input'.
*/
static async moveMouseToInput(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Move mouse to Cmp Input ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInput({ tEQ, idForLog, enableLog: false });
await gT.s.uA.moveMouseById(id, false);
},
});
}
/**
* Sends ESC key to the component.
* Can be used, e.g. to close boundlist in combobox.
*/
static async sendEsc(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Send ESC ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInputId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.sendEscById(id, false);
},
});
}
/**
* Sends DOWN key to the component.
* Can be used to open boundlist, e.g. in combobox, or splitbutton.
* Or to move selection in a table.
*/
static async sendDown(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Send DOWN ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInputId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.sendDownById(id, false);
},
});
}
/**
* Sends UP key to the component.
* Can be used e.g. to move selection in a table.
*/
static async sendUp(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Send UP ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInputId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.sendUpById(id, false);
},
});
}
/**
* Sends ENTER key to the component.
* E.g. for save value to form.
*/
static async sendEnter(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Send ENTER ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInputId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.sendEnterById(id, false);
},
});
}
/**
* Sends TAB key to the component.
* E.g. to move to next form field.
*/
static async sendTab(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Send TAB ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInputId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.sendTabById(id, false);
},
});
}
/**
* Sends PAGE_DOWN key to the component.
* Can be used e.g. to move selection in a table.
*/
static async sendPgDown(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Send PAGE_DOWN ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInputId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.sendPgDownById(id, false);
},
});
}
/**
* Sends PAGE_UP key to the component.
* Can be used e.g. to move selection in a table.
*/
static async sendPgUp(tEQ, idForLog, enableLog) {
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Send PAGE_UP ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInputId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.sendPgUpById(id, false);
},
});
}
/**
* Sends keys to the component.
* Default actionDesc is 'Send keys'.
*/
static async sendKeys(tEQ, keys, idForLog, enableLog) {
let keysArg = _.clone(keys);
const realKeys = gT.e.utils.locKeyToStrAndEscapeSlashes(keysArg);
if (realKeys !== keysArg && gT.e.utils.debugLocale) {
keysArg += ` ("${realKeys}")`;
}
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} sendKeys: '${keysArg}' ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInputId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.sendKeysById(id, realKeys, false);
},
});
}
/**
* Ctrl + a, and send keys to the Component.
* Default actionDesc is 'Ctrl +a, Send keys'
*/
static async sendCtrlAAndKeys(tEQ, keys, idForLog, enableLog) {
let keysArg = _.clone(keys);
const realKeys = gT.e.utils.locKeyToStrAndEscapeSlashes(keysArg);
if (realKeys !== keysArg && gT.e.utils.debugLocale) {
keysArg += ` ("${realKeys}")`;
}
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Send Ctrl + A and keys: '${keysArg}' ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInputId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.sendCtrlAAndKeysById(id, realKeys, false);
},
});
}
/**
* Ctrl + a, keys, ENTER to the Component.
* Default actionDesc is 'Ctrl +a, Send keys, Enter'
*/
static async sendCtrlAKeysEnter(tEQ, keys, idForLog, enableLog) {
let keysArg = _.clone(keys);
const realKeys = gT.e.utils.locKeyToStrAndEscapeSlashes(keysArg);
if (realKeys !== keysArg && gT.e.utils.debugLocale) {
keysArg += ` ("${realKeys}")`;
}
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Send Ctrl + A, keys, ENTER: '${keysArg}' ... `,
enableLog,
act: async () => {
const id = await tia_extjs_query_1.queryCmpInputId({ tEQ, idForLog, enableLog: false });
await gT.s.uA.sendCtrlAKeysEnterById(id, realKeys, false);
},
});
}
/**
* Waits for the component to become enabled and not masked.
* https://docs.sencha.com/extjs/6.5.3/classic/Ext.Component.html#method-isMasked
* https://docs.sencha.com/extjs/6.5.3/classic/Ext.Component.html#method-isDisabled
* @param [timeout = 5000] - milliseconds to wait.
*/
static async waitForEnabledAndNotMasked(tEQ, timeout = gT.engineConsts.timeoutForEnabledByTEQ, idForLog, enableLog) {
const realId = await tia_extjs_query_1.queryCmpId({ tEQ, idForLog, enableLog });
return gIn.wrap({
msg: `${extjs_utils_1.getCIS(tEQ, this.compName, idForLog)} Wait for component to become enabled and non masked: ... `,
enableLog,
act: () => gT.sOrig.driver.wait(async () => {
const res = await gT.s.browser.executeScriptWrapper(`return !(Ext.getCmp('${realId}').isDisabled()) && !(Ext.getCmp('${realId}').isMasked(true));`);
// console.log(`HERE: ${realId} ${res}`);
return res;
}, timeout),
});
}
}
ComponentActions.compName = compName;
exports.ComponentActions = ComponentActions;
/**
* gT.eC.component.c or gT.eC.component.checks
*/
class ComponentChecks {
}
ComponentChecks.compName = compName;
exports.ComponentChecks = ComponentChecks;
/**
* gT.eC.component.g or gT.eC.component.grabs
*/
class ComponentGrabs {
}
ComponentGrabs.compName = compName;
exports.ComponentGrabs = ComponentGrabs;
/**
* gT.eC.component.l or gT.eC.component.logs
*/
class ComponentLogs {
}
ComponentLogs.compName = compName;
exports.ComponentLogs = ComponentLogs;
class ComponentAPI {
}
ComponentAPI.a = ComponentActions;
ComponentAPI.actions = ComponentActions;
ComponentAPI.c = ComponentChecks;
ComponentAPI.checks = ComponentChecks;
ComponentAPI.l = ComponentLogs;
ComponentAPI.logs = ComponentLogs;
exports.ComponentAPI = ComponentAPI;
//# sourceMappingURL=component.js.map