Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions apps/vscode-e2e/fixtures/list-files.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"fixtures": [
{
"match": {
"userMessage": "LIST_FILES_NON_RECURSIVE_SMOKE"
},
"response": {
"toolCalls": [
{
"name": "list_files",
"arguments": "{\"path\":\"list-files-tool-fixture\",\"recursive\":false}",
"id": "call_list_files_non_recursive_001"
}
]
}
},
{
"match": {
"userMessage": "LIST_FILES_RECURSIVE_SMOKE"
},
"response": {
"toolCalls": [
{
"name": "list_files",
"arguments": "{\"path\":\"list-files-tool-fixture\",\"recursive\":true}",
"id": "call_list_files_recursive_001"
}
]
}
},
{
"match": {
"userMessage": "LIST_FILES_SYMLINK_SMOKE"
},
"response": {
"toolCalls": [
{
"name": "list_files",
"arguments": "{\"path\":\"list-files-symlink-fixture\",\"recursive\":false}",
"id": "call_list_files_symlink_001"
}
]
}
},
{
"match": {
"userMessage": "LIST_FILES_WORKSPACE_ROOT_SMOKE"
},
"response": {
"toolCalls": [
{
"name": "list_files",
"arguments": "{\"path\":\".\",\"recursive\":false}",
"id": "call_list_files_workspace_root_001"
}
]
}
}
]
}
116 changes: 116 additions & 0 deletions apps/vscode-e2e/fixtures/search-files.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"fixtures": [
{
"match": {
"userMessage": "SEARCH_FILES_FUNCTIONS_SMOKE"
},
"response": {
"toolCalls": [
{
"name": "search_files",
"arguments": "{\"path\":\"search-files-tool-fixture\",\"regex\":\"function\\\\s+\\\\w+\"}",
"id": "call_search_files_functions_001"
}
]
}
},
{
"match": {
"userMessage": "SEARCH_FILES_TODO_SMOKE"
},
"response": {
"toolCalls": [
{
"name": "search_files",
"arguments": "{\"path\":\"search-files-tool-fixture\",\"regex\":\"TODO.*\"}",
"id": "call_search_files_todo_001"
}
]
}
},
{
"match": {
"userMessage": "SEARCH_FILES_TYPESCRIPT_SMOKE"
},
"response": {
"toolCalls": [
{
"name": "search_files",
"arguments": "{\"path\":\"search-files-tool-fixture\",\"regex\":\"interface\\\\s+\\\\w+\",\"file_pattern\":\"*.ts\"}",
"id": "call_search_files_typescript_001"
}
]
}
},
{
"match": {
"userMessage": "SEARCH_FILES_JSON_SMOKE"
},
"response": {
"toolCalls": [
{
"name": "search_files",
"arguments": "{\"path\":\"search-files-tool-fixture\",\"regex\":\"\\\"\\\\w+\\\":\\\\s*\",\"file_pattern\":\"*.json\"}",
"id": "call_search_files_json_001"
}
]
}
},
{
"match": {
"userMessage": "SEARCH_FILES_NESTED_SMOKE"
},
"response": {
"toolCalls": [
{
"name": "search_files",
"arguments": "{\"path\":\"search-files-tool-fixture\",\"regex\":\"function\\\\s+(format|debounce)\"}",
"id": "call_search_files_nested_001"
}
]
}
},
{
"match": {
"userMessage": "SEARCH_FILES_COMPLEX_REGEX_SMOKE"
},
"response": {
"toolCalls": [
{
"name": "search_files",
"arguments": "{\"path\":\"search-files-tool-fixture\",\"regex\":\"(import|export).*\",\"file_pattern\":\"*.{js,ts}\"}",
"id": "call_search_files_complex_regex_001"
}
]
}
},
{
"match": {
"userMessage": "SEARCH_FILES_NO_MATCH_SMOKE"
},
"response": {
"toolCalls": [
{
"name": "search_files",
"arguments": "{\"path\":\"search-files-tool-fixture\",\"regex\":\"nonExistentPattern12345\"}",
"id": "call_search_files_no_match_001"
}
]
}
},
{
"match": {
"userMessage": "SEARCH_FILES_CLASS_METHOD_SMOKE"
},
"response": {
"toolCalls": [
{
"name": "search_files",
"arguments": "{\"path\":\"search-files-tool-fixture\",\"regex\":\"(class\\\\s+\\\\w+|async\\\\s+\\\\w+)\",\"file_pattern\":\"*.ts\"}",
"id": "call_search_files_class_method_001"
}
]
}
}
]
}
115 changes: 115 additions & 0 deletions apps/vscode-e2e/src/fixtures/use-mcp-tool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import { LLMock } from "@copilotkit/aimock"

const TEST_DIR_NAME = "use-mcp-tool-fixture"
const FILESYSTEM_SERVER_NAME = "filesystem"
const READ_FILE_RELATIVE_PATH = `${TEST_DIR_NAME}/mcp-read-target.txt`
const WRITE_FILE_RELATIVE_PATH = `${TEST_DIR_NAME}/mcp-write-target.txt`

type UseMcpToolFixture = {
userMessagePattern: string
toolCallId: string
toolName: string
toolArguments?: Record<string, unknown>
serverName?: string
result: string
id: string
}

