Files
OmniRoute/tests/unit/keepalive-threshold.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

82 lines
3.0 KiB
TypeScript

/**
* Adaptive keepalive threshold — Unit Tests (PR5 of issue #3368)
*
* Run: node --import tsx/esm --test tests/unit/keepalive-threshold.test.ts
*/
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import {
resolveKeepaliveThreshold,
SLOW_KEEPALIVE_PROVIDERS,
} from "../../open-sse/utils/keepaliveThreshold.ts";
describe("resolveKeepaliveThreshold", () => {
it("returns 2000ms default for undefined model", () => {
assert.equal(resolveKeepaliveThreshold(undefined), 2000);
});
it("returns 2000ms default for null model", () => {
assert.equal(resolveKeepaliveThreshold(null), 2000);
});
it("returns 2000ms default for empty string", () => {
assert.equal(resolveKeepaliveThreshold(""), 2000);
});
it("returns 2000ms default for model without prefix", () => {
assert.equal(resolveKeepaliveThreshold("gpt-4"), 2000);
});
it("returns 2000ms default for normal API-key provider", () => {
assert.equal(resolveKeepaliveThreshold("openai/gpt-4"), 2000);
assert.equal(resolveKeepaliveThreshold("anthropic/claude-sonnet-4"), 2000);
assert.equal(resolveKeepaliveThreshold("deepseek/deepseek-chat"), 2000);
});
it("returns 15000ms for anonymous fallback provider (pollinations)", () => {
assert.equal(resolveKeepaliveThreshold("pollinations/gpt-5"), 15000);
});
it("returns 15000ms for anonymous fallback provider alias (pol)", () => {
assert.equal(resolveKeepaliveThreshold("pol/gpt-5"), 15000);
});
it("returns 15000ms for anonymous fallback provider (opencode-zen)", () => {
assert.equal(resolveKeepaliveThreshold("opencode-zen/gpt-4"), 15000);
});
it("uses a longer threshold for clean-room ChatGPT Web but not its retired alias", () => {
assert.equal(resolveKeepaliveThreshold("chatgpt-web/gpt-5"), 15000);
assert.equal(resolveKeepaliveThreshold("cgpt-web/gpt-5"), 2000);
});
it("keeps the longer threshold for ChatGPT Web Codex", () => {
assert.equal(resolveKeepaliveThreshold("chatgpt-web-codex/high"), 15000);
});
it("returns 15000ms for web-session provider (grok-web)", () => {
assert.equal(resolveKeepaliveThreshold("grok-web/grok-4"), 15000);
});
it("returns 15000ms for web-session provider (claude-web)", () => {
assert.equal(resolveKeepaliveThreshold("claude-web/claude-sonnet-4"), 15000);
});
it("SLOW_KEEPALIVE_PROVIDERS set contains expected providers", () => {
assert.ok(SLOW_KEEPALIVE_PROVIDERS.has("pollinations"));
assert.ok(SLOW_KEEPALIVE_PROVIDERS.has("pol"));
assert.ok(SLOW_KEEPALIVE_PROVIDERS.has("opencode-zen"));
assert.ok(SLOW_KEEPALIVE_PROVIDERS.has("chatgpt-web"));
assert.ok(SLOW_KEEPALIVE_PROVIDERS.has("chatgpt-web-codex"));
assert.ok(SLOW_KEEPALIVE_PROVIDERS.has("grok-web"));
assert.ok(SLOW_KEEPALIVE_PROVIDERS.has("claude-web"));
});
it("SLOW_KEEPALIVE_PROVIDERS does not contain normal providers", () => {
assert.ok(!SLOW_KEEPALIVE_PROVIDERS.has("openai"));
assert.ok(!SLOW_KEEPALIVE_PROVIDERS.has("anthropic"));
assert.ok(!SLOW_KEEPALIVE_PROVIDERS.has("deepseek"));
});
});