Files
SnapOtter/tests/e2e/tools-all.spec.ts
T
SnapOtterandGitHub d10d0f544f fix: release QA hardening across processing, media, security, and CI gates (#649)
A release-readiness QA pass over the whole product. The commits split into
defects a user would hit and gates that were reporting green while measuring
nothing.

## Fixes that change behaviour

Rate limiting was bypassable on every install: TRUST_PROXY defaulted to true, so
request.ip came from a client-set header and a forged X-Forwarded-For got past
the login limiter. The default is now a private-network trust list.

A transient Postgres outage stranded in-flight jobs, leaving finished output on
disk with no row pointing at it. A reconciler now resolves those rows and adopts
the bytes rather than dropping the work.

A Redis connection that moved to a new address wedged every read-blocked
consumer, so completions stopped signalling while health still answered 200.
Socket timeouts plus subscriber pings recover it.

Installing more than one AI bundle left the shared venv multi-versioned and
silently broke three tools. The installer now reconciles distributions to one
version each.

Converting an image to JXL at quality 1 through 4 returned a 500, because
libjxl 0.7 rejects the distance those values compute. The quality is floored at
what the encoder honours. A missing ffmpeg was also reported to the user as a
corrupt upload; it now says the engine is unavailable.

RAW uploads reached an unpatched LibRaw on arm64, so it is built from source at
0.22.2, and the release scan was split so it can fail on an unfixed critical
instead of hiding it behind ignore-unfixed.

## Gates that could not fail

Two mutation lanes ran zero mutants because Stryker crawled the gitignored docs
build; coverage discarded its whole report on any failing test; the lint gate
skipped root tests, scripts, and two workspaces; and several generated matrices
counted a host missing ffmpeg as a passing tool. Each now measures what it
claims.

Full evidence and the outstanding release items are tracked locally and are not
part of this branch.
2026-07-27 15:37:30 +08:00

98 lines
4.1 KiB
TypeScript

import { TOOL_DISPLAY_MODES } from "../../apps/web/src/lib/tool-display-modes";
import { TOOLS } from "../../packages/shared/src/constants";
import { TOOL_BUNDLE_MAP } from "../../packages/shared/src/features";
import { expect, test, uploadTestImage } from "./helpers";
// ---------------------------------------------------------------------------
// Every tool page must load, show its name, and render the right UI shell.
// Generated from the shared TOOLS catalog + the display-mode map, so a newly
// added tool is covered automatically and a missing registry entry fails here.
// ---------------------------------------------------------------------------
const NO_DROPZONE_MODES = new Set(["no-dropzone"]);
test.describe("All tool pages render", () => {
for (const tool of TOOLS) {
const displayMode = TOOL_DISPLAY_MODES[tool.id];
const isAiTool = tool.id in TOOL_BUNDLE_MAP;
test(`${tool.name} (/${tool.id}) renders its UI shell`, async ({ loggedInPage: page }) => {
expect(displayMode, `tool "${tool.id}" missing from tool-display-modes.ts`).toBeTruthy();
// Navigate by the catalog route, never by modality: toolSection() splits
// the "document" modality into pdf and files and maps "file" to files, so
// a modality-built URL sends 52 of the 243 tools to the catch-all and the
// assertions below then run against the 404 page.
await page.goto(tool.route);
// Tool name should be visible (header renders the shared TOOLS name)
await expect(page.getByText(tool.name, { exact: false }).first()).toBeVisible();
// AI tools may show an install prompt instead of a dropzone when the
// model bundle is not installed.
if (isAiTool) {
const uploadVisible = await page.getByText("Upload from computer").isVisible();
if (!uploadVisible) {
await expect(
page.getByText(/additional download|Feature Not Enabled/i).first(),
).toBeVisible();
return;
}
}
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 immediately, so the settings
// panel is present before any upload.
await expect(page.locator(".settings-container").first()).toBeVisible();
return;
}
// Standard dropzone tools: before a file is loaded the page renders the
// full-width dropzone (tool-page.tsx renders the dropzone-only layout when
// !hasFile). The settings panel appears only after upload, which the
// per-tool gui-tools-*.spec.ts suites cover. Here, assert the dropzone.
await expect(page.getByText("Upload from computer")).toBeVisible();
await expect(page.getByText("Files").first()).toBeVisible();
});
}
});
test.describe("Tool pages accept file upload", () => {
// Representative subset across display modes (uploading on all tools would
// be slow; per-tool processing flows live in gui-tools-*.spec.ts)
const REPRESENTATIVE_TOOLS = [
"resize",
"compress",
"convert",
"strip-metadata",
"adjust-colors",
"watermark-text",
"info",
"border",
"vectorize",
"gif-tools",
];
for (const toolId of REPRESENTATIVE_TOOLS) {
test(`${toolId} accepts file upload`, async ({ loggedInPage: page }) => {
const tool = TOOLS.find((t) => t.id === toolId);
expect(tool, `"${toolId}" is not in the shared TOOLS catalog`).toBeTruthy();
await page.goto(tool?.route ?? "");
await uploadTestImage(page);
// After upload, dropzone should be replaced with image viewer
await expect(page.getByText("Upload from computer")).not.toBeVisible();
// Should show file info (Selected: or the filename)
await expect(page.getByText(/selected|test-image/i).first()).toBeVisible();
});
}
});
test.describe("Tool not found", () => {
test("nonexistent tool shows error", async ({ loggedInPage: page }) => {
await page.goto("/image/nonexistent-tool-xyz");
await expect(page.getByText(/not found/i)).toBeVisible();
});
});