botTopicBatchSource.test.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { describe, expect, it } from "vitest";
  2. import { botGroupInputSourceSchema } from "@zcode/shared";
  3. const source = {
  4. provider: "feishu",
  5. botId: "bot",
  6. chatId: "chat",
  7. threadId: "topic",
  8. senderId: "last",
  9. senderName: "Last",
  10. messageId: "m2",
  11. };
  12. const messages = [
  13. {
  14. messageId: "m1",
  15. senderId: "first",
  16. senderName: "First",
  17. mentionedBot: true,
  18. text: "first request",
  19. attachmentIndexes: [0],
  20. },
  21. {
  22. messageId: "m2",
  23. senderId: "last",
  24. senderName: "Last",
  25. mentionedBot: false,
  26. text: "correction",
  27. attachmentIndexes: [],
  28. },
  29. ];
  30. describe("topic batch original messages", () => {
  31. it("preserves each sender and body independently inside one accepted input", () => {
  32. expect(botGroupInputSourceSchema.parse({ ...source, messages }).messages).toEqual(messages);
  33. });
  34. it("rejects duplicate source messages and a mismatching boundary", () => {
  35. expect(
  36. botGroupInputSourceSchema.safeParse({ ...source, messages: [messages[0], messages[0]] })
  37. .success,
  38. ).toBe(false);
  39. expect(
  40. botGroupInputSourceSchema.safeParse({ ...source, messageId: "other", messages }).success,
  41. ).toBe(false);
  42. });
  43. });