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
+6 -8
View File
@@ -8,6 +8,7 @@ type CiTestPlan = {
const TEST_ROOTS = ["bin", "script", "src"] as const const TEST_ROOTS = ["bin", "script", "src"] as const
const MODULE_MOCK_PATTERN = "mock.module(" 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[]> { async function collectTestFiles(rootDirectory: string): Promise<string[]> {
const testFiles: string[] = [] const testFiles: string[] = []
@@ -29,13 +30,7 @@ async function usesModuleMock(rootDirectory: string, testFile: string): Promise<
} }
function toIsolatedTarget(testFile: string): string { function toIsolatedTarget(testFile: string): string {
const pathSegments = testFile.split("/") return testFile
if (pathSegments.length <= 3) {
return testFile
}
return pathSegments.slice(0, -1).join("/")
} }
function isCoveredByTarget(testFile: string, isolatedTarget: string): boolean { 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( 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), left.localeCompare(right),
), ),
) )
@@ -11,6 +11,7 @@ import type { OpenClawConfig } from "../types"
const originalHome = process.env.HOME const originalHome = process.env.HOME
const originalUserProfile = process.env.USERPROFILE const originalUserProfile = process.env.USERPROFILE
const originalFetch = globalThis.fetch
const tempHome = mkdtempSync(join(tmpdir(), "openclaw-reply-listener-discord-")) const tempHome = mkdtempSync(join(tmpdir(), "openclaw-reply-listener-discord-"))
const stateDir = join(tempHome, ".omx", "state") const stateDir = join(tempHome, ".omx", "state")
@@ -60,12 +61,14 @@ describe("pollDiscordReplies", () => {
beforeEach(() => { beforeEach(() => {
process.env.HOME = tempHome process.env.HOME = tempHome
process.env.USERPROFILE = tempHome process.env.USERPROFILE = tempHome
globalThis.fetch = originalFetch
rmSync(stateDir, { recursive: true, force: true }) rmSync(stateDir, { recursive: true, force: true })
mkdirSync(stateDir, { recursive: true }) mkdirSync(stateDir, { recursive: true })
}) })
afterEach(() => { afterEach(() => {
mock.restore() mock.restore()
globalThis.fetch = originalFetch
}) })
test("records HTTP failures in daemon state when Discord returns non-ok", async () => { test("records HTTP failures in daemon state when Discord returns non-ok", async () => {