mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
test: massive test coverage expansion (+1,437 tests, 22 new files)
Expand test coverage across all layers via 14 parallel agents: Unit tests (3,378 total, +534): - First-ever AI sidecar tests (157 tests covering bridge lifecycle, all 12 tool modules) - API route infrastructure (auth, pipeline, batch, settings, teams, roles, audit, api-keys, files, docs) - Lib coverage improvements (audit 7%->95%, worker-pool 33%->100%) - Web store/lib gap fills (features-store, tool-registry) Integration tests (4,403 total, +903): - Expanded 19 tool test files with parameter variations, format edge cases, boundary values - Cross-format matrix: 290 tests covering 14 tools x 17 formats - Adversarial/edge cases: 63 tests for extreme inputs, concurrent requests, corrupted files E2E-Docker (125 new tests): - Expanded 8 spec files + 1 new file covering all 49 tools - Added HEIC/format handling, auth failures, download verification GUI E2E (expanded 28 spec files): - Navigation, responsive layout, keyboard shortcuts - All 51 tool UIs with settings, processing, display modes - Batch/pipeline workflows, settings/RBAC, visual regression - Resilience, accessibility (ARIA, contrast, focus), performance budgets
This commit is contained in:
@@ -759,6 +759,162 @@ test.describe("QR Read", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Compare — Additional ──────────────────────────────────────
|
||||
|
||||
test.describe("Compare — additional", () => {
|
||||
test("compare HEIC and PNG images", async ({ request }) => {
|
||||
const { body, contentType } = buildMultipart(
|
||||
[
|
||||
{ name: "file", filename: "a.heic", contentType: "image/heic", buffer: HEIC_200x150 },
|
||||
{ name: "file", filename: "b.png", contentType: "image/png", buffer: PNG_200x150 },
|
||||
],
|
||||
[],
|
||||
);
|
||||
const res = await request.post("/api/v1/tools/compare", {
|
||||
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
|
||||
data: body,
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const json = await res.json();
|
||||
expect(typeof json.similarity).toBe("number");
|
||||
expect(json.similarity).toBeGreaterThanOrEqual(0);
|
||||
expect(json.similarity).toBeLessThanOrEqual(100);
|
||||
});
|
||||
|
||||
test("compare two different format images of same content", async ({ request }) => {
|
||||
const { body, contentType } = buildMultipart(
|
||||
[
|
||||
{ name: "file", filename: "a.webp", contentType: "image/webp", buffer: WEBP_50x50 },
|
||||
{ name: "file", filename: "b.webp", contentType: "image/webp", buffer: WEBP_50x50 },
|
||||
],
|
||||
[],
|
||||
);
|
||||
const res = await request.post("/api/v1/tools/compare", {
|
||||
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
|
||||
data: body,
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const json = await res.json();
|
||||
// Same image should have very high similarity
|
||||
expect(json.similarity).toBeGreaterThan(99);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Find Duplicates — Additional ─────────────────────────────
|
||||
|
||||
test.describe("Find Duplicates — additional", () => {
|
||||
test("find duplicates with 4 files (2 pairs)", async ({ request }) => {
|
||||
const { body, contentType } = buildMultipart(
|
||||
[
|
||||
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
|
||||
{ name: "file", filename: "b.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
|
||||
{ name: "file", filename: "c.png", contentType: "image/png", buffer: PNG_200x150 },
|
||||
{ name: "file", filename: "d.jpg", contentType: "image/jpeg", buffer: JPG_100x100 },
|
||||
],
|
||||
[],
|
||||
);
|
||||
const res = await request.post("/api/v1/tools/find-duplicates", {
|
||||
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
|
||||
data: body,
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const json = await res.json();
|
||||
expect(json.duplicateGroups).toBeInstanceOf(Array);
|
||||
expect(json.duplicateGroups.length).toBeGreaterThan(0);
|
||||
expect(json.totalImages).toBe(4);
|
||||
});
|
||||
|
||||
test("find duplicates with HEIC images", async ({ request }) => {
|
||||
const { body, contentType } = buildMultipart(
|
||||
[
|
||||
{ name: "file", filename: "a.heic", contentType: "image/heic", buffer: HEIC_200x150 },
|
||||
{ name: "file", filename: "b.heic", contentType: "image/heic", buffer: HEIC_200x150 },
|
||||
{ name: "file", filename: "c.png", contentType: "image/png", buffer: PNG_200x150 },
|
||||
],
|
||||
[],
|
||||
);
|
||||
const res = await request.post("/api/v1/tools/find-duplicates", {
|
||||
headers: { Authorization: `Bearer ${token}`, "Content-Type": contentType },
|
||||
data: body,
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const json = await res.json();
|
||||
expect(json.duplicateGroups).toBeInstanceOf(Array);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── QR Generate — Output Verification ─────────────────────────
|
||||
|
||||
test.describe("QR Generate — output verification", () => {
|
||||
test("QR code image can be downloaded", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/qr-generate", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
data: {
|
||||
text: "https://test.snapotter.app/verify",
|
||||
size: 300,
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
|
||||
// Download the QR code
|
||||
const dlRes = await request.get(body.downloadUrl, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
expect(dlRes.ok()).toBe(true);
|
||||
const buffer = Buffer.from(await dlRes.body());
|
||||
expect(buffer.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test("QR code with all error correction levels", async ({ request }) => {
|
||||
const levels = ["L", "M", "Q", "H"] as const;
|
||||
for (const errorCorrection of levels) {
|
||||
const res = await request.post("/api/v1/tools/qr-generate", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
data: {
|
||||
text: `EC-${errorCorrection}`,
|
||||
size: 200,
|
||||
errorCorrection,
|
||||
},
|
||||
});
|
||||
expect(res.ok(), `QR with EC=${errorCorrection} should succeed`).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.downloadUrl).toBeTruthy();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Color Palette — Additional ────────────────────────────────
|
||||
|
||||
test.describe("Color Palette — additional", () => {
|
||||
test("extract colors from WebP image", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/color-palette", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "test.webp", mimeType: "image/webp", buffer: WEBP_50x50 },
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.colors).toBeInstanceOf(Array);
|
||||
expect(body.colors.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test("color palette on content image has rich palette", async ({ request }) => {
|
||||
const portrait = contentFixture("portrait-color.jpg");
|
||||
const res = await request.post("/api/v1/tools/color-palette", {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
multipart: {
|
||||
file: { name: "portrait.jpg", mimeType: "image/jpeg", buffer: portrait },
|
||||
},
|
||||
});
|
||||
expect(res.ok()).toBe(true);
|
||||
const body = await res.json();
|
||||
expect(body.colors.length).toBeGreaterThanOrEqual(3);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Auth Failure ──────────────────────────────────────────────────
|
||||
|
||||
test.describe("Auth failure", () => {
|
||||
@@ -786,4 +942,54 @@ test.describe("Auth failure", () => {
|
||||
});
|
||||
expect(res.status()).toBe(401);
|
||||
});
|
||||
|
||||
test("compare without token returns 401", async ({ request }) => {
|
||||
const { body, contentType } = buildMultipart(
|
||||
[
|
||||
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
|
||||
{ name: "file", filename: "b.png", contentType: "image/png", buffer: PNG_200x150 },
|
||||
],
|
||||
[],
|
||||
);
|
||||
const res = await request.post("/api/v1/tools/compare", {
|
||||
headers: { "Content-Type": contentType },
|
||||
data: body,
|
||||
});
|
||||
expect(res.status()).toBe(401);
|
||||
});
|
||||
|
||||
test("find-duplicates without token returns 401", async ({ request }) => {
|
||||
const { body, contentType } = buildMultipart(
|
||||
[
|
||||
{ name: "file", filename: "a.png", contentType: "image/png", buffer: PNG_200x150 },
|
||||
{ name: "file", filename: "b.png", contentType: "image/png", buffer: PNG_200x150 },
|
||||
],
|
||||
[],
|
||||
);
|
||||
const res = await request.post("/api/v1/tools/find-duplicates", {
|
||||
headers: { "Content-Type": contentType },
|
||||
data: body,
|
||||
});
|
||||
expect(res.status()).toBe(401);
|
||||
});
|
||||
|
||||
test("barcode-read without token returns 401", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/barcode-read", {
|
||||
multipart: {
|
||||
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
|
||||
settings: JSON.stringify({}),
|
||||
},
|
||||
});
|
||||
expect(res.status()).toBe(401);
|
||||
});
|
||||
|
||||
test("image-to-base64 without token returns 401", async ({ request }) => {
|
||||
const res = await request.post("/api/v1/tools/image-to-base64", {
|
||||
multipart: {
|
||||
file: { name: "test.png", mimeType: "image/png", buffer: PNG_200x150 },
|
||||
settings: JSON.stringify({}),
|
||||
},
|
||||
});
|
||||
expect(res.status()).toBe(401);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user