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
+114
View File
@@ -644,3 +644,117 @@ test.describe("Bulk Rename", () => {
expect(json.error).toBeDefined();
});
});
// ─── Image to Base64 ───────────────────────────────────────────────
test.describe("Image to Base64", () => {
test("encode PNG to base64 returns data URI", async ({ request }) => {
const res = await request.post("/api/v1/tools/image-to-base64", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
settings: JSON.stringify({}),
},
});
expect(res.ok()).toBe(true);
const body = await res.json();
expect(body.results).toBeInstanceOf(Array);
expect(body.results.length).toBeGreaterThan(0);
const result = body.results[0];
expect(result.base64).toBeTruthy();
expect(result.dataUri).toContain("data:image/");
expect(result.mimeType).toBe("image/png");
expect(result.width).toBe(200);
expect(result.height).toBe(150);
});
test("encode JPEG to base64", async ({ request }) => {
const res = await request.post("/api/v1/tools/image-to-base64", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.jpg", mimeType: "image/jpeg", buffer: JPG_100x100 },
settings: JSON.stringify({}),
},
});
expect(res.ok()).toBe(true);
const body = await res.json();
expect(body.results[0].base64).toBeTruthy();
expect(body.results[0].mimeType).toContain("image/");
});
test("encode with maxWidth constraint", async ({ request }) => {
const res = await request.post("/api/v1/tools/image-to-base64", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
settings: JSON.stringify({ maxWidth: 50 }),
},
});
expect(res.ok()).toBe(true);
const body = await res.json();
expect(body.results[0].width).toBeLessThanOrEqual(50);
});
test("encode with output format conversion", async ({ request }) => {
const res = await request.post("/api/v1/tools/image-to-base64", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
settings: JSON.stringify({ outputFormat: "jpeg", quality: 50 }),
},
});
expect(res.ok()).toBe(true);
const body = await res.json();
expect(body.results[0].mimeType).toBe("image/jpeg");
});
test("encode HEIC image to base64", async ({ request }) => {
const res = await request.post("/api/v1/tools/image-to-base64", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.heic", mimeType: "image/heic", buffer: HEIC_200x150 },
settings: JSON.stringify({}),
},
});
expect(res.ok()).toBe(true);
const body = await res.json();
expect(body.results[0].base64).toBeTruthy();
expect(body.results[0].width).toBeGreaterThan(0);
});
test("overhead percent is calculated", async ({ request }) => {
const res = await request.post("/api/v1/tools/image-to-base64", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
settings: JSON.stringify({}),
},
});
expect(res.ok()).toBe(true);
const body = await res.json();
expect(typeof body.results[0].overheadPercent).toBe("number");
expect(body.results[0].overheadPercent).toBeGreaterThan(0);
});
});
// ─── QR Read (from content fixtures) ───────────────────────────────
test.describe("QR Read", () => {
test("read QR code from content fixture", async ({ request }) => {
const qrImage = contentFixture("qr-code.avif");
const res = await request.post("/api/v1/tools/barcode-read", {
headers: { Authorization: `Bearer ${token}` },
multipart: {
file: { name: "qr-code.avif", mimeType: "image/avif", buffer: qrImage },
settings: JSON.stringify({}),
},
});
expect(res.ok()).toBe(true);
const body = await res.json();
expect(body.barcodes).toBeInstanceOf(Array);
if (body.barcodes.length > 0) {
expect(body.barcodes[0].text).toBeTruthy();
}
});
});