v4PromptScrollFocusPolicy.test.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { describe, expect, it } from "vitest";
  2. import { shouldFocusTimelineAfterComposerSend } from "@/v4/promptScrollFocusPolicy.js";
  3. describe("V4 prompt scroll focus policy", () => {
  4. it("focuses the latest content after draft and start-now sends", () => {
  5. expect(
  6. shouldFocusTimelineAfterComposerSend({
  7. draftMode: true,
  8. inputRoutingMode: null,
  9. }),
  10. ).toBe(true);
  11. expect(
  12. shouldFocusTimelineAfterComposerSend({
  13. draftMode: false,
  14. inputRoutingMode: "startNow",
  15. }),
  16. ).toBe(true);
  17. });
  18. it("preserves the reading position when the new prompt only enqueues", () => {
  19. expect(
  20. shouldFocusTimelineAfterComposerSend({
  21. draftMode: false,
  22. inputRoutingMode: "enqueue",
  23. }),
  24. ).toBe(false);
  25. });
  26. it("focuses after either held-queue choice because both start immediately", () => {
  27. expect(
  28. shouldFocusTimelineAfterComposerSend({
  29. draftMode: false,
  30. inputRoutingMode: "choice",
  31. heldQueueDisposition: "clearQueueAndSend",
  32. }),
  33. ).toBe(true);
  34. expect(
  35. shouldFocusTimelineAfterComposerSend({
  36. draftMode: false,
  37. inputRoutingMode: "choice",
  38. heldQueueDisposition: "keepQueueAndSend",
  39. }),
  40. ).toBe(true);
  41. });
  42. });