From c2027290b91a6992c2320473129d16c5e6634ccc Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 18 Mar 2026 11:55:48 +0900 Subject: [PATCH] test: update test fixtures for oh-my-openagent primary name --- .../config-manager/plugin-detection.test.ts | 134 +++++++++--------- src/plugin/hooks/create-session-hooks.test.ts | 6 +- 2 files changed, 70 insertions(+), 70 deletions(-) diff --git a/src/cli/config-manager/plugin-detection.test.ts b/src/cli/config-manager/plugin-detection.test.ts index 2d4d69945..ec432a736 100644 --- a/src/cli/config-manager/plugin-detection.test.ts +++ b/src/cli/config-manager/plugin-detection.test.ts @@ -15,7 +15,7 @@ describe("detectCurrentConfig - single package detection", () => { beforeEach(() => { testConfigDir = join(tmpdir(), `omo-detect-config-${Date.now()}-${Math.random().toString(36).slice(2)}`) testConfigPath = join(testConfigDir, "opencode.json") - testOmoConfigPath = join(testConfigDir, "oh-my-opencode.json") + testOmoConfigPath = join(testConfigDir, "oh-my-openagent.json") mkdirSync(testConfigDir, { recursive: true }) process.env.OPENCODE_CONFIG_DIR = testConfigDir @@ -28,31 +28,7 @@ describe("detectCurrentConfig - single package detection", () => { delete process.env.OPENCODE_CONFIG_DIR }) - it("detects oh-my-opencode in plugin array", () => { - // given - const config = { plugin: ["oh-my-opencode"] } - writeFileSync(testConfigPath, JSON.stringify(config, null, 2) + "\n", "utf-8") - - // when - const result = detectCurrentConfig() - - // then - expect(result.isInstalled).toBe(true) - }) - - it("detects oh-my-opencode with version pin", () => { - // given - const config = { plugin: ["oh-my-opencode@3.11.0"] } - writeFileSync(testConfigPath, JSON.stringify(config, null, 2) + "\n", "utf-8") - - // when - const result = detectCurrentConfig() - - // then - expect(result.isInstalled).toBe(true) - }) - - it("detects oh-my-openagent as installed (legacy name)", () => { + it("detects oh-my-openagent in plugin array", () => { // given const config = { plugin: ["oh-my-openagent"] } writeFileSync(testConfigPath, JSON.stringify(config, null, 2) + "\n", "utf-8") @@ -64,7 +40,7 @@ describe("detectCurrentConfig - single package detection", () => { expect(result.isInstalled).toBe(true) }) - it("detects oh-my-openagent with version pin as installed (legacy name)", () => { + it("detects oh-my-openagent with version pin", () => { // given const config = { plugin: ["oh-my-openagent@3.11.0"] } writeFileSync(testConfigPath, JSON.stringify(config, null, 2) + "\n", "utf-8") @@ -76,6 +52,30 @@ describe("detectCurrentConfig - single package detection", () => { expect(result.isInstalled).toBe(true) }) + it("detects oh-my-opencode as installed (legacy name)", () => { + // given + const config = { plugin: ["oh-my-opencode"] } + writeFileSync(testConfigPath, JSON.stringify(config, null, 2) + "\n", "utf-8") + + // when + const result = detectCurrentConfig() + + // then + expect(result.isInstalled).toBe(true) + }) + + it("detects oh-my-opencode with version pin as installed (legacy name)", () => { + // given + const config = { plugin: ["oh-my-opencode@3.11.0"] } + writeFileSync(testConfigPath, JSON.stringify(config, null, 2) + "\n", "utf-8") + + // when + const result = detectCurrentConfig() + + // then + expect(result.isInstalled).toBe(true) + }) + it("returns false when plugin not present", () => { // given const config = { plugin: ["some-other-plugin"] } @@ -89,7 +89,7 @@ describe("detectCurrentConfig - single package detection", () => { }) it("returns false when plugin not present (even with similar name)", () => { - // given - not exactly oh-my-openagent + // given const config = { plugin: ["oh-my-openagent-extra"] } writeFileSync(testConfigPath, JSON.stringify(config, null, 2) + "\n", "utf-8") @@ -102,7 +102,7 @@ describe("detectCurrentConfig - single package detection", () => { it("detects OpenCode Go from the existing omo config", () => { // given - writeFileSync(testConfigPath, JSON.stringify({ plugin: ["oh-my-opencode"] }, null, 2) + "\n", "utf-8") + writeFileSync(testConfigPath, JSON.stringify({ plugin: ["oh-my-openagent"] }, null, 2) + "\n", "utf-8") writeFileSync( testOmoConfigPath, JSON.stringify({ agents: { atlas: { model: "opencode-go/kimi-k2.5" } } }, null, 2) + "\n", @@ -137,36 +137,7 @@ describe("addPluginToOpenCodeConfig - single package writes", () => { delete process.env.OPENCODE_CONFIG_DIR }) - it("keeps oh-my-opencode when it already exists", async () => { - // given - const config = { plugin: ["oh-my-opencode"] } - writeFileSync(testConfigPath, JSON.stringify(config, null, 2) + "\n", "utf-8") - - // when - const result = await addPluginToOpenCodeConfig("3.11.0") - - // then - expect(result.success).toBe(true) - const savedConfig = JSON.parse(readFileSync(testConfigPath, "utf-8")) - expect(savedConfig.plugin).toContain("oh-my-opencode") - }) - - it("replaces version-pinned oh-my-opencode@X.Y.Z", async () => { - // given - const config = { plugin: ["oh-my-opencode@3.10.0"] } - writeFileSync(testConfigPath, JSON.stringify(config, null, 2) + "\n", "utf-8") - - // when - const result = await addPluginToOpenCodeConfig("3.11.0") - - // then - expect(result.success).toBe(true) - const savedConfig = JSON.parse(readFileSync(testConfigPath, "utf-8")) - expect(savedConfig.plugin).toContain("oh-my-opencode") - expect(savedConfig.plugin).not.toContain("oh-my-opencode@3.10.0") - }) - - it("recognizes oh-my-openagent as already installed (legacy name)", async () => { + it("keeps oh-my-openagent when it already exists", async () => { // given const config = { plugin: ["oh-my-openagent"] } writeFileSync(testConfigPath, JSON.stringify(config, null, 2) + "\n", "utf-8") @@ -177,12 +148,10 @@ describe("addPluginToOpenCodeConfig - single package writes", () => { // then expect(result.success).toBe(true) const savedConfig = JSON.parse(readFileSync(testConfigPath, "utf-8")) - // Should upgrade to new name - expect(savedConfig.plugin).toContain("oh-my-opencode") - expect(savedConfig.plugin).not.toContain("oh-my-openagent") + expect(savedConfig.plugin).toContain("oh-my-openagent") }) - it("replaces version-pinned oh-my-openagent@X.Y.Z with new name", async () => { + it("replaces version-pinned oh-my-openagent@X.Y.Z", async () => { // given const config = { plugin: ["oh-my-openagent@3.10.0"] } writeFileSync(testConfigPath, JSON.stringify(config, null, 2) + "\n", "utf-8") @@ -190,12 +159,43 @@ describe("addPluginToOpenCodeConfig - single package writes", () => { // when const result = await addPluginToOpenCodeConfig("3.11.0") + // then + expect(result.success).toBe(true) + const savedConfig = JSON.parse(readFileSync(testConfigPath, "utf-8")) + expect(savedConfig.plugin).toContain("oh-my-openagent") + expect(savedConfig.plugin).not.toContain("oh-my-openagent@3.10.0") + }) + + it("recognizes oh-my-opencode as already installed (legacy name)", async () => { + // given + const config = { plugin: ["oh-my-opencode"] } + writeFileSync(testConfigPath, JSON.stringify(config, null, 2) + "\n", "utf-8") + + // when + const result = await addPluginToOpenCodeConfig("3.11.0") + + // then + expect(result.success).toBe(true) + const savedConfig = JSON.parse(readFileSync(testConfigPath, "utf-8")) + // Should upgrade to new name + expect(savedConfig.plugin).toContain("oh-my-openagent") + expect(savedConfig.plugin).not.toContain("oh-my-opencode") + }) + + it("replaces version-pinned oh-my-opencode@X.Y.Z with new name", async () => { + // given + const config = { plugin: ["oh-my-opencode@3.10.0"] } + writeFileSync(testConfigPath, JSON.stringify(config, null, 2) + "\n", "utf-8") + + // when + const result = await addPluginToOpenCodeConfig("3.11.0") + // then expect(result.success).toBe(true) const savedConfig = JSON.parse(readFileSync(testConfigPath, "utf-8")) // Legacy should be replaced with new name - expect(savedConfig.plugin).toContain("oh-my-opencode") - expect(savedConfig.plugin).not.toContain("oh-my-openagent") + expect(savedConfig.plugin).toContain("oh-my-openagent") + expect(savedConfig.plugin).not.toContain("oh-my-opencode") }) it("adds new plugin when none exists", async () => { @@ -209,7 +209,7 @@ describe("addPluginToOpenCodeConfig - single package writes", () => { // then expect(result.success).toBe(true) const savedConfig = JSON.parse(readFileSync(testConfigPath, "utf-8")) - expect(savedConfig.plugin).toContain("oh-my-opencode") + expect(savedConfig.plugin).toContain("oh-my-openagent") }) it("adds plugin when plugin array is empty", async () => { @@ -223,6 +223,6 @@ describe("addPluginToOpenCodeConfig - single package writes", () => { // then expect(result.success).toBe(true) const savedConfig = JSON.parse(readFileSync(testConfigPath, "utf-8")) - expect(savedConfig.plugin).toContain("oh-my-opencode") + expect(savedConfig.plugin).toContain("oh-my-openagent") }) }) diff --git a/src/plugin/hooks/create-session-hooks.test.ts b/src/plugin/hooks/create-session-hooks.test.ts index a1098fd43..09395b1cd 100644 --- a/src/plugin/hooks/create-session-hooks.test.ts +++ b/src/plugin/hooks/create-session-hooks.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "bun:test" -import type { OhMyOpenCodeConfig } from "../../config" +import type { OhMyOpenAgentConfig } from "../../config" import type { ModelCacheState } from "../../plugin-state" import type { PluginContext } from "../types" import { createSessionHooks } from "./create-session-hooks" @@ -22,7 +22,7 @@ const mockModelCacheState = {} as ModelCacheState describe("createSessionHooks", () => { it("keeps model fallback disabled when config is unset", () => { // given - const pluginConfig = {} as OhMyOpenCodeConfig + const pluginConfig = {} as OhMyOpenAgentConfig // when const result = createSessionHooks({ @@ -39,7 +39,7 @@ describe("createSessionHooks", () => { it("creates model fallback hook when config explicitly enables it", () => { // given - const pluginConfig = { model_fallback: true } as OhMyOpenCodeConfig + const pluginConfig = { model_fallback: true } as OhMyOpenAgentConfig // when const result = createSessionHooks({