mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 19:35:28 -06:00
test: remove redundant extension test seams (#127688)
This commit is contained in:
committed by
GitHub
parent
b765944a9f
commit
4e7bf407d1
@@ -6,7 +6,6 @@ import { describe, expect, it } from "vitest";
|
||||
import { codexCatalogHomeId } from "../session-catalog-home-id.js";
|
||||
import {
|
||||
createCodexManagedThreadStore,
|
||||
markStartedCodexManagedThread,
|
||||
type StoredCodexManagedThread,
|
||||
} from "./managed-thread-store.js";
|
||||
|
||||
@@ -59,21 +58,6 @@ describe("Codex managed thread store", () => {
|
||||
await expect(createCodexManagedThreadStore(state).snapshot()).resolves.toEqual(new Map());
|
||||
});
|
||||
|
||||
it("records the supplied catalog home instead of deriving ownership from rollout metadata", async () => {
|
||||
const { state, values } = createStateStore();
|
||||
const sourceHomeId = codexCatalogHomeId("/tmp/configured-codex-home");
|
||||
await markStartedCodexManagedThread(createCodexManagedThreadStore(state), {
|
||||
sourceHomeId,
|
||||
threadId: "thread-1",
|
||||
rolloutPath: "/tmp/other-codex-home/sessions/2026/08/rollout.jsonl",
|
||||
});
|
||||
|
||||
expect([...values.values()][0]).toMatchObject({
|
||||
sourceHomeId,
|
||||
threadId: "thread-1",
|
||||
});
|
||||
});
|
||||
|
||||
it("uses the same source identity for a symlinked configured home", async () => {
|
||||
const root = await fs.realpath(await fs.mkdtemp(path.join(os.tmpdir(), "codex-home-id-")));
|
||||
try {
|
||||
|
||||
@@ -10,12 +10,4 @@ describe("sandbox exec-server JSON-RPC helpers", () => {
|
||||
|
||||
expect(send).toHaveBeenCalledWith({ jsonrpc: "2.0", id: 1, result: null });
|
||||
});
|
||||
|
||||
it("keeps undefined results as empty objects for methods without bodies", () => {
|
||||
const send = vi.fn();
|
||||
|
||||
sendResult(send, 2, undefined);
|
||||
|
||||
expect(send).toHaveBeenCalledWith({ jsonrpc: "2.0", id: 2, result: {} });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -78,24 +78,6 @@ describe("OpenClaw Codex sandbox exec-server", () => {
|
||||
expect(sandboxExecServerRegistry.servers.has(sandbox.runtimeId)).toBe(false);
|
||||
});
|
||||
|
||||
it("propagates environment registration failures and releases the server lease", async () => {
|
||||
const sandbox = createSandboxContext({});
|
||||
const client = {
|
||||
getServerVersion: vi.fn(() => CODEX_APP_SERVER_VERSION),
|
||||
request: vi.fn(async () => {
|
||||
throw new Error("environment registration failed");
|
||||
}),
|
||||
};
|
||||
|
||||
await expect(
|
||||
ensureCodexSandboxExecServerEnvironment({
|
||||
client: client as never,
|
||||
sandbox,
|
||||
}),
|
||||
).rejects.toThrow("environment registration failed");
|
||||
expect(sandboxExecServerRegistry.servers.has(sandbox.runtimeId)).toBe(false);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ containerWorkdir: "/workspace", cwd: "file:///workspace" },
|
||||
{
|
||||
|
||||
@@ -88,9 +88,9 @@ export function readHttpHeaders(value: unknown): HttpHeader[] {
|
||||
export function sendResult(
|
||||
send: CodexSandboxExecMessageTransport["send"],
|
||||
id: string | number,
|
||||
result: JsonValue | undefined,
|
||||
result: JsonValue,
|
||||
): void {
|
||||
send({ jsonrpc: "2.0", id, result: result === undefined ? {} : result });
|
||||
send({ jsonrpc: "2.0", id, result });
|
||||
}
|
||||
|
||||
/** Sends a JSON-RPC error response through the connection message sink. */
|
||||
|
||||
@@ -105,7 +105,6 @@ export {
|
||||
type QaGatewayChildStateMutationContext,
|
||||
startQaGatewayChild,
|
||||
} from "./src/gateway-child.js";
|
||||
export { startQaGatewayRpcClient } from "./src/gateway-rpc-client.js";
|
||||
export {
|
||||
buildQaSuiteSummaryJson,
|
||||
type QaSuiteResult,
|
||||
|
||||
@@ -111,18 +111,6 @@ describe("startQaGatewayRpcClient", () => {
|
||||
expect(requestOptions.timeoutMs).toBeLessThanOrEqual(45_000);
|
||||
});
|
||||
|
||||
it("can request a narrower operator scope for authorization-sensitive probes", async () => {
|
||||
const client = await startQaGatewayRpcClient({
|
||||
wsUrl: "ws://127.0.0.1:18789",
|
||||
token: "qa-token",
|
||||
logs: () => "qa logs",
|
||||
scopes: ["operator.write"],
|
||||
});
|
||||
|
||||
expect(gatewayRpcMock.clients[0]?.options.scopes).toEqual(["operator.write"]);
|
||||
await client.stop();
|
||||
});
|
||||
|
||||
it("dispatches concurrent requests over the same client", async () => {
|
||||
let releaseFirst: (() => void) | undefined;
|
||||
gatewayRpcMock.request
|
||||
|
||||
@@ -75,7 +75,6 @@ export async function startQaGatewayRpcClient(params: {
|
||||
wsUrl: string;
|
||||
token: string;
|
||||
logs: () => string;
|
||||
scopes?: Array<"operator.read" | "operator.write" | "operator.admin">;
|
||||
}): Promise<QaGatewayRpcClient> {
|
||||
const wrapError = (error: unknown) => formatQaGatewayRpcError(error, params.logs);
|
||||
let stopped = false;
|
||||
@@ -93,7 +92,7 @@ export async function startQaGatewayRpcClient(params: {
|
||||
clientName: "gateway-client",
|
||||
deviceIdentity: null,
|
||||
mode: "backend",
|
||||
scopes: params.scopes ?? ["operator.admin"],
|
||||
scopes: ["operator.admin"],
|
||||
onHelloOk: () => {
|
||||
connection.connected = true;
|
||||
connection.resolve();
|
||||
|
||||
@@ -3,11 +3,11 @@ import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { setTimeout as sleep } from "node:timers/promises";
|
||||
import { afterEach, describe, expect, test } from "vitest";
|
||||
import { startQaGatewayChild, startQaMockOpenAiServer } from "../../../../extensions/qa-lab/api.js";
|
||||
import {
|
||||
startQaGatewayChild,
|
||||
startQaGatewayRpcClient,
|
||||
startQaMockOpenAiServer,
|
||||
} from "../../../../extensions/qa-lab/api.js";
|
||||
connectGatewayClient,
|
||||
disconnectGatewayClient,
|
||||
} from "../../../../src/gateway/test-helpers.e2e.js";
|
||||
import type { OpenClawConfig } from "../../../../src/plugin-sdk/config-contracts.js";
|
||||
import { MEMORY_DREAMING_SYSTEM_EVENT_TEXT } from "../../../../src/plugin-sdk/memory-core-host-status.js";
|
||||
|
||||
@@ -17,7 +17,7 @@ const WAIT_TIMEOUT_MS = 30_000;
|
||||
|
||||
type GatewayHandle = Awaited<ReturnType<typeof startQaGatewayChild>>;
|
||||
type MockHandle = Awaited<ReturnType<typeof startQaMockOpenAiServer>>;
|
||||
type RpcClient = Awaited<ReturnType<typeof startQaGatewayRpcClient>>;
|
||||
type RpcClient = Awaited<ReturnType<typeof connectGatewayClient>>;
|
||||
|
||||
let gateway: GatewayHandle | undefined;
|
||||
let mock: MockHandle | undefined;
|
||||
@@ -27,7 +27,7 @@ afterEach(async () => {
|
||||
const cleanups = [
|
||||
gateway?.stop().catch(() => undefined),
|
||||
mock?.stop().catch(() => undefined),
|
||||
restrictedClient?.stop().catch(() => undefined),
|
||||
restrictedClient ? disconnectGatewayClient(restrictedClient).catch(() => undefined) : undefined,
|
||||
].filter((cleanup): cleanup is Promise<void> => cleanup !== undefined);
|
||||
gateway = undefined;
|
||||
mock = undefined;
|
||||
@@ -140,18 +140,15 @@ describe("memory provenance through a real Gateway", () => {
|
||||
enabledPluginIds: ["memory-core"],
|
||||
mutateConfig: configureMemoryProof,
|
||||
});
|
||||
restrictedClient = await startQaGatewayRpcClient({
|
||||
wsUrl: gateway.wsUrl,
|
||||
restrictedClient = await connectGatewayClient({
|
||||
url: gateway.wsUrl,
|
||||
token: gateway.token,
|
||||
logs: gateway.logs,
|
||||
scopes: ["operator.write"],
|
||||
});
|
||||
const restrictedCall: GatewayHandle["call"] = (method, params, options) =>
|
||||
restrictedClient!.request(method, params, options);
|
||||
|
||||
const sessionKey = "agent:qa:memory-provenance-e2e";
|
||||
await sendAndWait({
|
||||
call: restrictedCall,
|
||||
call: restrictedClient.request.bind(restrictedClient),
|
||||
sessionKey,
|
||||
message: `Remember this stored instruction: ${RESTRICTED_MARKER}`,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user