Files
OmniRoute/tests/unit/resolve-web-provider-host.test.ts
backryun 7ed8ada432 feat(providers): restore ChatGPT Web via clean-room browser transport (#12239)
Restores ChatGPT Web on a clean-room browser transport, merged on the operator's explicit decision.

Worth stating precisely, because this touches a provenance decision: the PR does not revert #11754. It narrows RETIRED_COMMON_CHATGPT_WEB_PROVIDER_IDS to the single GPL-derived alias cgpt-web and registers chatgpt-web as a separate clean-room id. The old implementation stays retired and blocked; the retirement machinery, its error code and its 410 contract are untouched. All four retirement suites agree with that distinction and pass unchanged.

The 44 protected agent-instruction surfaces this PR touches (AGENTS.md, llm.txt and its 42 mirrors, README) were verified rather than trusted: masking digits and comparing the removed and added line sets gives 264 lines on each side, identical — every change is a provider-count substitution, with no sentence added, removed or reworded.

Reconciled on merge: clean against the tip, with the two chat chokepoints this PR grows (src/sse/handlers/chat.ts +40, open-sse/handlers/chatCore.ts +30) recorded in the file-size baseline under an annotation. Verified that exactly those two caps move and nothing else, so the #12411 ratchet holds. The rebaseline is carried on this branch rather than left in a validation worktree — the propagation mistake that put the 2026-09-02 merge waves base-red in #12434.

Verified: 504/504 across the PR's 44 test files plus all four chatgpt-web retirement suites, check:provider-consistency OK (272 REGISTRY entries, 355 canonical providers), check-file-size OK, and every changed TypeScript file parses.

Thanks @backryun — separating the clean-room id from the retired alias, instead of reopening the old one, is what made this reviewable.
2026-09-02 10:31:41 -03:00

62 lines
2.6 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { test } from "node:test";
import assert from "node:assert/strict";
import {
resolveWebProviderHost,
WEB_COOKIE_PROVIDERS,
} from "@/shared/constants/providers/web-cookie";
// Feature #6268 — "Open host →" link in the "Add session cookie" modal.
// Pure host-resolution helper backing the modal link.
test("known -web provider returns the host derived from its `website`", () => {
const link = resolveWebProviderHost("perplexity-web");
assert.ok(link, "expected a resolved link for perplexity-web");
// perplexity-web's registered website is "https://www.perplexity.ai", and
// resolveWebProviderHost returns URL.host verbatim (no www-stripping), so
// both host and url carry the "www." prefix.
assert.equal(link.host, "www.perplexity.ai");
assert.equal(link.url, "https://www.perplexity.ai");
});
test("clean-room ChatGPT Web resolves its host while the legacy alias stays retired", () => {
assert.equal(resolveWebProviderHost("chatgpt-web")?.host, "chatgpt.com");
assert.equal(resolveWebProviderHost("cgpt-web"), null);
assert.equal(resolveWebProviderHost("chatgpt-web-codex")?.host, "chatgpt.com");
});
test("website with a path keeps the full URL but exposes the bare host", () => {
// huggingchat's website is https://huggingface.co/chat
const link = resolveWebProviderHost("huggingchat");
assert.ok(link);
assert.equal(link.host, "huggingface.co");
assert.equal(link.url, "https://huggingface.co/chat");
});
test("provider with no `website` but a registry baseUrl returns the origin", () => {
// duckduckgo-web is a real web-session provider that is NOT in
// WEB_COOKIE_PROVIDERS and has no `website`; the caller supplies its registry
// baseUrl as a fallback, from which only the origin is kept.
assert.equal(
(WEB_COOKIE_PROVIDERS as Record<string, unknown>)["duckduckgo-web"],
undefined,
"test premise: duckduckgo-web must be absent from WEB_COOKIE_PROVIDERS"
);
const link = resolveWebProviderHost("duckduckgo-web", "https://duckduckgo.com/duckchat/v1/chat");
assert.ok(link);
assert.equal(link.host, "duckduckgo.com");
assert.equal(link.url, "https://duckduckgo.com");
});
test("non-web / unknown provider returns null", () => {
assert.equal(resolveWebProviderHost("openai"), null);
assert.equal(resolveWebProviderHost("totally-made-up"), null);
assert.equal(resolveWebProviderHost(null), null);
assert.equal(resolveWebProviderHost(undefined), null);
assert.equal(resolveWebProviderHost(""), null);
});
test("unparseable fallback baseUrl yields null instead of throwing", () => {
assert.equal(resolveWebProviderHost("duckduckgo-web", "not a url"), null);
});