@resolveio/server-lib 22.3.80 → 22.3.82
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/package.json
CHANGED
|
@@ -54,11 +54,19 @@ export interface ResolveIORunnerPersistEvidenceResult {
|
|
|
54
54
|
files: ResolveIORunnerPersistedEvidenceFile[];
|
|
55
55
|
errors: string[];
|
|
56
56
|
}
|
|
57
|
+
export interface ResolveIORunnerEvidenceArtifactRootScanInput {
|
|
58
|
+
roots?: string[];
|
|
59
|
+
artifactDirNames?: string[];
|
|
60
|
+
maxFiles?: number;
|
|
61
|
+
includeJson?: boolean;
|
|
62
|
+
}
|
|
57
63
|
export declare function inferResolveIORunnerEvidenceContentType(fileName: string): string;
|
|
58
64
|
export declare function buildResolveIORunnerEvidenceCid(filePath: string): string;
|
|
59
65
|
export declare function inferResolveIORunnerEvidenceCaption(fileNameOrPath: string): string;
|
|
60
66
|
export declare function normalizeResolveIORunnerPersistedEvidenceFiles(value: any): ResolveIORunnerPersistedEvidenceFile[];
|
|
61
67
|
export declare function mergeResolveIORunnerEvidenceFileIds(...values: any[]): string[];
|
|
68
|
+
export declare function collectResolveIORunnerEvidenceArtifactFilesFromRoots(input?: ResolveIORunnerEvidenceArtifactRootScanInput): string[];
|
|
69
|
+
export declare function toResolveIORunnerEvidenceAttachmentsFromRoots(input?: ResolveIORunnerEvidenceArtifactRootScanInput): ResolveIORunnerEvidenceAttachment[];
|
|
62
70
|
export declare function collectResolveIORunnerEvidenceArtifactPaths(input?: {
|
|
63
71
|
evidence?: any;
|
|
64
72
|
job?: any;
|
|
@@ -88,6 +88,8 @@ exports.buildResolveIORunnerEvidenceCid = buildResolveIORunnerEvidenceCid;
|
|
|
88
88
|
exports.inferResolveIORunnerEvidenceCaption = inferResolveIORunnerEvidenceCaption;
|
|
89
89
|
exports.normalizeResolveIORunnerPersistedEvidenceFiles = normalizeResolveIORunnerPersistedEvidenceFiles;
|
|
90
90
|
exports.mergeResolveIORunnerEvidenceFileIds = mergeResolveIORunnerEvidenceFileIds;
|
|
91
|
+
exports.collectResolveIORunnerEvidenceArtifactFilesFromRoots = collectResolveIORunnerEvidenceArtifactFilesFromRoots;
|
|
92
|
+
exports.toResolveIORunnerEvidenceAttachmentsFromRoots = toResolveIORunnerEvidenceAttachmentsFromRoots;
|
|
91
93
|
exports.collectResolveIORunnerEvidenceArtifactPaths = collectResolveIORunnerEvidenceArtifactPaths;
|
|
92
94
|
exports.toResolveIORunnerEvidenceAttachments = toResolveIORunnerEvidenceAttachments;
|
|
93
95
|
exports.persistResolveIORunnerEvidenceArtifacts = persistResolveIORunnerEvidenceArtifacts;
|
|
@@ -265,8 +267,188 @@ function resolveArtifactCandidate(candidate, roots) {
|
|
|
265
267
|
}
|
|
266
268
|
return '';
|
|
267
269
|
}
|
|
270
|
+
function isEvidenceArtifactExtension(filePath, includeJson) {
|
|
271
|
+
var ext = path.extname(String(filePath || '')).toLowerCase();
|
|
272
|
+
return ext === '.png'
|
|
273
|
+
|| ext === '.jpg'
|
|
274
|
+
|| ext === '.jpeg'
|
|
275
|
+
|| ext === '.webp'
|
|
276
|
+
|| ext === '.zip'
|
|
277
|
+
|| (includeJson && ext === '.json');
|
|
278
|
+
}
|
|
279
|
+
function scoreEvidenceArtifactPath(filePath) {
|
|
280
|
+
var baseName = path.basename(String(filePath || '')).toLowerCase();
|
|
281
|
+
var ext = path.extname(baseName);
|
|
282
|
+
var score = 0;
|
|
283
|
+
if (['.png', '.jpg', '.jpeg', '.webp'].includes(ext)) {
|
|
284
|
+
score += 100;
|
|
285
|
+
}
|
|
286
|
+
if (/\b(invoice|billing|surcharge|tax|inventory|transaction|location|chemical|item|truck|delivery|saved|submit|line|select|modal)\b/i.test(baseName)) {
|
|
287
|
+
score += 60;
|
|
288
|
+
}
|
|
289
|
+
if (/\b(coverage|assert|result|summary|matrix)\b/i.test(baseName)) {
|
|
290
|
+
score += 20;
|
|
291
|
+
}
|
|
292
|
+
if (/\b(auth|bootstrap|ready|client\.log|server\.log|runner|chrome)\b/i.test(baseName)) {
|
|
293
|
+
score -= 120;
|
|
294
|
+
}
|
|
295
|
+
return score;
|
|
296
|
+
}
|
|
297
|
+
function collectEvidenceArtifactFilesFromDirectory(dirPath, includeJson, output, seen, depth) {
|
|
298
|
+
var e_2, _a;
|
|
299
|
+
if (depth === void 0) { depth = 0; }
|
|
300
|
+
if (depth > 2) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
var entries = [];
|
|
304
|
+
try {
|
|
305
|
+
entries = fs.readdirSync(dirPath);
|
|
306
|
+
}
|
|
307
|
+
catch (_b) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
try {
|
|
311
|
+
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
312
|
+
var entry = entries_1_1.value;
|
|
313
|
+
var candidate = path.join(dirPath, entry);
|
|
314
|
+
var stat = void 0;
|
|
315
|
+
try {
|
|
316
|
+
stat = fs.statSync(candidate);
|
|
317
|
+
}
|
|
318
|
+
catch (_c) {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
if (stat.isDirectory()) {
|
|
322
|
+
collectEvidenceArtifactFilesFromDirectory(candidate, includeJson, output, seen, depth + 1);
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
if (!stat.isFile() || stat.size <= 0 || !isEvidenceArtifactExtension(candidate, includeJson)) {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
var resolved = path.resolve(candidate);
|
|
329
|
+
if (seen.has(resolved)) {
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
seen.add(resolved);
|
|
333
|
+
output.push({
|
|
334
|
+
filePath: resolved,
|
|
335
|
+
score: scoreEvidenceArtifactPath(resolved),
|
|
336
|
+
mtimeMs: Number(stat.mtimeMs || 0)
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
341
|
+
finally {
|
|
342
|
+
try {
|
|
343
|
+
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
|
|
344
|
+
}
|
|
345
|
+
finally { if (e_2) throw e_2.error; }
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function collectResolveIORunnerEvidenceArtifactFilesFromRoots(input) {
|
|
349
|
+
var e_3, _a, e_4, _b, e_5, _c;
|
|
350
|
+
var _d;
|
|
351
|
+
if (input === void 0) { input = {}; }
|
|
352
|
+
var maxFiles = Math.max(1, Number(input.maxFiles || 12));
|
|
353
|
+
var includeJson = input.includeJson !== false;
|
|
354
|
+
var artifactDirNames = (((_d = input.artifactDirNames) === null || _d === void 0 ? void 0 : _d.length) ? input.artifactDirNames : ['qa-artifacts'])
|
|
355
|
+
.map(function (entry) { return String(entry || '').trim(); })
|
|
356
|
+
.filter(Boolean);
|
|
357
|
+
var roots = Array.from(new Set((input.roots || [])
|
|
358
|
+
.map(function (entry) { return String(entry || '').trim(); })
|
|
359
|
+
.filter(Boolean)
|
|
360
|
+
.map(function (entry) { return path.resolve(entry); })));
|
|
361
|
+
var artifactDirs = new Set();
|
|
362
|
+
try {
|
|
363
|
+
for (var roots_2 = __values(roots), roots_2_1 = roots_2.next(); !roots_2_1.done; roots_2_1 = roots_2.next()) {
|
|
364
|
+
var root = roots_2_1.value;
|
|
365
|
+
var stat = null;
|
|
366
|
+
try {
|
|
367
|
+
stat = fs.statSync(root);
|
|
368
|
+
}
|
|
369
|
+
catch (_e) {
|
|
370
|
+
stat = null;
|
|
371
|
+
}
|
|
372
|
+
if (!(stat === null || stat === void 0 ? void 0 : stat.isDirectory())) {
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
var rootBaseName = path.basename(root);
|
|
376
|
+
if (artifactDirNames.includes(rootBaseName)) {
|
|
377
|
+
artifactDirs.add(root);
|
|
378
|
+
}
|
|
379
|
+
try {
|
|
380
|
+
for (var artifactDirNames_1 = (e_4 = void 0, __values(artifactDirNames)), artifactDirNames_1_1 = artifactDirNames_1.next(); !artifactDirNames_1_1.done; artifactDirNames_1_1 = artifactDirNames_1.next()) {
|
|
381
|
+
var artifactDirName = artifactDirNames_1_1.value;
|
|
382
|
+
var directArtifactDir = path.join(root, artifactDirName);
|
|
383
|
+
try {
|
|
384
|
+
if (fs.statSync(directArtifactDir).isDirectory()) {
|
|
385
|
+
artifactDirs.add(directArtifactDir);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
catch (_f) {
|
|
389
|
+
// Ignore missing artifact directories.
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
394
|
+
finally {
|
|
395
|
+
try {
|
|
396
|
+
if (artifactDirNames_1_1 && !artifactDirNames_1_1.done && (_b = artifactDirNames_1.return)) _b.call(artifactDirNames_1);
|
|
397
|
+
}
|
|
398
|
+
finally { if (e_4) throw e_4.error; }
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
403
|
+
finally {
|
|
404
|
+
try {
|
|
405
|
+
if (roots_2_1 && !roots_2_1.done && (_a = roots_2.return)) _a.call(roots_2);
|
|
406
|
+
}
|
|
407
|
+
finally { if (e_3) throw e_3.error; }
|
|
408
|
+
}
|
|
409
|
+
var seen = new Set();
|
|
410
|
+
var files = [];
|
|
411
|
+
try {
|
|
412
|
+
for (var artifactDirs_1 = __values(artifactDirs), artifactDirs_1_1 = artifactDirs_1.next(); !artifactDirs_1_1.done; artifactDirs_1_1 = artifactDirs_1.next()) {
|
|
413
|
+
var artifactDir = artifactDirs_1_1.value;
|
|
414
|
+
collectEvidenceArtifactFilesFromDirectory(artifactDir, includeJson, files, seen);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
418
|
+
finally {
|
|
419
|
+
try {
|
|
420
|
+
if (artifactDirs_1_1 && !artifactDirs_1_1.done && (_c = artifactDirs_1.return)) _c.call(artifactDirs_1);
|
|
421
|
+
}
|
|
422
|
+
finally { if (e_5) throw e_5.error; }
|
|
423
|
+
}
|
|
424
|
+
return files
|
|
425
|
+
.sort(function (left, right) {
|
|
426
|
+
if (right.score !== left.score) {
|
|
427
|
+
return right.score - left.score;
|
|
428
|
+
}
|
|
429
|
+
if (left.mtimeMs !== right.mtimeMs) {
|
|
430
|
+
return left.mtimeMs - right.mtimeMs;
|
|
431
|
+
}
|
|
432
|
+
return left.filePath.localeCompare(right.filePath);
|
|
433
|
+
})
|
|
434
|
+
.slice(0, maxFiles)
|
|
435
|
+
.map(function (entry) { return entry.filePath; });
|
|
436
|
+
}
|
|
437
|
+
function toResolveIORunnerEvidenceAttachmentsFromRoots(input) {
|
|
438
|
+
if (input === void 0) { input = {}; }
|
|
439
|
+
return collectResolveIORunnerEvidenceArtifactFilesFromRoots(input).map(function (filePath) {
|
|
440
|
+
var filename = path.basename(filePath);
|
|
441
|
+
return {
|
|
442
|
+
filename: filename,
|
|
443
|
+
path: filePath,
|
|
444
|
+
contentType: inferResolveIORunnerEvidenceContentType(filename),
|
|
445
|
+
cid: buildResolveIORunnerEvidenceCid(filePath),
|
|
446
|
+
caption: inferResolveIORunnerEvidenceCaption(filename)
|
|
447
|
+
};
|
|
448
|
+
});
|
|
449
|
+
}
|
|
268
450
|
function collectResolveIORunnerEvidenceArtifactPaths(input) {
|
|
269
|
-
var
|
|
451
|
+
var e_6, _a, e_7, _b, e_8, _c, e_9, _d, e_10, _e;
|
|
270
452
|
var _f, _g, _h, _j;
|
|
271
453
|
if (input === void 0) { input = {}; }
|
|
272
454
|
var values = [];
|
|
@@ -292,12 +474,12 @@ function collectResolveIORunnerEvidenceArtifactPaths(input) {
|
|
|
292
474
|
collectResolveIORunnerEvidenceText(task === null || task === void 0 ? void 0 : task.evidence, values);
|
|
293
475
|
}
|
|
294
476
|
}
|
|
295
|
-
catch (
|
|
477
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
296
478
|
finally {
|
|
297
479
|
try {
|
|
298
480
|
if (_l && !_l.done && (_a = _k.return)) _a.call(_k);
|
|
299
481
|
}
|
|
300
|
-
finally { if (
|
|
482
|
+
finally { if (e_6) throw e_6.error; }
|
|
301
483
|
}
|
|
302
484
|
}
|
|
303
485
|
if (Array.isArray(job.log)) {
|
|
@@ -315,39 +497,39 @@ function collectResolveIORunnerEvidenceArtifactPaths(input) {
|
|
|
315
497
|
var value = values_1_1.value;
|
|
316
498
|
var text = String(value || '');
|
|
317
499
|
try {
|
|
318
|
-
for (var _m = (
|
|
500
|
+
for (var _m = (e_8 = void 0, __values(text.matchAll(/((?:\/tmp\/|\/var\/|\/Users\/)[^\s)'"]+?\.(?:png|jpe?g|webp|zip|json|txt|log))/gi))), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
319
501
|
var match = _o.value;
|
|
320
502
|
candidates.push(match[1]);
|
|
321
503
|
}
|
|
322
504
|
}
|
|
323
|
-
catch (
|
|
505
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
324
506
|
finally {
|
|
325
507
|
try {
|
|
326
508
|
if (_o && !_o.done && (_c = _m.return)) _c.call(_m);
|
|
327
509
|
}
|
|
328
|
-
finally { if (
|
|
510
|
+
finally { if (e_8) throw e_8.error; }
|
|
329
511
|
}
|
|
330
512
|
try {
|
|
331
|
-
for (var _p = (
|
|
513
|
+
for (var _p = (e_9 = void 0, __values(text.matchAll(/(?:^|[\s("'`])((?:(?:[\w.-]+\/)*qa-artifacts|qa-artifacts|test-results|playwright-report|\.build-output)\/[^\s)'"]+?\.(?:png|jpe?g|webp|zip|json|txt|log))/gim))), _q = _p.next(); !_q.done; _q = _p.next()) {
|
|
332
514
|
var match = _q.value;
|
|
333
515
|
candidates.push(match[1]);
|
|
334
516
|
}
|
|
335
517
|
}
|
|
336
|
-
catch (
|
|
518
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
337
519
|
finally {
|
|
338
520
|
try {
|
|
339
521
|
if (_q && !_q.done && (_d = _p.return)) _d.call(_p);
|
|
340
522
|
}
|
|
341
|
-
finally { if (
|
|
523
|
+
finally { if (e_9) throw e_9.error; }
|
|
342
524
|
}
|
|
343
525
|
}
|
|
344
526
|
}
|
|
345
|
-
catch (
|
|
527
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
346
528
|
finally {
|
|
347
529
|
try {
|
|
348
530
|
if (values_1_1 && !values_1_1.done && (_b = values_1.return)) _b.call(values_1);
|
|
349
531
|
}
|
|
350
|
-
finally { if (
|
|
532
|
+
finally { if (e_7) throw e_7.error; }
|
|
351
533
|
}
|
|
352
534
|
var resolved = [];
|
|
353
535
|
var seen = new Set();
|
|
@@ -365,12 +547,12 @@ function collectResolveIORunnerEvidenceArtifactPaths(input) {
|
|
|
365
547
|
}
|
|
366
548
|
}
|
|
367
549
|
}
|
|
368
|
-
catch (
|
|
550
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
369
551
|
finally {
|
|
370
552
|
try {
|
|
371
553
|
if (candidates_1_1 && !candidates_1_1.done && (_e = candidates_1.return)) _e.call(candidates_1);
|
|
372
554
|
}
|
|
373
|
-
finally { if (
|
|
555
|
+
finally { if (e_10) throw e_10.error; }
|
|
374
556
|
}
|
|
375
557
|
return resolved;
|
|
376
558
|
}
|
|
@@ -389,8 +571,8 @@ function toResolveIORunnerEvidenceAttachments(input) {
|
|
|
389
571
|
}
|
|
390
572
|
function persistResolveIORunnerEvidenceArtifacts(options) {
|
|
391
573
|
return __awaiter(this, void 0, void 0, function () {
|
|
392
|
-
var maxFiles, previousFiles, existingByHash, previousFiles_1, previousFiles_1_1, file, attachments, persistedFiles, fileIds, errors, nextAttachments, seenPaths, attachments_1, attachments_1_1, attachment, filePath, filename, contentType, error, stat, error, contentBuffer, contentHash, existing, uploaded, fileId, persisted, error_1, message,
|
|
393
|
-
var
|
|
574
|
+
var maxFiles, previousFiles, existingByHash, previousFiles_1, previousFiles_1_1, file, attachments, persistedFiles, fileIds, errors, nextAttachments, seenPaths, attachments_1, attachments_1_1, attachment, filePath, filename, contentType, error, stat, error, contentBuffer, contentHash, existing, uploaded, fileId, persisted, error_1, message, e_11_1;
|
|
575
|
+
var e_12, _a, e_11, _b;
|
|
394
576
|
return __generator(this, function (_c) {
|
|
395
577
|
switch (_c.label) {
|
|
396
578
|
case 0:
|
|
@@ -405,12 +587,12 @@ function persistResolveIORunnerEvidenceArtifacts(options) {
|
|
|
405
587
|
}
|
|
406
588
|
}
|
|
407
589
|
}
|
|
408
|
-
catch (
|
|
590
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
409
591
|
finally {
|
|
410
592
|
try {
|
|
411
593
|
if (previousFiles_1_1 && !previousFiles_1_1.done && (_a = previousFiles_1.return)) _a.call(previousFiles_1);
|
|
412
594
|
}
|
|
413
|
-
finally { if (
|
|
595
|
+
finally { if (e_12) throw e_12.error; }
|
|
414
596
|
}
|
|
415
597
|
attachments = __spreadArray(__spreadArray([], __read((options.attachments || [])), false), __read(toResolveIORunnerEvidenceAttachments({
|
|
416
598
|
evidence: options.evidence,
|
|
@@ -508,14 +690,14 @@ function persistResolveIORunnerEvidenceArtifacts(options) {
|
|
|
508
690
|
return [3 /*break*/, 2];
|
|
509
691
|
case 9: return [3 /*break*/, 12];
|
|
510
692
|
case 10:
|
|
511
|
-
|
|
512
|
-
|
|
693
|
+
e_11_1 = _c.sent();
|
|
694
|
+
e_11 = { error: e_11_1 };
|
|
513
695
|
return [3 /*break*/, 12];
|
|
514
696
|
case 11:
|
|
515
697
|
try {
|
|
516
698
|
if (attachments_1_1 && !attachments_1_1.done && (_b = attachments_1.return)) _b.call(attachments_1);
|
|
517
699
|
}
|
|
518
|
-
finally { if (
|
|
700
|
+
finally { if (e_11) throw e_11.error; }
|
|
519
701
|
return [7 /*endfinally*/];
|
|
520
702
|
case 12: return [2 /*return*/, {
|
|
521
703
|
attachments: nextAttachments,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/ai-runner-artifacts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,0FAqBC;AAED,0EASC;AAED,kFAiCC;AAED,wGAqBC;AAED,kFAiBC;AAwDD,kGA8DC;AAED,oFAgBC;AAED,0FAoHC;AA7aD,2CAAyC;AACzC,uBAAyB;AACzB,2BAA6B;AAgE7B,SAAgB,uCAAuC,CAAC,QAAgB;IACvE,IAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC/D,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,OAAO,WAAW,CAAC;IACpB,CAAC;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACjE,OAAO,YAAY,CAAC;IACrB,CAAC;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,OAAO,YAAY,CAAC;IACrB,CAAC;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,OAAO,iBAAiB,CAAC;IAC1B,CAAC;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,OAAO,kBAAkB,CAAC;IAC3B,CAAC;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAChE,OAAO,2BAA2B,CAAC;IACpC,CAAC;IACD,OAAO,0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C,QAAQ,CAAC;wBAClG,YAAY,EAAE,WAAW;wBACzB,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,SAAS;qBAC/D,CAAC;oBACF,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAC/B,cAAc,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;oBAC3C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBACrB,eAAe,CAAC,IAAI,uBAChB,UAAU,KACb,QAAQ,UAAA,EACR,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,SAAS,CAAC,GAAG,EAClB,OAAO,EAAE,SAAS,CAAC,OAAO,EAC1B,YAAY,EAAE,WAAW,EACzB,UAAU,EAAE,SAAS,CAAC,UAAU,EAChC,0BAA0B,EAAE,IAAI,IAC/B,CAAC;;;;oBAGG,OAAO,GAAG,UAAG,QAAQ,eAAK,CAAC,OAAe,aAAf,OAAK,uBAAL,OAAK,CAAY,OAAO,KAAI,OAAK,CAAE,CAAC;oBACrE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACrB,eAAe,CAAC,IAAI,uBAAM,UAAU,KAAE,QAAQ,UAAA,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,IAAG,CAAC;;;;;;;;;;;;;;;;yBAItG,sBAAO;wBACN,WAAW,EAAE,eAAe;wBAC5B,OAAO,EAAE,mCAAmC,CAAC,OAAO,CAAC;wBACrD,KAAK,EAAE,cAAc;wBACrB,MAAM,QAAA;qBACN,EAAC;;;;CACF","file":"ai-runner-artifacts.js","sourcesContent":["import { createHash } from 'node:crypto';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nexport interface ResolveIORunnerEvidenceAttachment {\n\tfilename: string;\n\tpath: string;\n\tcontentType?: string;\n\tcid?: string;\n\tcaption?: string;\n\tfile_id?: string;\n\tkey?: string;\n\tcontent_hash?: string;\n\tticket_url?: string;\n\tuploaded_to_support_ticket?: boolean;\n\tupload_error?: string;\n}\n\nexport interface ResolveIORunnerPersistedEvidenceFile {\n\tfile_id: string;\n\tfilename: string;\n\tkey?: string;\n\tcontentType?: string;\n\tcaption?: string;\n\tcontent_hash?: string;\n\tticket_url?: string;\n}\n\nexport interface ResolveIORunnerEvidenceUploadInput {\n\tfilename: string;\n\tfilePath: string;\n\tcontentType: string;\n\tsize: number;\n\tcontentBuffer: Buffer;\n\tcontentHash: string;\n}\n\nexport interface ResolveIORunnerEvidenceUploadResult {\n\tfile_id?: string;\n\tid_file?: string;\n\t_id?: string;\n\tkey?: string;\n\tname?: string;\n\tfilename?: string;\n}\n\nexport interface ResolveIORunnerPersistEvidenceOptions {\n\tattachments?: ResolveIORunnerEvidenceAttachment[];\n\tevidence?: any;\n\tjob?: any;\n\tticket?: any;\n\tticketUrl?: string;\n\troots?: string[];\n\tpreviousFiles?: any[];\n\texistingFileIds?: any[];\n\tmaxFiles?: number;\n\tuploadFile: any;\n}\n\nexport interface ResolveIORunnerPersistEvidenceResult {\n\tattachments: ResolveIORunnerEvidenceAttachment[];\n\tfileIds: string[];\n\tfiles: ResolveIORunnerPersistedEvidenceFile[];\n\terrors: string[];\n}\n\nexport function inferResolveIORunnerEvidenceContentType(fileName: string): string {\n\tconst normalized = String(fileName || '').trim().toLowerCase();\n\tif (normalized.endsWith('.png')) {\n\t\treturn 'image/png';\n\t}\n\tif (normalized.endsWith('.jpg') || normalized.endsWith('.jpeg')) {\n\t\treturn 'image/jpeg';\n\t}\n\tif (normalized.endsWith('.webp')) {\n\t\treturn 'image/webp';\n\t}\n\tif (normalized.endsWith('.zip')) {\n\t\treturn 'application/zip';\n\t}\n\tif (normalized.endsWith('.json')) {\n\t\treturn 'application/json';\n\t}\n\tif (normalized.endsWith('.txt') || normalized.endsWith('.log')) {\n\t\treturn 'text/plain; charset=utf-8';\n\t}\n\treturn 'application/octet-stream';\n}\n\nexport function buildResolveIORunnerEvidenceCid(filePath: string): string {\n\tconst baseName = path.basename(String(filePath || '').trim()) || 'runner-artifact';\n\tconst normalized = baseName\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9._-]+/g, '-')\n\t\t.replace(/^-+|-+$/g, '')\n\t\t.slice(0, 80) || 'runner-artifact';\n\tconst digest = createHash('sha1').update(String(filePath || '')).digest('hex').slice(0, 12);\n\treturn `${normalized}-${digest}@resolveio-runner`;\n}\n\nexport function inferResolveIORunnerEvidenceCaption(fileNameOrPath: string): string {\n\tconst baseName = path.basename(String(fileNameOrPath || '').trim()).replace(/\\.[a-z0-9]+$/i, '');\n\tconst normalized = baseName\n\t\t.toLowerCase()\n\t\t.replace(/[_-]+/g, ' ')\n\t\t.replace(/\\b\\d{4,}\\b/g, '')\n\t\t.replace(/\\s+/g, ' ')\n\t\t.trim();\n\tif (!normalized) {\n\t\treturn 'QA screenshot captured during validation.';\n\t}\n\tif (/\\bbefore\\b/.test(normalized)) {\n\t\treturn 'Before: the tested page is loaded at the start of the workflow.';\n\t}\n\tif (/\\bready\\b/.test(normalized) && /\\bimport\\b/.test(normalized)) {\n\t\treturn 'Ready to import: the uploaded data was accepted and is displayed for review before submission.';\n\t}\n\tif (/\\bsubmitted\\b|\\bresult\\b|\\bafter\\b|\\bcomplete\\b|\\bsuccess\\b|\\bverified\\b/.test(normalized)) {\n\t\treturn 'After submission: the workflow completed and the result confirms the change worked.';\n\t}\n\tif (/\\bdialog\\b|\\bmodal\\b|\\bpopup\\b/.test(normalized)) {\n\t\treturn 'Dialog: the tested prompt or modal is shown in the expected state.';\n\t}\n\tif (/\\bmobile\\b/.test(normalized)) {\n\t\treturn 'Mobile view: the tested workflow is shown at the mobile viewport.';\n\t}\n\tif (/\\bdesktop\\b|\\bwide\\b/.test(normalized)) {\n\t\treturn 'Desktop view: the tested workflow is shown at a full-width desktop viewport.';\n\t}\n\treturn baseName\n\t\t.replace(/[_-]+/g, ' ')\n\t\t.replace(/\\b\\w/g, (letter) => letter.toUpperCase())\n\t\t.slice(0, 180);\n}\n\nexport function normalizeResolveIORunnerPersistedEvidenceFiles(value: any): ResolveIORunnerPersistedEvidenceFile[] {\n\tif (!Array.isArray(value)) {\n\t\treturn [];\n\t}\n\treturn value\n\t\t.map((item): ResolveIORunnerPersistedEvidenceFile | null => {\n\t\t\tconst fileId = String(item?.file_id || item?.id_file || item?._id || '').trim();\n\t\t\tif (!fileId) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tfile_id: fileId,\n\t\t\t\tfilename: String(item?.filename || item?.name || '').trim(),\n\t\t\t\tkey: String(item?.key || '').trim() || undefined,\n\t\t\t\tcontentType: String(item?.contentType || item?.content_type || '').trim() || undefined,\n\t\t\t\tcaption: String(item?.caption || '').trim() || undefined,\n\t\t\t\tcontent_hash: String(item?.content_hash || item?.hash || '').trim() || undefined,\n\t\t\t\tticket_url: String(item?.ticket_url || '').trim() || undefined\n\t\t\t};\n\t\t})\n\t\t.filter((item): item is ResolveIORunnerPersistedEvidenceFile => !!item);\n}\n\nexport function mergeResolveIORunnerEvidenceFileIds(...values: any[]): string[] {\n\tconst ids: string[] = [];\n\tconst seen = new Set<string>();\n\tconst push = (value: any) => {\n\t\tif (Array.isArray(value)) {\n\t\t\tvalue.forEach(push);\n\t\t\treturn;\n\t\t}\n\t\tconst id = String(value?.file_id || value?.id_file || value?._id || value || '').trim();\n\t\tif (!id || seen.has(id)) {\n\t\t\treturn;\n\t\t}\n\t\tseen.add(id);\n\t\tids.push(id);\n\t};\n\tvalues.forEach(push);\n\treturn ids;\n}\n\nfunction collectResolveIORunnerEvidenceText(value: any, output: string[]): void {\n\tif (value === null || value === undefined) {\n\t\treturn;\n\t}\n\tif (typeof value === 'string') {\n\t\toutput.push(value);\n\t\treturn;\n\t}\n\tif (Array.isArray(value)) {\n\t\tvalue.forEach((entry) => collectResolveIORunnerEvidenceText(entry, output));\n\t\treturn;\n\t}\n\tif (typeof value === 'object') {\n\t\tObject.values(value).forEach((entry) => collectResolveIORunnerEvidenceText(entry, output));\n\t}\n}\n\nfunction normalizeArtifactCandidatePath(value: string): string {\n\treturn String(value || '')\n\t\t.trim()\n\t\t.replace(/[),.;:'\"]+$/g, '')\n\t\t.replace(/\\\\/g, '/');\n}\n\nfunction pathExists(filePath: string): boolean {\n\ttry {\n\t\treturn !!filePath && fs.existsSync(filePath) && fs.statSync(filePath).isFile();\n\t}\n\tcatch {\n\t\treturn false;\n\t}\n}\n\nfunction resolveArtifactCandidate(candidate: string, roots: string[]): string {\n\tconst normalized = normalizeArtifactCandidatePath(candidate);\n\tif (!normalized) {\n\t\treturn '';\n\t}\n\tif (path.isAbsolute(normalized)) {\n\t\treturn pathExists(normalized) ? normalized : '';\n\t}\n\tfor (const root of roots) {\n\t\tconst normalizedRoot = String(root || '').trim();\n\t\tif (!normalizedRoot) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst resolved = path.resolve(normalizedRoot, normalized);\n\t\tif (pathExists(resolved)) {\n\t\t\treturn resolved;\n\t\t}\n\t}\n\treturn '';\n}\n\nexport function collectResolveIORunnerEvidenceArtifactPaths(input: {\n\tevidence?: any;\n\tjob?: any;\n\troots?: string[];\n\tmaxFiles?: number;\n} = {}): string[] {\n\tconst values: string[] = [];\n\tcollectResolveIORunnerEvidenceText(input.evidence, values);\n\tconst job = input.job || {};\n\tcollectResolveIORunnerEvidenceText(job.responseSummary, values);\n\tcollectResolveIORunnerEvidenceText(job.lastVerificationSummary, values);\n\tcollectResolveIORunnerEvidenceText(job.lastRerunReason, values);\n\tcollectResolveIORunnerEvidenceText(job.artifacts?.agentNotes, values);\n\tcollectResolveIORunnerEvidenceText(job.artifacts?.supportArtifacts, values);\n\tcollectResolveIORunnerEvidenceText(job.artifacts?.qaArtifacts, values);\n\tcollectResolveIORunnerEvidenceText(job.artifacts?.qa_artifacts, values);\n\tcollectResolveIORunnerEvidenceText(job.qa_artifacts, values);\n\tcollectResolveIORunnerEvidenceText(job.supportQaArtifacts, values);\n\tcollectResolveIORunnerEvidenceText(job.runnerEvidenceArtifacts, values);\n\tif (Array.isArray(job.tasks)) {\n\t\tfor (const task of job.tasks) {\n\t\t\tcollectResolveIORunnerEvidenceText(task?.title, values);\n\t\t\tcollectResolveIORunnerEvidenceText(task?.notes, values);\n\t\t\tcollectResolveIORunnerEvidenceText(task?.artifacts, values);\n\t\t\tcollectResolveIORunnerEvidenceText(task?.evidence, values);\n\t\t}\n\t}\n\tif (Array.isArray(job.log)) {\n\t\tcollectResolveIORunnerEvidenceText(job.log.slice(-160), values);\n\t}\n\n\tconst roots = Array.from(new Set([\n\t\t...(input.roots || []),\n\t\tjob.workspacePath,\n\t\tjob.projectRoot && job.workspacePath ? path.join(job.workspacePath, job.projectRoot) : '',\n\t\tjob.projectDisplayPath && job.workspacePath ? path.join(job.workspacePath, job.projectDisplayPath) : '',\n\t\tjob.localPath\n\t].map((entry) => String(entry || '').trim()).filter(Boolean)));\n\tconst candidates: string[] = [];\n\tfor (const value of values) {\n\t\tconst text = String(value || '');\n\t\tfor (const match of text.matchAll(/((?:\\/tmp\\/|\\/var\\/|\\/Users\\/)[^\\s)'\"]+?\\.(?:png|jpe?g|webp|zip|json|txt|log))/gi)) {\n\t\t\tcandidates.push(match[1]);\n\t\t}\n\t\tfor (const match of text.matchAll(/(?:^|[\\s(\"'`])((?:(?:[\\w.-]+\\/)*qa-artifacts|qa-artifacts|test-results|playwright-report|\\.build-output)\\/[^\\s)'\"]+?\\.(?:png|jpe?g|webp|zip|json|txt|log))/gim)) {\n\t\t\tcandidates.push(match[1]);\n\t\t}\n\t}\n\tconst resolved: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const candidate of candidates) {\n\t\tconst filePath = resolveArtifactCandidate(candidate, roots);\n\t\tif (!filePath || seen.has(filePath)) {\n\t\t\tcontinue;\n\t\t}\n\t\tseen.add(filePath);\n\t\tresolved.push(filePath);\n\t\tif (resolved.length >= (input.maxFiles || 8)) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn resolved;\n}\n\nexport function toResolveIORunnerEvidenceAttachments(input: {\n\tevidence?: any;\n\tjob?: any;\n\troots?: string[];\n\tmaxFiles?: number;\n} = {}): ResolveIORunnerEvidenceAttachment[] {\n\treturn collectResolveIORunnerEvidenceArtifactPaths(input).map((filePath) => {\n\t\tconst filename = path.basename(filePath);\n\t\treturn {\n\t\t\tfilename,\n\t\t\tpath: filePath,\n\t\t\tcontentType: inferResolveIORunnerEvidenceContentType(filename),\n\t\t\tcid: buildResolveIORunnerEvidenceCid(filePath),\n\t\t\tcaption: inferResolveIORunnerEvidenceCaption(filename)\n\t\t};\n\t});\n}\n\nexport async function persistResolveIORunnerEvidenceArtifacts(\n\toptions: ResolveIORunnerPersistEvidenceOptions\n): Promise<ResolveIORunnerPersistEvidenceResult> {\n\tconst maxFiles = Math.max(1, options.maxFiles || 8);\n\tconst previousFiles = normalizeResolveIORunnerPersistedEvidenceFiles(options.previousFiles);\n\tconst existingByHash = new Map<string, ResolveIORunnerPersistedEvidenceFile>();\n\tfor (const file of previousFiles) {\n\t\tif (file.content_hash) {\n\t\t\texistingByHash.set(file.content_hash, file);\n\t\t}\n\t}\n\tconst attachments = [\n\t\t...(options.attachments || []),\n\t\t...toResolveIORunnerEvidenceAttachments({\n\t\t\tevidence: options.evidence,\n\t\t\tjob: options.job,\n\t\t\troots: options.roots,\n\t\t\tmaxFiles\n\t\t})\n\t];\n\tconst persistedFiles = [...previousFiles];\n\tconst fileIds = mergeResolveIORunnerEvidenceFileIds(options.existingFileIds, previousFiles.map((file) => file.file_id));\n\tconst errors: string[] = [];\n\tconst nextAttachments: ResolveIORunnerEvidenceAttachment[] = [];\n\tconst seenPaths = new Set<string>();\n\n\tfor (const attachment of attachments) {\n\t\tif (nextAttachments.length >= maxFiles) {\n\t\t\tbreak;\n\t\t}\n\t\tconst filePath = String(attachment?.path || '').trim();\n\t\tif (!filePath || seenPaths.has(filePath)) {\n\t\t\tcontinue;\n\t\t}\n\t\tseenPaths.add(filePath);\n\t\tconst filename = String(attachment?.filename || path.basename(filePath) || 'runner-qa-artifact.png').trim();\n\t\tconst contentType = String(attachment?.contentType || inferResolveIORunnerEvidenceContentType(filename)).trim();\n\t\tif (!pathExists(filePath)) {\n\t\t\tconst error = `${filename}: evidence file was not found before S3 upload.`;\n\t\t\terrors.push(error);\n\t\t\tnextAttachments.push({ ...attachment, filename, upload_error: error });\n\t\t\tcontinue;\n\t\t}\n\t\tconst stat = await fs.promises.stat(filePath);\n\t\tif (!stat.isFile() || stat.size <= 0) {\n\t\t\tconst error = `${filename}: evidence file was empty before S3 upload.`;\n\t\t\terrors.push(error);\n\t\t\tnextAttachments.push({ ...attachment, filename, upload_error: error });\n\t\t\tcontinue;\n\t\t}\n\t\tconst contentBuffer = await fs.promises.readFile(filePath);\n\t\tconst contentHash = createHash('sha1').update(new Uint8Array(contentBuffer)).digest('hex');\n\t\tconst existing = existingByHash.get(contentHash);\n\t\tif (existing) {\n\t\t\tfileIds.push(existing.file_id);\n\t\t\tnextAttachments.push({\n\t\t\t\t...attachment,\n\t\t\t\tfilename,\n\t\t\t\tfile_id: existing.file_id,\n\t\t\t\tkey: existing.key,\n\t\t\t\tcaption: attachment.caption || existing.caption || inferResolveIORunnerEvidenceCaption(filename),\n\t\t\t\tcontent_hash: contentHash,\n\t\t\t\tticket_url: options.ticketUrl || existing.ticket_url,\n\t\t\t\tuploaded_to_support_ticket: true\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tconst uploaded = await options.uploadFile({\n\t\t\t\tfilename,\n\t\t\t\tfilePath,\n\t\t\t\tcontentType,\n\t\t\t\tsize: stat.size,\n\t\t\t\tcontentBuffer,\n\t\t\t\tcontentHash\n\t\t\t});\n\t\t\tconst fileId = String(uploaded?.file_id || uploaded?.id_file || uploaded?._id || '').trim();\n\t\t\tif (!fileId) {\n\t\t\t\tthrow new Error('artifact upload returned no file id');\n\t\t\t}\n\t\t\tconst persisted: ResolveIORunnerPersistedEvidenceFile = {\n\t\t\t\tfile_id: fileId,\n\t\t\t\tfilename: String(uploaded?.filename || uploaded?.name || filename).trim() || filename,\n\t\t\t\tkey: String(uploaded?.key || '').trim() || undefined,\n\t\t\t\tcontentType,\n\t\t\t\tcaption: String(attachment?.caption || '').trim() || inferResolveIORunnerEvidenceCaption(filename),\n\t\t\t\tcontent_hash: contentHash,\n\t\t\t\tticket_url: String(options.ticketUrl || '').trim() || undefined\n\t\t\t};\n\t\t\tpersistedFiles.push(persisted);\n\t\t\texistingByHash.set(contentHash, persisted);\n\t\t\tfileIds.push(fileId);\n\t\t\tnextAttachments.push({\n\t\t\t\t...attachment,\n\t\t\t\tfilename,\n\t\t\t\tfile_id: fileId,\n\t\t\t\tkey: persisted.key,\n\t\t\t\tcaption: persisted.caption,\n\t\t\t\tcontent_hash: contentHash,\n\t\t\t\tticket_url: persisted.ticket_url,\n\t\t\t\tuploaded_to_support_ticket: true\n\t\t\t});\n\t\t}\n\t\tcatch (error) {\n\t\t\tconst message = `${filename}: ${(error as Error)?.message || error}`;\n\t\t\terrors.push(message);\n\t\t\tnextAttachments.push({ ...attachment, filename, content_hash: contentHash, upload_error: message });\n\t\t}\n\t}\n\n\treturn {\n\t\tattachments: nextAttachments,\n\t\tfileIds: mergeResolveIORunnerEvidenceFileIds(fileIds),\n\t\tfiles: persistedFiles,\n\t\terrors\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/util/ai-runner-artifacts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,0FAqBC;AAED,0EASC;AAED,kFAiCC;AAED,wGAqBC;AAED,kFAiBC;AAmID,oHAyDC;AAED,sGAaC;AAED,kGA8DC;AAED,oFAgBC;AAED,0FAoHC;AAzkBD,2CAAyC;AACzC,uBAAyB;AACzB,2BAA6B;AAuE7B,SAAgB,uCAAuC,CAAC,QAAgB;IACvE,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AAE,QAAQ,UAAA,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,IAAG,CAAC;;;;;;;;;;;;;;;;yBAItG,sBAAO;wBACN,WAAW,EAAE,eAAe;wBAC5B,OAAO,EAAE,mCAAmC,CAAC,OAAO,CAAC;wBACrD,KAAK,EAAE,cAAc;wBACrB,MAAM,QAAA;qBACN,EAAC;;;;CACF","file":"ai-runner-artifacts.js","sourcesContent":["import { createHash } from 'node:crypto';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nexport interface ResolveIORunnerEvidenceAttachment {\n\tfilename: string;\n\tpath: string;\n\tcontentType?: string;\n\tcid?: string;\n\tcaption?: string;\n\tfile_id?: string;\n\tkey?: string;\n\tcontent_hash?: string;\n\tticket_url?: string;\n\tuploaded_to_support_ticket?: boolean;\n\tupload_error?: string;\n}\n\nexport interface ResolveIORunnerPersistedEvidenceFile {\n\tfile_id: string;\n\tfilename: string;\n\tkey?: string;\n\tcontentType?: string;\n\tcaption?: string;\n\tcontent_hash?: string;\n\tticket_url?: string;\n}\n\nexport interface ResolveIORunnerEvidenceUploadInput {\n\tfilename: string;\n\tfilePath: string;\n\tcontentType: string;\n\tsize: number;\n\tcontentBuffer: Buffer;\n\tcontentHash: string;\n}\n\nexport interface ResolveIORunnerEvidenceUploadResult {\n\tfile_id?: string;\n\tid_file?: string;\n\t_id?: string;\n\tkey?: string;\n\tname?: string;\n\tfilename?: string;\n}\n\nexport interface ResolveIORunnerPersistEvidenceOptions {\n\tattachments?: ResolveIORunnerEvidenceAttachment[];\n\tevidence?: any;\n\tjob?: any;\n\tticket?: any;\n\tticketUrl?: string;\n\troots?: string[];\n\tpreviousFiles?: any[];\n\texistingFileIds?: any[];\n\tmaxFiles?: number;\n\tuploadFile: any;\n}\n\nexport interface ResolveIORunnerPersistEvidenceResult {\n\tattachments: ResolveIORunnerEvidenceAttachment[];\n\tfileIds: string[];\n\tfiles: ResolveIORunnerPersistedEvidenceFile[];\n\terrors: string[];\n}\n\nexport interface ResolveIORunnerEvidenceArtifactRootScanInput {\n\troots?: string[];\n\tartifactDirNames?: string[];\n\tmaxFiles?: number;\n\tincludeJson?: boolean;\n}\n\nexport function inferResolveIORunnerEvidenceContentType(fileName: string): string {\n\tconst normalized = String(fileName || '').trim().toLowerCase();\n\tif (normalized.endsWith('.png')) {\n\t\treturn 'image/png';\n\t}\n\tif (normalized.endsWith('.jpg') || normalized.endsWith('.jpeg')) {\n\t\treturn 'image/jpeg';\n\t}\n\tif (normalized.endsWith('.webp')) {\n\t\treturn 'image/webp';\n\t}\n\tif (normalized.endsWith('.zip')) {\n\t\treturn 'application/zip';\n\t}\n\tif (normalized.endsWith('.json')) {\n\t\treturn 'application/json';\n\t}\n\tif (normalized.endsWith('.txt') || normalized.endsWith('.log')) {\n\t\treturn 'text/plain; charset=utf-8';\n\t}\n\treturn 'application/octet-stream';\n}\n\nexport function buildResolveIORunnerEvidenceCid(filePath: string): string {\n\tconst baseName = path.basename(String(filePath || '').trim()) || 'runner-artifact';\n\tconst normalized = baseName\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9._-]+/g, '-')\n\t\t.replace(/^-+|-+$/g, '')\n\t\t.slice(0, 80) || 'runner-artifact';\n\tconst digest = createHash('sha1').update(String(filePath || '')).digest('hex').slice(0, 12);\n\treturn `${normalized}-${digest}@resolveio-runner`;\n}\n\nexport function inferResolveIORunnerEvidenceCaption(fileNameOrPath: string): string {\n\tconst baseName = path.basename(String(fileNameOrPath || '').trim()).replace(/\\.[a-z0-9]+$/i, '');\n\tconst normalized = baseName\n\t\t.toLowerCase()\n\t\t.replace(/[_-]+/g, ' ')\n\t\t.replace(/\\b\\d{4,}\\b/g, '')\n\t\t.replace(/\\s+/g, ' ')\n\t\t.trim();\n\tif (!normalized) {\n\t\treturn 'QA screenshot captured during validation.';\n\t}\n\tif (/\\bbefore\\b/.test(normalized)) {\n\t\treturn 'Before: the tested page is loaded at the start of the workflow.';\n\t}\n\tif (/\\bready\\b/.test(normalized) && /\\bimport\\b/.test(normalized)) {\n\t\treturn 'Ready to import: the uploaded data was accepted and is displayed for review before submission.';\n\t}\n\tif (/\\bsubmitted\\b|\\bresult\\b|\\bafter\\b|\\bcomplete\\b|\\bsuccess\\b|\\bverified\\b/.test(normalized)) {\n\t\treturn 'After submission: the workflow completed and the result confirms the change worked.';\n\t}\n\tif (/\\bdialog\\b|\\bmodal\\b|\\bpopup\\b/.test(normalized)) {\n\t\treturn 'Dialog: the tested prompt or modal is shown in the expected state.';\n\t}\n\tif (/\\bmobile\\b/.test(normalized)) {\n\t\treturn 'Mobile view: the tested workflow is shown at the mobile viewport.';\n\t}\n\tif (/\\bdesktop\\b|\\bwide\\b/.test(normalized)) {\n\t\treturn 'Desktop view: the tested workflow is shown at a full-width desktop viewport.';\n\t}\n\treturn baseName\n\t\t.replace(/[_-]+/g, ' ')\n\t\t.replace(/\\b\\w/g, (letter) => letter.toUpperCase())\n\t\t.slice(0, 180);\n}\n\nexport function normalizeResolveIORunnerPersistedEvidenceFiles(value: any): ResolveIORunnerPersistedEvidenceFile[] {\n\tif (!Array.isArray(value)) {\n\t\treturn [];\n\t}\n\treturn value\n\t\t.map((item): ResolveIORunnerPersistedEvidenceFile | null => {\n\t\t\tconst fileId = String(item?.file_id || item?.id_file || item?._id || '').trim();\n\t\t\tif (!fileId) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tfile_id: fileId,\n\t\t\t\tfilename: String(item?.filename || item?.name || '').trim(),\n\t\t\t\tkey: String(item?.key || '').trim() || undefined,\n\t\t\t\tcontentType: String(item?.contentType || item?.content_type || '').trim() || undefined,\n\t\t\t\tcaption: String(item?.caption || '').trim() || undefined,\n\t\t\t\tcontent_hash: String(item?.content_hash || item?.hash || '').trim() || undefined,\n\t\t\t\tticket_url: String(item?.ticket_url || '').trim() || undefined\n\t\t\t};\n\t\t})\n\t\t.filter((item): item is ResolveIORunnerPersistedEvidenceFile => !!item);\n}\n\nexport function mergeResolveIORunnerEvidenceFileIds(...values: any[]): string[] {\n\tconst ids: string[] = [];\n\tconst seen = new Set<string>();\n\tconst push = (value: any) => {\n\t\tif (Array.isArray(value)) {\n\t\t\tvalue.forEach(push);\n\t\t\treturn;\n\t\t}\n\t\tconst id = String(value?.file_id || value?.id_file || value?._id || value || '').trim();\n\t\tif (!id || seen.has(id)) {\n\t\t\treturn;\n\t\t}\n\t\tseen.add(id);\n\t\tids.push(id);\n\t};\n\tvalues.forEach(push);\n\treturn ids;\n}\n\nfunction collectResolveIORunnerEvidenceText(value: any, output: string[]): void {\n\tif (value === null || value === undefined) {\n\t\treturn;\n\t}\n\tif (typeof value === 'string') {\n\t\toutput.push(value);\n\t\treturn;\n\t}\n\tif (Array.isArray(value)) {\n\t\tvalue.forEach((entry) => collectResolveIORunnerEvidenceText(entry, output));\n\t\treturn;\n\t}\n\tif (typeof value === 'object') {\n\t\tObject.values(value).forEach((entry) => collectResolveIORunnerEvidenceText(entry, output));\n\t}\n}\n\nfunction normalizeArtifactCandidatePath(value: string): string {\n\treturn String(value || '')\n\t\t.trim()\n\t\t.replace(/[),.;:'\"]+$/g, '')\n\t\t.replace(/\\\\/g, '/');\n}\n\nfunction pathExists(filePath: string): boolean {\n\ttry {\n\t\treturn !!filePath && fs.existsSync(filePath) && fs.statSync(filePath).isFile();\n\t}\n\tcatch {\n\t\treturn false;\n\t}\n}\n\nfunction resolveArtifactCandidate(candidate: string, roots: string[]): string {\n\tconst normalized = normalizeArtifactCandidatePath(candidate);\n\tif (!normalized) {\n\t\treturn '';\n\t}\n\tif (path.isAbsolute(normalized)) {\n\t\treturn pathExists(normalized) ? normalized : '';\n\t}\n\tfor (const root of roots) {\n\t\tconst normalizedRoot = String(root || '').trim();\n\t\tif (!normalizedRoot) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst resolved = path.resolve(normalizedRoot, normalized);\n\t\tif (pathExists(resolved)) {\n\t\t\treturn resolved;\n\t\t}\n\t}\n\treturn '';\n}\n\nfunction isEvidenceArtifactExtension(filePath: string, includeJson: boolean): boolean {\n\tconst ext = path.extname(String(filePath || '')).toLowerCase();\n\treturn ext === '.png'\n\t\t|| ext === '.jpg'\n\t\t|| ext === '.jpeg'\n\t\t|| ext === '.webp'\n\t\t|| ext === '.zip'\n\t\t|| (includeJson && ext === '.json');\n}\n\nfunction scoreEvidenceArtifactPath(filePath: string): number {\n\tconst baseName = path.basename(String(filePath || '')).toLowerCase();\n\tconst ext = path.extname(baseName);\n\tlet score = 0;\n\tif (['.png', '.jpg', '.jpeg', '.webp'].includes(ext)) {\n\t\tscore += 100;\n\t}\n\tif (/\\b(invoice|billing|surcharge|tax|inventory|transaction|location|chemical|item|truck|delivery|saved|submit|line|select|modal)\\b/i.test(baseName)) {\n\t\tscore += 60;\n\t}\n\tif (/\\b(coverage|assert|result|summary|matrix)\\b/i.test(baseName)) {\n\t\tscore += 20;\n\t}\n\tif (/\\b(auth|bootstrap|ready|client\\.log|server\\.log|runner|chrome)\\b/i.test(baseName)) {\n\t\tscore -= 120;\n\t}\n\treturn score;\n}\n\nfunction collectEvidenceArtifactFilesFromDirectory(\n\tdirPath: string,\n\tincludeJson: boolean,\n\toutput: Array<{ filePath: string; score: number; mtimeMs: number }>,\n\tseen: Set<string>,\n\tdepth = 0\n): void {\n\tif (depth > 2) {\n\t\treturn;\n\t}\n\tlet entries: string[] = [];\n\ttry {\n\t\tentries = fs.readdirSync(dirPath);\n\t}\n\tcatch {\n\t\treturn;\n\t}\n\tfor (const entry of entries) {\n\t\tconst candidate = path.join(dirPath, entry);\n\t\tlet stat: fs.Stats;\n\t\ttry {\n\t\t\tstat = fs.statSync(candidate);\n\t\t}\n\t\tcatch {\n\t\t\tcontinue;\n\t\t}\n\t\tif (stat.isDirectory()) {\n\t\t\tcollectEvidenceArtifactFilesFromDirectory(candidate, includeJson, output, seen, depth + 1);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!stat.isFile() || stat.size <= 0 || !isEvidenceArtifactExtension(candidate, includeJson)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst resolved = path.resolve(candidate);\n\t\tif (seen.has(resolved)) {\n\t\t\tcontinue;\n\t\t}\n\t\tseen.add(resolved);\n\t\toutput.push({\n\t\t\tfilePath: resolved,\n\t\t\tscore: scoreEvidenceArtifactPath(resolved),\n\t\t\tmtimeMs: Number(stat.mtimeMs || 0)\n\t\t});\n\t}\n}\n\nexport function collectResolveIORunnerEvidenceArtifactFilesFromRoots(\n\tinput: ResolveIORunnerEvidenceArtifactRootScanInput = {}\n): string[] {\n\tconst maxFiles = Math.max(1, Number(input.maxFiles || 12));\n\tconst includeJson = input.includeJson !== false;\n\tconst artifactDirNames = (input.artifactDirNames?.length ? input.artifactDirNames : ['qa-artifacts'])\n\t\t.map((entry) => String(entry || '').trim())\n\t\t.filter(Boolean);\n\tconst roots = Array.from(new Set((input.roots || [])\n\t\t.map((entry) => String(entry || '').trim())\n\t\t.filter(Boolean)\n\t\t.map((entry) => path.resolve(entry))));\n\tconst artifactDirs = new Set<string>();\n\tfor (const root of roots) {\n\t\tlet stat: fs.Stats | null = null;\n\t\ttry {\n\t\t\tstat = fs.statSync(root);\n\t\t}\n\t\tcatch {\n\t\t\tstat = null;\n\t\t}\n\t\tif (!stat?.isDirectory()) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst rootBaseName = path.basename(root);\n\t\tif (artifactDirNames.includes(rootBaseName)) {\n\t\t\tartifactDirs.add(root);\n\t\t}\n\t\tfor (const artifactDirName of artifactDirNames) {\n\t\t\tconst directArtifactDir = path.join(root, artifactDirName);\n\t\t\ttry {\n\t\t\t\tif (fs.statSync(directArtifactDir).isDirectory()) {\n\t\t\t\t\tartifactDirs.add(directArtifactDir);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch {\n\t\t\t\t// Ignore missing artifact directories.\n\t\t\t}\n\t\t}\n\t}\n\tconst seen = new Set<string>();\n\tconst files: Array<{ filePath: string; score: number; mtimeMs: number }> = [];\n\tfor (const artifactDir of artifactDirs) {\n\t\tcollectEvidenceArtifactFilesFromDirectory(artifactDir, includeJson, files, seen);\n\t}\n\treturn files\n\t\t.sort((left, right) => {\n\t\t\tif (right.score !== left.score) {\n\t\t\t\treturn right.score - left.score;\n\t\t\t}\n\t\t\tif (left.mtimeMs !== right.mtimeMs) {\n\t\t\t\treturn left.mtimeMs - right.mtimeMs;\n\t\t\t}\n\t\t\treturn left.filePath.localeCompare(right.filePath);\n\t\t})\n\t\t.slice(0, maxFiles)\n\t\t.map((entry) => entry.filePath);\n}\n\nexport function toResolveIORunnerEvidenceAttachmentsFromRoots(\n\tinput: ResolveIORunnerEvidenceArtifactRootScanInput = {}\n): ResolveIORunnerEvidenceAttachment[] {\n\treturn collectResolveIORunnerEvidenceArtifactFilesFromRoots(input).map((filePath) => {\n\t\tconst filename = path.basename(filePath);\n\t\treturn {\n\t\t\tfilename,\n\t\t\tpath: filePath,\n\t\t\tcontentType: inferResolveIORunnerEvidenceContentType(filename),\n\t\t\tcid: buildResolveIORunnerEvidenceCid(filePath),\n\t\t\tcaption: inferResolveIORunnerEvidenceCaption(filename)\n\t\t};\n\t});\n}\n\nexport function collectResolveIORunnerEvidenceArtifactPaths(input: {\n\tevidence?: any;\n\tjob?: any;\n\troots?: string[];\n\tmaxFiles?: number;\n} = {}): string[] {\n\tconst values: string[] = [];\n\tcollectResolveIORunnerEvidenceText(input.evidence, values);\n\tconst job = input.job || {};\n\tcollectResolveIORunnerEvidenceText(job.responseSummary, values);\n\tcollectResolveIORunnerEvidenceText(job.lastVerificationSummary, values);\n\tcollectResolveIORunnerEvidenceText(job.lastRerunReason, values);\n\tcollectResolveIORunnerEvidenceText(job.artifacts?.agentNotes, values);\n\tcollectResolveIORunnerEvidenceText(job.artifacts?.supportArtifacts, values);\n\tcollectResolveIORunnerEvidenceText(job.artifacts?.qaArtifacts, values);\n\tcollectResolveIORunnerEvidenceText(job.artifacts?.qa_artifacts, values);\n\tcollectResolveIORunnerEvidenceText(job.qa_artifacts, values);\n\tcollectResolveIORunnerEvidenceText(job.supportQaArtifacts, values);\n\tcollectResolveIORunnerEvidenceText(job.runnerEvidenceArtifacts, values);\n\tif (Array.isArray(job.tasks)) {\n\t\tfor (const task of job.tasks) {\n\t\t\tcollectResolveIORunnerEvidenceText(task?.title, values);\n\t\t\tcollectResolveIORunnerEvidenceText(task?.notes, values);\n\t\t\tcollectResolveIORunnerEvidenceText(task?.artifacts, values);\n\t\t\tcollectResolveIORunnerEvidenceText(task?.evidence, values);\n\t\t}\n\t}\n\tif (Array.isArray(job.log)) {\n\t\tcollectResolveIORunnerEvidenceText(job.log.slice(-160), values);\n\t}\n\n\tconst roots = Array.from(new Set([\n\t\t...(input.roots || []),\n\t\tjob.workspacePath,\n\t\tjob.projectRoot && job.workspacePath ? path.join(job.workspacePath, job.projectRoot) : '',\n\t\tjob.projectDisplayPath && job.workspacePath ? path.join(job.workspacePath, job.projectDisplayPath) : '',\n\t\tjob.localPath\n\t].map((entry) => String(entry || '').trim()).filter(Boolean)));\n\tconst candidates: string[] = [];\n\tfor (const value of values) {\n\t\tconst text = String(value || '');\n\t\tfor (const match of text.matchAll(/((?:\\/tmp\\/|\\/var\\/|\\/Users\\/)[^\\s)'\"]+?\\.(?:png|jpe?g|webp|zip|json|txt|log))/gi)) {\n\t\t\tcandidates.push(match[1]);\n\t\t}\n\t\tfor (const match of text.matchAll(/(?:^|[\\s(\"'`])((?:(?:[\\w.-]+\\/)*qa-artifacts|qa-artifacts|test-results|playwright-report|\\.build-output)\\/[^\\s)'\"]+?\\.(?:png|jpe?g|webp|zip|json|txt|log))/gim)) {\n\t\t\tcandidates.push(match[1]);\n\t\t}\n\t}\n\tconst resolved: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const candidate of candidates) {\n\t\tconst filePath = resolveArtifactCandidate(candidate, roots);\n\t\tif (!filePath || seen.has(filePath)) {\n\t\t\tcontinue;\n\t\t}\n\t\tseen.add(filePath);\n\t\tresolved.push(filePath);\n\t\tif (resolved.length >= (input.maxFiles || 8)) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn resolved;\n}\n\nexport function toResolveIORunnerEvidenceAttachments(input: {\n\tevidence?: any;\n\tjob?: any;\n\troots?: string[];\n\tmaxFiles?: number;\n} = {}): ResolveIORunnerEvidenceAttachment[] {\n\treturn collectResolveIORunnerEvidenceArtifactPaths(input).map((filePath) => {\n\t\tconst filename = path.basename(filePath);\n\t\treturn {\n\t\t\tfilename,\n\t\t\tpath: filePath,\n\t\t\tcontentType: inferResolveIORunnerEvidenceContentType(filename),\n\t\t\tcid: buildResolveIORunnerEvidenceCid(filePath),\n\t\t\tcaption: inferResolveIORunnerEvidenceCaption(filename)\n\t\t};\n\t});\n}\n\nexport async function persistResolveIORunnerEvidenceArtifacts(\n\toptions: ResolveIORunnerPersistEvidenceOptions\n): Promise<ResolveIORunnerPersistEvidenceResult> {\n\tconst maxFiles = Math.max(1, options.maxFiles || 8);\n\tconst previousFiles = normalizeResolveIORunnerPersistedEvidenceFiles(options.previousFiles);\n\tconst existingByHash = new Map<string, ResolveIORunnerPersistedEvidenceFile>();\n\tfor (const file of previousFiles) {\n\t\tif (file.content_hash) {\n\t\t\texistingByHash.set(file.content_hash, file);\n\t\t}\n\t}\n\tconst attachments = [\n\t\t...(options.attachments || []),\n\t\t...toResolveIORunnerEvidenceAttachments({\n\t\t\tevidence: options.evidence,\n\t\t\tjob: options.job,\n\t\t\troots: options.roots,\n\t\t\tmaxFiles\n\t\t})\n\t];\n\tconst persistedFiles = [...previousFiles];\n\tconst fileIds = mergeResolveIORunnerEvidenceFileIds(options.existingFileIds, previousFiles.map((file) => file.file_id));\n\tconst errors: string[] = [];\n\tconst nextAttachments: ResolveIORunnerEvidenceAttachment[] = [];\n\tconst seenPaths = new Set<string>();\n\n\tfor (const attachment of attachments) {\n\t\tif (nextAttachments.length >= maxFiles) {\n\t\t\tbreak;\n\t\t}\n\t\tconst filePath = String(attachment?.path || '').trim();\n\t\tif (!filePath || seenPaths.has(filePath)) {\n\t\t\tcontinue;\n\t\t}\n\t\tseenPaths.add(filePath);\n\t\tconst filename = String(attachment?.filename || path.basename(filePath) || 'runner-qa-artifact.png').trim();\n\t\tconst contentType = String(attachment?.contentType || inferResolveIORunnerEvidenceContentType(filename)).trim();\n\t\tif (!pathExists(filePath)) {\n\t\t\tconst error = `${filename}: evidence file was not found before S3 upload.`;\n\t\t\terrors.push(error);\n\t\t\tnextAttachments.push({ ...attachment, filename, upload_error: error });\n\t\t\tcontinue;\n\t\t}\n\t\tconst stat = await fs.promises.stat(filePath);\n\t\tif (!stat.isFile() || stat.size <= 0) {\n\t\t\tconst error = `${filename}: evidence file was empty before S3 upload.`;\n\t\t\terrors.push(error);\n\t\t\tnextAttachments.push({ ...attachment, filename, upload_error: error });\n\t\t\tcontinue;\n\t\t}\n\t\tconst contentBuffer = await fs.promises.readFile(filePath);\n\t\tconst contentHash = createHash('sha1').update(new Uint8Array(contentBuffer)).digest('hex');\n\t\tconst existing = existingByHash.get(contentHash);\n\t\tif (existing) {\n\t\t\tfileIds.push(existing.file_id);\n\t\t\tnextAttachments.push({\n\t\t\t\t...attachment,\n\t\t\t\tfilename,\n\t\t\t\tfile_id: existing.file_id,\n\t\t\t\tkey: existing.key,\n\t\t\t\tcaption: attachment.caption || existing.caption || inferResolveIORunnerEvidenceCaption(filename),\n\t\t\t\tcontent_hash: contentHash,\n\t\t\t\tticket_url: options.ticketUrl || existing.ticket_url,\n\t\t\t\tuploaded_to_support_ticket: true\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tconst uploaded = await options.uploadFile({\n\t\t\t\tfilename,\n\t\t\t\tfilePath,\n\t\t\t\tcontentType,\n\t\t\t\tsize: stat.size,\n\t\t\t\tcontentBuffer,\n\t\t\t\tcontentHash\n\t\t\t});\n\t\t\tconst fileId = String(uploaded?.file_id || uploaded?.id_file || uploaded?._id || '').trim();\n\t\t\tif (!fileId) {\n\t\t\t\tthrow new Error('artifact upload returned no file id');\n\t\t\t}\n\t\t\tconst persisted: ResolveIORunnerPersistedEvidenceFile = {\n\t\t\t\tfile_id: fileId,\n\t\t\t\tfilename: String(uploaded?.filename || uploaded?.name || filename).trim() || filename,\n\t\t\t\tkey: String(uploaded?.key || '').trim() || undefined,\n\t\t\t\tcontentType,\n\t\t\t\tcaption: String(attachment?.caption || '').trim() || inferResolveIORunnerEvidenceCaption(filename),\n\t\t\t\tcontent_hash: contentHash,\n\t\t\t\tticket_url: String(options.ticketUrl || '').trim() || undefined\n\t\t\t};\n\t\t\tpersistedFiles.push(persisted);\n\t\t\texistingByHash.set(contentHash, persisted);\n\t\t\tfileIds.push(fileId);\n\t\t\tnextAttachments.push({\n\t\t\t\t...attachment,\n\t\t\t\tfilename,\n\t\t\t\tfile_id: fileId,\n\t\t\t\tkey: persisted.key,\n\t\t\t\tcaption: persisted.caption,\n\t\t\t\tcontent_hash: contentHash,\n\t\t\t\tticket_url: persisted.ticket_url,\n\t\t\t\tuploaded_to_support_ticket: true\n\t\t\t});\n\t\t}\n\t\tcatch (error) {\n\t\t\tconst message = `${filename}: ${(error as Error)?.message || error}`;\n\t\t\terrors.push(message);\n\t\t\tnextAttachments.push({ ...attachment, filename, content_hash: contentHash, upload_error: message });\n\t\t}\n\t}\n\n\treturn {\n\t\tattachments: nextAttachments,\n\t\tfileIds: mergeResolveIORunnerEvidenceFileIds(fileIds),\n\t\tfiles: persistedFiles,\n\t\terrors\n\t};\n}\n"]}
|
|
@@ -97,7 +97,8 @@ function buildResolveIORunnerQaAuthBootstrapScript(options) {
|
|
|
97
97
|
' secondary_font_color: "#ffffff",',
|
|
98
98
|
' secondary_hover_color: "#5a6268",',
|
|
99
99
|
' routing_preference: "",',
|
|
100
|
-
' opening_route: targetRoute',
|
|
100
|
+
' opening_route: targetRoute,',
|
|
101
|
+
' rio_select_search_mode: "exact"',
|
|
101
102
|
' };',
|
|
102
103
|
'}',
|
|
103
104
|
'',
|
|
@@ -136,7 +137,7 @@ function buildResolveIORunnerQaAuthBootstrapScript(options) {
|
|
|
136
137
|
' const hash = crypto.pbkdf2Sync(password, salt, 25000, 512, "sha256").toString("hex");',
|
|
137
138
|
' const existing = await users.findOne({ $or: [{ username }, { email: username }] }, { projection: { _id: 1 } });',
|
|
138
139
|
' const defaultSettings = buildDefaultQaUserSettings();',
|
|
139
|
-
' const defaultOther = { yards: [], tour_completed: true, took_tour: true, core_tour_completed: true, welcome_tour_completed: true, top_navigation_tour_completed: true, user_settings_tour_completed: true, tour_completed_at: now.toISOString() };',
|
|
140
|
+
' const defaultOther = { yards: [], date_picker_day_start: "S", tour_completed: true, took_tour: true, core_tour_completed: true, welcome_tour_completed: true, top_navigation_tour_completed: true, user_settings_tour_completed: true, tour_completed_at: now.toISOString() };',
|
|
140
141
|
' const baseUser = {',
|
|
141
142
|
' __v: 0,',
|
|
142
143
|
' username,',
|
|
@@ -184,6 +185,23 @@ function buildResolveIORunnerQaAuthBootstrapScript(options) {
|
|
|
184
185
|
' else {',
|
|
185
186
|
' await users.insertOne({ _id: crypto.randomBytes(12).toString("hex"), createdAt: now, ...baseUser });',
|
|
186
187
|
' }',
|
|
188
|
+
' const repaired = await users.findOne(qaUserFilter, { projection: { _id: 1 } });',
|
|
189
|
+
' if (repaired && repaired._id) {',
|
|
190
|
+
' await users.updateOne({ _id: repaired._id }, {',
|
|
191
|
+
' $set: {',
|
|
192
|
+
' active: true,',
|
|
193
|
+
' roles: baseUser.roles,',
|
|
194
|
+
' other: defaultOther,',
|
|
195
|
+
' settings: defaultSettings,',
|
|
196
|
+
' hash,',
|
|
197
|
+
' salt,',
|
|
198
|
+
' attempts: 0,',
|
|
199
|
+
' readonly: false,',
|
|
200
|
+
' is_customer: false,',
|
|
201
|
+
' updatedAt: now',
|
|
202
|
+
' }',
|
|
203
|
+
' });',
|
|
204
|
+
' }',
|
|
187
205
|
' return true;',
|
|
188
206
|
' }',
|
|
189
207
|
' finally {',
|
|
@@ -400,7 +418,8 @@ function buildResolveIORunnerQaAuthBootstrapScript(options) {
|
|
|
400
418
|
' secondary_font_color: "#ffffff",',
|
|
401
419
|
' secondary_hover_color: "#5a6268",',
|
|
402
420
|
' routing_preference: "",',
|
|
403
|
-
' opening_route: nextRoute',
|
|
421
|
+
' opening_route: nextRoute,',
|
|
422
|
+
' rio_select_search_mode: "exact"',
|
|
404
423
|
' };',
|
|
405
424
|
' user = {',
|
|
406
425
|
' ...user,',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/ai-runner-qa-auth.ts"],"names":[],"mappings":";;AAKA,8FAmpBC;AAnpBD,SAAgB,yCAAyC,CAAC,OAAyD;IAAzD,wBAAA,EAAA,YAAyD;IAClH,IAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC;IAC3D,IAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC;IACtD,OAAO;QACN,qBAAqB;QACrB,eAAe;QACf,EAAE;QACF,2BAA2B;QAC3B,mCAAmC;QACnC,+BAA+B;QAC/B,iCAAiC;QACjC,+BAA+B;QAC/B,EAAE;QACF,qEAAqE;QACrE,wLAAwL;QACxL,2EAA2E;QAC3E,kNAAkN;QAClN,6JAA6J;QAC7J,oHAA6G,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,MAAG;QAC/I,oHAA6G,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,MAAG;QAC/I,4KAA4K;QAC5K,0IAA0I;QAC1I,6IAA6I;QAC7I,qMAAqM;QACrM,0EAA0E;QAC1E,iFAAiF;QACjF,oFAAoF;QACpF,EAAE;QACF,sCAAsC;QACtC,mDAAmD;QACnD,GAAG;QACH,EAAE;QACF,kCAAkC;QAClC,QAAQ;QACR,kCAAkC;QAClC,uEAAuE;QACvE,IAAI;QACJ,kBAAkB;QAClB,iBAAiB;QACjB,IAAI;QACJ,GAAG;QACH,EAAE;QACF,mCAAmC;QACnC,qOAAqO;QACrO,mCAAmC;QACnC,2BAA2B;QAC3B,IAAI;QACJ,mDAAm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AwB;QACxB,2BAA2B;QAC3B,kCAAkC;QAClC,6DAA6D;QAC7D,2DAA2D;QAC3D,6CAA6C;QAC7C,mEAAmE;QACnE,kHAAkH;QAClH,6CAA6C;QAC7C,uDAAuD;QACvD,MAAM;QACN,MAAM;QACN,GAAG;QACH,EAAE;QACF,gBAAgB;QAChB,kDAAkD;QAClD,wCAAwC;QACxC,kDAAkD;QAClD,YAAY;QACZ,QAAQ;QACR,mDAAmD;QACnD,mDAAmD;QACnD,mCAAmC;QACnC,6EAA6E;QAC7E,iCAAiC;QACjC,6BAA6B;QAC7B,4EAA4E;QAC5E,yDAAyD;QACzD,MAAM;QACN,OAAO;QACP,+EAA+E;QAC/E,6CAA6C;QAC7C,kCAAkC;QAClC,+BAA+B;QAC/B,+BAA+B;QAC/B,wCAAwC;QACxC,8CAA8C;QAC9C,gDAAgD;QAChD,yEAAyE;QACzE,qBAAqB;QACrB,oBAAoB;QACpB,eAAe;QACf,eAAe;QACf,iBAAiB;QACjB,qCAAqC;QACrC,qIAAqI;QACrI,oBAAoB;QACpB,MAAM;QACN,yBAAyB;QACzB,kDAAkD;QAClD,IAAI;QACJ,kBAAkB;QAClB,yJAAyJ;QACzJ,SAAS;QACT,gBAAgB;QAChB,6EAA6E;QAC7E,6CAA6C;QAC7C,MAAM;QACN,+BAA+B;QAC/B,mGAAmG;QACnG,KAAK;QACL,yBAAyB;QACzB,oDAAoD;QACpD,yBAAyB;QACzB,IAAI;QACJ,YAAY;QACZ,yDAAyD;QACzD,kDAAkD;QAClD,KAAK;QACL,wCAAwC;QACxC,IAAI;QACJ,OAAO;QACP,EAAE;KACF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC","file":"ai-runner-qa-auth.js","sourcesContent":["export interface ResolveIORunnerQaAuthBootstrapScriptOptions {\n\tdefaultUsername?: string;\n\tdefaultPassword?: string;\n}\n\nexport function buildResolveIORunnerQaAuthBootstrapScript(options: ResolveIORunnerQaAuthBootstrapScriptOptions = {}): string {\n\tconst defaultUsername = options.defaultUsername || 'admin';\n\tconst defaultPassword = options.defaultPassword || '';\n\treturn [\n\t\t'#!/usr/bin/env node',\n\t\t\"'use strict';\",\n\t\t'',\n\t\t'const fs = require(\"fs\");',\n\t\t'const crypto = require(\"crypto\");',\n\t\t'const http = require(\"http\");',\n\t\t'const https = require(\"https\");',\n\t\t'const path = require(\"path\");',\n\t\t'',\n\t\t'const projectRoot = path.resolve(process.argv[2] || process.cwd());',\n\t\t'const routeArg = process.argv[3] || process.env.RESOLVEIO_RUNNER_QA_TARGET_ROUTE || process.env.RESOLVEIO_SUPPORT_QA_TARGET_ROUTE || process.env.RESOLVEIO_SUPPORT_QA_LAST_URL || \"/\";',\n\t\t'const targetRoute = routeArg.startsWith(\"/\") ? routeArg : `/${routeArg}`;',\n\t\t'const clientUrl = stripTrailingSlash(process.env.RESOLVEIO_RUNNER_QA_CLIENT_URL || process.env.RESOLVEIO_SUPPORT_QA_CLIENT_URL || `http://localhost:${process.env.RESOLVEIO_SUPPORT_QA_CLIENT_PORT || \"4200\"}`);',\n\t\t'const serverUrl = stripTrailingSlash(process.env.RESOLVEIO_RUNNER_QA_SERVER_URL || process.env.RESOLVEIO_SUPPORT_QA_SERVER_URL || \"http://localhost:8080\");',\n\t\t`const username = process.env.RESOLVEIO_RUNNER_QA_USERNAME || process.env.RESOLVEIO_SUPPORT_QA_USERNAME || ${JSON.stringify(defaultUsername)};`,\n\t\t`const password = process.env.RESOLVEIO_RUNNER_QA_PASSWORD || process.env.RESOLVEIO_SUPPORT_QA_PASSWORD || ${JSON.stringify(defaultPassword)};`,\n\t\t'const artifactDir = path.resolve(process.env.RESOLVEIO_RUNNER_QA_ARTIFACT_DIR || process.env.RESOLVEIO_SUPPORT_QA_ARTIFACT_DIR || path.join(projectRoot, \"qa-artifacts\"));',\n\t\t'const viewportWidth = Number(process.env.RESOLVEIO_RUNNER_QA_VIEWPORT_WIDTH || process.env.RESOLVEIO_SUPPORT_QA_VIEWPORT_WIDTH || 1920);',\n\t\t'const viewportHeight = Number(process.env.RESOLVEIO_RUNNER_QA_VIEWPORT_HEIGHT || process.env.RESOLVEIO_SUPPORT_QA_VIEWPORT_HEIGHT || 1080);',\n\t\t'const startupTimeoutMs = Math.max(1000, Number(process.env.RESOLVEIO_RUNNER_QA_ANGULAR_STARTUP_TIMEOUT_SECONDS || process.env.RESOLVEIO_SUPPORT_QA_ANGULAR_STARTUP_TIMEOUT_SECONDS || 900) * 1000);',\n\t\t'const resultPath = path.join(artifactDir, \"auth-bootstrap-result.json\");',\n\t\t'const readyScreenshotPath = path.join(artifactDir, \"auth-bootstrap-ready.png\");',\n\t\t'const failureScreenshotPath = path.join(artifactDir, \"auth-bootstrap-failed.png\");',\n\t\t'',\n\t\t'function stripTrailingSlash(value) {',\n\t\t'\treturn String(value || \"\").replace(/\\\\/+$/, \"\");',\n\t\t'}',\n\t\t'',\n\t\t'function isLocalhostUrl(value) {',\n\t\t'\ttry {',\n\t\t'\t\tconst parsed = new URL(value);',\n\t\t'\t\treturn [\"localhost\", \"127.0.0.1\", \"::1\"].includes(parsed.hostname);',\n\t\t'\t}',\n\t\t'\tcatch (error) {',\n\t\t'\t\treturn false;',\n\t\t'\t}',\n\t\t'}',\n\t\t'',\n\t\t'function resolveLocalMongoUrl() {',\n\t\t'\tconst localQaMongoUrl = process.env.RESOLVEIO_RUNNER_QA_MONGO_URL || process.env.RESOLVEIO_SUPPORT_QA_MONGO_URL || `mongodb://127.0.0.1:${process.env.RESOLVEIO_SUPPORT_QA_MONGO_PORT || \"3001\"}/resolveio?directConnection=true`;',\n\t\t'\tif (isLocalhostUrl(serverUrl)) {',\n\t\t'\t\treturn localQaMongoUrl;',\n\t\t'\t}',\n\t\t'\treturn process.env.MONGO_URL || localQaMongoUrl;',\n\t\t'}',\n\t\t'',\n\t\t'function requireMongoClient() {',\n\t\t'\tconst candidates = [',\n\t\t'\t\tpath.join(projectRoot, \"server\", \"node_modules\", \"mongodb\"),',\n\t\t'\t\tpath.join(projectRoot, \"node_modules\", \"mongodb\"),',\n\t\t'\t\tpath.join(process.cwd(), \"server\", \"node_modules\", \"mongodb\"),',\n\t\t'\t\tpath.join(process.cwd(), \"node_modules\", \"mongodb\"),',\n\t\t'\t\t\"mongodb\"',\n\t\t'\t];',\n\t\t'\tfor (const candidate of candidates) {',\n\t\t'\t\ttry { return require(candidate).MongoClient; }',\n\t\t'\t\tcatch (error) {}',\n\t\t'\t}',\n\t\t'\tthrow new Error(\"Unable to require mongodb from project/server node_modules or global resolution\");',\n\t\t'}',\n\t\t'',\n\t\t'function buildDefaultQaUserSettings() {',\n\t\t'\treturn {',\n\t\t'\t\ttable_color: \"#3b3ee3\",',\n\t\t'\t\ttable_font_color: \"#ffffff\",',\n\t\t'\t\tsecondary_table_color: \"#87ceeb\",',\n\t\t'\t\tsecondary_table_font_color: \"#000000\",',\n\t\t'\t\ttertiary_table_color: \"#ff4500\",',\n\t\t'\t\ttertiary_table_font_color: \"#000000\",',\n\t\t'\t\tfont_size: 12,',\n\t\t'\t\tcollapsable_menu: true,',\n\t\t'\t\tentries_per_page: \"25\",',\n\t\t'\t\twarning_color: \"#ffc107\",',\n\t\t'\t\twarning_font_color: \"#000000\",',\n\t\t'\t\twarning_hover_color: \"#e0a800\",',\n\t\t'\t\tsuccess_color: \"#28a745\",',\n\t\t'\t\tsuccess_font_color: \"#ffffff\",',\n\t\t'\t\tsuccess_hover_color: \"#218838\",',\n\t\t'\t\tdanger_color: \"#dc3545\",',\n\t\t'\t\tdanger_font_color: \"#ffffff\",',\n\t\t'\t\tdanger_hover_color: \"#c82333\",',\n\t\t'\t\tinfo_color: \"#17a2b8\",',\n\t\t'\t\tinfo_font_color: \"#ffffff\",',\n\t\t'\t\tinfo_hover_color: \"#138496\",',\n\t\t'\t\tprimary_color: \"#007bff\",',\n\t\t'\t\tprimary_font_color: \"#ffffff\",',\n\t\t'\t\tprimary_hover_color: \"#0069d9\",',\n\t\t'\t\tsecondary_color: \"#868e96\",',\n\t\t'\t\tsecondary_font_color: \"#ffffff\",',\n\t\t'\t\tsecondary_hover_color: \"#5a6268\",',\n\t\t'\t\trouting_preference: \"\",',\n\t\t'\t\topening_route: targetRoute',\n\t\t'\t};',\n\t\t'}',\n\t\t'',\n\t\t'function normalizeQaUserForBrowser(user) {',\n\t\t'\tconst normalized = { ...(user || {}) };',\n\t\t'\tnormalized.other = {',\n\t\t'\t\t...(normalized.other || {}),',\n\t\t'\t\tyards: Array.isArray(normalized.other && normalized.other.yards) ? normalized.other.yards : [],',\n\t\t'\t\ttour_completed: true,',\n\t\t'\t\ttook_tour: true,',\n\t\t'\t\tcore_tour_completed: true,',\n\t\t'\t\twelcome_tour_completed: true,',\n\t\t'\t\ttop_navigation_tour_completed: true,',\n\t\t'\t\tuser_settings_tour_completed: true',\n\t\t'\t};',\n\t\t'\tnormalized.settings = {',\n\t\t'\t\t...buildDefaultQaUserSettings(),',\n\t\t'\t\t...(normalized.settings || {}),',\n\t\t'\t\topening_route: targetRoute',\n\t\t'\t};',\n\t\t'\treturn normalized;',\n\t\t'}',\n\t\t'',\n\t\t'async function ensureLocalQaUser() {',\n\t\t'\tif (!isLocalhostUrl(serverUrl) || process.env.RESOLVEIO_RUNNER_QA_DISABLE_LOCAL_USER_REPAIR === \"true\" || process.env.RESOLVEIO_SUPPORT_QA_DISABLE_LOCAL_USER_REPAIR === \"true\") {',\n\t\t'\t\treturn false;',\n\t\t'\t}',\n\t\t'\tconst MongoClient = requireMongoClient();',\n\t\t'\tconst client = new MongoClient(resolveLocalMongoUrl());',\n\t\t'\tawait client.connect();',\n\t\t'\ttry {',\n\t\t'\t\tconst db = client.db();',\n\t\t'\t\tconst users = db.collection(\"users\");',\n\t\t'\t\tconst now = new Date();',\n\t\t'\t\tconst salt = crypto.randomBytes(32).toString(\"hex\");',\n\t\t'\t\tconst hash = crypto.pbkdf2Sync(password, salt, 25000, 512, \"sha256\").toString(\"hex\");',\n\t\t'\t\tconst existing = await users.findOne({ $or: [{ username }, { email: username }] }, { projection: { _id: 1 } });',\n\t\t'\t\tconst defaultSettings = buildDefaultQaUserSettings();',\n\t\t'\t\tconst defaultOther = { yards: [], tour_completed: true, took_tour: true, core_tour_completed: true, welcome_tour_completed: true, top_navigation_tour_completed: true, user_settings_tour_completed: true, tour_completed_at: now.toISOString() };',\n\t\t'\t\tconst baseUser = {',\n\t\t'\t\t\t__v: 0,',\n\t\t'\t\t\tusername,',\n\t\t'\t\t\temail: username.includes(\"@\") ? username : \"dev@resolveio.com\",',\n\t\t'\t\t\tfullname: \"QA Admin\",',\n\t\t'\t\t\troles: { super_admin: true, approvals: [], groups: [], notifications: [], miscs: [] },',\n\t\t'\t\t\tactive: true,',\n\t\t'\t\t\tother: defaultOther,',\n\t\t'\t\t\tsettings: defaultSettings,',\n\t\t'\t\t\tphonenumber: \"\",',\n\t\t'\t\t\treadonly: false,',\n\t\t'\t\t\tis_customer: false,',\n\t\t'\t\t\thash,',\n\t\t'\t\t\tsalt,',\n\t\t'\t\t\tattempts: 0,',\n\t\t'\t\t\tservices: {},',\n\t\t'\t\t\tupdatedAt: now',\n\t\t'\t\t};',\n\t\t'\t\tconst qaUserFilter = {',\n\t\t'\t\t\t$or: [',\n\t\t'\t\t\t\t{ username },',\n\t\t'\t\t\t\t{ email: username },',\n\t\t'\t\t\t\t{ username: \"admin\" },',\n\t\t'\t\t\t\t{ email: \"admin\" },',\n\t\t'\t\t\t\t{ email: \"dev@resolveio.com\" }',\n\t\t'\t\t\t]',\n\t\t'\t\t};',\n\t\t'\t\tawait users.updateMany(qaUserFilter, {',\n\t\t'\t\t\t$set: {',\n\t\t'\t\t\t\tactive: true,',\n\t\t'\t\t\t\troles: baseUser.roles,',\n\t\t'\t\t\t\tother: defaultOther,',\n\t\t'\t\t\t\tsettings: defaultSettings,',\n\t\t'\t\t\t\thash,',\n\t\t'\t\t\t\tsalt,',\n\t\t'\t\t\t\tattempts: 0,',\n\t\t'\t\t\t\treadonly: false,',\n\t\t'\t\t\t\tis_customer: false,',\n\t\t'\t\t\t\tupdatedAt: now',\n\t\t'\t\t\t}',\n\t\t'\t\t});',\n\t\t'\t\tif (existing && existing._id) {',\n\t\t'\t\t\tawait users.updateOne({ _id: existing._id }, { $set: baseUser });',\n\t\t'\t\t}',\n\t\t'\t\telse {',\n\t\t'\t\t\tawait users.insertOne({ _id: crypto.randomBytes(12).toString(\"hex\"), createdAt: now, ...baseUser });',\n\t\t'\t\t}',\n\t\t'\t\treturn true;',\n\t\t'\t}',\n\t\t'\tfinally {',\n\t\t'\t\tawait client.close().catch(() => undefined);',\n\t\t'\t}',\n\t\t'}',\n\t\t'',\n\t\t'async function refreshAuthAndSeed(page) {',\n\t\t'\tconst auth = await login();',\n\t\t'\tawait seedAuth(page, auth);',\n\t\t'\treturn auth;',\n\t\t'}',\n\t\t'',\n\t\t'function writeResult(payload) {',\n\t\t'\tfs.mkdirSync(artifactDir, { recursive: true });',\n\t\t'\tfs.writeFileSync(resultPath, JSON.stringify(payload, null, 2));',\n\t\t'}',\n\t\t'',\n\t\t'function requestJson(url, payload) {',\n\t\t'\treturn new Promise((resolve, reject) => {',\n\t\t'\t\tconst body = JSON.stringify(payload || {});',\n\t\t'\t\tconst parsed = new URL(url);',\n\t\t'\t\tconst mod = parsed.protocol === \"https:\" ? https : http;',\n\t\t'\t\tconst req = mod.request(parsed, {',\n\t\t'\t\t\tmethod: \"POST\",',\n\t\t'\t\t\ttimeout: 20000,',\n\t\t'\t\t\theaders: {',\n\t\t'\t\t\t\t\"content-type\": \"application/json\",',\n\t\t'\t\t\t\t\"content-length\": Buffer.byteLength(body),',\n\t\t'\t\t\t\t\"origin\": clientUrl',\n\t\t'\t\t\t}',\n\t\t'\t\t}, (res) => {',\n\t\t'\t\t\tlet raw = \"\";',\n\t\t'\t\t\tres.setEncoding(\"utf8\");',\n\t\t'\t\t\tres.on(\"data\", (chunk) => { raw += chunk; });',\n\t\t'\t\t\tres.on(\"end\", () => {',\n\t\t'\t\t\t\tlet json = null;',\n\t\t'\t\t\t\ttry { json = raw ? JSON.parse(raw) : {}; }',\n\t\t'\t\t\t\tcatch (error) {',\n\t\t'\t\t\t\t\treject(new Error(`${url} returned non-JSON HTTP ${res.statusCode}: ${raw.slice(0, 300)}`));',\n\t\t'\t\t\t\t\treturn;',\n\t\t'\t\t\t\t}',\n\t\t'\t\t\t\tif (!res.statusCode || res.statusCode >= 400) {',\n\t\t'\t\t\t\t\treject(new Error(`${url} returned HTTP ${res.statusCode}: ${JSON.stringify(json).slice(0, 500)}`));',\n\t\t'\t\t\t\t\treturn;',\n\t\t'\t\t\t\t}',\n\t\t'\t\t\t\tresolve(json);',\n\t\t'\t\t\t});',\n\t\t'\t\t});',\n\t\t'\t\treq.on(\"timeout\", () => req.destroy(new Error(`${url} timed out`)));',\n\t\t'\t\treq.on(\"error\", reject);',\n\t\t'\t\treq.write(body);',\n\t\t'\t\treq.end();',\n\t\t'\t});',\n\t\t'}',\n\t\t'',\n\t\t'function requestReady(url) {',\n\t\t'\treturn new Promise((resolve) => {',\n\t\t'\t\ttry {',\n\t\t'\t\t\tconst parsed = new URL(url);',\n\t\t'\t\t\tconst mod = parsed.protocol === \"https:\" ? https : http;',\n\t\t'\t\t\tconst req = mod.get(parsed, { timeout: 2500 }, (res) => {',\n\t\t'\t\t\t\tres.resume();',\n\t\t'\t\t\t\tresolve(Boolean(res.statusCode && res.statusCode < 500));',\n\t\t'\t\t\t});',\n\t\t'\t\t\treq.on(\"timeout\", () => req.destroy(new Error(\"timeout\")));',\n\t\t'\t\t\treq.on(\"error\", () => resolve(false));',\n\t\t'\t\t}',\n\t\t'\t\tcatch (error) {',\n\t\t'\t\t\tresolve(false);',\n\t\t'\t\t}',\n\t\t'\t});',\n\t\t'}',\n\t\t'',\n\t\t'async function waitForHttpReady(url, label) {',\n\t\t'\tconst deadline = Date.now() + startupTimeoutMs;',\n\t\t'\twhile (Date.now() < deadline) {',\n\t\t'\t\tif (await requestReady(url)) {',\n\t\t'\t\t\treturn;',\n\t\t'\t\t}',\n\t\t'\t\tawait delay(3000);',\n\t\t'\t}',\n\t\t'\tthrow new Error(`${label} did not become ready at ${url} within ${Math.round(startupTimeoutMs / 1000)}s`);',\n\t\t'}',\n\t\t'',\n\t\t'function requirePuppeteer() {',\n\t\t'\tconst candidates = [',\n\t\t'\t\tpath.join(projectRoot, \"server\", \"node_modules\", \"puppeteer\", \"lib\", \"cjs\", \"puppeteer\", \"puppeteer.js\"),',\n\t\t'\t\tpath.join(projectRoot, \"node_modules\", \"puppeteer\", \"lib\", \"cjs\", \"puppeteer\", \"puppeteer.js\"),',\n\t\t'\t\tpath.join(process.cwd(), \"server\", \"node_modules\", \"puppeteer\", \"lib\", \"cjs\", \"puppeteer\", \"puppeteer.js\"),',\n\t\t'\t\tpath.join(process.cwd(), \"node_modules\", \"puppeteer\", \"lib\", \"cjs\", \"puppeteer\", \"puppeteer.js\"),',\n\t\t'\t\t\"puppeteer\"',\n\t\t'\t];',\n\t\t'\tfor (const candidate of candidates) {',\n\t\t'\t\ttry { return require(candidate); }',\n\t\t'\t\tcatch (error) {}',\n\t\t'\t}',\n\t\t'\tthrow new Error(\"Unable to require puppeteer from project/server node_modules or global resolution\");',\n\t\t'}',\n\t\t'',\n\t\t'async function login() {',\n\t\t'\tif (!password) {',\n\t\t'\t\tthrow new Error(\"QA password is empty; source .resolveio-support-tools/env.sh or set RESOLVEIO_RUNNER_QA_PASSWORD before auth bootstrap\");',\n\t\t'\t}',\n\t\t'\tawait waitForHttpReady(serverUrl, \"QA server\");',\n\t\t'\tawait ensureLocalQaUser();',\n\t\t'\tlet loginJson = await requestJson(`${serverUrl}/login`, { username, password });',\n\t\t'\tif ((loginJson && loginJson.error) && /Invalid Username And Password|Too Many Attempts/i.test(String(loginJson.result || \"\"))) {',\n\t\t'\t\tconst repaired = await ensureLocalQaUser();',\n\t\t'\t\tif (repaired) {',\n\t\t'\t\t\tloginJson = await requestJson(`${serverUrl}/login`, { username, password });',\n\t\t'\t\t}',\n\t\t'\t}',\n\t\t'\tconst refreshToken = loginJson && loginJson.result && loginJson.result.token;',\n\t\t'\tif (loginJson.error || !refreshToken) {',\n\t\t'\t\tthrow new Error(`Login failed: ${JSON.stringify(loginJson).slice(0, 800)}`);',\n\t\t'\t}',\n\t\t'\tconst accessJson = await requestJson(`${serverUrl}/accessToken`, { refreshToken });',\n\t\t'\tconst accessToken = accessJson && accessJson.result && accessJson.result.token;',\n\t\t'\tconst user = accessJson && accessJson.result && accessJson.result.user;',\n\t\t'\tif (accessJson.error || !accessToken || !user) {',\n\t\t'\t\tthrow new Error(`Access token failed: ${JSON.stringify(accessJson).slice(0, 800)}`);',\n\t\t'\t}',\n\t\t'\treturn { refreshToken, accessToken, user: normalizeQaUserForBrowser(user) };',\n\t\t'}',\n\t\t'',\n\t\t'async function launchBrowser(puppeteer) {',\n\t\t'\tconst browserUrl = process.env.RESOLVEIO_RUNNER_QA_BROWSER_URL || process.env.RESOLVEIO_SUPPORT_QA_BROWSER_URL || \"\";',\n\t\t'\tif (browserUrl) {',\n\t\t'\t\treturn puppeteer.connect({ browserURL: browserUrl, protocolTimeout: 30000, defaultViewport: null });',\n\t\t'\t}',\n\t\t'\tconst launchOptions = {',\n\t\t'\t\theadless: true,',\n\t\t'\t\tdefaultViewport: { width: viewportWidth, height: viewportHeight },',\n\t\t'\t\targs: [\"--no-sandbox\", \"--disable-setuid-sandbox\", \"--disable-dev-shm-usage\", `--window-size=${viewportWidth},${viewportHeight}`]',\n\t\t'\t};',\n\t\t'\tif (process.env.PUPPETEER_EXECUTABLE_PATH || process.env.CHROME_BIN) {',\n\t\t'\t\tlaunchOptions.executablePath = process.env.PUPPETEER_EXECUTABLE_PATH || process.env.CHROME_BIN;',\n\t\t'\t}',\n\t\t'\treturn puppeteer.launch(launchOptions);',\n\t\t'}',\n\t\t'',\n\t\t'async function resetBrowserState(page) {',\n\t\t'\tawait waitForHttpReady(clientUrl, \"QA client\");',\n\t\t'\tawait page.goto(clientUrl, { waitUntil: \"domcontentloaded\", timeout: 45000 });',\n\t\t'\tawait page.evaluate(async () => {',\n\t\t'\t\ttry {',\n\t\t'\t\t\tconst registrations = await navigator.serviceWorker.getRegistrations();',\n\t\t'\t\t\tawait Promise.all(registrations.map((registration) => registration.unregister().catch(() => false)));',\n\t\t'\t\t} catch (error) {}',\n\t\t'\t\ttry {',\n\t\t'\t\t\tif (window.caches && window.caches.keys) {',\n\t\t'\t\t\t\tconst keys = await window.caches.keys();',\n\t\t'\t\t\t\tawait Promise.all(keys.map((key) => window.caches.delete(key).catch(() => false)));',\n\t\t'\t\t\t}',\n\t\t'\t\t} catch (error) {}',\n\t\t'\t\ttry {',\n\t\t'\t\t\tif (window.indexedDB && window.indexedDB.databases) {',\n\t\t'\t\t\t\tconst databases = await window.indexedDB.databases();',\n\t\t'\t\t\t\tawait Promise.all(databases.filter((database) => database && database.name).map((database) => new Promise((resolve) => {',\n\t\t'\t\t\t\t\tconst request = window.indexedDB.deleteDatabase(database.name);',\n\t\t'\t\t\t\t\trequest.onsuccess = () => resolve(true);',\n\t\t'\t\t\t\t\trequest.onerror = () => resolve(false);',\n\t\t'\t\t\t\t\trequest.onblocked = () => resolve(false);',\n\t\t'\t\t\t\t})));',\n\t\t'\t\t\t}',\n\t\t'\t\t} catch (error) {}',\n\t\t'\t\tlocalStorage.clear();',\n\t\t'\t\tsessionStorage.clear();',\n\t\t'\t});',\n\t\t'}',\n\t\t'',\n\t\t'async function seedAuth(page, auth) {',\n\t\t'\tauth.user = normalizeQaUserForBrowser(auth.user);',\n\t\t'\tawait page.evaluate((payload) => {',\n\t\t'\t\tlocalStorage.setItem(\"refreshToken\", payload.refreshToken);',\n\t\t'\t\tlocalStorage.setItem(\"accessToken\", payload.accessToken);',\n\t\t'\t\tlocalStorage.setItem(\"user\", JSON.stringify(payload.user));',\n\t\t'\t\tlocalStorage.setItem(\"lastURL\", payload.lastURL);',\n\t\t'\t\tlocalStorage.setItem(\"resolveio.runnerQaAuthBootstrappedAt\", payload.bootstrappedAt);',\n\t\t'\t}, { ...auth, lastURL: targetRoute, bootstrappedAt: new Date().toISOString() });',\n\t\t'}',\n\t\t'',\n\t\t'async function patchBrowserQaUser(page) {',\n\t\t'\tawait page.evaluate((nextRoute) => {',\n\t\t'\t\tlet user = {};',\n\t\t'\t\ttry { user = JSON.parse(localStorage.getItem(\"user\") || \"{}\"); } catch (error) { user = {}; }',\n\t\t'\t\tconst settings = {',\n\t\t'\t\t\ttable_color: \"#3b3ee3\",',\n\t\t'\t\t\ttable_font_color: \"#ffffff\",',\n\t\t'\t\t\tsecondary_table_color: \"#87ceeb\",',\n\t\t'\t\t\tsecondary_table_font_color: \"#000000\",',\n\t\t'\t\t\ttertiary_table_color: \"#ff4500\",',\n\t\t'\t\t\ttertiary_table_font_color: \"#000000\",',\n\t\t'\t\t\tfont_size: 12,',\n\t\t'\t\t\tcollapsable_menu: true,',\n\t\t'\t\t\tentries_per_page: \"25\",',\n\t\t'\t\t\twarning_color: \"#ffc107\",',\n\t\t'\t\t\twarning_font_color: \"#000000\",',\n\t\t'\t\t\twarning_hover_color: \"#e0a800\",',\n\t\t'\t\t\tsuccess_color: \"#28a745\",',\n\t\t'\t\t\tsuccess_font_color: \"#ffffff\",',\n\t\t'\t\t\tsuccess_hover_color: \"#218838\",',\n\t\t'\t\t\tdanger_color: \"#dc3545\",',\n\t\t'\t\t\tdanger_font_color: \"#ffffff\",',\n\t\t'\t\t\tdanger_hover_color: \"#c82333\",',\n\t\t'\t\t\tinfo_color: \"#17a2b8\",',\n\t\t'\t\t\tinfo_font_color: \"#ffffff\",',\n\t\t'\t\t\tinfo_hover_color: \"#138496\",',\n\t\t'\t\t\tprimary_color: \"#007bff\",',\n\t\t'\t\t\tprimary_font_color: \"#ffffff\",',\n\t\t'\t\t\tprimary_hover_color: \"#0069d9\",',\n\t\t'\t\t\tsecondary_color: \"#868e96\",',\n\t\t'\t\t\tsecondary_font_color: \"#ffffff\",',\n\t\t'\t\t\tsecondary_hover_color: \"#5a6268\",',\n\t\t'\t\t\trouting_preference: \"\",',\n\t\t'\t\t\topening_route: nextRoute',\n\t\t'\t\t};',\n\t\t'\t\tuser = {',\n\t\t'\t\t\t...user,',\n\t\t'\t\t\tother: {',\n\t\t'\t\t\t\t...(user.other || {}),',\n\t\t'\t\t\t\tyards: Array.isArray(user.other && user.other.yards) ? user.other.yards : [],',\n\t\t'\t\t\t\ttour_completed: true,',\n\t\t'\t\t\t\ttook_tour: true,',\n\t\t'\t\t\t\tcore_tour_completed: true,',\n\t\t'\t\t\t\twelcome_tour_completed: true,',\n\t\t'\t\t\t\ttop_navigation_tour_completed: true,',\n\t\t'\t\t\t\tuser_settings_tour_completed: true',\n\t\t'\t\t\t},',\n\t\t'\t\t\tsettings: { ...settings, ...(user.settings || {}), opening_route: nextRoute }',\n\t\t'\t\t};',\n\t\t'\t\tlocalStorage.setItem(\"user\", JSON.stringify(user));',\n\t\t'\t\tlocalStorage.setItem(\"lastURL\", nextRoute);',\n\t\t'\t\tlocalStorage.setItem(\"resolveio.runnerQaPostLoginGateRepairedAt\", new Date().toISOString());',\n\t\t'\t});',\n\t\t'}',\n\t\t'',\n\t\t'async function dismissVisibleTourOrSetupGate(page) {',\n\t\t'\treturn page.evaluate(() => {',\n\t\t'\t\tconst controls = Array.from(document.querySelectorAll(\"button, a, [role=\\'button\\']\"));',\n\t\t'\t\tconst control = controls.find((candidate) => {',\n\t\t'\t\t\tconst text = (candidate.textContent || \"\").replace(/\\\\s+/g, \" \").trim();',\n\t\t'\t\t\treturn /^(skip|finish|done|close)$/i.test(text);',\n\t\t'\t\t});',\n\t\t'\t\tif (control && typeof control.click === \"function\") {',\n\t\t'\t\t\tcontrol.click();',\n\t\t'\t\t\treturn true;',\n\t\t'\t\t}',\n\t\t'\t\treturn false;',\n\t\t'\t});',\n\t\t'}',\n\t\t'',\n\t\t'function isPostLoginSetupOrTourGate(currentRoute, summary) {',\n\t\t'\tconst text = String(summary && summary.bodyTextSnippet || \"\");',\n\t\t'\treturn currentRoute === \"/user-settings/settings\" || /Top Navigation Step \\\\d+ of \\\\d+|\\\\bSkip\\\\b|User Settings/i.test(text);',\n\t\t'}',\n\t\t'',\n\t\t'async function repairPostLoginSetupOrTourGate(page, expectedRoute) {',\n\t\t'\tif (process.env.RESOLVEIO_RUNNER_QA_DISABLE_POST_LOGIN_ROUTE_REPAIR === \"true\" || process.env.RESOLVEIO_SUPPORT_QA_DISABLE_POST_LOGIN_ROUTE_REPAIR === \"true\") {',\n\t\t'\t\treturn false;',\n\t\t'\t}',\n\t\t'\tconst current = normalizeRoutePath(await page.evaluate(() => location.href));',\n\t\t'\tconst summary = await pageSummary(page).catch(() => ({}));',\n\t\t'\tif (!isPostLoginSetupOrTourGate(current, summary)) {',\n\t\t'\t\treturn false;',\n\t\t'\t}',\n\t\t'\tawait ensureLocalQaUser().catch(() => false);',\n\t\t'\tawait refreshAuthAndSeed(page).catch(() => undefined);',\n\t\t'\tawait dismissVisibleTourOrSetupGate(page).catch(() => false);',\n\t\t'\tawait patchBrowserQaUser(page);',\n\t\t'\tawait page.goto(`${clientUrl}${expectedRoute}`, { waitUntil: \"domcontentloaded\", timeout: 60000 });',\n\t\t'\tawait delay(1500);',\n\t\t'\tawait dismissVisibleTourOrSetupGate(page).catch(() => false);',\n\t\t'\tawait patchBrowserQaUser(page);',\n\t\t'\tawait delay(500);',\n\t\t'\tconst repairedCurrent = normalizeRoutePath(await page.evaluate(() => location.href));',\n\t\t'\treturn repairedCurrent === expectedRoute;',\n\t\t'}',\n\t\t'',\n\t\t'function delay(ms) {',\n\t\t'\treturn new Promise((resolve) => setTimeout(resolve, ms));',\n\t\t'}',\n\t\t'',\n\t\t'function normalizeRoutePath(value) {',\n\t\t'\ttry {',\n\t\t'\t\t\tconst parsed = new URL(value, clientUrl);',\n\t\t'\t\t\tlet pathname = parsed.pathname || \"/\";',\n\t\t'\t\t\tpathname = pathname.replace(/\\\\/+$/, \"\") || \"/\";',\n\t\t'\t\t\treturn pathname;',\n\t\t'\t}',\n\t\t'\tcatch (error) {',\n\t\t'\t\t\treturn String(value || \"/\").split(\"?\")[0].replace(/\\\\/+$/, \"\") || \"/\";',\n\t\t'\t}',\n\t\t'}',\n\t\t'',\n\t\t'async function assertTargetRoute(page) {',\n\t\t'\tconst expected = normalizeRoutePath(targetRoute);',\n\t\t'\tif (expected === \"/\") {',\n\t\t'\t\treturn;',\n\t\t'\t}',\n\t\t'\tconst current = normalizeRoutePath(await page.evaluate(() => location.href));',\n\t\t'\tif (current !== expected) {',\n\t\t'\t\tconst repaired = await repairPostLoginSetupOrTourGate(page, expected);',\n\t\t'\t\tif (repaired) {',\n\t\t'\t\t\treturn;',\n\t\t'\t\t}',\n\t\t'\t\tconst summary = await pageSummary(page).catch(() => ({}));',\n\t\t'\t\tthrow new Error(`QA auth bootstrap reached ${current}, not requested target route ${expected}. This is a route blocker; do not continue browser QA until the runner/app can reach the requested screen. Page summary: ${JSON.stringify(summary).slice(0, 1200)}`);',\n\t\t'\t}',\n\t\t'}',\n\t\t'',\n\t\t'async function waitForStableTargetRoute(page) {',\n\t\t'\tconst expected = normalizeRoutePath(targetRoute);',\n\t\t'\tif (expected === \"/\") {',\n\t\t'\t\treturn;',\n\t\t'\t}',\n\t\t'\tconst deadline = Date.now() + Number(process.env.RESOLVEIO_RUNNER_QA_ROUTE_STABILITY_TIMEOUT_MS || process.env.RESOLVEIO_SUPPORT_QA_ROUTE_STABILITY_TIMEOUT_MS || 7000);',\n\t\t'\tlet stableSince = 0;',\n\t\t'\tlet lastCurrent = \"\";',\n\t\t'\twhile (Date.now() < deadline) {',\n\t\t'\t\tconst current = normalizeRoutePath(await page.evaluate(() => location.href));',\n\t\t'\t\tlastCurrent = current;',\n\t\t'\t\tif (current === expected) {',\n\t\t'\t\t\tstableSince = stableSince || Date.now();',\n\t\t'\t\t\tif (Date.now() - stableSince >= Number(process.env.RESOLVEIO_RUNNER_QA_ROUTE_STABLE_MS || process.env.RESOLVEIO_SUPPORT_QA_ROUTE_STABLE_MS || 2500)) {',\n\t\t'\t\t\t\treturn;',\n\t\t'\t\t\t}',\n\t\t'\t\t}',\n\t\t'\t\telse {',\n\t\t'\t\t\tstableSince = 0;',\n\t\t'\t\t}',\n\t\t'\t\tawait delay(250);',\n\t\t'\t}',\n\t\t'\tconst summary = await pageSummary(page).catch(() => ({}));',\n\t\t'\tthrow new Error(`QA auth bootstrap route was not stable on requested target ${expected}; last route was ${lastCurrent || \"unknown\"}. This is a route blocker; do not continue browser QA until the runner/app can remain on the requested screen. Page summary: ${JSON.stringify(summary).slice(0, 1200)}`);',\n\t\t'}',\n\t\t'',\n\t\t'async function dismissNavigationOverlays(page) {',\n\t\t'\ttry {',\n\t\t'\t\tawait page.keyboard.press(\"Escape\");',\n\t\t'\t} catch (error) {}',\n\t\t'\ttry {',\n\t\t'\t\tawait page.mouse.move(16, Math.max(120, viewportHeight - 24));',\n\t\t'\t} catch (error) {}',\n\t\t'\ttry {',\n\t\t'\t\tawait page.evaluate(() => {',\n\t\t'\t\t\tif (document.activeElement && typeof document.activeElement.blur === \"function\") document.activeElement.blur();',\n\t\t'\t\t\tdocument.body && document.body.dispatchEvent(new MouseEvent(\"mousemove\", { bubbles: true, clientX: 16, clientY: Math.max(120, window.innerHeight - 24) }));',\n\t\t'\t\t});',\n\t\t'\t} catch (error) {}',\n\t\t'\tawait delay(350);',\n\t\t'}',\n\t\t'',\n\t\t'async function assertSummaryOnTargetRoute(summary) {',\n\t\t'\tconst expected = normalizeRoutePath(targetRoute);',\n\t\t'\tif (expected === \"/\") {',\n\t\t'\t\treturn;',\n\t\t'\t}',\n\t\t'\tconst current = normalizeRoutePath(summary && summary.url || \"\");',\n\t\t'\tif (current !== expected) {',\n\t\t'\t\tthrow new Error(`QA auth bootstrap final summary is on ${current}, not requested target route ${expected}. This is a route blocker; refusing to write a false pass. Page summary: ${JSON.stringify(summary).slice(0, 1200)}`);',\n\t\t'\t}',\n\t\t'}',\n\t\t'',\n\t\t'async function logoutExistingBrowserSession(page) {',\n\t\t'\ttry {',\n\t\t'\t\tawait page.goto(clientUrl, { waitUntil: \"domcontentloaded\", timeout: 45000 });',\n\t\t'\t\tawait delay(500);',\n\t\t'\t\tawait page.evaluate(() => {',\n\t\t'\t\t\tconst controls = Array.from(document.querySelectorAll(\"button, a, [role=\\'button\\']\"));',\n\t\t'\t\t\tconst logoutControl = controls.find((control) => /(^|\\\\s)logout(\\\\s|$)/i.test((control.textContent || \"\").trim()));',\n\t\t'\t\t\tif (logoutControl && typeof logoutControl.click === \"function\") {',\n\t\t'\t\t\t\tlogoutControl.click();',\n\t\t'\t\t\t\treturn true;',\n\t\t'\t\t\t}',\n\t\t'\t\t\treturn false;',\n\t\t'\t\t});',\n\t\t'\t\tawait delay(1000);',\n\t\t'\t}',\n\t\t'\tcatch (error) {}',\n\t\t'}',\n\t\t'',\n\t\t'async function waitForAuthenticatedApp(page) {',\n\t\t'\tconst url = `${clientUrl}${targetRoute}`;',\n\t\t'\tawait page.goto(url, { waitUntil: \"domcontentloaded\", timeout: 60000 });',\n\t\t'\tawait page.waitForFunction(() => {',\n\t\t'\t\tconst text = (document.body && document.body.innerText || \"\").replace(/\\\\s+/g, \" \").trim();',\n\t\t'\t\tconst hasTokens = !!localStorage.getItem(\"refreshToken\") && !!localStorage.getItem(\"accessToken\") && !!localStorage.getItem(\"user\");',\n\t\t'\t\tconst hasLogin = /Employee\\\\/Customer Login|Employee Sign In|Customer Access|Unable to sign in/i.test(text);',\n\t\t'\t\tconst hasOffline = text.includes(\"*** OFFLINE MODE ***\");',\n\t\t'\t\treturn hasTokens && !hasLogin && !hasOffline && text.length > 40;',\n\t\t'\t}, { timeout: Number(process.env.RESOLVEIO_RUNNER_QA_AUTH_TIMEOUT_MS || process.env.RESOLVEIO_SUPPORT_QA_AUTH_TIMEOUT_MS || 60000) });',\n\t\t'\tawait delay(1000);',\n\t\t'\tawait assertTargetRoute(page);',\n\t\t'\tawait waitForStableTargetRoute(page);',\n\t\t'\tawait dismissNavigationOverlays(page);',\n\t\t'}',\n\t\t'',\n\t\t'async function pageSummary(page) {',\n\t\t'\treturn page.evaluate(() => {',\n\t\t'\t\tconst bodyText = (document.body && document.body.innerText || \"\").replace(/\\\\s+/g, \" \").trim();',\n\t\t'\t\treturn {',\n\t\t'\t\t\turl: location.href,',\n\t\t'\t\t\ttitle: document.title,',\n\t\t'\t\t\thasAngularDebug: !!window.ng,',\n\t\t'\t\t\thasRefreshToken: !!localStorage.getItem(\"refreshToken\"),',\n\t\t'\t\t\thasAccessToken: !!localStorage.getItem(\"accessToken\"),',\n\t\t'\t\t\thasUser: !!localStorage.getItem(\"user\"),',\n\t\t'\t\t\thasOfflineModeText: bodyText.includes(\"*** OFFLINE MODE ***\"),',\n\t\t'\t\t\thasLoginText: /Employee\\\\/Customer Login|Employee Sign In|Customer Access|Unable to sign in/i.test(bodyText),',\n\t\t'\t\t\tbodyTextSnippet: bodyText.slice(0, 800),',\n\t\t'\t\t\tlocalStorageKeys: Object.keys(localStorage).sort()',\n\t\t'\t\t};',\n\t\t'\t});',\n\t\t'}',\n\t\t'',\n\t\t'(async () => {',\n\t\t'\tfs.mkdirSync(artifactDir, { recursive: true });',\n\t\t'\tconst puppeteer = requirePuppeteer();',\n\t\t'\tconst browser = await launchBrowser(puppeteer);',\n\t\t'\tlet page;',\n\t\t'\ttry {',\n\t\t'\t\tawait waitForHttpReady(clientUrl, \"QA client\");',\n\t\t'\t\tawait waitForHttpReady(serverUrl, \"QA server\");',\n\t\t'\t\tpage = await browser.newPage();',\n\t\t'\t\tawait page.setViewport({ width: viewportWidth, height: viewportHeight });',\n\t\t'\t\tpage.on(\"console\", (msg) => {',\n\t\t'\t\t\tconst text = msg.text();',\n\t\t'\t\t\tif ([\"error\", \"warning\"].includes(msg.type()) || /error/i.test(text)) {',\n\t\t'\t\t\t\tconsole.log(\"[browser console]\", msg.type(), text);',\n\t\t'\t\t\t}',\n\t\t'\t\t});',\n\t\t'\t\tpage.on(\"pageerror\", (error) => console.log(\"[pageerror]\", error.message));',\n\t\t'\t\tawait logoutExistingBrowserSession(page);',\n\t\t'\t\tawait resetBrowserState(page);',\n\t\t'\t\tconst auth = await login();',\n\t\t'\t\tawait seedAuth(page, auth);',\n\t\t'\t\tawait waitForAuthenticatedApp(page);',\n\t\t'\t\tconst finalPage = await pageSummary(page);',\n\t\t'\t\tawait assertSummaryOnTargetRoute(finalPage);',\n\t\t'\t\tawait page.screenshot({ path: readyScreenshotPath, fullPage: true });',\n\t\t'\t\tconst summary = {',\n\t\t'\t\t\tstatus: \"pass\",',\n\t\t'\t\t\tclientUrl,',\n\t\t'\t\t\tserverUrl,',\n\t\t'\t\t\ttargetRoute,',\n\t\t'\t\t\tscreenshot: readyScreenshotPath,',\n\t\t'\t\t\tuser: { _id: auth.user && auth.user._id, username: auth.user && auth.user.username, fullname: auth.user && auth.user.fullname },',\n\t\t'\t\t\tpage: finalPage',\n\t\t'\t\t};',\n\t\t'\t\twriteResult(summary);',\n\t\t'\t\tconsole.log(JSON.stringify(summary, null, 2));',\n\t\t'\t}',\n\t\t'\tcatch (error) {',\n\t\t'\t\tlet summary = { status: \"fail\", clientUrl, serverUrl, targetRoute, screenshot: failureScreenshotPath, error: error && error.stack || String(error) };',\n\t\t'\t\ttry {',\n\t\t'\t\t\tif (page) {',\n\t\t'\t\t\t\tawait page.screenshot({ path: failureScreenshotPath, fullPage: true });',\n\t\t'\t\t\t\tsummary.page = await pageSummary(page);',\n\t\t'\t\t\t}',\n\t\t'\t\t} catch (screenshotError) {',\n\t\t'\t\t\tsummary.screenshotError = screenshotError && screenshotError.stack || String(screenshotError);',\n\t\t'\t\t}',\n\t\t'\t\twriteResult(summary);',\n\t\t'\t\tconsole.error(JSON.stringify(summary, null, 2));',\n\t\t'\t\tprocess.exitCode = 1;',\n\t\t'\t}',\n\t\t'\tfinally {',\n\t\t'\t\tif (browser && typeof browser.close === \"function\") {',\n\t\t'\t\t\tawait browser.close().catch(() => undefined);',\n\t\t'\t\t}',\n\t\t'\t\tprocess.exit(process.exitCode || 0);',\n\t\t'\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C,+BAA+B;QAC/B,mGAAmG;QACnG,YAAY;QACZ,wBAAwB;QACxB,2BAA2B;QAC3B,kCAAkC;QAClC,6DAA6D;QAC7D,2DAA2D;QAC3D,6CAA6C;QAC7C,mEAAmE;QACnE,kHAAkH;QAClH,6CAA6C;QAC7C,uDAAuD;QACvD,MAAM;QACN,MAAM;QACN,GAAG;QACH,EAAE;QACF,gBAAgB;QAChB,kDAAkD;QAClD,wCAAwC;QACxC,kDAAkD;QAClD,YAAY;QACZ,QAAQ;QACR,mDAAmD;QACnD,mDAAmD;QACnD,mCAAmC;QACnC,6EAA6E;QAC7E,iCAAiC;QACjC,6BAA6B;QAC7B,4EAA4E;QAC5E,yDAAyD;QACzD,MAAM;QACN,OAAO;QACP,+EAA+E;QAC/E,6CAA6C;QAC7C,kCAAkC;QAClC,+BAA+B;QAC/B,+BAA+B;QAC/B,wCAAwC;QACxC,8CAA8C;QAC9C,gDAAgD;QAChD,yEAAyE;QACzE,qBAAqB;QACrB,oBAAoB;QACpB,eAAe;QACf,eAAe;QACf,iBAAiB;QACjB,qCAAqC;QACrC,qIAAqI;QACrI,oBAAoB;QACpB,MAAM;QACN,yBAAyB;QACzB,kDAAkD;QAClD,IAAI;QACJ,kBAAkB;QAClB,yJAAyJ;QACzJ,SAAS;QACT,gBAAgB;QAChB,6EAA6E;QAC7E,6CAA6C;QAC7C,MAAM;QACN,+BAA+B;QAC/B,mGAAmG;QACnG,KAAK;QACL,yBAAyB;QACzB,oDAAoD;QACpD,yBAAyB;QACzB,IAAI;QACJ,YAAY;QACZ,yDAAyD;QACzD,kDAAkD;QAClD,KAAK;QACL,wCAAwC;QACxC,IAAI;QACJ,OAAO;QACP,EAAE;KACF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC","file":"ai-runner-qa-auth.js","sourcesContent":["export interface ResolveIORunnerQaAuthBootstrapScriptOptions {\n\tdefaultUsername?: string;\n\tdefaultPassword?: string;\n}\n\nexport function buildResolveIORunnerQaAuthBootstrapScript(options: ResolveIORunnerQaAuthBootstrapScriptOptions = {}): string {\n\tconst defaultUsername = options.defaultUsername || 'admin';\n\tconst defaultPassword = options.defaultPassword || '';\n\treturn [\n\t\t'#!/usr/bin/env node',\n\t\t\"'use strict';\",\n\t\t'',\n\t\t'const fs = require(\"fs\");',\n\t\t'const crypto = require(\"crypto\");',\n\t\t'const http = require(\"http\");',\n\t\t'const https = require(\"https\");',\n\t\t'const path = require(\"path\");',\n\t\t'',\n\t\t'const projectRoot = path.resolve(process.argv[2] || process.cwd());',\n\t\t'const routeArg = process.argv[3] || process.env.RESOLVEIO_RUNNER_QA_TARGET_ROUTE || process.env.RESOLVEIO_SUPPORT_QA_TARGET_ROUTE || process.env.RESOLVEIO_SUPPORT_QA_LAST_URL || \"/\";',\n\t\t'const targetRoute = routeArg.startsWith(\"/\") ? routeArg : `/${routeArg}`;',\n\t\t'const clientUrl = stripTrailingSlash(process.env.RESOLVEIO_RUNNER_QA_CLIENT_URL || process.env.RESOLVEIO_SUPPORT_QA_CLIENT_URL || `http://localhost:${process.env.RESOLVEIO_SUPPORT_QA_CLIENT_PORT || \"4200\"}`);',\n\t\t'const serverUrl = stripTrailingSlash(process.env.RESOLVEIO_RUNNER_QA_SERVER_URL || process.env.RESOLVEIO_SUPPORT_QA_SERVER_URL || \"http://localhost:8080\");',\n\t\t`const username = process.env.RESOLVEIO_RUNNER_QA_USERNAME || process.env.RESOLVEIO_SUPPORT_QA_USERNAME || ${JSON.stringify(defaultUsername)};`,\n\t\t`const password = process.env.RESOLVEIO_RUNNER_QA_PASSWORD || process.env.RESOLVEIO_SUPPORT_QA_PASSWORD || ${JSON.stringify(defaultPassword)};`,\n\t\t'const artifactDir = path.resolve(process.env.RESOLVEIO_RUNNER_QA_ARTIFACT_DIR || process.env.RESOLVEIO_SUPPORT_QA_ARTIFACT_DIR || path.join(projectRoot, \"qa-artifacts\"));',\n\t\t'const viewportWidth = Number(process.env.RESOLVEIO_RUNNER_QA_VIEWPORT_WIDTH || process.env.RESOLVEIO_SUPPORT_QA_VIEWPORT_WIDTH || 1920);',\n\t\t'const viewportHeight = Number(process.env.RESOLVEIO_RUNNER_QA_VIEWPORT_HEIGHT || process.env.RESOLVEIO_SUPPORT_QA_VIEWPORT_HEIGHT || 1080);',\n\t\t'const startupTimeoutMs = Math.max(1000, Number(process.env.RESOLVEIO_RUNNER_QA_ANGULAR_STARTUP_TIMEOUT_SECONDS || process.env.RESOLVEIO_SUPPORT_QA_ANGULAR_STARTUP_TIMEOUT_SECONDS || 900) * 1000);',\n\t\t'const resultPath = path.join(artifactDir, \"auth-bootstrap-result.json\");',\n\t\t'const readyScreenshotPath = path.join(artifactDir, \"auth-bootstrap-ready.png\");',\n\t\t'const failureScreenshotPath = path.join(artifactDir, \"auth-bootstrap-failed.png\");',\n\t\t'',\n\t\t'function stripTrailingSlash(value) {',\n\t\t'\treturn String(value || \"\").replace(/\\\\/+$/, \"\");',\n\t\t'}',\n\t\t'',\n\t\t'function isLocalhostUrl(value) {',\n\t\t'\ttry {',\n\t\t'\t\tconst parsed = new URL(value);',\n\t\t'\t\treturn [\"localhost\", \"127.0.0.1\", \"::1\"].includes(parsed.hostname);',\n\t\t'\t}',\n\t\t'\tcatch (error) {',\n\t\t'\t\treturn false;',\n\t\t'\t}',\n\t\t'}',\n\t\t'',\n\t\t'function resolveLocalMongoUrl() {',\n\t\t'\tconst localQaMongoUrl = process.env.RESOLVEIO_RUNNER_QA_MONGO_URL || process.env.RESOLVEIO_SUPPORT_QA_MONGO_URL || `mongodb://127.0.0.1:${process.env.RESOLVEIO_SUPPORT_QA_MONGO_PORT || \"3001\"}/resolveio?directConnection=true`;',\n\t\t'\tif (isLocalhostUrl(serverUrl)) {',\n\t\t'\t\treturn localQaMongoUrl;',\n\t\t'\t}',\n\t\t'\treturn process.env.MONGO_URL || localQaMongoUrl;',\n\t\t'}',\n\t\t'',\n\t\t'function requireMongoClient() {',\n\t\t'\tconst candidates = [',\n\t\t'\t\tpath.join(projectRoot, \"server\", \"node_modules\", \"mongodb\"),',\n\t\t'\t\tpath.join(projectRoot, \"node_modules\", \"mongodb\"),',\n\t\t'\t\tpath.join(process.cwd(), \"server\", \"node_modules\", \"mongodb\"),',\n\t\t'\t\tpath.join(process.cwd(), \"node_modules\", \"mongodb\"),',\n\t\t'\t\t\"mongodb\"',\n\t\t'\t];',\n\t\t'\tfor (const candidate of candidates) {',\n\t\t'\t\ttry { return require(candidate).MongoClient; }',\n\t\t'\t\tcatch (error) {}',\n\t\t'\t}',\n\t\t'\tthrow new Error(\"Unable to require mongodb from project/server node_modules or global resolution\");',\n\t\t'}',\n\t\t'',\n\t\t'function buildDefaultQaUserSettings() {',\n\t\t'\treturn {',\n\t\t'\t\ttable_color: \"#3b3ee3\",',\n\t\t'\t\ttable_font_color: \"#ffffff\",',\n\t\t'\t\tsecondary_table_color: \"#87ceeb\",',\n\t\t'\t\tsecondary_table_font_color: \"#000000\",',\n\t\t'\t\ttertiary_table_color: \"#ff4500\",',\n\t\t'\t\ttertiary_table_font_color: \"#000000\",',\n\t\t'\t\tfont_size: 12,',\n\t\t'\t\tcollapsable_menu: true,',\n\t\t'\t\tentries_per_page: \"25\",',\n\t\t'\t\twarning_color: \"#ffc107\",',\n\t\t'\t\twarning_font_color: \"#000000\",',\n\t\t'\t\twarning_hover_color: \"#e0a800\",',\n\t\t'\t\tsuccess_color: \"#28a745\",',\n\t\t'\t\tsuccess_font_color: \"#ffffff\",',\n\t\t'\t\tsuccess_hover_color: \"#218838\",',\n\t\t'\t\tdanger_color: \"#dc3545\",',\n\t\t'\t\tdanger_font_color: \"#ffffff\",',\n\t\t'\t\tdanger_hover_color: \"#c82333\",',\n\t\t'\t\tinfo_color: \"#17a2b8\",',\n\t\t'\t\tinfo_font_color: \"#ffffff\",',\n\t\t'\t\tinfo_hover_color: \"#138496\",',\n\t\t'\t\tprimary_color: \"#007bff\",',\n\t\t'\t\tprimary_font_color: \"#ffffff\",',\n\t\t'\t\tprimary_hover_color: \"#0069d9\",',\n\t\t'\t\tsecondary_color: \"#868e96\",',\n\t\t'\t\tsecondary_font_color: \"#ffffff\",',\n\t\t'\t\tsecondary_hover_color: \"#5a6268\",',\n\t\t'\t\trouting_preference: \"\",',\n\t\t'\t\topening_route: targetRoute,',\n\t\t'\t\trio_select_search_mode: \"exact\"',\n\t\t'\t};',\n\t\t'}',\n\t\t'',\n\t\t'function normalizeQaUserForBrowser(user) {',\n\t\t'\tconst normalized = { ...(user || {}) };',\n\t\t'\tnormalized.other = {',\n\t\t'\t\t...(normalized.other || {}),',\n\t\t'\t\tyards: Array.isArray(normalized.other && normalized.other.yards) ? normalized.other.yards : [],',\n\t\t'\t\ttour_completed: true,',\n\t\t'\t\ttook_tour: true,',\n\t\t'\t\tcore_tour_completed: true,',\n\t\t'\t\twelcome_tour_completed: true,',\n\t\t'\t\ttop_navigation_tour_completed: true,',\n\t\t'\t\tuser_settings_tour_completed: true',\n\t\t'\t};',\n\t\t'\tnormalized.settings = {',\n\t\t'\t\t...buildDefaultQaUserSettings(),',\n\t\t'\t\t...(normalized.settings || {}),',\n\t\t'\t\topening_route: targetRoute',\n\t\t'\t};',\n\t\t'\treturn normalized;',\n\t\t'}',\n\t\t'',\n\t\t'async function ensureLocalQaUser() {',\n\t\t'\tif (!isLocalhostUrl(serverUrl) || process.env.RESOLVEIO_RUNNER_QA_DISABLE_LOCAL_USER_REPAIR === \"true\" || process.env.RESOLVEIO_SUPPORT_QA_DISABLE_LOCAL_USER_REPAIR === \"true\") {',\n\t\t'\t\treturn false;',\n\t\t'\t}',\n\t\t'\tconst MongoClient = requireMongoClient();',\n\t\t'\tconst client = new MongoClient(resolveLocalMongoUrl());',\n\t\t'\tawait client.connect();',\n\t\t'\ttry {',\n\t\t'\t\tconst db = client.db();',\n\t\t'\t\tconst users = db.collection(\"users\");',\n\t\t'\t\tconst now = new Date();',\n\t\t'\t\tconst salt = crypto.randomBytes(32).toString(\"hex\");',\n\t\t'\t\tconst hash = crypto.pbkdf2Sync(password, salt, 25000, 512, \"sha256\").toString(\"hex\");',\n\t\t'\t\tconst existing = await users.findOne({ $or: [{ username }, { email: username }] }, { projection: { _id: 1 } });',\n\t\t'\t\tconst defaultSettings = buildDefaultQaUserSettings();',\n\t\t'\t\tconst defaultOther = { yards: [], date_picker_day_start: \"S\", tour_completed: true, took_tour: true, core_tour_completed: true, welcome_tour_completed: true, top_navigation_tour_completed: true, user_settings_tour_completed: true, tour_completed_at: now.toISOString() };',\n\t\t'\t\tconst baseUser = {',\n\t\t'\t\t\t__v: 0,',\n\t\t'\t\t\tusername,',\n\t\t'\t\t\temail: username.includes(\"@\") ? username : \"dev@resolveio.com\",',\n\t\t'\t\t\tfullname: \"QA Admin\",',\n\t\t'\t\t\troles: { super_admin: true, approvals: [], groups: [], notifications: [], miscs: [] },',\n\t\t'\t\t\tactive: true,',\n\t\t'\t\t\tother: defaultOther,',\n\t\t'\t\t\tsettings: defaultSettings,',\n\t\t'\t\t\tphonenumber: \"\",',\n\t\t'\t\t\treadonly: false,',\n\t\t'\t\t\tis_customer: false,',\n\t\t'\t\t\thash,',\n\t\t'\t\t\tsalt,',\n\t\t'\t\t\tattempts: 0,',\n\t\t'\t\t\tservices: {},',\n\t\t'\t\t\tupdatedAt: now',\n\t\t'\t\t};',\n\t\t'\t\tconst qaUserFilter = {',\n\t\t'\t\t\t$or: [',\n\t\t'\t\t\t\t{ username },',\n\t\t'\t\t\t\t{ email: username },',\n\t\t'\t\t\t\t{ username: \"admin\" },',\n\t\t'\t\t\t\t{ email: \"admin\" },',\n\t\t'\t\t\t\t{ email: \"dev@resolveio.com\" }',\n\t\t'\t\t\t]',\n\t\t'\t\t};',\n\t\t'\t\tawait users.updateMany(qaUserFilter, {',\n\t\t'\t\t\t$set: {',\n\t\t'\t\t\t\tactive: true,',\n\t\t'\t\t\t\troles: baseUser.roles,',\n\t\t'\t\t\t\tother: defaultOther,',\n\t\t'\t\t\t\tsettings: defaultSettings,',\n\t\t'\t\t\t\thash,',\n\t\t'\t\t\t\tsalt,',\n\t\t'\t\t\t\tattempts: 0,',\n\t\t'\t\t\t\treadonly: false,',\n\t\t'\t\t\t\tis_customer: false,',\n\t\t'\t\t\t\tupdatedAt: now',\n\t\t'\t\t\t}',\n\t\t'\t\t});',\n\t\t'\t\tif (existing && existing._id) {',\n\t\t'\t\t\tawait users.updateOne({ _id: existing._id }, { $set: baseUser });',\n\t\t'\t\t}',\n\t\t'\t\telse {',\n\t\t'\t\t\tawait users.insertOne({ _id: crypto.randomBytes(12).toString(\"hex\"), createdAt: now, ...baseUser });',\n\t\t'\t\t}',\n\t\t'\t\tconst repaired = await users.findOne(qaUserFilter, { projection: { _id: 1 } });',\n\t\t'\t\tif (repaired && repaired._id) {',\n\t\t'\t\t\tawait users.updateOne({ _id: repaired._id }, {',\n\t\t'\t\t\t\t$set: {',\n\t\t'\t\t\t\t\tactive: true,',\n\t\t'\t\t\t\t\troles: baseUser.roles,',\n\t\t'\t\t\t\t\tother: defaultOther,',\n\t\t'\t\t\t\t\tsettings: defaultSettings,',\n\t\t'\t\t\t\t\thash,',\n\t\t'\t\t\t\t\tsalt,',\n\t\t'\t\t\t\t\tattempts: 0,',\n\t\t'\t\t\t\t\treadonly: false,',\n\t\t'\t\t\t\t\tis_customer: false,',\n\t\t'\t\t\t\t\tupdatedAt: now',\n\t\t'\t\t\t\t}',\n\t\t'\t\t\t});',\n\t\t'\t\t}',\n\t\t'\t\treturn true;',\n\t\t'\t}',\n\t\t'\tfinally {',\n\t\t'\t\tawait client.close().catch(() => undefined);',\n\t\t'\t}',\n\t\t'}',\n\t\t'',\n\t\t'async function refreshAuthAndSeed(page) {',\n\t\t'\tconst auth = await login();',\n\t\t'\tawait seedAuth(page, auth);',\n\t\t'\treturn auth;',\n\t\t'}',\n\t\t'',\n\t\t'function writeResult(payload) {',\n\t\t'\tfs.mkdirSync(artifactDir, { recursive: true });',\n\t\t'\tfs.writeFileSync(resultPath, JSON.stringify(payload, null, 2));',\n\t\t'}',\n\t\t'',\n\t\t'function requestJson(url, payload) {',\n\t\t'\treturn new Promise((resolve, reject) => {',\n\t\t'\t\tconst body = JSON.stringify(payload || {});',\n\t\t'\t\tconst parsed = new URL(url);',\n\t\t'\t\tconst mod = parsed.protocol === \"https:\" ? https : http;',\n\t\t'\t\tconst req = mod.request(parsed, {',\n\t\t'\t\t\tmethod: \"POST\",',\n\t\t'\t\t\ttimeout: 20000,',\n\t\t'\t\t\theaders: {',\n\t\t'\t\t\t\t\"content-type\": \"application/json\",',\n\t\t'\t\t\t\t\"content-length\": Buffer.byteLength(body),',\n\t\t'\t\t\t\t\"origin\": clientUrl',\n\t\t'\t\t\t}',\n\t\t'\t\t}, (res) => {',\n\t\t'\t\t\tlet raw = \"\";',\n\t\t'\t\t\tres.setEncoding(\"utf8\");',\n\t\t'\t\t\tres.on(\"data\", (chunk) => { raw += chunk; });',\n\t\t'\t\t\tres.on(\"end\", () => {',\n\t\t'\t\t\t\tlet json = null;',\n\t\t'\t\t\t\ttry { json = raw ? JSON.parse(raw) : {}; }',\n\t\t'\t\t\t\tcatch (error) {',\n\t\t'\t\t\t\t\treject(new Error(`${url} returned non-JSON HTTP ${res.statusCode}: ${raw.slice(0, 300)}`));',\n\t\t'\t\t\t\t\treturn;',\n\t\t'\t\t\t\t}',\n\t\t'\t\t\t\tif (!res.statusCode || res.statusCode >= 400) {',\n\t\t'\t\t\t\t\treject(new Error(`${url} returned HTTP ${res.statusCode}: ${JSON.stringify(json).slice(0, 500)}`));',\n\t\t'\t\t\t\t\treturn;',\n\t\t'\t\t\t\t}',\n\t\t'\t\t\t\tresolve(json);',\n\t\t'\t\t\t});',\n\t\t'\t\t});',\n\t\t'\t\treq.on(\"timeout\", () => req.destroy(new Error(`${url} timed out`)));',\n\t\t'\t\treq.on(\"error\", reject);',\n\t\t'\t\treq.write(body);',\n\t\t'\t\treq.end();',\n\t\t'\t});',\n\t\t'}',\n\t\t'',\n\t\t'function requestReady(url) {',\n\t\t'\treturn new Promise((resolve) => {',\n\t\t'\t\ttry {',\n\t\t'\t\t\tconst parsed = new URL(url);',\n\t\t'\t\t\tconst mod = parsed.protocol === \"https:\" ? https : http;',\n\t\t'\t\t\tconst req = mod.get(parsed, { timeout: 2500 }, (res) => {',\n\t\t'\t\t\t\tres.resume();',\n\t\t'\t\t\t\tresolve(Boolean(res.statusCode && res.statusCode < 500));',\n\t\t'\t\t\t});',\n\t\t'\t\t\treq.on(\"timeout\", () => req.destroy(new Error(\"timeout\")));',\n\t\t'\t\t\treq.on(\"error\", () => resolve(false));',\n\t\t'\t\t}',\n\t\t'\t\tcatch (error) {',\n\t\t'\t\t\tresolve(false);',\n\t\t'\t\t}',\n\t\t'\t});',\n\t\t'}',\n\t\t'',\n\t\t'async function waitForHttpReady(url, label) {',\n\t\t'\tconst deadline = Date.now() + startupTimeoutMs;',\n\t\t'\twhile (Date.now() < deadline) {',\n\t\t'\t\tif (await requestReady(url)) {',\n\t\t'\t\t\treturn;',\n\t\t'\t\t}',\n\t\t'\t\tawait delay(3000);',\n\t\t'\t}',\n\t\t'\tthrow new Error(`${label} did not become ready at ${url} within ${Math.round(startupTimeoutMs / 1000)}s`);',\n\t\t'}',\n\t\t'',\n\t\t'function requirePuppeteer() {',\n\t\t'\tconst candidates = [',\n\t\t'\t\tpath.join(projectRoot, \"server\", \"node_modules\", \"puppeteer\", \"lib\", \"cjs\", \"puppeteer\", \"puppeteer.js\"),',\n\t\t'\t\tpath.join(projectRoot, \"node_modules\", \"puppeteer\", \"lib\", \"cjs\", \"puppeteer\", \"puppeteer.js\"),',\n\t\t'\t\tpath.join(process.cwd(), \"server\", \"node_modules\", \"puppeteer\", \"lib\", \"cjs\", \"puppeteer\", \"puppeteer.js\"),',\n\t\t'\t\tpath.join(process.cwd(), \"node_modules\", \"puppeteer\", \"lib\", \"cjs\", \"puppeteer\", \"puppeteer.js\"),',\n\t\t'\t\t\"puppeteer\"',\n\t\t'\t];',\n\t\t'\tfor (const candidate of candidates) {',\n\t\t'\t\ttry { return require(candidate); }',\n\t\t'\t\tcatch (error) {}',\n\t\t'\t}',\n\t\t'\tthrow new Error(\"Unable to require puppeteer from project/server node_modules or global resolution\");',\n\t\t'}',\n\t\t'',\n\t\t'async function login() {',\n\t\t'\tif (!password) {',\n\t\t'\t\tthrow new Error(\"QA password is empty; source .resolveio-support-tools/env.sh or set RESOLVEIO_RUNNER_QA_PASSWORD before auth bootstrap\");',\n\t\t'\t}',\n\t\t'\tawait waitForHttpReady(serverUrl, \"QA server\");',\n\t\t'\tawait ensureLocalQaUser();',\n\t\t'\tlet loginJson = await requestJson(`${serverUrl}/login`, { username, password });',\n\t\t'\tif ((loginJson && loginJson.error) && /Invalid Username And Password|Too Many Attempts/i.test(String(loginJson.result || \"\"))) {',\n\t\t'\t\tconst repaired = await ensureLocalQaUser();',\n\t\t'\t\tif (repaired) {',\n\t\t'\t\t\tloginJson = await requestJson(`${serverUrl}/login`, { username, password });',\n\t\t'\t\t}',\n\t\t'\t}',\n\t\t'\tconst refreshToken = loginJson && loginJson.result && loginJson.result.token;',\n\t\t'\tif (loginJson.error || !refreshToken) {',\n\t\t'\t\tthrow new Error(`Login failed: ${JSON.stringify(loginJson).slice(0, 800)}`);',\n\t\t'\t}',\n\t\t'\tconst accessJson = await requestJson(`${serverUrl}/accessToken`, { refreshToken });',\n\t\t'\tconst accessToken = accessJson && accessJson.result && accessJson.result.token;',\n\t\t'\tconst user = accessJson && accessJson.result && accessJson.result.user;',\n\t\t'\tif (accessJson.error || !accessToken || !user) {',\n\t\t'\t\tthrow new Error(`Access token failed: ${JSON.stringify(accessJson).slice(0, 800)}`);',\n\t\t'\t}',\n\t\t'\treturn { refreshToken, accessToken, user: normalizeQaUserForBrowser(user) };',\n\t\t'}',\n\t\t'',\n\t\t'async function launchBrowser(puppeteer) {',\n\t\t'\tconst browserUrl = process.env.RESOLVEIO_RUNNER_QA_BROWSER_URL || process.env.RESOLVEIO_SUPPORT_QA_BROWSER_URL || \"\";',\n\t\t'\tif (browserUrl) {',\n\t\t'\t\treturn puppeteer.connect({ browserURL: browserUrl, protocolTimeout: 30000, defaultViewport: null });',\n\t\t'\t}',\n\t\t'\tconst launchOptions = {',\n\t\t'\t\theadless: true,',\n\t\t'\t\tdefaultViewport: { width: viewportWidth, height: viewportHeight },',\n\t\t'\t\targs: [\"--no-sandbox\", \"--disable-setuid-sandbox\", \"--disable-dev-shm-usage\", `--window-size=${viewportWidth},${viewportHeight}`]',\n\t\t'\t};',\n\t\t'\tif (process.env.PUPPETEER_EXECUTABLE_PATH || process.env.CHROME_BIN) {',\n\t\t'\t\tlaunchOptions.executablePath = process.env.PUPPETEER_EXECUTABLE_PATH || process.env.CHROME_BIN;',\n\t\t'\t}',\n\t\t'\treturn puppeteer.launch(launchOptions);',\n\t\t'}',\n\t\t'',\n\t\t'async function resetBrowserState(page) {',\n\t\t'\tawait waitForHttpReady(clientUrl, \"QA client\");',\n\t\t'\tawait page.goto(clientUrl, { waitUntil: \"domcontentloaded\", timeout: 45000 });',\n\t\t'\tawait page.evaluate(async () => {',\n\t\t'\t\ttry {',\n\t\t'\t\t\tconst registrations = await navigator.serviceWorker.getRegistrations();',\n\t\t'\t\t\tawait Promise.all(registrations.map((registration) => registration.unregister().catch(() => false)));',\n\t\t'\t\t} catch (error) {}',\n\t\t'\t\ttry {',\n\t\t'\t\t\tif (window.caches && window.caches.keys) {',\n\t\t'\t\t\t\tconst keys = await window.caches.keys();',\n\t\t'\t\t\t\tawait Promise.all(keys.map((key) => window.caches.delete(key).catch(() => false)));',\n\t\t'\t\t\t}',\n\t\t'\t\t} catch (error) {}',\n\t\t'\t\ttry {',\n\t\t'\t\t\tif (window.indexedDB && window.indexedDB.databases) {',\n\t\t'\t\t\t\tconst databases = await window.indexedDB.databases();',\n\t\t'\t\t\t\tawait Promise.all(databases.filter((database) => database && database.name).map((database) => new Promise((resolve) => {',\n\t\t'\t\t\t\t\tconst request = window.indexedDB.deleteDatabase(database.name);',\n\t\t'\t\t\t\t\trequest.onsuccess = () => resolve(true);',\n\t\t'\t\t\t\t\trequest.onerror = () => resolve(false);',\n\t\t'\t\t\t\t\trequest.onblocked = () => resolve(false);',\n\t\t'\t\t\t\t})));',\n\t\t'\t\t\t}',\n\t\t'\t\t} catch (error) {}',\n\t\t'\t\tlocalStorage.clear();',\n\t\t'\t\tsessionStorage.clear();',\n\t\t'\t});',\n\t\t'}',\n\t\t'',\n\t\t'async function seedAuth(page, auth) {',\n\t\t'\tauth.user = normalizeQaUserForBrowser(auth.user);',\n\t\t'\tawait page.evaluate((payload) => {',\n\t\t'\t\tlocalStorage.setItem(\"refreshToken\", payload.refreshToken);',\n\t\t'\t\tlocalStorage.setItem(\"accessToken\", payload.accessToken);',\n\t\t'\t\tlocalStorage.setItem(\"user\", JSON.stringify(payload.user));',\n\t\t'\t\tlocalStorage.setItem(\"lastURL\", payload.lastURL);',\n\t\t'\t\tlocalStorage.setItem(\"resolveio.runnerQaAuthBootstrappedAt\", payload.bootstrappedAt);',\n\t\t'\t}, { ...auth, lastURL: targetRoute, bootstrappedAt: new Date().toISOString() });',\n\t\t'}',\n\t\t'',\n\t\t'async function patchBrowserQaUser(page) {',\n\t\t'\tawait page.evaluate((nextRoute) => {',\n\t\t'\t\tlet user = {};',\n\t\t'\t\ttry { user = JSON.parse(localStorage.getItem(\"user\") || \"{}\"); } catch (error) { user = {}; }',\n\t\t'\t\tconst settings = {',\n\t\t'\t\t\ttable_color: \"#3b3ee3\",',\n\t\t'\t\t\ttable_font_color: \"#ffffff\",',\n\t\t'\t\t\tsecondary_table_color: \"#87ceeb\",',\n\t\t'\t\t\tsecondary_table_font_color: \"#000000\",',\n\t\t'\t\t\ttertiary_table_color: \"#ff4500\",',\n\t\t'\t\t\ttertiary_table_font_color: \"#000000\",',\n\t\t'\t\t\tfont_size: 12,',\n\t\t'\t\t\tcollapsable_menu: true,',\n\t\t'\t\t\tentries_per_page: \"25\",',\n\t\t'\t\t\twarning_color: \"#ffc107\",',\n\t\t'\t\t\twarning_font_color: \"#000000\",',\n\t\t'\t\t\twarning_hover_color: \"#e0a800\",',\n\t\t'\t\t\tsuccess_color: \"#28a745\",',\n\t\t'\t\t\tsuccess_font_color: \"#ffffff\",',\n\t\t'\t\t\tsuccess_hover_color: \"#218838\",',\n\t\t'\t\t\tdanger_color: \"#dc3545\",',\n\t\t'\t\t\tdanger_font_color: \"#ffffff\",',\n\t\t'\t\t\tdanger_hover_color: \"#c82333\",',\n\t\t'\t\t\tinfo_color: \"#17a2b8\",',\n\t\t'\t\t\tinfo_font_color: \"#ffffff\",',\n\t\t'\t\t\tinfo_hover_color: \"#138496\",',\n\t\t'\t\t\tprimary_color: \"#007bff\",',\n\t\t'\t\t\tprimary_font_color: \"#ffffff\",',\n\t\t'\t\t\tprimary_hover_color: \"#0069d9\",',\n\t\t'\t\t\tsecondary_color: \"#868e96\",',\n\t\t'\t\t\tsecondary_font_color: \"#ffffff\",',\n\t\t'\t\t\tsecondary_hover_color: \"#5a6268\",',\n\t\t'\t\t\trouting_preference: \"\",',\n\t\t'\t\t\topening_route: nextRoute,',\n\t\t'\t\t\trio_select_search_mode: \"exact\"',\n\t\t'\t\t};',\n\t\t'\t\tuser = {',\n\t\t'\t\t\t...user,',\n\t\t'\t\t\tother: {',\n\t\t'\t\t\t\t...(user.other || {}),',\n\t\t'\t\t\t\tyards: Array.isArray(user.other && user.other.yards) ? user.other.yards : [],',\n\t\t'\t\t\t\ttour_completed: true,',\n\t\t'\t\t\t\ttook_tour: true,',\n\t\t'\t\t\t\tcore_tour_completed: true,',\n\t\t'\t\t\t\twelcome_tour_completed: true,',\n\t\t'\t\t\t\ttop_navigation_tour_completed: true,',\n\t\t'\t\t\t\tuser_settings_tour_completed: true',\n\t\t'\t\t\t},',\n\t\t'\t\t\tsettings: { ...settings, ...(user.settings || {}), opening_route: nextRoute }',\n\t\t'\t\t};',\n\t\t'\t\tlocalStorage.setItem(\"user\", JSON.stringify(user));',\n\t\t'\t\tlocalStorage.setItem(\"lastURL\", nextRoute);',\n\t\t'\t\tlocalStorage.setItem(\"resolveio.runnerQaPostLoginGateRepairedAt\", new Date().toISOString());',\n\t\t'\t});',\n\t\t'}',\n\t\t'',\n\t\t'async function dismissVisibleTourOrSetupGate(page) {',\n\t\t'\treturn page.evaluate(() => {',\n\t\t'\t\tconst controls = Array.from(document.querySelectorAll(\"button, a, [role=\\'button\\']\"));',\n\t\t'\t\tconst control = controls.find((candidate) => {',\n\t\t'\t\t\tconst text = (candidate.textContent || \"\").replace(/\\\\s+/g, \" \").trim();',\n\t\t'\t\t\treturn /^(skip|finish|done|close)$/i.test(text);',\n\t\t'\t\t});',\n\t\t'\t\tif (control && typeof control.click === \"function\") {',\n\t\t'\t\t\tcontrol.click();',\n\t\t'\t\t\treturn true;',\n\t\t'\t\t}',\n\t\t'\t\treturn false;',\n\t\t'\t});',\n\t\t'}',\n\t\t'',\n\t\t'function isPostLoginSetupOrTourGate(currentRoute, summary) {',\n\t\t'\tconst text = String(summary && summary.bodyTextSnippet || \"\");',\n\t\t'\treturn currentRoute === \"/user-settings/settings\" || /Top Navigation Step \\\\d+ of \\\\d+|\\\\bSkip\\\\b|User Settings/i.test(text);',\n\t\t'}',\n\t\t'',\n\t\t'async function repairPostLoginSetupOrTourGate(page, expectedRoute) {',\n\t\t'\tif (process.env.RESOLVEIO_RUNNER_QA_DISABLE_POST_LOGIN_ROUTE_REPAIR === \"true\" || process.env.RESOLVEIO_SUPPORT_QA_DISABLE_POST_LOGIN_ROUTE_REPAIR === \"true\") {',\n\t\t'\t\treturn false;',\n\t\t'\t}',\n\t\t'\tconst current = normalizeRoutePath(await page.evaluate(() => location.href));',\n\t\t'\tconst summary = await pageSummary(page).catch(() => ({}));',\n\t\t'\tif (!isPostLoginSetupOrTourGate(current, summary)) {',\n\t\t'\t\treturn false;',\n\t\t'\t}',\n\t\t'\tawait ensureLocalQaUser().catch(() => false);',\n\t\t'\tawait refreshAuthAndSeed(page).catch(() => undefined);',\n\t\t'\tawait dismissVisibleTourOrSetupGate(page).catch(() => false);',\n\t\t'\tawait patchBrowserQaUser(page);',\n\t\t'\tawait page.goto(`${clientUrl}${expectedRoute}`, { waitUntil: \"domcontentloaded\", timeout: 60000 });',\n\t\t'\tawait delay(1500);',\n\t\t'\tawait dismissVisibleTourOrSetupGate(page).catch(() => false);',\n\t\t'\tawait patchBrowserQaUser(page);',\n\t\t'\tawait delay(500);',\n\t\t'\tconst repairedCurrent = normalizeRoutePath(await page.evaluate(() => location.href));',\n\t\t'\treturn repairedCurrent === expectedRoute;',\n\t\t'}',\n\t\t'',\n\t\t'function delay(ms) {',\n\t\t'\treturn new Promise((resolve) => setTimeout(resolve, ms));',\n\t\t'}',\n\t\t'',\n\t\t'function normalizeRoutePath(value) {',\n\t\t'\ttry {',\n\t\t'\t\t\tconst parsed = new URL(value, clientUrl);',\n\t\t'\t\t\tlet pathname = parsed.pathname || \"/\";',\n\t\t'\t\t\tpathname = pathname.replace(/\\\\/+$/, \"\") || \"/\";',\n\t\t'\t\t\treturn pathname;',\n\t\t'\t}',\n\t\t'\tcatch (error) {',\n\t\t'\t\t\treturn String(value || \"/\").split(\"?\")[0].replace(/\\\\/+$/, \"\") || \"/\";',\n\t\t'\t}',\n\t\t'}',\n\t\t'',\n\t\t'async function assertTargetRoute(page) {',\n\t\t'\tconst expected = normalizeRoutePath(targetRoute);',\n\t\t'\tif (expected === \"/\") {',\n\t\t'\t\treturn;',\n\t\t'\t}',\n\t\t'\tconst current = normalizeRoutePath(await page.evaluate(() => location.href));',\n\t\t'\tif (current !== expected) {',\n\t\t'\t\tconst repaired = await repairPostLoginSetupOrTourGate(page, expected);',\n\t\t'\t\tif (repaired) {',\n\t\t'\t\t\treturn;',\n\t\t'\t\t}',\n\t\t'\t\tconst summary = await pageSummary(page).catch(() => ({}));',\n\t\t'\t\tthrow new Error(`QA auth bootstrap reached ${current}, not requested target route ${expected}. This is a route blocker; do not continue browser QA until the runner/app can reach the requested screen. Page summary: ${JSON.stringify(summary).slice(0, 1200)}`);',\n\t\t'\t}',\n\t\t'}',\n\t\t'',\n\t\t'async function waitForStableTargetRoute(page) {',\n\t\t'\tconst expected = normalizeRoutePath(targetRoute);',\n\t\t'\tif (expected === \"/\") {',\n\t\t'\t\treturn;',\n\t\t'\t}',\n\t\t'\tconst deadline = Date.now() + Number(process.env.RESOLVEIO_RUNNER_QA_ROUTE_STABILITY_TIMEOUT_MS || process.env.RESOLVEIO_SUPPORT_QA_ROUTE_STABILITY_TIMEOUT_MS || 7000);',\n\t\t'\tlet stableSince = 0;',\n\t\t'\tlet lastCurrent = \"\";',\n\t\t'\twhile (Date.now() < deadline) {',\n\t\t'\t\tconst current = normalizeRoutePath(await page.evaluate(() => location.href));',\n\t\t'\t\tlastCurrent = current;',\n\t\t'\t\tif (current === expected) {',\n\t\t'\t\t\tstableSince = stableSince || Date.now();',\n\t\t'\t\t\tif (Date.now() - stableSince >= Number(process.env.RESOLVEIO_RUNNER_QA_ROUTE_STABLE_MS || process.env.RESOLVEIO_SUPPORT_QA_ROUTE_STABLE_MS || 2500)) {',\n\t\t'\t\t\t\treturn;',\n\t\t'\t\t\t}',\n\t\t'\t\t}',\n\t\t'\t\telse {',\n\t\t'\t\t\tstableSince = 0;',\n\t\t'\t\t}',\n\t\t'\t\tawait delay(250);',\n\t\t'\t}',\n\t\t'\tconst summary = await pageSummary(page).catch(() => ({}));',\n\t\t'\tthrow new Error(`QA auth bootstrap route was not stable on requested target ${expected}; last route was ${lastCurrent || \"unknown\"}. This is a route blocker; do not continue browser QA until the runner/app can remain on the requested screen. Page summary: ${JSON.stringify(summary).slice(0, 1200)}`);',\n\t\t'}',\n\t\t'',\n\t\t'async function dismissNavigationOverlays(page) {',\n\t\t'\ttry {',\n\t\t'\t\tawait page.keyboard.press(\"Escape\");',\n\t\t'\t} catch (error) {}',\n\t\t'\ttry {',\n\t\t'\t\tawait page.mouse.move(16, Math.max(120, viewportHeight - 24));',\n\t\t'\t} catch (error) {}',\n\t\t'\ttry {',\n\t\t'\t\tawait page.evaluate(() => {',\n\t\t'\t\t\tif (document.activeElement && typeof document.activeElement.blur === \"function\") document.activeElement.blur();',\n\t\t'\t\t\tdocument.body && document.body.dispatchEvent(new MouseEvent(\"mousemove\", { bubbles: true, clientX: 16, clientY: Math.max(120, window.innerHeight - 24) }));',\n\t\t'\t\t});',\n\t\t'\t} catch (error) {}',\n\t\t'\tawait delay(350);',\n\t\t'}',\n\t\t'',\n\t\t'async function assertSummaryOnTargetRoute(summary) {',\n\t\t'\tconst expected = normalizeRoutePath(targetRoute);',\n\t\t'\tif (expected === \"/\") {',\n\t\t'\t\treturn;',\n\t\t'\t}',\n\t\t'\tconst current = normalizeRoutePath(summary && summary.url || \"\");',\n\t\t'\tif (current !== expected) {',\n\t\t'\t\tthrow new Error(`QA auth bootstrap final summary is on ${current}, not requested target route ${expected}. This is a route blocker; refusing to write a false pass. Page summary: ${JSON.stringify(summary).slice(0, 1200)}`);',\n\t\t'\t}',\n\t\t'}',\n\t\t'',\n\t\t'async function logoutExistingBrowserSession(page) {',\n\t\t'\ttry {',\n\t\t'\t\tawait page.goto(clientUrl, { waitUntil: \"domcontentloaded\", timeout: 45000 });',\n\t\t'\t\tawait delay(500);',\n\t\t'\t\tawait page.evaluate(() => {',\n\t\t'\t\t\tconst controls = Array.from(document.querySelectorAll(\"button, a, [role=\\'button\\']\"));',\n\t\t'\t\t\tconst logoutControl = controls.find((control) => /(^|\\\\s)logout(\\\\s|$)/i.test((control.textContent || \"\").trim()));',\n\t\t'\t\t\tif (logoutControl && typeof logoutControl.click === \"function\") {',\n\t\t'\t\t\t\tlogoutControl.click();',\n\t\t'\t\t\t\treturn true;',\n\t\t'\t\t\t}',\n\t\t'\t\t\treturn false;',\n\t\t'\t\t});',\n\t\t'\t\tawait delay(1000);',\n\t\t'\t}',\n\t\t'\tcatch (error) {}',\n\t\t'}',\n\t\t'',\n\t\t'async function waitForAuthenticatedApp(page) {',\n\t\t'\tconst url = `${clientUrl}${targetRoute}`;',\n\t\t'\tawait page.goto(url, { waitUntil: \"domcontentloaded\", timeout: 60000 });',\n\t\t'\tawait page.waitForFunction(() => {',\n\t\t'\t\tconst text = (document.body && document.body.innerText || \"\").replace(/\\\\s+/g, \" \").trim();',\n\t\t'\t\tconst hasTokens = !!localStorage.getItem(\"refreshToken\") && !!localStorage.getItem(\"accessToken\") && !!localStorage.getItem(\"user\");',\n\t\t'\t\tconst hasLogin = /Employee\\\\/Customer Login|Employee Sign In|Customer Access|Unable to sign in/i.test(text);',\n\t\t'\t\tconst hasOffline = text.includes(\"*** OFFLINE MODE ***\");',\n\t\t'\t\treturn hasTokens && !hasLogin && !hasOffline && text.length > 40;',\n\t\t'\t}, { timeout: Number(process.env.RESOLVEIO_RUNNER_QA_AUTH_TIMEOUT_MS || process.env.RESOLVEIO_SUPPORT_QA_AUTH_TIMEOUT_MS || 60000) });',\n\t\t'\tawait delay(1000);',\n\t\t'\tawait assertTargetRoute(page);',\n\t\t'\tawait waitForStableTargetRoute(page);',\n\t\t'\tawait dismissNavigationOverlays(page);',\n\t\t'}',\n\t\t'',\n\t\t'async function pageSummary(page) {',\n\t\t'\treturn page.evaluate(() => {',\n\t\t'\t\tconst bodyText = (document.body && document.body.innerText || \"\").replace(/\\\\s+/g, \" \").trim();',\n\t\t'\t\treturn {',\n\t\t'\t\t\turl: location.href,',\n\t\t'\t\t\ttitle: document.title,',\n\t\t'\t\t\thasAngularDebug: !!window.ng,',\n\t\t'\t\t\thasRefreshToken: !!localStorage.getItem(\"refreshToken\"),',\n\t\t'\t\t\thasAccessToken: !!localStorage.getItem(\"accessToken\"),',\n\t\t'\t\t\thasUser: !!localStorage.getItem(\"user\"),',\n\t\t'\t\t\thasOfflineModeText: bodyText.includes(\"*** OFFLINE MODE ***\"),',\n\t\t'\t\t\thasLoginText: /Employee\\\\/Customer Login|Employee Sign In|Customer Access|Unable to sign in/i.test(bodyText),',\n\t\t'\t\t\tbodyTextSnippet: bodyText.slice(0, 800),',\n\t\t'\t\t\tlocalStorageKeys: Object.keys(localStorage).sort()',\n\t\t'\t\t};',\n\t\t'\t});',\n\t\t'}',\n\t\t'',\n\t\t'(async () => {',\n\t\t'\tfs.mkdirSync(artifactDir, { recursive: true });',\n\t\t'\tconst puppeteer = requirePuppeteer();',\n\t\t'\tconst browser = await launchBrowser(puppeteer);',\n\t\t'\tlet page;',\n\t\t'\ttry {',\n\t\t'\t\tawait waitForHttpReady(clientUrl, \"QA client\");',\n\t\t'\t\tawait waitForHttpReady(serverUrl, \"QA server\");',\n\t\t'\t\tpage = await browser.newPage();',\n\t\t'\t\tawait page.setViewport({ width: viewportWidth, height: viewportHeight });',\n\t\t'\t\tpage.on(\"console\", (msg) => {',\n\t\t'\t\t\tconst text = msg.text();',\n\t\t'\t\t\tif ([\"error\", \"warning\"].includes(msg.type()) || /error/i.test(text)) {',\n\t\t'\t\t\t\tconsole.log(\"[browser console]\", msg.type(), text);',\n\t\t'\t\t\t}',\n\t\t'\t\t});',\n\t\t'\t\tpage.on(\"pageerror\", (error) => console.log(\"[pageerror]\", error.message));',\n\t\t'\t\tawait logoutExistingBrowserSession(page);',\n\t\t'\t\tawait resetBrowserState(page);',\n\t\t'\t\tconst auth = await login();',\n\t\t'\t\tawait seedAuth(page, auth);',\n\t\t'\t\tawait waitForAuthenticatedApp(page);',\n\t\t'\t\tconst finalPage = await pageSummary(page);',\n\t\t'\t\tawait assertSummaryOnTargetRoute(finalPage);',\n\t\t'\t\tawait page.screenshot({ path: readyScreenshotPath, fullPage: true });',\n\t\t'\t\tconst summary = {',\n\t\t'\t\t\tstatus: \"pass\",',\n\t\t'\t\t\tclientUrl,',\n\t\t'\t\t\tserverUrl,',\n\t\t'\t\t\ttargetRoute,',\n\t\t'\t\t\tscreenshot: readyScreenshotPath,',\n\t\t'\t\t\tuser: { _id: auth.user && auth.user._id, username: auth.user && auth.user.username, fullname: auth.user && auth.user.fullname },',\n\t\t'\t\t\tpage: finalPage',\n\t\t'\t\t};',\n\t\t'\t\twriteResult(summary);',\n\t\t'\t\tconsole.log(JSON.stringify(summary, null, 2));',\n\t\t'\t}',\n\t\t'\tcatch (error) {',\n\t\t'\t\tlet summary = { status: \"fail\", clientUrl, serverUrl, targetRoute, screenshot: failureScreenshotPath, error: error && error.stack || String(error) };',\n\t\t'\t\ttry {',\n\t\t'\t\t\tif (page) {',\n\t\t'\t\t\t\tawait page.screenshot({ path: failureScreenshotPath, fullPage: true });',\n\t\t'\t\t\t\tsummary.page = await pageSummary(page);',\n\t\t'\t\t\t}',\n\t\t'\t\t} catch (screenshotError) {',\n\t\t'\t\t\tsummary.screenshotError = screenshotError && screenshotError.stack || String(screenshotError);',\n\t\t'\t\t}',\n\t\t'\t\twriteResult(summary);',\n\t\t'\t\tconsole.error(JSON.stringify(summary, null, 2));',\n\t\t'\t\tprocess.exitCode = 1;',\n\t\t'\t}',\n\t\t'\tfinally {',\n\t\t'\t\tif (browser && typeof browser.close === \"function\") {',\n\t\t'\t\t\tawait browser.close().catch(() => undefined);',\n\t\t'\t\t}',\n\t\t'\t\tprocess.exit(process.exitCode || 0);',\n\t\t'\t}',\n\t\t'})();',\n\t\t''\n\t].join('\\n');\n}\n"]}
|