105 lines
2.9 KiB
JavaScript
105 lines
2.9 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import ts from "typescript";
|
|
|
|
const testDir = path.dirname(fileURLToPath(import.meta.url));
|
|
const sourcePath = path.resolve(testDir, "../src/features/article-detail/model.ts");
|
|
const source = readFileSync(sourcePath, "utf8");
|
|
const compiled = ts.transpileModule(source, {
|
|
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 },
|
|
});
|
|
|
|
const moduleExports = {};
|
|
new Function("exports", compiled.outputText)(moduleExports);
|
|
|
|
const { buildProductionArtifactRows } = moduleExports;
|
|
|
|
const rows = buildProductionArtifactRows([
|
|
{
|
|
id: "job-section-1",
|
|
article_id: "a1",
|
|
parent_job_id: null,
|
|
attempt: 1,
|
|
job_type: "SECTION_SCAFFOLD",
|
|
agent_profile: "fake-section-scaffold",
|
|
status: "SUCCEEDED",
|
|
workspace_path: null,
|
|
input_files: [],
|
|
output_files: [],
|
|
payload: {
|
|
artifact_key: "section:1",
|
|
artifact_label: "Context and scope",
|
|
used_evidence_ids: ["e1", "e2"],
|
|
unsupported_claims: [],
|
|
},
|
|
error_category: null,
|
|
error_message: null,
|
|
stdout: "",
|
|
stderr: "",
|
|
exit_code: 0,
|
|
duration_ms: 3,
|
|
queued_at: "2026-05-21T00:00:00Z",
|
|
started_at: "2026-05-21T00:00:01Z",
|
|
finished_at: "2026-05-21T00:00:02Z",
|
|
},
|
|
{
|
|
id: "job-section-2",
|
|
article_id: "a1",
|
|
parent_job_id: null,
|
|
attempt: 1,
|
|
job_type: "SECTION_SCAFFOLD",
|
|
agent_profile: "fake-section-scaffold",
|
|
status: "FAILED",
|
|
workspace_path: null,
|
|
input_files: [],
|
|
output_files: [],
|
|
payload: {
|
|
artifact_key: "section:2",
|
|
artifact_label: "Implementation workflow",
|
|
used_evidence_ids: ["e2"],
|
|
unsupported_claims: [{ claim_text: "Unverified claim" }],
|
|
},
|
|
error_category: "UNSUPPORTED_CLAIMS_FOUND",
|
|
error_message: "Unsupported claims introduced during scaffolding: 1",
|
|
stdout: "",
|
|
stderr: "",
|
|
exit_code: 0,
|
|
duration_ms: 3,
|
|
queued_at: "2026-05-21T00:00:00Z",
|
|
started_at: "2026-05-21T00:00:01Z",
|
|
finished_at: "2026-05-21T00:00:02Z",
|
|
},
|
|
{
|
|
id: "job-non-artifact",
|
|
article_id: "a1",
|
|
parent_job_id: null,
|
|
attempt: 1,
|
|
job_type: "TEST_CODEX",
|
|
agent_profile: "fake-codex",
|
|
status: "SUCCEEDED",
|
|
workspace_path: null,
|
|
input_files: [],
|
|
output_files: [],
|
|
payload: {},
|
|
error_category: null,
|
|
error_message: null,
|
|
stdout: "",
|
|
stderr: "",
|
|
exit_code: 0,
|
|
duration_ms: 0,
|
|
queued_at: "2026-05-21T00:00:00Z",
|
|
started_at: "2026-05-21T00:00:01Z",
|
|
finished_at: "2026-05-21T00:00:02Z",
|
|
},
|
|
]);
|
|
|
|
assert.equal(rows.length, 2);
|
|
assert.equal(rows[0].artifactLabel, "Context and scope");
|
|
assert.equal(rows[0].status, "SUCCEEDED");
|
|
assert.deepEqual(rows[0].usedEvidenceIds, ["e1", "e2"]);
|
|
assert.equal(rows[1].status, "FAILED");
|
|
assert.deepEqual(rows[1].unsupportedClaims, ["Unverified claim"]);
|