prompt-input.test.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { describe, expect, it } from "vitest";
  2. import { projectInputHistoryAttachments } from "../src/app/prompt-input.js";
  3. describe("projectInputHistoryAttachments", () => {
  4. it("只把 legacy input history 支持的附件投影到存储契约", () => {
  5. expect(
  6. projectInputHistoryAttachments([
  7. {
  8. content: "zcode-artifact://session/image",
  9. path: "[image #1]",
  10. type: "image",
  11. },
  12. {
  13. content: "data:video/mp4;base64,dmlkZW8=",
  14. path: "[video #1]",
  15. type: "video",
  16. },
  17. {
  18. path: "/tmp/notes.txt",
  19. sourceKind: "clipboard-text",
  20. type: "file",
  21. },
  22. {
  23. content: "https://example.com",
  24. type: "url",
  25. },
  26. ]),
  27. ).toEqual([
  28. {
  29. content: "zcode-artifact://session/image",
  30. path: "[image #1]",
  31. type: "image",
  32. },
  33. {
  34. path: "/tmp/notes.txt",
  35. type: "file",
  36. },
  37. {
  38. content: "https://example.com",
  39. type: "url",
  40. },
  41. ]);
  42. });
  43. it("没有可持久化附件时返回 undefined", () => {
  44. expect(
  45. projectInputHistoryAttachments([
  46. {
  47. content: "data:video/mp4;base64,dmlkZW8=",
  48. type: "video",
  49. },
  50. ]),
  51. ).toBeUndefined();
  52. });
  53. });