mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 18:54:48 +00:00
test: tighten codex app server client assertions
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { EventEmitter } from "node:events";
|
||||
import { PassThrough } from "node:stream";
|
||||
import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
|
||||
import { embeddedAgentLog, OPENCLAW_VERSION } from "openclaw/plugin-sdk/agent-harness-runtime";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
__testing,
|
||||
@@ -57,14 +57,25 @@ describe("CodexAppServerClient", () => {
|
||||
|
||||
harness.process.stdout.write('{"token":"secret-value"} trailing\n');
|
||||
|
||||
await vi.waitFor(() =>
|
||||
expect(warn).toHaveBeenCalledWith(
|
||||
"failed to parse codex app-server message",
|
||||
expect.objectContaining({
|
||||
consoleMessage: expect.stringContaining("<redacted>"),
|
||||
linePreview: '{"token":"<redacted>"} trailing',
|
||||
}),
|
||||
),
|
||||
await vi.waitFor(() => expect(warn).toHaveBeenCalledTimes(1));
|
||||
expect(warn.mock.calls[0]?.[0]).toBe("failed to parse codex app-server message");
|
||||
const metadata = warn.mock.calls[0]?.[1] as
|
||||
| {
|
||||
error?: unknown;
|
||||
errorMessage?: string;
|
||||
fragmentCount?: number;
|
||||
linePreview?: string;
|
||||
consoleMessage?: string;
|
||||
}
|
||||
| undefined;
|
||||
expect(metadata?.error).toBeInstanceOf(SyntaxError);
|
||||
expect(metadata?.errorMessage).toBe(
|
||||
"Unexpected non-whitespace character after JSON at position 25 (line 1 column 26)",
|
||||
);
|
||||
expect(metadata?.fragmentCount).toBe(1);
|
||||
expect(metadata?.linePreview).toBe('{"token":"<redacted>"} trailing');
|
||||
expect(metadata?.consoleMessage).toBe(
|
||||
'failed to parse codex app-server message: preview="{\\"token\\":\\"<redacted>\\"} trailing"',
|
||||
);
|
||||
expect(JSON.stringify(warn.mock.calls)).not.toContain("secret-value");
|
||||
});
|
||||
@@ -157,13 +168,17 @@ describe("CodexAppServerClient", () => {
|
||||
});
|
||||
|
||||
await expect(initializing).resolves.toBeUndefined();
|
||||
expect(outbound).toMatchObject({
|
||||
expect(outbound).toStrictEqual({
|
||||
id: outbound.id,
|
||||
method: "initialize",
|
||||
params: {
|
||||
clientInfo: {
|
||||
name: "openclaw",
|
||||
title: "OpenClaw",
|
||||
version: expect.any(String),
|
||||
version: OPENCLAW_VERSION,
|
||||
},
|
||||
capabilities: {
|
||||
experimentalApi: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -433,14 +448,11 @@ describe("CodexAppServerClient", () => {
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(warn).toHaveBeenCalledWith(
|
||||
"codex app-server server request timed out",
|
||||
expect.objectContaining({
|
||||
id: "srv-timeout",
|
||||
method: "item/tool/call",
|
||||
timeoutMs: __testing.CODEX_DYNAMIC_TOOL_SERVER_REQUEST_TIMEOUT_MS,
|
||||
}),
|
||||
);
|
||||
expect(warn).toHaveBeenCalledWith("codex app-server server request timed out", {
|
||||
id: "srv-timeout",
|
||||
method: "item/tool/call",
|
||||
timeoutMs: __testing.CODEX_DYNAMIC_TOOL_SERVER_REQUEST_TIMEOUT_MS,
|
||||
});
|
||||
});
|
||||
|
||||
it("fails closed for unhandled native app-server approvals", async () => {
|
||||
|
||||
Reference in New Issue
Block a user