test(translator): add data-driven coverage, bug-exposing cases, and real provider smoke
- matrix.js generates N providers x M models from PROVIDER_MODELS - coverage-all-models + format-roundtrip for structural/semantic checks - bugs-* files expose known translation issues via it.fails - real/smoke-providers runs full handleChatCore path against live providers (RUN_REAL=1), concurrent - registerAll.js eagerly imports translators (Vitest ESM require fix) - vitest.config: array aliases for subpaths + maxConcurrency 60 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
45
tests/translator/bugs-kiro.test.js
Normal file
45
tests/translator/bugs-kiro.test.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// OpenAI → Kiro (AWS CodeWhisperer) request translation.
|
||||
import { describe, it, expect } from "vitest";
|
||||
import "./registerAll.js";
|
||||
import { translateRequest } from "../../open-sse/translator/index.js";
|
||||
import { FORMATS } from "../../open-sse/translator/formats.js";
|
||||
|
||||
const O2K = (body) => translateRequest(FORMATS.OPENAI, FORMATS.KIRO, "m", body, true, null, "kiro");
|
||||
|
||||
describe("OpenAI → Kiro", () => {
|
||||
// openai-to-kiro.js:214-216 — JSON.parse(arguments) without try/catch → throws on bad JSON
|
||||
// KNOWN BUG (severe: throws and breaks the whole request)
|
||||
it.fails("malformed tool arguments do not throw the whole request", () => {
|
||||
expect(() =>
|
||||
O2K({
|
||||
messages: [
|
||||
{ role: "user", content: "go" },
|
||||
{ role: "assistant", content: "", tool_calls: [
|
||||
{ id: "c1", type: "function", function: { name: "f", arguments: "{not json" } },
|
||||
] },
|
||||
{ role: "tool", tool_call_id: "c1", content: "r" },
|
||||
],
|
||||
})
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
// openai-to-kiro.js:309 — maxTokens hardcoded to 32000, ignores body.max_tokens
|
||||
// KNOWN BUG
|
||||
it.fails("respects client max_tokens", () => {
|
||||
const out = O2K({ max_tokens: 100, messages: [{ role: "user", content: "hi" }] });
|
||||
expect(out.inferenceConfig?.maxTokens, "client max_tokens ignored").toBe(100);
|
||||
});
|
||||
|
||||
// openai-to-kiro.js:132-134 — remote http image becomes "[Image: url]" text (lost)
|
||||
// KNOWN BUG
|
||||
it.fails("remote image url is preserved as an image, not text", () => {
|
||||
const out = O2K({
|
||||
messages: [{ role: "user", content: [
|
||||
{ type: "text", text: "see" },
|
||||
{ type: "image_url", image_url: { url: "https://x.com/p.png" } },
|
||||
] }],
|
||||
});
|
||||
const content = out.conversationState?.currentMessage?.userInputMessage?.content || "";
|
||||
expect(content, "remote image flattened to text").not.toContain("[Image:");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user