fix(ci): isolate discord reply listener test

This commit is contained in:
GeonWoo Jeon (Jay)
2026-04-09 12:09:09 +09:00
parent 3f5dfd8201
commit f82cc81c33
2 changed files with 9 additions and 8 deletions

View File

@@ -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<string[]> {
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),
),
)

View File

@@ -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 () => {