feat(ui): add operator UI server, stores, and insights
This commit is contained in:
66
tests/provider-executor.test.ts
Normal file
66
tests/provider-executor.test.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { parseActorExecutionResultFromModelOutput } from "../src/ui/provider-executor.js";
|
||||
|
||||
test("parseActorExecutionResultFromModelOutput parses strict JSON payload", () => {
|
||||
const parsed = parseActorExecutionResultFromModelOutput({
|
||||
rawText: JSON.stringify({
|
||||
status: "validation_fail",
|
||||
payload: {
|
||||
summary: "missing test",
|
||||
},
|
||||
stateFlags: {
|
||||
needs_fix: true,
|
||||
},
|
||||
stateMetadata: {
|
||||
stage: "qa",
|
||||
},
|
||||
events: [
|
||||
{
|
||||
type: "validation_failed",
|
||||
payload: {
|
||||
summary: "failed",
|
||||
},
|
||||
},
|
||||
],
|
||||
failureKind: "soft",
|
||||
failureCode: "missing_test",
|
||||
}),
|
||||
});
|
||||
|
||||
assert.equal(parsed.status, "validation_fail");
|
||||
assert.equal(parsed.payload?.summary, "missing test");
|
||||
assert.equal(parsed.stateFlags?.needs_fix, true);
|
||||
assert.equal(parsed.stateMetadata?.stage, "qa");
|
||||
assert.equal(parsed.events?.[0]?.type, "validation_failed");
|
||||
assert.equal(parsed.failureKind, "soft");
|
||||
assert.equal(parsed.failureCode, "missing_test");
|
||||
});
|
||||
|
||||
test("parseActorExecutionResultFromModelOutput parses fenced JSON", () => {
|
||||
const parsed = parseActorExecutionResultFromModelOutput({
|
||||
rawText: [
|
||||
"Here is the result",
|
||||
"```json",
|
||||
JSON.stringify({
|
||||
status: "success",
|
||||
payload: {
|
||||
code: "done",
|
||||
},
|
||||
}),
|
||||
"```",
|
||||
].join("\n"),
|
||||
});
|
||||
|
||||
assert.equal(parsed.status, "success");
|
||||
assert.equal(parsed.payload?.code, "done");
|
||||
});
|
||||
|
||||
test("parseActorExecutionResultFromModelOutput falls back when response is not JSON", () => {
|
||||
const parsed = parseActorExecutionResultFromModelOutput({
|
||||
rawText: "Implemented update successfully.",
|
||||
});
|
||||
|
||||
assert.equal(parsed.status, "success");
|
||||
assert.equal(parsed.payload?.assistantResponse, "Implemented update successfully.");
|
||||
});
|
||||
Reference in New Issue
Block a user