mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 04:22:43 +00:00
[AI-assisted] test: fix typing and test fixture issues (#31444)
* test: fix typing and test fixture issues * Fix type-test harness issues from session routing and mock typing * Add routing regression test for session.mainKey precedence
This commit is contained in:
@@ -2,7 +2,6 @@ import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { ModelProviderConfig } from "../config/types.models.js";
|
||||
import { validateConfigObject } from "../config/validation.js";
|
||||
import { resolveOpenClawAgentDir } from "./agent-paths.js";
|
||||
import {
|
||||
@@ -42,15 +41,15 @@ async function writeAgentModelsJson(content: unknown): Promise<void> {
|
||||
}
|
||||
|
||||
function createMergeConfigProvider() {
|
||||
const provider: ModelProviderConfig = {
|
||||
return {
|
||||
baseUrl: "https://config.example/v1",
|
||||
apiKey: "CONFIG_KEY",
|
||||
api: "openai-responses",
|
||||
api: "openai-responses" as const,
|
||||
models: [
|
||||
{
|
||||
id: "config-model",
|
||||
name: "Config model",
|
||||
input: ["text"],
|
||||
input: ["text"] as Array<"text" | "image">,
|
||||
reasoning: false,
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
contextWindow: 8192,
|
||||
@@ -58,7 +57,6 @@ function createMergeConfigProvider() {
|
||||
},
|
||||
],
|
||||
};
|
||||
return provider;
|
||||
}
|
||||
|
||||
async function runCustomProviderMergeTest(seedProvider: {
|
||||
|
||||
@@ -31,6 +31,19 @@ describe("resolveMainSessionAlias", () => {
|
||||
scope: "per-sender",
|
||||
});
|
||||
});
|
||||
|
||||
it("uses session.mainKey over any legacy routing sessions key", () => {
|
||||
const cfg = {
|
||||
session: { mainKey: " work ", scope: "per-sender" },
|
||||
routing: { sessions: { mainKey: "legacy-main" } },
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(resolveMainSessionAlias(cfg)).toEqual({
|
||||
mainKey: "work",
|
||||
alias: "work",
|
||||
scope: "per-sender",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("session key display/internal mapping", () => {
|
||||
|
||||
Reference in New Issue
Block a user