sedum-cli 0.1.0-alpha.3 → 0.1.0-alpha.5
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/dist/{affected-selection-YIHBKUST.js → affected-selection-OHKZUPYG.js} +17 -3
- package/dist/{chunk-AZJ7JJ6P.js → chunk-2BOXJT7M.js} +110 -39
- package/dist/{chunk-BI32AXS7.js → chunk-BEY4UNIW.js} +34 -2
- package/dist/{chunk-3MCSCE7X.js → chunk-DRCPO7W3.js} +12 -16
- package/dist/{chunk-YXSAX7E3.js → chunk-GYFQYSYT.js} +90 -12
- package/dist/{chunk-CZDCGWWD.js → chunk-NMAMFLDA.js} +42 -3
- package/dist/cli.js +30 -5
- package/dist/{doctor-command-A4FTFRUH.js → doctor-command-5HKQX3DN.js} +2 -2
- package/dist/index.d.ts +30 -1
- package/dist/index.js +10 -4
- package/dist/{init-command-EOS2MSWW.js → init-command-62UOTXTO.js} +20 -16
- package/dist/{run-command-P72XF5MI.js → run-command-YNDKEUUU.js} +136 -20
- package/package.json +4 -4
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
discoverRunTests
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DRCPO7W3.js";
|
|
4
4
|
import {
|
|
5
5
|
loadProjectConfig
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GYFQYSYT.js";
|
|
7
7
|
|
|
8
8
|
// src/affected-selection.ts
|
|
9
9
|
import { execFile } from "child_process";
|
|
10
10
|
import { readFile, realpath } from "fs/promises";
|
|
11
11
|
import path from "path";
|
|
12
12
|
import { promisify } from "util";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
isScriptTestFile,
|
|
15
|
+
loadFlowFile,
|
|
16
|
+
resolveFlowModules
|
|
17
|
+
} from "@sedum-dev/core";
|
|
14
18
|
import {
|
|
15
19
|
TypeSafeAdapter
|
|
16
20
|
} from "@sedum-dev/provider-typesafe";
|
|
@@ -128,6 +132,16 @@ async function selectAffectedTests(options) {
|
|
|
128
132
|
const forced = [];
|
|
129
133
|
for (const test of selection.tests) {
|
|
130
134
|
const file = path.join(config.projectRoot, test.file);
|
|
135
|
+
if (isScriptTestFile(file)) {
|
|
136
|
+
if (tests.some((scored) => scored.file === test.file)) continue;
|
|
137
|
+
forced.push(changed.has(await realpath(file)));
|
|
138
|
+
tests.push({
|
|
139
|
+
file: test.file,
|
|
140
|
+
source: await readFile(file, "utf8"),
|
|
141
|
+
modules: []
|
|
142
|
+
});
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
131
145
|
const parsed = await loadFlowFile(file, {
|
|
132
146
|
repoRoot: config.projectRoot,
|
|
133
147
|
rejectSymlinks: true
|
|
@@ -3,12 +3,23 @@ import {
|
|
|
3
3
|
clearLocatorCache,
|
|
4
4
|
parseParallel,
|
|
5
5
|
renderDiagnostic
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BEY4UNIW.js";
|
|
7
7
|
import {
|
|
8
8
|
ProjectConfigError,
|
|
9
9
|
discoverConfiguredTests,
|
|
10
10
|
loadProjectConfig
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-GYFQYSYT.js";
|
|
12
|
+
|
|
13
|
+
// src/invocation.ts
|
|
14
|
+
function sedumCommand(env = process.env, script = process.argv[1] ?? "") {
|
|
15
|
+
if (env.npm_command === "exec" || env.npm_lifecycle_event === "npx")
|
|
16
|
+
return "npx sedum";
|
|
17
|
+
return /[\\/]node_modules[\\/]/.test(script) ? "npx sedum" : "sedum";
|
|
18
|
+
}
|
|
19
|
+
var SUBCOMMAND = /(?<![\w./-]|npx )sedum (?=(?:run|browsers|doctor|validate|init|list)\b|--help\b|--version\b)/g;
|
|
20
|
+
function withCommand(text, command) {
|
|
21
|
+
return command === "sedum" ? text : text.replace(SUBCOMMAND, `${command} `);
|
|
22
|
+
}
|
|
12
23
|
|
|
13
24
|
// src/exit-policy.ts
|
|
14
25
|
import {
|
|
@@ -33,6 +44,7 @@ function listExitCode(listing, failedBeforeListing) {
|
|
|
33
44
|
|
|
34
45
|
// src/output.ts
|
|
35
46
|
import { validateRunResult as validateRunResult2 } from "@sedum-dev/core";
|
|
47
|
+
import { testLabel, usageLines, visionSummary } from "@sedum-dev/reporters";
|
|
36
48
|
var ansi = {
|
|
37
49
|
green: "\x1B[32m",
|
|
38
50
|
red: "\x1B[31m",
|
|
@@ -68,6 +80,23 @@ function executionLines(value) {
|
|
|
68
80
|
])
|
|
69
81
|
)
|
|
70
82
|
];
|
|
83
|
+
if (execution?.vision) {
|
|
84
|
+
const steps = value.tests.flatMap(
|
|
85
|
+
(test) => test.attempts.flatMap((attempt) => attempt.steps)
|
|
86
|
+
);
|
|
87
|
+
const used = steps.filter((step) => step.locator?.vision).length;
|
|
88
|
+
lines.push(
|
|
89
|
+
used ? `vision ${execution.vision.model}: used on ${used} step(s)` : `vision ${execution.vision.model}: enabled, not used; every click was resolved from the page text`
|
|
90
|
+
);
|
|
91
|
+
if (execution.vision.key === "rejected")
|
|
92
|
+
lines.push(
|
|
93
|
+
"vision warning: OpenRouter rejected OPEN_ROUTER_API_KEY, so vision fallback cannot work. Check it with `sedum doctor --vision`."
|
|
94
|
+
);
|
|
95
|
+
else if (execution.vision.key === "unreachable")
|
|
96
|
+
lines.push(
|
|
97
|
+
"vision warning: OpenRouter could not be reached to check OPEN_ROUTER_API_KEY."
|
|
98
|
+
);
|
|
99
|
+
}
|
|
71
100
|
const limited = calls.filter((call) => call.rateLimited).length;
|
|
72
101
|
const waitMs = calls.reduce(
|
|
73
102
|
(sum, call) => sum + (call.rateLimitWaitMs ?? 0),
|
|
@@ -90,13 +119,9 @@ function renderRunSummary(result, capabilities, artifacts, showCosts) {
|
|
|
90
119
|
const lines = [];
|
|
91
120
|
const flagCounts = { low_confidence: 0, contradiction: 0 };
|
|
92
121
|
for (const test of value.tests) {
|
|
93
|
-
const
|
|
94
|
-
const flags = test.flags.length ? ` [${test.flags.join(", ")}]` : "";
|
|
95
|
-
lines.push(
|
|
96
|
-
`test ${paint(label.text, label.color, color)} ${test.file}${flags}`
|
|
97
|
-
);
|
|
122
|
+
const details = [];
|
|
98
123
|
if (test.attempts.length > 1)
|
|
99
|
-
|
|
124
|
+
details.push(
|
|
100
125
|
` attempts ${test.attempts.length} (${test.attempts.map((attempt) => attempt.verdict ?? attempt.state).join(" -> ")})`
|
|
101
126
|
);
|
|
102
127
|
const selected = test.attempts.find(
|
|
@@ -109,27 +134,55 @@ function renderRunSummary(result, capabilities, artifacts, showCosts) {
|
|
|
109
134
|
const reason = cache.reason ? ` (${cache.reason})` : "";
|
|
110
135
|
const fallback = cache.fallbackCalledModel ? ", model fallback" : "";
|
|
111
136
|
const changed = cache.targetChanged ? ", target changed" : "";
|
|
112
|
-
|
|
137
|
+
details.push(
|
|
113
138
|
` step ${step.index}: cache ${cache.outcome}${reason}${fallback}${changed}`
|
|
114
139
|
);
|
|
115
140
|
}
|
|
116
141
|
}
|
|
142
|
+
if (details.length) lines.push(testLabel(test), ...details);
|
|
117
143
|
}
|
|
144
|
+
const outsideGit = value.tests.some(
|
|
145
|
+
(test) => test.attempts.some(
|
|
146
|
+
(attempt) => attempt.steps.some(
|
|
147
|
+
(step) => step.locator?.cache?.reason === "outside_git"
|
|
148
|
+
)
|
|
149
|
+
)
|
|
150
|
+
);
|
|
151
|
+
if (outsideGit)
|
|
152
|
+
lines.push(
|
|
153
|
+
"cache off: this project is not a Git checkout; run `git init` to cache locator results"
|
|
154
|
+
);
|
|
118
155
|
const runLabel = stateLabel(value.state, value.verdict);
|
|
119
156
|
lines.push(`run ${paint(runLabel.text, runLabel.color, color)}`);
|
|
120
157
|
for (const problem of value.discoveryProblems ?? [])
|
|
121
158
|
lines.push(
|
|
122
159
|
`discovery ${problem.file}${problem.line === void 0 ? "" : `:${problem.line}:${problem.col ?? 1}`}: ${problem.message} Fix: ${problem.fix}`
|
|
123
160
|
);
|
|
161
|
+
const erroredTests = value.tests.filter(
|
|
162
|
+
(test) => test.state === "error"
|
|
163
|
+
).length;
|
|
124
164
|
lines.push(
|
|
125
|
-
`tests ${value.totals.selectedTests} selected, ${value.totals.executedTests} executed, ${value.totals.passedTests} passed, ${value.totals.failedTests} failed`
|
|
165
|
+
`tests ${value.totals.selectedTests} selected, ${value.totals.executedTests} executed, ${value.totals.passedTests} passed, ${value.totals.failedTests} failed${erroredTests ? `, ${erroredTests} could not run` : ""}`
|
|
126
166
|
);
|
|
127
167
|
lines.push(
|
|
128
|
-
`flags ${value.totals.flaggedSteps} flagged step(s), low_confidence ${flagCounts.low_confidence}, contradiction ${flagCounts.contradiction}`
|
|
168
|
+
`flags ${value.totals.flaggedSteps} flagged step(s), low_confidence ${flagCounts.low_confidence}, contradiction ${flagCounts.contradiction}, flaky ${value.tests.filter((test) => test.flags.includes("flaky")).length} test(s)`
|
|
129
169
|
);
|
|
130
170
|
lines.push(...executionLines(value));
|
|
171
|
+
for (const test of value.tests)
|
|
172
|
+
for (const attempt of test.attempts)
|
|
173
|
+
for (const step of attempt.steps) {
|
|
174
|
+
const vision = visionSummary(step);
|
|
175
|
+
if (vision)
|
|
176
|
+
lines.push(
|
|
177
|
+
`${test.file} \xB7 attempt ${attempt.ordinal} \xB7 step ${step.index}: ${vision}`.replace(
|
|
178
|
+
// Strip terminal control characters from provider metadata.
|
|
179
|
+
// eslint-disable-next-line no-control-regex
|
|
180
|
+
/[\u0000-\u001f\u007f-\u009f]/g,
|
|
181
|
+
" "
|
|
182
|
+
)
|
|
183
|
+
);
|
|
184
|
+
}
|
|
131
185
|
if (artifacts.authoritative) {
|
|
132
|
-
lines.push(`progress ${artifacts.progressPath}`);
|
|
133
186
|
lines.push(`result ${artifacts.resultPath}`);
|
|
134
187
|
if (artifacts.htmlPath) lines.push(`html ${artifacts.htmlPath}`);
|
|
135
188
|
if (artifacts.markdownPath)
|
|
@@ -141,12 +194,9 @@ function renderRunSummary(result, capabilities, artifacts, showCosts) {
|
|
|
141
194
|
lines.push(`result unavailable (intended ${artifacts.resultPath})`);
|
|
142
195
|
}
|
|
143
196
|
if (capabilities.stdoutIsTTY || showCosts) {
|
|
144
|
-
lines.push(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
lines.push(
|
|
148
|
-
value.totals.costComplete && value.totals.costUsd !== null ? `cost $${value.totals.costUsd.toFixed(6)}` : "cost unknown or incomplete"
|
|
149
|
-
);
|
|
197
|
+
lines.push(...usageLines(value));
|
|
198
|
+
if (!value.totals.costComplete || value.totals.costUsd === null)
|
|
199
|
+
lines.push("cost unknown or incomplete");
|
|
150
200
|
}
|
|
151
201
|
return `${lines.join("\n")}
|
|
152
202
|
`;
|
|
@@ -162,7 +212,7 @@ import {
|
|
|
162
212
|
// src/list-command.ts
|
|
163
213
|
import {
|
|
164
214
|
listTests,
|
|
165
|
-
|
|
215
|
+
loadListingEntries
|
|
166
216
|
} from "@sedum-dev/core";
|
|
167
217
|
|
|
168
218
|
// src/project-context.ts
|
|
@@ -265,12 +315,9 @@ async function executeListCommand(options) {
|
|
|
265
315
|
const { discovery } = context;
|
|
266
316
|
if (discovery.problems.length)
|
|
267
317
|
return { discovery, configErrors: [], listing: null };
|
|
268
|
-
const parsed =
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
file,
|
|
272
|
-
result: await loadFlowFile(file, { repoRoot: discovery.root })
|
|
273
|
-
});
|
|
318
|
+
const parsed = await loadListingEntries(discovery.tests, {
|
|
319
|
+
repoRoot: discovery.root
|
|
320
|
+
});
|
|
274
321
|
return {
|
|
275
322
|
discovery,
|
|
276
323
|
configErrors: [],
|
|
@@ -298,7 +345,7 @@ function emptyProjectProblem(paths, testDirectory) {
|
|
|
298
345
|
return {
|
|
299
346
|
code: "missing_path",
|
|
300
347
|
path: shown,
|
|
301
|
-
message: `No *.test.yaml or *.module.yaml files were found under ${shown}.`,
|
|
348
|
+
message: `No *.test.ts, *.test.yaml, or *.module.yaml files were found under ${shown}.`,
|
|
302
349
|
fix: paths.length ? "Pass paths relative to the project root that contain tests or modules." : "Add tests under tests.directory, or correct tests.directory/include/exclude in sedum.config.yaml."
|
|
303
350
|
};
|
|
304
351
|
}
|
|
@@ -592,10 +639,13 @@ function commandHelp(command, writeErr) {
|
|
|
592
639
|
async function runCli(args, version, runtime = {}) {
|
|
593
640
|
const stdout = [];
|
|
594
641
|
const stderr = [];
|
|
595
|
-
const
|
|
596
|
-
const
|
|
642
|
+
const command = runtime.command ?? "sedum";
|
|
643
|
+
const rawOut = runtime.stdout ?? ((value) => stdout.push(value));
|
|
644
|
+
const rawErr = runtime.stderr ?? ((value) => stderr.push(value));
|
|
645
|
+
const writeOut = (value) => rawOut(withCommand(value, command));
|
|
646
|
+
const writeErr = (value) => rawErr(withCommand(value, command));
|
|
597
647
|
const capabilities = runtime.capabilities ?? plainOutput;
|
|
598
|
-
const executeRun = runtime.executeRun ?? (async (options) => (await import("./run-command-
|
|
648
|
+
const executeRun = runtime.executeRun ?? (async (options) => (await import("./run-command-YNDKEUUU.js")).executeRunCommand(options));
|
|
599
649
|
const cwd = runtime.cwd ?? process.cwd();
|
|
600
650
|
let exitCode = 3;
|
|
601
651
|
const program = new Command().name("sedum").description(
|
|
@@ -613,7 +663,7 @@ async function runCli(args, version, runtime = {}) {
|
|
|
613
663
|
"after",
|
|
614
664
|
"\nCreates a config, a SauceDemo example, .env.example, and ignore rules.\nExisting files are never replaced.\n"
|
|
615
665
|
).action(async () => {
|
|
616
|
-
const { executeInitCommand } = await import("./init-command-
|
|
666
|
+
const { executeInitCommand } = await import("./init-command-62UOTXTO.js");
|
|
617
667
|
const interactive = capabilities.stdoutIsTTY && (process.stdin.isTTY === true || runtime.confirmInit !== void 0);
|
|
618
668
|
const confirm = runtime.confirmInit ?? (interactive ? async (question) => {
|
|
619
669
|
const { createInterface } = await import("readline/promises");
|
|
@@ -674,7 +724,12 @@ async function runCli(args, version, runtime = {}) {
|
|
|
674
724
|
"match id or description substring (repeatable)",
|
|
675
725
|
collectValue,
|
|
676
726
|
[]
|
|
677
|
-
).option(
|
|
727
|
+
).option(
|
|
728
|
+
"--id <id>",
|
|
729
|
+
"select a test by its exact id (repeatable)",
|
|
730
|
+
collectValue,
|
|
731
|
+
[]
|
|
732
|
+
).option("--env <name>", "select a named environment").option("--browser <kind>", "chrome or chromium").option("--vision", "enable vision fallback for ambiguous clicks").option("--no-vision", "disable vision fallback").option("--vision-model <model>", "override the OpenRouter vision model").option(
|
|
678
733
|
"--url-override <url>",
|
|
679
734
|
"replace entry URL origin for preview deployments"
|
|
680
735
|
).option("--output-dir <path>", "run output directory").option("--reporter-dir <path>", "reporter artifact directory").option("--headed", "show the browser", false).option(
|
|
@@ -722,7 +777,7 @@ async function runCli(args, version, runtime = {}) {
|
|
|
722
777
|
false
|
|
723
778
|
).addHelpText(
|
|
724
779
|
"after",
|
|
725
|
-
"\nPrerequisites:\n Install Chromium with `sedum browsers install chromium` and set TYPESAFE_API_KEY (and TYPESAFE_BASE_URL for a compatible provider).\n\nExamples:\n sedum run tests/login.test.
|
|
780
|
+
"\nPrerequisites:\n Install Chromium with `sedum browsers install chromium` and set TYPESAFE_API_KEY (and TYPESAFE_BASE_URL for a compatible provider).\n\nExamples:\n sedum run tests/login.test.ts\n sedum run tests/login.test.ts --id 'tests/login.test.ts#signs in'\n sedum run tests/login.test.yaml --strict --costs\n"
|
|
726
781
|
).action(
|
|
727
782
|
async (paths, options) => {
|
|
728
783
|
if (options.shardIndex === void 0 !== (options.shardCount === void 0) || options.shardIndex !== void 0 && options.shardIndex > options.shardCount) {
|
|
@@ -755,7 +810,7 @@ async function runCli(args, version, runtime = {}) {
|
|
|
755
810
|
return;
|
|
756
811
|
}
|
|
757
812
|
if (options.affected) {
|
|
758
|
-
const { selectAffectedTests, AffectedSelectionError } = await import("./affected-selection-
|
|
813
|
+
const { selectAffectedTests, AffectedSelectionError } = await import("./affected-selection-OHKZUPYG.js");
|
|
759
814
|
const { ProviderError: ProviderError2 } = await import("@sedum-dev/core");
|
|
760
815
|
writeErr(
|
|
761
816
|
"Experimental selection sends the tracked Git diff and test/module sources to the configured TypeSafe provider. Full CI is still recommended.\n"
|
|
@@ -768,7 +823,8 @@ async function runCli(args, version, runtime = {}) {
|
|
|
768
823
|
include: options.include,
|
|
769
824
|
exclude: options.exclude,
|
|
770
825
|
labels: options.labels,
|
|
771
|
-
names: options.name
|
|
826
|
+
names: options.name,
|
|
827
|
+
ids: options.id
|
|
772
828
|
},
|
|
773
829
|
threshold: options.threshold ?? 0.1,
|
|
774
830
|
...options.base !== void 0 ? { base: options.base } : {},
|
|
@@ -843,15 +899,20 @@ No tests were run. Fix the selection error or run without --affected.
|
|
|
843
899
|
}
|
|
844
900
|
};
|
|
845
901
|
const execution = await executeRun({
|
|
902
|
+
command,
|
|
903
|
+
...runtime.onStrayRejection ? { onStrayRejection: runtime.onStrayRejection } : {},
|
|
846
904
|
paths,
|
|
847
905
|
filters: {
|
|
848
906
|
include: options.include,
|
|
849
907
|
exclude: options.exclude,
|
|
850
908
|
labels: options.labels,
|
|
851
|
-
names: options.name
|
|
909
|
+
names: options.name,
|
|
910
|
+
ids: options.id
|
|
852
911
|
},
|
|
853
912
|
...options.env ? { environment: options.env } : {},
|
|
854
913
|
...options.browser ? { browser: options.browser } : {},
|
|
914
|
+
...options.vision !== void 0 ? { vision: options.vision } : {},
|
|
915
|
+
...options.visionModel !== void 0 ? { visionModel: options.visionModel } : {},
|
|
855
916
|
...options.urlOverride ? { urlOverride: options.urlOverride } : {},
|
|
856
917
|
...options.outputDir ? { outputDir: options.outputDir } : {},
|
|
857
918
|
...options.reporterDir ? { reporterDir: options.reporterDir } : {},
|
|
@@ -933,12 +994,18 @@ No tests were run. Fix the selection error or run without --affected.
|
|
|
933
994
|
);
|
|
934
995
|
exitCode = 0;
|
|
935
996
|
});
|
|
936
|
-
program.command("doctor").description("check whether this environment can run Sedum").option("--json", "print versioned JSON checks on stdout", false).
|
|
997
|
+
program.command("doctor").description("check whether this environment can run Sedum").option("--json", "print versioned JSON checks on stdout", false).option(
|
|
998
|
+
"--vision",
|
|
999
|
+
"also check the vision fallback's OPEN_ROUTER_API_KEY (automatic when vision.enabled is true)",
|
|
1000
|
+
false
|
|
1001
|
+
).addHelpText(
|
|
937
1002
|
"after",
|
|
938
1003
|
"\nThe authenticated API check makes one small, potentially billable request.\n\nExit codes:\n 0 all checks passed\n 3 one or more prerequisites failed\n"
|
|
939
1004
|
).action(async (options) => {
|
|
940
|
-
const { executeDoctorCommand, renderDoctorText } = await import("./doctor-command-
|
|
941
|
-
const result = await executeDoctorCommand(cwd, runtime.doctorProbes
|
|
1005
|
+
const { executeDoctorCommand, renderDoctorText } = await import("./doctor-command-5HKQX3DN.js");
|
|
1006
|
+
const result = await executeDoctorCommand(cwd, runtime.doctorProbes, {
|
|
1007
|
+
vision: options.vision
|
|
1008
|
+
});
|
|
942
1009
|
writeOut(
|
|
943
1010
|
options.json ? `${JSON.stringify(result)}
|
|
944
1011
|
` : renderDoctorText(result)
|
|
@@ -1046,8 +1113,11 @@ Fix: use \`sedum browsers install chromium\`.
|
|
|
1046
1113
|
"Fix: correct the command shown above and rerun it, or use `sedum --help`.\n"
|
|
1047
1114
|
);
|
|
1048
1115
|
} else {
|
|
1116
|
+
const detail = error instanceof Error ? `${error.name}: ${error.message.split("\n")[0].slice(0, 200)}` : "unknown error";
|
|
1049
1117
|
writeErr(
|
|
1050
|
-
|
|
1118
|
+
`Sedum stopped on an unexpected internal error (${detail}).
|
|
1119
|
+
Fix: rerun the command; if it happens again, report it with the run's result.json.
|
|
1120
|
+
`
|
|
1051
1121
|
);
|
|
1052
1122
|
exitCode = 3;
|
|
1053
1123
|
}
|
|
@@ -1056,6 +1126,7 @@ Fix: use \`sedum browsers install chromium\`.
|
|
|
1056
1126
|
}
|
|
1057
1127
|
|
|
1058
1128
|
export {
|
|
1129
|
+
sedumCommand,
|
|
1059
1130
|
runExitCode,
|
|
1060
1131
|
renderRunSummary,
|
|
1061
1132
|
runCli
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProjectConfigError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GYFQYSYT.js";
|
|
4
4
|
|
|
5
5
|
// src/diagnostics.ts
|
|
6
6
|
import { BrowserDriverError, ProviderError } from "@sedum-dev/core";
|
|
@@ -103,17 +103,37 @@ function flowDiagnostic(result) {
|
|
|
103
103
|
};
|
|
104
104
|
const diagnostic = known[result.code];
|
|
105
105
|
if (diagnostic) return { code: result.code, ...diagnostic };
|
|
106
|
+
if (result.code === "navigation_failed")
|
|
107
|
+
return {
|
|
108
|
+
code: result.code,
|
|
109
|
+
message: bounded(result.message),
|
|
110
|
+
fix: bounded(
|
|
111
|
+
result.fix ?? "Check the test's url (or baseUrl), your network or VPN, and that the site is up."
|
|
112
|
+
)
|
|
113
|
+
};
|
|
106
114
|
if (result.code === "provider_rate_limited")
|
|
107
115
|
return {
|
|
108
116
|
code: result.code,
|
|
109
117
|
message: "The model provider kept rate limiting requests for five minutes.",
|
|
110
118
|
fix: "Lower --parallel or --provider-concurrency, or retry later."
|
|
111
119
|
};
|
|
120
|
+
if (result.code === "provider_authentication")
|
|
121
|
+
return {
|
|
122
|
+
code: result.code,
|
|
123
|
+
message: "The model provider rejected the API key.",
|
|
124
|
+
fix: "Set TYPESAFE_API_KEY to a valid key, check it with `sedum doctor`, then rerun."
|
|
125
|
+
};
|
|
126
|
+
if (result.code === "provider_configuration")
|
|
127
|
+
return {
|
|
128
|
+
code: result.code,
|
|
129
|
+
message: "The model provider is not configured correctly.",
|
|
130
|
+
fix: "Check TYPESAFE_API_KEY, TYPESAFE_BASE_URL and the model with `sedum doctor`, then rerun."
|
|
131
|
+
};
|
|
112
132
|
if (result.code.startsWith("provider_"))
|
|
113
133
|
return {
|
|
114
134
|
code: result.code,
|
|
115
135
|
message: "The model provider could not complete the run safely.",
|
|
116
|
-
fix:
|
|
136
|
+
fix: "Check provider availability and the test input, then rerun the test."
|
|
117
137
|
};
|
|
118
138
|
return {
|
|
119
139
|
code: "execution_error",
|
|
@@ -121,6 +141,17 @@ function flowDiagnostic(result) {
|
|
|
121
141
|
fix: "Check the browser, provider, and test input, then rerun the test."
|
|
122
142
|
};
|
|
123
143
|
}
|
|
144
|
+
var RUN_STOPPING_CODES = /* @__PURE__ */ new Set([
|
|
145
|
+
"browser-missing",
|
|
146
|
+
"browser-launch-failed",
|
|
147
|
+
"script-missing",
|
|
148
|
+
"provider_configuration",
|
|
149
|
+
"provider_authentication",
|
|
150
|
+
"provider_rate_limited"
|
|
151
|
+
]);
|
|
152
|
+
function stopsRun(code) {
|
|
153
|
+
return RUN_STOPPING_CODES.has(code);
|
|
154
|
+
}
|
|
124
155
|
function renderDiagnostic(diagnostic) {
|
|
125
156
|
return `${diagnostic.message}
|
|
126
157
|
Fix: ${diagnostic.fix}
|
|
@@ -434,6 +465,7 @@ export {
|
|
|
434
465
|
outputDiagnostic,
|
|
435
466
|
canonicalDiagnosticError,
|
|
436
467
|
flowDiagnostic,
|
|
468
|
+
stopsRun,
|
|
437
469
|
renderDiagnostic,
|
|
438
470
|
MAX_PARALLEL,
|
|
439
471
|
planLanes,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
discoverConfiguredTests
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GYFQYSYT.js";
|
|
4
4
|
|
|
5
5
|
// src/run-selection.ts
|
|
6
6
|
import { lstat, realpath } from "fs/promises";
|
|
@@ -8,7 +8,8 @@ import path from "path";
|
|
|
8
8
|
import { minimatch } from "minimatch";
|
|
9
9
|
import {
|
|
10
10
|
listTests,
|
|
11
|
-
|
|
11
|
+
loadListingEntries,
|
|
12
|
+
TEST_SUFFIXES,
|
|
12
13
|
walkSuiteFiles
|
|
13
14
|
} from "@sedum-dev/core";
|
|
14
15
|
function contained(root, target) {
|
|
@@ -20,8 +21,9 @@ function selectRunTests(tests, filters) {
|
|
|
20
21
|
const excludes = filters.exclude ?? [];
|
|
21
22
|
const labels = filters.labels ?? [];
|
|
22
23
|
const names = filters.names ?? [];
|
|
24
|
+
const ids = filters.ids ?? [];
|
|
23
25
|
return tests.filter(
|
|
24
|
-
(test) => (includes.length === 0 || includes.some((glob) => minimatch(test.file, glob))) && !excludes.some((glob) => minimatch(test.file, glob)) && labels.every((label) => test.tags.includes(label)) && (names.length === 0 || names.some(
|
|
26
|
+
(test) => (includes.length === 0 || includes.some((glob) => minimatch(test.file, glob))) && !excludes.some((glob) => minimatch(test.file, glob)) && labels.every((label) => test.tags.includes(label)) && (ids.length === 0 || ids.includes(test.id)) && (names.length === 0 || names.some(
|
|
25
27
|
(name) => `${test.id}
|
|
26
28
|
${test.description ?? ""}`.toLowerCase().includes(name.toLowerCase())
|
|
27
29
|
))
|
|
@@ -91,7 +93,7 @@ async function discoverRunTests(config, paths, filters = {}) {
|
|
|
91
93
|
if (info.isDirectory()) {
|
|
92
94
|
for (const file2 of await walkSuiteFiles(
|
|
93
95
|
target,
|
|
94
|
-
|
|
96
|
+
TEST_SUFFIXES,
|
|
95
97
|
(folder) => {
|
|
96
98
|
problems.push({
|
|
97
99
|
file: path.relative(root, folder),
|
|
@@ -102,27 +104,21 @@ async function discoverRunTests(config, paths, filters = {}) {
|
|
|
102
104
|
}
|
|
103
105
|
))
|
|
104
106
|
files.add(file2);
|
|
105
|
-
} else if (info.isFile() && candidate.endsWith(
|
|
107
|
+
} else if (info.isFile() && TEST_SUFFIXES.some((suffix) => candidate.endsWith(suffix)))
|
|
106
108
|
files.add(target);
|
|
107
109
|
else
|
|
108
110
|
problems.push({
|
|
109
111
|
file,
|
|
110
112
|
code: "unsupported_file",
|
|
111
|
-
message: "Expected a *.test.yaml file or directory.",
|
|
113
|
+
message: "Expected a *.test.ts or *.test.yaml file, or a directory.",
|
|
112
114
|
fix: "Choose a test path."
|
|
113
115
|
});
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
|
-
const parsed = []
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
result: await loadFlowFile(file, {
|
|
121
|
-
repoRoot: root,
|
|
122
|
-
rejectSymlinks: true
|
|
123
|
-
})
|
|
124
|
-
});
|
|
125
|
-
}
|
|
118
|
+
const parsed = await loadListingEntries([...files].sort(), {
|
|
119
|
+
repoRoot: root,
|
|
120
|
+
rejectSymlinks: true
|
|
121
|
+
});
|
|
126
122
|
const listing = listTests(parsed, { repoRoot: root });
|
|
127
123
|
return {
|
|
128
124
|
tests: selectRunTests(listing.tests, filters),
|