mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 21:01:26 +00:00
Tests: preserve OpenRouter explicit auth order under cooldown fields
This commit is contained in:
@@ -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)", () => {
|
it("mode: oauth config accepts both oauth and token credentials (issue #559)", () => {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const storeWithBothTypes: AuthProfileStore = {
|
const storeWithBothTypes: AuthProfileStore = {
|
||||||
|
|||||||
Reference in New Issue
Block a user