@testsprite/testsprite-cli 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -48
- package/dist/commands/doctor.js +12 -11
- package/dist/commands/project-env.d.ts +11 -1
- package/dist/commands/project-env.js +399 -61
- package/dist/commands/project-sign-in.d.ts +60 -0
- package/dist/commands/project-sign-in.js +289 -0
- package/dist/commands/project.d.ts +9 -0
- package/dist/commands/project.js +68 -28
- package/dist/commands/schedule.d.ts +12 -0
- package/dist/commands/schedule.js +175 -5
- package/dist/commands/test.d.ts +53 -20
- package/dist/commands/test.js +1356 -342
- package/dist/commands/testlist.d.ts +10 -5
- package/dist/commands/testlist.js +170 -30
- package/dist/commands/tunnel.js +11 -5
- package/dist/index.js +12 -37
- package/dist/lib/client-factory.d.ts +12 -1
- package/dist/lib/client-factory.js +14 -4
- package/dist/lib/dry-run/samples.js +53 -0
- package/dist/lib/environment-tunnel.d.ts +109 -0
- package/dist/lib/environment-tunnel.js +465 -0
- package/dist/lib/errors.js +12 -1
- package/dist/lib/gh-output.js +3 -0
- package/dist/lib/http.d.ts +2 -0
- package/dist/lib/junit-report.d.ts +11 -7
- package/dist/lib/junit-report.js +13 -7
- package/dist/lib/local-target.d.ts +13 -3
- package/dist/lib/local-target.js +47 -12
- package/dist/lib/output.js +15 -1
- package/dist/lib/plan-poll.js +3 -4
- package/dist/lib/redact.d.ts +38 -0
- package/dist/lib/redact.js +140 -0
- package/dist/lib/render-error.d.ts +19 -5
- package/dist/lib/render-error.js +31 -0
- package/dist/lib/runs.types.d.ts +9 -1
- package/dist/lib/target-url.js +5 -5
- package/dist/lib/telemetry.d.ts +6 -7
- package/dist/lib/telemetry.js +11 -4
- package/dist/lib/testlist.types.d.ts +1 -0
- package/dist/lib/ticker.d.ts +9 -0
- package/dist/lib/ticker.js +18 -0
- package/dist/lib/tunnel-session.d.ts +3 -4
- package/dist/lib/tunnel-session.js +3 -4
- package/dist/lib/v3-advisory.js +0 -1
- package/dist/vendor/tunnel-client/client.d.ts +15 -8
- package/dist/vendor/tunnel-client/client.js +477 -407
- package/dist/vendor/tunnel-client/config.d.ts +5 -5
- package/dist/vendor/tunnel-client/config.js +5 -5
- package/dist/vendor/tunnel-client/index.d.ts +4 -4
- package/dist/vendor/tunnel-client/index.js +4 -4
- package/dist/vendor/tunnel-client/types.d.ts +19 -34
- package/dist/vendor/tunnel-client/types.js +1 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +13 -3
- package/dist/vendor/tunnel-client/ws-compat.js +70 -12
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/testsprite-onboard.skill.md +4 -4
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { type EnvironmentTunnelContext } from '../lib/environment-tunnel.js';
|
|
2
|
+
import { type ShutdownHandle } from '../lib/interrupt.js';
|
|
3
|
+
import type { TunnelClientOptions } from '../vendor/tunnel-client/index.js';
|
|
4
|
+
import type { TunnelClientHandle } from '../lib/tunnel-session.js';
|
|
1
5
|
import { Command } from 'commander';
|
|
2
6
|
import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
|
|
3
7
|
import { type FetchImpl } from '../lib/http.js';
|
|
4
8
|
import { type JUnitReportFormat } from '../lib/junit-report.js';
|
|
5
9
|
import type { CliDeleteTestListResponse, CliTestList, CliTestListDetail, CliTestListRunResponse } from '../lib/testlist.types.js';
|
|
6
10
|
export interface TestListDeps {
|
|
11
|
+
shutdown?: ShutdownHandle;
|
|
12
|
+
createTunnelClient?: (options: TunnelClientOptions) => TunnelClientHandle;
|
|
13
|
+
environmentTunnel?: EnvironmentTunnelContext;
|
|
7
14
|
env?: NodeJS.ProcessEnv;
|
|
8
15
|
credentialsPath?: string;
|
|
9
16
|
fetchImpl?: FetchImpl;
|
|
@@ -60,6 +67,9 @@ export declare function waitRequestTimeoutMs(opts: {
|
|
|
60
67
|
requestTimeoutMs?: number;
|
|
61
68
|
}): number | undefined;
|
|
62
69
|
export interface RunTestlistRunOptions extends CommonOptions {
|
|
70
|
+
noWait?: boolean;
|
|
71
|
+
skipPreflight?: boolean;
|
|
72
|
+
concurrencyIsDefault?: boolean;
|
|
63
73
|
listId: string;
|
|
64
74
|
/** --case (repeatable): run only this subset of the list's cases (== test ids). */
|
|
65
75
|
cases?: string[];
|
|
@@ -78,11 +88,6 @@ export interface RunTestlistRunOptions extends CommonOptions {
|
|
|
78
88
|
/** --summary-file: also write the reduced machine summary JSON to this path. */
|
|
79
89
|
summaryFile?: string;
|
|
80
90
|
}
|
|
81
|
-
/**
|
|
82
|
-
* `testlist run` — dispatch the list's cases (optionally a `--case` subset) and,
|
|
83
|
-
* with `--wait`, poll every returned runId to a verdict, optionally writing a
|
|
84
|
-
* JUnit XML report (`--report junit`). testlist run is V3-only.
|
|
85
|
-
*/
|
|
86
91
|
export declare function runTestlistRun(opts: RunTestlistRunOptions, deps?: TestListDeps): Promise<CliTestListRunResponse>;
|
|
87
92
|
export declare function createTestListCommand(deps?: TestListDeps): Command;
|
|
88
93
|
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { TunnelLostError } from '../lib/tunnel-session.js';
|
|
2
|
+
import { resolveEnvironmentRunTarget, readEnvironmentPreflight, groupEnvironmentTargets, emitEnvironmentDispatchPartial, withEnvironmentTunnel, } from '../lib/environment-tunnel.js';
|
|
3
|
+
import { globalShutdown } from '../lib/interrupt.js';
|
|
1
4
|
import { randomUUID } from 'node:crypto';
|
|
2
5
|
import { Command } from 'commander';
|
|
3
6
|
import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
|
|
@@ -11,7 +14,7 @@ import { billingConflictLink, describeConflict, insufficientCreditsConflictError
|
|
|
11
14
|
import { recordBatchOutcome } from '../lib/telemetry.js';
|
|
12
15
|
import { formatRunProgressLine } from '../lib/run-progress.js';
|
|
13
16
|
import { createTicker } from '../lib/ticker.js';
|
|
14
|
-
import { buildJUnitReport, parseJUnitReportFormat, skippedJUnitResultsFromSummary, writeJUnitReportFile, } from '../lib/junit-report.js';
|
|
17
|
+
import { buildJUnitReport, durationSecondsBetween, parseJUnitReportFormat, skippedJUnitResultsFromSummary, writeJUnitReportFile, } from '../lib/junit-report.js';
|
|
15
18
|
import { renderTextTable, resolveTextColumns } from '../lib/text-table.js';
|
|
16
19
|
import { assertIdempotencyKey } from '../lib/validate.js';
|
|
17
20
|
import { resolveWaitFailure, waitMemberError } from '../lib/wait-exit.js';
|
|
@@ -289,9 +292,7 @@ function assertNoNotFound(resp) {
|
|
|
289
292
|
* with `--wait`, poll every returned runId to a verdict, optionally writing a
|
|
290
293
|
* JUnit XML report (`--report junit`). testlist run is V3-only.
|
|
291
294
|
*/
|
|
292
|
-
|
|
293
|
-
const out = makeOutput(opts.output, deps);
|
|
294
|
-
const stderrFn = deps.stderr ?? (line => process.stderr.write(`${line}\n`));
|
|
295
|
+
function validateTestlistRunOptions(opts) {
|
|
295
296
|
if (opts.idempotencyKey !== undefined)
|
|
296
297
|
assertIdempotencyKey(opts.idempotencyKey);
|
|
297
298
|
if (!Number.isInteger(opts.maxConcurrency) ||
|
|
@@ -316,6 +317,74 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
316
317
|
if (opts.summaryFile !== undefined && !opts.wait) {
|
|
317
318
|
throw localValidationError('summary-file', '--summary-file requires --wait (it reduces the terminal run result). Add --wait.');
|
|
318
319
|
}
|
|
320
|
+
}
|
|
321
|
+
export async function runTestlistRun(opts, deps = {}) {
|
|
322
|
+
validateTestlistRunOptions({ ...opts, wait: opts.wait || (!opts.dryRun && !opts.noWait) });
|
|
323
|
+
if (opts.dryRun || deps.environmentTunnel)
|
|
324
|
+
return runTestlistRunCore(opts, deps);
|
|
325
|
+
let client;
|
|
326
|
+
try {
|
|
327
|
+
client = makeClient(opts, deps);
|
|
328
|
+
}
|
|
329
|
+
catch (err) {
|
|
330
|
+
validateTestlistRunOptions(opts);
|
|
331
|
+
throw err;
|
|
332
|
+
}
|
|
333
|
+
const stderr = deps.stderr ?? (line => process.stderr.write(`${line}\n`));
|
|
334
|
+
let list;
|
|
335
|
+
try {
|
|
336
|
+
list = await readEnvironmentPreflight(client, `/testlist/${encodeURIComponent(opts.listId)}`);
|
|
337
|
+
}
|
|
338
|
+
catch (err) {
|
|
339
|
+
if (err instanceof InterruptError)
|
|
340
|
+
throw err;
|
|
341
|
+
return runTestlistRunCore(opts, deps);
|
|
342
|
+
}
|
|
343
|
+
const targets = new Map();
|
|
344
|
+
const backend = [];
|
|
345
|
+
const cache = new Map();
|
|
346
|
+
for (const test of list.cases ?? []) {
|
|
347
|
+
if (opts.cases?.length && !opts.cases.includes(test.testId))
|
|
348
|
+
continue;
|
|
349
|
+
const environment = list.projectEnvironments?.find(row => row.projectId === test.projectId)?.environmentName;
|
|
350
|
+
const target = await resolveEnvironmentRunTarget({
|
|
351
|
+
client,
|
|
352
|
+
testId: test.testId,
|
|
353
|
+
knownTest: test,
|
|
354
|
+
includeBackend: true,
|
|
355
|
+
environment,
|
|
356
|
+
noWait: opts.noWait,
|
|
357
|
+
verbose: opts.verbose || opts.debug,
|
|
358
|
+
stderr,
|
|
359
|
+
cache,
|
|
360
|
+
});
|
|
361
|
+
if (target && test.type === 'backend')
|
|
362
|
+
backend.push({ testId: test.testId, reason: 'backend-test' });
|
|
363
|
+
else if (target)
|
|
364
|
+
targets.set(test.testId, target);
|
|
365
|
+
}
|
|
366
|
+
if (!targets.size)
|
|
367
|
+
return runTestlistRunCore(opts, deps);
|
|
368
|
+
const maxConcurrency = opts.concurrencyIsDefault ? 5 : opts.maxConcurrency;
|
|
369
|
+
if (maxConcurrency > 10)
|
|
370
|
+
throw localValidationError('max-concurrency', 'tunnel runs support at most 10 concurrent runs (default 5)');
|
|
371
|
+
if (backend.length)
|
|
372
|
+
stderr(`[advisory] ${backend.length} backend test(s) skipped — tunnel runs frontend tests only.`);
|
|
373
|
+
const cases = (list.cases ?? [])
|
|
374
|
+
.filter(test => !backend.some(row => row.testId === test.testId) &&
|
|
375
|
+
(!opts.cases?.length || opts.cases.includes(test.testId)))
|
|
376
|
+
.map(test => test.testId);
|
|
377
|
+
cases.push(...(opts.cases ?? []).filter(id => !list.cases?.some(test => test.testId === id)));
|
|
378
|
+
return withEnvironmentTunnel({ ...opts, maxConcurrency, requestTimeoutMs: waitRequestTimeoutMs({ ...opts, wait: true }) }, deps, [...targets.values()], 'testlist run', context => {
|
|
379
|
+
context.targets = targets;
|
|
380
|
+
context.skipped = backend;
|
|
381
|
+
return runTestlistRunCore({ ...opts, cases, wait: true, maxConcurrency }, { ...deps, environmentTunnel: context });
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
async function runTestlistRunCore(opts, deps = {}) {
|
|
385
|
+
validateTestlistRunOptions(opts);
|
|
386
|
+
const out = makeOutput(opts.output, deps);
|
|
387
|
+
const stderrFn = deps.stderr ?? (line => process.stderr.write(`${line}\n`));
|
|
319
388
|
const idempotencyKey = opts.idempotencyKey ?? `cli-testlist-run-${randomUUID()}`;
|
|
320
389
|
emitIdempotencyKey(opts, deps, idempotencyKey, opts.idempotencyKey);
|
|
321
390
|
if (opts.dryRun) {
|
|
@@ -325,8 +394,51 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
325
394
|
return sample;
|
|
326
395
|
}
|
|
327
396
|
// Under --wait, raise the per-request timeout to cover --timeout (see helper).
|
|
328
|
-
const client =
|
|
329
|
-
|
|
397
|
+
const client = deps.environmentTunnel?.client ??
|
|
398
|
+
makeClient({ ...opts, requestTimeoutMs: waitRequestTimeoutMs(opts) }, deps);
|
|
399
|
+
let resp;
|
|
400
|
+
if (deps.environmentTunnel) {
|
|
401
|
+
const targets = deps.environmentTunnel.targets;
|
|
402
|
+
const groups = groupEnvironmentTargets(opts.cases ?? [...targets.keys()], targets, deps.environmentTunnel.maxConcurrency);
|
|
403
|
+
const responses = [];
|
|
404
|
+
try {
|
|
405
|
+
for (const [index, testIds] of groups.entries()) {
|
|
406
|
+
const target = targets.get(testIds[0]);
|
|
407
|
+
const suffix = groups.length > 1 ? `:group${index}` : '';
|
|
408
|
+
if (target)
|
|
409
|
+
await deps.environmentTunnel.waitForCapacity(testIds.length);
|
|
410
|
+
const response = await client.triggerTestListRun(opts.listId, {
|
|
411
|
+
testIds,
|
|
412
|
+
...(target
|
|
413
|
+
? { targetUrl: target.targetUrl, tunnelClientId: deps.environmentTunnel.clientId }
|
|
414
|
+
: {}),
|
|
415
|
+
}, { idempotencyKey: `${idempotencyKey.slice(0, 256 - suffix.length)}${suffix}` });
|
|
416
|
+
responses.push(response);
|
|
417
|
+
if (target)
|
|
418
|
+
await deps.environmentTunnel.confirm(response, response.accepted.map(row => row.runId));
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
catch (err) {
|
|
422
|
+
if (responses.length)
|
|
423
|
+
await emitEnvironmentDispatchPartial(responses, groups.flat(), opts, deps, 'testlist', err, deps.environmentTunnel);
|
|
424
|
+
throw err;
|
|
425
|
+
}
|
|
426
|
+
resp = {
|
|
427
|
+
...responses[0],
|
|
428
|
+
...(deps.environmentTunnel.skipped?.length
|
|
429
|
+
? { skipped: deps.environmentTunnel.skipped }
|
|
430
|
+
: {}),
|
|
431
|
+
accepted: responses.flatMap(row => row.accepted),
|
|
432
|
+
conflicts: responses.flatMap(row => row.conflicts),
|
|
433
|
+
deferred: responses.flatMap(row => row.deferred),
|
|
434
|
+
...(responses.some(row => row.notFound)
|
|
435
|
+
? { notFound: responses.flatMap(row => row.notFound ?? []) }
|
|
436
|
+
: {}),
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
resp = await client.triggerTestListRun(opts.listId, opts.cases && opts.cases.length > 0 ? { testIds: opts.cases } : {}, { idempotencyKey });
|
|
441
|
+
}
|
|
330
442
|
// Partial `--case` miss: some ids were not members of this list. The matched
|
|
331
443
|
// subset still dispatched; a FULL miss is a 404 upstream and never reaches
|
|
332
444
|
// here. Warn on stderr so JSON stdout stays the machine payload (the ids are
|
|
@@ -428,8 +540,9 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
428
540
|
// empty-suite report rather than nothing.
|
|
429
541
|
// --- --wait fan-out ---
|
|
430
542
|
const ticker = createTicker(stderrFn, opts.output === 'json' ? false : undefined);
|
|
431
|
-
const batchDeadlineMs = Date.now() + opts.timeoutSeconds * 1000;
|
|
543
|
+
const batchDeadlineMs = deps.environmentTunnel?.deadlineMs ?? Date.now() + opts.timeoutSeconds * 1000;
|
|
432
544
|
const results = [];
|
|
545
|
+
const reportDurations = new Map();
|
|
433
546
|
async function pollOne(entry) {
|
|
434
547
|
const remainingMs = batchDeadlineMs - Date.now();
|
|
435
548
|
if (remainingMs <= 0) {
|
|
@@ -452,8 +565,13 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
452
565
|
timeoutSeconds: Math.ceil(remainingMs / 1000),
|
|
453
566
|
sleep: deps.sleep,
|
|
454
567
|
onTransition: opts.verbose ? (msg) => stderrFn(`[verbose] ${msg}`) : undefined,
|
|
455
|
-
|
|
568
|
+
shutdown: deps.shutdown ?? globalShutdown,
|
|
569
|
+
onTick: (run, elapsedMs) => {
|
|
570
|
+
deps.environmentTunnel?.onPoll(run);
|
|
571
|
+
ticker.update(formatRunProgressLine(run, elapsedMs, `(${entry.testId})`));
|
|
572
|
+
},
|
|
456
573
|
});
|
|
574
|
+
reportDurations.set(entry.runId, durationSecondsBetween(finalRun.startedAt, finalRun.finishedAt, finalRun.createdAt));
|
|
457
575
|
return {
|
|
458
576
|
testId: entry.testId,
|
|
459
577
|
testTitle: finalRun.testTitle ?? null,
|
|
@@ -478,6 +596,8 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
478
596
|
};
|
|
479
597
|
}
|
|
480
598
|
catch (err) {
|
|
599
|
+
if (deps.environmentTunnel && err instanceof TunnelLostError)
|
|
600
|
+
throw err;
|
|
481
601
|
if (err instanceof TimeoutError) {
|
|
482
602
|
return {
|
|
483
603
|
testId: entry.testId,
|
|
@@ -519,32 +639,41 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
519
639
|
// `runTestRunAll`'s inline driver rather than extracting a shared helper).
|
|
520
640
|
let pollIdx = 0;
|
|
521
641
|
let inFlight = 0;
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
642
|
+
try {
|
|
643
|
+
await new Promise((resolve, reject) => {
|
|
644
|
+
function startNext() {
|
|
645
|
+
while (inFlight < opts.maxConcurrency && pollIdx < resp.accepted.length) {
|
|
646
|
+
const entry = resp.accepted[pollIdx++];
|
|
647
|
+
inFlight++;
|
|
648
|
+
pollOne(entry)
|
|
649
|
+
.then(r => {
|
|
650
|
+
results.push(r);
|
|
651
|
+
inFlight--;
|
|
652
|
+
startNext();
|
|
653
|
+
if (inFlight === 0 && pollIdx >= resp.accepted.length)
|
|
654
|
+
resolve();
|
|
655
|
+
})
|
|
656
|
+
.catch(reject);
|
|
657
|
+
}
|
|
536
658
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
659
|
+
startNext();
|
|
660
|
+
if (resp.accepted.length === 0)
|
|
661
|
+
resolve();
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
catch (err) {
|
|
665
|
+
ticker.finalize();
|
|
666
|
+
if (deps.environmentTunnel)
|
|
667
|
+
await emitEnvironmentDispatchPartial([resp], resp.accepted.map(row => row.testId), opts, deps, 'testlist', err, deps.environmentTunnel);
|
|
668
|
+
throw err;
|
|
669
|
+
}
|
|
542
670
|
ticker.finalize();
|
|
543
671
|
const passed = results.filter(r => r.status === 'passed').length;
|
|
544
672
|
const failed = results.filter(r => r.status !== 'passed' && r.status !== 'timeout').length;
|
|
545
673
|
const timedOut = results.filter(r => r.status === 'timeout').length;
|
|
546
674
|
stderrFn(`Test-list run complete: ${passed}/${resp.accepted.length} passed, ${failed} failed/blocked, ${timedOut} timed out`);
|
|
547
675
|
const jsonPayload = {
|
|
676
|
+
...(deps.environmentTunnel?.skipped?.length ? { skipped: deps.environmentTunnel.skipped } : {}),
|
|
548
677
|
accepted: results,
|
|
549
678
|
conflicts: resp.conflicts,
|
|
550
679
|
deferred: resp.deferred,
|
|
@@ -575,7 +704,13 @@ export async function runTestlistRun(opts, deps = {}) {
|
|
|
575
704
|
const xml = buildJUnitReport({
|
|
576
705
|
suiteName,
|
|
577
706
|
classname: `testlist:${opts.listId}`,
|
|
578
|
-
results: [
|
|
707
|
+
results: [
|
|
708
|
+
...results.map(r => ({
|
|
709
|
+
...r,
|
|
710
|
+
durationSeconds: r.runId ? reportDurations.get(r.runId) : undefined,
|
|
711
|
+
})),
|
|
712
|
+
...skippedJUnitResultsFromSummary(summary, results),
|
|
713
|
+
],
|
|
579
714
|
});
|
|
580
715
|
await writeJUnitReportFile(opts.reportFile, xml);
|
|
581
716
|
}
|
|
@@ -775,11 +910,13 @@ export function createTestListCommand(deps = {}) {
|
|
|
775
910
|
});
|
|
776
911
|
testlist
|
|
777
912
|
.command('run <list-id>')
|
|
778
|
-
.description('Run a test list (dispatch its cases and return pollable run ids)')
|
|
913
|
+
.description('Run a test list (dispatch its cases and return pollable run ids). Loopback environments open a tunnel automatically and wait.')
|
|
779
914
|
.option('--case <test-id>', 'run only this case (repeatable; default: every case in the list)', collectRepeatable, [])
|
|
780
915
|
.option('--wait', 'poll every dispatched run until terminal or --timeout', false)
|
|
916
|
+
.option('--no-wait', 'detach without opening an automatic environment tunnel')
|
|
917
|
+
.option('--skip-preflight', 'skip the loopback port probe before opening a tunnel')
|
|
781
918
|
.option('--timeout <s>', 'with --wait, max seconds to wait (1–3600, default 600)')
|
|
782
|
-
.option('--max-concurrency <n>', `with
|
|
919
|
+
.option('--max-concurrency <n>', `with a tunnel, max runs in flight (1-10, default 5); otherwise with --wait, max polls (1-${MAX_TESTLIST_RUN_CONCURRENCY}, default ${DEFAULT_TESTLIST_RUN_CONCURRENCY})`)
|
|
783
920
|
.option('--idempotency-key <key>', 'caller-supplied idempotency key (1-256 chars)')
|
|
784
921
|
.option('--report <format>', 'with --wait: write a JUnit XML sidecar after polling (accepted: junit)')
|
|
785
922
|
.option('--report-file <path>', 'output path for --report (atomic write)')
|
|
@@ -794,6 +931,9 @@ export function createTestListCommand(deps = {}) {
|
|
|
794
931
|
listId,
|
|
795
932
|
cases: cmdOpts.case,
|
|
796
933
|
wait,
|
|
934
|
+
noWait: command.getOptionValueSource('wait') === 'cli' && cmdOpts.wait === false,
|
|
935
|
+
skipPreflight: cmdOpts.skipPreflight === true,
|
|
936
|
+
concurrencyIsDefault: cmdOpts.maxConcurrency === undefined,
|
|
797
937
|
timeoutSeconds: parseTestlistTimeoutFlag(cmdOpts.timeout),
|
|
798
938
|
maxConcurrency: parseTestlistConcurrencyFlag(cmdOpts.maxConcurrency),
|
|
799
939
|
idempotencyKey: cmdOpts.idempotencyKey,
|
package/dist/commands/tunnel.js
CHANGED
|
@@ -264,7 +264,7 @@ export async function runTunnelStart(opts, deps = {}) {
|
|
|
264
264
|
`expiresAt ${d.expiresAt}`,
|
|
265
265
|
`status online`,
|
|
266
266
|
`transport ${d.transport}`,
|
|
267
|
-
`hint Attach a run: testsprite test run <test-id> --
|
|
267
|
+
`hint Attach a run: testsprite test run <test-id> --env <name> --tunnel-client ${d.clientId}`,
|
|
268
268
|
`hint Stop it: press Ctrl-C here, or run 'testsprite tunnel stop ${d.clientId}' from another terminal`,
|
|
269
269
|
].join('\n');
|
|
270
270
|
});
|
|
@@ -551,15 +551,15 @@ export async function runTunnelStop(opts, deps = {}) {
|
|
|
551
551
|
export function createTunnelCommand(deps = {}) {
|
|
552
552
|
const tunnel = new Command('tunnel')
|
|
553
553
|
.description('Open a tunnel so TestSprite can reach an app on this machine')
|
|
554
|
-
.addHelpText('after', '\
|
|
555
|
-
'
|
|
554
|
+
.addHelpText('after', '\nFrontend runs automatically open and close a tunnel when the selected environment URL\n' +
|
|
555
|
+
'is on this machine. Use these commands when you want one tunnel to serve several runs, or to check on\n' +
|
|
556
556
|
'one that a run reported as down.\n' +
|
|
557
557
|
'\nA tunnel lives only as long as `tunnel start` is running — there is no background\n' +
|
|
558
558
|
'daemon, because the credential that authorises an inbound network path into this machine\n' +
|
|
559
559
|
'is never written to disk.\n' +
|
|
560
560
|
'\nExamples:\n' +
|
|
561
561
|
' testsprite tunnel start # hold a tunnel open (Ctrl-C to stop)\n' +
|
|
562
|
-
' testsprite test run <id> --
|
|
562
|
+
' testsprite test run <id> --env <name> --tunnel-client <id>\n' +
|
|
563
563
|
' testsprite tunnel list\n' +
|
|
564
564
|
' testsprite tunnel status <id>\n' +
|
|
565
565
|
' testsprite tunnel stop <id>\n' +
|
|
@@ -574,7 +574,10 @@ export function createTunnelCommand(deps = {}) {
|
|
|
574
574
|
'credential is deleted when the command exits regardless — the lifetime only matters if ' +
|
|
575
575
|
'this process is killed without cleaning up.')
|
|
576
576
|
.addHelpText('after', '\nPrints the client id to stderr as soon as it is minted, before connecting; pass it\n' +
|
|
577
|
-
'to `test run --
|
|
577
|
+
'to `test run <id> --env <name> --tunnel-client <id>` for an environment on this machine.\n' +
|
|
578
|
+
'Frontend runs normally open their own tunnel automatically for a loopback environment URL.\n' +
|
|
579
|
+
'\nDev servers can take a minute per page through the tunnel. For a heavy dev server,\n' +
|
|
580
|
+
"test a built server: `npm run build`, then your framework's preview/start command.\n" +
|
|
578
581
|
'\nExit codes:\n' +
|
|
579
582
|
' 0 you stopped it (Ctrl-C is the normal way to end this command)\n' +
|
|
580
583
|
' 3 auth error — the key needs the `run:tunnel` scope; mint a new key\n' +
|
|
@@ -592,6 +595,7 @@ export function createTunnelCommand(deps = {}) {
|
|
|
592
595
|
.command('list')
|
|
593
596
|
.description('List live tunnel bindings for this account')
|
|
594
597
|
.addHelpText('after', '\nShows each tunnel client id, connection status, creation time and expiry.\n' +
|
|
598
|
+
'Includes tunnels automatically opened for environments on this machine.\n' +
|
|
595
599
|
'\nExit codes:\n' +
|
|
596
600
|
' 0 listed (possibly empty)\n' +
|
|
597
601
|
' 3 auth error — the key needs the `run:tunnel` scope\n' +
|
|
@@ -606,6 +610,7 @@ export function createTunnelCommand(deps = {}) {
|
|
|
606
610
|
.description('Report whether a tunnel client of yours is connected')
|
|
607
611
|
.addHelpText('after', '\n`offline` means the API answered and said nothing is connected with that id. A failure\n' +
|
|
608
612
|
'to reach TestSprite is reported as its own error, never as `offline`.\n' +
|
|
613
|
+
'Use the client id printed by a run that automatically opened a tunnel.\n' +
|
|
609
614
|
'\nExit codes:\n' +
|
|
610
615
|
' 0 answered (the answer may be `offline`)\n' +
|
|
611
616
|
' 4 no such tunnel for this account\n' +
|
|
@@ -621,6 +626,7 @@ export function createTunnelCommand(deps = {}) {
|
|
|
621
626
|
.option('--confirm', 'required with --all for this destructive operation', false)
|
|
622
627
|
.addHelpText('after', '\nStopping one that is already gone succeeds. Revoking the credential\n' +
|
|
623
628
|
'also makes a running `tunnel start` exit within ~15 s.\n' +
|
|
629
|
+
'A run that automatically opened this tunnel loses access to its environment when you stop it.\n' +
|
|
624
630
|
'Stopping all requires --confirm; --dry-run previews sample ids without it.\n' +
|
|
625
631
|
'\nExit codes:\n' +
|
|
626
632
|
' 0 stopped (or already absent), including an empty --all result\n' +
|
package/dist/index.js
CHANGED
|
@@ -19,9 +19,10 @@ import { ApiError, CLIError, InterruptError, RequestTimeoutError, extractNodeErr
|
|
|
19
19
|
import { armInterruptExitBackstop, installBrokenPipeGuard, installSignalHandlers, } from './lib/interrupt.js';
|
|
20
20
|
import { Output, isOutputMode } from './lib/output.js';
|
|
21
21
|
import { maybeInstallProxyAgent } from './lib/proxy.js';
|
|
22
|
-
import {
|
|
22
|
+
import { redactDeep } from './lib/redact.js';
|
|
23
|
+
import { buildInterruptEnvelope, renderAmbiguousOrgCandidates, renderTunnelBindingLimitIds, renderCommanderError, rephraseUnknownOption, } from './lib/render-error.js';
|
|
23
24
|
import { isPlanTemplateInvocation, maybeEmitSkillNudge } from './lib/skill-nudge.js';
|
|
24
|
-
import { classifyCliError, isTelemetryOptedOut, recordOutcome, resolveTelemetryAuth, } from './lib/telemetry.js';
|
|
25
|
+
import { classifyCliError, isTelemetryOptedOut, recordOutcome, recordTelemetryExtras, resolveTelemetryAuth, } from './lib/telemetry.js';
|
|
25
26
|
import { maybeNotifyUpdate } from './lib/update-check.js';
|
|
26
27
|
import { VERSION } from './version.js';
|
|
27
28
|
import { rejectUnsupportedNodeVersion } from './version-guard.js';
|
|
@@ -119,12 +120,6 @@ let telemetryEmit = false;
|
|
|
119
120
|
// Auth resolved in the preAction hook, before the command's action runs, so
|
|
120
121
|
// `auth remove` (which deletes the profile) is still reported on the key it used.
|
|
121
122
|
let telemetryAuth;
|
|
122
|
-
// True when the leaf command that is about to run carries a `--local` option
|
|
123
|
-
// value — `test run --local <port>` or `project create --local <port>`.
|
|
124
|
-
// Set before validation so test-run refusals still report attempts that a
|
|
125
|
-
// backend-side mint/attach event never observes. Local project admission
|
|
126
|
-
// failures have a separate zero-HTTP exception below.
|
|
127
|
-
let telemetryLocal = false;
|
|
128
123
|
// Local project admission failures must exit without any TestSprite HTTP,
|
|
129
124
|
// including telemetry. Track companion flags even when --local is missing.
|
|
130
125
|
let telemetryLocalProject = false;
|
|
@@ -205,9 +200,10 @@ program.hook('preAction', (_thisCommand, actionCommand) => {
|
|
|
205
200
|
const commandPath = commandPathOf(actionCommand);
|
|
206
201
|
// Record which leaf command ran, for the telemetry emit around parseAsync.
|
|
207
202
|
ranCommandPath = commandPath;
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
|
|
203
|
+
// Preserve explicit --local attempts, including refusals and borrowed tunnels;
|
|
204
|
+
// only flag presence is recorded. Automatic tunnel paths record the same fact.
|
|
205
|
+
if (globals.local !== undefined)
|
|
206
|
+
recordTelemetryExtras({ local: true });
|
|
211
207
|
telemetryLocalProject =
|
|
212
208
|
commandPath === 'project create' &&
|
|
213
209
|
(globals.local !== undefined || globals.localHost !== undefined);
|
|
@@ -277,7 +273,6 @@ try {
|
|
|
277
273
|
exitCode: 0,
|
|
278
274
|
durationMs: Date.now() - telemetryStartedAt,
|
|
279
275
|
...telemetryGlobals(),
|
|
280
|
-
local: telemetryLocal,
|
|
281
276
|
}, { resolvedAuth: telemetryAuth });
|
|
282
277
|
}
|
|
283
278
|
}
|
|
@@ -312,7 +307,6 @@ catch (err) {
|
|
|
312
307
|
...waitTimeoutTelemetry,
|
|
313
308
|
durationMs: Date.now() - telemetryStartedAt,
|
|
314
309
|
...telemetryGlobals(),
|
|
315
|
-
local: telemetryLocal,
|
|
316
310
|
}, { resolvedAuth: telemetryAuth });
|
|
317
311
|
}
|
|
318
312
|
process.exitCode = code;
|
|
@@ -333,7 +327,10 @@ catch (err) {
|
|
|
333
327
|
message,
|
|
334
328
|
nextAction: err.nextAction,
|
|
335
329
|
requestId: err.requestId,
|
|
336
|
-
|
|
330
|
+
// `err.details` is already redacted at ApiError construction (see
|
|
331
|
+
// `errors.ts`); redacting again here is defence in depth for this
|
|
332
|
+
// hand-built envelope specifically, independent of that.
|
|
333
|
+
details: redactDeep(err.details),
|
|
337
334
|
...(billingRefusal ? { links: billingRefusal.links } : {}),
|
|
338
335
|
},
|
|
339
336
|
};
|
|
@@ -391,29 +388,7 @@ catch (err) {
|
|
|
391
388
|
// A disarmed request has no run ID, so its JSON hint describes checking
|
|
392
389
|
// current state before retrying. Both use the conventional 128+signum code.
|
|
393
390
|
if (mode === 'json') {
|
|
394
|
-
|
|
395
|
-
.tunnelDetach;
|
|
396
|
-
const envelope = {
|
|
397
|
-
error: {
|
|
398
|
-
code: 'INTERRUPTED',
|
|
399
|
-
message: err.message,
|
|
400
|
-
nextAction: tunnelDetach?.nextAction ??
|
|
401
|
-
(err.runWaitContext
|
|
402
|
-
? 'The server-side run (if any) keeps executing and billing. ' +
|
|
403
|
-
'Re-attach with: testsprite test wait <runId>, or stop it with: testsprite test cancel <runId> ' +
|
|
404
|
-
'(runId is in the partial JSON on stdout).'
|
|
405
|
-
: 'The request was interrupted. Check the current state before retrying; ' +
|
|
406
|
-
'a multi-item command may have processed some items.'),
|
|
407
|
-
requestId: 'local',
|
|
408
|
-
details: {
|
|
409
|
-
signal: err.signal,
|
|
410
|
-
...(tunnelDetach
|
|
411
|
-
? { runId: tunnelDetach.runId, cancelOutcome: tunnelDetach.cancel }
|
|
412
|
-
: {}),
|
|
413
|
-
},
|
|
414
|
-
},
|
|
415
|
-
};
|
|
416
|
-
process.stderr.write(`${JSON.stringify(envelope, null, 2)}\n`);
|
|
391
|
+
process.stderr.write(`${JSON.stringify(buildInterruptEnvelope(err), null, 2)}\n`);
|
|
417
392
|
}
|
|
418
393
|
else {
|
|
419
394
|
process.stderr.write(`Error: ${err.message}\n`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FetchImpl, HttpClientOptions } from './http.js';
|
|
1
|
+
import type { DebugEvent, FetchImpl, HttpClientOptions } from './http.js';
|
|
2
2
|
import { HttpClient } from './http.js';
|
|
3
3
|
import { type ShutdownHandle } from './interrupt.js';
|
|
4
4
|
import type { OutputMode } from './output.js';
|
|
@@ -148,3 +148,14 @@ export declare function makeHttpClient(opts: CommonOptions, deps?: ClientFactory
|
|
|
148
148
|
export type HttpClientFactory = (overrides?: Pick<HttpClientOptions, 'requestTimeoutMs' | 'shutdownSignal'>) => HttpClient;
|
|
149
149
|
/** Resolve the profile once so related requests share an identity and endpoint. */
|
|
150
150
|
export declare function createHttpClientFactory(opts: CommonOptions, deps?: ClientFactoryDeps): HttpClientFactory;
|
|
151
|
+
/**
|
|
152
|
+
* `DebugEvent` today carries only method/url/attempt/status/errorCode/
|
|
153
|
+
* durationMs/requestId/delayMs — no headers or body — so there is nothing to
|
|
154
|
+
* redact in the current shape. This still routes through `redactDeep` so a
|
|
155
|
+
* future field (request/response headers or body added to `DebugEvent` for
|
|
156
|
+
* richer `--debug` tracing) is protected from day one rather than needing a
|
|
157
|
+
* second fix when that lands. Exported for direct unit coverage of that
|
|
158
|
+
* forward-compatibility contract.
|
|
159
|
+
*/
|
|
160
|
+
export declare function formatDebug(event: DebugEvent): string;
|
|
161
|
+
export declare function formatDryRunDebug(event: DebugEvent): string;
|
|
@@ -20,6 +20,7 @@ import { facadeBaseUrl } from './facade.js';
|
|
|
20
20
|
import { HttpClient, REQUEST_TIMEOUT_DEFAULT_MS, REQUEST_TIMEOUT_MAX_MS, REQUEST_TIMEOUT_MIN_MS, } from './http.js';
|
|
21
21
|
import { globalShutdown } from './interrupt.js';
|
|
22
22
|
import { createDryRunFetch } from './dry-run/fetch.js';
|
|
23
|
+
import { redactDeep } from './redact.js';
|
|
23
24
|
import { noteServerVersion } from './version-notice.js';
|
|
24
25
|
import { VERSION } from '../version.js';
|
|
25
26
|
/**
|
|
@@ -277,10 +278,19 @@ function resolveHttpClientOptions(opts, deps) {
|
|
|
277
278
|
shutdown: deps.shutdown ?? globalShutdown,
|
|
278
279
|
};
|
|
279
280
|
}
|
|
280
|
-
|
|
281
|
-
|
|
281
|
+
/**
|
|
282
|
+
* `DebugEvent` today carries only method/url/attempt/status/errorCode/
|
|
283
|
+
* durationMs/requestId/delayMs — no headers or body — so there is nothing to
|
|
284
|
+
* redact in the current shape. This still routes through `redactDeep` so a
|
|
285
|
+
* future field (request/response headers or body added to `DebugEvent` for
|
|
286
|
+
* richer `--debug` tracing) is protected from day one rather than needing a
|
|
287
|
+
* second fix when that lands. Exported for direct unit coverage of that
|
|
288
|
+
* forward-compatibility contract.
|
|
289
|
+
*/
|
|
290
|
+
export function formatDebug(event) {
|
|
291
|
+
return `[debug ${new Date().toISOString()}] ${JSON.stringify(redactDeep(event))}`;
|
|
282
292
|
}
|
|
283
|
-
function formatDryRunDebug(event) {
|
|
284
|
-
return `[debug ${new Date().toISOString()}] ${JSON.stringify({ ...event, mode: 'dry-run' })}`;
|
|
293
|
+
export function formatDryRunDebug(event) {
|
|
294
|
+
return `[debug ${new Date().toISOString()}] ${JSON.stringify(redactDeep({ ...event, mode: 'dry-run' }))}`;
|
|
285
295
|
}
|
|
286
296
|
//# sourceMappingURL=client-factory.js.map
|
|
@@ -466,6 +466,59 @@ function buildPathPattern(pathTemplate) {
|
|
|
466
466
|
const ENTRIES = [
|
|
467
467
|
entry('whoami', 'GET', '/me', me),
|
|
468
468
|
entry('listProjects', 'GET', '/projects', pageOf(projects)),
|
|
469
|
+
entry('getProjectSignIn', 'GET', '/projects/{projectId}/sign-in', {
|
|
470
|
+
projectId: SAMPLE_PROJECT_ID,
|
|
471
|
+
environment: {
|
|
472
|
+
id: 'env_dryrun',
|
|
473
|
+
name: 'default',
|
|
474
|
+
url: 'https://app.example.com',
|
|
475
|
+
isDefault: true,
|
|
476
|
+
authMode: 'public',
|
|
477
|
+
hasCredentials: false,
|
|
478
|
+
username: null,
|
|
479
|
+
enableOtp: false,
|
|
480
|
+
updatedAt: '2026-09-25T00:00:00.000Z',
|
|
481
|
+
},
|
|
482
|
+
signIn: { mode: 'public', account: null, otp: null, manual: null },
|
|
483
|
+
nextAction: null,
|
|
484
|
+
}),
|
|
485
|
+
entry('setProjectSignIn', 'PUT', '/projects/{projectId}/sign-in', (request) => {
|
|
486
|
+
const body = request;
|
|
487
|
+
const mode = body?.mode ?? 'manual';
|
|
488
|
+
return {
|
|
489
|
+
projectId: SAMPLE_PROJECT_ID,
|
|
490
|
+
environment: {
|
|
491
|
+
id: 'env_dryrun',
|
|
492
|
+
name: 'default',
|
|
493
|
+
url: 'https://app.example.com',
|
|
494
|
+
isDefault: true,
|
|
495
|
+
authMode: mode,
|
|
496
|
+
hasCredentials: mode === 'account',
|
|
497
|
+
username: mode === 'account' ? 'qa@example.com' : null,
|
|
498
|
+
enableOtp: mode === 'otp',
|
|
499
|
+
updatedAt: '2026-09-25T00:00:00.000Z',
|
|
500
|
+
},
|
|
501
|
+
signIn: {
|
|
502
|
+
mode,
|
|
503
|
+
account: mode === 'account' ? { username: 'qa@example.com', passwordSet: true } : null,
|
|
504
|
+
otp: mode === 'otp'
|
|
505
|
+
? { channels: ['email'], email: 'dryrun@inbox.example', phone: null }
|
|
506
|
+
: null,
|
|
507
|
+
manual: mode === 'manual'
|
|
508
|
+
? {
|
|
509
|
+
sessionReuseTtlSeconds: 3600,
|
|
510
|
+
hasValidSession: false,
|
|
511
|
+
needsReauth: true,
|
|
512
|
+
reason: 'never',
|
|
513
|
+
capturedAt: null,
|
|
514
|
+
expiresAt: null,
|
|
515
|
+
}
|
|
516
|
+
: null,
|
|
517
|
+
},
|
|
518
|
+
changed: mode !== 'otp',
|
|
519
|
+
nextAction: mode === 'manual' ? 'Log in once in the Portal.' : null,
|
|
520
|
+
};
|
|
521
|
+
}),
|
|
469
522
|
// Plan-generation surface. All three MUST be registered
|
|
470
523
|
// BEFORE `getProject`: findSample is first-match-wins and the projects/*
|
|
471
524
|
// family shares the `/projects/…` prefix, so the more specific plans
|