9239d877b9
compliance-close / close-non-compliant (push) Has been cancelled
beta / sync (push) Has been cancelled
docs-update / update-docs (push) Has been cancelled
deploy / deploy (push) Has been cancelled
generate / generate (push) Has been cancelled
nix-eval / nix-eval (push) Has been cancelled
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404, x86_64-linux) (push) Has been cancelled
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404-arm, aarch64-linux) (push) Has been cancelled
nix-hashes / compute-hash (macos-15-intel, x86_64-darwin) (push) Has been cancelled
nix-hashes / compute-hash (macos-latest, aarch64-darwin) (push) Has been cancelled
nix-hashes / update-hashes (push) Has been cancelled
publish / version (push) Has been cancelled
publish / build-cli (push) Has been cancelled
publish / build-tauri (map[host:blacksmith-4vcpu-ubuntu-2404 target:x86_64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-tauri (map[host:blacksmith-4vcpu-windows-2025 target:x86_64-pc-windows-msvc]) (push) Has been cancelled
publish / build-tauri (map[host:blacksmith-8vcpu-ubuntu-2404-arm target:aarch64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-tauri (map[host:macos-latest target:aarch64-apple-darwin]) (push) Has been cancelled
publish / build-tauri (map[host:macos-latest target:x86_64-apple-darwin]) (push) Has been cancelled
publish / build-tauri (map[host:windows-2025 target:aarch64-pc-windows-msvc]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404 platform_flag:--linux target:aarch64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404 platform_flag:--linux target:x86_64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-windows-2025 platform_flag:--win target:x86_64-pc-windows-msvc]) (push) Has been cancelled
publish / build-electron (map[host:macos-latest platform_flag:--mac --arm64 target:aarch64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[host:macos-latest platform_flag:--mac --x64 target:x86_64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[host:windows-2025 platform_flag:--win --arm64 target:aarch64-pc-windows-msvc]) (push) Has been cancelled
publish / publish (push) Has been cancelled
storybook / storybook build (push) Has been cancelled
test / unit (linux) (push) Has been cancelled
test / unit (windows) (push) Has been cancelled
test / e2e (linux) (push) Has been cancelled
test / e2e (windows) (push) Has been cancelled
typecheck / typecheck (push) Has been cancelled
containers / build (push) Has been cancelled
stats / stats (push) Has been cancelled
daily-pr-recap / pr-recap (push) Has been cancelled
daily-issues-recap / daily-recap (push) Has been cancelled
stale-issues / stale (push) Has been cancelled
close-stale-prs / close-stale-prs (push) Has been cancelled
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import type { Part } from "@opencode-ai/sdk/v2"
|
|
import { extractPromptFromParts } from "./prompt"
|
|
|
|
describe("extractPromptFromParts", () => {
|
|
test("restores multiple uploaded attachments", () => {
|
|
const parts = [
|
|
{
|
|
id: "text_1",
|
|
type: "text",
|
|
text: "check these",
|
|
sessionID: "ses_1",
|
|
messageID: "msg_1",
|
|
},
|
|
{
|
|
id: "file_1",
|
|
type: "file",
|
|
mime: "image/png",
|
|
url: "data:image/png;base64,AAA",
|
|
filename: "a.png",
|
|
sessionID: "ses_1",
|
|
messageID: "msg_1",
|
|
},
|
|
{
|
|
id: "file_2",
|
|
type: "file",
|
|
mime: "application/pdf",
|
|
url: "data:application/pdf;base64,BBB",
|
|
filename: "b.pdf",
|
|
sessionID: "ses_1",
|
|
messageID: "msg_1",
|
|
},
|
|
] satisfies Part[]
|
|
|
|
const result = extractPromptFromParts(parts)
|
|
|
|
expect(result).toHaveLength(3)
|
|
expect(result[0]).toMatchObject({ type: "text", content: "check these" })
|
|
expect(result.slice(1)).toMatchObject([
|
|
{ type: "image", filename: "a.png", mime: "image/png", dataUrl: "data:image/png;base64,AAA" },
|
|
{ type: "image", filename: "b.pdf", mime: "application/pdf", dataUrl: "data:application/pdf;base64,BBB" },
|
|
])
|
|
})
|
|
})
|