Move integration tests into its own module

This commit is contained in:
Chris Estreich 2025-02-28 21:23:11 -08:00
parent 2773208d06
commit 1d3f5380a8
19 changed files with 2548 additions and 959 deletions

View file

@ -37,7 +37,7 @@ jobs:
cache: 'npm'
- name: Install Dependencies
run: npm run install:all
run: npm run install:ci
# Check if there are any new changesets to process
- name: Check for changesets

View file

@ -20,7 +20,7 @@ jobs:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm run install:all
run: npm run install:ci
- name: Compile
run: npm run compile
- name: Check types
@ -39,7 +39,7 @@ jobs:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm run install:all
run: npm run install:ci
- name: Run knip checks
run: npm run knip
@ -54,7 +54,7 @@ jobs:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm run install:all
run: npm run install:ci
- name: Run unit tests
run: npx jest --silent
@ -69,7 +69,7 @@ jobs:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm run install:all
run: npm run install:ci
- name: Run unit tests
working-directory: webview-ui
run: npx jest --silent
@ -108,9 +108,11 @@ jobs:
with:
node-version: '18'
cache: 'npm'
- name: Create env.integration file
run: echo "OPENROUTER_API_KEY=${{ secrets.OPENROUTER_API_KEY }}" > .env.integration
- name: Install dependencies
run: npm run install:all
run: npm run install:ci
- name: Create env.integration file
working-directory: e2e
run: echo "OPENROUTER_API_KEY=${{ secrets.OPENROUTER_API_KEY }}" > .env.integration
- name: Run integration tests
run: xvfb-run -a npm run test:integration
working-directory: e2e
run: xvfb-run -a npm run ci

View file

