Files
OmniRoute/tests/unit/t19-codex-responses-empty-content.test.ts
Diego Rodrigues de Sa e Souza 7c23dab64d Release v3.8.40
v3.8.40 cycle integration → main. All test gates green (Unit/Integration/Coverage/Node-compat/Quality-Ratchet). The only red check, 'PR Test Policy', is the test-masking heuristic firing on the cumulative ~57-commit release diff (legitimate assert consolidations already reviewed per-PR — Gemini CLI removal #5246, retired GPT models #5280, provider catalog refreshes); overridden with --admin per the documented release-PR convention. CodeQL/SonarQube advisory scans non-blocking; #5278's code already passed CodeQL on main. Homologated on VPS 192.168.0.15 (v3.8.40 healthy).
2026-06-29 08:40:06 -03:00

67 lines
1.7 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
const { translateNonStreamingResponse } =
await import("../../open-sse/handlers/responseTranslator.ts");
const { FORMATS } = await import("../../open-sse/translator/formats.ts");
test("T19: picks the last non-empty message content from Responses output", () => {
const responseBody = {
object: "response",
id: "resp_t19",
model: "gpt-5.3-codex",
created_at: 1710000000,
output: [
{
type: "message",
content: [{ type: "output_text", text: "" }],
},
{
type: "reasoning",
summary: [{ type: "summary_text", text: "thinking..." }],
},
{
type: "message",
content: [{ type: "output_text", text: "Resposta final" }],
},
],
usage: { input_tokens: 10, output_tokens: 5 },
};
const translated = translateNonStreamingResponse(
responseBody,
FORMATS.OPENAI_RESPONSES,
FORMATS.OPENAI
);
assert.equal((translated as any).choices[0].message.content, "Resposta final");
});
test("T19: falls back to last message block when all message texts are empty", () => {
const responseBody = {
object: "response",
id: "resp_t19_empty",
model: "gpt-5.3-codex",
created_at: 1710000001,
output: [
{
type: "message",
content: [{ type: "output_text", text: "" }],
},
{
type: "message",
content: [{ type: "output_text", text: "" }],
},
],
};
const translated = translateNonStreamingResponse(
responseBody,
FORMATS.OPENAI_RESPONSES,
FORMATS.OPENAI
);
assert.equal((translated as any).choices[0].message.content, "");
(assert as any).equal((translated as any).choices[0].finish_reason, "stop");
});