@testingbot/cli 1.0.1 → 1.0.2
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 +3 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +55 -8
- package/dist/models/espresso_options.d.ts +9 -0
- package/dist/models/espresso_options.d.ts.map +1 -1
- package/dist/models/espresso_options.js +14 -0
- package/dist/models/maestro_options.d.ts +19 -7
- package/dist/models/maestro_options.d.ts.map +1 -1
- package/dist/models/maestro_options.js +17 -8
- package/dist/models/testingbot_error.d.ts +3 -0
- package/dist/models/testingbot_error.d.ts.map +1 -1
- package/dist/models/testingbot_error.js +5 -0
- package/dist/models/xcuitest_options.d.ts +9 -0
- package/dist/models/xcuitest_options.d.ts.map +1 -1
- package/dist/models/xcuitest_options.js +14 -0
- package/dist/providers/base_provider.d.ts +119 -0
- package/dist/providers/base_provider.d.ts.map +1 -0
- package/dist/providers/base_provider.js +296 -0
- package/dist/providers/espresso.d.ts +14 -21
- package/dist/providers/espresso.d.ts.map +1 -1
- package/dist/providers/espresso.js +39 -168
- package/dist/providers/login.d.ts +1 -0
- package/dist/providers/login.d.ts.map +1 -1
- package/dist/providers/login.js +16 -7
- package/dist/providers/maestro.d.ts +53 -21
- package/dist/providers/maestro.d.ts.map +1 -1
- package/dist/providers/maestro.js +614 -263
- package/dist/providers/xcuitest.d.ts +14 -21
- package/dist/providers/xcuitest.d.ts.map +1 -1
- package/dist/providers/xcuitest.js +39 -168
- package/dist/upload.d.ts +10 -0
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +46 -21
- package/dist/utils/connectivity.d.ts +25 -0
- package/dist/utils/connectivity.d.ts.map +1 -0
- package/dist/utils/connectivity.js +118 -0
- package/dist/utils/error-helpers.d.ts +26 -0
- package/dist/utils/error-helpers.d.ts.map +1 -0
- package/dist/utils/error-helpers.js +237 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +7 -2
- package/package.json +1 -1
|
@@ -10,26 +10,14 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
10
10
|
const socket_io_client_1 = require("socket.io-client");
|
|
11
11
|
const testingbot_error_1 = __importDefault(require("../models/testingbot_error"));
|
|
12
12
|
const utils_1 = __importDefault(require("../utils"));
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
class Espresso {
|
|
13
|
+
const base_provider_1 = __importDefault(require("./base_provider"));
|
|
14
|
+
class Espresso extends base_provider_1.default {
|
|
16
15
|
URL = 'https://api.testingbot.com/v1/app-automate/espresso';
|
|
17
|
-
POLL_INTERVAL_MS = 5000;
|
|
18
|
-
MAX_POLL_ATTEMPTS = 720; // 1 hour max with 5s interval
|
|
19
|
-
credentials;
|
|
20
|
-
options;
|
|
21
|
-
upload;
|
|
22
|
-
appId = undefined;
|
|
23
|
-
activeRunIds = [];
|
|
24
|
-
isShuttingDown = false;
|
|
25
|
-
signalHandler = null;
|
|
26
16
|
socket = null;
|
|
27
17
|
updateServer = null;
|
|
28
18
|
updateKey = null;
|
|
29
19
|
constructor(credentials, options) {
|
|
30
|
-
|
|
31
|
-
this.options = options;
|
|
32
|
-
this.upload = new upload_1.default();
|
|
20
|
+
super(credentials, options);
|
|
33
21
|
}
|
|
34
22
|
async validate() {
|
|
35
23
|
if (this.options.app === undefined) {
|
|
@@ -59,35 +47,13 @@ class Espresso {
|
|
|
59
47
|
}
|
|
60
48
|
return true;
|
|
61
49
|
}
|
|
62
|
-
async ensureOutputDirectory(dirPath) {
|
|
63
|
-
try {
|
|
64
|
-
const stat = await node_fs_1.default.promises.stat(dirPath);
|
|
65
|
-
if (!stat.isDirectory()) {
|
|
66
|
-
throw new testingbot_error_1.default(`Report output path exists but is not a directory: ${dirPath}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
if (error.code === 'ENOENT') {
|
|
71
|
-
try {
|
|
72
|
-
await node_fs_1.default.promises.mkdir(dirPath, { recursive: true });
|
|
73
|
-
}
|
|
74
|
-
catch (mkdirError) {
|
|
75
|
-
throw new testingbot_error_1.default(`Failed to create report output directory: ${dirPath}`, { cause: mkdirError });
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else if (error instanceof testingbot_error_1.default) {
|
|
79
|
-
throw error;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
throw new testingbot_error_1.default(`Failed to access report output directory: ${dirPath}`, { cause: error });
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
50
|
async run() {
|
|
87
51
|
if (!(await this.validate())) {
|
|
88
52
|
return { success: false, runs: [] };
|
|
89
53
|
}
|
|
90
54
|
try {
|
|
55
|
+
// Quick connectivity check before starting uploads
|
|
56
|
+
await this.ensureConnectivity();
|
|
91
57
|
if (!this.options.quiet) {
|
|
92
58
|
logger_1.default.info('Uploading Espresso App');
|
|
93
59
|
}
|
|
@@ -158,9 +124,11 @@ class Espresso {
|
|
|
158
124
|
try {
|
|
159
125
|
const capabilities = this.options.getCapabilities();
|
|
160
126
|
const espressoOptions = this.options.getEspressoOptions();
|
|
127
|
+
const metadata = this.options.metadata;
|
|
161
128
|
const response = await axios_1.default.post(`${this.URL}/${this.appId}/run`, {
|
|
162
129
|
capabilities: [capabilities],
|
|
163
130
|
...(espressoOptions && { espressoOptions }),
|
|
131
|
+
...(metadata && { metadata }),
|
|
164
132
|
}, {
|
|
165
133
|
headers: {
|
|
166
134
|
'Content-Type': 'application/json',
|
|
@@ -170,6 +138,7 @@ class Espresso {
|
|
|
170
138
|
username: this.credentials.userName,
|
|
171
139
|
password: this.credentials.accessKey,
|
|
172
140
|
},
|
|
141
|
+
timeout: 30000, // 30 second timeout
|
|
173
142
|
});
|
|
174
143
|
// Check for version update notification
|
|
175
144
|
const latestVersion = response.headers?.['x-testingbotctl-version'];
|
|
@@ -192,28 +161,30 @@ class Espresso {
|
|
|
192
161
|
if (error instanceof testingbot_error_1.default) {
|
|
193
162
|
throw error;
|
|
194
163
|
}
|
|
195
|
-
throw
|
|
196
|
-
cause: error,
|
|
197
|
-
});
|
|
164
|
+
throw await this.handleErrorWithDiagnostics(error, 'Running Espresso test failed');
|
|
198
165
|
}
|
|
199
166
|
}
|
|
200
167
|
async getStatus() {
|
|
201
168
|
try {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
169
|
+
return await this.withRetry('Getting Espresso test status', async () => {
|
|
170
|
+
const response = await axios_1.default.get(`${this.URL}/${this.appId}`, {
|
|
171
|
+
headers: {
|
|
172
|
+
'User-Agent': utils_1.default.getUserAgent(),
|
|
173
|
+
},
|
|
174
|
+
auth: {
|
|
175
|
+
username: this.credentials.userName,
|
|
176
|
+
password: this.credentials.accessKey,
|
|
177
|
+
},
|
|
178
|
+
timeout: 30000, // 30 second timeout
|
|
179
|
+
});
|
|
180
|
+
// Check for version update notification
|
|
181
|
+
const latestVersion = response.headers?.['x-testingbotctl-version'];
|
|
182
|
+
utils_1.default.checkForUpdate(latestVersion);
|
|
183
|
+
return response.data;
|
|
210
184
|
});
|
|
211
|
-
return response.data;
|
|
212
185
|
}
|
|
213
186
|
catch (error) {
|
|
214
|
-
throw
|
|
215
|
-
cause: error,
|
|
216
|
-
});
|
|
187
|
+
throw await this.handleErrorWithDiagnostics(error, 'Failed to get Espresso test status');
|
|
217
188
|
}
|
|
218
189
|
}
|
|
219
190
|
async waitForCompletion() {
|
|
@@ -240,7 +211,7 @@ class Espresso {
|
|
|
240
211
|
for (const run of status.runs) {
|
|
241
212
|
const statusEmoji = run.success === 1 ? '✅' : '❌';
|
|
242
213
|
const statusText = run.success === 1 ? 'Test completed successfully' : 'Test failed';
|
|
243
|
-
console.log(` ${statusEmoji} Run ${run.id} (${run
|
|
214
|
+
console.log(` ${statusEmoji} Run ${run.id} (${this.getRunDisplayName(run)}): ${statusText}`);
|
|
244
215
|
}
|
|
245
216
|
}
|
|
246
217
|
const allSucceeded = status.runs.every((run) => run.success === 1);
|
|
@@ -253,7 +224,7 @@ class Espresso {
|
|
|
253
224
|
const failedRuns = status.runs.filter((run) => run.success !== 1);
|
|
254
225
|
logger_1.default.error(`${failedRuns.length} test run(s) failed:`);
|
|
255
226
|
for (const run of failedRuns) {
|
|
256
|
-
logger_1.default.error(` - Run ${run.id} (${run
|
|
227
|
+
logger_1.default.error(` - Run ${run.id} (${this.getRunDisplayName(run)}): ${run.report || 'No report available'}`);
|
|
257
228
|
}
|
|
258
229
|
}
|
|
259
230
|
// Fetch reports if requested
|
|
@@ -284,24 +255,20 @@ class Espresso {
|
|
|
284
255
|
previousStatus.set(run.id, run.status);
|
|
285
256
|
const statusInfo = this.getStatusInfo(run.status);
|
|
286
257
|
if (run.status === 'WAITING' || run.status === 'READY') {
|
|
287
|
-
const message = ` ${statusInfo.emoji} Run ${run.id} (${run
|
|
258
|
+
const message = ` ${statusInfo.emoji} Run ${run.id} (${this.getRunDisplayName(run)}): ${statusInfo.text} (${elapsedStr})`;
|
|
288
259
|
process.stdout.write(`\r${message}`);
|
|
289
260
|
}
|
|
290
261
|
else if (statusChanged) {
|
|
291
|
-
console.log(` ${statusInfo.emoji} Run ${run.id} (${run
|
|
262
|
+
console.log(` ${statusInfo.emoji} Run ${run.id} (${this.getRunDisplayName(run)}): ${statusInfo.text}`);
|
|
292
263
|
}
|
|
293
264
|
}
|
|
294
265
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
const minutes = Math.floor(seconds / 60);
|
|
303
|
-
const remainingSeconds = seconds % 60;
|
|
304
|
-
return `${minutes}m ${remainingSeconds}s`;
|
|
266
|
+
/**
|
|
267
|
+
* Get the display name for a run, preferring environment.name over capabilities.deviceName
|
|
268
|
+
* This shows the actual device used when a wildcard (*) was specified
|
|
269
|
+
*/
|
|
270
|
+
getRunDisplayName(run) {
|
|
271
|
+
return run.environment?.name || run.capabilities.deviceName;
|
|
305
272
|
}
|
|
306
273
|
getStatusInfo(status) {
|
|
307
274
|
switch (status) {
|
|
@@ -340,7 +307,11 @@ class Espresso {
|
|
|
340
307
|
username: this.credentials.userName,
|
|
341
308
|
password: this.credentials.accessKey,
|
|
342
309
|
},
|
|
310
|
+
timeout: 30000, // 30 second timeout
|
|
343
311
|
});
|
|
312
|
+
// Check for version update notification
|
|
313
|
+
const latestVersion = response.headers?.['x-testingbotctl-version'];
|
|
314
|
+
utils_1.default.checkForUpdate(latestVersion);
|
|
344
315
|
const reportContent = response.data;
|
|
345
316
|
if (!reportContent) {
|
|
346
317
|
logger_1.default.error('No report content received');
|
|
@@ -357,106 +328,6 @@ class Espresso {
|
|
|
357
328
|
logger_1.default.error(`Failed to fetch report: ${error instanceof Error ? error.message : error}`);
|
|
358
329
|
}
|
|
359
330
|
}
|
|
360
|
-
sleep(ms) {
|
|
361
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
362
|
-
}
|
|
363
|
-
extractErrorMessage(cause) {
|
|
364
|
-
if (typeof cause === 'string') {
|
|
365
|
-
return cause;
|
|
366
|
-
}
|
|
367
|
-
if (Array.isArray(cause)) {
|
|
368
|
-
return cause.join('\n');
|
|
369
|
-
}
|
|
370
|
-
if (cause && typeof cause === 'object') {
|
|
371
|
-
const axiosError = cause;
|
|
372
|
-
if (axiosError.response?.data?.errors) {
|
|
373
|
-
return axiosError.response.data.errors.join('\n');
|
|
374
|
-
}
|
|
375
|
-
if (axiosError.response?.data?.error) {
|
|
376
|
-
return axiosError.response.data.error;
|
|
377
|
-
}
|
|
378
|
-
if (axiosError.response?.data?.message) {
|
|
379
|
-
return axiosError.response.data.message;
|
|
380
|
-
}
|
|
381
|
-
if (cause instanceof Error) {
|
|
382
|
-
return cause.message;
|
|
383
|
-
}
|
|
384
|
-
const obj = cause;
|
|
385
|
-
if (obj.errors) {
|
|
386
|
-
return obj.errors.join('\n');
|
|
387
|
-
}
|
|
388
|
-
if (obj.error) {
|
|
389
|
-
return obj.error;
|
|
390
|
-
}
|
|
391
|
-
if (obj.message) {
|
|
392
|
-
return obj.message;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
return null;
|
|
396
|
-
}
|
|
397
|
-
setupSignalHandlers() {
|
|
398
|
-
this.signalHandler = () => {
|
|
399
|
-
this.handleShutdown();
|
|
400
|
-
};
|
|
401
|
-
platform_1.default.setupSignalHandlers(this.signalHandler);
|
|
402
|
-
}
|
|
403
|
-
removeSignalHandlers() {
|
|
404
|
-
if (this.signalHandler) {
|
|
405
|
-
platform_1.default.removeSignalHandlers(this.signalHandler);
|
|
406
|
-
this.signalHandler = null;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
handleShutdown() {
|
|
410
|
-
if (this.isShuttingDown) {
|
|
411
|
-
logger_1.default.warn('Force exiting...');
|
|
412
|
-
process.exit(1);
|
|
413
|
-
}
|
|
414
|
-
this.isShuttingDown = true;
|
|
415
|
-
this.clearLine();
|
|
416
|
-
logger_1.default.warn('Received interrupt signal, stopping test runs...');
|
|
417
|
-
this.stopActiveRuns()
|
|
418
|
-
.then(() => {
|
|
419
|
-
logger_1.default.info('All test runs have been stopped.');
|
|
420
|
-
process.exit(1);
|
|
421
|
-
})
|
|
422
|
-
.catch((error) => {
|
|
423
|
-
logger_1.default.error(`Failed to stop some test runs: ${error instanceof Error ? error.message : error}`);
|
|
424
|
-
process.exit(1);
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
async stopActiveRuns() {
|
|
428
|
-
if (!this.appId || this.activeRunIds.length === 0) {
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
const stopPromises = this.activeRunIds.map((runId) => this.stopRun(runId).catch((error) => {
|
|
432
|
-
logger_1.default.error(`Failed to stop run ${runId}: ${error instanceof Error ? error.message : error}`);
|
|
433
|
-
}));
|
|
434
|
-
await Promise.all(stopPromises);
|
|
435
|
-
}
|
|
436
|
-
async stopRun(runId) {
|
|
437
|
-
if (!this.appId) {
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
try {
|
|
441
|
-
await axios_1.default.post(`${this.URL}/${this.appId}/${runId}/stop`, {}, {
|
|
442
|
-
headers: {
|
|
443
|
-
'User-Agent': utils_1.default.getUserAgent(),
|
|
444
|
-
},
|
|
445
|
-
auth: {
|
|
446
|
-
username: this.credentials.userName,
|
|
447
|
-
password: this.credentials.accessKey,
|
|
448
|
-
},
|
|
449
|
-
});
|
|
450
|
-
if (!this.options.quiet) {
|
|
451
|
-
logger_1.default.info(` Stopped run ${runId}`);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
catch (error) {
|
|
455
|
-
throw new testingbot_error_1.default(`Failed to stop run ${runId}`, {
|
|
456
|
-
cause: error,
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
331
|
connectToUpdateServer() {
|
|
461
332
|
if (!this.updateServer || !this.updateKey || this.options.quiet) {
|
|
462
333
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/providers/login.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/providers/login.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,IAAI,CAAa;IAEZ,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;IAiCxC,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,eAAe;IA4DvB,OAAO,CAAC,gBAAgB;IAoCxB,OAAO,CAAC,mBAAmB;IAoD3B,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,iBAAiB;YAyDX,eAAe;YAKf,WAAW;CAiB1B"}
|
package/dist/providers/login.js
CHANGED
|
@@ -8,7 +8,10 @@ const node_url_1 = require("node:url");
|
|
|
8
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
10
|
const node_os_1 = __importDefault(require("node:os"));
|
|
11
|
+
const node_child_process_1 = require("node:child_process");
|
|
12
|
+
const node_util_1 = require("node:util");
|
|
11
13
|
const logger_1 = __importDefault(require("../logger"));
|
|
14
|
+
const execFileAsync = (0, node_util_1.promisify)(node_child_process_1.execFile);
|
|
12
15
|
const AUTH_URL = 'https://testingbot.com/auth';
|
|
13
16
|
class Login {
|
|
14
17
|
server = null;
|
|
@@ -200,7 +203,16 @@ class Login {
|
|
|
200
203
|
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
201
204
|
res.end(html);
|
|
202
205
|
}
|
|
206
|
+
escapeHtml(text) {
|
|
207
|
+
return text
|
|
208
|
+
.replace(/&/g, '&')
|
|
209
|
+
.replace(/</g, '<')
|
|
210
|
+
.replace(/>/g, '>')
|
|
211
|
+
.replace(/"/g, '"')
|
|
212
|
+
.replace(/'/g, ''');
|
|
213
|
+
}
|
|
203
214
|
sendErrorResponse(res, error) {
|
|
215
|
+
const safeError = this.escapeHtml(error);
|
|
204
216
|
const html = `<!DOCTYPE html>
|
|
205
217
|
<html>
|
|
206
218
|
<head>
|
|
@@ -246,7 +258,7 @@ class Login {
|
|
|
246
258
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
|
247
259
|
</svg>
|
|
248
260
|
<h1>Authentication Failed</h1>
|
|
249
|
-
<p class="error">${
|
|
261
|
+
<p class="error">${safeError}</p>
|
|
250
262
|
<p>Please try again or contact support.</p>
|
|
251
263
|
</div>
|
|
252
264
|
</body>
|
|
@@ -259,20 +271,17 @@ class Login {
|
|
|
259
271
|
await node_fs_1.default.promises.writeFile(filePath, `${key}:${secret}`, { mode: 0o600 });
|
|
260
272
|
}
|
|
261
273
|
async openBrowser(url) {
|
|
262
|
-
const { exec } = await import('node:child_process');
|
|
263
|
-
const { promisify } = await import('node:util');
|
|
264
|
-
const execAsync = promisify(exec);
|
|
265
274
|
const platform = process.platform;
|
|
266
275
|
try {
|
|
267
276
|
if (platform === 'darwin') {
|
|
268
|
-
await
|
|
277
|
+
await execFileAsync('open', [url]);
|
|
269
278
|
}
|
|
270
279
|
else if (platform === 'win32') {
|
|
271
|
-
await
|
|
280
|
+
await execFileAsync('cmd', ['/c', 'start', '', url]);
|
|
272
281
|
}
|
|
273
282
|
else {
|
|
274
283
|
// Linux and others
|
|
275
|
-
await
|
|
284
|
+
await execFileAsync('xdg-open', [url]);
|
|
276
285
|
}
|
|
277
286
|
}
|
|
278
287
|
catch {
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import MaestroOptions from '../models/maestro_options';
|
|
2
2
|
import Credentials from '../models/credentials';
|
|
3
|
+
import BaseProvider from './base_provider';
|
|
3
4
|
export interface MaestroRunAssets {
|
|
4
5
|
logs?: Record<string, string>;
|
|
5
6
|
video?: string | false;
|
|
6
7
|
screenshots?: string[];
|
|
7
8
|
}
|
|
9
|
+
export type MaestroFlowStatus = 'WAITING' | 'READY' | 'DONE' | 'FAILED';
|
|
10
|
+
export interface MaestroFlowInfo {
|
|
11
|
+
id: number;
|
|
12
|
+
name: string;
|
|
13
|
+
report?: string;
|
|
14
|
+
requested_at?: string;
|
|
15
|
+
completed_at?: string;
|
|
16
|
+
status: MaestroFlowStatus;
|
|
17
|
+
success?: number;
|
|
18
|
+
test_case_id?: number;
|
|
19
|
+
error_messages?: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface MaestroRunEnvironment {
|
|
22
|
+
device?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
version?: string;
|
|
25
|
+
}
|
|
8
26
|
export interface MaestroRunInfo {
|
|
9
27
|
id: number;
|
|
10
28
|
status: 'WAITING' | 'READY' | 'DONE' | 'FAILED';
|
|
@@ -13,10 +31,13 @@ export interface MaestroRunInfo {
|
|
|
13
31
|
platformName: string;
|
|
14
32
|
version?: string;
|
|
15
33
|
};
|
|
34
|
+
environment?: MaestroRunEnvironment;
|
|
16
35
|
success: number;
|
|
17
36
|
report?: string;
|
|
18
37
|
options?: Record<string, unknown>;
|
|
19
38
|
assets?: MaestroRunAssets;
|
|
39
|
+
flows?: MaestroFlowInfo[];
|
|
40
|
+
error_messages?: string[];
|
|
20
41
|
}
|
|
21
42
|
export interface MaestroRunDetails extends MaestroRunInfo {
|
|
22
43
|
completed: boolean;
|
|
@@ -35,41 +56,59 @@ export interface MaestroSocketMessage {
|
|
|
35
56
|
id: number;
|
|
36
57
|
payload: string;
|
|
37
58
|
}
|
|
38
|
-
export default class Maestro {
|
|
39
|
-
|
|
40
|
-
private readonly POLL_INTERVAL_MS;
|
|
41
|
-
private readonly MAX_POLL_ATTEMPTS;
|
|
42
|
-
private credentials;
|
|
43
|
-
private options;
|
|
44
|
-
private upload;
|
|
45
|
-
private appId;
|
|
59
|
+
export default class Maestro extends BaseProvider<MaestroOptions> {
|
|
60
|
+
protected readonly URL = "https://api.testingbot.com/v1/app-automate/maestro";
|
|
46
61
|
private detectedPlatform;
|
|
47
|
-
private activeRunIds;
|
|
48
|
-
private isShuttingDown;
|
|
49
|
-
private signalHandler;
|
|
50
62
|
private socket;
|
|
51
63
|
private updateServer;
|
|
52
64
|
private updateKey;
|
|
53
65
|
constructor(credentials: Credentials, options: MaestroOptions);
|
|
54
66
|
private validate;
|
|
55
|
-
private ensureOutputDirectory;
|
|
56
67
|
/**
|
|
57
68
|
* Detect platform from app file content using magic bytes
|
|
58
69
|
*/
|
|
59
70
|
private detectPlatform;
|
|
60
71
|
run(): Promise<MaestroResult>;
|
|
61
72
|
private uploadApp;
|
|
73
|
+
private checkAppChecksum;
|
|
62
74
|
private uploadFlows;
|
|
63
75
|
private discoverFlows;
|
|
64
76
|
private discoverDependencies;
|
|
77
|
+
/**
|
|
78
|
+
* Check if a string looks like a file path (relative path with extension)
|
|
79
|
+
*/
|
|
80
|
+
private looksLikePath;
|
|
81
|
+
/**
|
|
82
|
+
* Try to add a file path as a dependency if it exists
|
|
83
|
+
*/
|
|
84
|
+
private tryAddDependency;
|
|
85
|
+
/**
|
|
86
|
+
* Recursively extract file paths from any value in the YAML structure
|
|
87
|
+
*/
|
|
88
|
+
private extractPathsFromValue;
|
|
89
|
+
private logIncludedFiles;
|
|
65
90
|
private createFlowsZip;
|
|
66
91
|
private runTests;
|
|
67
92
|
private getStatus;
|
|
68
93
|
private waitForCompletion;
|
|
69
94
|
private displayRunStatus;
|
|
70
|
-
|
|
71
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Get the display name for a run, preferring environment.name over capabilities.deviceName
|
|
97
|
+
* This shows the actual device used when a wildcard (*) was specified
|
|
98
|
+
*/
|
|
99
|
+
private getRunDisplayName;
|
|
72
100
|
private getStatusInfo;
|
|
101
|
+
private getFlowStatusDisplay;
|
|
102
|
+
private hasAnyFlowFailed;
|
|
103
|
+
private calculateFlowDuration;
|
|
104
|
+
private getTerminalHeight;
|
|
105
|
+
private getMaxDisplayableFlows;
|
|
106
|
+
private getRemainingSummary;
|
|
107
|
+
private displayFlowsWithLimit;
|
|
108
|
+
private displayFlowsTableHeader;
|
|
109
|
+
private displayFlowRow;
|
|
110
|
+
private displayFlowsTable;
|
|
111
|
+
private updateFlowsInPlace;
|
|
73
112
|
private fetchReports;
|
|
74
113
|
private getRunDetails;
|
|
75
114
|
private waitForArtifactsSync;
|
|
@@ -77,13 +116,6 @@ export default class Maestro {
|
|
|
77
116
|
private generateArtifactZipName;
|
|
78
117
|
private downloadArtifacts;
|
|
79
118
|
private createZipFromDirectory;
|
|
80
|
-
private sleep;
|
|
81
|
-
private extractErrorMessage;
|
|
82
|
-
private setupSignalHandlers;
|
|
83
|
-
private removeSignalHandlers;
|
|
84
|
-
private handleShutdown;
|
|
85
|
-
private stopActiveRuns;
|
|
86
|
-
private stopRun;
|
|
87
119
|
private connectToUpdateServer;
|
|
88
120
|
private disconnectFromUpdateServer;
|
|
89
121
|
private handleMaestroData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maestro.d.ts","sourceRoot":"","sources":["../../src/providers/maestro.ts"],"names":[],"mappings":"AAAA,OAAO,cAAiC,MAAM,2BAA2B,CAAC;AAE1E,OAAO,WAAW,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"maestro.d.ts","sourceRoot":"","sources":["../../src/providers/maestro.ts"],"names":[],"mappings":"AAAA,OAAO,cAAiC,MAAM,2BAA2B,CAAC;AAE1E,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAahD,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAE3C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAExE,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,W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