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).
92 lines
4.3 KiB
TypeScript
92 lines
4.3 KiB
TypeScript
import { expect, test } from "./helpers";
|
|
|
|
test.describe("Navigation", () => {
|
|
test("nav Tools link goes to home", async ({ loggedInPage: page }) => {
|
|
await page.goto("/automate");
|
|
// Top-nav link: top-nav.tsx useNavLinks() -> { label: t.sidebar.tools, href: "/" }
|
|
await page.getByRole("link", { name: "Tools" }).click();
|
|
await expect(page).toHaveURL("/");
|
|
});
|
|
|
|
test("nav Files link goes to files page", async ({ loggedInPage: page }) => {
|
|
// Top-nav link: top-nav.tsx useNavLinks() -> { label: t.sidebar.files, href: "/files" }.
|
|
// Scope to the nav landmark so a stray "Files" link elsewhere can't make this strict-mode ambiguous.
|
|
await page.getByRole("navigation").getByRole("link", { name: "Files" }).first().click();
|
|
await expect(page).toHaveURL("/files");
|
|
});
|
|
|
|
test("nav Automate link goes to automate page", async ({ loggedInPage: page }) => {
|
|
// Top-nav link: top-nav.tsx useNavLinks() -> { label: t.sidebar.automate, href: "/automate" }
|
|
await page.getByRole("link", { name: "Automate" }).click();
|
|
await expect(page).toHaveURL("/automate");
|
|
});
|
|
|
|
test("Settings button opens settings dialog", async ({ loggedInPage: page }) => {
|
|
// Settings is accessed via avatar dropdown (avatar-dropdown.tsx).
|
|
// The avatar button has aria-label={username}; the logged-in user is "admin".
|
|
await page.getByRole("button", { name: "admin" }).click();
|
|
// Then click Settings inside the dropdown (avatar-dropdown.tsx line 82-97, text = t.common.settings)
|
|
await page.getByRole("button", { name: "Settings" }).click();
|
|
await page.getByRole("dialog").waitFor({ state: "visible", timeout: 5000 });
|
|
// Settings dialog should appear with section headings (settings-dialog.tsx line 422, 85)
|
|
await expect(page.getByRole("heading", { name: "General" })).toBeVisible();
|
|
await expect(page.getByRole("button", { name: "Security" })).toBeVisible();
|
|
});
|
|
|
|
test("home page renders tool cards", async ({ loggedInPage: page }) => {
|
|
// Home page (/) is the tool grid with modality tabs (home-page.tsx AllTabContent)
|
|
await page.goto("/");
|
|
|
|
// Should show category headers (home-page.tsx line 405-407, getCategoryName())
|
|
await expect(page.getByText("Essentials")).toBeVisible();
|
|
await expect(page.getByText("Optimization")).toBeVisible();
|
|
await expect(page.getByText("Adjustments")).toBeVisible();
|
|
|
|
// Should show tools (tool-card.tsx renders <Link> with tool name text)
|
|
await expect(page.getByRole("link", { name: /^Resize/ }).first()).toBeVisible();
|
|
await expect(page.getByRole("link", { name: /^Compress/ }).first()).toBeVisible();
|
|
await expect(page.getByRole("link", { name: /^Convert/ }).first()).toBeVisible();
|
|
});
|
|
|
|
test("home page has search functionality", async ({ loggedInPage: page }) => {
|
|
// Home page search: home-page.tsx HomeSearchBar with data-search-input,
|
|
// placeholder from t.homePage.searchPlaceholder = "Search {count} tools..."
|
|
await page.goto("/");
|
|
|
|
const searchInput = page.getByPlaceholder(/search/i);
|
|
await expect(searchInput).toBeVisible();
|
|
|
|
// Search for a specific tool
|
|
await searchInput.fill("resize");
|
|
await expect(page.getByRole("link", { name: /^Resize/ }).first()).toBeVisible();
|
|
});
|
|
|
|
test("clicking a tool on home page navigates to tool page", async ({ loggedInPage: page }) => {
|
|
// Routes are /:modality/:toolId (App.tsx line 243).
|
|
// Resize route = /image/resize (constants.ts: route "/resize" + modality "image",
|
|
// post-processed at line 1793 with MODALITY_URL_SLUG prefix).
|
|
await page.goto("/");
|
|
|
|
// Click on Resize tool
|
|
await page
|
|
.getByRole("link", { name: /resize/i })
|
|
.first()
|
|
.click();
|
|
await expect(page).toHaveURL("/image/resize");
|
|
});
|
|
|
|
test("automate page shows pipeline builder", async ({ loggedInPage: page }) => {
|
|
await page.goto("/automate");
|
|
|
|
// Should show pipeline builder heading (automate-page.tsx line 802-804,
|
|
// t.automate.pipelineBuilder = "Pipeline Builder")
|
|
await expect(page.getByText(/pipeline/i).first()).toBeVisible();
|
|
});
|
|
|
|
test("home page shows categories", async ({ loggedInPage: page }) => {
|
|
// The home page shows categorized tools (home-page.tsx AllTabContent,
|
|
// category headers via getCategoryName(), en.ts categories.essentials = "Essentials")
|
|
await expect(page.getByText("Essentials").first()).toBeVisible();
|
|
});
|
|
});
|