Files
openclaw/extensions/codex/harness.test.ts
Peter Steinberger 96f0983a85 fix(onboarding): skip setup for configured gateways and require inference first (#102883)
* fix(crestodian): keep onboarding RPCs restart-safe

* fix(profiles): isolate approval state migrations

* fix(crestodian): bypass configured gateway setup

* test(crestodian): type onboarding mocks

* fix(onboarding): require inference before Crestodian

* fix(onboarding): enforce verified inference handoff

* fix(macos): reset setup on gateway endpoint edits

* chore(i18n): refresh native source inventory

* fix(gateway): keep socket on request cancellation

* test(packaging): require workspace templates

* fix(onboarding): bind setup to verified inference

* fix(onboarding): align inference gate contracts

* fix(crestodian): classify concurrent policy rejection

* test(crestodian): expect registry restoration

* fix(onboarding): bind setup to configured gateways

* fix(codex): preserve startup phase deadlines

* test(crestodian): match fail-closed policy ordering

* test(onboarding): assert bound gateway handoff

* fix(codex): bind runtime resolution to spawn cwd

* test(crestodian): assert policy rejection order

* fix(cli): preserve gateway routing across restarts

* fix(macos): fail closed during gateway edits

* test(macos): cover gateway route generation races

* chore: keep release notes out of onboarding PR

* fix(ci): refresh onboarding generated checks

* style(swift): align gateway channel formatting

* fix(ci): refresh plugin SDK surface budgets

* fix(ci): resync native string inventory

* refactor(swift): split gateway channel support

* test(doctor): isolate plugin compatibility registry

* test(macos): isolate gateway onboarding fixtures

* test(macos): assert gateway lease health ordering

* fix(codex): reconcile computer-use startup changes
2026-07-11 10:25:14 -07:00

102 lines
3.3 KiB
TypeScript

// Codex tests cover harness plugin behavior.
import { describe, expect, it } from "vitest";
import { createCodexAppServerAgentHarness } from "./harness.js";
import {
createCodexTestBindingStore,
sessionBindingIdentity,
testCodexAppServerBindingStore,
} from "./src/app-server/session-binding.test-helpers.js";
describe("Codex agent harness supports()", () => {
const harness = createCodexAppServerAgentHarness({
bindingStore: testCodexAppServerBindingStore,
});
it("supports the canonical codex virtual provider", () => {
expect(harness.supports({ provider: "codex", requestedRuntime: "codex" })).toEqual({
supported: true,
priority: 100,
});
});
it("delegates locked-session execution only to the voice-call plugin", () => {
expect(harness.delegatedExecutionPluginIds).toEqual(["voice-call"]);
});
it("supports openai as the primary OpenClaw routing id", () => {
expect(harness.supports({ provider: "openai", requestedRuntime: "codex" })).toEqual({
supported: true,
priority: 100,
});
});
it("supports the canonical openai routing id (documented Codex path)", () => {
expect(harness.supports({ provider: "openai", requestedRuntime: "codex" })).toEqual({
supported: true,
priority: 100,
});
});
it("rejects providers Codex app-server cannot resolve from its own config", () => {
const result = harness.supports({ provider: "9router", requestedRuntime: "codex" });
expect(result.supported).toBe(false);
expect(!result.supported ? (result.reason ?? "") : "").toContain("codex");
});
it("normalizes provider casing", () => {
expect(harness.supports({ provider: "OpenAI", requestedRuntime: "codex" })).toEqual({
supported: true,
priority: 100,
});
});
it("honors explicit provider id overrides", () => {
const narrowHarness = createCodexAppServerAgentHarness({
providerIds: ["codex"],
bindingStore: testCodexAppServerBindingStore,
});
const result = narrowHarness.supports({ provider: "openai", requestedRuntime: "codex" });
expect(result.supported).toBe(false);
});
it("exposes the fail-closed exact runtime artifact validator", async () => {
if (!harness.runtimeArtifact) {
throw new Error("expected Codex runtime artifact capability");
}
await expect(
harness.runtimeArtifact.validate({
id: "codex-app-server:v1:malformed",
fingerprint: "0".repeat(64),
}),
).resolves.toBe(false);
});
});
describe("Codex agent harness reset()", () => {
it("retires the physical session generation", async () => {
const bindingStore = createCodexTestBindingStore();
const identity = sessionBindingIdentity({
agentId: "worker",
sessionId: "session-1",
sessionKey: "agent:worker:main",
});
await bindingStore.mutate(identity, {
kind: "set",
binding: { threadId: "thread-1", cwd: "/repo" },
});
const harness = createCodexAppServerAgentHarness({ bindingStore });
if (!harness.reset) {
throw new Error("expected Codex harness reset hook");
}
await harness.reset({
agentId: "worker",
sessionId: "session-1",
sessionKey: "agent:worker:main",
reason: "reset",
});
await expect(bindingStore.read(identity)).resolves.toBeUndefined();
});
});