openclaw/test/plugins/codex-model-runtime-choice.test.ts
Peter Steinberger 94cbbecd46
test(ci,gateway,integration): remove low-value tests (batch d151) (#163532)
* test(ci): deslop s1016 tests

* test(gateway): deslop s842 tests

Port s842 commits 77c589897919272a876fe407c3b567a26ee4df11 and
9cccf18820d7eb027e39ed7f22f94a99a29d647f onto the campaign lane.
The abort fixture fixes are already present on the lane.

Consolidate yield setup while preserving HEAD's eight yield/resume cases,
transactional pause, requester retirement, acknowledgement recovery, and
unknown-write reconciliation assertions. Apply the shard's dispatch and
approval replay cleanup to files unchanged since its parent.

Validation: Testbox on origin/main baa26a6ad5
plus all five resolved shard files: 5 files, 25 tests passed, no skips,
82.86s Vitest duration. No timeouts raised. oxlint, oxfmt --check,
git diff --check, and independent review passed.

* test(tooling): deslop s1009 tests

* test(integration): deslop s1007 tests

* test(helpers): deslop s1010 tests

* test(plugins): deslop s1011 tests

* test(integration): deslop s1006 tests

* test(scripts): deslop s1022 tests

* test(scripts): deslop s1021 tests

* test(plugins): deslop s1012 tests
2026-10-02 13:03:08 +00:00

74 lines
3.2 KiB
TypeScript

import { fileURLToPath } from "node:url";
import { createTestPluginApi } from "openclaw/plugin-sdk/plugin-test-api";
import { createPluginRuntimeMock } from "openclaw/plugin-sdk/plugin-test-runtime";
import { describe, expect, it, onTestFinished } from "vitest";
import codexPlugin from "../../extensions/codex/index.js";
import {
dualRoutes,
routeResolverFactory,
} from "../../src/agents/model-auth-availability.test-support.js";
import { createModelCatalogDecisions } from "../../src/agents/model-catalog-decisions.js";
import type { OpenClawConfig } from "../../src/config/types.openclaw.js";
import { createPluginMetadataSnapshotFixture } from "../../src/plugins/plugin-metadata.test-support.js";
import { createEmptyPluginRegistry } from "../../src/plugins/registry-empty.js";
import { withOpenClawTestState } from "../../src/test-utils/openclaw-test-state.js";
describe("registered Codex runtime choices", () => {
it.each(["api_key", "oauth"] as const)(
"keeps native %s authentication with its registered harness",
async (mode) => {
await withOpenClawTestState(
{ layout: "state-only", prefix: "native-choice-" },
async (state) => {
const config: OpenClawConfig = {
plugins: { entries: { codex: { enabled: true } } },
agents: {
defaults: { models: { "openai/gpt-5.5": { agentRuntime: { id: "codex" } } } },
},
};
const registry = createEmptyPluginRegistry();
codexPlugin.register(
createTestPluginApi({
id: "codex",
rootDir: fileURLToPath(new URL("../../extensions/codex/", import.meta.url)),
config,
runtime: createPluginRuntimeMock({ config: { current: () => config } }),
registerAgentHarness: (harness) => {
registry.agentHarnesses.push({ pluginId: "codex", source: "test", harness });
onTestFinished(() => harness.dispose?.());
},
}),
);
const entry = { provider: "openai", id: "gpt-5.5", name: "GPT-5.5" };
const params = {
cfg: config,
agentId: "main",
agentDir: state.agentDir(),
workspaceDir: state.workspaceDir,
snapshot: { entries: [entry], routeVariants: [entry] },
metadataSnapshot: createPluginMetadataSnapshotFixture({
plugins: [{ id: "codex", providers: ["codex"], syntheticAuthRefs: ["codex"] }],
}),
preparedAuthStore: { version: 1, profiles: {} },
preparedSyntheticAuthComplete: true,
pluginRegistry: registry,
isCurrent: () => true,
routeResolverFactory: routeResolverFactory(dualRoutes),
};
const owner = createModelCatalogDecisions({
...params,
preparedRuntimeAuthModes: { codex: { source: "native", mode } },
});
expect(await owner.runtimeChoices(entry)).toEqual(["codex"]);
expect(
await createModelCatalogDecisions({
...params,
preparedRuntimeAuthModes: {},
}).runtimeChoices(entry),
).toEqual([]);
},
);
},
);
});