The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | import * as Schema from "effect/Schema"; |
| 3 | |
| 4 | import { ThreadId } from "./baseSchemas.ts"; |
| 5 | import { ProviderSendTurnInput, ProviderUploadFeedbackError } from "./provider.ts"; |
| 6 | |
| 7 | const decodeProviderSendTurnInput = Schema.decodeUnknownSync(ProviderSendTurnInput); |
| 8 | |
| 9 | describe("ProviderSendTurnInput", () => { |
| 10 | it.each(["image", "file"])( |
| 11 | "caps total image bytes for %s attachments without charging videos", |
| 12 | (type) => { |
| 13 | const image = { |
| 14 | type, |
| 15 | id: "image", |
| 16 | name: "image.png", |
| 17 | mimeType: "image/png", |
| 18 | sizeBytes: 10 * 1024 * 1024, |
| 19 | }; |
| 20 | const video = { |
| 21 | type: "file", |
| 22 | id: "video", |
| 23 | name: "video.mp4", |
| 24 | mimeType: "video/mp4", |
| 25 | sizeBytes: 50 * 1024 * 1024, |
| 26 | }; |
| 27 | expect( |
| 28 | decodeProviderSendTurnInput({ |
| 29 | threadId: "thread-1", |
| 30 | attachments: [...Array.from({ length: 8 }, () => image), video], |
| 31 | }).attachments, |
| 32 | ).toHaveLength(9); |
| 33 | expect(() => |
| 34 | decodeProviderSendTurnInput({ |
| 35 | threadId: "thread-1", |
| 36 | attachments: [...Array.from({ length: 8 }, () => image), { ...image, sizeBytes: 1 }], |
| 37 | }), |
| 38 | ).toThrow(/80 MiB/); |
| 39 | }, |
| 40 | ); |
| 41 | }); |
| 42 | |
| 43 | describe("provider feedback", () => { |
| 44 | it("keeps the failed thread and original cause without exposing upstream text", () => { |
| 45 | const cause = new Error("provider request secret"); |
| 46 | const error = new ProviderUploadFeedbackError({ |
| 47 | threadId: ThreadId.make("thread-1"), |
| 48 | cause, |
| 49 | }); |
| 50 | |
| 51 | expect(error.threadId).toBe("thread-1"); |
| 52 | expect(error.cause).toBe(cause); |
| 53 | expect(error.message).toBe("Failed to upload feedback for thread thread-1."); |
| 54 | expect(error.message).not.toContain("provider request secret"); |
| 55 | }); |
| 56 | }); |