-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Modify Full Integration Test Structure to allow for multiple tests th… #926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+692
−228
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4585281
Modify Full Integration Test Structure to allow for multiple tests th…
ColemanRoo a9c4306
Delete .env.e2e
ColemanRoo 481d54b
package.json update for integration test command in CI/CD
ColemanRoo 20dea5c
increase test timeout
ColemanRoo 4170479
adding comment on long timeout
ColemanRoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import * as path from "path" | ||
|
|
||
| import { runTests } from "@vscode/test-electron" | ||
|
|
||
| async function main() { | ||
| try { | ||
| // The folder containing the Extension Manifest package.json | ||
| // Passed to `--extensionDevelopmentPath` | ||
| const extensionDevelopmentPath = path.resolve(__dirname, "../../") | ||
|
|
||
| // The path to the extension test script | ||
| // Passed to --extensionTestsPath | ||
| const extensionTestsPath = path.resolve(__dirname, "./suite/index") | ||
|
|
||
| // Download VS Code, unzip it and run the integration test | ||
| await runTests({ extensionDevelopmentPath, extensionTestsPath }) | ||
| } catch { | ||
| console.error("Failed to run tests") | ||
| process.exit(1) | ||
| } | ||
| } | ||
|
|
||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| import * as path from "path" | ||
| import Mocha from "mocha" | ||
| import { glob } from "glob" | ||
| import { ClineAPI } from "../../exports/cline" | ||
| import { ClineProvider } from "../../core/webview/ClineProvider" | ||
| import * as vscode from "vscode" | ||
|
|
||
| declare global { | ||
| var api: ClineAPI | ||
| var provider: ClineProvider | ||
| var extension: vscode.Extension<ClineAPI> | undefined | ||
| var panel: vscode.WebviewPanel | undefined | ||
| } | ||
|
|
||
| export async function run(): Promise<void> { | ||
| // Create the mocha test | ||
| const mocha = new Mocha({ | ||
| ui: "tdd", | ||
| timeout: 600000, | ||
| }) | ||
|
|
||
| const testsRoot = path.resolve(__dirname, "..") | ||
|
|
||
| try { | ||
| // Find all test files | ||
| const files = await glob("**/**.test.js", { cwd: testsRoot }) | ||
|
|
||
| // Add files to the test suite | ||
| files.forEach((f: string) => mocha.addFile(path.resolve(testsRoot, f))) | ||
|
|
||
| //Set up global extension, api, provider, and panel | ||
| globalThis.extension = vscode.extensions.getExtension("RooVeterinaryInc.roo-cline") | ||
| if (!globalThis.extension) { | ||
| throw new Error("Extension not found") | ||
| } | ||
|
|
||
| globalThis.api = globalThis.extension.isActive | ||
| ? globalThis.extension.exports | ||
| : await globalThis.extension.activate() | ||
| globalThis.provider = globalThis.api.sidebarProvider | ||
| await globalThis.provider.updateGlobalState("apiProvider", "openrouter") | ||
| await globalThis.provider.updateGlobalState("openRouterModelId", "anthropic/claude-3.5-sonnet") | ||
| await globalThis.provider.storeSecret( | ||
| "openRouterApiKey", | ||
| process.env.OPENROUTER_API_KEY || "sk-or-v1-fake-api-key", | ||
| ) | ||
|
|
||
| globalThis.panel = vscode.window.createWebviewPanel( | ||
| "roo-cline.SidebarProvider", | ||
| "Roo Code", | ||
| vscode.ViewColumn.One, | ||
| { | ||
| enableScripts: true, | ||
| enableCommandUris: true, | ||
| retainContextWhenHidden: true, | ||
| localResourceRoots: [globalThis.extension?.extensionUri], | ||
| }, | ||
| ) | ||
|
|
||
| await globalThis.provider.resolveWebviewView(globalThis.panel) | ||
|
|
||
| let startTime = Date.now() | ||
| const timeout = 60000 | ||
| const interval = 1000 | ||
|
|
||
| while (Date.now() - startTime < timeout) { | ||
| if (globalThis.provider.viewLaunched) { | ||
| break | ||
| } | ||
|
|
||
| await new Promise((resolve) => setTimeout(resolve, interval)) | ||
| } | ||
|
|
||
| // Run the mocha test | ||
| return new Promise((resolve, reject) => { | ||
| try { | ||
| mocha.run((failures: number) => { | ||
| if (failures > 0) { | ||
| reject(new Error(`${failures} tests failed.`)) | ||
| } else { | ||
| resolve() | ||
| } | ||
| }) | ||
| } catch (err) { | ||
| console.error(err) | ||
| reject(err) | ||
| } | ||
| }) | ||
| } catch (err) { | ||
| console.error("Error while running tests:") | ||
| console.error(err) | ||
| throw err | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import * as assert from "assert" | ||
| import * as vscode from "vscode" | ||
|
|
||
| suite("Roo Code Modes", () => { | ||
| test("Should handle switching modes correctly", async function () { | ||
| const timeout = 30000 | ||
| const interval = 1000 | ||
|
|
||
| if (!globalThis.extension) { | ||
| assert.fail("Extension not found") | ||
| } | ||
|
|
||
| try { | ||
| let startTime = Date.now() | ||
|
|
||
| // Ensure the webview is launched. | ||
| while (Date.now() - startTime < timeout) { | ||
| if (globalThis.provider.viewLaunched) { | ||
| break | ||
| } | ||
|
|
||
| await new Promise((resolve) => setTimeout(resolve, interval)) | ||
| } | ||
|
|
||
| await globalThis.provider.updateGlobalState("mode", "Ask") | ||
| await globalThis.provider.updateGlobalState("alwaysAllowModeSwitch", true) | ||
| await globalThis.provider.updateGlobalState("autoApprovalEnabled", true) | ||
|
|
||
| // Start a new task. | ||
| await globalThis.api.startNewTask( | ||
| "For each mode (Code, Architect, Ask) respond with the mode name and what it specializes in after switching to that mode, do not start with the current mode, be sure to say 'I AM DONE' after the task is complete", | ||
| ) | ||
|
|
||
| // Wait for task to appear in history with tokens. | ||
| startTime = Date.now() | ||
|
|
||
| while (Date.now() - startTime < timeout) { | ||
| const messages = globalThis.provider.messages | ||
|
|
||
| if ( | ||
| messages.some( | ||
| ({ type, text }) => | ||
| type === "say" && text?.includes("I AM DONE") && !text?.includes("be sure to say"), | ||
| ) | ||
| ) { | ||
| break | ||
| } | ||
|
|
||
| await new Promise((resolve) => setTimeout(resolve, interval)) | ||
| } | ||
| if (globalThis.provider.messages.length === 0) { | ||
| assert.fail("No messages received") | ||
| } | ||
|
|
||
| assert.ok( | ||
| globalThis.provider.messages.some( | ||
| ({ type, text }) => type === "say" && text?.includes(`"request":"[switch_mode to 'code' because:`), | ||
| ), | ||
| "Did not receive expected response containing 'Roo wants to switch to code mode'", | ||
| ) | ||
| assert.ok( | ||
| globalThis.provider.messages.some( | ||
| ({ type, text }) => type === "say" && text?.includes("software engineer"), | ||
| ), | ||
| "Did not receive expected response containing 'I am Roo in Code mode, specializing in software engineering'", | ||
| ) | ||
|
|
||
| assert.ok( | ||
| globalThis.provider.messages.some( | ||
| ({ type, text }) => | ||
| type === "say" && text?.includes(`"request":"[switch_mode to 'architect' because:`), | ||
| ), | ||
| "Did not receive expected response containing 'Roo wants to switch to architect mode'", | ||
| ) | ||
| assert.ok( | ||
| globalThis.provider.messages.some( | ||
| ({ type, text }) => | ||
| type === "say" && (text?.includes("technical planning") || text?.includes("technical leader")), | ||
| ), | ||
| "Did not receive expected response containing 'I am Roo in Architect mode, specializing in analyzing codebases'", | ||
| ) | ||
|
|
||
| assert.ok( | ||
| globalThis.provider.messages.some( | ||
| ({ type, text }) => type === "say" && text?.includes(`"request":"[switch_mode to 'ask' because:`), | ||
| ), | ||
| "Did not receive expected response containing 'Roo wants to switch to ask mode'", | ||
| ) | ||
| assert.ok( | ||
| globalThis.provider.messages.some( | ||
| ({ type, text }) => | ||
| type === "say" && (text?.includes("technical knowledge") || text?.includes("technical assist")), | ||
| ), | ||
| "Did not receive expected response containing 'I am Roo in Ask mode, specializing in answering questions'", | ||
| ) | ||
| } finally { | ||
| } | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import * as assert from "assert" | ||
| import * as vscode from "vscode" | ||
|
|
||
| suite("Roo Code Task", () => { | ||
| test("Should handle prompt and response correctly", async function () { | ||
| const timeout = 30000 | ||
| const interval = 1000 | ||
|
|
||
| if (!globalThis.extension) { | ||
| assert.fail("Extension not found") | ||
| } | ||
|
|
||
| try { | ||
| // Ensure the webview is launched. | ||
| let startTime = Date.now() | ||
|
|
||
| while (Date.now() - startTime < timeout) { | ||
| if (globalThis.provider.viewLaunched) { | ||
| break | ||
| } | ||
|
|
||
| await new Promise((resolve) => setTimeout(resolve, interval)) | ||
| } | ||
|
|
||
| await globalThis.api.startNewTask("Hello world, what is your name? Respond with 'My name is ...'") | ||
|
|
||
| // Wait for task to appear in history with tokens. | ||
| startTime = Date.now() | ||
|
|
||
| while (Date.now() - startTime < timeout) { | ||
| const state = await globalThis.provider.getState() | ||
| const task = state.taskHistory?.[0] | ||
|
|
||
| if (task && task.tokensOut > 0) { | ||
| break | ||
| } | ||
|
|
||
| await new Promise((resolve) => setTimeout(resolve, interval)) | ||
| } | ||
|
|
||
| if (globalThis.provider.messages.length === 0) { | ||
| assert.fail("No messages received") | ||
| } | ||
|
|
||
| assert.ok( | ||
| globalThis.provider.messages.some( | ||
| ({ type, text }) => type === "say" && text?.includes("My name is Roo"), | ||
| ), | ||
| "Did not receive expected response containing 'My name is Roo'", | ||
| ) | ||
| } finally { | ||
| } | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timeout increased to 600000 (10 min). Consider adding a comment explaining why such a long timeout is needed, to aid future maintainers.