mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:51:23 +00:00
refactor(channels): dedupe transport and gateway test scaffolds
This commit is contained in:
@@ -8,8 +8,10 @@ import {
|
||||
connectDeviceAuthReq,
|
||||
connectGatewayClient,
|
||||
getFreeGatewayPort,
|
||||
startGatewayWithClient,
|
||||
} from "./test-helpers.e2e.js";
|
||||
import { installOpenAiResponsesMock } from "./test-helpers.openai-mock.js";
|
||||
import { buildOpenAiResponsesProviderConfig } from "./test-openai-responses-model.js";
|
||||
|
||||
function extractPayloadText(result: unknown): string {
|
||||
const record = result as Record<string, unknown>;
|
||||
@@ -66,40 +68,15 @@ describe("gateway e2e", () => {
|
||||
models: {
|
||||
mode: "replace",
|
||||
providers: {
|
||||
openai: {
|
||||
baseUrl: openaiBaseUrl,
|
||||
apiKey: "test",
|
||||
api: "openai-responses",
|
||||
models: [
|
||||
{
|
||||
id: "gpt-5.2",
|
||||
name: "gpt-5.2",
|
||||
api: "openai-responses",
|
||||
reasoning: false,
|
||||
input: ["text"],
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
contextWindow: 128_000,
|
||||
maxTokens: 4096,
|
||||
},
|
||||
],
|
||||
},
|
||||
openai: buildOpenAiResponsesProviderConfig(openaiBaseUrl),
|
||||
},
|
||||
},
|
||||
gateway: { auth: { token } },
|
||||
};
|
||||
|
||||
await fs.writeFile(configPath, `${JSON.stringify(cfg, null, 2)}\n`);
|
||||
process.env.OPENCLAW_CONFIG_PATH = configPath;
|
||||
|
||||
const port = await getFreeGatewayPort();
|
||||
const server = await startGatewayServer(port, {
|
||||
bind: "loopback",
|
||||
auth: { mode: "token", token },
|
||||
controlUiEnabled: false,
|
||||
});
|
||||
|
||||
const client = await connectGatewayClient({
|
||||
url: `ws://127.0.0.1:${port}`,
|
||||
const { server, client } = await startGatewayWithClient({
|
||||
cfg,
|
||||
configPath,
|
||||
token,
|
||||
clientDisplayName: "vitest-mock-openai",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user