Files
OmniRoute/tests/unit/version-manager-request.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

48 lines
1.5 KiB
TypeScript

import assert from "node:assert/strict";
import { test } from "node:test";
import { validateVersionManagerToolBody } from "../../src/app/api/version-manager/request.ts";
async function readFailure(result: ReturnType<typeof validateVersionManagerToolBody>) {
assert.equal(result.ok, false);
if (result.ok) {
throw new Error("expected validation failure");
}
return {
status: result.response.status,
body: await result.response.json(),
};
}
test("validateVersionManagerToolBody accepts cliproxy aliases", () => {
assert.deepEqual(validateVersionManagerToolBody({ tool: "cliproxy" }), {
ok: true,
tool: "cliproxy",
});
assert.deepEqual(validateVersionManagerToolBody({ tool: "cliproxyapi" }), {
ok: true,
tool: "cliproxyapi",
});
});
test("validateVersionManagerToolBody rejects unknown tools with the legacy response shape", async () => {
const failure = await readFailure(validateVersionManagerToolBody({ tool: "other" }));
assert.equal(failure.status, 400);
assert.deepEqual(failure.body, { error: "Unknown tool: other" });
});
test("validateVersionManagerToolBody rejects invalid bodies", async () => {
const failure = await readFailure(validateVersionManagerToolBody({}));
assert.equal(failure.status, 400);
assert.equal(failure.body.error.message, "Invalid request");
assert.deepEqual(failure.body.error.details, [
{
field: "tool",
message: "Invalid input: expected string, received undefined",
},
]);
});