| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 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",
- })
- })
- })
|