mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Add ~500 new E2E tests and ~300 new integration tests covering: - 24 new GUI E2E specs: navigation, responsive layout, keyboard shortcuts, tool UI for all 35 non-AI tools, batch/pipeline workflows, settings/RBAC, visual regression, accessibility, and performance budgets - 3 new E2E-Docker specs: batch workflows, advanced pipelines, cross-format - 1 new adversarial integration test: memory pressure, corrupted files, unicode filenames, extreme dimensions, pipeline/batch edge cases - 29 expanded integration test files: HEIC/HEIF input, large files, parameter boundaries, batch processing, format edge cases across all tools - Cross-format matrix expanded: 641 tests covering every tool x 18 formats - AI bridge unit tests expanded: lifecycle, tool modules, error propagation - Unit test gaps filled: analytics, tool-registry, web stores Also fixes: - vitest.config.ts: exclude e2e-docs and e2e-landing from Vitest runner - AI E2E specs: add sidecar health check to skip gracefully when Python AI backend is not running instead of timing out
109 lines
3.7 KiB
TypeScript
109 lines
3.7 KiB
TypeScript
import { expect, type Page } from "@playwright/test";
|
|
import { getTestImagePath, test } from "./helpers";
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Cross-browser smoke tests -- critical flows validated on Chromium.
|
|
// To add Firefox/WebKit, configure additional projects in playwright.config.ts.
|
|
// ---------------------------------------------------------------------------
|
|
|
|
const MOD = process.platform === "darwin" ? "Meta" : "Control";
|
|
|
|
async function uploadImage(page: Page) {
|
|
const testImagePath = getTestImagePath();
|
|
const fileChooserPromise = page.waitForEvent("filechooser");
|
|
const dropzone = page.locator("[class*='border-dashed']").first();
|
|
await dropzone.click();
|
|
const fileChooser = await fileChooserPromise;
|
|
await fileChooser.setFiles(testImagePath);
|
|
await page.waitForTimeout(500);
|
|
}
|
|
|
|
function collectConsoleErrors(page: Page): string[] {
|
|
const errors: string[] = [];
|
|
page.on("console", (msg) => {
|
|
if (msg.type() === "error") {
|
|
const text = msg.text();
|
|
if (text.includes("favicon") || text.includes("analytics")) return;
|
|
errors.push(text);
|
|
}
|
|
});
|
|
return errors;
|
|
}
|
|
|
|
test.describe("Cross-browser smoke tests", () => {
|
|
test("login flow: fill form, submit, verify redirect", async ({ loggedInPage: page }) => {
|
|
const errors = collectConsoleErrors(page);
|
|
await expect(page).toHaveURL("/");
|
|
expect(errors).toHaveLength(0);
|
|
});
|
|
|
|
test("home page file upload: upload image, verify preview", async ({ loggedInPage: page }) => {
|
|
const errors = collectConsoleErrors(page);
|
|
await page.waitForLoadState("networkidle");
|
|
|
|
await uploadImage(page);
|
|
|
|
await expect(page.locator("[class*='text-green']").first()).toBeVisible();
|
|
|
|
expect(errors).toHaveLength(0);
|
|
});
|
|
|
|
test("theme toggle: click toggle, verify theme changes", async ({ loggedInPage: page }) => {
|
|
const errors = collectConsoleErrors(page);
|
|
await page.waitForLoadState("networkidle");
|
|
|
|
const hadDarkBefore = await page.evaluate(() =>
|
|
document.documentElement.classList.contains("dark"),
|
|
);
|
|
|
|
const themeBtn = page.locator("button[title='Toggle Theme']");
|
|
await expect(themeBtn).toBeVisible({ timeout: 10_000 });
|
|
await themeBtn.click();
|
|
await page.waitForTimeout(300);
|
|
|
|
const hasDarkAfter = await page.evaluate(() =>
|
|
document.documentElement.classList.contains("dark"),
|
|
);
|
|
|
|
expect(hasDarkAfter).not.toBe(hadDarkBefore);
|
|
|
|
expect(errors).toHaveLength(0);
|
|
});
|
|
|
|
test("settings dialog: open, switch tabs, close", async ({ loggedInPage: page }) => {
|
|
const errors = collectConsoleErrors(page);
|
|
await page.waitForLoadState("networkidle");
|
|
|
|
await page.locator("aside").getByText("Settings").click();
|
|
await expect(page.getByRole("heading", { name: "General" })).toBeVisible();
|
|
|
|
await page.getByRole("button", { name: "About" }).click();
|
|
await page.waitForTimeout(300);
|
|
await expect(page.getByText(/about/i).first()).toBeVisible();
|
|
|
|
await page.getByRole("button", { name: "Security" }).click();
|
|
await page.waitForTimeout(300);
|
|
await expect(page.getByText(/security/i).first()).toBeVisible();
|
|
|
|
await page.keyboard.press("Escape");
|
|
await page.waitForTimeout(300);
|
|
await expect(page.getByRole("heading", { name: "General" })).not.toBeVisible();
|
|
|
|
expect(errors).toHaveLength(0);
|
|
});
|
|
|
|
test("keyboard shortcut: Cmd/Ctrl+K focuses search bar", async ({ loggedInPage: page }) => {
|
|
const errors = collectConsoleErrors(page);
|
|
await page.waitForLoadState("networkidle");
|
|
|
|
const searchInput = page.getByPlaceholder(/search/i).first();
|
|
await expect(searchInput).toBeVisible();
|
|
|
|
await page.keyboard.press(`${MOD}+k`);
|
|
|
|
await expect(searchInput).toBeFocused();
|
|
|
|
expect(errors).toHaveLength(0);
|
|
});
|
|
});
|