Files
SnapOtter/tests/e2e/blur-faces.spec.ts
T
SnapOtterandGitHub 0f98f60c33 test(e2e): modernize stale routes for 2.0 section URLs (#347)
The e2e specs predate the 2.0 section-route migration and navigated to
single-segment tool URLs (/resize) that now 404 (App.tsx only mounts
/:section/:toolId). This broke the whole e2e suite (Cross-Browser, Device
Matrix, E2E Full, Visual) - part of the known stale-spec backlog.

- Sweep 929 goto("/<tool>") -> goto("/<section>/<tool>") across 45 spec
  files, using the authoritative TOOLS + toolSection() mapping. Two-segment
  routes, top-level routes (/automate, /editor, ...), and intentional 404
  tests (/nonexistent-*) are untouched.
- Implement the legacy redirects the specs already assert: the 1.x color
  tools (brightness-contrast, saturation, color-channels, color-effects)
  redirect to /image/adjust-colors (App.tsx). Good for old bookmarks too.
- Remove the analytics-consent page tests (gui-navigation + gui-visual);
  #336 deleted that page.

Mechanical + biome-clean + web typecheck passes. Browser-specific behavior
can only be confirmed by the nightly e2e jobs.
2026-06-24 20:19:37 +08:00

61 lines
2.2 KiB
TypeScript

import path from "node:path";
import { expect, isAiSidecarRunning, 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(1000);
}
test.describe("Blur Faces tool", () => {
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
await page.goto("/image/blur-faces");
try {
await page.getByTestId("blur-faces-submit").waitFor({ state: "visible", timeout: 15_000 });
} catch {
test.skip(true, "face-detection feature bundle not installed");
}
if (!(await isAiSidecarRunning(page))) {
test.skip(true, "AI sidecar not running");
}
}
test("page loads with correct UI controls", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await expect(page.getByText("Blur Radius")).toBeVisible();
await expect(page.getByText("Detection Sensitivity")).toBeVisible();
await expect(page.getByTestId("blur-faces-submit")).toBeVisible();
});
test("HEIC image processes without error", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-portrait.heic"));
await page.getByTestId("blur-faces-submit").click();
// Should complete without the old "cannot identify image file" error
await expect(
page.getByTestId("blur-faces-download").or(page.getByText("No faces detected")).first(),
).toBeVisible({ timeout: 300_000 });
await expect(page.locator("text=cannot identify image")).not.toBeVisible();
});
test("no-face image shows warning message", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-blank.png"));
await page.getByTestId("blur-faces-submit").click();
await expect(page.getByText("No faces detected")).toBeVisible({ timeout: 300_000 });
});
});