Skip to content

test(vscode): actually run the autocomplete tests in CI#9555

Open
kilo-code-bot[bot] wants to merge 12 commits intomainfrom
fix/run-autocomplete-unit-specs
Open

test(vscode): actually run the autocomplete tests in CI#9555
kilo-code-bot[bot] wants to merge 12 commits intomainfrom
fix/run-autocomplete-unit-specs

Conversation

@kilo-code-bot
Copy link
Copy Markdown
Contributor

@kilo-code-bot kilo-code-bot Bot commented Apr 27, 2026

Stacks on top of #9310. The autocomplete model/settings tests added there live under src/**/__tests__/*.spec.ts, but bun run test:unit only globs tests/unit/, so CI never executed them. Move both specs to tests/unit/ and switch vitest APIs to bun:test so every PR actually exercises the new validation and FIM-streaming behavior.

kilo-code-bot Bot added 2 commits April 27, 2026 10:04
The file sat under src/**/__tests__/ and was not covered by
`bun test tests/unit/`, so none of the AutocompleteModel tests were
running in CI. Port to bun:test and move next to the rest of the unit
suite.
Same story as the AutocompleteModel port: the spec under src/__tests__/
was not picked up by `bun test tests/unit/`. Move to tests/unit/ and
swap vi.mock for mock.module so the suite exercises the new validation
rules on every PR.
Base automatically changed from mark/mercury-autocomplete-integration to main April 27, 2026 10:18
kilo-code-bot Bot added 9 commits April 27, 2026 11:51
Move the spec from src/agent-manager/__tests__/ to tests/unit/ so
`bun run test:unit` picks it up. Mechanical port — only swap the
vitest import for bun:test and re-anchor the source import.
Move the spec from src/__tests__/ to tests/unit/ so
`bun run test:unit` picks it up.
Move the spec from src/__tests__/ to tests/unit/ so
`bun run test:unit` picks it up.
Move the spec from src/__tests__/ to tests/unit/ so `bun run test:unit`
picks it up. The original vitest mock omitted `workspace.asRelativePath`
which the tracker calls on every editor; add it so the happy-path test
actually exercises the relative-path fallback.
Rewrite the spec for bun:test: drive a hand-rolled vscode stub via
mock.module (the shared preload omits ProgressLocation) and grab the
command callback from the registerCommand spy instead of relying on
vitest's hoisted vi.mock transform. Behavior coverage is preserved —
all 12 original scenarios still run.
Port the spec from src/__tests__/ to tests/unit/ using bun:test. Since
mock.module isn't hoisted like vitest's vi.mock, the mocks are declared
before the dynamic import of AgentManagerProvider. Had to flesh out the
git-import, WorktreeStateManager, and format-keybinding stubs with the
named exports the provider actually imports — the original mocks only
covered a subset and relied on vitest leaving missing exports undefined.
Rewrite for bun:test. The original spec wired in a `__setState` /
`__resetState` harness around a `core/config/ContextProxy` module that
no longer exists in the tree — those mocks were vestigial since
`AutocompleteServiceManager` reads settings from vscode.workspace
directly. Drop the dead setup and keep the codeSuggestion, snooze, and
inline-provider registration assertions.
The helper imports `../../mocking/MockTextDocument`, which was deleted
long ago — the spec has been un-runnable in any runner since. The only
consumer of MockWorkspace / MockWorkspaceEdit was this spec, so remove
the whole shim along with it.
When several freshly-ported suites called `mock.module("vscode", ...)`
at file scope, the last registered factory won globally — so running
e.g. autocomplete-visible-code-tracker before autocomplete-settings
erased `ConfigurationTarget`, and mocking agent-manager collaborators
clobbered setup-script-service's own import.

Fix:
- Expand the shared preload (tests/setup/vscode-mock.ts) with the bits
  our suites need (`languages`, `ProgressLocation`,
  `InlineCompletionTriggerKind`, `showErrorMessage`, `withProgress`,
  `CancellationTokenSource`) so no one needs to replace the module.
- Swap the per-file `mock.module("vscode", ...)` overrides for
  `spyOn` + direct property assignment on the preload shape.
- Drop the agent-manager dependency mocks — the provider is stubbed out
  via `Object.create`, so real module imports don't run constructors
  and the mocks only existed to pre-empt deps that load fine.

All 119 tests in the ported files now pass in any order, and
`bun run test:unit` stays green at 2090 / 2090.
@kilo-code-bot
Copy link
Copy Markdown
Contributor Author

kilo-code-bot Bot commented Apr 27, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/tests/unit/autocomplete-service-manager.test.ts 11 Replacing vscode.window.activeTextEditor with a getter-only property leaks into sibling tests and makes the suite order-dependent.
packages/kilo-vscode/tests/unit/autocomplete-service-manager.test.ts 14 Process-global mock.module() overrides can leak into later files and cause tests to exercise mocks instead of the real implementation.
Other Observations (not in diff)

No file content changed since commit da1901059e69ddc6a21b843341ddc9ab05029e18, so this incremental pass carries forward the two previously reported warnings unchanged.

Files Reviewed (0 files)
  • No file content changes in the incremental diff

Reviewed by gpt-5.4-2026-03-05 · 645,461 tokens

).mockImplementation(() => ({ dispose: mock() }))

let activeTextEditor: unknown = null
Object.defineProperty(vscode.window, "activeTextEditor", {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Getter-only activeTextEditor leaks into sibling tests

Object.defineProperty replaces the shared preload's writable vscode.window.activeTextEditor field with an accessor that has no setter and is never restored. Files like packages/kilo-vscode/tests/unit/autocomplete-visible-code-tracker.test.ts assign to that property directly; if this spec runs first, those assignments start throwing TypeError, so the suite becomes order-dependent.

get: () => activeTextEditor,
})

mock.module("../../src/services/autocomplete/AutocompleteModel", () => ({
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: These module mocks are process-global under Bun

mock.module() here shadows the real module for later test files in the same run. That makes specs such as packages/kilo-vscode/tests/unit/autocomplete-model.test.ts order-dependent, because they can end up importing this stubbed AutocompleteModel instead of the production implementation they are meant to verify.

`Object.defineProperty(..., { get })` turned activeTextEditor into a
read-only property, so when another ported file (sorted earlier alpha,
e.g. autocomplete-visible-code-tracker) later tried to assign to it
under the shared preload, Bun threw "Attempted to assign to readonly
property" on CI.

Swap it for a plain setter helper that writes through the preload's
existing writable slot — keeps the tests working regardless of file
load order.
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.

0 participants