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
This commit is contained in:
ashim-hq
2026-04-20 18:47:59 +08:00
parent e7eea34080
commit f67a03bb36
20 changed files with 911 additions and 61 deletions
+115
View File
@@ -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();
});
});