Tests: preserve OpenRouter explicit auth order under cooldown fields

This commit is contained in:
Vincent Koc
2026-02-24 18:46:04 -05:00
parent 06f0b4a193
commit aee38c42d3

View File

@@ -118,6 +118,50 @@ describe("resolveAuthProfileOrder", () => {
},
);
it.each(["store", "config"] as const)(
"keeps OpenRouter explicit order even when cooldown fields exist (%s)",
(orderSource) => {
const now = Date.now();
const explicitOrder = ["openrouter:default", "openrouter:work"];
const order = resolveAuthProfileOrder({
cfg:
orderSource === "config"
? {
auth: {
order: { openrouter: explicitOrder },
},
}
: undefined,
store: {
version: 1,
...(orderSource === "store" ? { order: { openrouter: explicitOrder } } : {}),
profiles: {
"openrouter:default": {
type: "api_key",
provider: "openrouter",
key: "sk-or-default",
},
"openrouter:work": {
type: "api_key",
provider: "openrouter",
key: "sk-or-work",
},
},
usageStats: {
"openrouter:default": {
cooldownUntil: now + 60_000,
disabledUntil: now + 120_000,
disabledReason: "billing",
},
},
},
provider: "openrouter",
});
expect(order).toEqual(explicitOrder);
},
);
it("mode: oauth config accepts both oauth and token credentials (issue #559)", () => {
const now = Date.now();
const storeWithBothTypes: AuthProfileStore = {