botGroupInputSource.test.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. commandPayloadSchemas,
  4. conversationInputIntentSchema,
  5. } from "@zcode/shared/zcode-protocol-v4";
  6. describe("group source wire contract", () => {
  7. it("preserves sender separately from destination in command and canonical input", () => {
  8. const botGroupSource = {
  9. provider: "feishu",
  10. botId: "bot",
  11. chatId: "oc_group",
  12. senderId: "ou_member",
  13. senderName: "甲",
  14. messageId: "om_message",
  15. };
  16. expect(
  17. commandPayloadSchemas.sendText.parse({
  18. text: "hello",
  19. botGroupSource,
  20. inputOrigin: "mobile",
  21. }),
  22. ).toMatchObject({
  23. botGroupSource,
  24. inputOrigin: "mobile",
  25. });
  26. const input = {
  27. sourceCommandId: "command",
  28. queueItemId: "queue",
  29. clientId: "client",
  30. kind: "sendText",
  31. text: "hello",
  32. delivery: { requested: "queue", admitted: "queue" },
  33. order: { admissionSeq: 1 },
  34. steer: { state: "notRequested" },
  35. dispatch: { state: "queued" },
  36. admittedAt: 1,
  37. botGroupSource,
  38. };
  39. expect(conversationInputIntentSchema.parse(input)).toMatchObject({ botGroupSource });
  40. });
  41. });