Merge feat/transparency-fixer: add PNG Transparency Fixer tool

New AI-powered tool that fixes fake transparent PNGs in one click.
Uses BiRefNet HR-matting (2048x2048) with Sharp defringe post-processing.
This commit is contained in:
SnapOtter
2026-05-06 21:57:46 +08:00
38 changed files with 1399 additions and 117 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ test.describe("Docs Homepage", () => {
await expect(page.getByText("SnapOtter").first()).toBeVisible();
await expect(page.getByText("A Self Hosted Image Manipulator")).toBeVisible();
await expect(
page.getByText("47 tools. Local AI. No cloud. Your images never leave your home."),
page.getByText("48 tools. Local AI. No cloud. Your images never leave your home."),
).toBeVisible();
});
@@ -29,7 +29,7 @@ test.describe("Docs Homepage", () => {
test("features section renders all 6 feature cards", async ({ page }) => {
const features = [
"47 Image Tools",
"48 Image Tools",
"Local AI",
"Pipelines",
"REST API",
+11 -7
View File
@@ -37,16 +37,20 @@ test.describe("Landing Homepage", () => {
test("how-it-works section renders Docker command", async ({ page }) => {
await expect(page.getByText("Get started in seconds")).toBeVisible();
await expect(
page.getByText("docker run -d --name SnapOtter", { exact: false }),
).toBeVisible();
await expect(page.getByText("docker run -d --name SnapOtter", { exact: false })).toBeVisible();
});
test("why-choose section renders all 9 benefit cards", async ({ page }) => {
await expect(page.getByText("Built different. On purpose.")).toBeVisible();
const cards = [
"No Signup", "No Uploads", "Forever Free", "No Limits",
"Batch Processing", "Lightning Fast", "Open Source", "REST API",
"No Signup",
"No Uploads",
"Forever Free",
"No Limits",
"Batch Processing",
"Lightning Fast",
"Open Source",
"REST API",
"Pipeline Automation",
];
for (const card of cards) {
@@ -55,9 +59,9 @@ test.describe("Landing Homepage", () => {
});
test("bento grid renders with search and tool count", async ({ page }) => {
await expect(page.getByText("47 tools. Zero cloud dependency.")).toBeVisible();
await expect(page.getByText("48 tools. Zero cloud dependency.")).toBeVisible();
await expect(page.getByPlaceholder("Search tools...")).toBeVisible();
await expect(page.getByText(/Showing 47 of 47 tools/)).toBeVisible();
await expect(page.getByText(/Showing 48 of 48 tools/)).toBeVisible();
});
test("enterprise section renders feature cards", async ({ page }) => {
+10 -18
View File
@@ -9,28 +9,28 @@ test.describe("BentoGrid Interactions", () => {
const input = page.getByPlaceholder("Search tools...");
await input.fill("resize");
await expect(page.getByText("Resize", { exact: true }).first()).toBeVisible();
await expect(page.getByText(/Showing \d+ of 47 tools/)).toBeVisible();
await expect(page.getByText(/Showing \d+ of 48 tools/)).toBeVisible();
});
test("category pill filters tools", async ({ page }) => {
await page.getByText(/AI Tools/).click();
await expect(page.getByText(/Showing 14 of 47 tools/)).toBeVisible();
await expect(page.getByText(/Showing 15 of 48 tools/)).toBeVisible();
await expect(page.getByText("Remove Background")).toBeVisible();
});
test("clicking All resets category filter", async ({ page }) => {
await page.getByText(/AI Tools/).click();
await expect(page.getByText(/Showing 14 of 47 tools/)).toBeVisible();
await expect(page.getByText(/Showing 15 of 48 tools/)).toBeVisible();
await page.getByText(/All \(47\)/).click();
await expect(page.getByText(/Showing 47 of 47 tools/)).toBeVisible();
await page.getByText(/All \(48\)/).click();
await expect(page.getByText(/Showing 48 of 48 tools/)).toBeVisible();
});
test("search with no results shows empty state", async ({ page }) => {
const input = page.getByPlaceholder("Search tools...");
await input.fill("xyznonexistent");
await expect(page.getByText("No tools found. Try a different search.")).toBeVisible();
await expect(page.getByText(/Showing 0 of 47 tools/)).toBeVisible();
await expect(page.getByText(/Showing 0 of 48 tools/)).toBeVisible();
});
test("combined search and category filter works", async ({ page }) => {
@@ -68,29 +68,21 @@ test.describe("FAQ Page Accordion", () => {
test("clicking a question expands the answer", async ({ page }) => {
await page.getByText("Are my files safe and private?").click();
await expect(
page.getByText(/All processing happens on your own server/),
).toBeVisible();
await expect(page.getByText(/All processing happens on your own server/)).toBeVisible();
});
test("clicking again collapses the answer", async ({ page }) => {
const question = page.getByText("Are my files safe and private?");
await question.click();
await expect(
page.getByText(/All processing happens on your own server/),
).toBeVisible();
await expect(page.getByText(/All processing happens on your own server/)).toBeVisible();
await question.click();
await expect(
page.getByText(/All processing happens on your own server/),
).not.toBeVisible();
await expect(page.getByText(/All processing happens on your own server/)).not.toBeVisible();
});
test("multiple FAQs can be open simultaneously", async ({ page }) => {
await page.getByText("Are my files safe and private?").click();
await page.getByText("Is SnapOtter really free?").click();
await expect(
page.getByText(/All processing happens on your own server/),
).toBeVisible();
await expect(page.getByText(/All processing happens on your own server/)).toBeVisible();
await expect(page.getByText(/open source under AGPL-3.0/)).toBeVisible();
});
});
+1 -1
View File
@@ -289,7 +289,7 @@ test.describe("GUI Settings - Tools Tab (deep)", () => {
// Each tool row has an enable/disable toggle (w-11 h-6 rounded-full)
const toolToggles = page.locator("button.w-11.h-6");
const count = await toolToggles.count();
// Should have many tools (SnapOtter has 47)
// Should have many tools (SnapOtter has 48)
expect(count).toBeGreaterThan(10);
});
+127
View File
@@ -831,4 +831,131 @@ test.describe("GUI AI Tools", () => {
).toBeVisible({ timeout: 10_000 });
});
});
// ========================================================================
// TRANSPARENCY FIXER
// ========================================================================
test.describe("PNG Transparency Fixer", () => {
test("renders tool page with dropzone", async ({ loggedInPage: page }) => {
await page.goto("/transparency-fixer");
await expect(page.getByText("PNG Transparency Fixer").first()).toBeVisible();
await expect(page.getByText("Upload from computer")).toBeVisible();
});
test("shows description text and submit button after upload", async ({
loggedInPage: page,
}) => {
await page.goto("/transparency-fixer");
await uploadTestImage(page);
await expect(page.getByText("Upload a PNG with a fake transparent background")).toBeVisible();
await expect(page.getByTestId("transparency-fixer-submit")).toBeVisible();
await expect(page.getByTestId("transparency-fixer-submit")).toHaveText(/Fix Transparency/);
});
test("advanced section is collapsed by default", async ({ loggedInPage: page }) => {
await page.goto("/transparency-fixer");
await uploadTestImage(page);
// Advanced toggle should be visible
await expect(page.getByText("Advanced")).toBeVisible();
// Defringe slider and Output Format should NOT be visible
await expect(page.getByText("Defringe")).not.toBeVisible();
await expect(page.getByText("Output Format")).not.toBeVisible();
});
test("advanced section toggles open with defringe and output format", async ({
loggedInPage: page,
}) => {
await page.goto("/transparency-fixer");
await uploadTestImage(page);
// Open advanced section
await page.getByText("Advanced").click();
// Defringe slider should be visible with default value 30
await expect(page.getByText("Defringe")).toBeVisible();
await expect(page.getByText("30")).toBeVisible();
// Output format dropdown should be visible
await expect(page.getByText("Output Format")).toBeVisible();
const formatSelect = page.locator("select");
await expect(formatSelect.first()).toBeVisible();
await expect(formatSelect.first()).toHaveValue("png");
});
test("defringe slider is interactive", async ({ loggedInPage: page }) => {
await page.goto("/transparency-fixer");
await uploadTestImage(page);
// Open advanced section
await page.getByText("Advanced").click();
// The slider should exist and be interactive
const slider = page.locator("input[type='range']").first();
await expect(slider).toBeVisible();
await expect(slider).toHaveAttribute("min", "0");
await expect(slider).toHaveAttribute("max", "100");
});
test("output format dropdown allows switching to WebP", async ({ loggedInPage: page }) => {
await page.goto("/transparency-fixer");
await uploadTestImage(page);
// Open advanced section
await page.getByText("Advanced").click();
const formatSelect = page.locator("select").first();
await formatSelect.selectOption("webp");
await expect(formatSelect).toHaveValue("webp");
// Switch back to PNG
await formatSelect.selectOption("png");
await expect(formatSelect).toHaveValue("png");
});
test("submit button disabled without file, enabled with file", async ({
loggedInPage: page,
}) => {
await page.goto("/transparency-fixer");
const submitBtn = page.getByTestId("transparency-fixer-submit");
await expect(submitBtn).toBeDisabled();
await uploadTestImage(page);
await expect(submitBtn).toBeEnabled();
await expect(submitBtn).toHaveText(/Fix Transparency/);
});
test("shows multi-file text for batch upload", async ({ loggedInPage: page }) => {
await page.goto("/transparency-fixer");
// Upload multiple files
const fileChooserPromise = page.waitForEvent("filechooser");
await page.locator("[class*='border-dashed']").first().click();
const fileChooser = await fileChooserPromise;
const path = await import("node:path");
const fixtures = path.join(process.cwd(), "tests", "fixtures");
await fileChooser.setFiles([
path.join(fixtures, "test-200x150.png"),
path.join(fixtures, "test-100x100.jpg"),
]);
await page.waitForTimeout(500);
await expect(page.getByTestId("transparency-fixer-submit")).toHaveText(
/Fix Transparency \(2 files\)/,
);
});
test.skip("shows feature-not-installed warning when AI sidecar is down", async ({
loggedInPage: page,
}) => {
await page.goto("/transparency-fixer");
await uploadTestImage(page);
await expect(
page.locator("text=/not installed|Feature.*not|is not available/i").first(),
).toBeVisible({ timeout: 10_000 });
});
});
});
+2
View File
@@ -41,6 +41,7 @@ const TOOLS_WITH_DROPZONE = [
{ id: "vectorize", name: "Image to SVG" },
{ id: "gif-tools", name: "GIF" },
{ id: "noise-removal", name: "Noise Removal" },
{ id: "transparency-fixer", name: "PNG Transparency Fixer" },
];
const TOOLS_WITHOUT_DROPZONE = [{ id: "qr-generate", name: "QR Code" }];
@@ -53,6 +54,7 @@ const AI_TOOL_IDS = new Set([
"blur-faces",
"smart-crop",
"noise-removal",
"transparency-fixer",
]);
test.describe("All tool pages render", () => {
+180
View File
@@ -0,0 +1,180 @@
import path from "node:path";
import { expect, isAiSidecarRunning, test } from "./helpers";
// ---------------------------------------------------------------------------
// PNG Transparency Fixer tool - e2e tests.
// Covers UI rendering, advanced settings, processing flow, and result display.
// ---------------------------------------------------------------------------
function fixturePath(name: string): string {
return path.join(process.cwd(), "tests", "fixtures", name);
}
async function uploadFile(page: import("@playwright/test").Page, filePath: string) {
const fileChooserPromise = page.waitForEvent("filechooser");
const dropzone = page.locator("[class*='border-dashed']").first();
await dropzone.click();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(filePath);
await page.waitForTimeout(500);
}
async function fixTransparencyAndWait(page: import("@playwright/test").Page) {
await page.getByTestId("transparency-fixer-submit").click();
// Wait for the before/after slider or result image to appear (AI processing can be slow)
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible({
timeout: 300_000,
});
// Ensure the submit button re-appears (processing finished, ProgressCard gone)
await expect(page.getByTestId("transparency-fixer-submit")).toBeVisible({ timeout: 10_000 });
}
test.describe("PNG Transparency Fixer tool", () => {
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
await page.goto("/transparency-fixer");
try {
await page
.getByTestId("transparency-fixer-submit")
.waitFor({ state: "visible", timeout: 15_000 });
} catch {
test.skip(true, "background-removal feature bundle not installed");
}
if (!(await isAiSidecarRunning(page))) {
test.skip(true, "AI sidecar not running");
}
}
test("page loads with correct title and description", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
// Tool title shown in the settings panel header
await expect(page.getByText("PNG Transparency Fixer")).toBeVisible();
// Description text from the settings component
await expect(page.getByText("Upload a PNG with a fake transparent background")).toBeVisible();
// Submit button disabled with no file
await expect(page.getByTestId("transparency-fixer-submit")).toBeDisabled();
});
test("submit button disabled without file", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await expect(page.getByTestId("transparency-fixer-submit")).toBeDisabled();
});
test("submit button enables after file upload", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-fake-transparency.png"));
await expect(page.getByTestId("transparency-fixer-submit")).toBeEnabled();
});
test("advanced section is collapsed by default", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
// Advanced toggle button should be visible
await expect(page.getByText("Advanced")).toBeVisible();
// Defringe slider and output format should NOT be visible yet
await expect(page.getByText("Defringe")).not.toBeVisible();
await expect(page.getByText("Output Format")).not.toBeVisible();
});
test("advanced section toggles open and shows defringe slider and output format", async ({
loggedInPage: page,
}) => {
await skipIfFeatureNotInstalled(page);
// Open advanced section
await page.getByText("Advanced").click();
// Defringe slider visible
await expect(page.getByText("Defringe")).toBeVisible();
const defringeSlider = page.locator("input[type='range'][min='0'][max='100']");
await expect(defringeSlider).toBeVisible();
// Output format dropdown visible
await expect(page.getByText("Output Format")).toBeVisible();
const formatSelect = page.locator("select");
await expect(formatSelect).toBeVisible();
// Verify default values
await expect(page.getByText("30")).toBeVisible(); // default defringe value
await expect(formatSelect).toHaveValue("png");
});
test("defringe slider is interactive", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
// Open advanced section
await page.getByText("Advanced").click();
const defringeSlider = page.locator("input[type='range'][min='0'][max='100']");
await expect(defringeSlider).toBeVisible();
// Adjust slider value
await defringeSlider.fill("75");
await expect(page.getByText("75")).toBeVisible();
await defringeSlider.fill("0");
await expect(page.getByText("0")).toBeVisible();
});
test("output format dropdown switches to WebP", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
// Open advanced section
await page.getByText("Advanced").click();
const formatSelect = page.locator("select");
await expect(formatSelect).toHaveValue("png");
// Switch to WebP
await formatSelect.selectOption("webp");
await expect(formatSelect).toHaveValue("webp");
// Switch back to PNG
await formatSelect.selectOption("png");
await expect(formatSelect).toHaveValue("png");
});
test("progress indicator appears during processing", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-fake-transparency.png"));
// Click submit
await page.getByTestId("transparency-fixer-submit").click();
// ProgressCard should appear (contains an animated spinner)
await expect(page.locator("[class*='animate-spin']")).toBeVisible({ timeout: 5_000 });
// Wait for processing to complete
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible({
timeout: 300_000,
});
});
test("PNG - fixes transparency and shows before/after result", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-fake-transparency.png"));
await fixTransparencyAndWait(page);
// Before/after slider or result image should be visible
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible();
// No error shown
await expect(page.getByText("Transparency fix failed")).not.toBeVisible();
await expect(page.getByText("Network error")).not.toBeVisible();
});
test("result download is available after processing", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-fake-transparency.png"));
await fixTransparencyAndWait(page);
// ReviewPanel should show with Download button in the sidebar
const downloadButton = page.getByRole("button", { name: /download/i });
await expect(downloadButton).toBeVisible({ timeout: 10_000 });
});
});
@@ -0,0 +1,262 @@
/**
* Integration tests for the transparency-fixer tool (/api/v1/tools/transparency-fixer).
*
* This tool requires the Python sidecar (rembg with BiRefNet HR-matting model).
* Tests accept 200, 202 (sidecar running), and 501 (not installed) for
* processing paths while fully testing validation paths that don't depend on
* the sidecar.
*/
import { readFileSync } from "node:fs";
import { join } from "node:path";
import sharp from "sharp";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { buildTestApp, createMultipartPayload, loginAsAdmin, type TestApp } from "./test-server.js";
const FIXTURES = join(__dirname, "..", "fixtures");
const FAKE_TRANSPARENCY = readFileSync(join(FIXTURES, "test-fake-transparency.png"));
const PNG = readFileSync(join(FIXTURES, "test-200x150.png"));
const JPG = readFileSync(join(FIXTURES, "test-100x100.jpg"));
const WEBP = readFileSync(join(FIXTURES, "test-50x50.webp"));
const SVG = readFileSync(join(FIXTURES, "test-100x100.svg"));
const HEIC = readFileSync(join(FIXTURES, "test-200x150.heic"));
const TINY = readFileSync(join(FIXTURES, "test-1x1.png"));
const TOOL_URL = "/api/v1/tools/transparency-fixer";
let testApp: TestApp;
let app: TestApp["app"];
let adminToken: string;
beforeAll(async () => {
testApp = await buildTestApp();
app = testApp.app;
adminToken = await loginAsAdmin(app);
}, 30_000);
afterAll(async () => {
await testApp.cleanup();
}, 10_000);
/** Helper: build multipart payload and POST to the transparency-fixer endpoint. */
async function postTransparencyFixer(
fileBuffer: Buffer,
filename: string,
settings?: Record<string, unknown>,
) {
const fields: Array<{
name: string;
filename?: string;
contentType?: string;
content: Buffer | string;
}> = [{ name: "file", filename, contentType: "application/octet-stream", content: fileBuffer }];
if (settings !== undefined) {
fields.push({ name: "settings", content: JSON.stringify(settings) });
}
const { body, contentType } = createMultipartPayload(fields);
return app.inject({
method: "POST",
url: TOOL_URL,
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
}
/** Helper: POST with raw settings string (for invalid JSON tests). */
async function postWithRawSettings(fileBuffer: Buffer, filename: string, rawSettings: string) {
const { body, contentType } = createMultipartPayload([
{ name: "file", filename, contentType: "application/octet-stream", content: fileBuffer },
{ name: "settings", content: rawSettings },
]);
return app.inject({
method: "POST",
url: TOOL_URL,
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
}
// ═══════════════════════════════════════════════════════════════════════════
// Happy path
// ═══════════════════════════════════════════════════════════════════════════
describe("PNG Transparency Fixer - Happy path", () => {
it("processes fake-transparency PNG with default settings", async () => {
const res = await postTransparencyFixer(FAKE_TRANSPARENCY, "test-fake-transparency.png", {});
expect([200, 202, 501]).toContain(res.statusCode);
if (res.statusCode === 202) {
const result = JSON.parse(res.body);
expect(result.jobId).toBeDefined();
expect(result.async).toBe(true);
}
if (res.statusCode === 501) {
const result = JSON.parse(res.body);
expect(result.code).toBe("FEATURE_NOT_INSTALLED");
}
}, 120_000);
it("processes standard PNG with default settings", async () => {
const res = await postTransparencyFixer(PNG, "test-200x150.png", {});
expect([200, 202, 501]).toContain(res.statusCode);
}, 120_000);
});
// ═══════════════════════════════════════════════════════════════════════════
// Advanced settings
// ═══════════════════════════════════════════════════════════════════════════
describe("PNG Transparency Fixer - Advanced settings", () => {
it("accepts defringe at 0", async () => {
const res = await postTransparencyFixer(PNG, "test.png", { defringe: 0 });
expect([200, 202, 501]).toContain(res.statusCode);
}, 120_000);
it("accepts defringe at 50", async () => {
const res = await postTransparencyFixer(PNG, "test.png", { defringe: 50 });
expect([200, 202, 501]).toContain(res.statusCode);
}, 120_000);
it("accepts defringe at 100", async () => {
const res = await postTransparencyFixer(PNG, "test.png", { defringe: 100 });
expect([200, 202, 501]).toContain(res.statusCode);
}, 120_000);
it("accepts output format webp", async () => {
const res = await postTransparencyFixer(PNG, "test.png", { outputFormat: "webp" });
expect([200, 202, 501]).toContain(res.statusCode);
}, 120_000);
});
// ═══════════════════════════════════════════════════════════════════════════
// Input format coverage
// ═══════════════════════════════════════════════════════════════════════════
describe("PNG Transparency Fixer - Input format coverage", () => {
it("accepts JPEG input", async () => {
const res = await postTransparencyFixer(JPG, "photo.jpg", {});
expect([200, 202, 501]).toContain(res.statusCode);
}, 120_000);
it("accepts PNG input", async () => {
const res = await postTransparencyFixer(PNG, "image.png", {});
expect([200, 202, 501]).toContain(res.statusCode);
}, 120_000);
it("accepts WebP input", async () => {
const res = await postTransparencyFixer(WEBP, "image.webp", {});
expect([200, 202, 501]).toContain(res.statusCode);
}, 120_000);
it("accepts SVG input", async () => {
const res = await postTransparencyFixer(SVG, "image.svg", {});
expect([200, 202, 501]).toContain(res.statusCode);
}, 120_000);
it("accepts HEIC input", async () => {
const res = await postTransparencyFixer(HEIC, "photo.heic", {});
expect([200, 202, 501]).toContain(res.statusCode);
}, 120_000);
});
// ═══════════════════════════════════════════════════════════════════════════
// Error handling
// ═══════════════════════════════════════════════════════════════════════════
describe("PNG Transparency Fixer - Error handling", () => {
it("rejects requests without a file", async () => {
const { body, contentType } = createMultipartPayload([
{ name: "settings", content: JSON.stringify({}) },
]);
const res = await app.inject({
method: "POST",
url: TOOL_URL,
headers: {
authorization: `Bearer ${adminToken}`,
"content-type": contentType,
},
body,
});
expect([400, 501]).toContain(res.statusCode);
if (res.statusCode === 400) {
const result = JSON.parse(res.body);
expect(result.error).toMatch(/no image/i);
}
});
it("rejects invalid settings JSON", async () => {
const res = await postWithRawSettings(PNG, "test.png", "not valid json{{{");
expect([400, 501]).toContain(res.statusCode);
if (res.statusCode === 400) {
const result = JSON.parse(res.body);
expect(result.error).toMatch(/json/i);
}
});
it("rejects defringe out of range (negative)", async () => {
const res = await postTransparencyFixer(PNG, "test.png", { defringe: -5 });
expect([400, 501]).toContain(res.statusCode);
if (res.statusCode === 400) {
const result = JSON.parse(res.body);
expect(result.error).toMatch(/invalid settings/i);
}
});
it("rejects defringe out of range (>100)", async () => {
const res = await postTransparencyFixer(PNG, "test.png", { defringe: 200 });
expect([400, 501]).toContain(res.statusCode);
if (res.statusCode === 400) {
const result = JSON.parse(res.body);
expect(result.error).toMatch(/invalid settings/i);
}
});
it("rejects invalid output format", async () => {
const res = await postTransparencyFixer(PNG, "test.png", { outputFormat: "bmp" });
expect([400, 501]).toContain(res.statusCode);
if (res.statusCode === 400) {
const result = JSON.parse(res.body);
expect(result.error).toMatch(/invalid settings/i);
}
});
});
// ═══════════════════════════════════════════════════════════════════════════
// Edge cases
// ═══════════════════════════════════════════════════════════════════════════
describe("PNG Transparency Fixer - Edge cases", () => {
it("handles 1x1 pixel image", async () => {
const res = await postTransparencyFixer(TINY, "tiny.png", {});
expect([200, 202, 422, 501]).toContain(res.statusCode);
}, 120_000);
it("handles already-transparent PNG", async () => {
// Create a 50x50 RGBA image with 50% alpha
const semiTransparent = await sharp({
create: {
width: 50,
height: 50,
channels: 4,
background: { r: 128, g: 128, b: 128, alpha: 0.5 },
},
})
.png()
.toBuffer();
const res = await postTransparencyFixer(semiTransparent, "semi-transparent.png", {});
expect([200, 202, 501]).toContain(res.statusCode);
}, 120_000);
});
+9 -9
View File
@@ -25,7 +25,7 @@ function getCountText(): string {
describe("BentoGrid", () => {
it("renders the section heading", () => {
render(<BentoGrid />);
expect(screen.getByText("47 tools. Zero cloud dependency.")).toBeDefined();
expect(screen.getByText("48 tools. Zero cloud dependency.")).toBeDefined();
});
it("renders the search input", () => {
@@ -36,12 +36,12 @@ describe("BentoGrid", () => {
it("shows all tools by default", () => {
render(<BentoGrid />);
const text = getCountText();
expect(text).toMatch(/Showing 47 of 47 tools/);
expect(text).toMatch(/Showing 48 of 48 tools/);
});
it("renders category filter pills including All", () => {
render(<BentoGrid />);
expect(screen.getByText((_, el) => el?.textContent === "All (47)")).toBeDefined();
expect(screen.getByText((_, el) => el?.textContent === "All (48)")).toBeDefined();
expect(screen.getByText(/Essentials/)).toBeDefined();
expect(screen.getByText(/AI Tools/)).toBeDefined();
expect(screen.getByText(/Optimization/)).toBeDefined();
@@ -53,7 +53,7 @@ describe("BentoGrid", () => {
fireEvent.change(input, { target: { value: "resize" } });
expect(screen.getByText("Resize")).toBeDefined();
const text = getCountText();
expect(text).toMatch(/Showing \d+ of 47 tools/);
expect(text).toMatch(/Showing \d+ of 48 tools/);
expect(screen.queryByText("OCR / Text Extraction")).toBeNull();
});
@@ -62,7 +62,7 @@ describe("BentoGrid", () => {
const aiButton = screen.getByText(/AI Tools/);
fireEvent.click(aiButton);
const text = getCountText();
expect(text).toMatch(/Showing 14 of 47 tools/);
expect(text).toMatch(/Showing 15 of 48 tools/);
expect(screen.getByText("Remove Background")).toBeDefined();
expect(screen.queryByText("Resize")).toBeNull();
});
@@ -73,7 +73,7 @@ describe("BentoGrid", () => {
fireEvent.change(input, { target: { value: "xyznonexistent" } });
expect(screen.getByText("No tools found. Try a different search.")).toBeDefined();
const text = getCountText();
expect(text).toMatch(/Showing 0 of 47 tools/);
expect(text).toMatch(/Showing 0 of 48 tools/);
});
it("combines search and category filter", () => {
@@ -89,9 +89,9 @@ describe("BentoGrid", () => {
it("clicking All resets category filter", () => {
render(<BentoGrid />);
fireEvent.click(screen.getByText(/AI Tools/));
expect(getCountText()).toMatch(/Showing 14 of 47 tools/);
fireEvent.click(screen.getByText((_, el) => el?.textContent === "All (47)"));
expect(getCountText()).toMatch(/Showing 47 of 47 tools/);
expect(getCountText()).toMatch(/Showing 15 of 48 tools/);
fireEvent.click(screen.getByText((_, el) => el?.textContent === "All (48)"));
expect(getCountText()).toMatch(/Showing 48 of 48 tools/);
});
it("renders each tool with name and description", () => {
+2 -2
View File
@@ -159,9 +159,9 @@ describe("Pricing", () => {
it("renders free plan features", () => {
render(<Pricing />);
expect(screen.getByText("All 47 image processing tools")).toBeDefined();
expect(screen.getByText("All 48 image processing tools")).toBeDefined();
expect(screen.getByText("Unlimited usage, no hidden caps")).toBeDefined();
expect(screen.getByText("14 local AI models included")).toBeDefined();
expect(screen.getByText("15 local AI models included")).toBeDefined();
expect(screen.getByText("AGPL-3.0 licensed")).toBeDefined();
});