fix(ci): resolve all test failures + complete rename compat layer
Sisyphus-authored fixes across 15 files: - plugin-identity: align CONFIG_BASENAME with actual config file name - add-plugin-to-opencode-config: handle legacy→canonical name migration - plugin-detection tests: update expectations for new identity constants - doctor/system: fix legacy name warning test assertions - install tests: align with new plugin name - chat-params tests: fix mock isolation - model-capabilities tests: fix snapshot expectations - image-converter: fix platform-dependent test assertions (Linux CI) - example configs: expanded with more detailed comments Full suite: 4484 pass, 0 fail, typecheck clean.
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
import { afterEach, beforeEach, describe, expect, it } from "bun:test"
|
||||
import { mkdirSync, rmSync, writeFileSync } from "node:fs"
|
||||
import { tmpdir } from "node:os"
|
||||
import { join } from "node:path"
|
||||
import { checkForLegacyPluginEntry } from "./legacy-plugin-warning"
|
||||
|
||||
describe("checkForLegacyPluginEntry", () => {
|
||||
let testConfigDir = ""
|
||||
let originalXdgConfigHome: string | undefined
|
||||
let originalOpenCodeConfigDir: string | undefined
|
||||
|
||||
beforeEach(() => {
|
||||
originalXdgConfigHome = process.env.XDG_CONFIG_HOME
|
||||
originalOpenCodeConfigDir = process.env.OPENCODE_CONFIG_DIR
|
||||
testConfigDir = join(tmpdir(), `omo-legacy-check-${Date.now()}-${Math.random().toString(36).slice(2)}`)
|
||||
mkdirSync(join(testConfigDir, "opencode"), { recursive: true })
|
||||
process.env.XDG_CONFIG_HOME = testConfigDir
|
||||
delete process.env.OPENCODE_CONFIG_DIR
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
if (originalXdgConfigHome === undefined) {
|
||||
delete process.env.XDG_CONFIG_HOME
|
||||
} else {
|
||||
process.env.XDG_CONFIG_HOME = originalXdgConfigHome
|
||||
}
|
||||
|
||||
if (originalOpenCodeConfigDir === undefined) {
|
||||
delete process.env.OPENCODE_CONFIG_DIR
|
||||
} else {
|
||||
process.env.OPENCODE_CONFIG_DIR = originalOpenCodeConfigDir
|
||||
}
|
||||
|
||||
rmSync(testConfigDir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it("detects a bare legacy plugin entry", () => {
|
||||
// given
|
||||
writeFileSync(join(testConfigDir, "opencode", "opencode.json"), JSON.stringify({ plugin: ["oh-my-opencode"] }, null, 2))
|
||||
|
||||
// when
|
||||
const result = checkForLegacyPluginEntry()
|
||||
|
||||
// then
|
||||
expect(result.hasLegacyEntry).toBe(true)
|
||||
expect(result.hasCanonicalEntry).toBe(false)
|
||||
expect(result.legacyEntries).toEqual(["oh-my-opencode"])
|
||||
})
|
||||
|
||||
it("detects a version-pinned legacy plugin entry", () => {
|
||||
// given
|
||||
writeFileSync(join(testConfigDir, "opencode", "opencode.json"), JSON.stringify({ plugin: ["oh-my-opencode@3.10.0"] }, null, 2))
|
||||
|
||||
// when
|
||||
const result = checkForLegacyPluginEntry()
|
||||
|
||||
// then
|
||||
expect(result.hasLegacyEntry).toBe(true)
|
||||
expect(result.hasCanonicalEntry).toBe(false)
|
||||
expect(result.legacyEntries).toEqual(["oh-my-opencode@3.10.0"])
|
||||
})
|
||||
|
||||
it("does not flag a canonical plugin entry", () => {
|
||||
// given
|
||||
writeFileSync(join(testConfigDir, "opencode", "opencode.json"), JSON.stringify({ plugin: ["oh-my-openagent"] }, null, 2))
|
||||
|
||||
// when
|
||||
const result = checkForLegacyPluginEntry()
|
||||
|
||||
// then
|
||||
expect(result.hasLegacyEntry).toBe(false)
|
||||
expect(result.hasCanonicalEntry).toBe(true)
|
||||
expect(result.legacyEntries).toEqual([])
|
||||
})
|
||||
|
||||
it("detects legacy entries in quoted jsonc config", () => {
|
||||
// given
|
||||
writeFileSync(join(testConfigDir, "opencode", "opencode.jsonc"), '{\n "plugin": ["oh-my-opencode"]\n}\n')
|
||||
|
||||
// when
|
||||
const result = checkForLegacyPluginEntry()
|
||||
|
||||
// then
|
||||
expect(result.hasLegacyEntry).toBe(true)
|
||||
expect(result.legacyEntries).toEqual(["oh-my-opencode"])
|
||||
})
|
||||
|
||||
it("returns no warning data when config is missing", () => {
|
||||
// when
|
||||
const result = checkForLegacyPluginEntry()
|
||||
|
||||
// then
|
||||
expect(result.hasLegacyEntry).toBe(false)
|
||||
expect(result.hasCanonicalEntry).toBe(false)
|
||||
expect(result.legacyEntries).toEqual([])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user