mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 04:12:10 +03:00
Centralize compression config schemas across settings, preview, RTK, and combo APIs to enforce consistent validation for stacked pipelines and engine-specific options. Expand caveman and stacked compression behavior by applying default combos at runtime, surfacing validation and fallback metadata, and exposing aggressive and ultra adapter schemas for configuration UI and tests. Persist MCP description compression snapshots into analytics without counting them as provider usage, and extend the dashboard with the new RTK controls and localized labels.
57 lines
2.3 KiB
TypeScript
57 lines
2.3 KiB
TypeScript
import { describe, it } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { rtkConfigSchema } from "../../../src/app/api/context/rtk/config/route.ts";
|
|
import { rtkTestSchema } from "../../../src/app/api/context/rtk/test/route.ts";
|
|
import { compressionComboCreateSchema } from "../../../src/app/api/context/combos/route.ts";
|
|
import { compressionComboUpdateSchema } from "../../../src/app/api/context/combos/[id]/route.ts";
|
|
import { assignmentsUpdateSchema } from "../../../src/app/api/context/combos/[id]/assignments/route.ts";
|
|
|
|
describe("context compression API schemas", () => {
|
|
it("rejects invalid RTK config and test payloads", () => {
|
|
assert.equal(rtkConfigSchema.safeParse({ intensity: "extreme" }).success, false);
|
|
assert.equal(rtkConfigSchema.safeParse({ applyToCodeBlocks: true }).success, true);
|
|
assert.equal(
|
|
rtkConfigSchema.safeParse({
|
|
customFiltersEnabled: true,
|
|
trustProjectFilters: false,
|
|
rawOutputRetention: "failures",
|
|
rawOutputMaxBytes: 4096,
|
|
}).success,
|
|
true
|
|
);
|
|
assert.equal(rtkConfigSchema.safeParse({ rawOutputRetention: "plaintext" }).success, false);
|
|
assert.equal(rtkTestSchema.safeParse({ text: "" }).success, false);
|
|
assert.equal(rtkTestSchema.safeParse({ text: "ok", extra: true }).success, false);
|
|
assert.equal(
|
|
rtkTestSchema.safeParse({
|
|
text: "ok",
|
|
config: { maxLinesPerResult: -1, madeUp: true },
|
|
}).success,
|
|
false
|
|
);
|
|
});
|
|
|
|
it("rejects invalid compression combo payloads", () => {
|
|
assert.equal(compressionComboCreateSchema.safeParse({ name: "" }).success, false);
|
|
assert.equal(
|
|
compressionComboCreateSchema.safeParse({
|
|
name: "Stacked",
|
|
pipeline: [{ engine: "rtk", intensity: "standard" }],
|
|
}).success,
|
|
true
|
|
);
|
|
assert.equal(compressionComboUpdateSchema.safeParse({ isDefault: true }).success, true);
|
|
assert.equal(compressionComboUpdateSchema.safeParse({ pipeline: [] }).success, false);
|
|
assert.equal(assignmentsUpdateSchema.safeParse({ routingComboIds: ["combo-a"] }).success, true);
|
|
assert.equal(assignmentsUpdateSchema.safeParse({ routingComboIds: [""] }).success, false);
|
|
assert.equal(
|
|
compressionComboCreateSchema.safeParse({
|
|
name: "Bad",
|
|
pipeline: [{ engine: "rtk", intensity: "bogus" }],
|
|
}).success,
|
|
false
|
|
);
|
|
});
|
|
});
|