chat.test.ts 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. // ---------------------------------------------------------------------------
  2. // CLI Interactive use cases — main chat view
  3. //
  4. // Covers:
  5. // - `cline` launches interactive view (authed / unauthed)
  6. // - /settings navigation and tab verification
  7. // - /models view
  8. // - /history view
  9. // - /skills view
  10. // - Plan/Act mode toggle (Tab)
  11. // - Plan task → toggle to Act → task executes
  12. // - Act task → file edit permission prompt → Save / Reject
  13. // - Task completed → Start New Task / Exit buttons
  14. // - Auto-approve settings
  15. // - Subagents
  16. // - Web tools
  17. // - Auto-approve all (Shift+Tab)
  18. // ---------------------------------------------------------------------------
  19. import { test } from "@microsoft/tui-test"
  20. import { CLINE_BIN, TERMINAL_WIDE } from "../helpers/constants.js"
  21. import { clineEnv } from "../helpers/env.js"
  22. import {
  23. openHistory,
  24. openModels,
  25. openSettings,
  26. openSkills,
  27. toggleAutoApproveAll,
  28. togglePlanAct,
  29. waitForChatReady,
  30. } from "../helpers/page-objects/chat.js"
  31. import {
  32. assertApiTab,
  33. assertAutoApproveTab,
  34. assertFeaturesTab,
  35. assertOtherTab,
  36. goToSettingsTab,
  37. } from "../helpers/page-objects/settings.js"
  38. import { expectVisible } from "../helpers/terminal.js"
  39. // ---------------------------------------------------------------------------
  40. // cline (unauthenticated) → shows interactive auth view
  41. // ---------------------------------------------------------------------------
  42. test.describe("cline (unauthenticated) — shows auth view", () => {
  43. test.use({
  44. program: { file: CLINE_BIN, args: ["--tui"] },
  45. ...TERMINAL_WIDE,
  46. env: clineEnv("unauthenticated"),
  47. })
  48. test("shows interactive auth view when not authenticated", async ({ terminal }) => {
  49. await expectVisible(terminal, /sign in|authenticate|api key/i, {
  50. timeout: 10_000,
  51. })
  52. })
  53. })
  54. // ---------------------------------------------------------------------------
  55. // cline (authenticated) → shows main chat view
  56. // ---------------------------------------------------------------------------
  57. test.describe("cline (authenticated) — shows chat view", () => {
  58. test.use({
  59. program: { file: CLINE_BIN, args: ["--tui"] },
  60. ...TERMINAL_WIDE,
  61. env: clineEnv("claude-sonnet-4.6"),
  62. })
  63. test("shows interactive chat view", async ({ terminal }) => {
  64. await waitForChatReady(terminal)
  65. })
  66. })
  67. // ---------------------------------------------------------------------------
  68. // /settings — tab navigation
  69. // ---------------------------------------------------------------------------
  70. test.describe("/settings — tab navigation", () => {
  71. test.use({
  72. program: { file: CLINE_BIN, args: ["--tui"] },
  73. ...TERMINAL_WIDE,
  74. env: clineEnv("claude-sonnet-4.6"),
  75. })
  76. test("opens settings and shows API tab by default", async ({ terminal }) => {
  77. await openSettings(terminal)
  78. await assertApiTab(terminal)
  79. })
  80. test("can navigate to Auto-approve tab with keyRight", async ({ terminal }) => {
  81. await openSettings(terminal)
  82. terminal.keyRight()
  83. await assertAutoApproveTab(terminal)
  84. })
  85. test("can navigate to Features tab", async ({ terminal }) => {
  86. await openSettings(terminal)
  87. await goToSettingsTab(terminal, "Features")
  88. await assertFeaturesTab(terminal)
  89. })
  90. test("can navigate to Other tab", async ({ terminal }) => {
  91. await openSettings(terminal)
  92. await goToSettingsTab(terminal, "Other")
  93. await assertOtherTab(terminal)
  94. })
  95. test("pressing Escape closes settings", async ({ terminal }) => {
  96. await openSettings(terminal)
  97. terminal.keyEscape()
  98. await waitForChatReady(terminal)
  99. })
  100. })
  101. // ---------------------------------------------------------------------------
  102. // /models — browse models
  103. // ---------------------------------------------------------------------------
  104. test.describe("/models — model browser", () => {
  105. test.use({
  106. program: { file: CLINE_BIN, args: ["--tui"] },
  107. ...TERMINAL_WIDE,
  108. env: clineEnv("claude-sonnet-4.6"),
  109. })
  110. test("opens models view with featured models", async ({ terminal }) => {
  111. await openModels(terminal)
  112. await expectVisible(terminal, "Browse all models...")
  113. })
  114. test("pressing Escape returns to chat view", async ({ terminal }) => {
  115. await openModels(terminal)
  116. await expectVisible(terminal, /model|browse/i, { timeout: 5000 })
  117. terminal.keyEscape()
  118. await waitForChatReady(terminal)
  119. })
  120. })
  121. // ---------------------------------------------------------------------------
  122. // /history — task history
  123. // ---------------------------------------------------------------------------
  124. test.describe("/history — task history", () => {
  125. test.use({
  126. program: { file: CLINE_BIN, args: ["--tui"] },
  127. ...TERMINAL_WIDE,
  128. env: clineEnv("claude-sonnet-4.6"),
  129. })
  130. test("opens history view", async ({ terminal }) => {
  131. await openHistory(terminal)
  132. await expectVisible(terminal, /history|task/i)
  133. })
  134. test("pressing Escape closes history", async ({ terminal }) => {
  135. await openHistory(terminal)
  136. await expectVisible(terminal, /history|task/i)
  137. terminal.keyEscape()
  138. await waitForChatReady(terminal)
  139. })
  140. })
  141. // ---------------------------------------------------------------------------
  142. // /skills — skills view
  143. // ---------------------------------------------------------------------------
  144. test.describe("/skills — skills view", () => {
  145. test.use({
  146. program: { file: CLINE_BIN, args: ["--tui"] },
  147. ...TERMINAL_WIDE,
  148. env: clineEnv("default"),
  149. })
  150. test("opens skills view", async ({ terminal }) => {
  151. await openSkills(terminal)
  152. await expectVisible(terminal, "Skills (Esc to close)")
  153. })
  154. test("pressing Escape closes skills", async ({ terminal }) => {
  155. await openSkills(terminal)
  156. await expectVisible(terminal, "Skills (Esc to close)")
  157. terminal.keyEscape()
  158. await waitForChatReady(terminal)
  159. })
  160. })
  161. // ---------------------------------------------------------------------------
  162. // Plan/Act mode toggle
  163. // ---------------------------------------------------------------------------
  164. test.describe("Plan/Act mode toggle", () => {
  165. test.use({
  166. program: { file: CLINE_BIN, args: ["--tui"] },
  167. ...TERMINAL_WIDE,
  168. env: clineEnv("default"),
  169. })
  170. test("pressing Tab toggles between Plan and Act mode", async ({ terminal }) => {
  171. await waitForChatReady(terminal)
  172. // Default should show Act
  173. await expectVisible(terminal, "○ Plan ● Act")
  174. await togglePlanAct(terminal)
  175. // After toggle, the other mode should be active
  176. await expectVisible(terminal, "● Plan ○ Act")
  177. })
  178. })
  179. // ---------------------------------------------------------------------------
  180. // Auto-approve all (Shift+Tab)
  181. // ---------------------------------------------------------------------------
  182. test.describe("Auto-approve all — Shift+Tab toggle", () => {
  183. test.use({
  184. program: { file: CLINE_BIN, args: ["--tui"] },
  185. ...TERMINAL_WIDE,
  186. env: clineEnv("default"),
  187. })
  188. test("Shift+Tab toggles auto-approve-all setting", async ({ terminal }) => {
  189. await waitForChatReady(terminal)
  190. await expectVisible(terminal, "Auto-approve all disabled")
  191. await toggleAutoApproveAll(terminal)
  192. // TODO: verify config store is updated
  193. await expectVisible(terminal, "Auto-approve all enabled")
  194. })
  195. })