diff --git a/script/run-ci-tests.ts b/script/run-ci-tests.ts index 5466885ce..116d5e4ff 100644 --- a/script/run-ci-tests.ts +++ b/script/run-ci-tests.ts @@ -8,6 +8,7 @@ type CiTestPlan = { const TEST_ROOTS = ["bin", "script", "src"] as const const MODULE_MOCK_PATTERN = "mock.module(" +const ALWAYS_ISOLATED_TEST_FILES = ["src/openclaw/__tests__/reply-listener-discord.test.ts"] as const async function collectTestFiles(rootDirectory: string): Promise { const testFiles: string[] = [] @@ -29,13 +30,7 @@ async function usesModuleMock(rootDirectory: string, testFile: string): Promise< } function toIsolatedTarget(testFile: string): string { - const pathSegments = testFile.split("/") - - if (pathSegments.length <= 3) { - return testFile - } - - return pathSegments.slice(0, -1).join("/") + return testFile } function isCoveredByTarget(testFile: string, isolatedTarget: string): boolean { @@ -60,8 +55,11 @@ export async function createCiTestPlan(rootDirectory: string = process.cwd()): P } } + const isolatedTestFiles = Array.from( + new Set([...isolatedModuleMockFiles, ...ALWAYS_ISOLATED_TEST_FILES.filter((testFile) => allTestFiles.includes(testFile))]), + ) const isolatedTestTargets = collapseNestedTargets( - Array.from(new Set(isolatedModuleMockFiles.map((testFile) => toIsolatedTarget(testFile)))).sort((left, right) => + isolatedTestFiles.map((testFile) => toIsolatedTarget(testFile)).sort((left, right) => left.localeCompare(right), ), ) diff --git a/src/openclaw/__tests__/reply-listener-discord.test.ts b/src/openclaw/__tests__/reply-listener-discord.test.ts index 357c8fd89..d1bdba01e 100644 --- a/src/openclaw/__tests__/reply-listener-discord.test.ts +++ b/src/openclaw/__tests__/reply-listener-discord.test.ts @@ -11,6 +11,7 @@ import type { OpenClawConfig } from "../types" const originalHome = process.env.HOME const originalUserProfile = process.env.USERPROFILE +const originalFetch = globalThis.fetch const tempHome = mkdtempSync(join(tmpdir(), "openclaw-reply-listener-discord-")) const stateDir = join(tempHome, ".omx", "state") @@ -60,12 +61,14 @@ describe("pollDiscordReplies", () => { beforeEach(() => { process.env.HOME = tempHome process.env.USERPROFILE = tempHome + globalThis.fetch = originalFetch rmSync(stateDir, { recursive: true, force: true }) mkdirSync(stateDir, { recursive: true }) }) afterEach(() => { mock.restore() + globalThis.fetch = originalFetch }) test("records HTTP failures in daemon state when Discord returns non-ok", async () => {