@testsprite/testsprite-cli 0.16.0 → 0.18.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 +52 -147
- package/dist/commands/agent.d.ts +12 -4
- package/dist/commands/agent.js +48 -63
- package/dist/commands/auth.d.ts +6 -10
- package/dist/commands/auth.js +40 -56
- package/dist/commands/ci.d.ts +23 -100
- package/dist/commands/ci.js +293 -487
- package/dist/commands/conversation.d.ts +27 -0
- package/dist/commands/conversation.js +741 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +129 -34
- package/dist/commands/init.d.ts +4 -45
- package/dist/commands/init.js +108 -66
- package/dist/commands/project-env.d.ts +62 -2
- package/dist/commands/project-env.js +434 -43
- package/dist/commands/project-sign-in.d.ts +0 -48
- package/dist/commands/project-sign-in.js +1 -229
- package/dist/commands/project.d.ts +19 -186
- package/dist/commands/project.js +108 -926
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +216 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +28 -87
- package/dist/commands/test.d.ts +301 -1838
- package/dist/commands/test.js +1880 -13917
- package/dist/commands/testlist.d.ts +130 -5
- package/dist/commands/testlist.js +300 -342
- package/dist/commands/tunnel.d.ts +3 -3
- package/dist/commands/tunnel.js +23 -20
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +50 -131
- package/dist/index.js +191 -110
- package/dist/lib/agent-detect.js +9 -5
- package/dist/lib/agent-targets.d.ts +21 -2
- package/dist/lib/agent-targets.js +88 -11
- package/dist/lib/args.d.ts +13 -0
- package/dist/lib/args.js +49 -0
- package/dist/lib/basic-auth.d.ts +3 -0
- package/dist/lib/basic-auth.js +15 -0
- package/dist/lib/billing-refusal.js +4 -3
- package/dist/lib/ci-linkage.d.ts +4 -82
- package/dist/lib/ci-linkage.js +4 -157
- package/dist/lib/ci-run.js +1 -1
- package/dist/lib/client-factory.d.ts +12 -4
- package/dist/lib/client-factory.js +41 -30
- package/dist/lib/commit-signal.d.ts +65 -0
- package/dist/lib/commit-signal.js +305 -0
- package/dist/lib/concurrency-limiter.d.ts +6 -0
- package/dist/lib/concurrency-limiter.js +29 -0
- package/dist/lib/config.js +10 -5
- package/dist/lib/conflict-reason.d.ts +9 -3
- package/dist/lib/conflict-reason.js +6 -3
- package/dist/lib/conversation/answers.d.ts +9 -0
- package/dist/lib/conversation/answers.js +49 -0
- package/dist/lib/conversation/api.d.ts +75 -0
- package/dist/lib/conversation/api.js +151 -0
- package/dist/lib/conversation/change.d.ts +31 -0
- package/dist/lib/conversation/change.js +124 -0
- package/dist/lib/conversation/context.d.ts +29 -0
- package/dist/lib/conversation/context.js +82 -0
- package/dist/lib/conversation/environment.d.ts +16 -0
- package/dist/lib/conversation/environment.js +21 -0
- package/dist/lib/conversation/follow.d.ts +24 -0
- package/dist/lib/conversation/follow.js +42 -0
- package/dist/lib/conversation/render.d.ts +33 -0
- package/dist/lib/conversation/render.js +318 -0
- package/dist/lib/conversation/title.d.ts +2 -0
- package/dist/lib/conversation/title.js +18 -0
- package/dist/lib/conversation/types.d.ts +158 -0
- package/dist/lib/conversation/types.js +6 -0
- package/dist/lib/credentials.js +67 -11
- package/dist/lib/cron.d.ts +1 -1
- package/dist/lib/cron.js +2 -2
- package/dist/lib/dispatch-stop.d.ts +20 -0
- package/dist/lib/dispatch-stop.js +30 -0
- package/dist/lib/download.d.ts +100 -0
- package/dist/lib/download.js +408 -0
- package/dist/lib/dry-run/fetch.d.ts +10 -0
- package/dist/lib/dry-run/fetch.js +20 -0
- package/dist/lib/dry-run/samples.d.ts +6 -34
- package/dist/lib/dry-run/samples.js +375 -747
- package/dist/lib/environment-tunnel.d.ts +19 -30
- package/dist/lib/environment-tunnel.js +168 -202
- package/dist/lib/errors.d.ts +20 -4
- package/dist/lib/errors.js +36 -16
- package/dist/lib/facade.d.ts +7 -29
- package/dist/lib/facade.js +7 -36
- package/dist/lib/failing-fe-resolver.d.ts +13 -58
- package/dist/lib/failing-fe-resolver.js +47 -132
- package/dist/lib/first-suite-hint.d.ts +20 -30
- package/dist/lib/first-suite-hint.js +57 -72
- package/dist/lib/gh-output.d.ts +76 -21
- package/dist/lib/gh-output.js +171 -90
- package/dist/lib/git-utils.d.ts +56 -0
- package/dist/lib/git-utils.js +212 -0
- package/dist/lib/github-context.d.ts +2 -0
- package/dist/lib/github-context.js +40 -8
- package/dist/lib/history-retention.d.ts +6 -2
- package/dist/lib/history-retention.js +10 -7
- package/dist/lib/http.d.ts +58 -134
- package/dist/lib/http.js +354 -291
- package/dist/lib/interrupt.d.ts +14 -8
- package/dist/lib/interrupt.js +28 -10
- package/dist/lib/junit-report.d.ts +57 -4
- package/dist/lib/junit-report.js +202 -32
- package/dist/lib/local-target.d.ts +8 -7
- package/dist/lib/local-target.js +14 -13
- package/dist/lib/output.d.ts +2 -41
- package/dist/lib/output.js +13 -51
- package/dist/lib/pagination.d.ts +2 -5
- package/dist/lib/pagination.js +2 -5
- package/dist/lib/presigned-url.d.ts +22 -0
- package/dist/lib/presigned-url.js +90 -0
- package/dist/lib/prompt.js +36 -2
- package/dist/lib/proxy.js +2 -1
- package/dist/lib/redact.d.ts +2 -2
- package/dist/lib/redact.js +3 -4
- package/dist/lib/removed-commands.d.ts +18 -0
- package/dist/lib/removed-commands.js +170 -0
- package/dist/lib/render-error.d.ts +31 -6
- package/dist/lib/render-error.js +88 -25
- package/dist/lib/response-schemas.d.ts +38 -30
- package/dist/lib/response-schemas.js +207 -207
- package/dist/lib/result/api.d.ts +24 -0
- package/dist/lib/result/api.js +28 -0
- package/dist/lib/result/evidence.d.ts +73 -0
- package/dist/lib/result/evidence.js +422 -0
- package/dist/lib/result/render.d.ts +20 -0
- package/dist/lib/result/render.js +194 -0
- package/dist/lib/result/types.d.ts +122 -0
- package/dist/lib/result/types.js +19 -0
- package/dist/lib/run-output.d.ts +275 -0
- package/dist/lib/run-output.js +227 -0
- package/dist/lib/run-render.d.ts +101 -0
- package/dist/lib/run-render.js +183 -0
- package/dist/lib/run-wait.d.ts +192 -0
- package/dist/lib/run-wait.js +452 -0
- package/dist/lib/runs.types.d.ts +118 -367
- package/dist/lib/runs.types.js +0 -14
- package/dist/lib/secret-file.d.ts +1 -1
- package/dist/lib/secret-file.js +11 -2
- package/dist/lib/skill-nudge.d.ts +7 -27
- package/dist/lib/skill-nudge.js +9 -37
- package/dist/lib/target-path.d.ts +15 -0
- package/dist/lib/target-path.js +35 -0
- package/dist/lib/target-url-advisory.d.ts +19 -0
- package/dist/lib/target-url-advisory.js +31 -0
- package/dist/lib/target-url-preflight.d.ts +9 -0
- package/dist/lib/target-url-preflight.js +214 -106
- package/dist/lib/target-url.d.ts +8 -8
- package/dist/lib/target-url.js +14 -24
- package/dist/lib/telemetry.d.ts +35 -15
- package/dist/lib/telemetry.js +38 -9
- package/dist/lib/terminal-text.d.ts +41 -0
- package/dist/lib/terminal-text.js +127 -0
- package/dist/lib/testlist.types.d.ts +16 -8
- package/dist/lib/testlist.types.js +1 -1
- package/dist/lib/text-equality.d.ts +2 -0
- package/dist/lib/text-equality.js +5 -0
- package/dist/lib/text-file.d.ts +16 -0
- package/dist/lib/text-file.js +41 -0
- package/dist/lib/text-table.d.ts +46 -0
- package/dist/lib/text-table.js +72 -4
- package/dist/lib/ticker.d.ts +9 -2
- package/dist/lib/ticker.js +16 -3
- package/dist/lib/transport-failure.d.ts +22 -0
- package/dist/lib/transport-failure.js +126 -0
- package/dist/lib/tunnel-session.d.ts +8 -2
- package/dist/lib/tunnel-session.js +24 -11
- package/dist/lib/update-check.js +3 -2
- package/dist/lib/url-template.d.ts +43 -0
- package/dist/lib/url-template.js +151 -0
- package/dist/lib/validate.d.ts +0 -64
- package/dist/lib/validate.js +2 -131
- package/dist/lib/version-notice.js +4 -3
- package/dist/lib/wait-exit.d.ts +37 -2
- package/dist/lib/wait-exit.js +88 -30
- package/dist/lib/workspace-status.js +10 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -3
- package/skills/testsprite-ci.skill.md +52 -23
- package/skills/testsprite-onboard.skill.md +70 -153
- package/skills/testsprite-verify.codex.md +54 -58
- package/skills/testsprite-verify.skill.md +189 -358
- package/dist/lib/browser.d.ts +0 -6
- package/dist/lib/browser.js +0 -54
- package/dist/lib/bundle.d.ts +0 -234
- package/dist/lib/bundle.js +0 -781
- package/dist/lib/deprecate.d.ts +0 -32
- package/dist/lib/deprecate.js +0 -39
- package/dist/lib/flaky.d.ts +0 -91
- package/dist/lib/flaky.js +0 -71
- package/dist/lib/plan-poll.d.ts +0 -171
- package/dist/lib/plan-poll.js +0 -441
- package/dist/lib/plans.types.d.ts +0 -130
- package/dist/lib/plans.types.js +0 -31
- package/dist/lib/poll.d.ts +0 -100
- package/dist/lib/poll.js +0 -290
- package/dist/lib/rate-throttle.d.ts +0 -49
- package/dist/lib/rate-throttle.js +0 -75
- package/dist/lib/run-progress.d.ts +0 -41
- package/dist/lib/run-progress.js +0 -56
- package/dist/lib/v3-advisory.d.ts +0 -55
- package/dist/lib/v3-advisory.js +0 -74
- package/schemas/plan.schema.json +0 -61
package/dist/lib/errors.d.ts
CHANGED
|
@@ -168,13 +168,19 @@ export declare class ApiError extends CLIError {
|
|
|
168
168
|
* (e.g. `'... Remove --target-url.'`), and unconditionally appending a
|
|
169
169
|
* second period produced a doubled `..` at the end of the rendered message.
|
|
170
170
|
*/
|
|
171
|
-
export declare function localValidationError(field: string, reason: string, accepted?: unknown, kind?: 'flag' | 'field'): ApiError;
|
|
171
|
+
export declare function localValidationError(field: string, reason: string, accepted?: unknown, kind?: 'flag' | 'field' | 'argument'): ApiError;
|
|
172
|
+
export interface TransportErrorOptions {
|
|
173
|
+
/** Cause-specific remediation; defaults to the generic availability text. */
|
|
174
|
+
nextAction?: string;
|
|
175
|
+
/** Machine-readable cause, e.g. `{ cause: 'SELF_SIGNED_CERT_IN_CHAIN' }`. */
|
|
176
|
+
details?: Record<string, unknown>;
|
|
177
|
+
}
|
|
172
178
|
/**
|
|
173
179
|
* Network/transport failure not associated with a server envelope. Treated
|
|
174
180
|
* as `UNAVAILABLE` for exit-code purposes per design §8.2.
|
|
175
181
|
*/
|
|
176
182
|
export declare class TransportError extends ApiError {
|
|
177
|
-
constructor(message: string, requestId?: string);
|
|
183
|
+
constructor(message: string, requestId?: string, options?: TransportErrorOptions);
|
|
178
184
|
}
|
|
179
185
|
/**
|
|
180
186
|
* Client-side per-request timeout. The fetch was aborted because the
|
|
@@ -184,11 +190,21 @@ export declare class TransportError extends ApiError {
|
|
|
184
190
|
* as `TimeoutError` from the polling path. Use `--request-timeout <s>` or
|
|
185
191
|
* `TESTSPRITE_REQUEST_TIMEOUT_MS` to extend the deadline when targeting a
|
|
186
192
|
* slow backend.
|
|
193
|
+
*
|
|
194
|
+
* A caller working against a fixed internal deadline the `--request-timeout`
|
|
195
|
+
* flag does not govern (e.g. the environment preflight read) passes
|
|
196
|
+
* `message` / `nextAction` overrides so the rendered guidance names that
|
|
197
|
+
* deadline instead of pointing at the flag.
|
|
187
198
|
*/
|
|
188
199
|
export declare class RequestTimeoutError extends CLIError {
|
|
189
200
|
readonly requestId: string;
|
|
190
201
|
readonly timeoutMs: number;
|
|
191
|
-
|
|
202
|
+
/** Caller-specific envelope guidance; unset keeps the generic advice. */
|
|
203
|
+
readonly nextAction?: string;
|
|
204
|
+
constructor(timeoutMs: number, requestId?: string, options?: {
|
|
205
|
+
message?: string;
|
|
206
|
+
nextAction?: string;
|
|
207
|
+
});
|
|
192
208
|
}
|
|
193
209
|
/**
|
|
194
210
|
* The synthesized `nextAction` for an INSUFFICIENT_CREDITS refusal when the
|
|
@@ -197,7 +213,7 @@ export declare class RequestTimeoutError extends CLIError {
|
|
|
197
213
|
* prod portals live on different domains); an unknown host gets the route only —
|
|
198
214
|
* a hardcoded domain would point at the wrong environment.
|
|
199
215
|
*
|
|
200
|
-
*
|
|
216
|
+
* API keys are membership-bound: a key minted for a team org spends THAT
|
|
201
217
|
* org's wallet, not the holder's personal one, and there is no request-scoped
|
|
202
218
|
* signal at this layer to tell which kind of key just failed. So the hint
|
|
203
219
|
* deliberately does NOT assert "top up your (personal) credits" as the only
|
package/dist/lib/errors.js
CHANGED
|
@@ -16,8 +16,7 @@ export const ERROR_CODES = [
|
|
|
16
16
|
// `nextAction` points the operator at the Portal upload flow.
|
|
17
17
|
'PAYLOAD_TOO_LARGE',
|
|
18
18
|
'CONFLICT',
|
|
19
|
-
//
|
|
20
|
-
// `test code put`. Exit 6, same family as CONFLICT (the caller should
|
|
19
|
+
// HTTP 412 precondition failure. Exit 6, same family as CONFLICT (the caller should
|
|
21
20
|
// re-fetch and retry); kept distinct so machine consumers can route on
|
|
22
21
|
// it without parsing message strings.
|
|
23
22
|
'PRECONDITION_FAILED',
|
|
@@ -350,9 +349,15 @@ export class ApiError extends CLIError {
|
|
|
350
349
|
* second period produced a doubled `..` at the end of the rendered message.
|
|
351
350
|
*/
|
|
352
351
|
export function localValidationError(field, reason, accepted, kind = 'flag') {
|
|
352
|
+
let argName = field;
|
|
353
|
+
if (kind === 'argument' && !field.startsWith('<') && !field.startsWith('[')) {
|
|
354
|
+
argName = `<${field.replace(/[A-Z]/g, ch => `-${ch.toLowerCase()}`)}>`;
|
|
355
|
+
}
|
|
353
356
|
const subject = kind === 'flag'
|
|
354
357
|
? `Flag \`--${field.replace(/[A-Z]/g, ch => `-${ch.toLowerCase()}`)}\``
|
|
355
|
-
:
|
|
358
|
+
: kind === 'argument'
|
|
359
|
+
? `Argument \`${argName}\``
|
|
360
|
+
: `Field \`${field}\``;
|
|
356
361
|
const punctuatedReason = reason.endsWith('.') ? reason : `${reason}.`;
|
|
357
362
|
return ApiError.fromEnvelope({
|
|
358
363
|
error: {
|
|
@@ -369,13 +374,14 @@ export function localValidationError(field, reason, accepted, kind = 'flag') {
|
|
|
369
374
|
* as `UNAVAILABLE` for exit-code purposes per design §8.2.
|
|
370
375
|
*/
|
|
371
376
|
export class TransportError extends ApiError {
|
|
372
|
-
constructor(message, requestId = 'local') {
|
|
377
|
+
constructor(message, requestId = 'local', options = {}) {
|
|
373
378
|
super({
|
|
374
379
|
code: 'UNAVAILABLE',
|
|
375
380
|
message,
|
|
376
|
-
nextAction:
|
|
381
|
+
nextAction: options.nextAction ??
|
|
382
|
+
'Service is temporarily unavailable. The CLI retries with exponential backoff; if this persists, report it.',
|
|
377
383
|
requestId,
|
|
378
|
-
details: {},
|
|
384
|
+
details: options.details ?? {},
|
|
379
385
|
});
|
|
380
386
|
this.name = 'TransportError';
|
|
381
387
|
}
|
|
@@ -388,25 +394,39 @@ export class TransportError extends ApiError {
|
|
|
388
394
|
* as `TimeoutError` from the polling path. Use `--request-timeout <s>` or
|
|
389
395
|
* `TESTSPRITE_REQUEST_TIMEOUT_MS` to extend the deadline when targeting a
|
|
390
396
|
* slow backend.
|
|
397
|
+
*
|
|
398
|
+
* A caller working against a fixed internal deadline the `--request-timeout`
|
|
399
|
+
* flag does not govern (e.g. the environment preflight read) passes
|
|
400
|
+
* `message` / `nextAction` overrides so the rendered guidance names that
|
|
401
|
+
* deadline instead of pointing at the flag.
|
|
391
402
|
*/
|
|
392
403
|
export class RequestTimeoutError extends CLIError {
|
|
393
404
|
requestId;
|
|
394
405
|
timeoutMs;
|
|
395
|
-
|
|
406
|
+
/** Caller-specific envelope guidance; unset keeps the generic advice. */
|
|
407
|
+
nextAction;
|
|
408
|
+
constructor(timeoutMs, requestId = 'local', options = {}) {
|
|
396
409
|
const timeoutSec = Math.round(timeoutMs / 1000);
|
|
397
|
-
super(
|
|
398
|
-
`
|
|
410
|
+
super(options.message ??
|
|
411
|
+
`Request timed out after ${timeoutSec}s (client-side). ` +
|
|
412
|
+
`Use --request-timeout <seconds> or TESTSPRITE_REQUEST_TIMEOUT_MS to extend the deadline.`, 7, 'REQUEST_TIMEOUT');
|
|
399
413
|
this.name = 'RequestTimeoutError';
|
|
400
414
|
this.requestId = requestId;
|
|
401
415
|
this.timeoutMs = timeoutMs;
|
|
416
|
+
if (options.nextAction !== undefined)
|
|
417
|
+
this.nextAction = options.nextAction;
|
|
402
418
|
}
|
|
403
419
|
}
|
|
404
420
|
/**
|
|
405
421
|
* Every facade-emitted HTTP status maps to a
|
|
406
422
|
* known error code. When the envelope is missing or its `code` field is
|
|
407
|
-
* unrecognized (
|
|
408
|
-
*
|
|
409
|
-
*
|
|
423
|
+
* unrecognized (content was mangled), we fall back to the status-derived code
|
|
424
|
+
* so the retry budget and exit code match what the contract promises.
|
|
425
|
+
*
|
|
426
|
+
* `HttpClient` never routes a 4xx (other than 408/429) whose body is not JSON,
|
|
427
|
+
* including an empty one, through this mapping: that answer came from
|
|
428
|
+
* something between the CLI and the API (a proxy or firewall page), so it is
|
|
429
|
+
* reported as such instead of as a bad key, missing credits or an old CLI.
|
|
410
430
|
*/
|
|
411
431
|
function codeFromHttpStatus(status) {
|
|
412
432
|
switch (status) {
|
|
@@ -468,7 +488,7 @@ function isInsufficientCredits(rawCode, message, details) {
|
|
|
468
488
|
* prod portals live on different domains); an unknown host gets the route only —
|
|
469
489
|
* a hardcoded domain would point at the wrong environment.
|
|
470
490
|
*
|
|
471
|
-
*
|
|
491
|
+
* API keys are membership-bound: a key minted for a team org spends THAT
|
|
472
492
|
* org's wallet, not the holder's personal one, and there is no request-scoped
|
|
473
493
|
* signal at this layer to tell which kind of key just failed. So the hint
|
|
474
494
|
* deliberately does NOT assert "top up your (personal) credits" as the only
|
|
@@ -480,8 +500,8 @@ function isInsufficientCredits(rawCode, message, details) {
|
|
|
480
500
|
export function insufficientCreditsNextAction(apiUrl) {
|
|
481
501
|
const portalBase = apiUrl === undefined ? undefined : resolvePortalBase(apiUrl);
|
|
482
502
|
return ((portalBase !== undefined
|
|
483
|
-
? `Top up credits at ${portalBase}/dashboard/settings/billing (personal keys) — ask an org admin if this key is organization-bound — or upgrade your plan at ${portalBase}/pricing.`
|
|
484
|
-
: 'Top up credits on the portal Billing page (/dashboard/settings/billing) if this is a personal key — ask an org admin if it is organization-bound — or upgrade your plan (/pricing).') +
|
|
503
|
+
? `Top up credits at ${portalBase}/dashboard-v3/settings/billing (personal keys) — ask an org admin if this key is organization-bound — or upgrade your plan at ${portalBase}/pricing.`
|
|
504
|
+
: 'Top up credits on the portal Billing page (/dashboard-v3/settings/billing) if this is a personal key — ask an org admin if it is organization-bound — or upgrade your plan (/pricing).') +
|
|
485
505
|
' Run `testsprite usage` to check your current balance before the next run.');
|
|
486
506
|
}
|
|
487
507
|
/**
|
|
@@ -615,7 +635,7 @@ function parseEnvelopeBody(raw, httpStatus, apiUrl) {
|
|
|
615
635
|
// prod portals live on different domains); unknown hosts get the route
|
|
616
636
|
// only — a hardcoded domain would point at the wrong environment.
|
|
617
637
|
//
|
|
618
|
-
//
|
|
638
|
+
// API keys are membership-bound: a key minted for a team org spends
|
|
619
639
|
// THAT org's wallet, not the holder's personal one, and there is no
|
|
620
640
|
// request-scoped signal here (this branch fires client-side, purely
|
|
621
641
|
// from the HTTP status/body) to tell which kind of key just failed. So
|
package/dist/lib/facade.d.ts
CHANGED
|
@@ -7,26 +7,9 @@
|
|
|
7
7
|
export declare const FACADE_PATH = "/api/cli/v1";
|
|
8
8
|
export declare function facadeBaseUrl(endpointUrl: string): string;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* Coverage rule: only emit a dashboardUrl where BOTH projectId AND testId are
|
|
14
|
-
* already known client-side from the create/run response — no extra network calls.
|
|
15
|
-
* Currently covered commands:
|
|
16
|
-
* - `test create` / `test create-batch` (projectId from opts/spec — or, on the
|
|
17
|
-
* `--plan-from` path, from the validated plan body; testId from response).
|
|
18
|
-
* - `test run --wait`, `test wait`, `test rerun --wait` terminal output —
|
|
19
|
-
* `GET /runs/{runId}` carries both projectId and testId on the wire.
|
|
20
|
-
* - `test run --all` accepted items (projectId from opts, testId per item).
|
|
21
|
-
* NOT covered (wire gap, no lookup round-trip allowed): no-wait `test run` /
|
|
22
|
-
* `test rerun` trigger output (TriggerRunResponse lacks projectId) and
|
|
23
|
-
* `test result` (CliLatestResult lacks projectId).
|
|
24
|
-
*
|
|
25
|
-
* Normalization uses `new URL()` semantics (R2):
|
|
26
|
-
* - Protocol and hostname are lowercased.
|
|
27
|
-
* - An explicit `:443` on https is treated as the default port (omitted).
|
|
28
|
-
* - Trailing slashes and FACADE_PATH suffix are stripped before parsing.
|
|
29
|
-
* - URL parse failures → undefined (no crash).
|
|
10
|
+
* Map the configured API endpoint to the matching Portal origin (no path).
|
|
11
|
+
* Returns undefined for unknown hosts so callers emit nothing rather than a
|
|
12
|
+
* wrong-environment link.
|
|
30
13
|
*
|
|
31
14
|
* Mapping (match on normalized protocol, hostname, and port):
|
|
32
15
|
* TESTSPRITE_PORTAL_URL env var set → that origin verbatim (highest
|
|
@@ -35,14 +18,9 @@ export declare function facadeBaseUrl(endpointUrl: string): string;
|
|
|
35
18
|
* https://api.testsprite.com (port absent or 443) → https://www.testsprite.com
|
|
36
19
|
* anything else (unknown host, non-https on prod, parse failure) → undefined
|
|
37
20
|
*
|
|
38
|
-
*
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* Map the configured API endpoint to the matching Portal origin (no path).
|
|
43
|
-
* Honors the TESTSPRITE_PORTAL_URL override first; otherwise same
|
|
44
|
-
* normalization and host mapping as `resolvePortalUrl` (which delegates
|
|
45
|
-
* here); returns undefined for unknown hosts so callers emit nothing rather
|
|
46
|
-
* than a wrong-environment link.
|
|
21
|
+
* Normalization uses `new URL()` semantics: protocol and hostname are
|
|
22
|
+
* lowercased, an explicit `:443` on https is the default port, trailing
|
|
23
|
+
* slashes and the FACADE_PATH suffix are stripped before parsing, and a parse
|
|
24
|
+
* failure → undefined (no crash).
|
|
47
25
|
*/
|
|
48
26
|
export declare function resolvePortalBase(apiUrl: string): string | undefined;
|
package/dist/lib/facade.js
CHANGED
|
@@ -12,26 +12,9 @@ export function facadeBaseUrl(endpointUrl) {
|
|
|
12
12
|
return `${trimmed}${FACADE_PATH}`;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* Coverage rule: only emit a dashboardUrl where BOTH projectId AND testId are
|
|
19
|
-
* already known client-side from the create/run response — no extra network calls.
|
|
20
|
-
* Currently covered commands:
|
|
21
|
-
* - `test create` / `test create-batch` (projectId from opts/spec — or, on the
|
|
22
|
-
* `--plan-from` path, from the validated plan body; testId from response).
|
|
23
|
-
* - `test run --wait`, `test wait`, `test rerun --wait` terminal output —
|
|
24
|
-
* `GET /runs/{runId}` carries both projectId and testId on the wire.
|
|
25
|
-
* - `test run --all` accepted items (projectId from opts, testId per item).
|
|
26
|
-
* NOT covered (wire gap, no lookup round-trip allowed): no-wait `test run` /
|
|
27
|
-
* `test rerun` trigger output (TriggerRunResponse lacks projectId) and
|
|
28
|
-
* `test result` (CliLatestResult lacks projectId).
|
|
29
|
-
*
|
|
30
|
-
* Normalization uses `new URL()` semantics (R2):
|
|
31
|
-
* - Protocol and hostname are lowercased.
|
|
32
|
-
* - An explicit `:443` on https is treated as the default port (omitted).
|
|
33
|
-
* - Trailing slashes and FACADE_PATH suffix are stripped before parsing.
|
|
34
|
-
* - URL parse failures → undefined (no crash).
|
|
15
|
+
* Map the configured API endpoint to the matching Portal origin (no path).
|
|
16
|
+
* Returns undefined for unknown hosts so callers emit nothing rather than a
|
|
17
|
+
* wrong-environment link.
|
|
35
18
|
*
|
|
36
19
|
* Mapping (match on normalized protocol, hostname, and port):
|
|
37
20
|
* TESTSPRITE_PORTAL_URL env var set → that origin verbatim (highest
|
|
@@ -40,22 +23,10 @@ export function facadeBaseUrl(endpointUrl) {
|
|
|
40
23
|
* https://api.testsprite.com (port absent or 443) → https://www.testsprite.com
|
|
41
24
|
* anything else (unknown host, non-https on prod, parse failure) → undefined
|
|
42
25
|
*
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (portalBase === undefined)
|
|
48
|
-
return undefined;
|
|
49
|
-
// R4: encode path segments so future opaque ids (e.g. containing '#' or '?')
|
|
50
|
-
// produce a valid URL without breaking the path structure.
|
|
51
|
-
return `${portalBase}/dashboard/tests/${encodeURIComponent(projectId)}/test/${encodeURIComponent(testId)}`;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Map the configured API endpoint to the matching Portal origin (no path).
|
|
55
|
-
* Honors the TESTSPRITE_PORTAL_URL override first; otherwise same
|
|
56
|
-
* normalization and host mapping as `resolvePortalUrl` (which delegates
|
|
57
|
-
* here); returns undefined for unknown hosts so callers emit nothing rather
|
|
58
|
-
* than a wrong-environment link.
|
|
26
|
+
* Normalization uses `new URL()` semantics: protocol and hostname are
|
|
27
|
+
* lowercased, an explicit `:443` on https is the default port, trailing
|
|
28
|
+
* slashes and the FACADE_PATH suffix are stripped before parsing, and a parse
|
|
29
|
+
* failure → undefined (no crash).
|
|
59
30
|
*/
|
|
60
31
|
export function resolvePortalBase(apiUrl) {
|
|
61
32
|
// Operator override: lets any non-prod environment point dashboard links at
|
|
@@ -1,75 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Dev-e2e fixture resolver: confirms that the pinned `failingFrontendTestId`
|
|
3
|
+
* from `fixtures.local.json` is still failing, by its latest result. The
|
|
4
|
+
* suite's failing-path assertions need a test whose larun is red; a pin
|
|
5
|
+
* that went green is reported, never silently used.
|
|
3
6
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* discovered id on success, or `null` when no Failed test is found, the
|
|
8
|
-
* API call fails, or the required env / fixture preconditions are absent.
|
|
9
|
-
*
|
|
10
|
-
* The `null` path is intentionally non-throwing: callers fall back to the
|
|
11
|
-
* static `fixtures.local.json` value so the suite degrades gracefully on
|
|
12
|
-
* transient network issues.
|
|
13
|
-
*
|
|
14
|
-
* @see test/dev-e2e/global-setup.ts — invokes this at suite start and
|
|
15
|
-
* writes the result to `process.env.TESTSPRITE_DEV_FAILING_FE_TEST_ID`.
|
|
16
|
-
* @see test/dev-e2e/_shared.ts — `loadFixtures()` reads that env var and
|
|
17
|
-
* prefers it over the static fixture file value.
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* Minimal shape of an item returned by GET /tests.
|
|
21
|
-
* Only the fields we need for discovery; the full shape is in tests.dev-e2e.test.ts.
|
|
7
|
+
* `test list` says nothing about results, so there is no scan for "the
|
|
8
|
+
* freshest failed test": the pin is the one source, as the README asks for a
|
|
9
|
+
* dedicated, permanently-red fixture.
|
|
22
10
|
*/
|
|
23
|
-
export interface TestListItem {
|
|
24
|
-
id: string;
|
|
25
|
-
type: 'frontend' | 'backend';
|
|
26
|
-
status: string;
|
|
27
|
-
updatedAt: string;
|
|
28
|
-
}
|
|
29
11
|
export interface ResolverOptions {
|
|
30
12
|
/** Base URL for the CLI v1 API (e.g. https://api.testsprite.com/api/cli/v1) */
|
|
31
13
|
baseUrl: string;
|
|
32
14
|
/** API key sent as x-api-key header */
|
|
33
15
|
apiKey: string;
|
|
34
|
-
/**
|
|
35
|
-
projectId: string;
|
|
36
|
-
/**
|
|
37
|
-
* Optional fetch override for unit tests.
|
|
38
|
-
* Defaults to the global `fetch` when not provided.
|
|
39
|
-
*/
|
|
40
|
-
fetchImpl?: typeof fetch;
|
|
41
|
-
/**
|
|
42
|
-
* Maximum number of pages to walk (safety guard, default 5).
|
|
43
|
-
* Each page uses pageSize=50, so 5 pages = 250 tests scanned.
|
|
44
|
-
*/
|
|
45
|
-
maxPages?: number;
|
|
46
|
-
/**
|
|
47
|
-
* The operator's pinned `failingFrontendTestId` (the static value
|
|
48
|
-
* from fixtures.local.json). "Freshest failed" alone is fragile in a shared
|
|
49
|
-
* project: any OTHER FE test that fails more recently than a dedicated,
|
|
50
|
-
* permanently-red fixture silently steals the slot (live-reproduced
|
|
51
|
-
* 2026-07-16 — a `passingFrontendTestId` fresh-run flip immediately
|
|
52
|
-
* outranked the dedicated fixture on `updatedAt`). When set, the pinned id
|
|
53
|
-
* is probed directly first (one GET /tests/{id} — immune to the maxPages
|
|
54
|
-
* list-scan cap); if it is currently `status:failed` it wins outright,
|
|
55
|
-
* regardless of timestamp. If the probe errors, the list scan below still
|
|
56
|
-
* prefers the pinned id when it appears among the candidates. Falls through
|
|
57
|
-
* to the existing freshest-wins behavior when unset or no longer failing —
|
|
58
|
-
* fully backward compatible.
|
|
59
|
-
*/
|
|
16
|
+
/** The static `failingFrontendTestId` from fixtures.local.json. */
|
|
60
17
|
preferredId?: string;
|
|
18
|
+
/** Injectable fetch (tests). */
|
|
19
|
+
fetchImpl?: typeof fetch;
|
|
61
20
|
}
|
|
62
21
|
export interface ResolverResult {
|
|
63
|
-
/** The resolved failing frontend test id, or null if none found. */
|
|
64
22
|
testId: string | null;
|
|
65
|
-
/** Human-readable description of how the result was obtained. */
|
|
66
23
|
reason: string;
|
|
67
24
|
}
|
|
68
25
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* Returns `{ testId: null, reason: <explanation> }` on any error or
|
|
73
|
-
* when no Failed test exists — never throws.
|
|
26
|
+
* A test's newest result, as `result list --test <test-id> --limit 1` reads
|
|
27
|
+
* it: newest first, cancelled results left out.
|
|
74
28
|
*/
|
|
29
|
+
export declare function latestResultPath(testId: string): string;
|
|
75
30
|
export declare function resolveFailingFrontendTestId(opts: ResolverOptions): Promise<ResolverResult>;
|
|
@@ -1,151 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Dev-e2e fixture resolver: confirms that the pinned `failingFrontendTestId`
|
|
3
|
+
* from `fixtures.local.json` is still failing, by its latest result. The
|
|
4
|
+
* suite's failing-path assertions need a test whose larun is red; a pin
|
|
5
|
+
* that went green is reported, never silently used.
|
|
3
6
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* discovered id on success, or `null` when no Failed test is found, the
|
|
8
|
-
* API call fails, or the required env / fixture preconditions are absent.
|
|
9
|
-
*
|
|
10
|
-
* The `null` path is intentionally non-throwing: callers fall back to the
|
|
11
|
-
* static `fixtures.local.json` value so the suite degrades gracefully on
|
|
12
|
-
* transient network issues.
|
|
13
|
-
*
|
|
14
|
-
* @see test/dev-e2e/global-setup.ts — invokes this at suite start and
|
|
15
|
-
* writes the result to `process.env.TESTSPRITE_DEV_FAILING_FE_TEST_ID`.
|
|
16
|
-
* @see test/dev-e2e/_shared.ts — `loadFixtures()` reads that env var and
|
|
17
|
-
* prefers it over the static fixture file value.
|
|
7
|
+
* `test list` says nothing about results, so there is no scan for "the
|
|
8
|
+
* freshest failed test": the pin is the one source, as the README asks for a
|
|
9
|
+
* dedicated, permanently-red fixture.
|
|
18
10
|
*/
|
|
19
11
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* Returns `{ testId: null, reason: <explanation> }` on any error or
|
|
24
|
-
* when no Failed test exists — never throws.
|
|
12
|
+
* A test's newest result, as `result list --test <test-id> --limit 1` reads
|
|
13
|
+
* it: newest first, cancelled results left out.
|
|
25
14
|
*/
|
|
15
|
+
export function latestResultPath(testId) {
|
|
16
|
+
return `/results?test=${encodeURIComponent(testId)}&limit=1`;
|
|
17
|
+
}
|
|
26
18
|
export async function resolveFailingFrontendTestId(opts) {
|
|
27
|
-
const { baseUrl, apiKey,
|
|
19
|
+
const { baseUrl, apiKey, preferredId } = opts;
|
|
28
20
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// fixture beyond page `maxPages` would otherwise silently lose the slot to
|
|
32
|
-
// an incidental fresher failure). Any probe error or non-failed status
|
|
33
|
-
// falls through to the list scan; the in-candidates preference there
|
|
34
|
-
// remains as a second chance after a transient probe failure.
|
|
35
|
-
if (preferredId) {
|
|
36
|
-
try {
|
|
37
|
-
const resp = await fetchImpl(`${baseUrl}/tests/${encodeURIComponent(preferredId)}`, {
|
|
38
|
-
headers: {
|
|
39
|
-
'x-api-key': apiKey,
|
|
40
|
-
'x-request-id': `dev-e2e-resolver-preferred-${Date.now()}`,
|
|
41
|
-
accept: 'application/json',
|
|
42
|
-
},
|
|
43
|
-
signal: AbortSignal.timeout(10_000),
|
|
44
|
-
});
|
|
45
|
-
if (resp.ok) {
|
|
46
|
-
const test = (await resp.json());
|
|
47
|
-
// The probe must honor the resolver's project scope:
|
|
48
|
-
// the list path filters by projectId server-side, so a pin that
|
|
49
|
-
// points at a failed FE test in a DIFFERENT project must not win
|
|
50
|
-
// here either. A response without a matching projectId (absent or
|
|
51
|
-
// mismatched) falls through to the project-scoped list scan.
|
|
52
|
-
if (test.type === 'frontend' && test.status === 'failed' && test.projectId === projectId) {
|
|
53
|
-
return {
|
|
54
|
-
testId: preferredId,
|
|
55
|
-
reason: `Preferred pinned failingFrontendTestId (${preferredId}) confirmed status:failed ` +
|
|
56
|
-
`via direct GET (updatedAt=${test.updatedAt ?? 'unknown'}); list scan skipped`,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
// Transient probe failure — fall through to the list scan below.
|
|
63
|
-
}
|
|
21
|
+
if (!preferredId) {
|
|
22
|
+
return { testId: null, reason: 'no failingFrontendTestId pinned in fixtures.local.json' };
|
|
64
23
|
}
|
|
65
|
-
const
|
|
66
|
-
let cursor;
|
|
67
|
-
let pagesFetched = 0;
|
|
24
|
+
const path = latestResultPath(preferredId);
|
|
68
25
|
try {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
// Only keep frontend+failed items (the query params should filter, but be defensive)
|
|
99
|
-
for (const item of body.items) {
|
|
100
|
-
if (item.type === 'frontend' && item.status === 'failed') {
|
|
101
|
-
candidates.push(item);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
cursor = body.nextToken ?? undefined;
|
|
105
|
-
pagesFetched++;
|
|
106
|
-
} while (cursor && pagesFetched < maxPages);
|
|
107
|
-
}
|
|
108
|
-
catch (err) {
|
|
109
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
26
|
+
const resp = await fetchImpl(`${baseUrl}${path}`, {
|
|
27
|
+
headers: {
|
|
28
|
+
'x-api-key': apiKey,
|
|
29
|
+
'x-request-id': `dev-e2e-resolver-${Date.now()}`,
|
|
30
|
+
accept: 'application/json',
|
|
31
|
+
},
|
|
32
|
+
signal: AbortSignal.timeout(10_000),
|
|
33
|
+
});
|
|
34
|
+
if (!resp.ok) {
|
|
35
|
+
return {
|
|
36
|
+
testId: null,
|
|
37
|
+
reason: `GET ${path} returned HTTP ${resp.status}; static fixture used as-is`,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const latest = (await resp.json()).results?.[0];
|
|
41
|
+
if (!latest) {
|
|
42
|
+
return {
|
|
43
|
+
testId: null,
|
|
44
|
+
reason: `pinned failingFrontendTestId (${preferredId}) has no result yet; run it, or re-pin a red fixture`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const status = latest.testStatus?.toLowerCase() ?? 'unknown';
|
|
48
|
+
if (status === 'failed') {
|
|
49
|
+
return {
|
|
50
|
+
testId: preferredId,
|
|
51
|
+
reason: `pinned failingFrontendTestId (${preferredId}) is still failing (latest result created ${latest.created ?? 'unknown'})`,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
110
54
|
return {
|
|
111
55
|
testId: null,
|
|
112
|
-
reason: `
|
|
56
|
+
reason: `pinned failingFrontendTestId (${preferredId}) has latest result ${status}, not failed; re-pin a red fixture`,
|
|
113
57
|
};
|
|
114
58
|
}
|
|
115
|
-
|
|
59
|
+
catch (err) {
|
|
116
60
|
return {
|
|
117
61
|
testId: null,
|
|
118
|
-
reason:
|
|
62
|
+
reason: `probe of the pinned failingFrontendTestId failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
119
63
|
};
|
|
120
64
|
}
|
|
121
|
-
// A pinned, dedicated "always red" fixture wins over freshest
|
|
122
|
-
// whenever it is still in the failed set — see the doc comment on
|
|
123
|
-
// ResolverOptions.preferredId for why "freshest" alone is not enough.
|
|
124
|
-
if (preferredId) {
|
|
125
|
-
const pinned = candidates.find(c => c.id === preferredId);
|
|
126
|
-
if (pinned) {
|
|
127
|
-
return {
|
|
128
|
-
testId: pinned.id,
|
|
129
|
-
reason: `Preferred pinned failingFrontendTestId (${pinned.id}) is still status:failed (updatedAt=${pinned.updatedAt}); took priority over freshest-updatedAt candidate`,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
// Pick the most recently updated candidate — freshest failure is the
|
|
134
|
-
// most likely to have a valid failure bundle attached.
|
|
135
|
-
candidates.sort((a, b) => {
|
|
136
|
-
const ta = new Date(a.updatedAt).getTime();
|
|
137
|
-
const tb = new Date(b.updatedAt).getTime();
|
|
138
|
-
return tb - ta; // descending: freshest first
|
|
139
|
-
});
|
|
140
|
-
const best = candidates[0];
|
|
141
|
-
if (!best) {
|
|
142
|
-
// Unreachable: the early return above guards candidates.length === 0,
|
|
143
|
-
// but TypeScript requires the narrowing here due to noUncheckedIndexedAccess.
|
|
144
|
-
return { testId: null, reason: 'No candidates after sort (unexpected)' };
|
|
145
|
-
}
|
|
146
|
-
return {
|
|
147
|
-
testId: best.id,
|
|
148
|
-
reason: `Discovered from ${pagesFetched} page(s) of GET /tests; freshest failed test updatedAt=${best.updatedAt}`,
|
|
149
|
-
};
|
|
150
65
|
}
|
|
151
66
|
//# sourceMappingURL=failing-fe-resolver.js.map
|