From 646e271c72dc96a91df1ee96f104e0b2d6fb6b57 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 4 Apr 2026 02:29:00 +0900 Subject: [PATCH] test(contracts): split provider wizard lanes --- .../wizard.choice-resolution.contract.test.ts | 3 + .../wizard.model-picker.contract.test.ts | 3 + .../wizard.setup-options.contract.test.ts | 3 + .../provider-wizard-contract-suites.ts | 104 ++++++++++-------- 4 files changed, 66 insertions(+), 47 deletions(-) create mode 100644 src/plugins/contracts/wizard.choice-resolution.contract.test.ts create mode 100644 src/plugins/contracts/wizard.model-picker.contract.test.ts create mode 100644 src/plugins/contracts/wizard.setup-options.contract.test.ts rename src/plugins/contracts/wizard.contract.test.ts => test/helpers/plugins/provider-wizard-contract-suites.ts (67%) diff --git a/src/plugins/contracts/wizard.choice-resolution.contract.test.ts b/src/plugins/contracts/wizard.choice-resolution.contract.test.ts new file mode 100644 index 00000000000..9ef4151fcbb --- /dev/null +++ b/src/plugins/contracts/wizard.choice-resolution.contract.test.ts @@ -0,0 +1,3 @@ +import { describeProviderWizardChoiceResolutionContract } from "../../../test/helpers/plugins/provider-wizard-contract-suites.js"; + +describeProviderWizardChoiceResolutionContract(); diff --git a/src/plugins/contracts/wizard.model-picker.contract.test.ts b/src/plugins/contracts/wizard.model-picker.contract.test.ts new file mode 100644 index 00000000000..9300bcce969 --- /dev/null +++ b/src/plugins/contracts/wizard.model-picker.contract.test.ts @@ -0,0 +1,3 @@ +import { describeProviderWizardModelPickerContract } from "../../../test/helpers/plugins/provider-wizard-contract-suites.js"; + +describeProviderWizardModelPickerContract(); diff --git a/src/plugins/contracts/wizard.setup-options.contract.test.ts b/src/plugins/contracts/wizard.setup-options.contract.test.ts new file mode 100644 index 00000000000..2ace6e2adfc --- /dev/null +++ b/src/plugins/contracts/wizard.setup-options.contract.test.ts @@ -0,0 +1,3 @@ +import { describeProviderWizardSetupOptionsContract } from "../../../test/helpers/plugins/provider-wizard-contract-suites.js"; + +describeProviderWizardSetupOptionsContract(); diff --git a/src/plugins/contracts/wizard.contract.test.ts b/test/helpers/plugins/provider-wizard-contract-suites.ts similarity index 67% rename from src/plugins/contracts/wizard.contract.test.ts rename to test/helpers/plugins/provider-wizard-contract-suites.ts index 261977e7da6..0e126e56d32 100644 --- a/src/plugins/contracts/wizard.contract.test.ts +++ b/test/helpers/plugins/provider-wizard-contract-suites.ts @@ -4,12 +4,12 @@ import { resolveProviderModelPickerEntries, resolveProviderPluginChoice, resolveProviderWizardOptions, -} from "../provider-wizard.js"; -import type { ProviderAuthMethod, ProviderPlugin } from "../types.js"; +} from "../../../src/plugins/provider-wizard.js"; +import type { ProviderAuthMethod, ProviderPlugin } from "../../../src/plugins/types.js"; const resolvePluginProvidersMock = vi.fn(); -vi.mock("../providers.runtime.js", () => ({ +vi.mock("../../../src/plugins/providers.runtime.js", () => ({ resolvePluginProviders: (...args: unknown[]) => resolvePluginProvidersMock(...args), })); @@ -171,58 +171,68 @@ function expectAllChoicesResolve( ).toBe(true); } -describe("provider wizard contract", () => { - beforeEach(() => { - resolvePluginProvidersMock.mockReset(); - resolvePluginProvidersMock.mockReturnValue(TEST_PROVIDERS); - }); +beforeEach(() => { + resolvePluginProvidersMock.mockReset(); + resolvePluginProvidersMock.mockReturnValue(TEST_PROVIDERS); +}); - it("exposes every wizard setup choice through the shared wizard layer", () => { - const options = resolveProviderWizardOptions({ - config: { - plugins: { - enabled: true, - allow: TEST_PROVIDER_IDS, - slots: { - memory: "none", +export function describeProviderWizardSetupOptionsContract() { + describe("provider wizard setup options contract", () => { + it("exposes every wizard setup choice through the shared wizard layer", () => { + const options = resolveProviderWizardOptions({ + config: { + plugins: { + enabled: true, + allow: TEST_PROVIDER_IDS, + slots: { + memory: "none", + }, }, }, - }, - env: process.env, + env: process.env, + }); + + expect(sortedValues(options.map((option) => option.value))).toEqual( + resolveExpectedWizardChoiceValues(TEST_PROVIDERS), + ); + expectUniqueValues(options.map((option) => option.value)); }); - - expect(sortedValues(options.map((option) => option.value))).toEqual( - resolveExpectedWizardChoiceValues(TEST_PROVIDERS), - ); - expectUniqueValues(options.map((option) => option.value)); }); +} - it("round-trips every shared wizard choice back to its provider and auth method", () => { - const options = resolveProviderWizardOptions({ config: {}, env: process.env }); +export function describeProviderWizardChoiceResolutionContract() { + describe("provider wizard choice resolution contract", () => { + it("round-trips every shared wizard choice back to its provider and auth method", () => { + const options = resolveProviderWizardOptions({ config: {}, env: process.env }); - expectAllChoicesResolve( - options.map((option) => option.value), - (choice) => - resolveProviderPluginChoice({ - providers: TEST_PROVIDERS, - choice, - }), - ); + expectAllChoicesResolve( + options.map((option) => option.value), + (choice) => + resolveProviderPluginChoice({ + providers: TEST_PROVIDERS, + choice, + }), + ); + }); }); +} - it("exposes every model-picker entry through the shared wizard layer", () => { - const entries = resolveProviderModelPickerEntries({ config: {}, env: process.env }); +export function describeProviderWizardModelPickerContract() { + describe("provider wizard model picker contract", () => { + it("exposes every model-picker entry through the shared wizard layer", () => { + const entries = resolveProviderModelPickerEntries({ config: {}, env: process.env }); - expect(sortedValues(entries.map((entry) => entry.value))).toEqual( - resolveExpectedModelPickerValues(TEST_PROVIDERS), - ); - expectAllChoicesResolve( - entries.map((entry) => entry.value), - (choice) => - resolveProviderPluginChoice({ - providers: TEST_PROVIDERS, - choice, - }), - ); + expect(sortedValues(entries.map((entry) => entry.value))).toEqual( + resolveExpectedModelPickerValues(TEST_PROVIDERS), + ); + expectAllChoicesResolve( + entries.map((entry) => entry.value), + (choice) => + resolveProviderPluginChoice({ + providers: TEST_PROVIDERS, + choice, + }), + ); + }); }); -}); +}