@ -4,6 +4,8 @@
.vscode/**
.vscode-test/**
out/**
out-integration/**
e2e/**
node_modules/**
src/**
.gitignore
@ -25,7 +27,6 @@ demo.gif
.roomodes
cline_docs/**
coverage/**
out-integration/**
# Ignore all webview-ui files except the build directory (https://github.com/microsoft/vscode-webview-ui-toolkit-samples/blob/main/frameworks/hello-world-react-cra/.vscodeignore)
webview-ui/src/**

View file

@ -6,7 +6,7 @@ import { defineConfig } from '@vscode/test-cli';
export default defineConfig({
label: 'integrationTest',
files: 'out-integration/test/**/*.test.js',
files: 'out/e2e/src/suite/**/*.test.js',
workspaceFolder: '.',
mocha: {
ui: 'tdd',

View file

@ -11,8 +11,8 @@ The integration tests use the `@vscode/test-electron` package to run tests in a
### Directory Structure
```
src/test/
├── runTest.ts # Main test runner
e2e/src/
├── runTest.ts # Main test runner
├── suite/
│ ├── index.ts # Test suite configuration
│ ├── modes.test.ts # Mode switching tests

2387
e2e/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

21
e2e/package.json Normal file
View file

@ -0,0 +1,21 @@
{
"name": "e2e",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "cd .. && npm run build",
"compile": "tsc -p tsconfig.json",
"lint": "eslint src --ext ts",
"check-types": "tsc --noEmit",
"test": "npm run compile && npx dotenvx run -f .env.integration -- node ./out/e2e/src/runTest.js",
"ci": "npm run build && npm run test"
},
"dependencies": {},
"devDependencies": {
"@types/mocha": "^10.0.10",
"@vscode/test-cli": "^0.0.9",
"@vscode/test-electron": "^2.4.0",
"mocha": "^11.1.0",
"typescript": "^5.4.5"
}
}

View file

@ -6,7 +6,7 @@ async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, "../../")
const extensionDevelopmentPath = path.resolve(__dirname, "../../../../")
// The path to the extension test script
// Passed to --extensionTestsPath

View file

@ -1,8 +1,7 @@
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 { ClineAPI, ClineProvider } from "../../../src/exports/cline"
import * as vscode from "vscode"
declare global {

View file

@ -9,9 +9,8 @@
"strict": true,
"skipLibCheck": true,
"useUnknownInCatchVariables": false,
"rootDir": "src",
"outDir": "out-integration"
"outDir": "out"
},
"include": ["**/*.ts"],
"exclude": [".vscode-test", "benchmark", "dist", "**/node_modules/**", "out", "out-integration", "webview-ui"]
"include": ["src", "../src/exports"],
"exclude": [".vscode-test", "**/node_modules/**", "out"]
}

View file

@ -16,7 +16,9 @@
"src/activate/**",
"src/exports/**",
"src/extension.ts",
".vscode-test.mjs"
"e2e/.vscode-test.mjs",
"e2e/src/runTest.ts",
"e2e/src/suite/index.ts"
],
"workspaces": {
"webview-ui": {

922
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -276,21 +276,24 @@
"scripts": {
"build": "npm run build:webview && npm run vsix",
"build:webview": "cd webview-ui && npm run build",
"changeset": "changeset",
"check-types": "tsc --noEmit && cd webview-ui && npm run check-types",
"compile": "tsc -p . --outDir out && node esbuild.js",
"compile:integration": "tsc -p tsconfig.integration.json",
"install:all": "npm install && cd webview-ui && npm install",
"knip": "knip --include files",
"lint": "eslint src --ext ts && npm run lint --prefix webview-ui",
"lint-local": "eslint -c .eslintrc.local.json src --ext ts && npm run lint --prefix webview-ui",
"lint-fix": "eslint src --ext ts --fix && npm run lint-fix --prefix webview-ui",
"lint-fix-local": "eslint -c .eslintrc.local.json src --ext ts --fix && npm run lint-fix --prefix webview-ui",
"install:all": "npm-run-all -p install-*",
"install:ci": "npm install npm-run-all && npm run install:all",
"install-extension": "npm install",
"install-webview-ui": "cd webview-ui && npm install",
"install-e2e": "cd e2e && npm install",
"lint": "npm-run-all -p lint:*",
"lint:extension": "eslint src --ext ts",
"lint:webview-ui": "cd webview-ui && npm run lint",
"lint:e2e": "cd e2e && npm run lint",
"check-types": "npm-run-all -p check-types:*",
"check-types:extension": "tsc --noEmit",
"check-types:webview-ui": "cd webview-ui && npm run check-types",
"check-types:e2e": "cd e2e && npm run check-types",
"package": "npm run build:webview && npm run check-types && npm run lint && node esbuild.js --production",
"pretest": "npm run compile && npm run compile:integration",
"pretest": "npm run compile",
"dev": "cd webview-ui && npm run dev",
"test": "jest && cd webview-ui && npm run test",
"test:integration": "npm run build && npm run compile:integration && npx dotenvx run -f .env.integration -- node ./out-integration/test/runTest.js",
"prepare": "husky",
"publish:marketplace": "vsce publish && ovsx publish",
"publish": "npm run build && changeset publish && npm install --package-lock-only",
@ -300,7 +303,9 @@
"watch": "npm-run-all -p watch:*",
"watch:esbuild": "node esbuild.js --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"watch-tests": "tsc -p . -w --outDir out"
"watch-tests": "tsc -p . -w --outDir out",
"changeset": "changeset",
"knip": "knip --include files"
},
"dependencies": {
"@anthropic-ai/bedrock-sdk": "^0.10.2",
@ -358,13 +363,10 @@
"@types/diff-match-patch": "^1.0.36",
"@types/glob": "^8.1.0",
"@types/jest": "^29.5.14",
"@types/mocha": "^10.0.10",
"@types/node": "20.x",
"@types/string-similarity": "^4.0.2",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.11.0",
"@vscode/test-cli": "^0.0.9",
"@vscode/test-electron": "^2.4.0",
"esbuild": "^0.24.0",
"eslint": "^8.57.0",
"glob": "^11.0.1",
@ -374,7 +376,6 @@
"knip": "^5.44.4",
"lint-staged": "^15.2.11",
"mkdirp": "^3.0.1",
"mocha": "^11.1.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.4.2",
"rimraf": "^6.0.1",

View file

@ -40,3 +40,96 @@ export interface ClineAPI {
*/
sidebarProvider: ClineSidebarProvider
}
export interface ClineProvider {
readonly context: vscode.ExtensionContext
readonly viewLaunched: boolean
readonly messages: ClineMessage[]
/**
* Resolves the webview view for the provider
* @param webviewView The webview view or panel to resolve
*/
resolveWebviewView(webviewView: vscode.WebviewView | vscode.WebviewPanel): Promise<void>
/**
* Initializes Cline with a task
*/
initClineWithTask(task?: string, images?: string[]): Promise<void>
/**
* Initializes Cline with a history item
*/
initClineWithHistoryItem(historyItem: HistoryItem): Promise<void>
/**
* Posts a message to the webview
*/
postMessageToWebview(message: ExtensionMessage): Promise<void>
/**
* Handles mode switching
*/
handleModeSwitch(newMode: Mode): Promise<void>
/**
* Updates custom instructions
*/
updateCustomInstructions(instructions?: string): Promise<void>
/**
* Cancels the current task
*/
cancelTask(): Promise<void>
/**
* Clears the current task
*/
clearTask(): Promise<void>
/**
* Gets the current state
*/
getState(): Promise<any>
/**
* Updates a value in the global state
* @param key The key to update
* @param value The value to set
*/
updateGlobalState(key: GlobalStateKey, value: any): Promise<void>
/**
* Gets a value from the global state
* @param key The key to get
*/
getGlobalState(key: GlobalStateKey): Promise<any>
/**
* Stores a secret value in secure storage
* @param key The key to store the secret under
* @param value The secret value to store, or undefined to remove the secret
*/
storeSecret(key: SecretKey, value?: string): Promise<void>
/**
* Retrieves a secret value from secure storage
* @param key The key of the secret to retrieve
*/
getSecret(key: SecretKey): Promise<string | undefined>
/**
* Resets the state
*/
resetState(): Promise<void>
/**
* Logs a message
*/
log(message: string): void
/**
* Disposes of the provider
*/
dispose(): Promise<void>
}

View file

@ -36,7 +36,11 @@ export type CustomModePrompts = {
// Helper to extract group name regardless of format
export function getGroupName(group: GroupEntry): ToolGroup {
return Array.isArray(group) ? group[0] : group
if (typeof group === "string") {
return group
}
return group[0]
}
// Helper to get group options if they exist