Files
SnapOtter/tests/unit/pairwise.test.ts
T
SnapOtterandGitHub 4ec39c556f test: testing overhaul -- CI e2e gates, parallel suites, generated matrices, mutation testing (#215)
Closes the "e2e never runs in CI" hole. Adds per-PR e2e smoke gate,
nightly full-suite workflows, parallel vitest forks (per-fork DBs),
Playwright parallel/serial/visual projects against production builds,
metadata-generated test suites (drift guards, hostile inputs, format
matrix, pairwise settings, property-based fuzz), Stryker mutation
testing, Schemathesis API fuzz, coverage ratchet, and fixes for three
session-poisoning bugs that caused 200+ serial-bucket failures.

Bug fix included: favicon/split/bulk-rename could hang clients forever
when ZIP streaming failed after reply.hijack().
2026-06-10 22:01:13 +08:00

55 lines
1.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { pairwise } from "../helpers/pairwise.js";
describe("pairwise covering-array generator", () => {
it("covers every pair of values across all axis pairs", () => {
const axes = [
{ key: "fit", values: ["contain", "cover", "fill", "inside"] },
{ key: "format", values: ["png", "jpeg", "webp"] },
{ key: "withMetadata", values: [true, false] },
{ key: "quality", values: [1, 50, 100] },
];
const cases = pairwise(axes);
for (let i = 0; i < axes.length; i++) {
for (let j = i + 1; j < axes.length; j++) {
for (const vi of axes[i].values) {
for (const vj of axes[j].values) {
const covered = cases.some((c) => c[axes[i].key] === vi && c[axes[j].key] === vj);
expect(covered, `pair ${axes[i].key}=${vi} x ${axes[j].key}=${vj} not covered`).toBe(
true,
);
}
}
}
}
});
it("produces far fewer cases than the full cartesian product", () => {
const axes = [
{ key: "a", values: [1, 2, 3, 4] },
{ key: "b", values: [1, 2, 3] },
{ key: "c", values: [true, false] },
{ key: "d", values: ["x", "y", "z"] },
];
const cases = pairwise(axes);
// Cartesian product is 72; pairwise needs at least 12 (largest axis pair).
expect(cases.length).toBeGreaterThanOrEqual(12);
expect(cases.length).toBeLessThan(30);
});
it("is deterministic", () => {
const axes = [
{ key: "a", values: [1, 2, 3] },
{ key: "b", values: ["x", "y"] },
{ key: "c", values: [true, false] },
];
expect(pairwise(axes)).toEqual(pairwise(axes));
});
it("handles degenerate inputs", () => {
expect(pairwise([])).toEqual([]);
expect(pairwise([{ key: "only", values: [1, 2] }])).toEqual([{ only: 1 }, { only: 2 }]);
});
});