Files
OmniRoute/tests/unit/free-provider-onboarding-setup.test.ts
Tushar Agarwal 1089c24bc8 Remove/mimocode sunset provider (#10186)
* remove: drop sunset MiMoCode provider from model catalog

* remove: drop sunset MiMoCode provider from model catalog (shared.ts)

Remove unused imports, types, and comments from shared.ts.

* remove: MiMoCode provider (Xiaomi sunset) — executor, registry, no-auth config, icon, tests

* refactor(providers): finish MiMoCode removal — sweep remaining no-auth references

Drop the leftover mimocode entries from the no-auth provider controls, the
translate-path snapshot, the eslint suppressions, and the #3061 auth-loop
test. Re-point the fingerprint-pin (#6696) and proxy-noauth (#6272) tests at
opencode, which exercises the same fingerprint path, so the removal does not
break runtime behavior.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

* docs(providers): reconcile provider/executor counts after MiMoCode sunset

The base's parallel doc-count sync (#10433) pinned 340 providers / 101
executors. With mimocode removed, live code has 339 providers and 100
executors; refresh the user-facing counts (package.json description,
llm.txt, README/AGENTS, i18n llm.txt, provider reference, diagrams) so the
check-docs-counts STRICT gate stays green.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>

* test(providers): fix orphaned mimocode references after MiMoCode sunset

The sunset removed mimocode/mcode from the free-onboarding candidates and
from FINGERPRINT_PROVIDERS, but two tests still referenced them:

- free-provider-onboarding-setup: the mimocode->theoldllm substitution
  introduced duplicate 'opencode' rows (impossible given the request-set
  dedupe) and the wrong display name; align expectations with the actual
  {opencode, theoldllm} dedupe behavior and 'The Old LLM (Free)' name.
- combo-system-prompt-templates-5501: resolveTargetFingerprint tested with
  provider 'mcode', which is no longer a fingerprint provider; point it at
  the remaining fingerprint provider 'opencode'.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
Co-authored-by: Tushar49 <Tushar49@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: adevwithpurpose <adevwithpurpose@users.noreply.github.com>
Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>
2026-08-18 10:49:24 -03:00

90 lines
3.4 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import {
getEligibleFreeOnboardingProviders,
setupFreeProviderConnections,
} from "../../src/lib/providers/freeOnboarding.ts";
test("batch setup creates missing providers, skips existing ones, and is retry-safe", async () => {
const existing = [{ provider: "opencode", name: "My customized OpenCode" }];
const created: Array<{ provider: string; name: string }> = [];
const candidates = getEligibleFreeOnboardingProviders();
const requestedIds = ["opencode", "theoldllm"];
const first = await setupFreeProviderConnections({
requestedIds,
candidates,
listExisting: async () => [...existing, ...created],
create: async (input) => {
created.push({ provider: input.provider, name: input.name });
return { id: `created-${input.provider}` };
},
});
const second = await setupFreeProviderConnections({
requestedIds,
candidates,
listExisting: async () => [...existing, ...created],
create: async (input) => {
created.push({ provider: input.provider, name: input.name });
return { id: `created-${input.provider}` };
},
});
assert.deepEqual(first.results, [
{ providerId: "opencode", status: "skipped", reason: "already-configured" },
{ providerId: "theoldllm", status: "created", connectionId: "created-theoldllm" },
]);
assert.deepEqual(second.results, [
{ providerId: "opencode", status: "skipped", reason: "already-configured" },
{ providerId: "theoldllm", status: "skipped", reason: "already-configured" },
]);
assert.deepEqual(existing, [{ provider: "opencode", name: "My customized OpenCode" }]);
assert.deepEqual(created, [{ provider: "theoldllm", name: "The Old LLM (Free)" }]);
});
test("batch setup rejects unknown or ineligible IDs before creating anything", async () => {
let createCalls = 0;
await assert.rejects(
setupFreeProviderConnections({
requestedIds: ["openai", "missing-provider"],
candidates: getEligibleFreeOnboardingProviders(),
listExisting: async () => [],
create: async () => {
createCalls += 1;
return { id: "unexpected" };
},
}),
/Ineligible free provider IDs: missing-provider, openai/
);
assert.equal(createCalls, 0);
});
test("partial failures are reported per provider and can be retried", async () => {
const created = new Set<string>();
let oldllmAttempts = 0;
const input = {
requestedIds: ["opencode", "theoldllm"],
candidates: getEligibleFreeOnboardingProviders(),
listExisting: async () => [...created].map((provider) => ({ provider })),
create: async ({ provider }: { provider: string }) => {
if (provider === "theoldllm" && oldllmAttempts++ === 0) throw new Error("upstream detail");
created.add(provider);
return { id: `created-${provider}` };
},
};
const first = await setupFreeProviderConnections(input);
const retry = await setupFreeProviderConnections(input);
assert.deepEqual(first.results, [
{ providerId: "opencode", status: "created", connectionId: "created-opencode" },
{ providerId: "theoldllm", status: "failed", reason: "Failed to create provider" },
]);
assert.deepEqual(retry.results, [
{ providerId: "opencode", status: "skipped", reason: "already-configured" },
{ providerId: "theoldllm", status: "created", connectionId: "created-theoldllm" },
]);
});