diff --git a/scripts/src/hwlab-node/web-probe-observe-collect.test.ts b/scripts/src/hwlab-node/web-probe-observe-collect.test.ts index 7db6f765..1c882939 100644 --- a/scripts/src/hwlab-node/web-probe-observe-collect.test.ts +++ b/scripts/src/hwlab-node/web-probe-observe-collect.test.ts @@ -135,6 +135,42 @@ test("collects an exact failed command artifact without treating artifact failur expect(String(rendered.renderedText)).toContain("terminal event arrived before subscriber disconnect"); }); +test("accepts the standard file collect envelope without requiring a summary view", () => { + const options = collectOptions(); + options.collectView = "files"; + options.collectFile = "commands/failed/cmd-fixture.json"; + const payload = buildNodeWebProbeObserveCollectPayload(options, { workspace: "/workspace" }, { + command: ["trans", "NC01:/workspace", "sh"], + cwd: "/repo", + exitCode: 0, + stdout: JSON.stringify({ + ok: true, + command: "web-probe-observe collect", + stateDir: "/remote/state", + mode: "file", + requestedFile: options.collectFile, + resolvedFile: options.collectFile, + file: { + relative: options.collectFile, + byteCount: 21885, + sha256: "sha256:fixture", + jsonSummary: { topLevelKeys: ["ok", "commandId", "type", "failedAt", "error"] }, + }, + valuesRedacted: true, + }), + stderr: "", + signal: null, + timedOut: false, + } satisfies CommandResult); + + expect(payload.ok).toBe(true); + expect(payload.status).toBe("collected"); + expect(payload.degradedReason).toBeNull(); + const collect = payload.collect as Record; + expect(collect.mode).toBe("file"); + expect(collect.file.byteCount).toBe(21885); +}); + function collectOptions(): NodeWebProbeObserveOptions { return { action: "observe", diff --git a/scripts/src/hwlab-node/web-probe-observe-collect.ts b/scripts/src/hwlab-node/web-probe-observe-collect.ts index b85568b4..7c2f108b 100644 --- a/scripts/src/hwlab-node/web-probe-observe-collect.ts +++ b/scripts/src/hwlab-node/web-probe-observe-collect.ts @@ -89,6 +89,7 @@ export function buildNodeWebProbeObserveCollectPayload( export function isWebObserveCollectJsonContract(value: Record, requestedFile: string | null = null): boolean { const command = stringOrNull(value.command); const view = stringOrNull(value.view); + const mode = stringOrNull(value.mode); const stateDir = stringOrNull(value.stateDir); if (commandArtifactBucket(value, requestedFile) !== null) return true; if (value.ok === false) { @@ -98,7 +99,7 @@ export function isWebObserveCollectJsonContract(value: Record, || stringOrNull(value.error) !== null; } return command === "web-probe-observe collect" - && view !== null + && (view !== null || mode === "file") && stateDir !== null; }