From 5958454710b661eaad13ff8853262dca662a14bf Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 15 Feb 2026 21:27:07 +0000 Subject: [PATCH] refactor(test): share auth profile order fixtures --- ...-lastgood-round-robin-ordering.e2e.test.ts | 29 ++++--------------- ...les.resolve-auth-profile-order.fixtures.ts | 26 +++++++++++++++++ ...alizes-z-ai-aliases-auth-order.e2e.test.ts | 24 --------------- ...tused-no-explicit-order-exists.e2e.test.ts | 24 --------------- ...ored-profiles-no-config-exists.e2e.test.ts | 29 ++++--------------- 5 files changed, 38 insertions(+), 94 deletions(-) create mode 100644 src/agents/auth-profiles.resolve-auth-profile-order.fixtures.ts diff --git a/src/agents/auth-profiles.resolve-auth-profile-order.does-not-prioritize-lastgood-round-robin-ordering.e2e.test.ts b/src/agents/auth-profiles.resolve-auth-profile-order.does-not-prioritize-lastgood-round-robin-ordering.e2e.test.ts index 692b67a01..79f227989 100644 --- a/src/agents/auth-profiles.resolve-auth-profile-order.does-not-prioritize-lastgood-round-robin-ordering.e2e.test.ts +++ b/src/agents/auth-profiles.resolve-auth-profile-order.does-not-prioritize-lastgood-round-robin-ordering.e2e.test.ts @@ -1,30 +1,13 @@ import { describe, expect, it } from "vitest"; import { resolveAuthProfileOrder } from "./auth-profiles.js"; +import { + ANTHROPIC_CFG, + ANTHROPIC_STORE, +} from "./auth-profiles.resolve-auth-profile-order.fixtures.js"; describe("resolveAuthProfileOrder", () => { - const store: AuthProfileStore = { - version: 1, - profiles: { - "anthropic:default": { - type: "api_key", - provider: "anthropic", - key: "sk-default", - }, - "anthropic:work": { - type: "api_key", - provider: "anthropic", - key: "sk-work", - }, - }, - }; - const cfg = { - auth: { - profiles: { - "anthropic:default": { provider: "anthropic", mode: "api_key" }, - "anthropic:work": { provider: "anthropic", mode: "api_key" }, - }, - }, - }; + const store = ANTHROPIC_STORE; + const cfg = ANTHROPIC_CFG; it("does not prioritize lastGood over round-robin ordering", () => { const order = resolveAuthProfileOrder({ diff --git a/src/agents/auth-profiles.resolve-auth-profile-order.fixtures.ts b/src/agents/auth-profiles.resolve-auth-profile-order.fixtures.ts new file mode 100644 index 000000000..bc7b5cf98 --- /dev/null +++ b/src/agents/auth-profiles.resolve-auth-profile-order.fixtures.ts @@ -0,0 +1,26 @@ +import type { AuthProfileStore } from "./auth-profiles.js"; + +export const ANTHROPIC_STORE: AuthProfileStore = { + version: 1, + profiles: { + "anthropic:default": { + type: "api_key", + provider: "anthropic", + key: "sk-default", + }, + "anthropic:work": { + type: "api_key", + provider: "anthropic", + key: "sk-work", + }, + }, +}; + +export const ANTHROPIC_CFG = { + auth: { + profiles: { + "anthropic:default": { provider: "anthropic", mode: "api_key" }, + "anthropic:work": { provider: "anthropic", mode: "api_key" }, + }, + }, +}; diff --git a/src/agents/auth-profiles.resolve-auth-profile-order.normalizes-z-ai-aliases-auth-order.e2e.test.ts b/src/agents/auth-profiles.resolve-auth-profile-order.normalizes-z-ai-aliases-auth-order.e2e.test.ts index a6bd59b3b..0817f2280 100644 --- a/src/agents/auth-profiles.resolve-auth-profile-order.normalizes-z-ai-aliases-auth-order.e2e.test.ts +++ b/src/agents/auth-profiles.resolve-auth-profile-order.normalizes-z-ai-aliases-auth-order.e2e.test.ts @@ -2,30 +2,6 @@ import { describe, expect, it } from "vitest"; import { resolveAuthProfileOrder } from "./auth-profiles.js"; describe("resolveAuthProfileOrder", () => { - const _store: AuthProfileStore = { - version: 1, - profiles: { - "anthropic:default": { - type: "api_key", - provider: "anthropic", - key: "sk-default", - }, - "anthropic:work": { - type: "api_key", - provider: "anthropic", - key: "sk-work", - }, - }, - }; - const _cfg = { - auth: { - profiles: { - "anthropic:default": { provider: "anthropic", mode: "api_key" }, - "anthropic:work": { provider: "anthropic", mode: "api_key" }, - }, - }, - }; - it("normalizes z.ai aliases in auth.order", () => { const order = resolveAuthProfileOrder({ cfg: { diff --git a/src/agents/auth-profiles.resolve-auth-profile-order.orders-by-lastused-no-explicit-order-exists.e2e.test.ts b/src/agents/auth-profiles.resolve-auth-profile-order.orders-by-lastused-no-explicit-order-exists.e2e.test.ts index 55816522c..2842fb48e 100644 --- a/src/agents/auth-profiles.resolve-auth-profile-order.orders-by-lastused-no-explicit-order-exists.e2e.test.ts +++ b/src/agents/auth-profiles.resolve-auth-profile-order.orders-by-lastused-no-explicit-order-exists.e2e.test.ts @@ -2,30 +2,6 @@ import { describe, expect, it } from "vitest"; import { resolveAuthProfileOrder } from "./auth-profiles.js"; describe("resolveAuthProfileOrder", () => { - const _store: AuthProfileStore = { - version: 1, - profiles: { - "anthropic:default": { - type: "api_key", - provider: "anthropic", - key: "sk-default", - }, - "anthropic:work": { - type: "api_key", - provider: "anthropic", - key: "sk-work", - }, - }, - }; - const _cfg = { - auth: { - profiles: { - "anthropic:default": { provider: "anthropic", mode: "api_key" }, - "anthropic:work": { provider: "anthropic", mode: "api_key" }, - }, - }, - }; - it("orders by lastUsed when no explicit order exists", () => { const order = resolveAuthProfileOrder({ store: { diff --git a/src/agents/auth-profiles.resolve-auth-profile-order.uses-stored-profiles-no-config-exists.e2e.test.ts b/src/agents/auth-profiles.resolve-auth-profile-order.uses-stored-profiles-no-config-exists.e2e.test.ts index 0a4344bb6..c5ec9826e 100644 --- a/src/agents/auth-profiles.resolve-auth-profile-order.uses-stored-profiles-no-config-exists.e2e.test.ts +++ b/src/agents/auth-profiles.resolve-auth-profile-order.uses-stored-profiles-no-config-exists.e2e.test.ts @@ -1,30 +1,13 @@ import { describe, expect, it } from "vitest"; import { resolveAuthProfileOrder } from "./auth-profiles.js"; +import { + ANTHROPIC_CFG, + ANTHROPIC_STORE, +} from "./auth-profiles.resolve-auth-profile-order.fixtures.js"; describe("resolveAuthProfileOrder", () => { - const store: AuthProfileStore = { - version: 1, - profiles: { - "anthropic:default": { - type: "api_key", - provider: "anthropic", - key: "sk-default", - }, - "anthropic:work": { - type: "api_key", - provider: "anthropic", - key: "sk-work", - }, - }, - }; - const cfg = { - auth: { - profiles: { - "anthropic:default": { provider: "anthropic", mode: "api_key" }, - "anthropic:work": { provider: "anthropic", mode: "api_key" }, - }, - }, - }; + const store = ANTHROPIC_STORE; + const cfg = ANTHROPIC_CFG; it("uses stored profiles when no config exists", () => { const order = resolveAuthProfileOrder({