chore: Fix types in tests 20/N.

This commit is contained in:
cpojer
2026-02-17 12:21:55 +09:00
parent e09643e82c
commit 18cc48dfd9
9 changed files with 68 additions and 58 deletions

View File

@@ -1,9 +1,12 @@
import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { resolveMemorySearchConfig } from "./memory-search.js";
const asConfig = (cfg: OpenClawConfig): OpenClawConfig => cfg;
describe("memory search config", () => {
it("returns null when disabled", () => {
const cfg = {
const cfg = asConfig({
agents: {
defaults: {
memorySearch: { enabled: true },
@@ -16,13 +19,13 @@ describe("memory search config", () => {
},
],
},
};
});
const resolved = resolveMemorySearchConfig(cfg, "main");
expect(resolved).toBeNull();
});
it("defaults provider to auto when unspecified", () => {
const cfg = {
const cfg = asConfig({
agents: {
defaults: {
memorySearch: {
@@ -30,14 +33,14 @@ describe("memory search config", () => {
},
},
},
};
});
const resolved = resolveMemorySearchConfig(cfg, "main");
expect(resolved?.provider).toBe("auto");
expect(resolved?.fallback).toBe("none");
});
it("merges defaults and overrides", () => {
const cfg = {
const cfg = asConfig({
agents: {
defaults: {
memorySearch: {
@@ -69,7 +72,7 @@ describe("memory search config", () => {
},
],
},
};
});
const resolved = resolveMemorySearchConfig(cfg, "main");
expect(resolved?.provider).toBe("openai");
expect(resolved?.model).toBe("text-embedding-3-small");
@@ -82,7 +85,7 @@ describe("memory search config", () => {
});
it("merges extra memory paths from defaults and overrides", () => {
const cfg = {
const cfg = asConfig({
agents: {
defaults: {
memorySearch: {
@@ -99,13 +102,13 @@ describe("memory search config", () => {
},
],
},
};
});
const resolved = resolveMemorySearchConfig(cfg, "main");
expect(resolved?.extraPaths).toEqual(["/shared/notes", "docs", "../team-notes"]);
});
it("includes batch defaults for openai without remote overrides", () => {
const cfg = {
const cfg = asConfig({
agents: {
defaults: {
memorySearch: {
@@ -113,7 +116,7 @@ describe("memory search config", () => {
},
},
},
};
});
const resolved = resolveMemorySearchConfig(cfg, "main");
expect(resolved?.remote?.batch).toEqual({
enabled: false,
@@ -125,7 +128,7 @@ describe("memory search config", () => {
});
it("keeps remote unset for local provider without overrides", () => {
const cfg = {
const cfg = asConfig({
agents: {
defaults: {
memorySearch: {
@@ -133,13 +136,13 @@ describe("memory search config", () => {
},
},
},
};
});
const resolved = resolveMemorySearchConfig(cfg, "main");
expect(resolved?.remote).toBeUndefined();
});
it("includes remote defaults for gemini without overrides", () => {
const cfg = {
const cfg = asConfig({
agents: {
defaults: {
memorySearch: {
@@ -147,7 +150,7 @@ describe("memory search config", () => {
},
},
},
};
});
const resolved = resolveMemorySearchConfig(cfg, "main");
expect(resolved?.remote?.batch).toEqual({
enabled: false,
@@ -159,7 +162,7 @@ describe("memory search config", () => {
});
it("defaults session delta thresholds", () => {
const cfg = {
const cfg = asConfig({
agents: {
defaults: {
memorySearch: {
@@ -167,7 +170,7 @@ describe("memory search config", () => {
},
},
},
};
});
const resolved = resolveMemorySearchConfig(cfg, "main");
expect(resolved?.sync.sessions).toEqual({
deltaBytes: 100000,
@@ -176,7 +179,7 @@ describe("memory search config", () => {
});
it("merges remote defaults with agent overrides", () => {
const cfg = {
const cfg = asConfig({
agents: {
defaults: {
memorySearch: {
@@ -200,7 +203,7 @@ describe("memory search config", () => {
},
],
},
};
});
const resolved = resolveMemorySearchConfig(cfg, "main");
expect(resolved?.remote).toEqual({
baseUrl: "https://agent.example/v1",
@@ -217,7 +220,7 @@ describe("memory search config", () => {
});
it("gates session sources behind experimental flag", () => {
const cfg = {
const cfg = asConfig({
agents: {
defaults: {
memorySearch: {
@@ -235,13 +238,13 @@ describe("memory search config", () => {
},
],
},
};
});
const resolved = resolveMemorySearchConfig(cfg, "main");
expect(resolved?.sources).toEqual(["memory"]);
});
it("allows session sources when experimental flag is enabled", () => {
const cfg = {
const cfg = asConfig({
agents: {
defaults: {
memorySearch: {
@@ -251,7 +254,7 @@ describe("memory search config", () => {
},
},
},
};
});
const resolved = resolveMemorySearchConfig(cfg, "main");
expect(resolved?.sources).toContain("sessions");
});