Files
pikasTech-unidesk/scripts/src/hwlab-node/web-observe-render.test.ts
T
2026-06-26 09:45:30 +00:00

41 lines
1.7 KiB
TypeScript

import assert from "node:assert/strict";
import { test } from "bun:test";
import { renderWebProbeScriptResult } from "./web-observe-render";
test("web-probe script render warns to promote repeated scripts into commands", () => {
const rendered = renderWebProbeScriptResult({
ok: true,
status: "pass",
command: "web-probe script --node D601 --lane v03",
node: "D601",
lane: "v03",
url: "https://hwlab.example.test",
warnings: [{
code: "web_probe_script_ad_hoc_only",
severity: "warning",
message: "web-probe script is for one-off exploration; repeated or high-frequency checks must be promoted to a typed command instead of rerunning temporary scripts.",
}],
hints: [
"Prefer `web-probe observe start` plus `web-probe observe command` for interactive flows.",
],
preferredCommands: {
startObserver: "bun scripts/cli.ts web-probe observe start --node D601 --lane v03 --target-path /projects/mdtodo",
mdtodoSummary: "bun scripts/cli.ts web-probe observe collect <observerId> --view project-mdtodo-summary",
},
summary: { ok: true, status: "pass" },
issueEvidence: {},
probe: { steps: [], script: { result: { ok: true } } },
reportLoad: { source: "stdout", path: ".state/web-probe-script/run.demo/web-probe-script-report.json" },
result: { exitCode: 0, timedOut: false },
});
const text = String(rendered.renderedText ?? "");
assert.match(text, /WARNINGS/u);
assert.match(text, /web_probe_script_ad_hoc_only/u);
assert.match(text, /HINTS/u);
assert.match(text, /web-probe observe command/u);
assert.match(text, /startObserver: bun scripts\/cli\.ts web-probe observe start/u);
assert.match(text, /mdtodoSummary: bun scripts\/cli\.ts web-probe observe collect/u);
});