Skip to content

Add integration tests for kilo-vscode extension#6551

Draft
markijbema wants to merge 14 commits intomainfrom
mark/integration-tests
Draft

Add integration tests for kilo-vscode extension#6551
markijbema wants to merge 14 commits intomainfrom
mark/integration-tests

Conversation

@markijbema
Copy link
Contributor

Summary

Implements the integration testing plan from the testing gaps document.

Changes

Level 1: Extension Activation Tests

File: packages/kilo-vscode/src/test/integration/activation.test.ts

Uses @vscode/test-electron + .vscode-test.mjs to run mocha tests inside a headless VS Code instance:

  • Extension activates successfully
  • Expected commands are registered
  • Sidebar view provider is available

Level 2: CLI Backend + SDK Integration Tests

File: packages/kilo-vscode/tests/integration/cli-backend.test.ts

Standalone bun tests that spawn kilo serve and use @kilocode/sdk:

  • Server health check responds
  • Can list sessions via SDK
  • Can create a session via SDK

Level 3: Full E2E with Mock LLM

File: packages/kilo-vscode/tests/integration/e2e-mock-llm.test.ts

End-to-end test with a mock OpenAI-compatible HTTP server:

  • Starts a mock LLM server with canned streaming completions
  • Configures kilo serve to use the mock provider via KILO_CONFIG_CONTENT
  • Verifies the complete message flow: SDK → CLI → provider → response

CI Workflow

File: .github/workflows/integration-test.yml

  • Triggers on workflow_dispatch (pre-release) and weekday nightly schedule (03:00 UTC)
  • Builds CLI binary, runs Level 1 with xvfb-run, runs Levels 2+3 with bun test
  • ~30 min timeout

Supporting Changes

  • Added packages/kilo-vscode/tsconfig.test.json for compiling Level 1 mocha tests
  • Updated compile-tests script to use the test tsconfig

Why This Approach

Consideration Decision
Webview DOM access Not possible from @vscode/test-electron — VS Code isolates webview content. Separate concern.
Mock LLM vs real API Mock is free, deterministic, doesn't require secrets.
Level 1 vs Levels 2+3 Level 1 needs VS Code APIs. Levels 2+3 are standalone bun tests — faster and more debuggable.
When to run Not on every PR (too slow). Runs on workflow_dispatch + weekday nightly schedule.

- Phase 0 (CI trigger fix) and Phase 1.2/1.3/1.4 (contract tests) are
  already done — mark as completed with details
- Add 'What's Already Been Done' section documenting kilo-ui-contract.test.ts
  runtime checks and test-vscode.yml paths fix
- Fix e2e test status: disabled (if: false), not running on every PR
- Update stats: 48 stories (not 50), 48 unit tests (not 45+), ~89
  re-exports (not 50+), 33 CSS overrides, Storybook 10 (not 8+)
- Fix all line number references to match current source
- Fix data.tsx references (52 lines total, not 67+)
- Update priority table with completion status
- Restructure plan to only show remaining work
Three-level approach:
- Level 1: Extension activation via @vscode/test-electron + xvfb-run
- Level 2: CLI backend + SDK (spawn kilo serve, connect with SDK)
- Level 3: Full E2E with mock OpenAI-compatible HTTP server

Uses KILO_CONFIG_CONTENT to inject a custom provider pointing to a
local Bun.serve mock that returns canned streaming completions.

Runs on workflow_dispatch (pre-release) + weekday nightly schedule,
~30 min budget.
Level 1: Extension activation tests using @vscode/test-electron
  - Verifies extension activates successfully
  - Checks expected commands are registered
  - Validates sidebar view provider registration

Level 2: CLI backend + SDK integration tests
  - Spawns kilo serve and communicates via @kilocode/sdk
  - Tests health check, session list, session create

Level 3: Full E2E with mock LLM
  - Mock OpenAI-compatible HTTP server with canned completions
  - Tests complete message flow: SDK → CLI → provider → response
  - Verifies streamed responses arrive in session messages

CI workflow: .github/workflows/integration-test.yml
  - Runs on workflow_dispatch + weekday nightly schedule
  - Builds CLI, runs activation tests with xvfb, runs bun integration tests
- CLI path: use packages/kilo-vscode/bin/kilo (copied by prepare:cli-binary)
  instead of incorrect relative path to packages/opencode/dist/kilo
- Support KILO_CLI_PATH env var override for local testing
- Fix .vscode-test.mjs glob: out/src/test/** (matches tsconfig.test.json output)
The pretest script redundantly recompiles everything (SDK, types, lint,
esbuild) when running 'bun run test'. Instead, compile the extension
once upfront with 'bun run compile', then run 'vscode-test' directly.
npx can't find vscode-test in a bun workspace. Use the bin path directly.
- Add 60s mocha suite timeout for activation tests
- Replace sidebar focus test with safer command-check approach
- Add 5min step timeout for Level 1
- Add continue-on-error so Levels 2+3 always run
The kilo serve server expects Basic auth with username 'kilo' and
the password, matching how KiloConnectionService creates the client.
The bun default 5s timeout was too short for the full E2E flow.
Added stderr logging and extended polling to 30s.
The extension host becomes 'unresponsive' during activation because
of heavy module loading (WASM, tiktoken, tree-sitter). VS Code then
freezes the host and tests never run.

Fix: pass --extensions-unresponsive-timeout 300000 to VS Code via
.vscode-test.mjs launchArgs. Also set mocha timeout to 120s and
disable GPU + workspace trust for cleaner CI.
Fix Level 3: pass explicit model to session.prompt()

Level 1: --extensions-unresponsive-timeout is not a valid VS Code flag.
Use --disable-extensions instead to skip loading all built-in extensions
(the dev extension under test is still loaded). This should prevent the
extension host from becoming unresponsive during activation.

Level 3: session.prompt() returned 200 but never produced an assistant
message. Add explicit model: { providerID: 'mock', modelID: 'mock-model' }
so the CLI knows which provider to route to.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant