zcodeProtocolV4UserInputEpilogue.test.ts 1.2 KB

12345678910111213141516171819202122232425262728
  1. import { describe, expect, it } from "vitest";
  2. import { userInputRowSchema } from "../src/zcode-protocol-v4/index.js";
  3. // docs/dynamic-workflow/transcript-and-notifications.md:userInput 行的 epilogueStart 是一个非负整数
  4. // 下标(0 = 整条都是引擎文本),可缺席(老转录 / 非工作流会话)。
  5. const base = {
  6. rowId: 1,
  7. entityId: "message-1",
  8. turnId: "turn-1",
  9. createdAt: 1_700_000_000_000,
  10. createdAtSeq: 1,
  11. kind: "userInput" as const,
  12. origin: "realUser" as const,
  13. text: "Summarize\n\n---\nStandard",
  14. };
  15. describe("v4 userInput.epilogueStart", () => {
  16. it("accepts a non-negative integer, including 0, and absence", () => {
  17. expect(userInputRowSchema.parse({ ...base, epilogueStart: 9 }).epilogueStart).toBe(9);
  18. expect(userInputRowSchema.parse({ ...base, epilogueStart: 0 }).epilogueStart).toBe(0);
  19. expect(userInputRowSchema.parse(base)).not.toHaveProperty("epilogueStart");
  20. });
  21. it("rejects negative and fractional offsets", () => {
  22. expect(userInputRowSchema.safeParse({ ...base, epilogueStart: -1 }).success).toBe(false);
  23. expect(userInputRowSchema.safeParse({ ...base, epilogueStart: 1.5 }).success).toBe(false);
  24. });
  25. });