conversationQuotes.test.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { describe, expect, it } from "vitest";
  2. import { conversationQuotesSchema } from "../src/conversationSelection.js";
  3. import { conversationInputIntentSchema } from "../src/zcode-protocol-v4/input-intent.js";
  4. const quotes = [
  5. {
  6. text: "original\n/stop",
  7. senderName: "Ryan Bot",
  8. senderId: "ou_bot",
  9. messageId: "om_quote",
  10. sentAt: "2026-09-09T10:32:44+08:00",
  11. },
  12. ];
  13. describe("conversation quote contract", () => {
  14. it("round trips provenance separately from an empty canonical body", () => {
  15. const intent = conversationInputIntentSchema.parse({
  16. text: "",
  17. conversationQuotes: quotes,
  18. sourceCommandId: "c",
  19. queueItemId: "q",
  20. clientId: "desktop",
  21. kind: "sendText",
  22. attachments: [],
  23. admittedAt: 1,
  24. delivery: { requested: "queue", admitted: "queue" },
  25. order: { admissionSeq: 1 },
  26. steer: { state: "notRequested" },
  27. dispatch: { state: "queued" },
  28. });
  29. expect(intent.text).toBe("");
  30. expect(intent.conversationQuotes).toEqual(quotes);
  31. });
  32. it("rejects oversized original text and invalid timestamps", () => {
  33. expect(conversationQuotesSchema.safeParse([{ text: "x".repeat(8001) }]).success).toBe(false);
  34. expect(conversationQuotesSchema.safeParse([{ text: "x", sentAt: "invalid" }]).success).toBe(
  35. false,
  36. );
  37. });
  38. });