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.3 KiB
TypeScript
56 lines
2.3 KiB
TypeScript
import { isToolInputError } from "@snapotter/shared";
|
|
import { describe, expect, it } from "vitest";
|
|
import { markIfInputError } from "../src/ffmpeg.js";
|
|
|
|
/**
|
|
* markIfInputError tags the error with the isToolInputError marker when stderr
|
|
* matches one of INPUT_ERROR_PATTERNS. One matching string per pattern kills
|
|
* the corresponding array-element mutant; a non-matching string proves the
|
|
* marker is NOT applied indiscriminately (kills the `.some(...) ? ... : err`
|
|
* conditional and the boolean-return mutants).
|
|
*/
|
|
describe("markIfInputError: matches each INPUT_ERROR_PATTERN", () => {
|
|
const matches: Array<[string, string]> = [
|
|
["received no packets", "Output file #0 does not contain any stream: received no packets"],
|
|
["invalid data found when processing input", "pipe:: Invalid data found when processing input"],
|
|
["could not find codec parameters", "Could not find codec parameters for stream 0 (Video)"],
|
|
["moov atom not found", "[mov,mp4] moov atom not found\nError opening input file"],
|
|
];
|
|
|
|
for (const [label, stderr] of matches) {
|
|
it(`marks input error for "${label}"`, () => {
|
|
const err = markIfInputError(new Error("ffmpeg exited 1"), stderr);
|
|
expect(isToolInputError(err)).toBe(true);
|
|
});
|
|
}
|
|
});
|
|
|
|
describe("markIfInputError: does not mark unrelated stderr", () => {
|
|
it("leaves a generic ffmpeg error unmarked", () => {
|
|
const err = markIfInputError(new Error("boom"), "Conversion failed! Unknown encoder 'libfoo'");
|
|
expect(isToolInputError(err)).toBe(false);
|
|
});
|
|
|
|
it("leaves empty stderr unmarked", () => {
|
|
const err = markIfInputError(new Error("boom"), "");
|
|
expect(isToolInputError(err)).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("markIfInputError: case-insensitive matching and identity", () => {
|
|
it("matches regardless of case (uppercase 'MOOV ATOM NOT FOUND')", () => {
|
|
const err = markIfInputError(new Error("x"), "MOOV ATOM NOT FOUND");
|
|
expect(isToolInputError(err)).toBe(true);
|
|
});
|
|
|
|
it("returns the same error object it was given", () => {
|
|
const original = new Error("x");
|
|
expect(markIfInputError(original, "moov atom not found")).toBe(original);
|
|
});
|
|
|
|
it("returns the same object when it does not match (no copy)", () => {
|
|
const original = new Error("x");
|
|
expect(markIfInputError(original, "nothing matches here")).toBe(original);
|
|
});
|
|
});
|