test: fix 2.0 integration CI -- 202 async fallback + timeout hardening

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).
This commit is contained in:
SnapOtter
2026-06-19 18:15:20 +08:00
committed by GitHub
parent d39091375a
commit 7579634633
10 changed files with 294 additions and 122 deletions
+17 -15
View File
@@ -8,8 +8,8 @@ test.describe("Smoke tests", () => {
await expect(page.getByLabel("Username")).toBeVisible();
await expect(page.getByLabel("Password")).toBeVisible();
await expect(page.getByRole("button", { name: /login/i })).toBeVisible();
// Right panel marketing text
await expect(page.getByText("Your images. Stay yours.")).toBeVisible();
// Right panel marketing text (en.ts auth.heroTitle)
await expect(page.getByText("Your files. Stay yours.")).toBeVisible();
});
test("can log in with admin credentials", async ({ page }) => {
@@ -64,21 +64,23 @@ test.describe("Smoke tests", () => {
test("home page loads after login", async ({ loggedInPage: page }) => {
await expect(page).toHaveURL("/");
// The dropzone should be visible
await expect(page.getByText("Upload from computer")).toBeVisible();
await expect(page.getByText("Drop your images here")).toBeVisible();
// The home page shows a tool grid with modality tabs (home-page.tsx). Tab
// buttons render label + count span, so match on the label prefix.
await expect(page.getByRole("button", { name: /^All/ }).first()).toBeVisible();
await expect(page.getByRole("button", { name: /^Image/ }).first()).toBeVisible();
});
test("sidebar is visible on desktop", async ({ loggedInPage: page }) => {
const sidebar = page.locator("aside");
await expect(sidebar).toBeVisible();
test("top nav is visible on desktop", async ({ loggedInPage: page }) => {
// 2.0 uses a top nav bar (top-nav.tsx) instead of an aside sidebar
const nav = page.getByRole("navigation", { name: "Navigation" });
await expect(nav).toBeVisible();
// Check sidebar labels
await expect(sidebar.getByText("Tools")).toBeVisible();
await expect(sidebar.getByText("Grid")).toBeVisible();
await expect(sidebar.getByText("Automate")).toBeVisible();
await expect(sidebar.getByText("Files")).toBeVisible();
await expect(sidebar.getByText("Help")).toBeVisible();
await expect(sidebar.getByText("Settings")).toBeVisible();
// Check nav links (top-nav.tsx useNavLinks: Tools, Automate, Editor, Files)
await expect(nav.getByText("Tools")).toBeVisible();
await expect(nav.getByText("Automate")).toBeVisible();
await expect(nav.getByText("Editor")).toBeVisible();
await expect(nav.getByText("Files")).toBeVisible();
// Help is an icon-only button with aria-label (top-nav.tsx:244)
await expect(page.getByRole("button", { name: "Help" })).toBeVisible();
});
});