mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Coverage 83.6 to 87.36% lines, 81.63 to 84.14% branches. Mutation testing across five packages: image-engine 85, media-engine 92, doc-engine 87, shared+enterprise 86, apps/api security and jobs slice. Runs all five lanes weekly. Fixes the silently-broken mutation CI (babel pin), a redact-pdf envelope-shape test bug, an untested enterprise license valid-signature path, and an audit test that only exercised a hand-copied reproduction. Test and config only, no product code changes beyond the babel pin and one test-only oidc export. Full suite: 16,712 pass, 0 fail.
56 lines
2.7 KiB
TypeScript
56 lines
2.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
CONVERSION_PRESET_BY_ID,
|
|
expandConversionPresets,
|
|
} from "../../../packages/shared/src/conversion-presets.js";
|
|
|
|
// Targets the expansion logic in expandConversionPresets (L593-L599): the
|
|
// name/description templates and the executionHint derivation
|
|
// (base?.executionHint ?? (cfg.modality === "image" ? "fast" : "long")).
|
|
|
|
describe("expandConversionPresets name/description templates", () => {
|
|
it("builds name and description from the preset's from/to for every preset", () => {
|
|
const tools = expandConversionPresets();
|
|
expect(tools.length).toBeGreaterThan(0);
|
|
for (const tool of tools) {
|
|
const preset = CONVERSION_PRESET_BY_ID[tool.id];
|
|
expect(preset).toBeDefined();
|
|
expect(tool.name).toBe(`${preset.from} to ${preset.to}`);
|
|
expect(tool.description).toBe(`Convert ${preset.from} to ${preset.to}`);
|
|
expect(tool.route).toBe(`/${preset.id}`);
|
|
}
|
|
});
|
|
});
|
|
|
|
describe("expandConversionPresets executionHint derivation", () => {
|
|
it("without a base tool: image modality is fast, every other modality is long", () => {
|
|
const tools = expandConversionPresets();
|
|
// Prove both arms of the ternary are exercised across the catalog.
|
|
const image = tools.filter((t) => t.modality === "image");
|
|
const other = tools.filter((t) => t.modality !== "image");
|
|
expect(image.length).toBeGreaterThan(0);
|
|
for (const t of image) expect(t.executionHint).toBe("fast");
|
|
for (const t of other) expect(t.executionHint).toBe("long");
|
|
});
|
|
|
|
it("with a base tool present, the base's executionHint wins over the modality default", () => {
|
|
// Give every base an explicit "long" hint; image presets would default to
|
|
// "fast", so if they come back "long" the base override (the ?? left side)
|
|
// is what produced it.
|
|
const bases = new Set(Object.values(CONVERSION_PRESET_BY_ID).map((p) => p.base));
|
|
const baseTools = [...bases].map((id) => ({ id, executionHint: "long" as const }));
|
|
const tools = expandConversionPresets(baseTools);
|
|
const image = tools.filter((t) => t.modality === "image");
|
|
expect(image.length).toBeGreaterThan(0);
|
|
for (const t of image) expect(t.executionHint).toBe("long");
|
|
});
|
|
|
|
it("a base tool with a fast hint overrides a non-image modality default of long", () => {
|
|
const bases = new Set(Object.values(CONVERSION_PRESET_BY_ID).map((p) => p.base));
|
|
const baseTools = [...bases].map((id) => ({ id, executionHint: "fast" as const }));
|
|
const tools = expandConversionPresets(baseTools);
|
|
const other = tools.filter((t) => t.modality !== "image");
|
|
if (other.length > 0) for (const t of other) expect(t.executionHint).toBe("fast");
|
|
});
|
|
});
|