extension.test.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import * as assert from "assert"
  2. import * as vscode from "vscode"
  3. suite("Roo Code Extension", () => {
  4. test("OPENROUTER_API_KEY environment variable is set", () => {
  5. if (!process.env.OPENROUTER_API_KEY) {
  6. assert.fail("OPENROUTER_API_KEY environment variable is not set")
  7. }
  8. })
  9. test("Commands should be registered", async () => {
  10. const timeout = 10 * 1_000
  11. const interval = 1_000
  12. const startTime = Date.now()
  13. const expectedCommands = [
  14. "roo-cline.plusButtonClicked",
  15. "roo-cline.mcpButtonClicked",
  16. "roo-cline.historyButtonClicked",
  17. "roo-cline.popoutButtonClicked",
  18. "roo-cline.settingsButtonClicked",
  19. "roo-cline.openInNewTab",
  20. "roo-cline.explainCode",
  21. "roo-cline.fixCode",
  22. "roo-cline.improveCode",
  23. ]
  24. while (Date.now() - startTime < timeout) {
  25. const commands = await vscode.commands.getCommands(true)
  26. const missingCommands = []
  27. for (const cmd of expectedCommands) {
  28. if (!commands.includes(cmd)) {
  29. missingCommands.push(cmd)
  30. }
  31. }
  32. if (missingCommands.length === 0) {
  33. break
  34. }
  35. await new Promise((resolve) => setTimeout(resolve, interval))
  36. }
  37. const commands = await vscode.commands.getCommands(true)
  38. for (const cmd of expectedCommands) {
  39. assert.ok(commands.includes(cmd), `Command ${cmd} should be registered`)
  40. }
  41. })
  42. test("Webview panel can be created", () => {
  43. const view = vscode.window.createWebviewPanel(
  44. "roo-cline.SidebarProvider",
  45. "Roo Code",
  46. vscode.ViewColumn.One,
  47. {},
  48. )
  49. assert.ok(view, "Failed to create webview panel")
  50. view.dispose()
  51. })
  52. })