Roo-Code/src/test/extension.test.ts
2025-01-31 15:18:20 -08:00

63 lines
1.5 KiB
TypeScript

import * as assert from "assert"
import * as vscode from "vscode"
suite("Roo Code Extension", () => {
test("OPENROUTER_API_KEY environment variable is set", () => {
if (!process.env.OPENROUTER_API_KEY) {
assert.fail("OPENROUTER_API_KEY environment variable is not set")
}
})
test("Commands should be registered", async () => {
const timeout = 10 * 1_000
const interval = 1_000
const startTime = Date.now()
const expectedCommands = [
"roo-cline.plusButtonClicked",
"roo-cline.mcpButtonClicked",
"roo-cline.historyButtonClicked",
"roo-cline.popoutButtonClicked",
"roo-cline.settingsButtonClicked",
"roo-cline.openInNewTab",
"roo-cline.explainCode",
"roo-cline.fixCode",
"roo-cline.improveCode",
]
while (Date.now() - startTime < timeout) {
const commands = await vscode.commands.getCommands(true)
const missingCommands = []
for (const cmd of expectedCommands) {
if (!commands.includes(cmd)) {
missingCommands.push(cmd)
}
}
if (missingCommands.length === 0) {
break
}
await new Promise((resolve) => setTimeout(resolve, interval))
}
const commands = await vscode.commands.getCommands(true)
for (const cmd of expectedCommands) {
assert.ok(commands.includes(cmd), `Command ${cmd} should be registered`)
}
})
test("Webview panel can be created", () => {
const view = vscode.window.createWebviewPanel(
"roo-cline.SidebarProvider",
"Roo Code",
vscode.ViewColumn.One,
{},
)
assert.ok(view, "Failed to create webview panel")
view.dispose()
})
})