test: tighten codex shared client assertions

This commit is contained in:
Shakker
2026-05-10 19:09:18 +01:00
parent 072e600813
commit 7139aa8ad4

View File

@@ -143,16 +143,10 @@ describe("shared Codex app-server client", () => {
await sendEmptyModelList(harness);
await expect(listPromise).resolves.toEqual({ models: [] });
expect(mocks.bridgeCodexAppServerStartOptions).toHaveBeenCalledWith(
expect.objectContaining({
authProfileId: "openai-codex:work",
}),
);
expect(mocks.applyCodexAppServerAuthProfile).toHaveBeenCalledWith(
expect.objectContaining({
authProfileId: "openai-codex:work",
}),
);
const [bridgeCall] = mocks.bridgeCodexAppServerStartOptions.mock.calls[0] ?? [];
expect(bridgeCall?.authProfileId).toBe("openai-codex:work");
const [applyCall] = mocks.applyCodexAppServerAuthProfile.mock.calls[0] ?? [];
expect(applyCall?.authProfileId).toBe("openai-codex:work");
});
it("resolves the configured implicit auth profile before sharing a client", async () => {
@@ -169,21 +163,18 @@ describe("shared Codex app-server client", () => {
await sendEmptyModelList(harness);
await expect(listPromise).resolves.toEqual({ models: [] });
expect(mocks.resolveCodexAppServerAuthProfileIdForAgent).toHaveBeenCalledWith(
expect.objectContaining({ config }),
);
expect(mocks.bridgeCodexAppServerStartOptions).toHaveBeenCalledWith(
expect.objectContaining({
authProfileId: "openai-codex:work",
config,
}),
);
expect(mocks.applyCodexAppServerAuthProfile).toHaveBeenCalledWith(
expect.objectContaining({
authProfileId: "openai-codex:work",
config,
}),
);
const [resolveCall] = mocks.resolveCodexAppServerAuthProfileIdForAgent.mock.calls[0] ?? [];
expect(resolveCall).toStrictEqual({
authProfileId: undefined,
agentDir: "/tmp/openclaw-agent",
config,
});
const [bridgeCall] = mocks.bridgeCodexAppServerStartOptions.mock.calls[0] ?? [];
expect(bridgeCall?.authProfileId).toBe("openai-codex:work");
expect(bridgeCall?.config).toBe(config);
const [applyCall] = mocks.applyCodexAppServerAuthProfile.mock.calls[0] ?? [];
expect(applyCall?.authProfileId).toBe("openai-codex:work");
expect(applyCall?.config).toBe(config);
});
it("uses the selected agent dir for shared app-server auth bridging", async () => {
@@ -199,18 +190,12 @@ describe("shared Codex app-server client", () => {
await sendEmptyModelList(harness);
await expect(listPromise).resolves.toEqual({ models: [] });
expect(mocks.bridgeCodexAppServerStartOptions).toHaveBeenCalledWith(
expect.objectContaining({
agentDir: "/tmp/openclaw-agent-nova",
authProfileId: "openai-codex:work",
}),
);
expect(mocks.applyCodexAppServerAuthProfile).toHaveBeenCalledWith(
expect.objectContaining({
agentDir: "/tmp/openclaw-agent-nova",
authProfileId: "openai-codex:work",
}),
);
const [bridgeCall] = mocks.bridgeCodexAppServerStartOptions.mock.calls[0] ?? [];
expect(bridgeCall?.agentDir).toBe("/tmp/openclaw-agent-nova");
expect(bridgeCall?.authProfileId).toBe("openai-codex:work");
const [applyCall] = mocks.applyCodexAppServerAuthProfile.mock.calls[0] ?? [];
expect(applyCall?.agentDir).toBe("/tmp/openclaw-agent-nova");
expect(applyCall?.authProfileId).toBe("openai-codex:work");
});
it("resolves the managed binary before bridging and spawning the shared client", async () => {
@@ -227,26 +212,15 @@ describe("shared Codex app-server client", () => {
await sendEmptyModelList(harness);
await expect(listPromise).resolves.toEqual({ models: [] });
expect(mocks.resolveManagedCodexAppServerStartOptions).toHaveBeenCalledWith(
expect.objectContaining({
command: "codex",
commandSource: "managed",
}),
);
expect(mocks.bridgeCodexAppServerStartOptions).toHaveBeenCalledWith(
expect.objectContaining({
startOptions: expect.objectContaining({
command: "/cache/openclaw/codex",
commandSource: "resolved-managed",
}),
}),
);
expect(startSpy).toHaveBeenCalledWith(
expect.objectContaining({
command: "/cache/openclaw/codex",
commandSource: "resolved-managed",
}),
);
const [managedCall] = mocks.resolveManagedCodexAppServerStartOptions.mock.calls[0] ?? [];
expect(managedCall?.command).toBe("codex");
expect(managedCall?.commandSource).toBe("managed");
const [bridgeCall] = mocks.bridgeCodexAppServerStartOptions.mock.calls[0] ?? [];
expect(bridgeCall?.startOptions.command).toBe("/cache/openclaw/codex");
expect(bridgeCall?.startOptions.commandSource).toBe("resolved-managed");
const [startCall] = startSpy.mock.calls[0] ?? [];
expect(startCall?.command).toBe("/cache/openclaw/codex");
expect(startCall?.commandSource).toBe("resolved-managed");
});
it("restarts the shared client when the bridged auth token changes", async () => {