@testsprite/testsprite-cli 0.6.0 → 0.8.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 -31
- package/dist/commands/agent.js +91 -45
- package/dist/commands/ci.d.ts +88 -0
- package/dist/commands/ci.js +429 -0
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.js +104 -8
- package/dist/commands/init.js +8 -0
- package/dist/commands/project.d.ts +78 -0
- package/dist/commands/project.js +429 -5
- package/dist/commands/schedule.d.ts +120 -0
- package/dist/commands/schedule.js +487 -0
- package/dist/commands/test.d.ts +176 -2
- package/dist/commands/test.js +2235 -609
- package/dist/commands/testlist.d.ts +88 -0
- package/dist/commands/testlist.js +753 -0
- package/dist/commands/tunnel.d.ts +72 -0
- package/dist/commands/tunnel.js +367 -0
- package/dist/index.js +113 -40
- package/dist/lib/agent-targets.d.ts +13 -4
- package/dist/lib/agent-targets.js +11 -2
- package/dist/lib/conflict-reason.d.ts +30 -0
- package/dist/lib/conflict-reason.js +45 -0
- package/dist/lib/credentials.js +42 -1
- package/dist/lib/cron.d.ts +40 -0
- package/dist/lib/cron.js +190 -0
- package/dist/lib/dry-run/samples.d.ts +9 -0
- package/dist/lib/dry-run/samples.js +293 -55
- package/dist/lib/errors.d.ts +9 -0
- package/dist/lib/errors.js +11 -0
- package/dist/lib/gh-output.d.ts +33 -1
- package/dist/lib/gh-output.js +97 -27
- package/dist/lib/http.d.ts +119 -0
- package/dist/lib/http.js +243 -2
- package/dist/lib/interrupt.d.ts +38 -13
- package/dist/lib/interrupt.js +130 -15
- package/dist/lib/junit-report.d.ts +20 -2
- package/dist/lib/junit-report.js +38 -5
- package/dist/lib/local-target.d.ts +95 -0
- package/dist/lib/local-target.js +184 -0
- package/dist/lib/plan-poll.d.ts +171 -0
- package/dist/lib/plan-poll.js +442 -0
- package/dist/lib/plans.types.d.ts +130 -0
- package/dist/lib/plans.types.js +31 -0
- package/dist/lib/poll-support.d.ts +26 -0
- package/dist/lib/poll-support.js +65 -0
- package/dist/lib/poll.d.ts +1 -0
- package/dist/lib/poll.js +2 -40
- package/dist/lib/proxy.d.ts +16 -0
- package/dist/lib/proxy.js +19 -1
- package/dist/lib/response-schemas.d.ts +20 -0
- package/dist/lib/response-schemas.js +55 -1
- package/dist/lib/run-progress.d.ts +41 -0
- package/dist/lib/run-progress.js +56 -0
- package/dist/lib/runs.types.d.ts +32 -3
- package/dist/lib/secret-file.d.ts +15 -0
- package/dist/lib/secret-file.js +82 -0
- package/dist/lib/target-url-preflight.d.ts +91 -0
- package/dist/lib/target-url-preflight.js +259 -0
- package/dist/lib/target-url.d.ts +63 -9
- package/dist/lib/target-url.js +283 -62
- package/dist/lib/telemetry.d.ts +11 -0
- package/dist/lib/telemetry.js +1 -0
- package/dist/lib/testlist.types.d.ts +77 -0
- package/dist/lib/testlist.types.js +9 -0
- package/dist/lib/ticker.d.ts +8 -0
- package/dist/lib/ticker.js +3 -0
- package/dist/lib/tunnel-session.d.ts +129 -0
- package/dist/lib/tunnel-session.js +232 -0
- package/dist/lib/tunnel.types.d.ts +54 -0
- package/dist/lib/tunnel.types.js +8 -0
- package/dist/lib/v3-advisory.d.ts +35 -22
- package/dist/lib/v3-advisory.js +44 -24
- package/dist/lib/wait-exit.d.ts +29 -0
- package/dist/lib/wait-exit.js +103 -0
- package/dist/vendor/tunnel-client/client.d.ts +83 -0
- package/dist/vendor/tunnel-client/client.js +871 -0
- package/dist/vendor/tunnel-client/config.d.ts +41 -0
- package/dist/vendor/tunnel-client/config.js +42 -0
- package/dist/vendor/tunnel-client/index.d.ts +9 -0
- package/dist/vendor/tunnel-client/index.js +9 -0
- package/dist/vendor/tunnel-client/lodash-lite.d.ts +14 -0
- package/dist/vendor/tunnel-client/lodash-lite.js +24 -0
- package/dist/vendor/tunnel-client/protocol.d.ts +60 -0
- package/dist/vendor/tunnel-client/protocol.js +143 -0
- package/dist/vendor/tunnel-client/types.d.ts +96 -0
- package/dist/vendor/tunnel-client/types.js +10 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +206 -0
- package/dist/vendor/tunnel-client/ws-compat.js +316 -0
- package/dist/version-guard.d.ts +10 -7
- package/dist/version-guard.js +37 -9
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -1
- package/skills/testsprite-onboard.skill.md +60 -4
- package/skills/testsprite-verify.codex.md +22 -16
- package/skills/testsprite-verify.skill.md +27 -18
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ApiError, CLIError, isAuthCode } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Exit-code precedence for a `--wait` fan-out, highest first. Ordered
|
|
4
|
+
* batch-wide-non-retriable → per-run → transient → timeout → generic:
|
|
5
|
+
* - auth (3) and CLIENT_TOO_OLD (14): a bad credential / too-old client fails
|
|
6
|
+
* EVERY poll and retrying can never succeed — batch-wide, so they top the
|
|
7
|
+
* table (a transient `RATE_LIMITED` "retry later" must never outrank them).
|
|
8
|
+
* - INSUFFICIENT_CREDITS (12) / FEATURE_GATED (13): per-run, non-retriable.
|
|
9
|
+
* - NOT_FOUND (4) / VALIDATION_ERROR (5) / CONFLICT (6): per-run.
|
|
10
|
+
* - RATE_LIMITED (11) / UNAVAILABLE (10): transient — a retry may help.
|
|
11
|
+
* - timeout (7): outranks only a generic failure.
|
|
12
|
+
* - generic (1): the floor (genuine test-fail / INTERNAL).
|
|
13
|
+
* A code NOT in this table folds into the generic bucket (never surfaced as an
|
|
14
|
+
* operational error), so an out-of-contract exit (0, 99, a leaked signal code)
|
|
15
|
+
* can neither preempt a real verdict nor produce a printed-failure-green-exit.
|
|
16
|
+
*/
|
|
17
|
+
const WAIT_EXIT_PRIORITY = [3, 14, 12, 13, 4, 5, 6, 11, 10, 7, 1];
|
|
18
|
+
/**
|
|
19
|
+
* A "typed operational" code is one that sits in the precedence table above the
|
|
20
|
+
* generic floor — known AND not the generic `1`. Everything else (unknown
|
|
21
|
+
* codes, `0`, INTERNAL/1) folds into the generic failure bucket.
|
|
22
|
+
*/
|
|
23
|
+
function isOperationalCode(exitCode) {
|
|
24
|
+
return (exitCode !== 1 && WAIT_EXIT_PRIORITY.includes(exitCode));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Index of `exitCode` in the precedence table (lower = higher priority). Only
|
|
28
|
+
* ever called on operational codes (see `isOperationalCode`), so the index is
|
|
29
|
+
* always valid.
|
|
30
|
+
*/
|
|
31
|
+
function priorityOf(exitCode) {
|
|
32
|
+
return WAIT_EXIT_PRIORITY.indexOf(exitCode);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolve the process-level failure for a completed `--wait` fan-out, or `null`
|
|
36
|
+
* when every member passed. Shared by `test run --all` / `test rerun` and
|
|
37
|
+
* `testlist run` so their exit-code semantics can't drift.
|
|
38
|
+
*
|
|
39
|
+
* Precedence (see {@link WAIT_EXIT_PRIORITY}): auth / client-too-old → typed
|
|
40
|
+
* operational ApiError → timeout (7) → generic test-failure (1).
|
|
41
|
+
*/
|
|
42
|
+
export function resolveWaitFailure(results, opts) {
|
|
43
|
+
const timedOut = results.filter(r => r.status === 'timeout');
|
|
44
|
+
const errored = results.filter((r) => r.status === 'error' && r.error !== undefined);
|
|
45
|
+
// A genuine test failure: terminal-not-passed, and not one of the synthesized
|
|
46
|
+
// timeout/typed-error members above.
|
|
47
|
+
const failed = results.filter(r => r.status !== 'passed' && r.status !== 'timeout' && !(r.status === 'error' && r.error));
|
|
48
|
+
// How many runs did NOT pass — used for the auth failure count so the message
|
|
49
|
+
// agrees with the "N failed/blocked" summary printed just above it.
|
|
50
|
+
const notPassed = results.filter(r => r.status !== 'passed').length;
|
|
51
|
+
// 1) Auth wins over everything — the credential is bad, not the test.
|
|
52
|
+
// Classified via the single `isAuthCode` source (derived from `exitCodeFor`)
|
|
53
|
+
// rather than a local `=== 3` so a future AUTH_* code can't be missed here.
|
|
54
|
+
const authErr = errored.find(r => isAuthCode(r.error.code));
|
|
55
|
+
if (authErr) {
|
|
56
|
+
return new CLIError(`${notPassed} run${notPassed !== 1 ? 's' : ''} failed — auth error (${authErr.error.code}): ${authErr.error.message}`, 3);
|
|
57
|
+
}
|
|
58
|
+
// 2) Any other typed operational ApiError, highest-priority first. Only codes
|
|
59
|
+
// IN the precedence table qualify — an unknown / out-of-contract code folds
|
|
60
|
+
// into the generic bucket below rather than being surfaced (or leaking a
|
|
61
|
+
// non-1 exit like 0/99). Routed through the ENVELOPE so `--output json`
|
|
62
|
+
// carries `error.code` — the machine-readable field this fix exists for;
|
|
63
|
+
// `ApiError.fromEnvelope` derives the exit via `exitCodeFor(code)`.
|
|
64
|
+
const operational = errored
|
|
65
|
+
.filter(r => isOperationalCode(r.error.exitCode ?? 1))
|
|
66
|
+
.sort((a, b) => priorityOf(a.error.exitCode) - priorityOf(b.error.exitCode))[0];
|
|
67
|
+
if (operational) {
|
|
68
|
+
return ApiError.fromEnvelope({
|
|
69
|
+
error: {
|
|
70
|
+
code: operational.error.code,
|
|
71
|
+
message: operational.error.message,
|
|
72
|
+
nextAction: '',
|
|
73
|
+
requestId: 'local',
|
|
74
|
+
details: { runId: operational.runId ?? null, testId: operational.testId ?? null },
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// 3) Timeout — outranks a generic failure so the operator gets resume/cancel
|
|
79
|
+
// guidance for the runs that didn't finish.
|
|
80
|
+
if (timedOut.length > 0) {
|
|
81
|
+
const runIds = timedOut.map(r => r.runId).filter((id) => Boolean(id));
|
|
82
|
+
return ApiError.fromEnvelope({
|
|
83
|
+
error: {
|
|
84
|
+
code: 'UNSUPPORTED',
|
|
85
|
+
message: `${timedOut.length} run${timedOut.length !== 1 ? 's' : ''} timed out.`,
|
|
86
|
+
nextAction: [
|
|
87
|
+
...runIds.map(rid => `Resume: testsprite test wait ${rid}`),
|
|
88
|
+
...runIds.map(rid => `Cancel: testsprite test cancel ${rid}`),
|
|
89
|
+
].join('\n'),
|
|
90
|
+
requestId: 'local',
|
|
91
|
+
details: { timedOutRunIds: runIds, timeoutSeconds: opts.timeoutSeconds },
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
// 4) Generic test failures — genuine test-fails, INTERNAL (1), and any
|
|
96
|
+
// unknown / out-of-contract error code folded here.
|
|
97
|
+
const genericCount = failed.length + errored.filter(r => !isOperationalCode(r.error.exitCode ?? 1)).length;
|
|
98
|
+
if (genericCount > 0) {
|
|
99
|
+
return new CLIError(`${genericCount} run${genericCount !== 1 ? 's' : ''} failed.`, 1);
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=wait-exit.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import { TunnelClientOptions } from "./types.js";
|
|
3
|
+
export declare class TunnelClient extends EventEmitter {
|
|
4
|
+
private readonly options;
|
|
5
|
+
private running;
|
|
6
|
+
private controlConnected;
|
|
7
|
+
private controlWs?;
|
|
8
|
+
private controlLoopTask?;
|
|
9
|
+
private allowTunnelReconnect;
|
|
10
|
+
private readonly tunnelRuntimes;
|
|
11
|
+
private reconnectDelayController;
|
|
12
|
+
private readonly activeTargetSockets;
|
|
13
|
+
constructor(options: TunnelClientOptions);
|
|
14
|
+
start(): Promise<void>;
|
|
15
|
+
stop(): Promise<void>;
|
|
16
|
+
private runControlLoop;
|
|
17
|
+
private runTunnelLoop;
|
|
18
|
+
private connectControl;
|
|
19
|
+
private sendControlMessage;
|
|
20
|
+
private parseControlMessage;
|
|
21
|
+
private ensureTunnelRuntime;
|
|
22
|
+
private connectTunnel;
|
|
23
|
+
private stopAllTunnelRuntimes;
|
|
24
|
+
private handleIncomingStream;
|
|
25
|
+
private proxyStreams;
|
|
26
|
+
private copyOneWay;
|
|
27
|
+
private connectTarget;
|
|
28
|
+
private connectOnce;
|
|
29
|
+
private log;
|
|
30
|
+
private reportError;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolve `host:port` to the exact set of addresses a dial will be attempted against.
|
|
34
|
+
*
|
|
35
|
+
* Mirrors the Rust client's `dial_candidates`: for `localhost` (case-insensitive), `127.0.0.1`
|
|
36
|
+
* and `::1` are added up front; the host is then also resolved normally (an IP literal parses
|
|
37
|
+
* without touching the network, exactly like Rust's `to_socket_addrs`; anything else goes
|
|
38
|
+
* through `dns.lookup`, i.e. getaddrinfo, honoring `/etc/hosts`), and any additional resolved
|
|
39
|
+
* addresses are appended, deduplicated.
|
|
40
|
+
*
|
|
41
|
+
* Callers must validate and dial this exact returned list — re-resolving `host` a second time
|
|
42
|
+
* reopens the DNS-rebind window this function exists to close.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveDialCandidates(host: string, port: number): Promise<Array<{
|
|
45
|
+
host: string;
|
|
46
|
+
port: number;
|
|
47
|
+
}>>;
|
|
48
|
+
/**
|
|
49
|
+
* Why `address` (a literal IPv4 or IPv6 address, e.g. from {@link resolveDialCandidates}) must not
|
|
50
|
+
* be dialled, or `undefined` if it is acceptable. Mirrors the Rust client's
|
|
51
|
+
* `blocked_target_reason` — the two must agree exactly, or the same request succeeds on one
|
|
52
|
+
* client and fails on the other.
|
|
53
|
+
*
|
|
54
|
+
* Acceptable = loopback (the app under test) or a globally-routable address (the fonts, CDNs and
|
|
55
|
+
* third-party APIs a real page legitimately loads). Blocked = the private address space, which is
|
|
56
|
+
* only reachable because this client runs inside someone's network.
|
|
57
|
+
*
|
|
58
|
+
* Not a hostname resolver — callers pass already-resolved literals.
|
|
59
|
+
*/
|
|
60
|
+
export declare function blockedTargetReason(address: string): string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Ensure no candidate in `candidates` sits in a blocked range, unless `allowPrivateNetwork` opts
|
|
63
|
+
* out. Mirrors the Rust client's `ensure_candidates_allowed` / `ensure_target_allowed`: takes an
|
|
64
|
+
* already-resolved candidate set (rather than resolving internally) so callers about to dial that
|
|
65
|
+
* exact set can validate it without a second, independent DNS lookup.
|
|
66
|
+
*
|
|
67
|
+
* Deliberately NOT loopback-only: the browser under test proxies every request through this
|
|
68
|
+
* tunnel (Chromium `bypass='<-loopback>'`), so public targets are normal subresource traffic.
|
|
69
|
+
* See the Rust `ensure_target_allowed` doc comment for the full rationale.
|
|
70
|
+
*/
|
|
71
|
+
export declare function ensureTargetAllowed(host: string, port: number, candidates: Array<{
|
|
72
|
+
host: string;
|
|
73
|
+
port: number;
|
|
74
|
+
}>, allowPrivateNetwork: boolean): void;
|
|
75
|
+
/**
|
|
76
|
+
* Thrown by {@link ensureTargetAllowed} when a proxied target resolves into a blocked
|
|
77
|
+
* (private/internal) range and the client has not opted in via `allowPrivateNetworkTarget` /
|
|
78
|
+
* `TS_TUNNEL_ALLOW_PRIVATE_NETWORK_TARGET`. Mirrors the Rust client's
|
|
79
|
+
* `ensure_candidates_allowed` error.
|
|
80
|
+
*/
|
|
81
|
+
export declare class BlockedTargetError extends Error {
|
|
82
|
+
constructor(host: string, port: number, address?: string, reason?: string);
|
|
83
|
+
}
|