test(slashcommand): isolate command discovery mocks

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-27 13:24:50 +09:00
parent ecce65bb67
commit a2c3804b5f
4 changed files with 22 additions and 11 deletions
@@ -1,8 +1,9 @@
/// <reference types="bun-types" />
import { afterEach, describe, expect, it, spyOn } from "bun:test"
import type { LoadedSkill } from "../../features/opencode-skill-loader"
import * as shared from "../../shared"
import * as slashcommand from "../../tools/slashcommand"
import { executeSlashCommand } from "./executor"
import * as slashcommand from "../../tools/slashcommand/command-discovery"
let resolveCommandsInTextSpy: { mockRestore: () => void } | undefined
let resolveFileReferencesInTextSpy: { mockRestore: () => void } | undefined
@@ -38,6 +39,11 @@ function restoreExecutorSpies(): void {
discoverCommandsSyncSpy = undefined
}
async function executeSlashCommand(...args: Parameters<typeof import("./executor").executeSlashCommand>): ReturnType<typeof import("./executor").executeSlashCommand> {
const module = await import(`./executor?test=${Date.now()}-${Math.random()}`)
return module.executeSlashCommand(...args)
}
afterEach(restoreExecutorSpies)
function createRestrictedSkill(): LoadedSkill {