Roo-Code/e2e/VSCODE_INTEGRATION_TESTS.md
Chris Estreich 4f683b5e8e
Parallel tasks (#2128)
* Parallel tasks

* Handle null [x]ModelInfo types, recover from settings schema parse errors (#2064)

* Require exactly node v20.18.1 (#2065)

* Get rid of runner and all CJS stuff

* Add an activation command for other extensions (#2073)

Since VS Code provides no actionEvents that trigger when a specific
extension activates, extensions can't activate only once Roo is
activated and ready.

This commit introduces a new roo-cline.activationCompleted command
and fires it at the very end of extension activation. Other
extensions that use Roo's exported APIs can now activate when they
see this event.

Co-authored-by: Greg Taylor <gregtaylor@netflix.com>

* Update bug_report.yml (#1994)

* Update bug_report.yml

* Update bug_report.yml

---------

Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>

* Fix mention file name is not fully displayed (#2026)

Fixed path leading character handling to preserve language characters and remove specific punctuation marks

* In-Editor Browser Improvements (#1601)

* Browser Automation Improvements
* Added multi-tab remote Chrome support
* Added support for hover
* Properly caching remote browser host in global state
* Cleanup functions

* Updated for changes after merge

* Added www. exception for common tabs

* Update src/core/webview/ClineProvider.ts

* Revert README changes

---------

Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>

* Add missing awaits on refactored tools (#2078)

* More progress

* Added Gemini 2.5 Pro model to GCP Vertex AI Provider (#2079)

* More progress

* Display info about partial reads in chat row (#2080)

* More progress

* Update contributors list (#2023)

docs: update contributors list [skip ci]

Co-authored-by: mrubens <mrubens@users.noreply.github.com>

* More progress

* Handle multiple API pages worth of contributors (#2088)

* Update contributors list (#2089)

docs: update contributors list [skip ci]

Co-authored-by: mrubens <mrubens@users.noreply.github.com>

* Refactor/cline.ts/list files (#2067)

* "Refactor list_files tool to separate module (#2057)"

* Await

---------

Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>

* Remove switch from tools (#2091)

* HandleError returns a promise

* Remove unnecessary switch from tools

* Fix a type in the listFiles tool (#2092)

* Move write_to_file to a tool file (#2093)

* Move apply_diff to a tool file (#2094)

* Move insert_content to a tool file (#2095)

* Move search_and_replace to a tool file (#2096)

* Move list_code_definition_names to a tool file (#2097)

* Move search_files to a tool file (#2098)

* Move browser_action to a tool file (#2099)

* Move execute_command to a tool file (#2100)

* Move use_mcp_tool and access_mcp_resource to tool files (#2101)

* Move new_task, switch_mode, attempt_completion, and ask_followup_question to tool files (#2102)

* Do a little code cleanup now that tools are refactored out (#2103)

* Clean up the way we compute the current diff strategy (#2049)

* Clean up the way we compute the current diff strategy

* Add changeset

* i18n Add translations for task pinning and unpinning (#2109)

Signed-off-by: feifei <liuyansheng1121@gmail.com>

* Remove the ask promise error (#2107)

* Remove the ask promise error

* Send start_time along with checkpoints and use it to position in the messages

* Link to the settings page from the auto approve toolbar (#2111)

* Link to provider docs from the API options (#2112)

* Revert "Remove the ask promise error" (#2117)

Revert "Remove the ask promise error (#2107)"

This reverts commit 712ca71ee0.

* Parse the retry out of the gemini 429 response (#2118)

* Fix Gemini command escaping (#2120)

* Fix switching profiles to ensure only the selected profile is switche… (#2119)

Fix switching profiles to ensure only the selected profile is switched for all modes, and optimize certain i18n keys.

Signed-off-by: feifei <liuyansheng1121@gmail.com>

* Tweaks to support prompt line number format (#2121)

* Remove the ask promise error (#2123)

* Stronger typing

* Added Gemini 2.5 Pro model to GCP Vertex AI Provider (#2079)

* Display info about partial reads in chat row (#2080)

* Update contributors list (#2023)

docs: update contributors list [skip ci]

Co-authored-by: mrubens <mrubens@users.noreply.github.com>

* Handle multiple API pages worth of contributors (#2088)

* Update contributors list (#2089)

docs: update contributors list [skip ci]

Co-authored-by: mrubens <mrubens@users.noreply.github.com>

* Refactor/cline.ts/list files (#2067)

* "Refactor list_files tool to separate module (#2057)"

* Await

---------

Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>

* Remove switch from tools (#2091)

* HandleError returns a promise

* Remove unnecessary switch from tools

* Fix a type in the listFiles tool (#2092)

* Move write_to_file to a tool file (#2093)

* Move apply_diff to a tool file (#2094)

* Move insert_content to a tool file (#2095)

* Move search_and_replace to a tool file (#2096)

* Move list_code_definition_names to a tool file (#2097)

* Move search_files to a tool file (#2098)

* Move browser_action to a tool file (#2099)

* Move execute_command to a tool file (#2100)

* Move use_mcp_tool and access_mcp_resource to tool files (#2101)

* Move new_task, switch_mode, attempt_completion, and ask_followup_question to tool files (#2102)

* Do a little code cleanup now that tools are refactored out (#2103)

* Clean up the way we compute the current diff strategy (#2049)

* Clean up the way we compute the current diff strategy

* Add changeset

* i18n Add translations for task pinning and unpinning (#2109)

Signed-off-by: feifei <liuyansheng1121@gmail.com>

* Remove the ask promise error (#2107)

* Remove the ask promise error

* Send start_time along with checkpoints and use it to position in the messages

* Link to the settings page from the auto approve toolbar (#2111)

* Link to provider docs from the API options (#2112)

* Revert "Remove the ask promise error" (#2117)

Revert "Remove the ask promise error (#2107)"

This reverts commit 712ca71ee0.

* Parse the retry out of the gemini 429 response (#2118)

* Fix Gemini command escaping (#2120)

* Fix switching profiles to ensure only the selected profile is switche… (#2119)

Fix switching profiles to ensure only the selected profile is switched for all modes, and optimize certain i18n keys.

Signed-off-by: feifei <liuyansheng1121@gmail.com>

* Tweaks to support prompt line number format (#2121)

* Remove the ask promise error (#2123)

* Pass along pid and ppid

* Revert "Remove the ask promise error" (#2126)

Revert "Remove the ask promise error (#2123)"

This reverts commit b788aa1ec4.

---------

Signed-off-by: feifei <liuyansheng1121@gmail.com>
Co-authored-by: Greg Taylor <gtaylor@users.noreply.github.com>
Co-authored-by: Greg Taylor <gregtaylor@netflix.com>
Co-authored-by: Hannes Rudolph <hrudolph@gmail.com>
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
Co-authored-by: aheizi <aheizi@outlook.com>
Co-authored-by: Afshawn Lotfi <6283745+afshawnlotfi@users.noreply.github.com>
Co-authored-by: Nico Bihan <nicolas.bihan@wellsky.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Bhavesh Ramburn <nitrogen@gmail.com>
Co-authored-by: feifei <46489071+feifei325@users.noreply.github.com>
2025-03-30 15:09:26 -07:00

4 KiB

VSCode Integration Tests

This document describes the integration test setup for the Roo Code VSCode extension.

Overview

The integration tests use the @vscode/test-electron package to run tests in a real VSCode environment. These tests verify that the extension works correctly within VSCode, including features like mode switching, webview interactions, and API communication.

Test Setup

Directory Structure

e2e/src/
├── runTest.ts          # Main test runner
├── suite/
│   ├── index.ts        # Test suite configuration
│   ├── modes.test.ts   # Mode switching tests
│   ├── tasks.test.ts   # Task execution tests
│   └── extension.test.ts # Extension activation tests

Test Runner Configuration

The test runner (runTest.ts) is responsible for:

  • Setting up the extension development path
  • Configuring the test environment
  • Running the integration tests using @vscode/test-electron

Environment Setup

  1. Create a .env.local file in the root directory with required environment variables:
OPENROUTER_API_KEY=sk-or-v1-...
  1. The test suite (suite/index.ts) configures:
  • Mocha test framework with TDD interface
  • 10-minute timeout for LLM communication
  • Global extension API access
  • WebView panel setup
  • OpenRouter API configuration

Test Suite Structure

Tests are organized using Mocha's TDD interface (suite and test functions). The main test files are:

  • modes.test.ts: Tests mode switching functionality
  • tasks.test.ts: Tests task execution
  • extension.test.ts: Tests extension activation

Global Objects

The following global objects are available in tests:

declare global {
	var api: RooCodeAPI
	var provider: ClineProvider
	var extension: vscode.Extension<RooCodeAPI>
	var panel: vscode.WebviewPanel
}

Running Tests

  1. Ensure you have the required environment variables set in .env.local

  2. Run the integration tests:

npm run test:integration
  1. If you want to run a specific test, you can use the test.only function in the test file. This will run only the test you specify and ignore the others. Be sure to remove the test.only function before committing your changes.

The tests will:

  • Download and launch a clean VSCode instance
  • Install the extension
  • Execute the test suite
  • Report results

Writing New Tests

When writing new integration tests:

  1. Create a new test file in src/test/suite/ with the .test.ts extension

  2. Structure your tests using the TDD interface:

import * as assert from "assert"
import * as vscode from "vscode"

suite("Your Test Suite Name", () => {
	test("Should do something specific", async function () {
		// Your test code here
	})
})
  1. Use the global objects (api, provider, extension, panel) to interact with the extension

Best Practices

  1. Timeouts: Use appropriate timeouts for async operations:
const timeout = 30000
const interval = 1000
  1. State Management: Reset extension state before/after tests:
await globalThis.api.setConfiguration({
	mode: "Ask",
	alwaysAllowModeSwitch: true,
})
  1. Assertions: Use clear assertions with meaningful messages:
assert.ok(condition, "Descriptive message about what failed")
  1. Error Handling: Wrap test code in try/catch blocks and clean up resources:
try {
	// Test code
} finally {
	// Cleanup code
}
  1. Wait for Operations: Use polling when waiting for async operations:
let startTime = Date.now()

while (Date.now() - startTime < timeout) {
	if (condition) {
		break
	}

	await new Promise((resolve) => setTimeout(resolve, interval))
}
  1. Grading: When grading tests, use the Grade: format to ensure the test is graded correctly (See modes.test.ts for an example).
await globalThis.api.startNewTask({
	text: `Given this prompt: ${testPrompt} grade the response from 1 to 10 in the format of "Grade: (1-10)": ${output} \n Be sure to say 'I AM DONE GRADING' after the task is complete`,
})