refactor(test): consolidate doctor health and sandbox fixtures

This commit is contained in:
Peter Steinberger
2026-02-16 16:48:46 +00:00
parent 2d8edf85ad
commit 0d51869c3c
5 changed files with 133 additions and 109 deletions

View File

@@ -31,6 +31,19 @@ import { detectLegacyWorkspaceDirs } from "./doctor-workspace.js";
describe("noteMemorySearchHealth", () => {
const cfg = {} as OpenClawConfig;
async function expectNoWarningWithConfiguredRemoteApiKey(provider: string) {
resolveMemorySearchConfig.mockReturnValue({
provider,
local: {},
remote: { apiKey: "from-config" },
});
await noteMemorySearchHealth(cfg);
expect(note).not.toHaveBeenCalled();
expect(resolveApiKeyForProvider).not.toHaveBeenCalled();
}
beforeEach(() => {
note.mockReset();
resolveDefaultAgentId.mockClear();
@@ -40,29 +53,11 @@ describe("noteMemorySearchHealth", () => {
});
it("does not warn when remote apiKey is configured for explicit provider", async () => {
resolveMemorySearchConfig.mockReturnValue({
provider: "openai",
local: {},
remote: { apiKey: "from-config" },
});
await noteMemorySearchHealth(cfg);
expect(note).not.toHaveBeenCalled();
expect(resolveApiKeyForProvider).not.toHaveBeenCalled();
await expectNoWarningWithConfiguredRemoteApiKey("openai");
});
it("does not warn in auto mode when remote apiKey is configured", async () => {
resolveMemorySearchConfig.mockReturnValue({
provider: "auto",
local: {},
remote: { apiKey: "from-config" },
});
await noteMemorySearchHealth(cfg);
expect(note).not.toHaveBeenCalled();
expect(resolveApiKeyForProvider).not.toHaveBeenCalled();
await expectNoWarningWithConfiguredRemoteApiKey("auto");
});
it("resolves provider auth from the default agent directory", async () => {