From 3c7beb4e4210ca67fd8d93bf086ee43720e95794 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 8 Apr 2026 23:24:58 +0100 Subject: [PATCH] test: avoid runtime auth overlays in failure-state coverage --- ...th-profiles.markauthprofilefailure.test.ts | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/agents/auth-profiles.markauthprofilefailure.test.ts b/src/agents/auth-profiles.markauthprofilefailure.test.ts index 7807e58d9db..ded22634c1a 100644 --- a/src/agents/auth-profiles.markauthprofilefailure.test.ts +++ b/src/agents/auth-profiles.markauthprofilefailure.test.ts @@ -1,13 +1,22 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import { describe, expect, it } from "vitest"; +import { describe, expect, it, vi } from "vitest"; + +vi.mock("./cli-credentials.js", () => ({ + readCodexCliCredentialsCached: () => null, + readMiniMaxCliCredentialsCached: () => null, +})); + +vi.mock("../plugins/provider-runtime.js", () => ({ + resolveExternalAuthProfilesWithPlugins: () => [], +})); + import { clearRuntimeAuthProfileStoreSnapshots, calculateAuthProfileCooldownMs, ensureAuthProfileStore, markAuthProfileFailure, - replaceRuntimeAuthProfileStoreSnapshots, } from "./auth-profiles.js"; type AuthProfileStore = ReturnType; @@ -68,12 +77,16 @@ describe("markAuthProfileFailure", () => { }), ); - replaceRuntimeAuthProfileStoreSnapshots([ - { - agentDir, - store: ensureAuthProfileStore(agentDir), + const staleRuntimeStore: AuthProfileStore = { + version: 1, + profiles: { + "openai:default": { + type: "api_key", + provider: "openai", + key: "sk-expired-old", + }, }, - ]); + }; fs.writeFileSync( authPath, @@ -89,7 +102,6 @@ describe("markAuthProfileFailure", () => { }), ); - const staleRuntimeStore = ensureAuthProfileStore(agentDir); const staleCredential = staleRuntimeStore.profiles["openai:default"]; expect(staleCredential?.type).toBe("api_key"); expect(staleCredential && "key" in staleCredential ? staleCredential.key : undefined).toBe(