fix: fix test

This commit is contained in:
Catriel Müller
2026-06-11 14:59:37 -03:00
parent 4e0c7248a9
commit 71cc624f59
2 changed files with 16 additions and 37 deletions
@@ -6,8 +6,6 @@ import { Server } from "../../../src/server/server"
import { Config } from "../../../src/config/config"
import { KilocodeConfigOverlay } from "../../../src/kilocode/config/overlay"
import { Permission } from "../../../src/permission"
import { AppRuntime } from "../../../src/effect/app-runtime"
import { Effect } from "effect"
import { resetDatabase } from "../../fixture/db"
import { disposeAllInstances, tmpdir } from "../../fixture/fixture"
@@ -27,7 +25,6 @@ type Agent = {
afterEach(async () => {
;(Global.Path as { config: string }).config = original
await AppRuntime.runPromise(Config.Service.use((svc) => svc.invalidate()))
await disposeAllInstances()
await resetDatabase()
})
@@ -65,12 +62,13 @@ async function config(dir: string, value: unknown) {
await Bun.write(path.join(dir, "kilo.json"), JSON.stringify(value, null, 2))
}
async function invalidate() {
await AppRuntime.runPromise(
Effect.gen(function* () {
const svc = yield* Config.Service
yield* svc.invalidate()
yield* svc.getGlobal()
async function setGlobal(dir: string, value: Config.Info) {
;(Global.Path as { config: string }).config = dir
await json(
await request(Server.Default().app, undefined, "/config/overlay", {
method: "PATCH",
headers: { "content-type": "application/json" },
body: JSON.stringify({ scope: "global", set: value }),
}),
)
}
@@ -94,13 +92,11 @@ describe("config overlay routes", () => {
test.serial("marks global values inherited in project scope", async () => {
await using global = await tmpdir()
await using project = await tmpdir()
;(Global.Path as { config: string }).config = global.path
await config(global.path, {
await setGlobal(global.path, {
model: "kilo/global-model",
permission: { bash: "ask" },
mcp: { shared: { type: "local", command: ["node", "shared.js"], enabled: true } },
})
await invalidate()
const body = await json<Overlay>(await req(project.path, "/config/overlay?scope=project"))
@@ -118,15 +114,13 @@ describe("config overlay routes", () => {
test.serial("marks global indexing values inherited in project scope", async () => {
await using global = await tmpdir()
await using project = await tmpdir()
;(Global.Path as { config: string }).config = global.path
await config(global.path, {
await setGlobal(global.path, {
indexing: {
enabled: true,
provider: "ollama",
ollama: { baseUrl: "http://localhost:11434" },
},
})
await invalidate()
const body = await json<Overlay>(await req(project.path, "/config/overlay?scope=project"))
@@ -175,9 +169,7 @@ describe("config overlay routes", () => {
test.serial("writes project indexing overrides to .kilo/kilo.jsonc", async () => {
await using global = await tmpdir()
await using project = await tmpdir()
;(Global.Path as { config: string }).config = global.path
await config(global.path, { indexing: { enabled: true, provider: "openai" } })
await invalidate()
await setGlobal(global.path, { indexing: { enabled: true, provider: "openai" } })
await json(
await req(project.path, "/config/overlay", {
@@ -207,9 +199,7 @@ describe("config overlay routes", () => {
test.serial("removes local scalar override and falls back to global", async () => {
await using global = await tmpdir()
await using project = await tmpdir({ config: { model: "kilo/project-model", username: "alice" } })
;(Global.Path as { config: string }).config = global.path
await config(global.path, { model: "kilo/global-model" })
await invalidate()
await setGlobal(global.path, { model: "kilo/global-model" })
await json(
await req(project.path, "/config/overlay", {
@@ -229,11 +219,9 @@ describe("config overlay routes", () => {
test.serial("writes project mcp overrides without copying inherited servers", async () => {
await using global = await tmpdir()
await using project = await tmpdir()
;(Global.Path as { config: string }).config = global.path
await config(global.path, {
await setGlobal(global.path, {
mcp: { shared: { type: "local", command: ["node", "shared.js"], enabled: true } },
})
await invalidate()
await json(
await req(project.path, "/config/overlay", {
@@ -255,11 +243,9 @@ describe("config overlay routes", () => {
test.serial("disables inherited mcp server with a minimal local override", async () => {
await using global = await tmpdir()
await using project = await tmpdir()
;(Global.Path as { config: string }).config = global.path
await config(global.path, {
await setGlobal(global.path, {
mcp: { shared: { type: "local", command: ["node", "shared.js"], enabled: true } },
})
await invalidate()
await json(
await req(project.path, "/config/overlay", {
@@ -278,9 +264,7 @@ describe("config overlay routes", () => {
test.serial("refreshes effective config after project permission update", async () => {
await using global = await tmpdir()
await using project = await tmpdir()
;(Global.Path as { config: string }).config = global.path
await config(global.path, { permission: { edit: "allow" } })
await invalidate()
await setGlobal(global.path, { permission: { edit: "allow" } })
const before = await json<Agent[]>(await req(project.path, "/agent"))
expect(Permission.evaluate("edit", "*", before.find((item) => item.name === "code")?.permission ?? []).action).toBe(
@@ -313,9 +297,7 @@ describe("config overlay routes", () => {
test.serial("refreshes agent permissions after global permission update", async () => {
await using global = await tmpdir()
await using project = await tmpdir()
;(Global.Path as { config: string }).config = global.path
await config(global.path, { permission: { edit: "allow" } })
await invalidate()
await setGlobal(global.path, { permission: { edit: "allow" } })
const before = await json<Agent[]>(await req(project.path, "/agent"))
expect(Permission.evaluate("edit", "*", before.find((item) => item.name === "code")?.permission ?? []).action).toBe(
@@ -347,9 +329,7 @@ describe("config overlay routes", () => {
async () => {
await using global = await tmpdir()
await using project = await tmpdir()
;(Global.Path as { config: string }).config = global.path
await config(global.path, { permission: { edit: "ask" } })
await invalidate()
await setGlobal(global.path, { permission: { edit: "ask" } })
await disposeAllInstances()
const target = app(value)
-1
View File
@@ -34,7 +34,6 @@ const testAllow: Record<string, { count: number; reason: string }> = {
"kilocode/config-resilience.test.ts": { count: 4, reason: "existing runtime integration test" },
"kilocode/config-validation.test.ts": { count: 2, reason: "existing runtime integration test" },
"kilocode/plan-followup.test.ts": { count: 4, reason: "existing runtime integration test" },
"kilocode/server/config-overlay.test.ts": { count: 3, reason: "server config cache integration test" },
"kilocode/session/platform-attribution.test.ts": { count: 5, reason: "existing runtime integration test" },
"kilocode/session-prompt-queue.test.ts": { count: 5, reason: "prompt queue legacy instance bridge regression" },
"kilocode/session/session.test.ts": { count: 5, reason: "existing runtime integration test" },