Files
OmniRoute/tests/unit/sse-shim-contract.test.ts
Diego Rodrigues de Sa e Souza 0adae00c7b Release v3.8.42 (#5459)
Release v3.8.42 — full CHANGELOG in CHANGELOG.md.

CI: 103 checks green incl. CodeQL (all languages), Semgrep, all 8 unit shards,
coverage, Node 24 compat, and integration tests. Full unit suite validated
locally: 19437 pass / 0 fail. The 3 red checks are advisory and do not gate
main (no required status checks): SonarCloud/SonarQube new-code coverage gate,
and PR Test Policy (test-masking detector flagging the legitimate dead-Phind
provider removal in #5530 — reviewed, correct).

Includes cycle-close reconciliation + repair of inherited base-red tests from
#5480/#5527/#5427/#5521 that the PR->release fast-path did not exercise.
2026-06-30 06:54:29 -03:00

75 lines
2.6 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { existsSync, readdirSync, readFileSync } from "node:fs";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
const TEST_DATA_DIR = mkdtempSync(join(tmpdir(), "omniroute-sse-shim-"));
process.env.DATA_DIR = TEST_DATA_DIR;
const repoRoot = join(import.meta.dirname, "../..");
function readProjectFile(relativePath: string): string {
return readFileSync(join(repoRoot, relativePath), "utf8");
}
function listProjectFiles(relativePath: string): string[] {
const fullPath = join(repoRoot, relativePath);
if (!existsSync(fullPath)) return [];
return readdirSync(fullPath, { withFileTypes: true }).flatMap((entry) => {
const childPath = `${relativePath}/${entry.name}`;
if (entry.isDirectory()) return listProjectFiles(childPath);
return childPath;
});
}
test.after(() => {
rmSync(TEST_DATA_DIR, { recursive: true, force: true });
});
test("src/sse model shim keeps parseModel behavior aligned with open-sse core", async () => {
const srcModel = await import("../../src/sse/services/model.ts");
const coreModel = await import("../../open-sse/services/model.ts");
const samples = [
"openai/gpt-4o-mini",
"claude-sonnet-4-6[1m]",
"gemini-3-pro-preview",
"anthropic/claude-opus-4.5",
"gpt-oss:120b",
"../bad-model",
];
for (const sample of samples) {
assert.deepEqual(srcModel.parseModel(sample), coreModel.parseModel(sample));
}
});
test("src/sse model shim exposes the active model helper surface", async () => {
const srcModel = await import("../../src/sse/services/model.ts");
for (const helper of ["parseModel", "getModelInfo", "getCombo", "getComboForModel"]) {
assert.equal(typeof srcModel[helper], "function", `${helper} should stay exported`);
}
});
test("src/sse service wrappers delegate to open-sse and shared infrastructure", () => {
const tokenRefreshSource = readProjectFile("src/sse/services/tokenRefresh.ts");
const modelSource = readProjectFile("src/sse/services/model.ts");
const loggerSource = readProjectFile("src/sse/utils/logger.ts");
assert.match(tokenRefreshSource, /@omniroute\/open-sse\/services\/tokenRefresh\.ts/);
assert.match(modelSource, /@omniroute\/open-sse\/services\/model\.ts/);
assert.match(loggerSource, /@\/shared\/utils\/logger/);
assert.doesNotMatch(loggerSource, /console\.(log|warn|error|info|debug)/);
});
test("src/sse does not contain tracked backup artifacts", () => {
const artifacts = listProjectFiles("src/sse").filter((file) =>
/\.(orig|bak|backup)$/i.test(file)
);
assert.deepEqual(artifacts, []);
});