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
+6 -5
View File
@@ -19,7 +19,7 @@ test.describe("All tool pages render", () => {
test(`${tool.name} (/${tool.id}) renders its UI shell`, async ({ loggedInPage: page }) => {
expect(displayMode, `tool "${tool.id}" missing from tool-display-modes.ts`).toBeTruthy();
await page.goto(`/${tool.id}`);
await page.goto(`/${tool.modality}/${tool.id}`);
// Tool name should be visible (header renders the shared TOOLS name)
await expect(page.getByText(tool.name, { exact: false }).first()).toBeVisible();
@@ -39,14 +39,14 @@ test.describe("All tool pages render", () => {
if (NO_DROPZONE_MODES.has(displayMode)) {
// Custom-input tools (meme-generator, qr-generate, collage, html-to-image,
// pdf-to-image) render their own input UI; just require the settings panel.
await expect(page.getByText("Settings").first()).toBeVisible();
await expect(page.locator(".settings-container").first()).toBeVisible();
return;
}
// Standard dropzone tools
await expect(page.getByText("Upload from computer")).toBeVisible();
await expect(page.getByText("Files").first()).toBeVisible();
await expect(page.getByText("Settings").first()).toBeVisible();
await expect(page.locator(".settings-container").first()).toBeVisible();
});
}
});
@@ -69,7 +69,8 @@ test.describe("Tool pages accept file upload", () => {
for (const toolId of REPRESENTATIVE_TOOLS) {
test(`${toolId} accepts file upload`, async ({ loggedInPage: page }) => {
await page.goto(`/${toolId}`);
const tool = TOOLS.find((t) => t.id === toolId);
await page.goto(`/${tool?.modality ?? "image"}/${toolId}`);
await uploadTestImage(page);
// After upload, dropzone should be replaced with image viewer
@@ -82,7 +83,7 @@ test.describe("Tool pages accept file upload", () => {
test.describe("Tool not found", () => {
test("nonexistent tool shows error", async ({ loggedInPage: page }) => {
await page.goto("/nonexistent-tool-xyz");
await page.goto("/image/nonexistent-tool-xyz");
await expect(page.getByText(/not found/i)).toBeVisible();
});
});