export function addUseMcpToolResultFixtures(mock: InstanceType<typeof LLMock>) {
const fixtures: UseMcpToolFixture[] = [
{
userMessagePattern: "USE_MCP_TOOL_READ_FILE_SMOKE",
toolCallId: "call_use_mcp_tool_read_file_001",
toolName: "read_file",
toolArguments: { path: READ_FILE_RELATIVE_PATH },
result: "Read the requested file through the MCP filesystem server.",
id: "call_use_mcp_tool_read_file_002",
},
{
userMessagePattern: "USE_MCP_TOOL_WRITE_FILE_SMOKE",
toolCallId: "call_use_mcp_tool_write_file_001",
toolName: "write_file",
toolArguments: { path: WRITE_FILE_RELATIVE_PATH, content: "Hello from MCP!" },
result: "Created the requested file through the MCP filesystem server.",
id: "call_use_mcp_tool_write_file_002",
},
{
userMessagePattern: "USE_MCP_TOOL_LIST_DIRECTORY_SMOKE",
toolCallId: "call_use_mcp_tool_list_directory_001",
toolName: "list_directory",
toolArguments: { path: TEST_DIR_NAME },
result: "Listed the requested directory through the MCP filesystem server.",
id: "call_use_mcp_tool_list_directory_002",
},
{
userMessagePattern: "USE_MCP_TOOL_DIRECTORY_TREE_SMOKE",
toolCallId: "call_use_mcp_tool_directory_tree_001",
toolName: "directory_tree",
toolArguments: { path: TEST_DIR_NAME },
result: "Returned the directory tree through the MCP filesystem server.",
id: "call_use_mcp_tool_directory_tree_002",
},
{
userMessagePattern: "USE_MCP_TOOL_GET_FILE_INFO_SMOKE",
toolCallId: "call_use_mcp_tool_get_file_info_001",
toolName: "get_file_info",
toolArguments: { path: READ_FILE_RELATIVE_PATH },
result: "Returned the requested file metadata through the MCP filesystem server.",
id: "call_use_mcp_tool_get_file_info_002",
},
{
userMessagePattern: "USE_MCP_TOOL_UNKNOWN_SERVER_SMOKE",
toolCallId: "call_use_mcp_tool_unknown_server_001",
serverName: "nonexistent-server",
toolName: "read_file",
toolArguments: { path: READ_FILE_RELATIVE_PATH },
result: "MCP server 'nonexistent-server' is not configured. Available servers: filesystem",
id: "call_use_mcp_tool_unknown_server_002",
},
]

for (const fixture of fixtures) {
const serverName = fixture.serverName ?? FILESYSTEM_SERVER_NAME
const isConfiguredFilesystemTool = serverName === FILESYSTEM_SERVER_NAME

mock.addFixture({
match: {
userMessage: new RegExp(fixture.userMessagePattern),
},
response: {
toolCalls: [
{
name: isConfiguredFilesystemTool
? `mcp--${FILESYSTEM_SERVER_NAME}--${fixture.toolName}`
: "use_mcp_tool",
arguments: JSON.stringify(
isConfiguredFilesystemTool
? fixture.toolArguments
: {
server_name: serverName,
tool_name: fixture.toolName,
arguments: fixture.toolArguments,
},
),
id: fixture.toolCallId,
},
],
},
})

mock.addFixture({
match: {
toolCallId: fixture.toolCallId,
},
response: {
toolCalls: [
{
name: "attempt_completion",
arguments: JSON.stringify({ result: fixture.result }),
id: fixture.id,
},
],
},
})
}
}
9 changes: 6 additions & 3 deletions apps/vscode-e2e/src/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { addExecuteCommandResultFixtures } from "./fixtures/execute-command"
import { addListFilesResultFixtures } from "./fixtures/list-files"
import { addReadFileResultFixtures } from "./fixtures/read-file"
import { addSearchFilesResultFixtures } from "./fixtures/search-files"
import { addUseMcpToolResultFixtures } from "./fixtures/use-mcp-tool"
import { addWriteToFileResultFixtures } from "./fixtures/write-to-file"

function getCliFlagValue(flag: string) {
Expand Down Expand Up @@ -59,6 +60,10 @@ async function main() {
let testWorkspace: string | undefined

try {
// Create a temporary workspace folder for tests before installing fixtures that
// need workspace-specific paths.
testWorkspace = await fs.mkdtemp(path.join(os.tmpdir(), "roo-test-workspace-"))

if (useMock) {
const fixturesDir = path.resolve(__dirname, "../fixtures")

Expand Down Expand Up @@ -87,6 +92,7 @@ async function main() {
addListFilesResultFixtures(mock)
addReadFileResultFixtures(mock)
addSearchFilesResultFixtures(mock)
addUseMcpToolResultFixtures(mock)
addWriteToFileResultFixtures(mock)

// The modes test (switch_mode → ask) triggers a second API call whose last
Expand All @@ -110,9 +116,6 @@ async function main() {

await mock.start()
}

// Create a temporary workspace folder for tests
testWorkspace = await fs.mkdtemp(path.join(os.tmpdir(), "roo-test-workspace-"))
// Get test filter from command line arguments or environment variable
// Usage examples:
// - npm run test:e2e -- --grep "write-to-file"
Expand Down
Loading
Loading