Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
test(studio-server): pin how an older history log takes in the media ledger (#5021)
Miguel Ángelf70dce70ed4c
diff --git a/packages/studio-server/src/history/projectHistory.test.ts b/packages/studio-server/src/history/projectHistory.test.tsindex 0d9a80f190..fa846ec88a 100644--- a/packages/studio-server/src/history/projectHistory.test.ts+++ b/packages/studio-server/src/history/projectHistory.test.ts@@ -70,20 +70,20 @@ async function project(files: Record<string, string | Buffer>, options = {}) {return { projectDir, historyRoot, history, write, read, has };}-/** Undoes the newest change still in effect, whoever made it; Cmd+Z steps only over the caller's own. */-/** What 0.8.123 leaves: a log whose baseline never names the media ledger and carries no marker. */-function asWrittenBy0_8_123(logFile: string) {+/** A log as an older version leaves it: no marker; 0.8.123's baseline also never names the media ledger. */+function asWrittenBy(version: "0.8.122" | "0.8.123", logFile: string) {const lines = readFileSync(logFile, "utf-8").trim().split("\n").map((line) => JSON.parse(line));for (const record of lines.filter((line) => line.type === "baseline")) {- delete record.files[".media/manifest.jsonl"];+ if (version === "0.8.123") delete record.files[".media/manifest.jsonl"];delete record.keepsLedger;}writeFileSync(logFile, lines.map((record) => JSON.stringify(record)).join("\n") + "\n");}+/** Undoes the newest change still in effect, whoever made it; Cmd+Z steps only over the caller's own. */async function undoNewest(history: ProjectHistory) {const newest = [...history.list()].reverse().find((entry) => !entry.undoes && !entry.undone);return history.undo(newest!.id, { who: you });@@ -221,7 +221,7 @@ describe("openProjectHistory", () => {});await change(history, you, "Your edit", () => write("index.html", "B"));await history.close();- asWrittenBy0_8_123(join(historyRoot, history.projectId, "log.jsonl"));+ asWrittenBy("0.8.123", join(historyRoot, history.projectId, "log.jsonl"));const reopened = await open(projectDir, historyRoot);expect(await reopened.step("back", you)).toMatchObject({ ok: true });expect([read("index.html"), read(".media/manifest.jsonl")]).toEqual(["A", "{}\n"]);@@ -236,7 +236,7 @@ describe("openProjectHistory", () => {{ quietMs: 30 },);await history.close();- asWrittenBy0_8_123(join(historyRoot, history.projectId, "log.jsonl"));+ asWrittenBy("0.8.123", join(historyRoot, history.projectId, "log.jsonl"));const outside = tempDir("hf-history-linked-");writeFileSync(join(outside, "manifest.jsonl"), "{}\n");symlinkSync(outside, join(projectDir, ".media"), "dir");@@ -265,6 +265,50 @@ describe("openProjectHistory", () => {expect([read("index.html"), has(".media/manifest.jsonl")]).toEqual(["A", false]);});+ it("a log 0.8.123 wrote without a ledger takes none in, and one made later while closed is a change", async () => {+ const { history, write, projectDir, historyRoot } = await project(+ { "index.html": "A" },+ { quietMs: 30 },+ );+ await history.close();+ asWrittenBy("0.8.123", join(historyRoot, history.projectId, "log.jsonl"));+ await (await open(projectDir, historyRoot, { quietMs: 30 })).close();+ write(".media/manifest.jsonl", "{}\n");+ const reopened = await open(projectDir, historyRoot, { quietMs: 30 });+ await reopened.flush();+ expect(reopened.list().map((entry) => entry.files.map((file) => file.path))).toEqual([+ [".media/manifest.jsonl"],+ ]);+ });++ it("an older log keeps a ledger one of its changes made out of the start", async () => {+ const { history, write, has, projectDir, historyRoot } = await project({ "index.html": "A" });+ await change(history, agent, "Cut out the logo", () => {+ write("index.html", "B");+ write(".media/manifest.jsonl", "{}\n");+ });+ await history.close();+ asWrittenBy("0.8.122", join(historyRoot, history.projectId, "log.jsonl"));+ const reopened = await open(projectDir, historyRoot);+ await reopened.restore(START, you);+ expect(has(".media/manifest.jsonl")).toBe(false);+ });++ it("an older log keeps the ledger its start names, so a change made while closed is filed", async () => {+ const { history, write, projectDir, historyRoot } = await project(+ { "index.html": "A", ".media/manifest.jsonl": "{}\n" },+ { quietMs: 30 },+ );+ await history.close();+ asWrittenBy("0.8.122", join(historyRoot, history.projectId, "log.jsonl"));+ write(".media/manifest.jsonl", '{}\n{"id":"logo"}\n');+ const reopened = await open(projectDir, historyRoot, { quietMs: 30 });+ await reopened.flush();+ expect(reopened.list().map((entry) => entry.files.map((file) => file.path))).toEqual([+ [".media/manifest.jsonl"],+ ]);+ });+it("takes the media ledger back with the film when a change is undone", async () => {const { history, write, read } = await project({"index.html": "<h1>Hello</h1>",