From 0c245c35c57b8e8cfc14cc9add4e67f5d7136f00 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 18 Apr 2026 20:34:40 +0100 Subject: [PATCH] test: trim auth and skill install setup --- ...auth.openai-codex-refresh-fallback.test.ts | 11 +++++++--- src/agents/skills-install.download.test.ts | 21 ++++++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/agents/auth-profiles/oauth.openai-codex-refresh-fallback.test.ts b/src/agents/auth-profiles/oauth.openai-codex-refresh-fallback.test.ts index 92c12f31d64..a9e74088480 100644 --- a/src/agents/auth-profiles/oauth.openai-codex-refresh-fallback.test.ts +++ b/src/agents/auth-profiles/oauth.openai-codex-refresh-fallback.test.ts @@ -109,8 +109,10 @@ describe("resolveApiKeyForProfile openai-codex refresh fallback", () => { ]); let tempRoot = ""; let agentDir = ""; + let caseIndex = 0; beforeAll(async () => { + tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-codex-refresh-fallback-")); ({ resolveApiKeyForProfile } = await import("./oauth.js")); }); @@ -131,10 +133,10 @@ describe("resolveApiKeyForProfile openai-codex refresh fallback", () => { buildProviderAuthDoctorHintWithPluginMock.mockReset(); buildProviderAuthDoctorHintWithPluginMock.mockResolvedValue(undefined); clearRuntimeAuthProfileStoreSnapshots(); - tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-codex-refresh-fallback-")); - agentDir = path.join(tempRoot, "agents", "main", "agent"); + const caseRoot = path.join(tempRoot, `case-${++caseIndex}`); + agentDir = path.join(caseRoot, "agents", "main", "agent"); await fs.mkdir(agentDir, { recursive: true }); - process.env.OPENCLAW_STATE_DIR = tempRoot; + process.env.OPENCLAW_STATE_DIR = caseRoot; process.env.OPENCLAW_AGENT_DIR = agentDir; process.env.PI_CODING_AGENT_DIR = agentDir; }); @@ -143,6 +145,9 @@ describe("resolveApiKeyForProfile openai-codex refresh fallback", () => { resetFileLockStateForTest(); clearRuntimeAuthProfileStoreSnapshots(); envSnapshot.restore(); + }); + + afterAll(async () => { await fs.rm(tempRoot, { recursive: true, force: true }); }); diff --git a/src/agents/skills-install.download.test.ts b/src/agents/skills-install.download.test.ts index f5f688a2679..a6a753a957e 100644 --- a/src/agents/skills-install.download.test.ts +++ b/src/agents/skills-install.download.test.ts @@ -202,22 +202,27 @@ describe("installDownloadSpec extraction safety", () => { }); it("allows relative targetDir inside the per-skill tools root", async () => { - mockArchiveResponse(new Uint8Array(SAFE_ZIP_BUFFER)); + mockArchiveResponse(new TextEncoder().encode("payload")); const entry = buildEntry("relative-targetdir"); - const result = await installDownloadSkill({ - name: "relative-targetdir", - url: "https://example.invalid/good.zip", - archive: "zip", - targetDir: "runtime", + const result = await installDownloadSpec({ + entry, + spec: { + kind: "download", + id: "dl", + url: "https://example.invalid/payload.bin", + extract: false, + targetDir: "runtime", + }, + timeoutMs: 30_000, }); expect(result.ok).toBe(true); expect( await fs.readFile( - path.join(resolveSkillToolsRootDir(entry), "runtime", "hello.txt"), + path.join(resolveSkillToolsRootDir(entry), "runtime", "payload.bin"), "utf-8", ), - ).toBe("hi"); + ).toBe("payload"); }); it.runIf(process.platform !== "win32")(