|
1 | 1 | import * as assert from "assert" |
2 | 2 |
|
3 | | -import type { ClineMessage } from "@roo-code/types" |
4 | | - |
5 | 3 | import { waitUntilCompleted } from "./utils" |
6 | 4 |
|
7 | 5 | suite("Roo Code Modes", () => { |
8 | 6 | test("Should handle switching modes correctly", async () => { |
9 | | - const api = globalThis.api |
10 | | - |
11 | | - const switchModesPrompt = |
12 | | - "For each mode (Architect, Ask, Debug) respond with the mode name and what it specializes in after switching to that mode." |
13 | | - |
14 | | - const messages: ClineMessage[] = [] |
15 | | - const modeSwitches: string[] = [] |
| 7 | + const modes: string[] = [] |
16 | 8 |
|
17 | | - api.on("taskModeSwitched", (_taskId, mode) => { |
18 | | - console.log("taskModeSwitched", mode) |
19 | | - modeSwitches.push(mode) |
20 | | - }) |
21 | | - |
22 | | - api.on("message", ({ message }) => { |
23 | | - if (message.type === "say" && message.partial === false) { |
24 | | - messages.push(message) |
25 | | - } |
26 | | - }) |
| 9 | + globalThis.api.on("taskModeSwitched", (_taskId, mode) => modes.push(mode)) |
27 | 10 |
|
28 | | - const switchModesTaskId = await api.startNewTask({ |
| 11 | + const switchModesTaskId = await globalThis.api.startNewTask({ |
29 | 12 | configuration: { mode: "code", alwaysAllowModeSwitch: true, autoApprovalEnabled: true }, |
30 | | - text: switchModesPrompt, |
| 13 | + text: "For each of `architect`, `ask`, and `debug` use the `switch_mode` tool to switch to that mode.", |
31 | 14 | }) |
32 | 15 |
|
33 | | - await waitUntilCompleted({ api, taskId: switchModesTaskId }) |
34 | | - await api.cancelCurrentTask() |
| 16 | + await waitUntilCompleted({ api: globalThis.api, taskId: switchModesTaskId }) |
| 17 | + await globalThis.api.cancelCurrentTask() |
35 | 18 |
|
36 | | - assert.ok(modeSwitches.includes("architect")) |
37 | | - assert.ok(modeSwitches.includes("ask")) |
38 | | - assert.ok(modeSwitches.includes("debug")) |
| 19 | + assert.ok(modes.includes("architect")) |
| 20 | + assert.ok(modes.includes("ask")) |
| 21 | + assert.ok(modes.includes("debug")) |
| 22 | + assert.ok(modes.length === 3) |
39 | 23 | }) |
40 | 24 | }) |
0 commit comments