



















@@ -13,8 +13,13 @@ const ensureCodexRuntimePluginForModelSelection = vi.hoisted(() =>
1313),
1414);
1515vi.mock("../../codex-runtime-plugin-install.js", () => ({
16+CODEX_RUNTIME_PLUGIN_ID: "codex",
1617 ensureCodexRuntimePluginForModelSelection,
1718}));
19+const offerPostInstallMigrations = vi.hoisted(() => vi.fn(async () => {}));
20+vi.mock("../../../wizard/setup.post-install-migration.js", () => ({
21+ offerPostInstallMigrations,
22+}));
1823const resolvePreferredProviderForAuthChoice = vi.hoisted(() => vi.fn(async () => undefined));
1924vi.mock("../../../plugins/provider-auth-choice-preference.js", () => ({
2025 resolvePreferredProviderForAuthChoice,
@@ -47,6 +52,7 @@ beforeEach(() => {
4752required: false,
4853installed: false,
4954}));
55+offerPostInstallMigrations.mockClear();
5056});
51575258function createRuntime() {
@@ -270,5 +276,40 @@ describe("applyNonInteractivePluginProviderChoice", () => {
270276expect(ensureInput.runtime).toBe(runtime);
271277expectWorkspaceDir(ensureInput.workspaceDir);
272278expect(result).toBe(installedConfig);
279+expect(offerPostInstallMigrations).toHaveBeenCalledOnce();
280+const migrationInput = mockArg(offerPostInstallMigrations);
281+expect(migrationInput.config).toBe(installedConfig);
282+expect(migrationInput.installedPluginIds).toEqual(["codex"]);
283+expect(migrationInput.nonInteractive).toBe(true);
284+});
285+286+it("does not offer post-install migration when Codex is not required for the selected model", async () => {
287+const runtime = createRuntime();
288+const selectedConfig = {
289+agents: { defaults: { model: { primary: "openai/gpt-5.5" } } },
290+} as OpenClawConfig;
291+const runNonInteractive = vi.fn(async () => selectedConfig);
292+ensureCodexRuntimePluginForModelSelection.mockResolvedValue({
293+cfg: selectedConfig,
294+required: false,
295+installed: false,
296+});
297+resolvePluginProviders.mockReturnValue([{ id: "openai", pluginId: "openai" }] as never);
298+resolveProviderPluginChoice.mockReturnValue({
299+provider: { id: "openai", pluginId: "openai", label: "OpenAI" },
300+method: { runNonInteractive },
301+});
302+303+await applyNonInteractivePluginProviderChoice({
304+nextConfig: { agents: { defaults: {} } } as OpenClawConfig,
305+authChoice: "openai-api-key",
306+opts: {} as never,
307+runtime: runtime as never,
308+baseConfig: { agents: { defaults: {} } } as OpenClawConfig,
309+resolveApiKey: vi.fn(),
310+toApiKeyCredential: vi.fn(),
311+});
312+313+expect(offerPostInstallMigrations).not.toHaveBeenCalled();
273314});
274315});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。