Files
OmniRoute/tests/unit/8676-monsterapi-deprecation.test.ts
Paco Cartones dd4a33d1d8 fix(providers): make the monsterapi deprecation from #8676 actually apply (#10234)
* fix(providers): make the monsterapi deprecation from #8676 actually apply

#8676 marked MonsterAPI deprecated after its domain stopped resolving, but
wrote the flag as `isDeprecated`. Nothing reads that key. The field the
codebase consumes is `deprecated`:

  src/shared/validation/providerSchema.ts   declares `deprecated`
  ProviderCard.tsx                          strikethrough + block icon + reason
  ProviderTestSlideOver.tsx                 warning
  providerOnboardingCatalog.ts              Boolean(provider.deprecated), sorts last
  ProviderOnboardingWizard.tsx              deprecated badge
  scripts/docs/gen-provider-reference.ts    gates the DEPRECATED note

Zod object schemas ignore undeclared keys, so `isDeprecated` never failed
validation - it was dropped silently. The deprecation therefore had no effect
anywhere, and tests/unit/8676-monsterapi-deprecation.test.ts asserted the same
unread key, so it stayed green while guarding nothing.

The committed docs/reference/PROVIDER_REFERENCE.md is the visible proof: the
generator renders predibase (which uses `deprecated`) with a DEPRECATED note,
while monsterapi still advertised "Get API key at monsterapi.ai" - a domain
that does not resolve (probed 2026-08-13: api.monsterapi.ai and monsterapi.ai
both 000, against api.openai.com 401 as a reachability control).

Rename the key, repair the regression test to assert the consumed field and to
reject the undeclared one, and refresh the generated reference row.

* fix(providers): name the changelog fragment for PR #10234

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

---------

Co-authored-by: pacocartones <pacocartones@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: adevwithpurpose <adevwithpurpose@users.noreply.github.com>
2026-08-16 00:14:20 -03:00

65 lines
3.2 KiB
TypeScript

import assert from "node:assert/strict";
import { test } from "node:test";
import { APIKEY_PROVIDERS_INFERENCE } from "../../src/shared/constants/providers/apikey/inference-hosts.ts";
/**
* #8676 deprecated MonsterAPI after its domain stopped resolving, but wrote the flag
* as `isDeprecated` — a key no schema declares and no consumer reads. The catalog
* field the codebase actually consumes is `deprecated`:
*
* src/shared/validation/providerSchema.ts declares `deprecated`, not `isDeprecated`
* ProviderCard.tsx `provider.deprecated` (strikethrough + block icon)
* ProviderTestSlideOver.tsx `provider.deprecated` (warning)
* providerOnboardingCatalog.ts `Boolean(provider.deprecated)` + sorts last
* ProviderOnboardingWizard.tsx `option.deprecated` (badge)
* scripts/docs/gen-provider-reference.ts `p.deprecated` gates the DEPRECATED note
*
* Because Zod object schemas ignore undeclared keys, `isDeprecated` never failed
* validation — it was silently dropped, so the deprecation had no effect anywhere
* while this test stayed green.
*
* Upstream state re-probed 2026-08-13, with paired controls:
* GET https://api.monsterapi.ai/v1/chat/completions -> 000 (does not resolve)
* GET https://monsterapi.ai -> 000 (does not resolve)
* GET https://api.openai.com/v1/models -> 401 (control: reachable)
* GET https://<nonexistent-domain> -> 000 (control: unreachable)
*/
test("Monster API provider is marked as deprecated (fixes #8676)", () => {
const monsterEntry = APIKEY_PROVIDERS_INFERENCE.monsterapi as Record<string, unknown>;
assert.ok(monsterEntry, "monsterapi entry must exist in APIKEY_PROVIDERS_INFERENCE");
assert.equal(
monsterEntry.deprecated,
true,
"monsterapi must set `deprecated` — the field every consumer and the Zod schema read"
);
assert.ok(
typeof monsterEntry.deprecationReason === "string",
"monsterapi must specify deprecationReason"
);
});
test("Monster API deprecation uses no undeclared flag name (#8676)", () => {
const monsterEntry = APIKEY_PROVIDERS_INFERENCE.monsterapi as Record<string, unknown>;
assert.equal(
"isDeprecated" in monsterEntry,
false,
"`isDeprecated` is read by nothing and silently dropped by the provider schema — " +
"the consumed field is `deprecated`"
);
});
test("Monster API deprecation matches the flag shape of its sibling entries (#8676)", () => {
// predibase, in this same catalog, is the reference implementation: its `deprecated`
// flag is what makes the generated PROVIDER_REFERENCE.md render its DEPRECATED note.
const monsterEntry = APIKEY_PROVIDERS_INFERENCE.monsterapi as Record<string, unknown>;
const predibaseEntry = APIKEY_PROVIDERS_INFERENCE.predibase as Record<string, unknown>;
assert.equal(predibaseEntry.deprecated, true, "predibase is the in-file reference for the flag");
for (const field of ["deprecated", "deprecationReason"]) {
assert.equal(
typeof monsterEntry[field],
typeof predibaseEntry[field],
`monsterapi must declare ${field} the same way predibase does`
);
}
});