test: major coverage expansion — 18 new test files, ~830 new tests

Unit tests: 1354 → 1781 (+427)
- 11 new AI bridge module tests (packages/ai/ from 2/13 → 13/13 files)
- files-page-store (0% → full), pdf-to-image-store, features-store expanded
- saturation and edit-metadata image-engine operations
- analytics route, features route, web analytics lib, api-extended

Integration tests: ~2070 → 2320 (+250)
- 31 integration files expanded with branch-coverage-targeted tests
- progress.ts SSE endpoints (28% → comprehensive, +18 tests)
- gif-tools all modes (+18), pdf-to-image format variants (+13)
- Cross-format matrix expanded to 17 tools × 17 formats (467 tests)
- Adversarial: concurrent, memory pressure, unicode filenames, pipeline limits

E2E-Docker: +1020 lines across 6 spec files
- Info, colors, sharpening, base64, QR read, JXL/ICO/SVG formats
- Strip-metadata, image-enhancement, content-aware-resize expanded
- Batch pipelines, multi-format batches, HEIC input coverage
This commit is contained in:
SnapOtter
2026-04-26 12:03:08 +08:00
parent dee9452c48
commit 733ebe8010
61 changed files with 12791 additions and 4 deletions
+100
View File
@@ -317,3 +317,103 @@ describe("Download verification", () => {
expect(meta.height).toBe(150);
});
});
// ── Branch coverage: lines 87-88 (negative exposure path) ────────
describe("Exposure adjustments", () => {
it("applies positive exposure (brightens midtones)", async () => {
const res = await postTool("adjust-colors", { exposure: 50 });
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.downloadUrl).toBeDefined();
});
it("applies negative exposure (darkens midtones)", async () => {
const res = await postTool("adjust-colors", { exposure: -50 });
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.downloadUrl).toBeDefined();
});
it("handles max positive exposure (+100)", async () => {
const res = await postTool("adjust-colors", { exposure: 100 });
expect(res.statusCode).toBe(200);
});
it("handles max negative exposure (-100)", async () => {
const res = await postTool("adjust-colors", { exposure: -100 });
expect(res.statusCode).toBe(200);
});
it("handles zero exposure (no-op)", async () => {
const res = await postTool("adjust-colors", { exposure: 0 });
expect(res.statusCode).toBe(200);
});
});
// ── HEIC input ──────────────────────────────────────────────────
describe("HEIC input", () => {
it("processes HEIC input with brightness adjustment", async () => {
const HEIC = readFileSync(join(FIXTURES, "test-200x150.heic"));
const res = await postTool(
"adjust-colors",
{ brightness: 30 },
HEIC,
"photo.heic",
"image/heic",
);
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.downloadUrl).toBeDefined();
});
});
// ── Combined adjustments with exposure ──────────────────────────
describe("Combined exposure adjustments", () => {
it("applies exposure + brightness + contrast together", async () => {
const res = await postTool("adjust-colors", {
exposure: -30,
brightness: 20,
contrast: 10,
});
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.downloadUrl).toBeDefined();
});
it("applies all adjustments simultaneously", async () => {
const res = await postTool("adjust-colors", {
brightness: 10,
contrast: 15,
exposure: 20,
saturation: 30,
temperature: 10,
tint: -5,
hue: 45,
sharpness: 25,
red: 110,
green: 90,
blue: 105,
effect: "none",
});
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.downloadUrl).toBeDefined();
});
});
// ── Tiny and stress inputs ──────────────────────────────────────
describe("Edge size inputs", () => {
it("processes 1x1 pixel image", async () => {
const TINY = readFileSync(join(FIXTURES, "test-1x1.png"));
const res = await postTool("adjust-colors", { brightness: 50 }, TINY, "tiny.png", "image/png");
expect(res.statusCode).toBe(200);
});
it("processes stress-large.jpg", async () => {
const LARGE = readFileSync(join(FIXTURES, "content", "stress-large.jpg"));
const res = await postTool("adjust-colors", { contrast: 30 }, LARGE, "large.jpg", "image/jpeg");
expect(res.statusCode).toBe(200);
const result = JSON.parse(res.body);
expect(result.processedSize).toBeGreaterThan(0);
});
});