[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:
Vincent Koc
2026-03-02 00:41:21 -08:00
committed by GitHub
parent 1443bb9a84
commit 29c3ce9454
13 changed files with 195 additions and 104 deletions

View File

@@ -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: {

View File

@@ -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", () => {