



























@@ -1,3 +1,4 @@
1+import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
12import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2334const { startQaGatewayChild, startQaProviderServer } = vi.hoisted(() => ({
@@ -15,6 +16,13 @@ vi.mock("../../providers/server-runtime.js", () => ({
15161617import { startQaLiveLaneGateway } from "./live-gateway.runtime.js";
171819+type GatewayOptions = {
20+providerBaseUrl?: string;
21+providerMode?: string;
22+transportBaseUrl?: string;
23+mutateConfig?: (cfg: OpenClawConfig) => OpenClawConfig;
24+};
25+1826function createStubTransport(baseUrl = "http://127.0.0.1:43123") {
1927return {
2028requiredPluginIds: ["qa-channel"],
@@ -38,6 +46,10 @@ function createStubTransport(baseUrl = "http://127.0.0.1:43123") {
3846};
3947}
404849+function firstGatewayOptions(): GatewayOptions | undefined {
50+return startQaGatewayChild.mock.calls[0]?.[0] as GatewayOptions | undefined;
51+}
52+4153describe("startQaLiveLaneGateway", () => {
4254const gatewayStop = vi.fn();
4355const gatewayCall = vi.fn();
@@ -81,9 +93,7 @@ describe("startQaLiveLaneGateway", () => {
8193});
82948395expect(startQaProviderServer).toHaveBeenCalledWith("mock-openai");
84-const gatewayOptions = startQaGatewayChild.mock.calls.at(0)?.[0] as
85-| { providerBaseUrl?: string; providerMode?: string; transportBaseUrl?: string }
86-| undefined;
96+const gatewayOptions = firstGatewayOptions();
8797expect(gatewayOptions?.transportBaseUrl).toBe("http://127.0.0.1:43123");
8898expect(gatewayOptions?.providerBaseUrl).toBe("http://127.0.0.1:44080/v1");
8999expect(gatewayOptions?.providerMode).toBe("mock-openai");
@@ -104,7 +114,7 @@ describe("startQaLiveLaneGateway", () => {
104114controlUiEnabled: false,
105115});
106116107-const [{ mutateConfig }] = startQaGatewayChild.mock.calls.at(0) ?? [];
117+const { mutateConfig } = firstGatewayOptions() ?? {};
108118if (!mutateConfig) {
109119throw new Error("expected gateway config mutator");
110120}
@@ -173,9 +183,7 @@ describe("startQaLiveLaneGateway", () => {
173183});
174184175185expect(startQaProviderServer).toHaveBeenCalledWith("live-frontier");
176-const gatewayOptions = startQaGatewayChild.mock.calls.at(0)?.[0] as
177-| { providerBaseUrl?: string; providerMode?: string; transportBaseUrl?: string }
178-| undefined;
186+const gatewayOptions = firstGatewayOptions();
179187expect(gatewayOptions?.transportBaseUrl).toBe("http://127.0.0.1:43123");
180188expect(gatewayOptions?.providerBaseUrl).toBeUndefined();
181189expect(gatewayOptions?.providerMode).toBe("live-frontier");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。