2026-04-19 19:52:23 +08:00
|
|
|
import path from "node:path";
|
2026-04-29 01:39:25 +08:00
|
|
|
import { expect, isAiSidecarRunning, test } from "./helpers";
|
2026-04-19 19:52:23 +08:00
|
|
|
|
|
|
|
|
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", () => {
|
2026-04-20 20:53:54 +08:00
|
|
|
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
|
2026-04-19 19:52:23 +08:00
|
|
|
await page.goto("/blur-faces");
|
2026-04-20 20:53:54 +08:00
|
|
|
try {
|
|
|
|
|
await page.getByTestId("blur-faces-submit").waitFor({ state: "visible", timeout: 15_000 });
|
|
|
|
|
} catch {
|
|
|
|
|
test.skip(true, "face-detection feature bundle not installed");
|
|
|
|
|
}
|
2026-04-29 01:39:25 +08:00
|
|
|
if (!(await isAiSidecarRunning(page))) {
|
|
|
|
|
test.skip(true, "AI sidecar not running");
|
|
|
|
|
}
|
2026-04-20 20:53:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test("page loads with correct UI controls", async ({ loggedInPage: page }) => {
|
|
|
|
|
await skipIfFeatureNotInstalled(page);
|
2026-04-19 19:52:23 +08:00
|
|
|
|
|
|
|
|
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 }) => {
|
2026-04-20 20:53:54 +08:00
|
|
|
await skipIfFeatureNotInstalled(page);
|
2026-04-19 19:52:23 +08:00
|
|
|
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(
|
2026-04-20 10:56:47 +08:00
|
|
|
page.getByTestId("blur-faces-download").or(page.getByText("No faces detected")).first(),
|
2026-04-20 15:03:56 +08:00
|
|
|
).toBeVisible({ timeout: 300_000 });
|
2026-04-19 19:52:23 +08:00
|
|
|
|
|
|
|
|
await expect(page.locator("text=cannot identify image")).not.toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("no-face image shows warning message", async ({ loggedInPage: page }) => {
|
2026-04-20 20:53:54 +08:00
|
|
|
await skipIfFeatureNotInstalled(page);
|
2026-04-19 19:52:23 +08:00
|
|
|
await uploadFile(page, fixturePath("test-blank.png"));
|
|
|
|
|
|
|
|
|
|
await page.getByTestId("blur-faces-submit").click();
|
|
|
|
|
|
2026-04-20 15:03:56 +08:00
|
|
|
await expect(page.getByText("No faces detected")).toBeVisible({ timeout: 300_000 });
|
2026-04-19 19:52:23 +08:00
|
|
|
});
|
|
|
|
|
});
|