Skip to content

Commit da3ecbc

Browse files
committed
Make e2e tests faster and more reliable
1 parent e464c41 commit da3ecbc

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

e2e/src/suite/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function run() {
2626
await api.setConfiguration({
2727
apiProvider: "openrouter",
2828
openRouterApiKey: process.env.OPENROUTER_API_KEY!,
29-
openRouterModelId: "anthropic/claude-3.5-sonnet",
29+
openRouterModelId: "google/gemini-2.0-flash-001", // "anthropic/claude-3.5-sonnet",
3030
})
3131

3232
await waitUntilReady({ api })

e2e/src/suite/modes.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as assert from "assert"
22

3-
import { getCompletion, getMessage, sleep, waitForCompletion, waitUntilAborted } from "./utils"
3+
import { getCompletion, waitUntilCompleted } from "./utils"
44

55
suite("Roo Code Modes", () => {
66
test("Should handle switching modes correctly", async function () {
@@ -16,7 +16,7 @@ suite("Roo Code Modes", () => {
1616

1717
await api.setConfiguration({ mode: "Code", alwaysAllowModeSwitch: true, autoApprovalEnabled: true })
1818
const switchModesTaskId = await api.startNewTask(switchModesPrompt)
19-
await waitForCompletion({ api, taskId: switchModesTaskId, timeout: 60_000 })
19+
await waitUntilCompleted({ api, taskId: switchModesTaskId, timeout: 60_000 })
2020

2121
/**
2222
* Grade the response.
@@ -32,7 +32,7 @@ suite("Roo Code Modes", () => {
3232

3333
await api.setConfiguration({ mode: "Ask" })
3434
const gradeTaskId = await api.startNewTask(gradePrompt)
35-
await waitForCompletion({ api, taskId: gradeTaskId, timeout: 60_000 })
35+
await waitUntilCompleted({ api, taskId: gradeTaskId, timeout: 60_000 })
3636

3737
const completion = getCompletion({ api, taskId: gradeTaskId })
3838
const match = completion?.text?.match(/Grade: (\d+)/)

e2e/src/suite/subtasks.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as assert from "assert"
22

3-
import { sleep, waitFor, getMessage, waitForCompletion } from "./utils"
3+
import { sleep, waitFor, getMessage, waitUntilCompleted } from "./utils"
44

55
suite("Roo Code Subtasks", () => {
66
test("Should handle subtask cancellation and resumption correctly", async function () {
@@ -48,7 +48,7 @@ suite("Roo Code Subtasks", () => {
4848

4949
// Start a new task with the same message as the subtask.
5050
const anotherTaskId = await api.startNewTask(childPrompt)
51-
await waitForCompletion({ api, taskId: anotherTaskId })
51+
await waitUntilCompleted({ api, taskId: anotherTaskId })
5252

5353
// Wait a bit to ensure any task resumption would have happened.
5454
await sleep(2_000)
@@ -66,6 +66,6 @@ suite("Roo Code Subtasks", () => {
6666

6767
// Clean up - cancel all tasks.
6868
await api.clearCurrentTask()
69-
await waitForCompletion({ api, taskId: parentTaskId })
69+
await waitUntilCompleted({ api, taskId: parentTaskId })
7070
})
7171
})

e2e/src/suite/utils.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@ export const waitUntilAborted = async ({ api, taskId, ...options }: WaitUntilAbo
6161
await waitFor(() => set.has(taskId), options)
6262
}
6363

64-
export const waitForCompletion = async ({
65-
api,
66-
taskId,
67-
...options
68-
}: WaitUntilReadyOptions & {
64+
type WaitUntilCompletedOptions = WaitForOptions & {
65+
api: RooCodeAPI
6966
taskId: string
70-
}) => waitFor(() => !!getCompletion({ api, taskId }), options)
67+
}
68+
69+
export const waitUntilCompleted = async ({ api, taskId, ...options }: WaitUntilCompletedOptions) => {
70+
const set = new Set<string>()
71+
api.on("taskCompleted", (taskId) => set.add(taskId))
72+
await waitFor(() => set.has(taskId), options)
73+
}
7174

7275
export const getCompletion = ({ api, taskId }: { api: RooCodeAPI; taskId: string }) =>
7376
api.getMessages(taskId).find(({ say, partial }) => say === "completion_result" && partial === false)

0 commit comments

Comments
 (0)