@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
|
@@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
|
|
4
4
|
import { resolveProfileName } from '../lib/config.js';
|
|
5
|
-
import { ApiError } from '../lib/errors.js';
|
|
5
|
+
import { ApiError, InterruptError } from '../lib/errors.js';
|
|
6
6
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
7
7
|
import { formatScheduleFrequencyAdvisory, runsPerMonth } from '../lib/cron.js';
|
|
8
8
|
import { renderTextTable } from '../lib/text-table.js';
|
|
@@ -54,10 +54,17 @@ export async function runCreate(opts, deps = {}) {
|
|
|
54
54
|
}
|
|
55
55
|
const targetType = opts.targetType;
|
|
56
56
|
const cron = opts.cron.trim();
|
|
57
|
+
const environment = normalizeScheduleEnvironmentName(opts.env);
|
|
58
|
+
if (targetType === 'testList' && environment !== undefined) {
|
|
59
|
+
throw environmentValidationError('not_supported_for_target', `Test-list schedules inherit their list's environment bindings. ` +
|
|
60
|
+
`Use testsprite testlist update ${opts.targetId} ` +
|
|
61
|
+
'--project-env <projectId>:<environmentName> instead.');
|
|
62
|
+
}
|
|
57
63
|
const body = {
|
|
58
64
|
name: opts.name,
|
|
59
65
|
targetType,
|
|
60
66
|
targetId: opts.targetId,
|
|
67
|
+
...(environment !== undefined ? { environment } : {}),
|
|
61
68
|
cron,
|
|
62
69
|
...(opts.timezone !== undefined ? { timezone: opts.timezone } : {}),
|
|
63
70
|
...(opts.start !== undefined ? { startAt: opts.start } : {}),
|
|
@@ -73,23 +80,63 @@ export async function runCreate(opts, deps = {}) {
|
|
|
73
80
|
if (opts.dryRun) {
|
|
74
81
|
emitDryRunBanner(stderr);
|
|
75
82
|
// Carries a cost figure so the advisory below is exercised offline too.
|
|
83
|
+
// There is no real server round trip to confirm here, so the mode is
|
|
84
|
+
// synthesized straight from the flags being previewed, same as a
|
|
85
|
+
// compliant server would echo back.
|
|
76
86
|
const sample = {
|
|
77
87
|
scheduleId: 'sch_dryrun_2026',
|
|
78
88
|
estimatedCreditsPerRun: 5,
|
|
89
|
+
...(targetType === 'project'
|
|
90
|
+
? { environment: environment ?? null, environmentMode: environment ? 'pinned' : 'inherit' }
|
|
91
|
+
: {}),
|
|
79
92
|
};
|
|
80
93
|
emitCostAdvisory(sample, cron, stderr);
|
|
81
94
|
out.print(sample, data => renderCreateScheduleText(data));
|
|
82
95
|
return sample;
|
|
83
96
|
}
|
|
84
97
|
const client = makeClient(opts, deps);
|
|
98
|
+
if (environment !== undefined) {
|
|
99
|
+
await checkScheduleEnvironmentSupport(client);
|
|
100
|
+
}
|
|
85
101
|
const created = await client.post('/schedules', {
|
|
86
102
|
body,
|
|
87
103
|
headers: { 'idempotency-key': idempotencyKey },
|
|
88
104
|
});
|
|
105
|
+
if (targetType === 'project' && environment !== undefined) {
|
|
106
|
+
await confirmCreateEnvironmentPin(created, environment, client);
|
|
107
|
+
}
|
|
89
108
|
emitCostAdvisory(created, cron, stderr);
|
|
90
109
|
out.print(created, data => renderCreateScheduleText(data));
|
|
91
110
|
return created;
|
|
92
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* `--env` on create asks the server to pin the new schedule. An old server
|
|
114
|
+
* without this feature drops the field silently and echoes back a schedule
|
|
115
|
+
* with no environment mode at all — printing a confirmation on top of that
|
|
116
|
+
* would claim a pin that was never applied. Instead, best-effort undo the
|
|
117
|
+
* create (this command's own write, seconds old) and refuse.
|
|
118
|
+
*/
|
|
119
|
+
async function confirmCreateEnvironmentPin(created, environment, client) {
|
|
120
|
+
if (created.environmentMode === 'pinned' && created.environment === environment)
|
|
121
|
+
return;
|
|
122
|
+
let rolledBack = false;
|
|
123
|
+
try {
|
|
124
|
+
await client.delete(`/schedules/${encodeURIComponent(created.scheduleId)}`, {
|
|
125
|
+
headers: { 'idempotency-key': `cli-sched-create-rollback-${randomUUID()}` },
|
|
126
|
+
});
|
|
127
|
+
rolledBack = true;
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
if (err instanceof InterruptError)
|
|
131
|
+
throw err;
|
|
132
|
+
}
|
|
133
|
+
throw unsupportedEnvironmentError(rolledBack
|
|
134
|
+
? `Schedule ${created.scheduleId} was created and then removed because this server did ` +
|
|
135
|
+
'not apply the requested environment.'
|
|
136
|
+
: `Schedule ${created.scheduleId} was created without a confirmed environment pin, and ` +
|
|
137
|
+
'the CLI could not remove it; remove it with: ' +
|
|
138
|
+
`testsprite schedule delete ${created.scheduleId} --confirm`, { scheduleId: created.scheduleId, rolledBack });
|
|
139
|
+
}
|
|
93
140
|
/**
|
|
94
141
|
* Cost advisory for a schedule that was just created.
|
|
95
142
|
*
|
|
@@ -126,8 +173,10 @@ export async function runUpdate(opts, deps = {}) {
|
|
|
126
173
|
if (opts.pause && opts.resume) {
|
|
127
174
|
throw localValidationError('--pause and --resume cannot be combined');
|
|
128
175
|
}
|
|
176
|
+
const environment = normalizeScheduleEnvironmentName(opts.env);
|
|
129
177
|
const body = {
|
|
130
178
|
...(opts.name !== undefined ? { name: opts.name } : {}),
|
|
179
|
+
...(environment !== undefined ? { environment } : {}),
|
|
131
180
|
...(opts.cron !== undefined ? { cron: opts.cron } : {}),
|
|
132
181
|
...(opts.timezone !== undefined ? { timezone: opts.timezone } : {}),
|
|
133
182
|
...(opts.start !== undefined ? { startAt: opts.start } : {}),
|
|
@@ -151,7 +200,24 @@ export async function runUpdate(opts, deps = {}) {
|
|
|
151
200
|
stderr(formatScheduleFrequencyAdvisory(opts.cron));
|
|
152
201
|
}
|
|
153
202
|
const client = makeClient(opts, deps);
|
|
203
|
+
if (environment !== undefined && !opts.dryRun) {
|
|
204
|
+
await checkScheduleEnvironmentSupport(client, opts.scheduleId);
|
|
205
|
+
}
|
|
154
206
|
const updated = await client.patch(`/schedules/${encodeURIComponent(opts.scheduleId)}`, { body, headers: { 'idempotency-key': idempotencyKey } });
|
|
207
|
+
// `--env` on update pins an existing schedule. An old server drops the
|
|
208
|
+
// field silently and echoes back no environment mode; unlike create there
|
|
209
|
+
// is nothing to roll back (the schedule pre-existed this command), so this
|
|
210
|
+
// just refuses rather than confirming a pin that was never applied. Other
|
|
211
|
+
// fields in the same request may still have gone through.
|
|
212
|
+
if (environment !== undefined &&
|
|
213
|
+
!(updated.environmentMode === 'pinned' && updated.environment === environment)) {
|
|
214
|
+
throw unsupportedEnvironmentError(`The server updated schedule ${updated.scheduleId} without confirming the environment ` +
|
|
215
|
+
`pin. Other requested fields (${Object.keys(body)
|
|
216
|
+
.filter(key => key !== 'environment')
|
|
217
|
+
.join(', ') || 'none'}) ` +
|
|
218
|
+
'may have been applied; inspect it with: ' +
|
|
219
|
+
`testsprite schedule get ${updated.scheduleId}`, { scheduleId: updated.scheduleId, requestedFields: Object.keys(body) });
|
|
220
|
+
}
|
|
155
221
|
out.print(updated, data => renderScheduleText(data));
|
|
156
222
|
return updated;
|
|
157
223
|
}
|
|
@@ -238,7 +304,16 @@ const SCHEDULE_LIST_COLUMNS = [
|
|
|
238
304
|
width: rows => Math.max(2, ...rows.map(s => (s.timezone ?? '').length)),
|
|
239
305
|
render: s => s.timezone ?? '',
|
|
240
306
|
},
|
|
241
|
-
{
|
|
307
|
+
{
|
|
308
|
+
header: 'LAST RUN',
|
|
309
|
+
width: rows => Math.max(8, ...rows.map(s => (s.lastRunId ?? '').length)),
|
|
310
|
+
render: s => s.lastRunId ?? '',
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
header: 'ENVIRONMENT',
|
|
314
|
+
width: rows => Math.max(11, ...rows.map(s => scheduleEnvironmentText(s).length)),
|
|
315
|
+
render: scheduleEnvironmentText,
|
|
316
|
+
},
|
|
242
317
|
];
|
|
243
318
|
function renderScheduleListText(schedules, options = {}) {
|
|
244
319
|
if (schedules.length === 0)
|
|
@@ -266,10 +341,99 @@ function renderScheduleText(s) {
|
|
|
266
341
|
];
|
|
267
342
|
if (s.autoPausedAt)
|
|
268
343
|
lines.push(`autoPaused: ${s.autoPausedAt}`);
|
|
344
|
+
if (s.environmentMode !== undefined) {
|
|
345
|
+
lines.push(`environment: ${scheduleEnvironmentText(s)}`);
|
|
346
|
+
}
|
|
269
347
|
return lines.join('\n');
|
|
270
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* Renders the environment/mode strictly from the server's response — never
|
|
351
|
+
* from what the command asked for. When the response omits `environmentMode`
|
|
352
|
+
* altogether (an old server that has never heard of schedule environments),
|
|
353
|
+
* this stays silent about it, matching the confirmation text from before the
|
|
354
|
+
* feature existed rather than fabricating a claim the server never made.
|
|
355
|
+
* (A request that explicitly asked to pin and got no confirmation never
|
|
356
|
+
* reaches this renderer — `confirmCreateEnvironmentPin` refuses first.)
|
|
357
|
+
*/
|
|
271
358
|
function renderCreateScheduleText(r) {
|
|
272
|
-
|
|
359
|
+
if (r.environmentMode === undefined)
|
|
360
|
+
return `id: ${r.scheduleId}`;
|
|
361
|
+
return `id: ${r.scheduleId}\nenvironment: ${scheduleEnvironmentText(r)}`;
|
|
362
|
+
}
|
|
363
|
+
function scheduleEnvironmentText(schedule) {
|
|
364
|
+
if (schedule.environmentMode === 'inherit')
|
|
365
|
+
return 'project default (inherits)';
|
|
366
|
+
if (schedule.environmentMode === 'pinned' && schedule.environment) {
|
|
367
|
+
return `${schedule.environment} (pinned)`;
|
|
368
|
+
}
|
|
369
|
+
return '-';
|
|
370
|
+
}
|
|
371
|
+
function normalizeScheduleEnvironmentName(raw) {
|
|
372
|
+
if (raw === undefined)
|
|
373
|
+
return undefined;
|
|
374
|
+
const name = raw.trim();
|
|
375
|
+
if (name.length === 0) {
|
|
376
|
+
throw environmentValidationError('blank_value', '--env must be a non-empty environment name');
|
|
377
|
+
}
|
|
378
|
+
return name;
|
|
379
|
+
}
|
|
380
|
+
/** A missing mode on a project schedule proves that the server predates pins. */
|
|
381
|
+
async function checkScheduleEnvironmentSupport(client, scheduleId) {
|
|
382
|
+
let schedules;
|
|
383
|
+
try {
|
|
384
|
+
schedules =
|
|
385
|
+
scheduleId === undefined
|
|
386
|
+
? ((await client.get('/schedules', { retry: false })).schedules ?? [])
|
|
387
|
+
: [
|
|
388
|
+
await client.get(`/schedules/${encodeURIComponent(scheduleId)}`, {
|
|
389
|
+
retry: false,
|
|
390
|
+
}),
|
|
391
|
+
];
|
|
392
|
+
}
|
|
393
|
+
catch (err) {
|
|
394
|
+
if (err instanceof InterruptError)
|
|
395
|
+
throw err;
|
|
396
|
+
// A write-scoped key may not read schedules. Keep response confirmation
|
|
397
|
+
// for inconclusive probes and for a server with no existing schedules.
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (schedules.some(schedule => schedule.targetType === 'project' && schedule.environmentMode === undefined)) {
|
|
401
|
+
throw unsupportedEnvironmentError(scheduleId === undefined
|
|
402
|
+
? 'No schedule was created. Upgrade the server before using schedule --env.'
|
|
403
|
+
: `No schedule changes were sent. Upgrade the server before using schedule --env on ${scheduleId}.`, {
|
|
404
|
+
...(scheduleId !== undefined ? { scheduleId } : {}),
|
|
405
|
+
reason: 'schedule-environments-unsupported',
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Local validation failures on `--env` — mirrors the field the API itself
|
|
411
|
+
* uses (`environment`, the wire name) rather than the flag name, so a caller
|
|
412
|
+
* inspecting `details.field` sees the same value whether the rejection was
|
|
413
|
+
* caught locally or came back from the server.
|
|
414
|
+
*/
|
|
415
|
+
function environmentValidationError(reason, nextAction) {
|
|
416
|
+
return ApiError.fromEnvelope({
|
|
417
|
+
error: {
|
|
418
|
+
code: 'VALIDATION_ERROR',
|
|
419
|
+
message: 'Invalid request.',
|
|
420
|
+
nextAction,
|
|
421
|
+
requestId: 'local',
|
|
422
|
+
details: { field: 'environment', reason },
|
|
423
|
+
},
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
/** Exit 7 — a server that doesn't (yet) support schedule environments. */
|
|
427
|
+
function unsupportedEnvironmentError(nextAction, details) {
|
|
428
|
+
return ApiError.fromEnvelope({
|
|
429
|
+
error: {
|
|
430
|
+
code: 'UNSUPPORTED',
|
|
431
|
+
message: 'This server does not support schedule environments yet.',
|
|
432
|
+
nextAction,
|
|
433
|
+
requestId: 'local',
|
|
434
|
+
details,
|
|
435
|
+
},
|
|
436
|
+
});
|
|
273
437
|
}
|
|
274
438
|
const RUN_LIST_COLUMNS = [
|
|
275
439
|
{
|
|
@@ -351,12 +515,14 @@ export function createScheduleCommand(deps = {}) {
|
|
|
351
515
|
' 4 target not found\n' +
|
|
352
516
|
' 5 validation error (e.g., missing --cron)\n' +
|
|
353
517
|
' 6 idempotency conflict\n' +
|
|
354
|
-
' 7 schedules are not available on this account
|
|
518
|
+
' 7 schedules are not available on this account, or (with --env) the server does ' +
|
|
519
|
+
'not support schedule environments yet\n' +
|
|
355
520
|
' 10 transport/network failure (UNAVAILABLE) — retry the command\n' +
|
|
356
521
|
' 13 not available on your plan, or the plan limit is reached')
|
|
357
522
|
.option('--name <name>', 'schedule name (required)')
|
|
358
523
|
.option('--target-type <project|testList>', 'what to run (required)')
|
|
359
524
|
.option('--target-id <id>', 'project id or test-list id (required)')
|
|
525
|
+
.option('--env <name>', "Pin this project schedule to an environment; omit to always use the project's default environment")
|
|
360
526
|
.option('--cron <expr>', 'standard 5-field cron (minute hour day-of-month month day-of-week), ' +
|
|
361
527
|
'e.g. "0 3 * * *". Day-of-week is 0-7, with both 0 and 7 = Sunday. ' +
|
|
362
528
|
'Constrain ' +
|
|
@@ -373,6 +539,7 @@ export function createScheduleCommand(deps = {}) {
|
|
|
373
539
|
name: cmdOpts.name,
|
|
374
540
|
targetType: cmdOpts.targetType,
|
|
375
541
|
targetId: cmdOpts.targetId,
|
|
542
|
+
env: cmdOpts.env,
|
|
376
543
|
cron: cmdOpts.cron,
|
|
377
544
|
timezone: cmdOpts.timezone,
|
|
378
545
|
start: cmdOpts.start,
|
|
@@ -390,10 +557,12 @@ export function createScheduleCommand(deps = {}) {
|
|
|
390
557
|
' 4 not found\n' +
|
|
391
558
|
' 5 validation error (e.g., no fields given)\n' +
|
|
392
559
|
' 6 idempotency conflict\n' +
|
|
393
|
-
' 7 schedules are not available on this account
|
|
560
|
+
' 7 schedules are not available on this account, or (with --env) the server does ' +
|
|
561
|
+
'not support schedule environments yet\n' +
|
|
394
562
|
' 10 transport/network failure (UNAVAILABLE) — retry the command\n' +
|
|
395
563
|
' 13 not available on your plan')
|
|
396
564
|
.option('--name <name>', 'new schedule name')
|
|
565
|
+
.option('--env <name>', "Pin this project schedule to an environment; omit to always use the project's default environment")
|
|
397
566
|
.option('--cron <expr>', 'new standard 5-field cron, as printed by `schedule get`. Day-of-week is ' +
|
|
398
567
|
'0-7, with both 0 and 7 = Sunday. Constrain day-of-month or day-of-week, not both.')
|
|
399
568
|
.option('--timezone <tz>', 'new IANA timezone')
|
|
@@ -409,6 +578,7 @@ export function createScheduleCommand(deps = {}) {
|
|
|
409
578
|
...resolveCommonOptions(command, deps.env),
|
|
410
579
|
scheduleId,
|
|
411
580
|
name: cmdOpts.name,
|
|
581
|
+
env: cmdOpts.env,
|
|
412
582
|
cron: cmdOpts.cron,
|
|
413
583
|
timezone: cmdOpts.timezone,
|
|
414
584
|
start: cmdOpts.start,
|
package/dist/commands/test.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveEnvironmentRunTarget, type EnvironmentTunnelContext, type ResolvedRunTarget, type RunTargetTest } from '../lib/environment-tunnel.js';
|
|
1
2
|
import { Command } from 'commander';
|
|
2
3
|
import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
|
|
3
4
|
import { type WriteBundleResult } from '../lib/bundle.js';
|
|
@@ -7,7 +8,7 @@ import { type ShutdownHandle } from '../lib/interrupt.js';
|
|
|
7
8
|
import type { FetchImpl } from '../lib/http.js';
|
|
8
9
|
import { type Page } from '../lib/pagination.js';
|
|
9
10
|
import { type WaitTimeoutTelemetry } from '../lib/telemetry.js';
|
|
10
|
-
import type { CliGetPlansResponse } from '../lib/plans.types.js';
|
|
11
|
+
import type { CliGetPlansResponse, CliGenerationStage } from '../lib/plans.types.js';
|
|
11
12
|
import type { RunResponse, RunStatus, TriggerRunResponse, RerunResponse, BatchRerunResponse, ListRunsResponse, RunSource, BatchRunFreshResponse, CancelRunResponse, RunEnvironmentRef } from '../lib/runs.types.js';
|
|
12
13
|
import { type LoopbackHost } from '../lib/local-target.js';
|
|
13
14
|
import { type TunnelClientHandle } from '../lib/tunnel-session.js';
|
|
@@ -50,6 +51,15 @@ export interface CliTest {
|
|
|
50
51
|
type: 'frontend' | 'backend';
|
|
51
52
|
createdFrom: 'portal' | 'mcp' | 'cli';
|
|
52
53
|
status: CliPublicStatus;
|
|
54
|
+
statusByEnvironment?: Array<{
|
|
55
|
+
environmentId: string | null;
|
|
56
|
+
environmentName: string | null;
|
|
57
|
+
status: CliPublicStatus;
|
|
58
|
+
}>;
|
|
59
|
+
headlineEnvironment?: {
|
|
60
|
+
id: string | null;
|
|
61
|
+
name: string | null;
|
|
62
|
+
} | null;
|
|
53
63
|
createdAt: string;
|
|
54
64
|
updatedAt: string;
|
|
55
65
|
/**
|
|
@@ -321,6 +331,10 @@ export interface CliFailureContext {
|
|
|
321
331
|
failure: CliFailureBlock;
|
|
322
332
|
}
|
|
323
333
|
export interface TestDeps {
|
|
334
|
+
environmentCache?: Parameters<typeof resolveEnvironmentRunTarget>[0]['cache'];
|
|
335
|
+
creationTargets?: ReadonlyMap<string, ResolvedRunTarget>;
|
|
336
|
+
createdTests?: ReadonlyMap<string, RunTargetTest>;
|
|
337
|
+
environmentTunnel?: EnvironmentTunnelContext;
|
|
324
338
|
/** Report an exhausted poll deadline without changing the public output/error shape. */
|
|
325
339
|
onWaitTimeout?: (context: WaitTimeoutTelemetry) => void;
|
|
326
340
|
env?: NodeJS.ProcessEnv;
|
|
@@ -368,6 +382,8 @@ export interface TunnelDetach {
|
|
|
368
382
|
testId: string;
|
|
369
383
|
localPort: number;
|
|
370
384
|
localHost: LoopbackHost;
|
|
385
|
+
automatic?: boolean;
|
|
386
|
+
environment?: string;
|
|
371
387
|
reason: TunnelDetachReason;
|
|
372
388
|
/** The borrowed tunnel owner disappeared while this run was non-terminal. */
|
|
373
389
|
ownerGone?: boolean;
|
|
@@ -392,6 +408,7 @@ export declare function tunnelInterruptNextAction(detach: TunnelDetach, err: Int
|
|
|
392
408
|
type CommonOptions = FactoryCommonOptions;
|
|
393
409
|
interface ListOptions extends CommonOptions {
|
|
394
410
|
projectId?: string;
|
|
411
|
+
environment?: string;
|
|
395
412
|
type?: 'frontend' | 'backend';
|
|
396
413
|
createdFrom?: 'portal' | 'mcp' | 'cli';
|
|
397
414
|
/**
|
|
@@ -440,6 +457,7 @@ export interface CliCreateTestResponse {
|
|
|
440
457
|
export declare const CLI_CREATE_PRIORITIES: readonly ["p0", "p1", "p2", "p3"];
|
|
441
458
|
export type CliCreatePriority = (typeof CLI_CREATE_PRIORITIES)[number];
|
|
442
459
|
interface CreateOptions extends CommonOptions {
|
|
460
|
+
noWait?: boolean;
|
|
443
461
|
environment?: string;
|
|
444
462
|
projectId?: string;
|
|
445
463
|
type: 'frontend' | 'backend';
|
|
@@ -757,7 +775,7 @@ export interface CliCreateFromPlanResponse extends CliCreateTestResponse {
|
|
|
757
775
|
* Caveat: the pinned tag only resolves once that version is actually
|
|
758
776
|
* released — a locally-built/pre-release checkout may see a 404 until then.
|
|
759
777
|
*/
|
|
760
|
-
export declare const PLAN_SCHEMA_URL = "https://raw.githubusercontent.com/TestSprite/testsprite-cli/v0.
|
|
778
|
+
export declare const PLAN_SCHEMA_URL = "https://raw.githubusercontent.com/TestSprite/testsprite-cli/v0.14.0/schemas/plan.schema.json";
|
|
761
779
|
/**
|
|
762
780
|
* The SINGLE canonical example plan. This
|
|
763
781
|
* exact value (via `PLAN_TEMPLATE_TEXT` below) is:
|
|
@@ -842,6 +860,7 @@ export interface CliBatchRunResult {
|
|
|
842
860
|
code: string;
|
|
843
861
|
message: string;
|
|
844
862
|
exitCode: number;
|
|
863
|
+
details?: Record<string, unknown>;
|
|
845
864
|
};
|
|
846
865
|
/**
|
|
847
866
|
* Portal deep link (R3b), threaded through from the SAME per-item
|
|
@@ -972,6 +991,7 @@ export declare const DEFERRED_RETRY_DEFAULT_SLEEP_MS = 61000;
|
|
|
972
991
|
*/
|
|
973
992
|
export declare function isTransientRateLimit(err: ApiError): boolean;
|
|
974
993
|
interface CreateFromPlanOptions extends CommonOptions {
|
|
994
|
+
noWait?: boolean;
|
|
975
995
|
environment?: string;
|
|
976
996
|
/** Path to the JSON file containing one `CliPlanInput`. */
|
|
977
997
|
planFrom: string;
|
|
@@ -1027,6 +1047,7 @@ interface CreateFromPlanOptions extends CommonOptions {
|
|
|
1027
1047
|
*/
|
|
1028
1048
|
export declare function runCreateFromPlan(opts: CreateFromPlanOptions, deps?: TestDeps): Promise<CliCreateFromPlanResponse>;
|
|
1029
1049
|
interface CreateBatchOptions extends CommonOptions {
|
|
1050
|
+
noWait?: boolean;
|
|
1030
1051
|
environment?: string;
|
|
1031
1052
|
/** Path to the JSONL file containing one `CliPlanInput` per line. */
|
|
1032
1053
|
plans: string;
|
|
@@ -1483,6 +1504,8 @@ export interface FailureGetResult {
|
|
|
1483
1504
|
*/
|
|
1484
1505
|
export declare function runFailureGet(opts: FailureGetOptions, deps?: TestDeps): Promise<FailureGetResult>;
|
|
1485
1506
|
interface RunTestRunOptions extends CommonOptions {
|
|
1507
|
+
knownTest?: RunTargetTest;
|
|
1508
|
+
noWait?: boolean;
|
|
1486
1509
|
testId: string;
|
|
1487
1510
|
targetUrl?: string;
|
|
1488
1511
|
/**
|
|
@@ -1577,6 +1600,11 @@ interface RunTestWaitOptions extends CommonOptions {
|
|
|
1577
1600
|
timeoutSeconds: number;
|
|
1578
1601
|
}
|
|
1579
1602
|
interface RunTestRerunOptions extends CommonOptions {
|
|
1603
|
+
knownTests?: ReadonlyMap<string, Pick<CliTest, 'type' | 'projectId'>>;
|
|
1604
|
+
noWait?: boolean;
|
|
1605
|
+
skipPreflight?: boolean;
|
|
1606
|
+
concurrencyIsDefault?: boolean;
|
|
1607
|
+
batchResolved?: boolean;
|
|
1580
1608
|
/** One or more testIds to rerun. Empty + all=false → validation error (exit 5). */
|
|
1581
1609
|
testIds: string[];
|
|
1582
1610
|
/** --all: resolve all tests in the project and batch-rerun them. */
|
|
@@ -1785,6 +1813,11 @@ export declare function createTestCancelCommand(deps: TestDeps): Command;
|
|
|
1785
1813
|
*/
|
|
1786
1814
|
export declare function runTestWait(opts: RunTestWaitOptions, deps?: TestDeps): Promise<RunResponse>;
|
|
1787
1815
|
interface RunTestRunAllOptions extends CommonOptions {
|
|
1816
|
+
environmentResolutionComplete?: boolean;
|
|
1817
|
+
cancelOnInterrupt?: boolean;
|
|
1818
|
+
timeoutIsDefault?: boolean;
|
|
1819
|
+
noWait?: boolean;
|
|
1820
|
+
concurrencyIsDefault?: boolean;
|
|
1788
1821
|
/** projectId to run all tests in; may be resolved from --project or TESTSPRITE_PROJECT_ID. */
|
|
1789
1822
|
projectId?: string;
|
|
1790
1823
|
/** --filter <substr>: only run tests whose name contains this substring (case-insensitive). */
|
|
@@ -1829,6 +1862,7 @@ export declare function writeBatchJUnitReportIfRequested(opts: {
|
|
|
1829
1862
|
reportSuiteName?: string;
|
|
1830
1863
|
projectId?: string;
|
|
1831
1864
|
}, results: readonly (JUnitTestResult & {
|
|
1865
|
+
createdAt?: string | null;
|
|
1832
1866
|
startedAt?: string | null;
|
|
1833
1867
|
finishedAt?: string | null;
|
|
1834
1868
|
testTitle?: string | null;
|
|
@@ -1842,12 +1876,17 @@ export declare function writeBatchJUnitReportIfRequested(opts: {
|
|
|
1842
1876
|
*/
|
|
1843
1877
|
export declare function runTestRunAll(opts: RunTestRunAllOptions, deps?: TestDeps): Promise<BatchRunFreshResponse | undefined>;
|
|
1844
1878
|
interface RunTestRunLocalBatchOptions extends CommonOptions {
|
|
1879
|
+
wait?: boolean;
|
|
1880
|
+
targetUrl?: string;
|
|
1881
|
+
noWait?: boolean;
|
|
1882
|
+
concurrencyIsDefault?: boolean;
|
|
1883
|
+
resolvedTarget?: ResolvedRunTarget;
|
|
1845
1884
|
testIds: string[];
|
|
1846
1885
|
all: boolean;
|
|
1847
1886
|
projectId?: string;
|
|
1848
1887
|
nameFilter?: string;
|
|
1849
|
-
localPort
|
|
1850
|
-
localHost
|
|
1888
|
+
localPort?: number;
|
|
1889
|
+
localHost?: LoopbackHost;
|
|
1851
1890
|
skipPreflight: boolean;
|
|
1852
1891
|
tunnelClientId?: string;
|
|
1853
1892
|
cancelOnInterrupt: boolean;
|
|
@@ -1865,20 +1904,6 @@ interface RunTestRunLocalBatchOptions extends CommonOptions {
|
|
|
1865
1904
|
}
|
|
1866
1905
|
/** One bounded trigger-and-wait pool shares one local tunnel for its full lifetime. */
|
|
1867
1906
|
export declare function runTestRunLocalBatch(opts: RunTestRunLocalBatchOptions, deps?: TestDeps): Promise<void>;
|
|
1868
|
-
/**
|
|
1869
|
-
* `test rerun` — M3.4 piece-3.
|
|
1870
|
-
*
|
|
1871
|
-
* FE: `POST /tests/{id}/runs/rerun` → verbatim replay, billed at 0.5 credits
|
|
1872
|
-
* (same as a fresh run; legacy V2 accounts: free). With `--wait`, polls
|
|
1873
|
-
* `GET /runs/{runId}` until terminal.
|
|
1874
|
-
*
|
|
1875
|
-
* BE: same route → closure + per-member runIds. With `--wait`, polls every
|
|
1876
|
-
* closure-member runId; exits on the named test's verdict; failed closure
|
|
1877
|
-
* members surface as warnings + `closureFailures[]` in JSON.
|
|
1878
|
-
*
|
|
1879
|
-
* Batch / `--all`: `POST /tests/batch/rerun` → per-test runIds. With
|
|
1880
|
-
* `--wait`, fan-out poll under `--max-concurrency`. `deferred[]` → exit 7.
|
|
1881
|
-
*/
|
|
1882
1907
|
export declare function runTestRerun(opts: RunTestRerunOptions, deps?: TestDeps): Promise<RerunResponse | BatchRerunResponse | undefined>;
|
|
1883
1908
|
export interface ArtifactGetOptions extends CommonOptions {
|
|
1884
1909
|
runId: string;
|
|
@@ -1979,6 +2004,13 @@ interface PlanAcceptOptions extends CommonOptions {
|
|
|
1979
2004
|
* reachable through `runGenerationLadder` today (after the proposals rung it
|
|
1980
2005
|
* polls until staged/failed/timeout), so it is pinned directly. */
|
|
1981
2006
|
export declare function renderPlanGenerateResultText(plans: CliGetPlansResponse, projectId: string, creditsUsed: number | null, skippedCategories?: number | null): string;
|
|
2007
|
+
/** Plan-generate interrupt outcome consumed by the top-level JSON renderer
|
|
2008
|
+
* (`buildInterruptEnvelope`), the way `TunnelInterruptDetach` is for tunnels. */
|
|
2009
|
+
export interface PlanInterruptDetach {
|
|
2010
|
+
projectId: string;
|
|
2011
|
+
stagesRemaining: CliGenerationStage[] | null;
|
|
2012
|
+
nextAction: string;
|
|
2013
|
+
}
|
|
1982
2014
|
/**
|
|
1983
2015
|
* `test plan generate --project <id>`.
|
|
1984
2016
|
*
|
|
@@ -1986,8 +2018,9 @@ export declare function renderPlanGenerateResultText(plans: CliGetPlansResponse,
|
|
|
1986
2018
|
* proposals) through `runGenerationLadder` and renders the staged
|
|
1987
2019
|
* proposals. Exit 0 on staged proposals, 1 on a server-side stage failure,
|
|
1988
2020
|
* 7 on timeout (typed `UNSUPPORTED` envelope — the raw ladder timeout is
|
|
1989
|
-
* not a CLI error), 130/143 on Ctrl-C
|
|
1990
|
-
*
|
|
2021
|
+
* not a CLI error), 130/143 on Ctrl-C (the running stage finishes server-side;
|
|
2022
|
+
* nothing after it starts until a re-run, see PlanStageTracker), plus the
|
|
2023
|
+
* usual catalog exits for trigger errors
|
|
1991
2024
|
* (412 → 6 with the exact fix command, 402 → 12, 404 → 4, 429 → 11).
|
|
1992
2025
|
*/
|
|
1993
2026
|
export declare function runPlanGenerate(opts: PlanGenerateOptions, deps?: TestDeps): Promise<unknown>;
|