mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
- Fix SKIP_MUST_CHANGE_PASSWORD not affecting login/session API responses, causing frontend redirect even when the env var was set after user creation - Increase Docker Playwright timeouts (test: 600s, expect: 60s, AI processing: 300s) to support CPU-only self-hosted environments - Increase default rate limit from 100 to 50000 req/min for self-hosted deployments - Fix OCR tests: use filechooser pattern (Dropzone has no static file input), correct enhance checkbox default, rewrite for actual fixture behavior - Fix remove-bg tests: update quality labels (Balanced→HD, Best→Max) - Fix noise-removal skip guard: use waitFor() instead of instant isVisible() - Fix automate pipeline save test: clean up stale E2E pipelines before assertion
87 lines
3.3 KiB
TypeScript
87 lines
3.3 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
async function uploadOcrFile(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);
|
|
}
|
|
|
|
async function submitOcr(page: import("@playwright/test").Page) {
|
|
const submit = page.getByTestId("ocr-submit");
|
|
await expect(submit).toBeEnabled();
|
|
await submit.click();
|
|
await expect(page.getByText("Extracted Text")).toBeVisible({ timeout: 300_000 });
|
|
}
|
|
|
|
test.describe("OCR / Text Extraction", () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto("/ocr");
|
|
await page.waitForLoadState("networkidle");
|
|
});
|
|
|
|
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 }) => {
|
|
const checkbox = page.locator('input[type="checkbox"]');
|
|
await expect(checkbox).not.toBeChecked();
|
|
});
|
|
|
|
test("enhance defaults to unchecked when Best is selected", async ({ 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 }) => {
|
|
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 }) => {
|
|
await page.getByText("Language").click();
|
|
await expect(page.locator("select")).toBeVisible();
|
|
|
|
const options = page.locator("select option");
|
|
await expect(options).toHaveCount(8);
|
|
});
|
|
|
|
test("extract text button is disabled without a file", async ({ page }) => {
|
|
const button = page.getByTestId("ocr-submit");
|
|
await expect(button).toBeDisabled();
|
|
});
|
|
|
|
test("uploads image and OCR processing completes", async ({ 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 }) => {
|
|
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 }) => {
|
|
await uploadOcrFile(page, "tests/fixtures/test-blank.png");
|
|
await submitOcr(page);
|
|
|
|
await expect(page.getByText("No text detected")).toBeVisible();
|
|
});
|
|
});
|