mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
test: expand coverage across all layers -- 1,268 new tests, fix replace-color div-by-zero
14-agent parallel test expansion covering integration, unit, E2E, E2E-Docker, cross-format matrix, adversarial, GUI navigation/tools/settings/visual/a11y/perf. - Integration: expand 23 tool test files with HEIC, stress, batch, edge cases - Unit: close coverage gaps in image-engine, stores, lib (metadata, auto-enhance, connection-store, lazy-with-retry, collage/file-store HEIC preview) - AI bridge: 141 new tests for dispatcher buffering, crash recovery, OOM/segfault - Cross-format: 794 parameterized tests (16 formats x 12 tools + no-crash matrix) - Adversarial: memory stress (50x large file), zero-byte, corrupted headers, unicode - E2E-Docker: expand 8 spec files with dimension verification, pipeline chains - GUI E2E: tool UI settings/interactions for all 47 tools, remove all test.skip, RBAC per-role verification, visual screenshot naming, cross-browser smoke tests, a11y ARIA/focus/contrast, performance budgets, 15-tool stability test - Fix: replace-color.ts tolerance=0 caused division-by-zero producing NaN pixels Total: 8,958 tests passing across 202 files. Zero failures, zero skips.
This commit is contained in:
@@ -571,3 +571,89 @@ describe("Filename tracking", () => {
|
||||
expect(result.filename).toBe("my-image-2024.png");
|
||||
});
|
||||
});
|
||||
|
||||
// ── Extracted colors are unique ────────────────────────────────
|
||||
describe("Color uniqueness", () => {
|
||||
it("returns only unique colors (no duplicates)", async () => {
|
||||
const PHOTO = readFileSync(join(FIXTURES, "content", "portrait-color.jpg"));
|
||||
const { body: payload, contentType } = makeFilePayload(PHOTO, "photo.jpg", "image/jpeg");
|
||||
const res = await app.inject({
|
||||
method: "POST",
|
||||
url: "/api/v1/tools/color-palette",
|
||||
payload,
|
||||
headers: {
|
||||
"content-type": contentType,
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
},
|
||||
});
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
const uniqueColors = new Set(result.colors);
|
||||
expect(uniqueColors.size).toBe(result.colors.length);
|
||||
});
|
||||
});
|
||||
|
||||
// ── SVG logo from content fixtures ────────────────────────────
|
||||
describe("SVG logo input", () => {
|
||||
it("extracts palette from svg-logo.svg", async () => {
|
||||
const SVG_LOGO = readFileSync(join(FIXTURES, "content", "svg-logo.svg"));
|
||||
const { body: payload, contentType } = makeFilePayload(SVG_LOGO, "logo.svg", "image/svg+xml");
|
||||
const res = await app.inject({
|
||||
method: "POST",
|
||||
url: "/api/v1/tools/color-palette",
|
||||
payload,
|
||||
headers: {
|
||||
"content-type": contentType,
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
},
|
||||
});
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.colors.length).toBeGreaterThan(0);
|
||||
expect(result.filename).toBe("logo.svg");
|
||||
});
|
||||
});
|
||||
|
||||
// ── Three-color image ─────────────────────────────────────────
|
||||
describe("Three-color image", () => {
|
||||
it("extracts 3 colors from a 3-stripe image", async () => {
|
||||
const w = 60;
|
||||
const h = 30;
|
||||
const raw = Buffer.alloc(w * h * 3);
|
||||
for (let y = 0; y < h; y++) {
|
||||
for (let x = 0; x < w; x++) {
|
||||
const idx = (y * w + x) * 3;
|
||||
if (x < 20) {
|
||||
raw[idx] = 255;
|
||||
raw[idx + 1] = 0;
|
||||
raw[idx + 2] = 0;
|
||||
} else if (x < 40) {
|
||||
raw[idx] = 0;
|
||||
raw[idx + 1] = 255;
|
||||
raw[idx + 2] = 0;
|
||||
} else {
|
||||
raw[idx] = 0;
|
||||
raw[idx + 1] = 0;
|
||||
raw[idx + 2] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
const tricolorBuffer = await sharp(raw, { raw: { width: w, height: h, channels: 3 } })
|
||||
.png()
|
||||
.toBuffer();
|
||||
|
||||
const { body: payload, contentType } = makeFilePayload(tricolorBuffer, "tri.png", "image/png");
|
||||
const res = await app.inject({
|
||||
method: "POST",
|
||||
url: "/api/v1/tools/color-palette",
|
||||
payload,
|
||||
headers: {
|
||||
"content-type": contentType,
|
||||
authorization: `Bearer ${adminToken}`,
|
||||
},
|
||||
});
|
||||
expect(res.statusCode).toBe(200);
|
||||
const result = JSON.parse(res.body);
|
||||
expect(result.colors.length).toBeGreaterThanOrEqual(3);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user