mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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.
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
import { expect, openSettings, test, uploadTestImage, waitForProcessing } from "./helpers";
|
||||
import {
|
||||
expect,
|
||||
getE2eRunRoot,
|
||||
openSettings,
|
||||
test,
|
||||
uploadTestImage,
|
||||
waitForProcessing,
|
||||
} from "./helpers";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// GUI Resilience: Error handling, form validation, state reset, stability,
|
||||
@@ -13,65 +20,59 @@ test.describe("Connection Banner & Disconnection", () => {
|
||||
// Block all health-check requests so the monitor thinks the server is down
|
||||
await page.route("**/api/v1/health", (route) => route.abort());
|
||||
|
||||
// Trigger a health check by navigating (the connection monitor polls /api/v1/health)
|
||||
await page.evaluate(() => {
|
||||
window.dispatchEvent(new Event("offline"));
|
||||
});
|
||||
try {
|
||||
// Remount the connection monitor while health requests are blocked. This
|
||||
// avoids racing an in-flight successful health request from initial load.
|
||||
await page.reload();
|
||||
|
||||
// The connection banner is a non-sr-only role="status" region. The
|
||||
// RouteAnnouncer also renders role="status" aria-live="polite", so filter by
|
||||
// the banner's visible message text to avoid a strict-mode multi-match.
|
||||
const banner = page.getByRole("status").filter({ hasText: /offline|connect/i });
|
||||
await expect(banner).toBeVisible({ timeout: 10_000 });
|
||||
await expect(banner).toContainText(/offline|reconnecting/i);
|
||||
|
||||
// Unblock for later tests
|
||||
await page.unroute("**/api/v1/health");
|
||||
// The RouteAnnouncer also renders role="status", so match the connection
|
||||
// banner by its exact failure-state message.
|
||||
await expect(
|
||||
page.getByRole("status").filter({ hasText: /reconnecting to server/i }),
|
||||
).toBeVisible({ timeout: 10_000 });
|
||||
} finally {
|
||||
await page.unroute("**/api/v1/health");
|
||||
}
|
||||
});
|
||||
|
||||
test("UI remains interactive while disconnected (banner and main visible)", async ({
|
||||
loggedInPage: page,
|
||||
}) => {
|
||||
// Block health endpoint
|
||||
await page.route("**/api/v1/health", (route) => route.abort());
|
||||
await page.evaluate(() => window.dispatchEvent(new Event("offline")));
|
||||
await expect(page.getByPlaceholder(/search/i).first()).toBeVisible();
|
||||
await page.context().setOffline(true);
|
||||
try {
|
||||
await expect(page.getByRole("status").filter({ hasText: /you're offline/i })).toBeVisible({
|
||||
timeout: 10_000,
|
||||
});
|
||||
|
||||
// Wait for banner
|
||||
await expect(page.getByRole("status").filter({ hasText: /offline|connect/i })).toBeVisible({
|
||||
timeout: 10_000,
|
||||
});
|
||||
// Top-nav banner and main content should still be visible and interactive
|
||||
await expect(page.getByRole("banner")).toBeVisible();
|
||||
await expect(page.locator("main")).toBeVisible();
|
||||
|
||||
// Top-nav banner and main content should still be visible and interactive
|
||||
await expect(page.getByRole("banner")).toBeVisible();
|
||||
await expect(page.locator("main")).toBeVisible();
|
||||
|
||||
// Should be able to click sidebar navigation (SPA navigation still works)
|
||||
const searchInput = page.getByPlaceholder(/search/i).first();
|
||||
if (await searchInput.isVisible({ timeout: 2000 }).catch(() => false)) {
|
||||
await searchInput.fill("resize");
|
||||
await expect(page.getByText("Resize").first()).toBeVisible({ timeout: 5_000 });
|
||||
// Client-side filtering remains interactive without a network connection.
|
||||
const searchInput = page.getByPlaceholder(/search/i).first();
|
||||
if (await searchInput.isVisible({ timeout: 2000 }).catch(() => false)) {
|
||||
await searchInput.fill("resize");
|
||||
await expect(page.getByText("Resize").first()).toBeVisible({ timeout: 5_000 });
|
||||
}
|
||||
} finally {
|
||||
await page.context().setOffline(false);
|
||||
}
|
||||
|
||||
await page.unroute("**/api/v1/health");
|
||||
});
|
||||
|
||||
test("connection banner disappears when API reconnects", async ({ loggedInPage: page }) => {
|
||||
// Block health to trigger disconnected state
|
||||
await page.route("**/api/v1/health", (route) => route.abort());
|
||||
await page.evaluate(() => window.dispatchEvent(new Event("offline")));
|
||||
|
||||
await expect(page.getByRole("status").filter({ hasText: /offline|connect/i })).toBeVisible({
|
||||
await expect(page.getByPlaceholder(/search/i).first()).toBeVisible();
|
||||
await page.context().setOffline(true);
|
||||
await expect(page.getByRole("status").filter({ hasText: /you're offline/i })).toBeVisible({
|
||||
timeout: 10_000,
|
||||
});
|
||||
|
||||
// Unblock health and bring back online
|
||||
await page.unroute("**/api/v1/health");
|
||||
await page.evaluate(() => window.dispatchEvent(new Event("online")));
|
||||
await page.context().setOffline(false);
|
||||
|
||||
// Banner should eventually disappear (after "reconnected" state clears)
|
||||
await expect(page.getByRole("status").filter({ hasText: /offline|connect/i })).not.toBeVisible({
|
||||
timeout: 15_000,
|
||||
});
|
||||
await expect(
|
||||
page.getByRole("status").filter({ hasText: /offline|reconnecting|connected/i }),
|
||||
).not.toBeVisible({ timeout: 15_000 });
|
||||
});
|
||||
|
||||
test("toast appears when processing fails due to disconnection", async ({
|
||||
@@ -233,7 +234,7 @@ test.describe("File Upload Validation", () => {
|
||||
// the file, or the app may ignore it. Either way, no crash should occur.
|
||||
const fs = await import("node:fs");
|
||||
const path = await import("node:path");
|
||||
const tmpDir = path.join(process.cwd(), "test-results");
|
||||
const tmpDir = getE2eRunRoot();
|
||||
if (!fs.existsSync(tmpDir)) fs.mkdirSync(tmpDir, { recursive: true });
|
||||
const txtPath = path.join(tmpDir, "not-an-image.txt");
|
||||
fs.writeFileSync(txtPath, "This is not an image file.");
|
||||
@@ -835,7 +836,7 @@ test.describe("Server Error Handling", () => {
|
||||
// Create a 0-byte file
|
||||
const fs = await import("node:fs");
|
||||
const path = await import("node:path");
|
||||
const tmpDir = path.join(process.cwd(), "test-results");
|
||||
const tmpDir = getE2eRunRoot();
|
||||
if (!fs.existsSync(tmpDir)) fs.mkdirSync(tmpDir, { recursive: true });
|
||||
const emptyPath = path.join(tmpDir, "empty.png");
|
||||
fs.writeFileSync(emptyPath, "");
|
||||
|
||||
Reference in New Issue
Block a user