Files
OmniRoute/tests/unit/puter-provider-removed.test.ts
Diego Rodrigues de Sa e Souza f1eb0b8357 refactor(providers): remove the Puter provider at its owner's request (#10210)
Remove the Puter provider (id `puter`, alias `pu`) entirely, at the
request of Puter's owner, Nariman Jelveh:

- registry entry (open-sse/config/providers/registry/puter/) and
  PuterExecutor (open-sse/executors/puter.ts), with their registrations
- API-key preset card (gateways.ts), provider icon and public SVG asset
- 33 free-model catalog entries (pool `puter`)
- authHint i18n key across all 43 UI locales
- credential-requirement frozen-list entry and related comments
- docs: ARCHITECTURE, CODEBASE_DOCUMENTATION, FREE_TIERS (removal note),
  PROVIDER_REFERENCE regenerated (337 providers), translated doc mirrors,
  llm.txt + its 42 i18n mirrors, README/AGENTS/package.json counts
  (338→337 providers, 144→145 migrations) and the 5 canonical SVGs
- migration 152 cleans up stored puter connections/keys/custom models;
  historical usage records are preserved (same principle as migration 151)
- regression guard: tests/unit/puter-provider-removed.test.ts; puter
  fixtures in shared tests swapped for neutral providers; translate-path
  golden snapshot regenerated

Historical CHANGELOG mentions are intentionally preserved; the removal
carries its own CHANGELOG entry.

Co-authored-by: backryun <bakryun0718@proton.me>
2026-08-12 16:54:50 -03:00

78 lines
3.2 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-puter-removed-"));
process.env.DATA_DIR = TEST_DATA_DIR;
const { REGISTRY } = await import("../../open-sse/config/providerRegistry.ts");
const { APIKEY_PROVIDERS } = await import("../../src/shared/constants/providers.ts");
const { FREE_MODEL_BUDGETS } = await import("../../open-sse/config/freeModelCatalog.data.ts");
const { hasSpecializedExecutor } = await import("../../open-sse/executors/index.ts");
const core = await import("../../src/lib/db/core.ts");
// Regression guard: the Puter provider (id `puter`, alias `pu`,
// https://puter.com) was removed at the request of Puter's owner
// (Nariman Jelveh). It must stay out of every provider catalog, the
// executor map, and the free model catalog, and migration 152 must clean
// up any locally stored Puter configuration.
test.after(() => {
core.resetDbInstance();
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true });
});
test("puter provider is removed from the chat registry (id and alias)", () => {
assert.equal(REGISTRY["puter"], undefined);
assert.equal(REGISTRY["pu"], undefined);
});
test("puter provider is removed from the API-key provider presets", () => {
assert.equal((APIKEY_PROVIDERS as Record<string, unknown>)["puter"], undefined);
});
test("puter has no entries in the free model catalog", () => {
const offenders = FREE_MODEL_BUDGETS.filter((b) => b.provider === "puter");
assert.deepEqual(offenders, []);
});
test("puter executor is removed from the executor map (id and alias)", () => {
assert.equal(hasSpecializedExecutor("puter"), false);
assert.equal(hasSpecializedExecutor("pu"), false);
});
test("migration 152 deletes stored puter configuration and is idempotent", () => {
const db = core.getDbInstance();
const applied = db
.prepare("SELECT version FROM _omniroute_migrations WHERE version = 152")
.get() as { version: number } | undefined;
assert.ok(applied, "migration 152 must be recorded as applied");
// Simulate a pre-removal install that still has Puter configuration, then
// re-apply the migration SQL and assert every row is cleaned up.
db.prepare(
"INSERT INTO provider_connections (id, provider, auth_type, name, is_active, created_at, updated_at) VALUES (?, ?, ?, ?, 1, datetime('now'), datetime('now'))"
).run("puter-conn-test", "puter", "apikey", "puter-main");
db.prepare(
"INSERT INTO key_value (namespace, key, value) VALUES ('customModels', 'puter', '[]')"
).run();
const sql = fs.readFileSync(
path.join(process.cwd(), "src/lib/db/migrations/152_remove_puter_provider.sql"),
"utf8"
);
db.exec(sql);
db.exec(sql); // idempotent — a second run must not throw
const conn = db.prepare("SELECT id FROM provider_connections WHERE provider = 'puter'").get();
assert.equal(conn, undefined, "puter provider_connections rows must be deleted");
const custom = db
.prepare("SELECT key FROM key_value WHERE namespace = 'customModels' AND key = 'puter'")
.get();
assert.equal(custom, undefined, "puter custom models must be deleted");
});