Skip to content

Commit 0f30e86

Browse files
committed
test(e2e): address review feedback on readonly tool fixtures
1 parent 55cb374 commit 0f30e86

6 files changed

Lines changed: 25 additions & 68 deletions

File tree

apps/vscode-e2e/fixtures/list-files.json

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { ChatCompletionRequest, ChatMessage } from "@copilotkit/aimock"
2+
3+
export function toolResultContains(req: ChatCompletionRequest, toolCallId: string, expected: string[]) {
4+
const messages = Array.isArray(req?.messages) ? req.messages : []
5+
const toolMessage = messages.find(
6+
(message: ChatMessage) => message?.role === "tool" && message.tool_call_id === toolCallId,
7+
)
8+
9+
const content = toolMessage?.content
10+
if (typeof content !== "string") {
11+
return false
12+
}
13+
14+
return expected.every((text) => content.includes(text))
15+
}

apps/vscode-e2e/src/fixtures/list-files.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { LLMock } from "@copilotkit/aimock"
2-
import type { ChatCompletionRequest, ChatMessage } from "@copilotkit/aimock"
2+
3+
import { toolResultContains } from "./fixture-utils"
34

45
type ListFilesFixture = {
56
userMessagePattern: string
@@ -11,20 +12,6 @@ type ListFilesFixture = {
1112
id: string
1213
}
1314

14-
function toolResultContains(req: ChatCompletionRequest, toolCallId: string, expected: string[]) {
15-
const messages = Array.isArray(req?.messages) ? req.messages : []
16-
const toolMessage = messages.find(
17-
(message: ChatMessage) => message?.role === "tool" && message.tool_call_id === toolCallId,
18-
)
19-
20-
const content = toolMessage?.content
21-
if (typeof content !== "string") {
22-
return false
23-
}
24-
25-
return expected.every((text) => content.includes(text))
26-
}
27-
2815
export function addListFilesResultFixtures(mock: InstanceType<typeof LLMock>) {
2916
const fixtures: ListFilesFixture[] = [
3017
{
@@ -46,7 +33,7 @@ export function addListFilesResultFixtures(mock: InstanceType<typeof LLMock>) {
4633
id: "call_list_files_recursive_002",
4734
},
4835
{
49-
userMessagePattern: "list-files-symlink-fixture.*recursive=false",
36+
userMessagePattern: "path='list-files-symlink-fixture'",
5037
toolName: "list_files",
5138
arguments: '{"path":"list-files-symlink-fixture","recursive":false}',
5239
toolCallId: "call_list_files_symlink_001",

apps/vscode-e2e/src/fixtures/search-files.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { LLMock } from "@copilotkit/aimock"
2-
import type { ChatCompletionRequest, ChatMessage } from "@copilotkit/aimock"
2+
3+
import { toolResultContains } from "./fixture-utils"
34

45
type SearchFilesFixture = {
56
userMessagePattern: string
@@ -11,20 +12,6 @@ type SearchFilesFixture = {
1112
id: string
1213
}
1314

14-
function toolResultContains(req: ChatCompletionRequest, toolCallId: string, expected: string[]) {
15-
const messages = Array.isArray(req?.messages) ? req.messages : []
16-
const toolMessage = messages.find(
17-
(message: ChatMessage) => message?.role === "tool" && message.tool_call_id === toolCallId,
18-
)
19-
20-
const content = toolMessage?.content
21-
if (typeof content !== "string") {
22-
return false
23-
}
24-
25-
return expected.every((text) => content.includes(text))
26-
}
27-
2815
export function addSearchFilesResultFixtures(mock: InstanceType<typeof LLMock>) {
2916
const fixtures: SearchFilesFixture[] = [
3017
{
@@ -102,7 +89,7 @@ export function addSearchFilesResultFixtures(mock: InstanceType<typeof LLMock>)
10289
toolName: "search_files",
10390
arguments: '{"path":"search-files-tool-fixture","regex":"nonExistentPattern12345"}',
10491
toolCallId: "call_search_files_no_match_001",
105-
expected: ["Found 0 results."],
92+
expected: ["No results found"],
10693
result: "No matches were found for `nonExistentPattern12345` in the search fixture directory.",
10794
id: "call_search_files_no_match_002",
10895
},

apps/vscode-e2e/src/suite/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Mocha from "mocha"
33
import { glob } from "glob"
44
import * as vscode from "vscode"
55

6-
import type { RooCodeAPI, RooCodeEventName } from "@roo-code/types"
6+
import { RooCodeEventName, type RooCodeAPI } from "@roo-code/types"
77

88
import { waitFor } from "./utils"
99

@@ -33,14 +33,14 @@ export async function run() {
3333

3434
// Automatically approve completion_result asks so tests don't stall waiting
3535
// for a button that the webview routes to "start new task" rather than "yes".
36-
api.on("message" as RooCodeEventName.Message, ({ message }) => {
36+
api.on(RooCodeEventName.Message, ({ message }) => {
3737
if (message.type === "ask" && message.ask === "completion_result") {
3838
api.approveCurrentAsk()
3939
}
4040
})
4141

4242
if (!aimockUrl) {
43-
api.on("message" as RooCodeEventName.Message, ({ message }) => {
43+
api.on(RooCodeEventName.Message, ({ message }) => {
4444
if (message.type === "say" && !message.partial) {
4545
console.log(`[say:${message.say}]`, message.text?.slice(0, 300))
4646
}

apps/vscode-e2e/src/suite/tools/list-files.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ This directory contains various files and subdirectories for testing the list_fi
347347

348348
console.log("Symlink test Task ID:", taskId)
349349

350-
// Wait for task completion
350+
// 120s: real models may loop before finding the symlink fixture path.
351351
await waitFor(() => taskCompleted, { timeout: 120_000 })
352352

353353
const completionMessage = messages.find((m) => {

0 commit comments

Comments
 (0)