fix(test): move auto-slash-command-leak test to isolated subdirectory

mock.module('./executor') leaks across all files in the same batch because
Bun runs test files in a directory in parallel. The afterAll restore trick
doesn't work when other files load the module concurrently at startup.

Moving the leak test to its own subdirectory (leak/) ensures CI's batch
runner isolates it in a separate bun test invocation, preventing executor
mock contamination in executor-resolution.test.ts and index.test.ts.
This commit is contained in:
YeonGyu-Kim
2026-04-04 17:08:53 +09:00
parent 8fb22b89cf
commit c91c3e6164
@@ -1,12 +1,12 @@
import { afterAll, beforeEach, describe, expect, it, mock, spyOn } from "bun:test"
import { AUTO_SLASH_COMMAND_TAG_OPEN } from "./constants"
import { AUTO_SLASH_COMMAND_TAG_OPEN } from "../constants"
import type {
AutoSlashCommandHookInput,
AutoSlashCommandHookOutput,
CommandExecuteBeforeInput,
CommandExecuteBeforeOutput,
} from "./types"
import * as shared from "../../shared"
} from "../types"
import * as shared from "../../../shared"
const executeSlashCommandMock = mock(
async (parsed: { command: string; args: string; raw: string }) => ({
@@ -15,7 +15,7 @@ const executeSlashCommandMock = mock(
})
)
mock.module("./executor", () => ({
mock.module("../executor", () => ({
executeSlashCommand: executeSlashCommandMock,
}))
@@ -23,13 +23,13 @@ afterAll(async () => {
mock.restore()
// Restore the real executor module so subsequent test files in the same batch
// (e.g. executor-resolution.test.ts) don't get the mocked version
const realExecutor = await import("./executor")
mock.module("./executor", () => realExecutor)
const realExecutor = await import("../executor")
mock.module("../executor", () => realExecutor)
})
const logMock = spyOn(shared, "log").mockImplementation(() => {})
const { createAutoSlashCommandHook } = await import("./hook")
const { createAutoSlashCommandHook } = await import("../hook")
function createChatInput(sessionID: string, messageID: string): AutoSlashCommandHookInput {
return {