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
+37 -14
View File
@@ -1,4 +1,4 @@
import { expect, test } from "@playwright/test";
import { expect, test } from "./helpers";
async function uploadOcrFile(page: import("@playwright/test").Page, filePath: string) {
const fileChooserPromise = page.waitForEvent("filechooser");
@@ -17,37 +17,53 @@ async function submitOcr(page: import("@playwright/test").Page) {
}
test.describe("OCR / Text Extraction", () => {
test.beforeEach(async ({ page }) => {
async function skipIfFeatureNotInstalled(page: import("@playwright/test").Page) {
await page.goto("/ocr");
await page.waitForLoadState("networkidle");
});
try {
await page.getByTestId("ocr-submit").waitFor({ state: "visible", timeout: 15_000 });
} catch {
test.skip(true, "ocr feature bundle not installed");
}
}
test("renders quality selector with three options", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
test("renders quality selector with three options", async ({ page }) => {
const buttons = page.locator("button").filter({ hasText: /^(Fast|Balanced|Best)$/ });
await expect(buttons).toHaveCount(3);
// Balanced should be selected by default
const balanced = page.locator("button").filter({ hasText: "Balanced" });
await expect(balanced).toHaveClass(/border-primary/);
});
test("renders enhance checkbox defaulting to unchecked", async ({ page }) => {
test("renders enhance checkbox defaulting to unchecked", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
const checkbox = page.locator('input[type="checkbox"]');
await expect(checkbox).not.toBeChecked();
});
test("enhance defaults to unchecked when Best is selected", async ({ page }) => {
test("enhance defaults to unchecked when Best is selected", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await page.locator("button").filter({ hasText: "Best" }).click();
const checkbox = page.locator('input[type="checkbox"]');
await expect(checkbox).not.toBeChecked();
});
test("language section is collapsed by default showing auto-detect", async ({ page }) => {
test("language section is collapsed by default showing auto-detect", async ({
loggedInPage: page,
}) => {
await skipIfFeatureNotInstalled(page);
await expect(page.getByText("auto-detect", { exact: false })).toBeVisible();
await expect(page.locator("select")).not.toBeVisible();
});
test("language section expands to show dropdown", async ({ page }) => {
test("language section expands to show dropdown", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await page.getByText("Language").click();
await expect(page.locator("select")).toBeVisible();
@@ -55,29 +71,36 @@ test.describe("OCR / Text Extraction", () => {
await expect(options).toHaveCount(8);
});
test("extract text button is disabled without a file", async ({ page }) => {
test("extract text button is disabled without a file", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
const button = page.getByTestId("ocr-submit");
await expect(button).toBeDisabled();
});
test("uploads image and OCR processing completes", async ({ page }) => {
test("uploads image and OCR processing completes", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await uploadOcrFile(page, "tests/fixtures/test-portrait.jpg");
await submitOcr(page);
// OCR completed — shows either extracted text or "no text" message
const hasText = await page.getByTestId("ocr-result-text").isVisible();
const hasNoText = await page.getByText("No text detected").isVisible();
expect(hasText || hasNoText).toBe(true);
});
test("copy button is visible after OCR completes", async ({ page }) => {
test("copy button is visible after OCR completes", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await uploadOcrFile(page, "tests/fixtures/test-portrait.jpg");
await submitOcr(page);
await expect(page.getByText("Copy")).toBeVisible();
});
test("shows 'no text detected' for blank image", async ({ page }) => {
test("shows 'no text detected' for blank image", async ({ loggedInPage: page }) => {
await skipIfFeatureNotInstalled(page);
await uploadOcrFile(page, "tests/fixtures/test-blank.png");
await submitOcr(page);