mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-01 14:52:25 +00:00
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import type { PromptInfo } from "../../../../src/cli/cmd/tui/component/prompt/history"
|
|
import { assign, strip } from "../../../../src/cli/cmd/tui/component/prompt/part"
|
|
|
|
describe("prompt part", () => {
|
|
test("strip removes persisted ids from reused file parts", () => {
|
|
const part = {
|
|
id: "prt_old",
|
|
sessionID: "ses_old",
|
|
messageID: "msg_old",
|
|
type: "file" as const,
|
|
mime: "image/png",
|
|
filename: "tiny.png",
|
|
url: "data:image/png;base64,abc",
|
|
}
|
|
|
|
expect(strip(part)).toEqual({
|
|
type: "file",
|
|
mime: "image/png",
|
|
filename: "tiny.png",
|
|
url: "data:image/png;base64,abc",
|
|
})
|
|
})
|
|
|
|
test("assign overwrites stale runtime ids", () => {
|
|
const part = {
|
|
id: "prt_old",
|
|
sessionID: "ses_old",
|
|
messageID: "msg_old",
|
|
type: "file" as const,
|
|
mime: "image/png",
|
|
filename: "tiny.png",
|
|
url: "data:image/png;base64,abc",
|
|
} as PromptInfo["parts"][number]
|
|
|
|
const next = assign(part)
|
|
|
|
expect(next.id).not.toBe("prt_old")
|
|
expect(next.id.startsWith("prt_")).toBe(true)
|
|
expect(next).toMatchObject({
|
|
type: "file",
|
|
mime: "image/png",
|
|
filename: "tiny.png",
|
|
url: "data:image/png;base64,abc",
|
|
})
|
|
})
|
|
})
|