bd09c55c47
Integrates nine commits of reviewed work from the lane-go branch after the automated resolver failed on this merge five times (each attempt dying on the malformed-result defect whose fix is contained in this same merge). Integration decisions: - Search: kept main's shipped design (Store.Search + SearchResponse.Results) and dropped lane-go's parallel, older attempt (an unused Message.Matches field, an absent runs.search, and two partial TUI plumbing blocks). lane-go itself did not compile: protocol.SearchMatch was undefined and model.go referenced searchNav, requestSearch and applyRunNav, which exist nowhere. Those partial TUI blocks are removed; the queued TUI omni-search item will implement the surface properly on main's design. - Both sides' additions are kept where they are independent: run titles and provenance, the human decision stage and its CLI/TUI surface, the derived stage verdict, the stale-client guard, the line-oriented result format, and main's search command. - The search key's help label is now "/ omni search"; the two tests asserting the old label are updated rather than the label reverted. - docs/cli.md and the packaged operations reference carry both sides' text. Verified: go build ./... , go vet ./... and the full go test ./... suite pass.
103 lines
3.5 KiB
JavaScript
103 lines
3.5 KiB
JavaScript
// Live end-to-end smoke test: drives the *real* client (src/client.js) against a
|
|
// running Pipelines server. Opt-in, because it needs a server:
|
|
//
|
|
// PIPELINES_WS_URL=ws://127.0.0.1:8080/connect node test/smoke.mjs
|
|
//
|
|
// Uses Node's built-in global WebSocket and fetch (Node >= 22). Exits non-zero
|
|
// on the first failed assertion so it is usable in a check.
|
|
import assert from "node:assert/strict";
|
|
|
|
import { PipelinesClient } from "../src/client.js";
|
|
import { PipelinesRepository } from "../src/repository.js";
|
|
import { validateServerUrl, resolveArtifactUrl } from "../src/serverUrl.js";
|
|
|
|
const raw = process.env.PIPELINES_WS_URL ?? process.argv[2] ?? "";
|
|
if (!raw) {
|
|
console.error("PIPELINES_WS_URL is required, e.g. ws://127.0.0.1:8080/connect");
|
|
process.exit(2);
|
|
}
|
|
|
|
const validated = validateServerUrl(raw);
|
|
if (!validated.valid) {
|
|
console.error(`invalid server URL: ${validated.message}`);
|
|
process.exit(2);
|
|
}
|
|
|
|
const client = new PipelinesClient();
|
|
const repo = new PipelinesRepository(client);
|
|
const checks = [];
|
|
const pass = (name) => {
|
|
checks.push(name);
|
|
console.log(` ok ${name}`);
|
|
};
|
|
|
|
try {
|
|
await connectWithTimeout(client, validated, 5000);
|
|
pass("websocket connected");
|
|
|
|
const pong = await repo.ping();
|
|
assert.equal(pong.type, "pong");
|
|
pass("ping -> pong");
|
|
|
|
const pipelines = await repo.listPipelines();
|
|
assert.ok(Array.isArray(pipelines));
|
|
pass(`list_pipelines -> ${pipelines.length} pipeline(s)`);
|
|
|
|
const { runs, usage } = await repo.listRuns();
|
|
assert.ok(Array.isArray(runs));
|
|
pass(`list_runs -> ${runs.length} run(s), usage.total=${usage?.total ?? "n/a"}`);
|
|
|
|
if (pipelines.length) {
|
|
const detail = await repo.getPipeline(pipelines[0].id, pipelines[0].version);
|
|
assert.equal(detail.id, pipelines[0].id);
|
|
assert.ok(Array.isArray(detail.graph?.stages));
|
|
pass(`get_pipeline #${detail.id} -> ${detail.graph.stages.length} stage(s)`);
|
|
} else {
|
|
console.log(" -- no pipelines; skipped get_pipeline");
|
|
}
|
|
|
|
if (runs.length) {
|
|
const run = await repo.getRun(runs[0].id);
|
|
assert.equal(run.id, runs[0].id);
|
|
assert.ok(Array.isArray(run.steps));
|
|
pass(`get_run #${run.id} -> status=${run.status} steps=${run.steps.length}`);
|
|
|
|
const artifact = run.steps.flatMap((s) => s.artifacts ?? []).find((a) => a.url);
|
|
if (artifact) {
|
|
const url = resolveArtifactUrl(raw, artifact.url);
|
|
assert.ok(url?.startsWith("http"));
|
|
const res = await fetch(url, { method: "HEAD" });
|
|
pass(`artifact HEAD ${url} -> ${res.status} ${res.headers.get("content-type") ?? ""}`.trim());
|
|
assert.ok(res.ok, `artifact HEAD was ${res.status}`);
|
|
} else {
|
|
console.log(" -- newest run has no artifacts; skipped artifact fetch");
|
|
}
|
|
} else {
|
|
console.log(" -- no runs; skipped get_run");
|
|
}
|
|
|
|
console.log(`\nSMOKE PASS (${checks.length} checks) against ${validated.wsUrl}`);
|
|
client.disconnect();
|
|
process.exit(0);
|
|
} catch (err) {
|
|
console.error(`\nSMOKE FAIL: ${err?.message ?? err}`);
|
|
console.error(`against ${validated.wsUrl}`);
|
|
client.disconnect();
|
|
process.exit(1);
|
|
}
|
|
|
|
function connectWithTimeout(c, validatedUrl, ms) {
|
|
return new Promise((resolve, reject) => {
|
|
const timer = setTimeout(() => reject(new Error(`connect timed out after ${ms}ms`)), ms);
|
|
const onState = (event) => {
|
|
if (event.detail.kind === "connected") {
|
|
clearTimeout(timer);
|
|
c.removeEventListener("state", onState);
|
|
resolve();
|
|
}
|
|
};
|
|
c.addEventListener("state", onState);
|
|
c.connect(validatedUrl);
|
|
});
|
|
}
|