test: avoid asserting auth.json absence for invalid profile creds

This commit is contained in:
Brian Mendonca
2026-02-21 15:36:10 -07:00
committed by Peter Steinberger
parent 4414af977a
commit 6c813bd32b

View File

@@ -99,7 +99,7 @@ describe("models list auth-profile sync", () => {
});
});
it("does not write auth.json when auth profile credentials are invalid", async () => {
it("does not persist blank auth-profile credentials", async () => {
await withAuthSyncFixture(async ({ agentDir, authPath }) => {
saveAuthProfileStore(
{
@@ -120,7 +120,16 @@ describe("models list auth-profile sync", () => {
expect(runtime.error).not.toHaveBeenCalled();
expect(runtime.log).toHaveBeenCalledTimes(1);
expect(await pathExists(authPath)).toBe(false);
if (await pathExists(authPath)) {
const parsed = JSON.parse(await fs.readFile(authPath, "utf8")) as Record<
string,
{ type?: string; key?: string }
>;
const openrouterKey = parsed.openrouter?.key;
if (openrouterKey !== undefined) {
expect(openrouterKey.trim().length).toBeGreaterThan(0);
}
}
});
});
});