test: mock auth alias registry in onboarding auth

This commit is contained in:
Peter Steinberger
2026-04-17 09:05:22 +01:00
parent d3e12cee7e
commit 199bb1fe05

View File

@@ -2,7 +2,7 @@ import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import type { OAuthCredentials } from "@mariozechner/pi-ai";
import { afterEach, describe, expect, it } from "vitest";
import { afterEach, describe, expect, it, vi } from "vitest";
import {
applyAuthProfileConfig,
upsertApiKeyProfile,
@@ -14,6 +14,16 @@ import {
setupAuthTestEnv,
} from "./test-wizard-helpers.js";
vi.mock("../agents/provider-auth-aliases.js", () => ({
resolveProviderIdForAuth: (provider: string) => {
const normalized = provider.trim().toLowerCase();
if (normalized === "z.ai" || normalized === "z-ai") {
return "zai";
}
return normalized;
},
}));
describe("writeOAuthCredentials", () => {
const lifecycle = createAuthTestLifecycle([
"OPENCLAW_STATE_DIR",