fix: resolve ONNX CUDA fallback, Docker e2e infrastructure, and all test failures

- 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
This commit is contained in:
ashim-hq
2026-04-20 20:53:54 +08:00
parent f67a03bb36
commit 37277e5c09
23 changed files with 203 additions and 94 deletions
+27 -16
View File
@@ -31,8 +31,19 @@ async function removeBgAndWait(page: import("@playwright/test").Page) {
}
test.describe("Remove Background tool", () => {
test("page loads with correct UI sections", async ({ loggedInPage: page }) => {
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
await page.goto("/remove-background");
try {
await page
.getByTestId("remove-background-submit")
.waitFor({ state: "visible", timeout: 15_000 });
} catch {
test.skip(true, "background-removal feature bundle not installed");
}
}
test("page loads with correct UI sections", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await expect(page.getByText("People")).toBeVisible();
await expect(page.getByText("Products")).toBeVisible();
@@ -58,7 +69,7 @@ test.describe("Remove Background tool", () => {
test("passport checkbox defaults ON for people, OFF for other subjects", async ({
loggedInPage: page,
}) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
const passportCheckbox = page.locator("input[type='checkbox']").first();
await expect(passportCheckbox).toBeChecked();
@@ -72,7 +83,7 @@ test.describe("Remove Background tool", () => {
});
test("background type controls show/hide sub-options", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
await page.getByRole("button", { name: "Color" }).click();
await expect(page.locator("input[type='color']").first()).toBeVisible();
@@ -87,7 +98,7 @@ test.describe("Remove Background tool", () => {
});
test("effects section expands with blur and shadow controls", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
await page.getByText("Effects").click();
await expect(page.getByText("Blur Background")).toBeVisible();
@@ -101,7 +112,7 @@ test.describe("Remove Background tool", () => {
});
test("JPG portrait - transparent background removal", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-portrait.jpg"));
await removeBgAndWait(page);
@@ -109,7 +120,7 @@ test.describe("Remove Background tool", () => {
});
test("Ultra quality visible for People, hidden for Products", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
// People is default - Ultra should be visible
await expect(page.getByRole("button", { name: "Ultra" })).toBeVisible();
@@ -124,7 +135,7 @@ test.describe("Remove Background tool", () => {
});
test("Ultra quality processes JPG portrait", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-portrait.jpg"));
// Select Ultra quality
@@ -136,7 +147,7 @@ test.describe("Remove Background tool", () => {
});
test("HEIC portrait - processes without error", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-portrait.heic"));
await removeBgAndWait(page);
@@ -146,7 +157,7 @@ test.describe("Remove Background tool", () => {
test("two-phase: remove bg then download with color background", async ({
loggedInPage: page,
}) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-portrait.jpg"));
// Phase 1
@@ -165,7 +176,7 @@ test.describe("Remove Background tool", () => {
});
test("two-phase: remove bg then download with gradient", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-portrait.jpg"));
await removeBgAndWait(page);
@@ -179,7 +190,7 @@ test.describe("Remove Background tool", () => {
});
test("two-phase: remove bg then download with blur", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-portrait.jpg"));
await removeBgAndWait(page);
@@ -198,7 +209,7 @@ test.describe("Remove Background tool", () => {
});
test("two-phase: remove bg then download with shadow", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-portrait.jpg"));
await removeBgAndWait(page);
@@ -213,7 +224,7 @@ test.describe("Remove Background tool", () => {
});
test("two-phase: remove bg then download with blur + shadow", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-portrait.jpg"));
await removeBgAndWait(page);
@@ -229,7 +240,7 @@ test.describe("Remove Background tool", () => {
});
test("two-phase: custom bg image + blur shows uploaded bg", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-portrait.jpg"));
await page.getByRole("button", { name: "Image" }).click();
@@ -254,7 +265,7 @@ test.describe("Remove Background tool", () => {
test("two-phase: HEIC background image works for preview and download", async ({
loggedInPage: page,
}) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
await uploadFile(page, fixturePath("test-portrait.jpg"));
await page.getByRole("button", { name: "Image" }).click();
@@ -273,7 +284,7 @@ test.describe("Remove Background tool", () => {
});
test("batch - JPG + HEIC processes both", async ({ loggedInPage: page }) => {
await page.goto("/remove-background");
await skipIfFeatureNotInstalled(page);
const files = [fixturePath("test-portrait.jpg"), fixturePath("test-portrait.heic")];
const fileChooserPromise = page.waitForEvent("filechooser");