fix: resolve all audit findings — e2e coverage, feature system hardening, visual baselines
- Add 8 new E2E specs for AI tools (upscale, enhance-faces, colorize, restore-photo, erase-object, smart-crop, passport-photo, red-eye-removal) closing all HIGH/MEDIUM coverage gaps from the test matrix audit - Fix ensureAiDirs() crash on non-Docker environments by gating on isDockerEnvironment() — prevents ENOENT when /data doesn't exist - Bump torch 2.6.0→2.7.0 and torchvision 0.21.0→0.22.0 in feature manifest for broader Python version compatibility - Add Python 3.14 version guard warning in install_feature.py - Remove duplicate torchvision shims from upscale.py and enhance_faces.py (dispatcher.py already handles this at startup) - Remove orphaned tools.batch i18n key and dead pipeline-builder filter - Regenerate 4 visual regression baselines for current UI state - Add data-testid to passport-photo generate button for E2E testability
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 126 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 136 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 82 KiB |
@@ -0,0 +1,90 @@
|
||||
import path from "node:path";
|
||||
import { expect, test } from "./helpers";
|
||||
|
||||
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 colorizeAndWait(page: import("@playwright/test").Page) {
|
||||
await page.getByTestId("colorize-submit").click();
|
||||
await expect(page.getByTestId("colorize-download")).toBeVisible({ timeout: 300_000 });
|
||||
}
|
||||
|
||||
test.describe("Colorize tool", () => {
|
||||
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
|
||||
await page.goto("/colorize");
|
||||
try {
|
||||
await page.getByTestId("colorize-submit").waitFor({ state: "visible", timeout: 15_000 });
|
||||
} catch {
|
||||
test.skip(true, "object-eraser-colorize feature bundle not installed");
|
||||
}
|
||||
}
|
||||
|
||||
test("page loads with correct UI controls", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
// Model buttons
|
||||
await expect(page.getByRole("button", { name: "Fast" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Balanced" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Best" })).toBeVisible();
|
||||
|
||||
// Color intensity slider
|
||||
await expect(page.getByText("Color Intensity")).toBeVisible();
|
||||
|
||||
// Submit button disabled with no file
|
||||
await expect(page.getByTestId("colorize-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button disabled without file", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await expect(page.getByTestId("colorize-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button enables after file upload", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-200x150.png"));
|
||||
await expect(page.getByTestId("colorize-submit")).toBeEnabled();
|
||||
});
|
||||
|
||||
test("color intensity slider is interactive", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
const slider = page.locator("input[type='range'][min='10'][max='100']");
|
||||
await expect(slider).toBeVisible();
|
||||
|
||||
await slider.fill("50");
|
||||
await expect(page.getByText("50%")).toBeVisible();
|
||||
|
||||
await slider.fill("10");
|
||||
await expect(page.getByText("10%")).toBeVisible();
|
||||
});
|
||||
|
||||
test("JPG - colorizes and shows download", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-100x100.jpg"));
|
||||
|
||||
await colorizeAndWait(page);
|
||||
|
||||
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible();
|
||||
await expect(page.getByText("Colorize failed")).not.toBeVisible();
|
||||
});
|
||||
|
||||
test("HEIC input processes without error", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-200x150.heic"));
|
||||
|
||||
await colorizeAndWait(page);
|
||||
|
||||
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible();
|
||||
await expect(page.getByText("Colorize failed")).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,93 @@
|
||||
import path from "node:path";
|
||||
import { expect, test } from "./helpers";
|
||||
|
||||
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 enhanceFacesAndWait(page: import("@playwright/test").Page) {
|
||||
await page.getByTestId("enhance-faces-submit").click();
|
||||
await expect(page.getByTestId("enhance-faces-download")).toBeVisible({ timeout: 300_000 });
|
||||
}
|
||||
|
||||
test.describe("Enhance Faces tool", () => {
|
||||
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
|
||||
await page.goto("/enhance-faces");
|
||||
try {
|
||||
await page.getByTestId("enhance-faces-submit").waitFor({ state: "visible", timeout: 15_000 });
|
||||
} catch {
|
||||
test.skip(true, "upscale-enhance feature bundle not installed");
|
||||
}
|
||||
}
|
||||
|
||||
test("page loads with correct UI controls", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
// Quality buttons
|
||||
await expect(page.getByRole("button", { name: "Fast" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Balanced" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Best" })).toBeVisible();
|
||||
|
||||
// Strength slider
|
||||
await expect(page.getByText("Enhancement Strength")).toBeVisible();
|
||||
|
||||
// Detection sensitivity slider
|
||||
await expect(page.getByText("Detection Sensitivity")).toBeVisible();
|
||||
|
||||
// Submit button disabled with no file
|
||||
await expect(page.getByTestId("enhance-faces-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button disabled without file", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await expect(page.getByTestId("enhance-faces-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button enables after file upload", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-portrait.jpg"));
|
||||
await expect(page.getByTestId("enhance-faces-submit")).toBeEnabled();
|
||||
});
|
||||
|
||||
test("enhancement strength slider is interactive", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
const slider = page.locator("#enhance-faces-strength");
|
||||
await expect(slider).toBeVisible();
|
||||
|
||||
await slider.fill("50");
|
||||
await expect(page.getByText("50%")).toBeVisible();
|
||||
|
||||
await slider.fill("100");
|
||||
await expect(page.getByText("100%")).toBeVisible();
|
||||
});
|
||||
|
||||
test("JPG portrait - processes and shows download", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-portrait.jpg"));
|
||||
|
||||
await enhanceFacesAndWait(page);
|
||||
|
||||
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible();
|
||||
await expect(page.getByText("Face enhancement failed")).not.toBeVisible();
|
||||
});
|
||||
|
||||
test("HEIC input processes without error", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-200x150.heic"));
|
||||
|
||||
await enhanceFacesAndWait(page);
|
||||
|
||||
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible();
|
||||
await expect(page.getByText("Face enhancement failed")).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,89 @@
|
||||
import path from "node:path";
|
||||
import { expect, test } from "./helpers";
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
test.describe("Erase Object tool", () => {
|
||||
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
|
||||
await page.goto("/erase-object");
|
||||
try {
|
||||
await page.getByTestId("erase-object-submit").waitFor({ state: "visible", timeout: 15_000 });
|
||||
} catch {
|
||||
test.skip(true, "object-eraser-colorize feature bundle not installed");
|
||||
}
|
||||
}
|
||||
|
||||
test("page loads with correct UI controls", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
// Brush size slider
|
||||
await expect(page.getByText("Brush Size")).toBeVisible();
|
||||
await expect(page.locator("#eraser-brush-size")).toBeVisible();
|
||||
|
||||
// Output format dropdown
|
||||
await expect(page.locator("#eraser-format")).toBeVisible();
|
||||
|
||||
// Submit button is disabled with no file
|
||||
await expect(page.getByTestId("erase-object-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button disabled without file", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
await expect(page.getByTestId("erase-object-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button remains disabled with file but no strokes", async ({
|
||||
loggedInPage: page,
|
||||
}) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-200x150.png"));
|
||||
|
||||
// Submit should still be disabled because no strokes have been painted
|
||||
await expect(page.getByTestId("erase-object-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("brush size slider is interactive", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
const slider = page.locator("#eraser-brush-size");
|
||||
await expect(slider).toBeVisible();
|
||||
|
||||
// Change slider value
|
||||
await slider.fill("75");
|
||||
await expect(page.getByText("75px")).toBeVisible();
|
||||
});
|
||||
|
||||
test("quality slider shows for lossy formats only", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
const qualitySlider = page.locator("#eraser-quality");
|
||||
const formatSelect = page.locator("#eraser-format");
|
||||
|
||||
// Default is PNG — quality hidden
|
||||
await expect(qualitySlider).not.toBeVisible();
|
||||
|
||||
// Select JPG — quality visible
|
||||
await formatSelect.selectOption("jpg");
|
||||
await expect(qualitySlider).toBeVisible();
|
||||
|
||||
// Select WEBP — quality visible
|
||||
await formatSelect.selectOption("webp");
|
||||
await expect(qualitySlider).toBeVisible();
|
||||
|
||||
// Back to PNG — quality hidden
|
||||
await formatSelect.selectOption("png");
|
||||
await expect(qualitySlider).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,121 @@
|
||||
import path from "node:path";
|
||||
import { expect, test } from "./helpers";
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
test.describe("Passport Photo tool", () => {
|
||||
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
|
||||
await page.goto("/passport-photo");
|
||||
try {
|
||||
// Wait for the page to load — the country dropdown is always present
|
||||
await page.getByText("Country").waitFor({ state: "visible", timeout: 15_000 });
|
||||
} catch {
|
||||
test.skip(true, "background-removal or face-detection feature bundle not installed");
|
||||
}
|
||||
}
|
||||
|
||||
test("page loads with correct UI controls", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
// Country dropdown
|
||||
await expect(page.getByText("Country")).toBeVisible();
|
||||
|
||||
// DPI input
|
||||
await expect(page.getByText("DPI")).toBeVisible();
|
||||
|
||||
// Background color section
|
||||
await expect(page.getByText("Background Color")).toBeVisible();
|
||||
|
||||
// Max file size section
|
||||
await expect(page.getByText("Max File Size")).toBeVisible();
|
||||
});
|
||||
|
||||
test("country dropdown opens and is searchable", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
// Click the country dropdown button
|
||||
const dropdownButton = page.locator("button", { hasText: "United States" });
|
||||
await dropdownButton.click();
|
||||
|
||||
// Search input should appear
|
||||
const searchInput = page.getByPlaceholder("Search countries...");
|
||||
await expect(searchInput).toBeVisible();
|
||||
|
||||
// Type to filter
|
||||
await searchInput.fill("Canada");
|
||||
await expect(page.locator("button", { hasText: "Canada" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("background color swatches are interactive", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
// Click a non-white swatch (light gray)
|
||||
const graySwatch = page.locator("button[title='Light gray (UK/DE)']");
|
||||
await graySwatch.click();
|
||||
|
||||
// The swatch should become selected (has scale-110 class)
|
||||
await expect(graySwatch).toHaveClass(/scale-110/);
|
||||
});
|
||||
|
||||
test("file size presets are interactive", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
// Click 100 KB preset
|
||||
const preset = page.getByRole("button", { name: "100 KB" });
|
||||
await preset.click();
|
||||
|
||||
// Should have active styling
|
||||
await expect(preset).toHaveClass(/border-primary/);
|
||||
});
|
||||
|
||||
test("submit button disabled without file", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
// No generate button should be visible without a file
|
||||
await expect(page.getByTestId("passport-photo-generate")).not.toBeVisible();
|
||||
});
|
||||
|
||||
test("portrait upload triggers auto-analyze", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-portrait.jpg"));
|
||||
|
||||
// Analysis progress should appear
|
||||
await expect(
|
||||
page.getByText("Analyzing face").or(page.getByText("Detecting landmarks")),
|
||||
).toBeVisible({ timeout: 15_000 });
|
||||
});
|
||||
|
||||
test("generate button appears after analysis", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-portrait.jpg"));
|
||||
|
||||
// Wait for analysis to complete and generate button to appear
|
||||
await expect(page.getByTestId("passport-photo-generate")).toBeVisible({ timeout: 300_000 });
|
||||
});
|
||||
|
||||
test("HEIC portrait input processes without error", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-portrait.heic"));
|
||||
|
||||
// Wait for analysis to complete — either generate button or an error
|
||||
await expect(
|
||||
page
|
||||
.getByTestId("passport-photo-generate")
|
||||
.or(page.getByText("Face analysis failed"))
|
||||
.first(),
|
||||
).toBeVisible({ timeout: 300_000 });
|
||||
|
||||
await expect(page.locator("text=cannot identify image")).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,115 @@
|
||||
import path from "node:path";
|
||||
import { expect, test } from "./helpers";
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
test.describe("Red Eye Removal tool", () => {
|
||||
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
|
||||
await page.goto("/red-eye-removal");
|
||||
try {
|
||||
await page
|
||||
.getByTestId("red-eye-removal-submit")
|
||||
.waitFor({ state: "visible", timeout: 15_000 });
|
||||
} catch {
|
||||
test.skip(true, "face-detection feature bundle not installed");
|
||||
}
|
||||
}
|
||||
|
||||
test("page loads with correct UI controls", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
// Sensitivity slider
|
||||
await expect(page.getByText("Sensitivity")).toBeVisible();
|
||||
|
||||
// Correction Strength slider
|
||||
await expect(page.getByText("Correction Strength")).toBeVisible();
|
||||
|
||||
// Output format buttons
|
||||
await expect(page.getByRole("button", { name: "Original" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "PNG" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "JPEG" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "WEBP" })).toBeVisible();
|
||||
|
||||
// Submit button disabled with no file
|
||||
await expect(page.getByTestId("red-eye-removal-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button disabled without file", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
await expect(page.getByTestId("red-eye-removal-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button enables after file upload", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-200x150.png"));
|
||||
|
||||
await expect(page.getByTestId("red-eye-removal-submit")).toBeEnabled();
|
||||
});
|
||||
|
||||
test("quality slider shows for lossy formats only", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
const qualityText = page.locator("p", { hasText: "Quality" }).last();
|
||||
|
||||
// Original — quality hidden
|
||||
await expect(qualityText).not.toBeVisible();
|
||||
|
||||
// JPEG — quality visible
|
||||
await page.getByRole("button", { name: "JPEG" }).click();
|
||||
await expect(qualityText).toBeVisible();
|
||||
|
||||
// WEBP — quality visible
|
||||
await page.getByRole("button", { name: "WEBP" }).click();
|
||||
await expect(qualityText).toBeVisible();
|
||||
|
||||
// PNG — quality hidden
|
||||
await page.getByRole("button", { name: "PNG" }).click();
|
||||
await expect(qualityText).not.toBeVisible();
|
||||
});
|
||||
|
||||
test("JPG - processes and shows download", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-portrait.jpg"));
|
||||
|
||||
await page.getByTestId("red-eye-removal-submit").click();
|
||||
|
||||
// Wait for download button or "No red eyes detected" message
|
||||
await expect(
|
||||
page
|
||||
.getByTestId("red-eye-removal-download")
|
||||
.or(page.getByText(/no red/i))
|
||||
.first(),
|
||||
).toBeVisible({ timeout: 300_000 });
|
||||
|
||||
// No network errors
|
||||
await expect(page.getByText("Network error")).not.toBeVisible();
|
||||
});
|
||||
|
||||
test("HEIC input processes without error", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-portrait.heic"));
|
||||
|
||||
await page.getByTestId("red-eye-removal-submit").click();
|
||||
|
||||
await expect(
|
||||
page
|
||||
.getByTestId("red-eye-removal-download")
|
||||
.or(page.getByText(/no red/i))
|
||||
.first(),
|
||||
).toBeVisible({ timeout: 300_000 });
|
||||
|
||||
await expect(page.locator("text=cannot identify image")).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,118 @@
|
||||
import path from "node:path";
|
||||
import { expect, test } from "./helpers";
|
||||
|
||||
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 restoreAndWait(page: import("@playwright/test").Page) {
|
||||
await page.getByTestId("restore-photo-submit").click();
|
||||
await expect(page.getByTestId("restore-photo-download")).toBeVisible({ timeout: 300_000 });
|
||||
}
|
||||
|
||||
test.describe("Restore Photo tool", () => {
|
||||
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
|
||||
await page.goto("/restore-photo");
|
||||
try {
|
||||
await page.getByTestId("restore-photo-submit").waitFor({ state: "visible", timeout: 15_000 });
|
||||
} catch {
|
||||
test.skip(true, "photo-restoration feature bundle not installed");
|
||||
}
|
||||
}
|
||||
|
||||
test("page loads with correct UI controls", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
// Mode buttons
|
||||
await expect(page.getByRole("button", { name: "Light" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Auto" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Heavy" })).toBeVisible();
|
||||
|
||||
// Feature checkboxes
|
||||
await expect(page.getByText("Scratch Removal")).toBeVisible();
|
||||
await expect(page.getByText("Face Enhancement")).toBeVisible();
|
||||
await expect(page.getByText("Noise Reduction")).toBeVisible();
|
||||
await expect(page.getByText("Auto-Colorize")).toBeVisible();
|
||||
|
||||
// Submit button disabled with no file
|
||||
await expect(page.getByTestId("restore-photo-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button disabled without file", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await expect(page.getByTestId("restore-photo-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button enables after file upload", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-portrait.jpg"));
|
||||
await expect(page.getByTestId("restore-photo-submit")).toBeEnabled();
|
||||
});
|
||||
|
||||
test("face fidelity slider visible only when face enhancement enabled", async ({
|
||||
loggedInPage: page,
|
||||
}) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
const fidelityLabel = page.getByText("Face Fidelity");
|
||||
|
||||
// Face enhancement is ON by default - fidelity visible
|
||||
await expect(fidelityLabel).toBeVisible();
|
||||
|
||||
// Uncheck face enhancement - fidelity hidden
|
||||
await page.getByText("Face Enhancement").click();
|
||||
await expect(fidelityLabel).not.toBeVisible();
|
||||
|
||||
// Re-enable face enhancement - fidelity visible again
|
||||
await page.getByText("Face Enhancement").click();
|
||||
await expect(fidelityLabel).toBeVisible();
|
||||
});
|
||||
|
||||
test("denoise strength slider visible only when noise reduction enabled", async ({
|
||||
loggedInPage: page,
|
||||
}) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
const denoiseLabel = page.getByText("Denoise Strength");
|
||||
|
||||
// Noise reduction is ON by default - strength visible
|
||||
await expect(denoiseLabel).toBeVisible();
|
||||
|
||||
// Uncheck noise reduction - strength hidden
|
||||
await page.getByText("Noise Reduction").click();
|
||||
await expect(denoiseLabel).not.toBeVisible();
|
||||
|
||||
// Re-enable noise reduction - strength visible again
|
||||
await page.getByText("Noise Reduction").click();
|
||||
await expect(denoiseLabel).toBeVisible();
|
||||
});
|
||||
|
||||
test("JPG - auto mode restores and shows download", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-portrait.jpg"));
|
||||
|
||||
await restoreAndWait(page);
|
||||
|
||||
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible();
|
||||
await expect(page.getByText("Restoration failed")).not.toBeVisible();
|
||||
});
|
||||
|
||||
test("HEIC input processes without error", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-200x150.heic"));
|
||||
|
||||
await restoreAndWait(page);
|
||||
|
||||
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible();
|
||||
await expect(page.getByText("Restoration failed")).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,121 @@
|
||||
import path from "node:path";
|
||||
import { expect, test } from "./helpers";
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
test.describe("Smart Crop tool", () => {
|
||||
test("page loads with correct UI controls", async ({ loggedInPage: page }) => {
|
||||
await page.goto("/smart-crop");
|
||||
|
||||
// Mode tabs
|
||||
await expect(page.getByRole("button", { name: "Subject Focus" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Face Focus" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Auto Trim" })).toBeVisible();
|
||||
|
||||
// Submit button disabled with no file
|
||||
await expect(page.getByTestId("smart-crop-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button disabled without file", async ({ loggedInPage: page }) => {
|
||||
await page.goto("/smart-crop");
|
||||
|
||||
await expect(page.getByTestId("smart-crop-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button enables after file upload", async ({ loggedInPage: page }) => {
|
||||
await page.goto("/smart-crop");
|
||||
await uploadFile(page, fixturePath("test-200x150.png"));
|
||||
|
||||
await expect(page.getByTestId("smart-crop-submit")).toBeEnabled();
|
||||
});
|
||||
|
||||
test("subject mode shows strategy and padding controls", async ({ loggedInPage: page }) => {
|
||||
await page.goto("/smart-crop");
|
||||
|
||||
// Subject Focus is default
|
||||
await expect(page.getByText("Detection Strategy")).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Attention" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Entropy" })).toBeVisible();
|
||||
await expect(page.getByText("Padding")).toBeVisible();
|
||||
await expect(page.getByText("Width (px)")).toBeVisible();
|
||||
await expect(page.getByText("Height (px)")).toBeVisible();
|
||||
});
|
||||
|
||||
test("face mode shows framing and sensitivity controls", async ({ loggedInPage: page }) => {
|
||||
await page.goto("/smart-crop");
|
||||
|
||||
await page.getByRole("button", { name: "Face Focus" }).click();
|
||||
|
||||
await expect(page.getByText("Framing")).toBeVisible();
|
||||
await expect(page.getByText("Detection Sensitivity")).toBeVisible();
|
||||
await expect(page.getByText("Face Padding")).toBeVisible();
|
||||
});
|
||||
|
||||
test("trim mode shows tolerance controls", async ({ loggedInPage: page }) => {
|
||||
await page.goto("/smart-crop");
|
||||
|
||||
await page.getByRole("button", { name: "Auto Trim" }).click();
|
||||
|
||||
await expect(page.getByText("Tolerance")).toBeVisible();
|
||||
await expect(page.getByText("Pad to square")).toBeVisible();
|
||||
});
|
||||
|
||||
test("aspect ratio presets update dimensions", async ({ loggedInPage: page }) => {
|
||||
await page.goto("/smart-crop");
|
||||
|
||||
// Click 16:9 preset
|
||||
await page.getByRole("button", { name: "16:9" }).click();
|
||||
|
||||
const widthInput = page.locator("#sc-width");
|
||||
const heightInput = page.locator("#sc-height");
|
||||
|
||||
await expect(widthInput).toHaveValue("1920");
|
||||
await expect(heightInput).toHaveValue("1080");
|
||||
|
||||
// Click 4:5 preset
|
||||
await page.getByRole("button", { name: "4:5" }).click();
|
||||
|
||||
await expect(widthInput).toHaveValue("1080");
|
||||
await expect(heightInput).toHaveValue("1350");
|
||||
});
|
||||
|
||||
test("JPG - subject focus crops and shows result", async ({ loggedInPage: page }) => {
|
||||
await page.goto("/smart-crop");
|
||||
await uploadFile(page, fixturePath("test-100x100.jpg"));
|
||||
|
||||
// Use default subject mode with attention strategy
|
||||
await page.getByTestId("smart-crop-submit").click();
|
||||
|
||||
// Wait for the processed image preview to appear
|
||||
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible({
|
||||
timeout: 300_000,
|
||||
});
|
||||
|
||||
// No error shown
|
||||
await expect(page.getByText("Network error")).not.toBeVisible();
|
||||
});
|
||||
|
||||
test("HEIC input processes without error", async ({ loggedInPage: page }) => {
|
||||
await page.goto("/smart-crop");
|
||||
await uploadFile(page, fixturePath("test-200x150.heic"));
|
||||
|
||||
await page.getByTestId("smart-crop-submit").click();
|
||||
|
||||
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible({
|
||||
timeout: 300_000,
|
||||
});
|
||||
|
||||
await expect(page.locator("text=cannot identify image")).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,153 @@
|
||||
import path from "node:path";
|
||||
import { expect, test } from "./helpers";
|
||||
|
||||
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 upscaleAndWait(page: import("@playwright/test").Page) {
|
||||
await page.getByTestId("upscale-submit").click();
|
||||
await expect(page.getByTestId("upscale-download")).toBeVisible({ timeout: 300_000 });
|
||||
}
|
||||
|
||||
test.describe("Upscale tool", () => {
|
||||
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
|
||||
await page.goto("/upscale");
|
||||
try {
|
||||
await page.getByTestId("upscale-submit").waitFor({ state: "visible", timeout: 15_000 });
|
||||
} catch {
|
||||
test.skip(true, "upscale-enhance feature bundle not installed");
|
||||
}
|
||||
}
|
||||
|
||||
test("page loads with correct UI controls", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
// Scale factor buttons
|
||||
await expect(page.getByRole("button", { name: "2x" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "4x" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "8x" })).toBeVisible();
|
||||
|
||||
// Quality tier buttons
|
||||
await expect(page.getByRole("button", { name: "Fast" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Balanced" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Best" })).toBeVisible();
|
||||
|
||||
// Output format dropdown
|
||||
await expect(page.locator("#upscale-format")).toBeVisible();
|
||||
|
||||
// Submit button disabled with no file
|
||||
await expect(page.getByTestId("upscale-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button disabled without file", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await expect(page.getByTestId("upscale-submit")).toBeDisabled();
|
||||
});
|
||||
|
||||
test("submit button enables after file upload", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-200x150.png"));
|
||||
await expect(page.getByTestId("upscale-submit")).toBeEnabled();
|
||||
});
|
||||
|
||||
test("scale factor buttons are interactive", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
const btn4x = page.getByRole("button", { name: "4x" });
|
||||
await btn4x.click();
|
||||
await expect(btn4x).toHaveClass(/bg-primary/);
|
||||
|
||||
const btn8x = page.getByRole("button", { name: "8x" });
|
||||
await btn8x.click();
|
||||
await expect(btn8x).toHaveClass(/bg-primary/);
|
||||
});
|
||||
|
||||
test("quality tier buttons are interactive", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
const fast = page.getByRole("button", { name: "Fast" });
|
||||
const balanced = page.getByRole("button", { name: "Balanced" });
|
||||
const best = page.getByRole("button", { name: "Best" });
|
||||
|
||||
await fast.click();
|
||||
await expect(fast).toHaveClass(/bg-primary/);
|
||||
|
||||
await balanced.click();
|
||||
await expect(balanced).toHaveClass(/bg-primary/);
|
||||
|
||||
await best.click();
|
||||
await expect(best).toHaveClass(/bg-primary/);
|
||||
});
|
||||
|
||||
test("face enhance checkbox visibility depends on quality tier", async ({
|
||||
loggedInPage: page,
|
||||
}) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
const faceCheckbox = page.getByText("Enhance faces");
|
||||
|
||||
// Balanced (default) - visible
|
||||
await expect(faceCheckbox).toBeVisible();
|
||||
|
||||
// Fast (lanczos) - hidden
|
||||
await page.getByRole("button", { name: "Fast" }).click();
|
||||
await expect(faceCheckbox).not.toBeVisible();
|
||||
|
||||
// Best (realesrgan) - visible
|
||||
await page.getByRole("button", { name: "Best" }).click();
|
||||
await expect(faceCheckbox).toBeVisible();
|
||||
});
|
||||
|
||||
test("quality slider shows only for lossy output formats", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
|
||||
const formatSelect = page.locator("#upscale-format");
|
||||
|
||||
// PNG (default) - no quality slider
|
||||
await expect(page.getByText("Quality").nth(1)).not.toBeVisible();
|
||||
|
||||
// JPG - quality slider visible
|
||||
await formatSelect.selectOption("jpg");
|
||||
await expect(page.locator("input[type='range'][min='1'][max='100']")).toBeVisible();
|
||||
|
||||
// WEBP - quality slider visible
|
||||
await formatSelect.selectOption("webp");
|
||||
await expect(page.locator("input[type='range'][min='1'][max='100']")).toBeVisible();
|
||||
|
||||
// PNG - quality slider hidden
|
||||
await formatSelect.selectOption("png");
|
||||
await expect(page.locator("input[type='range'][min='1'][max='100']")).not.toBeVisible();
|
||||
});
|
||||
|
||||
test("JPG portrait - balanced tier upscales and shows download", async ({
|
||||
loggedInPage: page,
|
||||
}) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-portrait.jpg"));
|
||||
|
||||
await upscaleAndWait(page);
|
||||
|
||||
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible();
|
||||
await expect(page.getByText("Upscale failed")).not.toBeVisible();
|
||||
});
|
||||
|
||||
test("HEIC input processes without error", async ({ loggedInPage: page }) => {
|
||||
await skipIfFeatureNotInstalled(page);
|
||||
await uploadFile(page, fixturePath("test-200x150.heic"));
|
||||
|
||||
await upscaleAndWait(page);
|
||||
|
||||
await expect(page.locator("section[aria-label='Image area'] img").first()).toBeVisible();
|
||||
await expect(page.getByText("Upscale failed")).not.toBeVisible();
|
||||
});
|
||||
});
|
||||