3cec1ffa87
Add a lightweight SummaryFileDiff derived from FileDiff via Struct.omit(["patch"]) to keep session summary DB payloads small. Replace inline anonymous object types in session.sql.ts, revert.ts, and session.ts with the new schema. Cast SessionPrompt input in remote-sender to satisfy narrowed PromptInput type, guard against null in permission normalizeInput, and switch remaining bare .parse calls to .zod.parse for Effect Schema compatibility. Include unit tests verifying SummaryFileDiff field exclusion and round-trip parsing behavior.
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { test, expect } from "bun:test"
|
|
import { Snapshot } from "../../src/snapshot"
|
|
|
|
test("SummaryFileDiff does not contain the `patch` field", () => {
|
|
const keys = Object.keys(Snapshot.SummaryFileDiff.fields)
|
|
expect(keys).not.toContain("patch")
|
|
expect(keys.sort()).toEqual(["additions", "deletions", "file", "status"])
|
|
})
|
|
|
|
test("SummaryFileDiff parse strips `patch` when present on input", () => {
|
|
const full = {
|
|
file: "a.txt",
|
|
patch: "@@ -1 +1 @@\n-old\n+new\n",
|
|
additions: 1,
|
|
deletions: 1,
|
|
status: "modified" as const,
|
|
}
|
|
const parsed = Snapshot.SummaryFileDiff.zod.parse(full)
|
|
expect(parsed).not.toHaveProperty("patch")
|
|
expect(parsed).toEqual({ file: "a.txt", additions: 1, deletions: 1, status: "modified" })
|
|
})
|
|
|
|
test("SummaryFileDiff differs from FileDiff by exactly `patch`", () => {
|
|
const full = new Set(Object.keys(Snapshot.FileDiff.fields))
|
|
const summary = new Set(Object.keys(Snapshot.SummaryFileDiff.fields))
|
|
expect([...full].filter((k) => !summary.has(k))).toEqual(["patch"])
|
|
expect([...summary].filter((k) => !full.has(k))).toEqual([])
|
|
})
|