chatPlaceholder.test.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. resolveChatPlaceholderKey,
  4. shouldDeferChatPlaceholder,
  5. } from "../src/lib/chatPlaceholder.js";
  6. describe("resolveChatPlaceholderKey", () => {
  7. it("returns newTask for empty conversation", () => {
  8. expect(
  9. resolveChatPlaceholderKey({
  10. hasHistoryMessages: false,
  11. isTaskProcessing: false,
  12. }),
  13. ).toBe("chat.placeholder.newTask");
  14. });
  15. it("returns compact newTask copy for an empty mobile remote conversation", () => {
  16. expect(
  17. resolveChatPlaceholderKey({
  18. hasHistoryMessages: false,
  19. isTaskProcessing: false,
  20. compactNewTask: true,
  21. }),
  22. ).toBe("chat.placeholder.newTaskMobile");
  23. });
  24. it("returns newTask while first turn is processing", () => {
  25. expect(
  26. resolveChatPlaceholderKey({
  27. hasHistoryMessages: false,
  28. isTaskProcessing: true,
  29. }),
  30. ).toBe("chat.placeholder.newTask");
  31. });
  32. it("returns followUpAsk when conversation is idle", () => {
  33. expect(
  34. resolveChatPlaceholderKey({
  35. hasHistoryMessages: true,
  36. isTaskProcessing: false,
  37. }),
  38. ).toBe("chat.placeholder.followUpAsk");
  39. });
  40. it("returns followUpQueue when follow-up can be queued", () => {
  41. expect(
  42. resolveChatPlaceholderKey({
  43. hasHistoryMessages: true,
  44. isTaskProcessing: true,
  45. }),
  46. ).toBe("chat.placeholder.followUpQueue");
  47. });
  48. });
  49. describe("shouldDeferChatPlaceholder", () => {
  50. it("defers placeholder while bound task is creating", () => {
  51. expect(
  52. shouldDeferChatPlaceholder({
  53. hasBoundTask: true,
  54. taskStatus: "creating",
  55. }),
  56. ).toBe(true);
  57. });
  58. it("defers placeholder while bound task is restoring", () => {
  59. expect(
  60. shouldDeferChatPlaceholder({
  61. hasBoundTask: true,
  62. taskStatus: "restoring",
  63. }),
  64. ).toBe(true);
  65. });
  66. it("does not defer placeholder after task becomes ready", () => {
  67. expect(
  68. shouldDeferChatPlaceholder({
  69. hasBoundTask: true,
  70. taskStatus: "ready",
  71. }),
  72. ).toBe(false);
  73. });
  74. it("does not defer placeholder in draft mode", () => {
  75. expect(
  76. shouldDeferChatPlaceholder({
  77. hasBoundTask: false,
  78. taskStatus: "creating",
  79. }),
  80. ).toBe(false);
  81. });
  82. });