fix(tests): replace as any with typed PluginInput mocks

This commit is contained in:
YeonGyu-Kim
2026-04-10 18:47:17 +09:00
parent bf5d1c58a4
commit e54f747916
3 changed files with 13 additions and 10 deletions
+9 -8
View File
@@ -1,4 +1,5 @@
import { describe, expect, test, beforeEach, afterEach, spyOn } from "bun:test"
import type { PluginInput } from "@opencode-ai/plugin"
import { createKeywordDetectorHook } from "./index"
import { setMainSession, updateSessionAgent, clearSessionAgent, _resetForTesting } from "../../features/claude-code-session-state"
import { ContextCollector } from "../../features/context-injector"
@@ -31,7 +32,7 @@ describe("keyword-detector message transform", () => {
showToast: async () => {},
},
},
} as any
} as unknown as PluginInput
}
test("should prepend ultrawork message to text part", async () => {
@@ -119,12 +120,12 @@ describe("keyword-detector session filtering", () => {
return {
client: {
tui: {
showToast: async (opts: any) => {
showToast: async (opts: { body: { title: string } }) => {
toastCalls.push(opts.body.title)
},
},
},
} as any
} as unknown as PluginInput
}
test("should skip non-ultrawork keywords in non-main session (using mainSessionID check)", async () => {
@@ -264,12 +265,12 @@ describe("keyword-detector word boundary", () => {
return {
client: {
tui: {
showToast: async (opts: any) => {
showToast: async (opts: { body: { title: string } }) => {
toastCalls.push(opts.body.title)
},
},
},
} as any
} as unknown as PluginInput
}
test("should NOT trigger ultrawork on partial matches like 'StatefulWidget' containing 'ulw'", async () => {
@@ -363,7 +364,7 @@ describe("keyword-detector system-reminder filtering", () => {
showToast: async () => {},
},
},
} as any
} as unknown as PluginInput
}
test("should NOT trigger search mode from keywords inside <system-reminder> tags", async () => {
@@ -554,7 +555,7 @@ describe("keyword-detector agent-specific ultrawork messages", () => {
showToast: async () => {},
},
},
} as any
} as unknown as PluginInput
}
test("should skip ultrawork injection when agent is prometheus", async () => {
@@ -771,7 +772,7 @@ describe("keyword-detector non-OMO agent skipping", () => {
showToast: async () => {},
},
},
} as any
} as unknown as PluginInput
}
test("should skip all keyword injection for OpenCode-Builder agent", async () => {
@@ -1,4 +1,5 @@
import { afterEach, beforeEach, describe, expect, test } from "bun:test"
import type { PluginInput } from "@opencode-ai/plugin"
import { createKeywordDetectorHook } from "./index"
import { _resetForTesting, setMainSession } from "../../features/claude-code-session-state"
@@ -18,7 +19,7 @@ function createMockPluginInput(toastCalls: string[] = []) {
},
},
},
} as any
} as unknown as PluginInput
}
function createMockRalphLoop(startLoopCalls: StartLoopCall[]) {
@@ -2,6 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test"
import { mkdtempSync, rmSync } from "node:fs"
import { join } from "node:path"
import { tmpdir } from "node:os"
import type { PluginInput } from "@opencode-ai/plugin"
import type { BackgroundManager, BackgroundTask } from "../../features/background-agent"
import { readContinuationMarker } from "../../features/run-continuation-state"
import { createStopContinuationGuardHook } from "./index"
@@ -37,7 +38,7 @@ describe("stop-continuation-guard", () => {
},
},
directory: createTempDir(),
} as any
} as unknown as PluginInput
}
function createBackgroundTask(status: BackgroundTask["status"], id: string): BackgroundTask {