mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
- Add safe_onnx_session() to gpu.py with graceful CUDA EP → CPU fallback - Replace bare ort.InferenceSession() calls across colorize, restore, inpaint, remove_bg - Add libcublas-12-6 to production Dockerfile for ONNX Runtime CUDA EP - Add skipIfFeatureNotInstalled guards to remove-bg, blur-faces, smart-crop, ocr, noise-removal e2e specs - Add AI tool install prompt detection in tools-all.spec.ts - Add smart-crop to PYTHON_SIDECAR_TOOLS so frontend shows install prompt correctly - Create Dockerfile.test.dockerignore to include tests/ in test image builds - Add libheif-examples and exiftool to Dockerfile.test for HEIC and metadata tests - Regenerate visual regression baselines for Docker/Linux and skip on non-Docker platforms
144 lines
5.1 KiB
TypeScript
144 lines
5.1 KiB
TypeScript
import { expect, test, uploadTestImage } from "./helpers";
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Test that EVERY tool page loads, shows correct name, and has the right UI.
|
|
// This covers the full 37-tool catalog from the PRD.
|
|
// ---------------------------------------------------------------------------
|
|
|
|
const TOOLS_WITH_DROPZONE = [
|
|
{ id: "resize", name: "Resize" },
|
|
{ id: "crop", name: "Crop" },
|
|
{ id: "rotate", name: "Rotate" },
|
|
{ id: "convert", name: "Convert" },
|
|
{ id: "compress", name: "Compress" },
|
|
{ id: "strip-metadata", name: "Remove Metadata" },
|
|
{ id: "edit-metadata", name: "Edit Metadata" },
|
|
{ id: "bulk-rename", name: "Bulk Rename" },
|
|
{ id: "image-to-pdf", name: "Image to PDF" },
|
|
{ id: "favicon", name: "Favicon" },
|
|
{ id: "adjust-colors", name: "Adjust Colors" },
|
|
{ id: "replace-color", name: "Replace" },
|
|
{ id: "remove-background", name: "Remove Background" },
|
|
{ id: "upscale", name: "Upscal" },
|
|
{ id: "erase-object", name: "Object Eraser" },
|
|
{ id: "ocr", name: "OCR" },
|
|
{ id: "blur-faces", name: "Face" },
|
|
{ id: "smart-crop", name: "Smart Crop" },
|
|
{ id: "watermark-text", name: "Text Watermark" },
|
|
{ id: "watermark-image", name: "Image Watermark" },
|
|
{ id: "text-overlay", name: "Text Overlay" },
|
|
{ id: "compose", name: "Image Composition" },
|
|
{ id: "info", name: "Image Info" },
|
|
{ id: "compare", name: "Image Compare" },
|
|
{ id: "find-duplicates", name: "Find Duplicates" },
|
|
{ id: "color-palette", name: "Color Palette" },
|
|
{ id: "barcode-read", name: "Barcode" },
|
|
{ id: "collage", name: "Collage", customDropzone: true },
|
|
{ id: "stitch", name: "Stitch" },
|
|
{ id: "split", name: "Image Splitting" },
|
|
{ id: "border", name: "Border" },
|
|
{ id: "svg-to-raster", name: "SVG to Raster" },
|
|
{ id: "vectorize", name: "Image to SVG" },
|
|
{ id: "gif-tools", name: "GIF" },
|
|
{ id: "noise-removal", name: "Noise Removal" },
|
|
];
|
|
|
|
const TOOLS_WITHOUT_DROPZONE = [{ id: "qr-generate", name: "QR Code" }];
|
|
|
|
const AI_TOOL_IDS = new Set([
|
|
"remove-background",
|
|
"upscale",
|
|
"erase-object",
|
|
"ocr",
|
|
"blur-faces",
|
|
"smart-crop",
|
|
"noise-removal",
|
|
]);
|
|
|
|
test.describe("All tool pages render", () => {
|
|
for (const tool of TOOLS_WITH_DROPZONE) {
|
|
test(`${tool.name} (/${tool.id}) loads with dropzone`, async ({ loggedInPage: page }) => {
|
|
await page.goto(`/${tool.id}`);
|
|
|
|
// Tool name should be visible
|
|
await expect(page.getByText(tool.name, { exact: false }).first()).toBeVisible();
|
|
|
|
// AI tools may show install prompt instead of dropzone when feature is not installed
|
|
if (AI_TOOL_IDS.has(tool.id)) {
|
|
const uploadVisible = await page.getByText("Upload from computer").isVisible();
|
|
if (!uploadVisible) {
|
|
await expect(
|
|
page.getByText(/additional download|Feature Not Enabled/i).first(),
|
|
).toBeVisible();
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Should show dropzone (some tools like collage use custom upload text)
|
|
const uploadText = (tool as any).customDropzone
|
|
? page.getByText(/upload/i).first()
|
|
: page.getByText("Upload from computer");
|
|
await expect(uploadText).toBeVisible();
|
|
|
|
// Collage has a custom layout (no Files/Settings headings)
|
|
if (!(tool as any).customDropzone) {
|
|
// Should show Files section
|
|
await expect(page.getByText("Files").first()).toBeVisible();
|
|
|
|
// Should show Settings section
|
|
await expect(page.getByText("Settings").first()).toBeVisible();
|
|
}
|
|
});
|
|
}
|
|
|
|
for (const tool of TOOLS_WITHOUT_DROPZONE) {
|
|
test(`${tool.name} (/${tool.id}) loads without dropzone`, async ({ loggedInPage: page }) => {
|
|
await page.goto(`/${tool.id}`);
|
|
|
|
// Tool name should be visible
|
|
await expect(page.getByText(tool.name, { exact: false }).first()).toBeVisible();
|
|
|
|
// Should show settings
|
|
await expect(page.getByText("Settings").first()).toBeVisible();
|
|
|
|
// Should NOT show the file upload dropzone
|
|
await expect(page.getByText("Upload from computer")).not.toBeVisible();
|
|
});
|
|
}
|
|
});
|
|
|
|
test.describe("Tool pages accept file upload", () => {
|
|
// Test a representative subset (testing all 35 would be very slow)
|
|
const REPRESENTATIVE_TOOLS = [
|
|
"resize",
|
|
"compress",
|
|
"convert",
|
|
"strip-metadata",
|
|
"adjust-colors",
|
|
"watermark-text",
|
|
"info",
|
|
"border",
|
|
"vectorize",
|
|
"gif-tools",
|
|
];
|
|
|
|
for (const toolId of REPRESENTATIVE_TOOLS) {
|
|
test(`${toolId} accepts file upload`, async ({ loggedInPage: page }) => {
|
|
await page.goto(`/${toolId}`);
|
|
await uploadTestImage(page);
|
|
|
|
// After upload, dropzone should be replaced with image viewer
|
|
await expect(page.getByText("Upload from computer")).not.toBeVisible();
|
|
// Should show file info (Selected: or the filename)
|
|
await expect(page.getByText(/selected|test-image/i).first()).toBeVisible();
|
|
});
|
|
}
|
|
});
|
|
|
|
test.describe("Tool not found", () => {
|
|
test("nonexistent tool shows error", async ({ loggedInPage: page }) => {
|
|
await page.goto("/nonexistent-tool-xyz");
|
|
await expect(page.getByText(/not found/i)).toBeVisible();
|
|
});
|
|
});
|