@testsprite/testsprite-cli 0.14.0 → 0.16.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 +27 -17
- package/dist/commands/agent.js +7 -2
- package/dist/commands/auth.js +7 -3
- package/dist/commands/ci.d.ts +66 -17
- package/dist/commands/ci.js +486 -122
- package/dist/commands/completion.js +2 -1
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.js +52 -10
- package/dist/commands/init.js +25 -5
- package/dist/commands/project-env.js +39 -17
- package/dist/commands/project-sign-in.js +9 -4
- package/dist/commands/project.js +43 -22
- package/dist/commands/schedule.js +24 -15
- package/dist/commands/test.d.ts +105 -36
- package/dist/commands/test.js +1494 -847
- package/dist/commands/testlist.js +13 -3
- package/dist/commands/tunnel.js +23 -25
- package/dist/commands/usage.js +1 -0
- package/dist/index.js +14 -7
- package/dist/lib/agent-targets.d.ts +8 -3
- package/dist/lib/agent-targets.js +15 -4
- package/dist/lib/ci-run.d.ts +11 -0
- package/dist/lib/ci-run.js +34 -0
- package/dist/lib/client-factory.d.ts +23 -0
- package/dist/lib/client-factory.js +7 -6
- package/dist/lib/config.d.ts +1 -0
- package/dist/lib/config.js +1 -1
- package/dist/lib/conflict-reason.d.ts +24 -3
- package/dist/lib/conflict-reason.js +33 -2
- package/dist/lib/credentials.d.ts +0 -1
- package/dist/lib/credentials.js +51 -14
- package/dist/lib/deprecate.d.ts +22 -0
- package/dist/lib/deprecate.js +26 -0
- package/dist/lib/dry-run/samples.js +56 -5
- package/dist/lib/environment-tunnel.d.ts +2 -1
- package/dist/lib/environment-tunnel.js +1 -4
- package/dist/lib/first-suite-hint.d.ts +55 -0
- package/dist/lib/first-suite-hint.js +101 -0
- package/dist/lib/gh-output.d.ts +62 -4
- package/dist/lib/gh-output.js +149 -7
- package/dist/lib/github-context.d.ts +21 -0
- package/dist/lib/github-context.js +153 -0
- package/dist/lib/http.d.ts +10 -1
- package/dist/lib/http.js +29 -3
- package/dist/lib/junit-report.d.ts +3 -0
- package/dist/lib/junit-report.js +8 -1
- package/dist/lib/output.d.ts +11 -1
- package/dist/lib/output.js +17 -2
- package/dist/lib/plans.types.d.ts +1 -1
- package/dist/lib/response-schemas.d.ts +5 -1
- package/dist/lib/response-schemas.js +57 -0
- package/dist/lib/runs.types.d.ts +122 -0
- package/dist/lib/telemetry.d.ts +26 -2
- package/dist/lib/telemetry.js +47 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/schemas/plan.schema.json +2 -2
- package/skills/testsprite-ci.skill.md +154 -0
- package/skills/testsprite-verify.codex.md +7 -7
- package/skills/testsprite-verify.skill.md +24 -21
package/dist/lib/deprecate.d.ts
CHANGED
|
@@ -8,3 +8,25 @@
|
|
|
8
8
|
* stderr — stdout stays clean so JSON pipelines are unaffected.
|
|
9
9
|
*/
|
|
10
10
|
export declare function emitDeprecationNotice(oldCmd: string, newCmd: string, stderr?: (line: string) => void): void;
|
|
11
|
+
/** Release that deletes the commands deprecated in the 0.16 line. */
|
|
12
|
+
export declare const REMOVED_IN = "0.17.0";
|
|
13
|
+
/**
|
|
14
|
+
* A deprecated command and the invocation that replaces it. `command` is the
|
|
15
|
+
* full name (`test rerun`) so the same entry feeds the stderr notice and the
|
|
16
|
+
* JSON `deprecations` key. `replacement` is a template, not a command to run
|
|
17
|
+
* as is: the caller's ids and flags carry over (see the notice's advice).
|
|
18
|
+
*/
|
|
19
|
+
export interface DeprecationEntry {
|
|
20
|
+
command: string;
|
|
21
|
+
replacement: string;
|
|
22
|
+
removedIn: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const TEST_RERUN_DEPRECATION: DeprecationEntry;
|
|
25
|
+
export declare const TEST_FLAKY_DEPRECATION: DeprecationEntry;
|
|
26
|
+
/**
|
|
27
|
+
* `advice` replaces the default "Use `<replacement>`." sentence with command-specific
|
|
28
|
+
* migration steps. `noReplacement` says so in the lead sentence for a command that is
|
|
29
|
+
* deleted outright.
|
|
30
|
+
*/
|
|
31
|
+
export declare function deprecationNoticeLine(entry: DeprecationEntry, advice?: string, noReplacement?: boolean): string;
|
|
32
|
+
export declare function emitDeprecationEntry(entry: DeprecationEntry, stderr?: (line: string) => void, advice?: string, noReplacement?: boolean): void;
|
package/dist/lib/deprecate.js
CHANGED
|
@@ -10,4 +10,30 @@
|
|
|
10
10
|
export function emitDeprecationNotice(oldCmd, newCmd, stderr = (line) => process.stderr.write(`${line}\n`)) {
|
|
11
11
|
stderr(`[deprecated] \`testsprite ${oldCmd}\` is deprecated — use \`testsprite ${newCmd}\`.`);
|
|
12
12
|
}
|
|
13
|
+
/** Release that deletes the commands deprecated in the 0.16 line. */
|
|
14
|
+
export const REMOVED_IN = '0.17.0';
|
|
15
|
+
export const TEST_RERUN_DEPRECATION = {
|
|
16
|
+
command: 'test rerun',
|
|
17
|
+
replacement: 'test run',
|
|
18
|
+
removedIn: REMOVED_IN,
|
|
19
|
+
};
|
|
20
|
+
// `test flaky` has no replacement; `replacement` names the command that samples a test again.
|
|
21
|
+
export const TEST_FLAKY_DEPRECATION = {
|
|
22
|
+
command: 'test flaky',
|
|
23
|
+
replacement: 'test run',
|
|
24
|
+
removedIn: REMOVED_IN,
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* `advice` replaces the default "Use `<replacement>`." sentence with command-specific
|
|
28
|
+
* migration steps. `noReplacement` says so in the lead sentence for a command that is
|
|
29
|
+
* deleted outright.
|
|
30
|
+
*/
|
|
31
|
+
export function deprecationNoticeLine(entry, advice, noReplacement = false) {
|
|
32
|
+
return (`[deprecated] \`testsprite ${entry.command}\` is deprecated and will be removed in ${entry.removedIn}` +
|
|
33
|
+
(noReplacement ? ', with no replacement. ' : '. ') +
|
|
34
|
+
(advice ?? `Use \`testsprite ${entry.replacement}\`.`));
|
|
35
|
+
}
|
|
36
|
+
export function emitDeprecationEntry(entry, stderr = (line) => process.stderr.write(`${line}\n`), advice, noReplacement = false) {
|
|
37
|
+
stderr(deprecationNoticeLine(entry, advice, noReplacement));
|
|
38
|
+
}
|
|
13
39
|
//# sourceMappingURL=deprecate.js.map
|
|
@@ -134,7 +134,7 @@ const tests = [
|
|
|
134
134
|
createdFrom: 'portal',
|
|
135
135
|
status: 'failed',
|
|
136
136
|
// G1a — priority label shown on one row so dry-run learners see the field.
|
|
137
|
-
priority: '
|
|
137
|
+
priority: 'Medium',
|
|
138
138
|
createdAt: '2026-04-20T11:00:00.000Z',
|
|
139
139
|
updatedAt: '2026-05-05T12:34:56.000Z',
|
|
140
140
|
details: {
|
|
@@ -331,6 +331,44 @@ const failureSummary = {
|
|
|
331
331
|
rootCauseHypothesis: failureContext.failure.rootCauseHypothesis,
|
|
332
332
|
recommendedFixTarget: failureContext.failure.recommendedFixTarget,
|
|
333
333
|
};
|
|
334
|
+
const SAMPLE_EXECUTION_ID = 'exec_dryrun0001';
|
|
335
|
+
/** A ready execution report: one failed and one passed row, the App's Markdown shape in miniature. */
|
|
336
|
+
const executionReportSample = {
|
|
337
|
+
ready: true,
|
|
338
|
+
report: {
|
|
339
|
+
projectId: SAMPLE_PROJECT_ID,
|
|
340
|
+
executionId: SAMPLE_EXECUTION_ID,
|
|
341
|
+
projectName: 'Sample project',
|
|
342
|
+
orgId: null,
|
|
343
|
+
stats: { passed: 1, failed: 1, blocked: 0, total: 2 },
|
|
344
|
+
allPassed: false,
|
|
345
|
+
narrative: 'Dry-run sample: one regression in checkout, login passed.',
|
|
346
|
+
whatCouldBeBetter: 'Add coverage for password reset.',
|
|
347
|
+
recommendedNextStep: 'Fix the checkout selector and rerun.',
|
|
348
|
+
tests: [
|
|
349
|
+
{
|
|
350
|
+
id: SAMPLE_RUN_ID,
|
|
351
|
+
title: 'Checkout applies a coupon',
|
|
352
|
+
slug: 'CHK-002',
|
|
353
|
+
status: 'FAILED',
|
|
354
|
+
screenshotUrl: null,
|
|
355
|
+
error: 'AssertionError: expected the order total to drop',
|
|
356
|
+
fix: 'Apply the coupon before computing the total.',
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
id: `${SAMPLE_RUN_ID}-2`,
|
|
360
|
+
title: 'Login with a valid account',
|
|
361
|
+
slug: 'AUTH-001',
|
|
362
|
+
status: 'PASSED',
|
|
363
|
+
screenshotUrl: null,
|
|
364
|
+
error: null,
|
|
365
|
+
fix: null,
|
|
366
|
+
},
|
|
367
|
+
],
|
|
368
|
+
resultUrl: `https://www.testsprite.com/dashboard-v3/projects/${SAMPLE_PROJECT_ID}/execution/${SAMPLE_EXECUTION_ID}`,
|
|
369
|
+
},
|
|
370
|
+
markdown: '> [!WARNING]\n> ### Ran into trouble — 1 failed\n>\n> Dry-run sample: one regression in checkout, login passed.\n',
|
|
371
|
+
};
|
|
334
372
|
const passedRunSample = {
|
|
335
373
|
runId: SAMPLE_RUN_ID,
|
|
336
374
|
testId: SAMPLE_TEST_ID_PASSED,
|
|
@@ -647,6 +685,9 @@ const ENTRIES = [
|
|
|
647
685
|
entry('getTestCode', 'GET', '/tests/{testId}/code', testCode),
|
|
648
686
|
entry('listTestSteps', 'GET', '/tests/{testId}/steps', pageOf(testSteps)),
|
|
649
687
|
entry('getTestResult', 'GET', '/tests/{testId}/result', latestResult),
|
|
688
|
+
// Execution report — static `executions/` prefix, four segments, so no
|
|
689
|
+
// `/tests/{testId}/…` pattern can shadow it; kept beside the other reads.
|
|
690
|
+
entry('getExecutionReport', 'GET', '/tests/executions/{executionId}/report', executionReportSample),
|
|
650
691
|
// `/failure/summary` MUST come before `/failure` so the regex matcher
|
|
651
692
|
// doesn't shadow it with the bundle endpoint.
|
|
652
693
|
entry('getTestFailureSummary', 'GET', '/tests/{testId}/failure/summary', failureSummary),
|
|
@@ -850,13 +891,14 @@ const ENTRIES = [
|
|
|
850
891
|
// **MUST appear before `/tests` and `/tests/{testId}` generic matchers**
|
|
851
892
|
// so the more-specific runs path wins. Canned response shape per the
|
|
852
893
|
// runs-trigger design spec.
|
|
853
|
-
entry('triggerRun', 'POST', '/tests/{testId}/runs', {
|
|
894
|
+
entry('triggerRun', 'POST', '/tests/{testId}/runs', (req) => ({
|
|
854
895
|
runId: SAMPLE_RUN_ID,
|
|
855
896
|
status: 'queued',
|
|
856
897
|
enqueuedAt: '2026-05-15T19:32:00.000Z',
|
|
857
898
|
codeVersion: 'v1',
|
|
858
899
|
targetUrl: SAMPLE_TARGET_URL,
|
|
859
|
-
|
|
900
|
+
...echoSkipDependencies(req),
|
|
901
|
+
})),
|
|
860
902
|
// M3.4 piece-3 — POST /tests/{testId}/runs/rerun (single rerun).
|
|
861
903
|
// **MUST appear before `/tests/{testId}/runs` and `/tests/{testId}`** so the
|
|
862
904
|
// more-specific `/runs/rerun` path wins over the generic runs trigger.
|
|
@@ -887,7 +929,7 @@ const ENTRIES = [
|
|
|
887
929
|
// **MUST appear before `/tests/batch/rerun` and `/tests/batch` (create)**
|
|
888
930
|
// so the more-specific `/batch/run` path wins. Shows `accepted[]` with
|
|
889
931
|
// per-test runIds + `skippedFrontend[]` so dry-run learners see both shapes.
|
|
890
|
-
entry('triggerBatchRunFresh', 'POST', '/tests/batch/run', {
|
|
932
|
+
entry('triggerBatchRunFresh', 'POST', '/tests/batch/run', (req) => ({
|
|
891
933
|
accepted: [
|
|
892
934
|
{
|
|
893
935
|
testId: SAMPLE_TEST_ID_FRESH_1,
|
|
@@ -904,7 +946,8 @@ const ENTRIES = [
|
|
|
904
946
|
deferred: [],
|
|
905
947
|
skippedFrontend: [],
|
|
906
948
|
skippedIntegration: [],
|
|
907
|
-
|
|
949
|
+
...echoSkipDependencies(req),
|
|
950
|
+
})),
|
|
908
951
|
// M3.4 piece-3 — POST /tests/batch/rerun (batch rerun).
|
|
909
952
|
// **MUST appear before `/tests/batch` (create)** so the more-specific
|
|
910
953
|
// `/batch/rerun` path wins. Shows `accepted[]` with per-test runIds (C2)
|
|
@@ -1025,6 +1068,14 @@ const ENTRIES = [
|
|
|
1025
1068
|
expiresAt: '2026-01-01T01:00:00.000Z',
|
|
1026
1069
|
}),
|
|
1027
1070
|
];
|
|
1071
|
+
/** What a backend that handles the field answers: `true` when asked, otherwise the key is omitted. */
|
|
1072
|
+
function echoSkipDependencies(req) {
|
|
1073
|
+
return req != null &&
|
|
1074
|
+
typeof req === 'object' &&
|
|
1075
|
+
req.skipDependencies === true
|
|
1076
|
+
? { skipDependencies: true }
|
|
1077
|
+
: {};
|
|
1078
|
+
}
|
|
1028
1079
|
function entry(operationId, method, pathTemplate, body) {
|
|
1029
1080
|
const bodyFn = typeof body === 'function' ? body : () => body;
|
|
1030
1081
|
return {
|
|
@@ -4,6 +4,7 @@ import { openTunnelSession, type TunnelClientHandle } from './tunnel-session.js'
|
|
|
4
4
|
import { type TunnelClientOptions } from '../vendor/tunnel-client/index.js';
|
|
5
5
|
import type { HttpClient } from './http.js';
|
|
6
6
|
import type { RunResponse } from './runs.types.js';
|
|
7
|
+
import type { DeprecationEntry } from './deprecate.js';
|
|
7
8
|
import { ApiError } from './errors.js';
|
|
8
9
|
import { type LoopbackHost, type StoredLocalTarget } from './local-target.js';
|
|
9
10
|
export interface RunTargetTest {
|
|
@@ -28,7 +29,6 @@ export declare function assertNoTunnelOptions(args: {
|
|
|
28
29
|
tunnelClientId?: string;
|
|
29
30
|
cancelOnInterrupt?: boolean;
|
|
30
31
|
}): void;
|
|
31
|
-
export declare function severalIdsWithoutTunnel(): never;
|
|
32
32
|
/** One resolver for fresh runs, replay, chained creation and test-list runs. */
|
|
33
33
|
export declare function resolveEnvironmentRunTarget(args: {
|
|
34
34
|
client: Pick<HttpClient, 'get'>;
|
|
@@ -105,5 +105,6 @@ export declare function emitEnvironmentDispatchPartial(responses: Array<{
|
|
|
105
105
|
summaryFile?: string;
|
|
106
106
|
}, deps: ClientFactoryDeps & {
|
|
107
107
|
stdout?: (line: string) => void;
|
|
108
|
+
deprecations?: readonly DeprecationEntry[];
|
|
108
109
|
}, label: string, error: unknown, context: EnvironmentTunnelContext): Promise<void>;
|
|
109
110
|
export {};
|
|
@@ -27,9 +27,6 @@ export function assertNoTunnelOptions(args) {
|
|
|
27
27
|
'cancelled when this command stops waiting — Ctrl-C detaches, and `testsprite test ' +
|
|
28
28
|
'cancel <run-id>` is the way to stop one');
|
|
29
29
|
}
|
|
30
|
-
export function severalIdsWithoutTunnel() {
|
|
31
|
-
throw localValidationError('test-id', 'several test ids run through one tunnel with --local <port>. For tests the runner can already reach, use `testsprite test run --all --project <id> [--filter <text>]`, or run them one at a time.');
|
|
32
|
-
}
|
|
33
30
|
const announcedEnvironments = new WeakMap();
|
|
34
31
|
/** One resolver for fresh runs, replay, chained creation and test-list runs. */
|
|
35
32
|
export async function resolveEnvironmentRunTarget(args) {
|
|
@@ -430,7 +427,7 @@ export async function emitEnvironmentDispatchPartial(responses, testIds, opts, d
|
|
|
430
427
|
...(responses.some(response => response.notFound) ? { notFound } : {}),
|
|
431
428
|
};
|
|
432
429
|
const stderr = deps.stderr ?? (line => process.stderr.write(`${line}\n`));
|
|
433
|
-
new Output(opts.output, { stdout: deps.stdout, stderr: deps.stderr }).print(partial, () => accepted.map(row => `${row.runId} ${row.status}`).join('\n'));
|
|
430
|
+
new Output(opts.output, { stdout: deps.stdout, stderr: deps.stderr }, { deprecations: deps.deprecations }).print(partial, () => accepted.map(row => `${row.runId} ${row.status}`).join('\n'));
|
|
434
431
|
const summary = summarizeAcceptedPayload(JSON.stringify(partial));
|
|
435
432
|
summary.runs.push(...notRunTestIds.map(testId => ({
|
|
436
433
|
testId,
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "You have a project, but no tests yet" signposts.
|
|
3
|
+
*
|
|
4
|
+
* A user who is not driving a coding agent otherwise never learns that
|
|
5
|
+
* `test plan generate` exists: `project create` used to print the record and
|
|
6
|
+
* stop, and the empty-project outputs said only "No tests." Every variant also
|
|
7
|
+
* names the hand-authored fallback, because an account not yet on the new
|
|
8
|
+
* platform is refused by generate and pointed at the Portal.
|
|
9
|
+
*
|
|
10
|
+
* Text mode only at every call site: a JSON caller already holds the project
|
|
11
|
+
* id, and stdout and the JSON error envelope must stay unchanged. Never under
|
|
12
|
+
* --dry-run (the id there is the canned sample). Printing a hint runs and
|
|
13
|
+
* charges nothing; the generation it points at does use credits.
|
|
14
|
+
*
|
|
15
|
+
* Zero requests: each call site branches only on what it already knows.
|
|
16
|
+
* `project create` knows the type and whether the app is local; `test run
|
|
17
|
+
* --all --local` knows it is local. `test list` and a cloud `test run --all`
|
|
18
|
+
* know neither, so their sentence names the backend prerequisite as a clause
|
|
19
|
+
* and leaves a local project to the backend's own pre-charge refusal, which
|
|
20
|
+
* carries the same hand-written-plan next step.
|
|
21
|
+
*/
|
|
22
|
+
import { type StoredLocalTarget } from './local-target.js';
|
|
23
|
+
/**
|
|
24
|
+
* How the run that found the project empty chose its local target, so the
|
|
25
|
+
* suggested `test run` reaches the same app with the same environment:
|
|
26
|
+
* `port`/`host` only for an explicit `--local`, `targetUrl` for an explicit
|
|
27
|
+
* `--target-url`, and `environment` for `--env` or the saved environment the
|
|
28
|
+
* tunnel was resolved from.
|
|
29
|
+
*/
|
|
30
|
+
export type LocalHint = {
|
|
31
|
+
host?: StoredLocalTarget['host'];
|
|
32
|
+
port?: number;
|
|
33
|
+
targetUrl?: string;
|
|
34
|
+
environment?: string;
|
|
35
|
+
};
|
|
36
|
+
export declare const FIRST_SUITE_FALLBACK = "testsprite test create --plan-template";
|
|
37
|
+
/**
|
|
38
|
+
* Multi-line `[hint]` block for stderr after a real `project create` of a
|
|
39
|
+
* deployed (non-`--local`) project. A `--local` project gets no hint here:
|
|
40
|
+
* its text record already ends with the hand-written-plan next steps (plan
|
|
41
|
+
* generation explores from the cloud with no tunnel, and the backend refuses
|
|
42
|
+
* it for a local-origin project before any charge), and two "Next" blocks
|
|
43
|
+
* would disagree.
|
|
44
|
+
*/
|
|
45
|
+
export declare function firstSuiteNextSteps(projectId: string, type: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* One sentence for an EMPTY project; folded into an error message or a hint.
|
|
48
|
+
*
|
|
49
|
+
* Pass `local` only where the caller knows the project runs on this machine
|
|
50
|
+
* (`test run --all --local`); see the module comment for why the other
|
|
51
|
+
* callers cannot.
|
|
52
|
+
*/
|
|
53
|
+
export declare function emptyProjectNextStep(projectId: string, local?: LocalHint | null): string;
|
|
54
|
+
/** The same sentence as a stderr `[hint]` line. */
|
|
55
|
+
export declare function emptyProjectHint(projectId: string, local?: LocalHint | null): string;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "You have a project, but no tests yet" signposts.
|
|
3
|
+
*
|
|
4
|
+
* A user who is not driving a coding agent otherwise never learns that
|
|
5
|
+
* `test plan generate` exists: `project create` used to print the record and
|
|
6
|
+
* stop, and the empty-project outputs said only "No tests." Every variant also
|
|
7
|
+
* names the hand-authored fallback, because an account not yet on the new
|
|
8
|
+
* platform is refused by generate and pointed at the Portal.
|
|
9
|
+
*
|
|
10
|
+
* Text mode only at every call site: a JSON caller already holds the project
|
|
11
|
+
* id, and stdout and the JSON error envelope must stay unchanged. Never under
|
|
12
|
+
* --dry-run (the id there is the canned sample). Printing a hint runs and
|
|
13
|
+
* charges nothing; the generation it points at does use credits.
|
|
14
|
+
*
|
|
15
|
+
* Zero requests: each call site branches only on what it already knows.
|
|
16
|
+
* `project create` knows the type and whether the app is local; `test run
|
|
17
|
+
* --all --local` knows it is local. `test list` and a cloud `test run --all`
|
|
18
|
+
* know neither, so their sentence names the backend prerequisite as a clause
|
|
19
|
+
* and leaves a local project to the backend's own pre-charge refusal, which
|
|
20
|
+
* carries the same hand-written-plan next step.
|
|
21
|
+
*/
|
|
22
|
+
import { quoteEnvironmentName } from './environment-tunnel.js';
|
|
23
|
+
import { DEFAULT_LOCAL_HOST } from './local-target.js';
|
|
24
|
+
export const FIRST_SUITE_FALLBACK = 'testsprite test create --plan-template';
|
|
25
|
+
/**
|
|
26
|
+
* `test run <test-id>` with the target flags the empty run was given. A bare
|
|
27
|
+
* `test run` would resolve the project's DEFAULT environment, which may be a
|
|
28
|
+
* deployed site rather than the app on this machine, so the environment is
|
|
29
|
+
* always named when one was used. `--local-host` is carried whenever the host
|
|
30
|
+
* is not the default: without it a `::1` or `localhost` app would be run
|
|
31
|
+
* against 127.0.0.1.
|
|
32
|
+
*/
|
|
33
|
+
function localRunCommand(local) {
|
|
34
|
+
const flags = [];
|
|
35
|
+
if (local.targetUrl !== undefined) {
|
|
36
|
+
flags.push(`--target-url ${shellWord(local.targetUrl)}`);
|
|
37
|
+
}
|
|
38
|
+
else if (local.port !== undefined) {
|
|
39
|
+
flags.push(`--local ${local.port}`);
|
|
40
|
+
if (local.host !== undefined && local.host !== DEFAULT_LOCAL_HOST)
|
|
41
|
+
flags.push(`--local-host ${local.host}`);
|
|
42
|
+
}
|
|
43
|
+
if (local.environment !== undefined)
|
|
44
|
+
flags.push(`--env ${quoteEnvironmentName(local.environment)}`);
|
|
45
|
+
return ['testsprite test run <test-id>', ...flags].join(' ');
|
|
46
|
+
}
|
|
47
|
+
/** A URL as one shell word: as typed when it is plain, single-quoted otherwise. */
|
|
48
|
+
function shellWord(value) {
|
|
49
|
+
return /^[\w.:/@%+=,~-]+$/.test(value) ? value : quoteEnvironmentName(value);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Multi-line `[hint]` block for stderr after a real `project create` of a
|
|
53
|
+
* deployed (non-`--local`) project. A `--local` project gets no hint here:
|
|
54
|
+
* its text record already ends with the hand-written-plan next steps (plan
|
|
55
|
+
* generation explores from the cloud with no tunnel, and the backend refuses
|
|
56
|
+
* it for a local-origin project before any charge), and two "Next" blocks
|
|
57
|
+
* would disagree.
|
|
58
|
+
*/
|
|
59
|
+
export function firstSuiteNextSteps(projectId, type) {
|
|
60
|
+
const backend = type === 'backend';
|
|
61
|
+
const lead = backend
|
|
62
|
+
? 'Next: upload your API spec, then let TestSprite propose your first tests (uses credits), review them, then accept:'
|
|
63
|
+
: 'Next: let TestSprite propose your first tests (uses credits), review them, then accept:';
|
|
64
|
+
const steps = [
|
|
65
|
+
...(backend ? [`testsprite project docs upload <api-spec.yaml> --project ${projectId}`] : []),
|
|
66
|
+
`testsprite test plan generate --project ${projectId}`,
|
|
67
|
+
`testsprite test plan accept --project ${projectId}`,
|
|
68
|
+
];
|
|
69
|
+
return [
|
|
70
|
+
`[hint] ${lead}`,
|
|
71
|
+
...steps.map(s => ` ${s}`),
|
|
72
|
+
` Prefer to write one yourself: ${FIRST_SUITE_FALLBACK}`,
|
|
73
|
+
].join('\n');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* One sentence for an EMPTY project; folded into an error message or a hint.
|
|
77
|
+
*
|
|
78
|
+
* Pass `local` only where the caller knows the project runs on this machine
|
|
79
|
+
* (`test run --all --local`); see the module comment for why the other
|
|
80
|
+
* callers cannot.
|
|
81
|
+
*/
|
|
82
|
+
export function emptyProjectNextStep(projectId, local) {
|
|
83
|
+
if (local) {
|
|
84
|
+
return (`This project has no tests yet, and plan generation cannot reach an app on your machine yet. ` +
|
|
85
|
+
`Write a plan yourself: ${FIRST_SUITE_FALLBACK} > first.plan.json, ` +
|
|
86
|
+
`set projectId to ${projectId} in it and edit the steps, create it with ` +
|
|
87
|
+
`testsprite test create --plan-from first.plan.json, ` +
|
|
88
|
+
`then run it with ${localRunCommand(local)}`);
|
|
89
|
+
}
|
|
90
|
+
return (`This project has no tests yet. Get a first set: ` +
|
|
91
|
+
`testsprite test plan generate --project ${projectId}, then ` +
|
|
92
|
+
`testsprite test plan accept --project ${projectId} ` +
|
|
93
|
+
`(generation uses credits; a backend project needs its API spec uploaded first: ` +
|
|
94
|
+
`testsprite project docs upload <spec> --project ${projectId}). ` +
|
|
95
|
+
`Or write one yourself: ${FIRST_SUITE_FALLBACK}`);
|
|
96
|
+
}
|
|
97
|
+
/** The same sentence as a stderr `[hint]` line. */
|
|
98
|
+
export function emptyProjectHint(projectId, local) {
|
|
99
|
+
return `[hint] ${emptyProjectNextStep(projectId, local)}`;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=first-suite-hint.js.map
|
package/dist/lib/gh-output.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExecutionReport } from './runs.types.js';
|
|
1
2
|
/**
|
|
2
3
|
* CI-native output layer for the run path (issue #99, reshaped from
|
|
3
4
|
* the withdrawn top-level `ci` command per the #264 review). Covers both a
|
|
@@ -42,6 +43,12 @@ export interface CiSummary {
|
|
|
42
43
|
skipped: number;
|
|
43
44
|
timedOut: number;
|
|
44
45
|
runs: CiRunRow[];
|
|
46
|
+
/**
|
|
47
|
+
* The server's execution report (the GitHub App comment content) when the
|
|
48
|
+
* backend could provide one for this batch. Absent otherwise — never null —
|
|
49
|
+
* so a summary from an older backend is byte-identical to before.
|
|
50
|
+
*/
|
|
51
|
+
executionReport?: ExecutionReport;
|
|
45
52
|
}
|
|
46
53
|
export declare function isNonDispatchedStatus(status: string): boolean;
|
|
47
54
|
/**
|
|
@@ -55,12 +62,17 @@ export declare function isNonDispatchedStatus(status: string): boolean;
|
|
|
55
62
|
* cannot read as "1/1 passed" with no annotation — but it counts as `skipped`,
|
|
56
63
|
* never `failed`: whether non-dispatch fails the job is the exit-code
|
|
57
64
|
* gates' call, and a `failed` count the gates disagree with is exactly the
|
|
58
|
-
* artifacts-contradict-the-exit bug.
|
|
59
|
-
*
|
|
60
|
-
*
|
|
65
|
+
* artifacts-contradict-the-exit bug.
|
|
66
|
+
*
|
|
67
|
+
* `skippedFrontend` / `skippedIntegration` are folded in only under
|
|
68
|
+
* `foldSkippedBuckets` (the `ci run` contract: ONE skipped number covering
|
|
69
|
+
* everything requested but not run). Default off — for `test run --all` they
|
|
70
|
+
* exit 0 and are the Action layer's allow-partial concern, and changing that
|
|
71
|
+
* default would silently change its artifacts.
|
|
61
72
|
*/
|
|
62
73
|
export declare function summarizeAcceptedPayload(capturedJson: string, opts?: {
|
|
63
74
|
notFoundNote?: string;
|
|
75
|
+
foldSkippedBuckets?: boolean;
|
|
64
76
|
}): CiSummary;
|
|
65
77
|
/**
|
|
66
78
|
* Reduce a single `test run <test-id> --wait` result into the same CI summary
|
|
@@ -106,6 +118,11 @@ export declare function emitGithubOutputs(summary: CiSummary, env: NodeJS.Proces
|
|
|
106
118
|
}, opts?: {
|
|
107
119
|
force?: boolean;
|
|
108
120
|
label?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Pre-rendered job-summary Markdown (the execution report) that replaces
|
|
123
|
+
* the local results table when the backend provided one.
|
|
124
|
+
*/
|
|
125
|
+
markdown?: string;
|
|
109
126
|
}): void;
|
|
110
127
|
/**
|
|
111
128
|
* Emit the CI artifacts for a `--wait` run: the machine summary file (when
|
|
@@ -128,4 +145,45 @@ export declare function emitCiArtifacts(summary: CiSummary, opts: {
|
|
|
128
145
|
env: NodeJS.ProcessEnv;
|
|
129
146
|
stdout: (line: string) => void;
|
|
130
147
|
stderr: (line: string) => void;
|
|
131
|
-
}, label: string
|
|
148
|
+
}, label: string, extra?: {
|
|
149
|
+
markdown?: string;
|
|
150
|
+
}): void;
|
|
151
|
+
/**
|
|
152
|
+
* Hand the execution report to later steps: its JSON and Markdown are written
|
|
153
|
+
* under `$RUNNER_TEMP` (else the OS temp dir) and their paths appended to
|
|
154
|
+
* `$GITHUB_OUTPUT` as `execution-report-file` / `execution-report-markdown-file`.
|
|
155
|
+
* Paths, not bodies — a step output is capped at 1 MiB and multi-line values
|
|
156
|
+
* need heredoc escaping. No-op without `GITHUB_OUTPUT` (nothing can consume
|
|
157
|
+
* them). Best-effort: a write failure is reported and never masks the gate.
|
|
158
|
+
*/
|
|
159
|
+
export declare function emitExecutionReportOutputs(ready: {
|
|
160
|
+
report: ExecutionReport;
|
|
161
|
+
markdown: string;
|
|
162
|
+
}, io: {
|
|
163
|
+
env: NodeJS.ProcessEnv;
|
|
164
|
+
stderr: (line: string) => void;
|
|
165
|
+
}): {
|
|
166
|
+
jsonPath: string;
|
|
167
|
+
markdownPath: string;
|
|
168
|
+
} | undefined;
|
|
169
|
+
/**
|
|
170
|
+
* The job-summary Markdown for a batch that has a server execution report.
|
|
171
|
+
*
|
|
172
|
+
* The exit code comes from the CLI's own poll of every run plus whatever did
|
|
173
|
+
* not dispatch; the report describes only the execution. Usually they agree
|
|
174
|
+
* and the summary is the report, byte for byte the App's comment. When they
|
|
175
|
+
* do not — a run the CLI could not read or that timed out, a test refused
|
|
176
|
+
* before dispatch, a retry error — the report alone would read "all passed"
|
|
177
|
+
* under a red check, so the local verdict is stated first and the rows the
|
|
178
|
+
* report cannot contain are appended. A red run whose failures the report
|
|
179
|
+
* also shows agrees — the counts match — and keeps the App's comment as is.
|
|
180
|
+
*/
|
|
181
|
+
export declare function reconcileExecutionReportMarkdown(summary: CiSummary, ready: {
|
|
182
|
+
report: ExecutionReport;
|
|
183
|
+
markdown: string;
|
|
184
|
+
}): string;
|
|
185
|
+
/** Numeric step outputs share the exact counters used by every other CI sink. */
|
|
186
|
+
export declare function emitCiStepOutputs(summary: CiSummary, io: {
|
|
187
|
+
env: NodeJS.ProcessEnv;
|
|
188
|
+
stderr: (line: string) => void;
|
|
189
|
+
}): void;
|