mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-01 15:32:11 +08:00
5d5fab36bb
Fixes 257 typecheck errors surfaced after the upstream merge: - Update imports to new module paths after upstream PR #24554 removed module barrel files (@/config, @/session, @/util, etc.) and PR #24309 renamed @opencode-ai/shared to @opencode-ai/core. - Migrate loadMode to use Info.zod.safeParse for consistency with loadAgents and ConfigCommand (unblocks KilocodeConfig.handleInvalid). - Drop removed Npm.outdated mock from tests. - Add missing Config.defaultLayer to bash-permission-metadata test runtime. - Fix Tips component signature (kilocode drops upstream's 'connected' prop). - Fix toast.tsx undefined 'duration' reference (should be toastOptions.duration). - Move filesystem-containment test from deleted shared package to core.
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { expect, test } from "bun:test"
|
|
import * as Log from "@opencode-ai/core/util/log"
|
|
|
|
Log.init({ print: false })
|
|
|
|
const { DEFAULT_THEMES, allThemes, addTheme, hasTheme, resolveTheme } = await import(
|
|
"../../../src/cli/cmd/tui/context/theme"
|
|
)
|
|
|
|
test("addTheme writes into module theme store", () => {
|
|
const name = `plugin-theme-${Date.now()}`
|
|
expect(addTheme(name, DEFAULT_THEMES.opencode)).toBe(true)
|
|
|
|
expect(allThemes()[name]).toBeDefined()
|
|
})
|
|
|
|
test("addTheme keeps first theme for duplicate names", () => {
|
|
const name = `plugin-theme-keep-${Date.now()}`
|
|
const one = structuredClone(DEFAULT_THEMES.opencode)
|
|
const two = structuredClone(DEFAULT_THEMES.opencode)
|
|
one.theme.primary = "#101010"
|
|
two.theme.primary = "#fefefe"
|
|
|
|
expect(addTheme(name, one)).toBe(true)
|
|
expect(addTheme(name, two)).toBe(false)
|
|
|
|
expect(allThemes()[name]).toBeDefined()
|
|
expect(allThemes()[name]!.theme.primary).toBe("#101010")
|
|
})
|
|
|
|
test("addTheme ignores entries without a theme object", () => {
|
|
const name = `plugin-theme-invalid-${Date.now()}`
|
|
expect(addTheme(name, { defs: { a: "#ffffff" } })).toBe(false)
|
|
expect(allThemes()[name]).toBeUndefined()
|
|
})
|
|
|
|
test("hasTheme checks theme presence", () => {
|
|
const name = `plugin-theme-has-${Date.now()}`
|
|
expect(hasTheme(name)).toBe(false)
|
|
expect(addTheme(name, DEFAULT_THEMES.opencode)).toBe(true)
|
|
expect(hasTheme(name)).toBe(true)
|
|
})
|
|
|
|
test("resolveTheme rejects circular color refs", () => {
|
|
const item = structuredClone(DEFAULT_THEMES.opencode)
|
|
item.defs = {
|
|
...item.defs,
|
|
one: "two",
|
|
two: "one",
|
|
}
|
|
item.theme.primary = "one"
|
|
|
|
expect(() => resolveTheme(item, "dark")).toThrow("Circular color reference")
|
|
})
|