mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Fixes all integration CI failures on the 2.0 branch.
## What was broken
Two independent root causes:
1. **202 assertion failures** -- Under 4-fork CI parallel load, the 30s
`SYNC_WAIT_MS` sync window can expire before a BullMQ worker finishes a
heavy encode (avif, heic), returning a legitimate `202 {jobId, async: true}`
instead of `200`. Tests that hard-asserted `200` were spuriously failing.
2. **Vitest timeout race** -- `SYNC_WAIT_MS` (30s) and the default Vitest
`testTimeout` (also 30s) fired simultaneously. Vitest won the race,
reporting "Test timed out in 30000ms" instead of the test receiving the
202 response.
## Fixes
- Added `isAsyncFallback()` helper to four integration test files; validates
the `{async: true, jobId}` body shape and returns early so the synchronous
200 path runs full assertions only when warranted.
- Set `vi.setConfig({ testTimeout: 60_000 })` at module level in
`image-enhancement.test.ts` and `format-matrix-comprehensive.test.ts`,
giving a 30s buffer between when `waitForJob()` returns 202 and when
Vitest gives up.
- Bumped explicit matrix timeouts in `format-matrix.test.ts` and
`new-formats.test.ts` from 30s to 60s for the same reason.
- Installed missing CI doc-engine binaries (qpdf, pandoc, libreoffice,
pdfcpu) that were causing unrelated integration failures.
- Fixed E2E smoke specs for 2.0 UI changes (modality selector, tool routes,
validation behavior).
88 lines
3.7 KiB
TypeScript
88 lines
3.7 KiB
TypeScript
import { expect, test } from "./helpers";
|
|
|
|
test.describe("Home Page", () => {
|
|
test("shows branding and search bar", async ({ loggedInPage: page }) => {
|
|
// The wordmark renders as a logo image, not text; the document title is
|
|
// the stable brand assertion.
|
|
await expect(page).toHaveTitle(/SnapOtter/i);
|
|
|
|
// 2.0 home page is a tool grid with a search bar (no dropzone)
|
|
await expect(page.locator("[data-search-input]")).toBeVisible();
|
|
});
|
|
|
|
test("modality tabs are visible", async ({ loggedInPage: page }) => {
|
|
// 2.0 home page has modality tabs: All, Image, Video, Audio, PDF, Data
|
|
// Tab buttons render label + a count span, so the accessible name is e.g.
|
|
// "Image5" (no word boundary before the digit) — match on the label prefix.
|
|
await expect(page.getByRole("button", { name: /^All/ }).first()).toBeVisible();
|
|
await expect(page.getByRole("button", { name: /^Image/ }).first()).toBeVisible();
|
|
await expect(page.getByRole("button", { name: /^Video/ }).first()).toBeVisible();
|
|
await expect(page.getByRole("button", { name: /^Audio/ }).first()).toBeVisible();
|
|
await expect(page.getByRole("button", { name: /^PDF/ }).first()).toBeVisible();
|
|
await expect(page.getByRole("button", { name: /^Data/ }).first()).toBeVisible();
|
|
});
|
|
|
|
test("tool categories are visible on home page", async ({ loggedInPage: page }) => {
|
|
// Search bar should be visible
|
|
await expect(page.getByPlaceholder(/search/i).first()).toBeVisible();
|
|
|
|
// Tool categories should be visible under All tab (default)
|
|
await expect(page.getByText("Essentials").first()).toBeVisible();
|
|
});
|
|
|
|
test("search filters tools", async ({ loggedInPage: page }) => {
|
|
const searchInput = page.getByPlaceholder(/search/i).first();
|
|
await searchInput.fill("compress");
|
|
|
|
// Should show Compress tool
|
|
await expect(page.getByText("Compress").first()).toBeVisible();
|
|
});
|
|
|
|
test("clicking a tool card navigates to tool page", async ({ loggedInPage: page }) => {
|
|
// Find and click a tool link (Resize is in Image > Essentials)
|
|
await page.locator("a").filter({ hasText: "Resize" }).first().click();
|
|
|
|
// 2.0 routes are /{modality}/{toolId}
|
|
await expect(page).toHaveURL("/image/resize");
|
|
});
|
|
|
|
test("modality tab filters tools by modality", async ({ loggedInPage: page }) => {
|
|
// Click the Video tab
|
|
await page
|
|
.getByRole("button", { name: /^Video/ })
|
|
.first()
|
|
.click();
|
|
|
|
// Should show video-specific category headings (Subtitles is unique to video)
|
|
await expect(page.getByText("Subtitles").first()).toBeVisible();
|
|
|
|
// Image-only categories should not be present
|
|
await expect(page.getByText("Essentials")).not.toBeVisible();
|
|
});
|
|
|
|
test("search shows no-results message for unknown query", async ({ loggedInPage: page }) => {
|
|
const searchInput = page.getByPlaceholder(/search/i).first();
|
|
await searchInput.fill("xyznonexistent");
|
|
|
|
// Should show no-results message (en.ts: homePage.noToolsMatch)
|
|
await expect(page.getByText(/no tools match/i).first()).toBeVisible();
|
|
});
|
|
|
|
test("search can be cleared", async ({ loggedInPage: page }) => {
|
|
const searchInput = page.getByPlaceholder(/search/i).first();
|
|
await searchInput.fill("xyznonexistent");
|
|
|
|
// Should show no-results with a clear button (en.ts: homePage.clearSearch)
|
|
await expect(page.getByText(/no tools match/i).first()).toBeVisible();
|
|
await page.getByText("Clear search").click();
|
|
|
|
// Tool grid should reappear after clearing
|
|
await expect(page.getByText("Essentials").first()).toBeVisible();
|
|
});
|
|
|
|
test("top nav has theme toggle", async ({ loggedInPage: page }) => {
|
|
// Theme toggle moved to the top-nav header in 2.0
|
|
await expect(page.getByTitle("Toggle theme")).toBeVisible();
|
|
});
|
|
});
|