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 | |
| 3 | import { |
| 4 | appendCodexArtifactTemplateUsePrompt, |
| 5 | resolveCodexArtifactTemplate, |
| 6 | type CodexArtifactTemplate, |
| 7 | } from "./codexArtifactTemplates.ts"; |
| 8 | |
| 9 | const HELLO_WORLD_TEMPLATE: CodexArtifactTemplate = { |
| 10 | artifactKind: "document", |
| 11 | displayName: "Hello World", |
| 12 | skillDirectory: "/Users/test/.codex/skills/artifact-template-hello-world", |
| 13 | skillName: "artifact-template-hello-world", |
| 14 | }; |
| 15 | |
| 16 | describe("resolveCodexArtifactTemplate", () => { |
| 17 | it("accepts the template metadata emitted by Codex", () => { |
| 18 | expect( |
| 19 | resolveCodexArtifactTemplate({ |
| 20 | artifact_kind: "document", |
| 21 | display_name: " Hello World ", |
| 22 | skill_directory: "/Users/test/.codex/skills/artifact-template-hello-world", |
| 23 | skill_name: "artifact-template-hello-world", |
| 24 | }), |
| 25 | ).toEqual(HELLO_WORLD_TEMPLATE); |
| 26 | }); |
| 27 | |
| 28 | it.each([ |
| 29 | String.raw`C:\Users\test\.codex\skills\artifact-template-hello-world`, |
| 30 | String.raw`\\server\share\artifact-template-hello-world`, |
| 31 | "//server/share/artifact-template-hello-world", |
| 32 | ])("accepts absolute Windows skill directories: %s", (skillDirectory) => { |
| 33 | expect( |
| 34 | resolveCodexArtifactTemplate({ |
| 35 | artifact_kind: "image", |
| 36 | display_name: "Reference image", |
| 37 | gallery_kind: "product-design", |
| 38 | skill_directory: skillDirectory, |
| 39 | skill_name: "artifact-template-reference-image", |
| 40 | }), |
| 41 | ).toMatchObject({ |
| 42 | artifactKind: "image", |
| 43 | galleryKind: "product-design", |
| 44 | skillDirectory, |
| 45 | }); |
| 46 | }); |
| 47 | }); |
| 48 | |
| 49 | describe("appendCodexArtifactTemplateUsePrompt", () => { |
| 50 | const prompt = "Create a document using this $artifact-template-hello-world about…"; |
| 51 | |
| 52 | it("preserves existing draft text", () => { |
| 53 | expect(appendCodexArtifactTemplateUsePrompt("Write about otters", HELLO_WORLD_TEMPLATE)).toBe( |
| 54 | `Write about otters ${prompt}`, |
| 55 | ); |
| 56 | }); |
| 57 | |
| 58 | it.each([prompt, `${prompt}\n`, `Notes\n\n${prompt}`])( |
| 59 | "does not append the same final prompt twice: %s", |
| 60 | (draft) => { |
| 61 | expect(appendCodexArtifactTemplateUsePrompt(draft, HELLO_WORLD_TEMPLATE)).toBe(draft); |
| 62 | }, |
| 63 | ); |
| 64 | |
| 65 | it("does not mistake text containing the prompt for a final prompt", () => { |
| 66 | const draft = `${prompt}\nAdditional instructions`; |
| 67 | expect(appendCodexArtifactTemplateUsePrompt(draft, HELLO_WORLD_TEMPLATE)).toBe( |
| 68 | `${draft} ${prompt}`, |
| 69 | ); |
| 70 | }); |
| 71 | }); |