@mablhq/mabl-cli 1.21.22 → 1.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/api/basicApiClient.js +4 -0
- package/api/mablApiClient.js +72 -53
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +91 -39
- package/commands/constants.js +3 -2
- package/commands/link-agents/link-agents_cmds/list.js +131 -0
- package/commands/link-agents/link-agents_cmds/terminate.js +31 -0
- package/commands/tests/testsUtil.js +25 -64
- package/commands/tests/tests_cmds/run.js +6 -6
- package/commands/tests/tests_cmds/trainerUtil.js +12 -0
- package/core/messaging/messaging.js +11 -1
- package/domUtil/index.js +1 -1
- package/execution/index.js +1 -1
- package/execution/index.js.LICENSE.txt +0 -27
- package/mablApi/index.js +1 -1
- package/mablscript/steps/SyntheticStep.js +20 -0
- package/mablscriptFind/index.js +1 -1
- package/package.json +5 -5
- package/resources/mablFind.js +1 -1
- package/commands/tests/executionUtil.js +0 -36
- package/commands/tests/tests_cmds/run-alpha.js +0 -129
- package/commands/tests/tests_cmds/run-legacy.js +0 -109
- package/commands/tests/tests_cmds/trainer.js +0 -5
- package/commands/tests/tests_cmds/trainer_cmds/install.js +0 -14
- package/commands/tests/tests_cmds/trainer_cmds/trainerUtil.js +0 -169
- package/commands/tests/tests_cmds/trainer_cmds/update.js +0 -27
- package/commands/tests/tests_cmds/trainer_cmds/version.js +0 -22
|
@@ -131,40 +131,64 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
|
|
|
131
131
|
async boundingBox() {
|
|
132
132
|
return (0, utils_1.mapIfNotNull)(await this.element.boundingBox(), (boundingBox) => boundingBox);
|
|
133
133
|
}
|
|
134
|
-
async
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
async maybeOverwriteScrollIntoViewDuringAction(action, options) {
|
|
135
|
+
if (options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView) {
|
|
136
|
+
await this.overwriteScrollIntoViewFunction();
|
|
137
|
+
}
|
|
137
138
|
try {
|
|
138
|
-
await
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
trial,
|
|
143
|
-
});
|
|
139
|
+
return await action();
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
throw e;
|
|
144
143
|
}
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
return;
|
|
144
|
+
finally {
|
|
145
|
+
if (options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView) {
|
|
146
|
+
await this.resetScrollIntoViewFunction();
|
|
149
147
|
}
|
|
150
|
-
throw error;
|
|
151
148
|
}
|
|
152
149
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
click(options) {
|
|
151
|
+
return this.maybeOverwriteScrollIntoViewDuringAction(async () => {
|
|
152
|
+
var _a, _b, _c;
|
|
156
153
|
const trial = (_a = options === null || options === void 0 ? void 0 : options.trial) !== null && _a !== void 0 ? _a : false;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (error.message.includes(exports.NAVIGATION_ERROR_MESSAGE)) {
|
|
165
|
-
(0, logUtils_1.logInternal)(`Action timed out due to navigation timeout. ${error.toString()}`);
|
|
154
|
+
try {
|
|
155
|
+
await this.element.click({
|
|
156
|
+
clickCount: (_b = options === null || options === void 0 ? void 0 : options.clickCount) !== null && _b !== void 0 ? _b : 1,
|
|
157
|
+
force: (_c = options === null || options === void 0 ? void 0 : options.force) !== null && _c !== void 0 ? _c : !trial,
|
|
158
|
+
timeout: this.getActionTimeout(options),
|
|
159
|
+
trial,
|
|
160
|
+
});
|
|
166
161
|
}
|
|
167
|
-
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (error.message.includes(exports.NAVIGATION_ERROR_MESSAGE)) {
|
|
164
|
+
(0, logUtils_1.logInternal)(`Action timed out due to navigation timeout. ${error.toString()}`);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
}, {
|
|
170
|
+
minimizeScrollIntoView: options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
async doubleClick(options) {
|
|
174
|
+
return this.maybeOverwriteScrollIntoViewDuringAction(async () => {
|
|
175
|
+
var _a, _b;
|
|
176
|
+
try {
|
|
177
|
+
const trial = (_a = options === null || options === void 0 ? void 0 : options.trial) !== null && _a !== void 0 ? _a : false;
|
|
178
|
+
return this.element.dblclick({
|
|
179
|
+
force: (_b = options === null || options === void 0 ? void 0 : options.force) !== null && _b !== void 0 ? _b : !trial,
|
|
180
|
+
timeout: this.getActionTimeout(options),
|
|
181
|
+
trial,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
if (error.message.includes(exports.NAVIGATION_ERROR_MESSAGE)) {
|
|
186
|
+
(0, logUtils_1.logInternal)(`Action timed out due to navigation timeout. ${error.toString()}`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}, {
|
|
190
|
+
minimizeScrollIntoView: options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView,
|
|
191
|
+
});
|
|
168
192
|
}
|
|
169
193
|
async clickablePoint() {
|
|
170
194
|
var _a;
|
|
@@ -190,22 +214,30 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
|
|
|
190
214
|
scrollIntoViewIfNeeded() {
|
|
191
215
|
return this.element.scrollIntoViewIfNeeded();
|
|
192
216
|
}
|
|
193
|
-
select(value) {
|
|
194
|
-
return this.element.selectOption(value)
|
|
217
|
+
async select(value, options) {
|
|
218
|
+
return this.maybeOverwriteScrollIntoViewDuringAction(async () => this.element.selectOption(value), {
|
|
219
|
+
minimizeScrollIntoView: options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView,
|
|
220
|
+
});
|
|
195
221
|
}
|
|
196
222
|
async type(text, options) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
223
|
+
return this.maybeOverwriteScrollIntoViewDuringAction(async () => {
|
|
224
|
+
var _a;
|
|
225
|
+
const selectText = (_a = options === null || options === void 0 ? void 0 : options.selectText) !== null && _a !== void 0 ? _a : true;
|
|
226
|
+
if (selectText) {
|
|
227
|
+
await this.element.selectText({ force: true });
|
|
228
|
+
}
|
|
229
|
+
await this.element.type(text, {
|
|
230
|
+
delay: options === null || options === void 0 ? void 0 : options.delay,
|
|
231
|
+
timeout: 0,
|
|
232
|
+
});
|
|
233
|
+
}, {
|
|
234
|
+
minimizeScrollIntoView: options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView,
|
|
205
235
|
});
|
|
206
236
|
}
|
|
207
|
-
press(key) {
|
|
208
|
-
return this.element.press(key)
|
|
237
|
+
press(key, options) {
|
|
238
|
+
return this.maybeOverwriteScrollIntoViewDuringAction(async () => this.element.press(key), {
|
|
239
|
+
minimizeScrollIntoView: options === null || options === void 0 ? void 0 : options.minimizeScrollIntoView,
|
|
240
|
+
});
|
|
209
241
|
}
|
|
210
242
|
getRemoteObjectId() {
|
|
211
243
|
var _a, _b, _c;
|
|
@@ -283,5 +315,25 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
|
|
|
283
315
|
: types_1.DefaultTimeouts.defaultActionTimeoutMs;
|
|
284
316
|
return (_a = options === null || options === void 0 ? void 0 : options.timeout) !== null && _a !== void 0 ? _a : defaultTimeout;
|
|
285
317
|
}
|
|
318
|
+
async overwriteScrollIntoViewFunction() {
|
|
319
|
+
var _a;
|
|
320
|
+
await ((_a = this.elementImpl) === null || _a === void 0 ? void 0 : _a.evaluateInUtility(([, node]) => {
|
|
321
|
+
const element = node;
|
|
322
|
+
if (!element.__mablOriginalScrollIntoView) {
|
|
323
|
+
element.__mablOriginalScrollIntoView = element.scrollIntoView;
|
|
324
|
+
}
|
|
325
|
+
element.scrollIntoView = () => element.scrollIntoViewIfNeeded();
|
|
326
|
+
}, []));
|
|
327
|
+
}
|
|
328
|
+
async resetScrollIntoViewFunction() {
|
|
329
|
+
var _a;
|
|
330
|
+
await ((_a = this.elementImpl) === null || _a === void 0 ? void 0 : _a.evaluateInUtility(([, node]) => {
|
|
331
|
+
const element = node;
|
|
332
|
+
const originalFunction = element.__mablOriginalScrollIntoView;
|
|
333
|
+
if (originalFunction) {
|
|
334
|
+
element.scrollIntoView = originalFunction;
|
|
335
|
+
}
|
|
336
|
+
}, []));
|
|
337
|
+
}
|
|
286
338
|
}
|
|
287
339
|
exports.PlaywrightElementHandle = PlaywrightElementHandle;
|
package/commands/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.BrowserTypeSelections = exports.DefaultBrowserType = exports.DefaultBranchName = exports.DefaultOutputFormatChoices = exports.DetailLevelFormats = exports.ReporterOptions = exports.OutputFormats = exports.CommandArgAliases = exports.CommandArgBrowserEnableExtensions = exports.CommandArgBrowserIgnoreCertificateErrors = exports.CommandArgBrowserDisableIsolation = exports.ListTimeFormat = exports.CommandArgReporterOptions = exports.CommandArgReporter = exports.CommandArgWorkspaceId = exports.CommandArgVersion = exports.CommandArgVariables = void 0;
|
|
3
|
+
exports.CommandArgUrlApp = exports.CommandArgUrl = exports.CommandArgTrainerVersion = exports.CommandArgTo = exports.CommandArgSilent = exports.CommandArgRevision = exports.CommandArgMaxHeartbeatAge = exports.CommandArgPlanId = exports.CommandArgContentTypes = exports.CommandArgPreview = exports.CommandArgOutputFilePath = exports.CommandArgOutput = exports.CommandArgNoPrompt = exports.CommandArgPrompt = exports.CommandArgPortNumber = exports.CommandArgName = exports.CommandArgMablBranchChangesOnly = exports.CommandArgMablBranch = exports.CommandArgMablAutoLogin = exports.CommandArgMablAutoBranch = exports.CommandArgLinkBypass = exports.CommandArgLinkLabel = exports.CommandArgLimitOutput = exports.CommandArgLabels = exports.CommandArgLabelsInclude = exports.CommandArgLabelsExclude = exports.CommandArgTestInteractionSpeed = exports.CommandArgTestRunId = exports.CommandArgTestFile = exports.CommandArgId = exports.CommandArgUserAgent = exports.CommandArgHttpHeaders = exports.CommandArgHelp = exports.CommandArgFromPlanId = exports.CommandArgFrom = exports.CommandArgFormat = exports.CommandArgFastFailure = exports.CommandArgOverrideEnvironmentId = exports.CommandArgEnvironmentId = exports.CommandArgEnableLink = exports.CommandArgDetailLevel = exports.CommandArgDescription = exports.CommandArgDeploymentId = exports.CommandArgDecrypt = exports.CommandArgDataTables = exports.CommandArgCredentials = exports.CommandArgBasicAuthCredentials = exports.CommandArgBrowsers = exports.CommandArgApplicationId = exports.CommandArgApiKey = void 0;
|
|
4
|
+
exports.BrowserTypeSelections = exports.DefaultBrowserType = exports.DefaultBranchName = exports.DefaultOutputFormatChoices = exports.DetailLevelFormats = exports.ReporterOptions = exports.OutputFormats = exports.CommandArgAliases = exports.CommandArgBrowserEnableExtensions = exports.CommandArgBrowserIgnoreCertificateErrors = exports.CommandArgBrowserDisableIsolation = exports.ListTimeFormat = exports.CommandArgReporterOptions = exports.CommandArgReporter = exports.CommandArgWorkspaceId = exports.CommandArgVersion = exports.CommandArgVariables = exports.CommandArgUrlApi = void 0;
|
|
5
5
|
const browserTypes_1 = require("./browserTypes");
|
|
6
6
|
exports.CommandArgApiKey = 'api-key';
|
|
7
7
|
exports.CommandArgApplicationId = 'application-id';
|
|
@@ -46,6 +46,7 @@ exports.CommandArgOutputFilePath = 'file';
|
|
|
46
46
|
exports.CommandArgPreview = 'preview';
|
|
47
47
|
exports.CommandArgContentTypes = 'types';
|
|
48
48
|
exports.CommandArgPlanId = 'plan-id';
|
|
49
|
+
exports.CommandArgMaxHeartbeatAge = 'max-heartbeat-age';
|
|
49
50
|
exports.CommandArgRevision = 'revision';
|
|
50
51
|
exports.CommandArgSilent = 'silent';
|
|
51
52
|
exports.CommandArgTo = 'to';
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
7
|
+
const moment = require("moment");
|
|
8
|
+
const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
|
|
9
|
+
const util_1 = require("../../commandUtil/util");
|
|
10
|
+
const constants_1 = require("../../constants");
|
|
11
|
+
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
12
|
+
const js_yaml_1 = require("js-yaml");
|
|
13
|
+
exports.command = 'list';
|
|
14
|
+
exports.describe = 'List link agents';
|
|
15
|
+
exports.builder = (yargs) => {
|
|
16
|
+
yargs
|
|
17
|
+
.option(constants_1.CommandArgWorkspaceId, {
|
|
18
|
+
alias: constants_1.CommandArgAliases.WorkspaceId,
|
|
19
|
+
describe: 'Workspace for which to list link agents',
|
|
20
|
+
nargs: 1,
|
|
21
|
+
type: 'string',
|
|
22
|
+
})
|
|
23
|
+
.option(constants_1.CommandArgOutput, {
|
|
24
|
+
alias: constants_1.CommandArgAliases.OutputType,
|
|
25
|
+
default: constants_1.OutputFormats.Table,
|
|
26
|
+
describe: 'Specify result output format',
|
|
27
|
+
nargs: 1,
|
|
28
|
+
choices: [...constants_1.DefaultOutputFormatChoices, constants_1.OutputFormats.Table],
|
|
29
|
+
})
|
|
30
|
+
.option(constants_1.CommandArgLimitOutput, {
|
|
31
|
+
alias: constants_1.CommandArgAliases.LimitOutput,
|
|
32
|
+
describe: 'The number of link agents to return',
|
|
33
|
+
default: 10,
|
|
34
|
+
nargs: 1,
|
|
35
|
+
type: 'number',
|
|
36
|
+
})
|
|
37
|
+
.option(constants_1.CommandArgMaxHeartbeatAge, {
|
|
38
|
+
describe: 'Only returns link agents that have sent a heartbeat within this number of seconds',
|
|
39
|
+
default: 300,
|
|
40
|
+
nargs: 1,
|
|
41
|
+
type: 'number',
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
exports.handler = (0, util_1.failWrapper)(listLinkAgents);
|
|
45
|
+
async function listLinkAgents(parsed) {
|
|
46
|
+
const limit = parsed.limit;
|
|
47
|
+
const maxHeartbeatAgeSeconds = parsed[constants_1.CommandArgMaxHeartbeatAge];
|
|
48
|
+
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
49
|
+
const output = parsed[constants_1.CommandArgOutput];
|
|
50
|
+
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
51
|
+
const linkAgents = (await apiClient.getLinkAgentsWithRecentHeartbeats(workspaceId, limit, maxHeartbeatAgeSeconds)).map((linkAgent) => ({
|
|
52
|
+
address: linkAgent.address,
|
|
53
|
+
created_time: linkAgent.created_time,
|
|
54
|
+
hostname: linkAgent.hostname,
|
|
55
|
+
id: linkAgent.id,
|
|
56
|
+
is_connected: linkAgent.is_connected,
|
|
57
|
+
java_version: linkAgent.java_version,
|
|
58
|
+
last_heartbeat_time: linkAgent.last_heartbeat_time,
|
|
59
|
+
name: linkAgent.label,
|
|
60
|
+
operating_system_architecture: linkAgent.operating_system_architecture,
|
|
61
|
+
operating_system_name: linkAgent.operating_system_name,
|
|
62
|
+
operating_system_version: linkAgent.operating_system_version,
|
|
63
|
+
status: linkAgent.status,
|
|
64
|
+
version: linkAgent.version,
|
|
65
|
+
}));
|
|
66
|
+
switch (output) {
|
|
67
|
+
case constants_1.OutputFormats.Json:
|
|
68
|
+
loggingProvider_1.logger.info(JSON.stringify(linkAgents, null, 2));
|
|
69
|
+
break;
|
|
70
|
+
case constants_1.OutputFormats.Yaml:
|
|
71
|
+
loggingProvider_1.logger.info((0, js_yaml_1.dump)(linkAgents));
|
|
72
|
+
break;
|
|
73
|
+
case constants_1.OutputFormats.Table:
|
|
74
|
+
default:
|
|
75
|
+
printLinkAgentsAsTable(linkAgents);
|
|
76
|
+
loggingProvider_1.logger.info(`${linkAgents.length} link agents returned`);
|
|
77
|
+
if (linkAgents.length === limit) {
|
|
78
|
+
loggingProvider_1.logger.info(`... use the --limit flag to return a larger set`);
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
return linkAgents.length;
|
|
83
|
+
}
|
|
84
|
+
function printLinkAgentsAsTable(linkAgents) {
|
|
85
|
+
const table = new cli_table3_1.default({
|
|
86
|
+
head: [
|
|
87
|
+
'ID',
|
|
88
|
+
'Name',
|
|
89
|
+
'Connected',
|
|
90
|
+
'Status',
|
|
91
|
+
'Host',
|
|
92
|
+
'OS',
|
|
93
|
+
'Java',
|
|
94
|
+
'Created',
|
|
95
|
+
'Heartbeat',
|
|
96
|
+
'Version',
|
|
97
|
+
],
|
|
98
|
+
wordWrap: true,
|
|
99
|
+
});
|
|
100
|
+
linkAgents.forEach((agent) => {
|
|
101
|
+
table.push([
|
|
102
|
+
{ rowSpan: 1, content: agent.id, vAlign: 'center' },
|
|
103
|
+
{ rowSpan: 1, content: agent.name, vAlign: 'center' },
|
|
104
|
+
{ rowSpan: 1, content: agent.is_connected, vAlign: 'center' },
|
|
105
|
+
{ rowSpan: 1, content: agent.status, vAlign: 'center' },
|
|
106
|
+
{
|
|
107
|
+
rowSpan: 1,
|
|
108
|
+
content: `${agent.hostname} (${agent.address})`,
|
|
109
|
+
vAlign: 'center',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
rowSpan: 1,
|
|
113
|
+
content: `${agent.operating_system_name} ${agent.operating_system_version} (${agent.operating_system_architecture})`,
|
|
114
|
+
vAlign: 'center',
|
|
115
|
+
},
|
|
116
|
+
{ rowSpan: 1, content: agent.java_version, vAlign: 'center' },
|
|
117
|
+
{
|
|
118
|
+
rowSpan: 1,
|
|
119
|
+
content: moment.utc(agent.created_time).format(constants_1.ListTimeFormat),
|
|
120
|
+
vAlign: 'center',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
rowSpan: 1,
|
|
124
|
+
content: moment.utc(agent.last_heartbeat_time).format(constants_1.ListTimeFormat),
|
|
125
|
+
vAlign: 'center',
|
|
126
|
+
},
|
|
127
|
+
{ rowSpan: 1, content: agent.version, vAlign: 'center' },
|
|
128
|
+
]);
|
|
129
|
+
});
|
|
130
|
+
loggingProvider_1.logger.info(table.toString());
|
|
131
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
|
|
7
|
+
const constants_1 = require("../../constants");
|
|
8
|
+
const util_1 = require("../../commandUtil/util");
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
11
|
+
exports.command = `terminate <${constants_1.CommandArgId}>`;
|
|
12
|
+
exports.describe = 'Sends a shutdown signal to a specific Link Agent.';
|
|
13
|
+
exports.builder = (yargs) => {
|
|
14
|
+
yargs.positional(constants_1.CommandArgId, {
|
|
15
|
+
describe: 'id of the link agent to terminate',
|
|
16
|
+
type: 'string',
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
exports.handler = (0, util_1.failWrapper)(terminateLinkAgent);
|
|
20
|
+
async function terminateLinkAgent(parsed) {
|
|
21
|
+
try {
|
|
22
|
+
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
23
|
+
const linkAgentId = parsed[constants_1.CommandArgId];
|
|
24
|
+
await apiClient.terminateLinkAgent(linkAgentId);
|
|
25
|
+
loggingProvider_1.logger.info(chalk_1.default.green(`Link agent ${chalk_1.default.bold(linkAgentId)} terminated`));
|
|
26
|
+
return linkAgentId;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
throw new Error(`Error terminating link agent: ${error}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -26,9 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.toBasicHttpAuthenticationCredentials = exports.generateChromiumPreferencesFile = exports.logTestInfoIfPresent = exports.milliSecondsToSeconds = exports.calculateTotalTimeSeconds = exports.extractTestRunConfig = exports.pullDownTestRunConfig = exports.validateRunCommandWithLabels = exports.validateRunEditCommand = exports.downloadUploadFile = exports.sleep = exports.editTheTest = exports.runTheTest = exports.prepareTrainerForSplitPlayback = exports.createTrainingSession = exports.cleanUpInitialPages = exports.getExtensionBackgroundPageWithCliTool = exports.
|
|
29
|
+
exports.toBasicHttpAuthenticationCredentials = exports.generateChromiumPreferencesFile = exports.logTestInfoIfPresent = exports.milliSecondsToSeconds = exports.calculateTotalTimeSeconds = exports.extractTestRunConfig = exports.pullDownTestRunConfig = exports.validateRunCommandWithLabels = exports.validateRunEditCommand = exports.downloadUploadFile = exports.sleep = exports.editTheTest = exports.runTheTest = exports.prepareTrainerForSplitPlayback = exports.createTrainingSession = exports.cleanUpInitialPages = exports.getExtensionBackgroundPageWithCliTool = exports.createBrowserForExecutionEngine = exports.addExecutionEngineLaunchArgs = exports.createBrowser = exports.prepareChromePreferencesDirectory = exports.findChrome = exports.searchForChrome = exports.getFinalUrl = exports.getTempChromePrefDirectory = void 0;
|
|
30
30
|
const os = __importStar(require("os"));
|
|
31
|
-
const trainerUtil_1 = require("./tests_cmds/trainer_cmds/trainerUtil");
|
|
32
31
|
const fs = __importStar(require("fs-extra"));
|
|
33
32
|
const path = __importStar(require("path"));
|
|
34
33
|
const constants_1 = require("../constants");
|
|
@@ -47,6 +46,7 @@ const resourceUtil_1 = require("../../util/resourceUtil");
|
|
|
47
46
|
const mobileEmulationUtil_1 = require("./mobileEmulationUtil");
|
|
48
47
|
const browserLauncher_1 = require("../../browserLauncher/browserLauncher");
|
|
49
48
|
const stream_1 = require("stream");
|
|
49
|
+
const trainerUtil_1 = require("./tests_cmds/trainerUtil");
|
|
50
50
|
const chalk = require('chalk');
|
|
51
51
|
const chromeFinder = require('chrome-launcher/dist/chrome-finder');
|
|
52
52
|
const launchUtils = require('chrome-launcher/dist/utils');
|
|
@@ -105,38 +105,6 @@ async function findChrome() {
|
|
|
105
105
|
return chromePath;
|
|
106
106
|
}
|
|
107
107
|
exports.findChrome = findChrome;
|
|
108
|
-
async function createBrowserWithAuthedExtension(accessToken, browserWidth, browserHeight, tempBrowserPreferencesDirectory, options) {
|
|
109
|
-
const { credentials, disableIsolation, ignoreCertificateErrors, runnerType, loggerFunc, } = options;
|
|
110
|
-
const pathToExtension = await (0, trainerUtil_1.getMablTrainerExtensionPath)();
|
|
111
|
-
const chromePath = await findChrome();
|
|
112
|
-
if (!chromePath.length) {
|
|
113
|
-
messaging_1.mablEventEmitter.log(chalk.yellow('Could not find a local install of Chrome to use, please ensure you have it installed and try again'));
|
|
114
|
-
throw new Error('Chrome not found error');
|
|
115
|
-
}
|
|
116
|
-
messaging_1.mablEventEmitter.log(`Using Chrome at the following path: ${chromePath}`);
|
|
117
|
-
const launchArgs = [
|
|
118
|
-
`--disable-extensions-except=${pathToExtension}`,
|
|
119
|
-
`--load-extension=${pathToExtension}`,
|
|
120
|
-
`--window-size=${browserWidth},${browserHeight}`,
|
|
121
|
-
];
|
|
122
|
-
if (ignoreCertificateErrors) {
|
|
123
|
-
launchArgs.push('--ignore-certificate-errors');
|
|
124
|
-
}
|
|
125
|
-
if (disableIsolation) {
|
|
126
|
-
launchArgs.push('--disable-features=IsolateOrigins,site-per-process');
|
|
127
|
-
}
|
|
128
|
-
const maybeBrowser = await launchBrowserInstance(chromePath, launchArgs, tempBrowserPreferencesDirectory, false, credentials, {
|
|
129
|
-
runnerType,
|
|
130
|
-
loggerFunc,
|
|
131
|
-
});
|
|
132
|
-
if (!maybeBrowser) {
|
|
133
|
-
throw new Error('Unable to start Chrome session');
|
|
134
|
-
}
|
|
135
|
-
await setUpAuthTokenForExtension(maybeBrowser, accessToken);
|
|
136
|
-
maybeBrowser.on(browserLauncher_1.BrowserEvent.BrowserDestroyed, () => removeTempBrowserPreferencesDirectory(tempBrowserPreferencesDirectory));
|
|
137
|
-
return maybeBrowser;
|
|
138
|
-
}
|
|
139
|
-
exports.createBrowserWithAuthedExtension = createBrowserWithAuthedExtension;
|
|
140
108
|
async function launchBrowserInstance(chromePath, launchArgs, userDataDir, headless, credentials, options) {
|
|
141
109
|
var _a;
|
|
142
110
|
const { bypassContentSecurityPolicy, defaultDeviceDescriptor, disableFocusEmulation, extraHttpHeaders, ignoreDefaultArgs, runnerType, loggerFunc, userAgent, } = options || {};
|
|
@@ -312,15 +280,6 @@ async function createBrowserForExecutionEngine(browserWidth, browserHeight, head
|
|
|
312
280
|
return maybeBrowser;
|
|
313
281
|
}
|
|
314
282
|
exports.createBrowserForExecutionEngine = createBrowserForExecutionEngine;
|
|
315
|
-
async function setUpAuthTokenForExtension(browser, accessToken) {
|
|
316
|
-
const backgroundPage = await browser.getExtensionBackgroundPage((0, trainerUtil_1.getTrainerId)());
|
|
317
|
-
await backgroundPage.evaluate((token) => {
|
|
318
|
-
localStorage.setItem('authResult', JSON.stringify({ idToken: token }));
|
|
319
|
-
localStorage.setItem('trainerWorld', 'mablCLI');
|
|
320
|
-
}, accessToken);
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
exports.setUpAuthTokenForExtension = setUpAuthTokenForExtension;
|
|
324
283
|
async function getExtensionBackgroundPageWithCliTool(browser) {
|
|
325
284
|
const backgroundPage = await browser.getExtensionBackgroundPage((0, trainerUtil_1.getTrainerId)());
|
|
326
285
|
if (backgroundPage) {
|
|
@@ -634,28 +593,29 @@ function validateRunCommandWithLabels(testId, suppliedLabelsInclude, suppliedLab
|
|
|
634
593
|
}
|
|
635
594
|
exports.validateRunCommandWithLabels = validateRunCommandWithLabels;
|
|
636
595
|
async function pullDownTestRunConfig(testRunId, apiClient) {
|
|
637
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
596
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
638
597
|
const journeyRun = await apiClient.getTestRun(testRunId);
|
|
639
598
|
const planRun = await apiClient.getPlanRun(journeyRun.parent_execution);
|
|
640
599
|
return {
|
|
641
|
-
|
|
600
|
+
basicAuthCredentialsId: ((_a = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _a === void 0 ? void 0 : _a.http_auth_credentials_required)
|
|
601
|
+
? (_b = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _b === void 0 ? void 0 : _b.http_auth_credentials_id
|
|
602
|
+
: undefined,
|
|
642
603
|
branchName: (_c = journeyRun.journey_parameters) === null || _c === void 0 ? void 0 : _c.source_control_tag,
|
|
643
604
|
credentialsId: (_d = planRun.run_policy) === null || _d === void 0 ? void 0 : _d.credentials_id,
|
|
605
|
+
dataTableVariables: (_e = journeyRun.journey_parameters) === null || _e === void 0 ? void 0 : _e.user_variables,
|
|
606
|
+
deviceEmulation: (_f = journeyRun.journey_parameters) === null || _f === void 0 ? void 0 : _f.device_emulation,
|
|
607
|
+
environmentId: (_h = (_g = journeyRun.journey_parameters) === null || _g === void 0 ? void 0 : _g.deployment) === null || _h === void 0 ? void 0 : _h.environment_id,
|
|
644
608
|
filterHttpRequests: false,
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
dataTableVariables: (_k = journeyRun.journey_parameters) === null || _k === void 0 ? void 0 : _k.user_variables,
|
|
651
|
-
deviceEmulation: (_l = journeyRun.journey_parameters) === null || _l === void 0 ? void 0 : _l.device_emulation,
|
|
652
|
-
importedVariables: (_m = journeyRun.journey_parameters) === null || _m === void 0 ? void 0 : _m.imported_variables,
|
|
653
|
-
pageLoadWait: (_o = journeyRun.journey_parameters) === null || _o === void 0 ? void 0 : _o.page_load_wait,
|
|
609
|
+
journeyUserDefinedVariables: (_k = (_j = journeyRun.journey) === null || _j === void 0 ? void 0 : _j.variables) === null || _k === void 0 ? void 0 : _k.inputs,
|
|
610
|
+
importedVariables: (_l = journeyRun.journey_parameters) === null || _l === void 0 ? void 0 : _l.imported_variables,
|
|
611
|
+
pageLoadWait: (_m = journeyRun.journey_parameters) === null || _m === void 0 ? void 0 : _m.page_load_wait,
|
|
612
|
+
testId: (_o = journeyRun.journey) === null || _o === void 0 ? void 0 : _o.invariant_id,
|
|
613
|
+
url: (_q = (_p = journeyRun.journey_parameters) === null || _p === void 0 ? void 0 : _p.deployment) === null || _q === void 0 ? void 0 : _q.uri,
|
|
654
614
|
};
|
|
655
615
|
}
|
|
656
616
|
exports.pullDownTestRunConfig = pullDownTestRunConfig;
|
|
657
617
|
async function extractTestRunConfig(executionMessage, apiClient) {
|
|
658
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
618
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
659
619
|
const journeyRun = (_a = executionMessage.journey_run) !== null && _a !== void 0 ? _a : (await apiClient.getTestRun(executionMessage.journey_run_id));
|
|
660
620
|
const planRun = executionMessage.plan_run;
|
|
661
621
|
const maybeRunnerType = ((_b = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _b === void 0 ? void 0 : _b.nodejs_runtime_variant)
|
|
@@ -663,17 +623,18 @@ async function extractTestRunConfig(executionMessage, apiClient) {
|
|
|
663
623
|
(_c = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _c === void 0 ? void 0 : _c.nodejs_runtime_variant
|
|
664
624
|
: undefined;
|
|
665
625
|
return {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
626
|
+
branchName: (_d = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _d === void 0 ? void 0 : _d.source_control_tag,
|
|
627
|
+
credentialsId: (_e = planRun === null || planRun === void 0 ? void 0 : planRun.run_policy) === null || _e === void 0 ? void 0 : _e.credentials_id,
|
|
628
|
+
dataTableVariables: (_f = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _f === void 0 ? void 0 : _f.user_variables,
|
|
629
|
+
deviceEmulation: (_g = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _g === void 0 ? void 0 : _g.device_emulation,
|
|
630
|
+
environmentId: (_j = (_h = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _h === void 0 ? void 0 : _h.deployment) === null || _j === void 0 ? void 0 : _j.environment_id,
|
|
669
631
|
filterHttpRequests: true,
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
deviceEmulation: (_m = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _m === void 0 ? void 0 : _m.device_emulation,
|
|
674
|
-
importedVariables: (_o = journeyRun.journey_parameters) === null || _o === void 0 ? void 0 : _o.imported_variables,
|
|
675
|
-
pageLoadWait: (_p = journeyRun.journey_parameters) === null || _p === void 0 ? void 0 : _p.page_load_wait,
|
|
632
|
+
importedVariables: (_k = journeyRun.journey_parameters) === null || _k === void 0 ? void 0 : _k.imported_variables,
|
|
633
|
+
journeyUserDefinedVariables: (_m = (_l = journeyRun.journey) === null || _l === void 0 ? void 0 : _l.variables) === null || _m === void 0 ? void 0 : _m.inputs,
|
|
634
|
+
pageLoadWait: (_o = journeyRun.journey_parameters) === null || _o === void 0 ? void 0 : _o.page_load_wait,
|
|
676
635
|
runnerType: maybeRunnerType,
|
|
636
|
+
testId: (_p = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey) === null || _p === void 0 ? void 0 : _p.invariant_id,
|
|
637
|
+
url: (_r = (_q = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _q === void 0 ? void 0 : _q.deployment) === null || _r === void 0 ? void 0 : _r.uri,
|
|
677
638
|
};
|
|
678
639
|
}
|
|
679
640
|
exports.extractTestRunConfig = extractTestRunConfig;
|
|
@@ -186,27 +186,27 @@ async function run(parsed) {
|
|
|
186
186
|
});
|
|
187
187
|
const testRunnerConfig = {
|
|
188
188
|
_cliCreated: true,
|
|
189
|
-
branchName: parsed['mabl-branch'],
|
|
190
189
|
basicAuthCredentialsId: parsed[constants_1.CommandArgBasicAuthCredentials],
|
|
190
|
+
branchName: parsed['mabl-branch'],
|
|
191
191
|
credentialsId: parsed['credentials-id'],
|
|
192
192
|
disableIsolation: parsed[constants_1.CommandArgBrowserDisableIsolation],
|
|
193
|
+
enableExtensions: parsed[constants_1.CommandArgBrowserEnableExtensions],
|
|
193
194
|
enableLink: parsed[constants_1.CommandArgEnableLink],
|
|
194
195
|
environmentId: parsed[constants_1.CommandArgEnvironmentId],
|
|
196
|
+
extraHttpHeaders,
|
|
195
197
|
filterHttpRequests: false,
|
|
198
|
+
fromPlanId: parsed['from-plan-id'],
|
|
196
199
|
headless: parsed.headless,
|
|
197
200
|
height: parsed.height,
|
|
198
201
|
highlights: parsed.highlights,
|
|
199
202
|
ignoreCertificateErrors: parsed[constants_1.CommandArgBrowserIgnoreCertificateErrors],
|
|
200
203
|
interactionSpeed: parsed[constants_1.CommandArgTestInteractionSpeed],
|
|
201
|
-
enableExtensions: parsed[constants_1.CommandArgBrowserEnableExtensions],
|
|
202
|
-
extraHttpHeaders,
|
|
203
204
|
keepBrowserOpen: parsed['keep-browser-open'],
|
|
204
205
|
labelsExclude: parsed['exclude-labels'],
|
|
205
206
|
labelsInclude: parsed.labels,
|
|
206
|
-
fromPlanId: parsed['from-plan-id'],
|
|
207
|
-
testId: parsed.id,
|
|
208
|
-
testFile: parsed[constants_1.CommandArgTestFile],
|
|
209
207
|
runId: parsed['run-id'],
|
|
208
|
+
testFile: parsed[constants_1.CommandArgTestFile],
|
|
209
|
+
testId: parsed.id,
|
|
210
210
|
url: parsed.url,
|
|
211
211
|
userAgent: parsed[constants_1.CommandArgUserAgent],
|
|
212
212
|
width: parsed.width,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTrainerId = exports.LOCAL_TRAINER_ID = void 0;
|
|
4
|
+
const env_1 = require("../../../env/env");
|
|
5
|
+
exports.LOCAL_TRAINER_ID = 'jmeffipchlcmnkllcolcbmneknjckcpp';
|
|
6
|
+
function getTrainerId() {
|
|
7
|
+
if (env_1.LOCAL_TRAINER_PATH) {
|
|
8
|
+
return env_1.EXTENSION_ID;
|
|
9
|
+
}
|
|
10
|
+
return exports.LOCAL_TRAINER_ID;
|
|
11
|
+
}
|
|
12
|
+
exports.getTrainerId = getTrainerId;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getDefaultLogMetadataForInfo = exports.MablCoreProcessAction = exports.MablCoreAction = exports.ExecutionPhase = exports.EventChannelMessageType = exports.getEmitter = exports.mablEventEmitter = exports.MablCoreEventEmitter = void 0;
|
|
4
|
+
exports.getDefaultLogMetadataForInfo = exports.MablCoreProcessAction = exports.MablCoreAction = exports.ObservationErrorSeverity = exports.ObservationErrorCode = exports.ExecutionPhase = exports.EventChannelMessageType = exports.getEmitter = exports.mablEventEmitter = exports.MablCoreEventEmitter = void 0;
|
|
5
5
|
const events_1 = require("events");
|
|
6
6
|
const loggingProvider_1 = require("../../providers/logging/loggingProvider");
|
|
7
7
|
const NO_ID_PLACEHOLDER = 'NO_ID_PROVIDED';
|
|
@@ -68,6 +68,16 @@ var ExecutionPhase;
|
|
|
68
68
|
ExecutionPhase["DURING_ACTION"] = "DURING_ACTION";
|
|
69
69
|
ExecutionPhase["SKIP_ACTION"] = "SKIP_ACTION";
|
|
70
70
|
})(ExecutionPhase = exports.ExecutionPhase || (exports.ExecutionPhase = {}));
|
|
71
|
+
var ObservationErrorCode;
|
|
72
|
+
(function (ObservationErrorCode) {
|
|
73
|
+
ObservationErrorCode["ILLEGAL_URL_ERROR"] = "ILLEGAL_URL_ERROR";
|
|
74
|
+
ObservationErrorCode["PAGE_LOAD_FAILURE"] = "PAGE_LOAD_FAILURE";
|
|
75
|
+
})(ObservationErrorCode = exports.ObservationErrorCode || (exports.ObservationErrorCode = {}));
|
|
76
|
+
var ObservationErrorSeverity;
|
|
77
|
+
(function (ObservationErrorSeverity) {
|
|
78
|
+
ObservationErrorSeverity["ERROR"] = "ERROR";
|
|
79
|
+
ObservationErrorSeverity["WARN"] = "WARN";
|
|
80
|
+
})(ObservationErrorSeverity = exports.ObservationErrorSeverity || (exports.ObservationErrorSeverity = {}));
|
|
71
81
|
class MablCoreAction {
|
|
72
82
|
constructor(type, payload, timestamp = Date.now()) {
|
|
73
83
|
this.type = type;
|