Publish static trace explorer: tests/core.test.mjs
Browse files- tests/core.test.mjs +16 -0
tests/core.test.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import test from "node:test";
|
| 2 |
+
import assert from "node:assert/strict";
|
| 3 |
+
import { parseTrace, compareBranch } from "../replay-core.js";
|
| 4 |
+
|
| 5 |
+
const trace = { schema_version: "deltastore-replay-trace-v1", trace_id: "t", original_trajectory: [{event_id:"e1"},{event_id:"e2"}], checkpoints: [{checkpoint_id:"c1",event_id:"e2"}], branches: [{branch_id:"b",parent_checkpoint_id:"c1",events:[{event_id:"b1"}],final_outcome:{task_success:true}}], final_outcome:{task_success:false} };
|
| 6 |
+
|
| 7 |
+
test("parses and compares a checkpoint branch", () => {
|
| 8 |
+
const parsed = parseTrace(trace);
|
| 9 |
+
const comparison = compareBranch(parsed, "b");
|
| 10 |
+
assert.equal(comparison.sharedPrefix.length, 2);
|
| 11 |
+
assert.equal(comparison.alternate[0].event_id, "b1");
|
| 12 |
+
});
|
| 13 |
+
|
| 14 |
+
test("rejects unsupported traces", () => {
|
| 15 |
+
assert.throws(() => parseTrace({ schema_version: "wrong" }));
|
| 16 |
+
});
|