mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
test: split cli backend coverage by ownership
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { createCapturedPluginRegistration } from "../../src/test-utils/plugin-registration.js";
|
||||
import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-registration.js";
|
||||
|
||||
const { readClaudeCliCredentialsForSetupMock, readClaudeCliCredentialsForRuntimeMock } = vi.hoisted(
|
||||
@@ -18,6 +19,23 @@ vi.mock("./cli-auth-seam.js", () => {
|
||||
import anthropicPlugin from "./index.js";
|
||||
|
||||
describe("anthropic provider replay hooks", () => {
|
||||
it("registers the claude-cli backend", async () => {
|
||||
const captured = createCapturedPluginRegistration();
|
||||
await anthropicPlugin.register(captured.api);
|
||||
|
||||
expect(captured.cliBackends).toContainEqual(
|
||||
expect.objectContaining({
|
||||
id: "claude-cli",
|
||||
bundleMcp: true,
|
||||
config: expect.objectContaining({
|
||||
command: "claude",
|
||||
modelArg: "--model",
|
||||
sessionArg: "--session-id",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("owns native reasoning output mode for Claude transports", async () => {
|
||||
const provider = await registerSingleProviderPlugin(anthropicPlugin);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, it, expect, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resetLogger, setLoggerOverride } from "../logging/logger.js";
|
||||
import { createEmptyPluginRegistry } from "../plugins/registry-empty.js";
|
||||
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
import { getActivePluginRegistry, setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
import {
|
||||
buildAllowedModelSet,
|
||||
inferUniqueProviderFromConfiguredModels,
|
||||
@@ -135,17 +135,26 @@ describe("model-selection", () => {
|
||||
|
||||
describe("isCliProvider", () => {
|
||||
it("treats runtime-registered CLI backends as CLI providers", () => {
|
||||
const previousRegistry = getActivePluginRegistry();
|
||||
const registry = createEmptyPluginRegistry();
|
||||
registry.cliBackends.push({
|
||||
pluginId: "anthropic",
|
||||
backend: {
|
||||
id: "claude-cli",
|
||||
label: "Claude CLI",
|
||||
command: ["claude"],
|
||||
},
|
||||
});
|
||||
setActivePluginRegistry(registry);
|
||||
expect(isCliProvider("claude-cli", {} as OpenClawConfig)).toBe(true);
|
||||
try {
|
||||
registry.cliBackends = [
|
||||
{
|
||||
pluginId: "example-plugin",
|
||||
source: "test",
|
||||
backend: {
|
||||
id: "example-cli",
|
||||
config: {
|
||||
command: "example",
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
setActivePluginRegistry(registry);
|
||||
expect(isCliProvider("example-cli", {} as OpenClawConfig)).toBe(true);
|
||||
} finally {
|
||||
setActivePluginRegistry(previousRegistry ?? createEmptyPluginRegistry());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user