test(config): add regression coverage for legacy migration bugs

Lock the current legacy config and plugin migration failures in place before the fixes land so the three regressions stay covered.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-04 01:32:17 +09:00
parent 53eeac3f31
commit d60ca63ed4
4 changed files with 115 additions and 17 deletions
+30 -1
View File
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, mock, spyOn } from "bun:test";
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs"
import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
import { tmpdir } from "node:os"
import { join } from "node:path"
import * as shared from "./shared"
@@ -321,4 +321,33 @@ describe("loadPluginConfig", () => {
// then
expect(config.mcp_env_allowlist).toEqual(["USER_ONLY_TOKEN"])
})
it("should ignore edits to the renamed legacy backup after migration", () => {
// given
const rootDir = mkdtempSync(join(tmpdir(), "omo-plugin-config-legacy-"))
const userConfigDir = join(rootDir, "user-config")
const projectDir = join(rootDir, "project")
const projectConfigDir = join(projectDir, ".opencode")
const legacyConfigPath = join(projectConfigDir, "oh-my-opencode.jsonc")
const backupConfigPath = `${legacyConfigPath}.bak`
const canonicalConfigPath = join(projectConfigDir, "oh-my-openagent.jsonc")
tempDirs.push(rootDir)
mkdirSync(userConfigDir, { recursive: true })
mkdirSync(projectConfigDir, { recursive: true })
writeFileSync(legacyConfigPath, JSON.stringify({ agents: { oracle: { model: "openai/gpt-5.4" } } }))
spyOn(shared, "getOpenCodeConfigDir").mockReturnValue(userConfigDir)
// when
loadPluginConfig(projectDir, {})
writeFileSync(backupConfigPath, JSON.stringify({ agents: { oracle: { model: "openai/gpt-5-nano" } } }))
const reloadedConfig = loadPluginConfig(projectDir, {})
// then
expect(existsSync(legacyConfigPath)).toBe(false)
expect(existsSync(backupConfigPath)).toBe(true)
expect(readFileSync(canonicalConfigPath, "utf-8")).toContain('"openai/gpt-5.4"')
expect(reloadedConfig.agents?.oracle?.model).toBe("openai/gpt-5.4")
})
})