- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/server/test/projected-path-history.test.ts?format=json
42 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 164, 1 version changed it
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { answer } from "../../worker/project/http.ts";
4import { Project } from "../../worker/project/project.ts";
5import { DiskFirstRuntime } from "../src/disk-first-runtime.ts";
6import { EngineProject } from "../src/engine-project.ts";
7import { memoryStorage } from "./helpers.ts";
9test("tree and path history after a move match memory without persistent read writes", (t) => {
10 const storage = memoryStorage();
11 t.after(() => storage.db.close());
12 const memory = EngineProject.open(storage);
13 assert.equal(answer(memory, "init", undefined, { files: { "a.txt": "one\ntwo\n" } }).status, 200);
14 assert.equal(answer(memory, "move", "alice", { from: "a.txt", to: "b.txt" }).status, 200);
15 assert.equal(answer(memory, "publish", "alice", { message: "Move" }).status, 200);
16 const requests = [
17 ["tree", {}],
18 ["tree", { version: 0 }],
19 ["path", { path: "a.txt" }],
20 ["path", { path: "b.txt" }],
21 ] as const;
22 const expected = requests.map(([op, body]) => answer(memory, op, "alice", body));
23 for (const result of expected) assert.equal(result.status, 200, JSON.stringify(result));
24 t.mock.method(Project, "load", () => {
25 throw Error("full-history replay forbidden");
26 });
27 const runtime = () => new DiskFirstRuntime(storage, "path-history", "path-history");
28 while (!runtime().preparePage(() => {}).ready) {}
29 const rows = () => storage.db.prepare("SELECT * FROM writer_state ORDER BY namespace,collection,key,part").all();
30 const before = rows();
31 for (let i = 0; i < requests.length; i++) {
32 const [op, body] = requests[i]!;
33 assert.deepEqual(
34 runtime().read(
35 (calls) => answer(calls, op, "alice", body),
36 () => {},
37 ),
38 expected[i],
39 );
40 }
41 assert.deepEqual(rows(), before);
42});