mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-20 14:12:59 +03:00
fix(tests): drain three base-reds left by the SSE-comment default and a locale gap (#10704)
* fix(tests): drain three base-reds left by the SSE-comment default and a locale gap All three reproduce on a pristine tip; none is caused by the branch that found them. 1. i18n vi — six keys landed in en.json without a Vietnamese counterpart (settings.reasoningTokenBuffer*, settings.zeroLatencyOptimizations*, settings.compressionOutputStyle.i-have-adhd.*). The vi locale is held to strict parity, so the whole i18n-vi suite went red. Translated; no existing key reordered. 2. chatcore-translation-paths — #10539 flipped OMNIROUTE_SSE_COMMENTS to off-by-default and updated three sibling tests, but not this one, which asserted the `: x-omniroute-*` trailer is emitted. The test now asserts the current contract (stream is comment-free, still ends with [DONE], metadata still travels in the X-OmniRoute-* headers). The opt-in half stays covered by sse-comments-optout-9305.test.ts, which drives the env var through all three states. Enabling the flag inside this file instead leaks process.env into its sibling call-log tests, which is how the first attempt turned one red into a different one. 3. chat-messages-validation-6402 — all nine Antigravity cases asserted `assert.match(body, /ok/)` against the mocked model output. That text never reached this layer: the match only ever succeeded on the "ok" inside `: x-omniroute-tokens-in=0`, an SSE comment trailer. When the trailers stopped being emitted the coincidence broke, not the behavior — bisected to6b823aa441, whose parent6d99a46d4bpasses. The test now asserts the guard it is named for (a cloudcode envelope must not be rejected by the #6402 missing-messages validator). Real content-relay coverage for this provider lives in antigravity-streaming-passthrough.test.ts, which passes. Verified: vi 5/5, chatcore-translation-paths 70/70, chat-messages-validation 14/14. * chore(changelog): correct the fragment to the real PR number (#10704) --------- Co-authored-by: Xiangzhe <bakryun0718@proton.me>
This commit is contained in:
committed by
GitHub
parent
c98045652d
commit
c8d531de0d
@@ -171,8 +171,22 @@ for (const model of ANTIGRAVITY_GEMINI_MODELS) {
|
||||
assert.equal(upstreamCalled, true, "Antigravity request should reach the upstream executor");
|
||||
assert.equal(response.status, 200, "Antigravity cloudcode envelopes must not return 400");
|
||||
|
||||
// This assertion is the guard the test is named for: a cloudcode envelope has no
|
||||
// `messages` key, so it must not be rejected by the #6402 validator.
|
||||
//
|
||||
// It used to read `assert.match(body, /ok/)`, aimed at the mocked upstream's
|
||||
// "ok" text — but that text never reached this layer. The match only ever
|
||||
// succeeded on the "ok" inside `: x-omniroute-tokens-in=0`, an SSE *comment*
|
||||
// trailer. When #10539 flipped OMNIROUTE_SSE_COMMENTS to off-by-default the
|
||||
// trailers stopped being emitted, the body went empty, and the coincidence —
|
||||
// not the behavior — broke. Content relay for this provider is covered for
|
||||
// real, at the executor level, by antigravity-streaming-passthrough.test.ts.
|
||||
const body = await response.text();
|
||||
assert.match(body, /ok/);
|
||||
assert.doesNotMatch(
|
||||
body,
|
||||
/messages.*Expected array/i,
|
||||
"cloudcode envelope must not be caught by the missing-messages guard"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2597,7 +2597,7 @@ test("chatCore injects progress events into streaming responses when requested",
|
||||
assert.equal(result.response.headers.get("X-OmniRoute-Progress"), "enabled");
|
||||
assert.match(streamText, /event: progress/);
|
||||
});
|
||||
test("chatCore emits final SSE metadata comments before [DONE] on streaming responses", async () => {
|
||||
test("chatCore keeps the SSE stream comment-free by default and still ends with [DONE]", async () => {
|
||||
const { result } = await invokeChatCore({
|
||||
provider: "openai",
|
||||
model: "gpt-4o-mini",
|
||||
@@ -2615,14 +2615,20 @@ test("chatCore emits final SSE metadata comments before [DONE] on streaming resp
|
||||
const streamText = await result.response.text();
|
||||
|
||||
assert.equal(result.success, true);
|
||||
// The per-request metadata reaches the client through these headers regardless
|
||||
// of the comment setting — that is what makes the trailer optional.
|
||||
assert.equal(result.response.headers.get("X-OmniRoute-Provider"), "openai");
|
||||
assert.equal(result.response.headers.get("X-OmniRoute-Model"), "gpt-4o-mini");
|
||||
assert.match(streamText, /: x-omniroute-response-cost=\d+\.\d{10}/);
|
||||
assert.match(streamText, /: x-omniroute-tokens-in=\d+/);
|
||||
assert.match(streamText, /: x-omniroute-tokens-out=\d+/);
|
||||
assert.ok(
|
||||
streamText.indexOf(": x-omniroute-response-cost=") < streamText.indexOf("data: [DONE]")
|
||||
);
|
||||
|
||||
// #10524 flipped OMNIROUTE_SSE_COMMENTS to off-by-default: strict SSE clients
|
||||
// JSON.parse every line and crash on `: x-omniroute-*` comments. This test used
|
||||
// to assert the opposite and went red on the release branch when that default
|
||||
// landed. The opt-in half — trailer present, after the finish chunk and before
|
||||
// [DONE] — is owned by sse-comments-optout-9305.test.ts, which drives the env
|
||||
// var through all three states; enabling it here instead leaks process.env into
|
||||
// the sibling call-log tests in this file.
|
||||
assert.doesNotMatch(streamText, /: x-omniroute-/);
|
||||
assert.match(streamText, /data: \[DONE\]/);
|
||||
});
|
||||
test("buildStreamingResponseHeaders drops upstream compression and framing headers", () => {
|
||||
const headers = new Headers(
|
||||
|
||||
Reference in New Issue
Block a user