mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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.
144 lines
5.7 KiB
TypeScript
144 lines
5.7 KiB
TypeScript
import path from "node:path";
|
|
import { expect, isAiSidecarRunning, test } from "./helpers";
|
|
|
|
function fixturePath(name: string): string {
|
|
return path.join(process.cwd(), "tests", "fixtures", "image", "valid", name);
|
|
}
|
|
|
|
async function uploadFile(page: import("@playwright/test").Page, filePath: string) {
|
|
const fileChooserPromise = page.waitForEvent("filechooser");
|
|
const dropzone = page.locator("[class*='border-dashed']").first();
|
|
await dropzone.click();
|
|
const fileChooser = await fileChooserPromise;
|
|
await fileChooser.setFiles(filePath);
|
|
await page.waitForTimeout(500);
|
|
}
|
|
|
|
test.describe("AI Canvas Expand", () => {
|
|
test("standalone /ai-canvas-expand route loads", async ({ loggedInPage: page }) => {
|
|
await page.goto("/image/ai-canvas-expand");
|
|
|
|
await expect(page.getByText("Tool not found")).not.toBeVisible();
|
|
// Heading appears in both the breadcrumb and the page; .first() avoids a
|
|
// strict-mode multiple-match error.
|
|
await expect(page.getByText("AI Canvas Expand").first()).toBeVisible();
|
|
|
|
// Settings (aspect-ratio + per-side inputs) only mount after a file loads.
|
|
await uploadFile(page, fixturePath("test-200x150.png"));
|
|
await expect(page.getByText("Extend to aspect ratio")).toBeVisible();
|
|
await expect(page.getByText("Extend by (pixels)")).toBeVisible();
|
|
});
|
|
|
|
test("standalone submit disabled without file", async ({ loggedInPage: page }) => {
|
|
await page.goto("/image/ai-canvas-expand");
|
|
// The settings panel (and its submit button) mount only after a file is
|
|
// uploaded; before upload the page shows just the dropzone.
|
|
await expect(page.getByTestId("ai-canvas-expand-submit")).toHaveCount(0);
|
|
});
|
|
|
|
test("standalone submit disabled when all extensions are zero", async ({
|
|
loggedInPage: page,
|
|
}) => {
|
|
await page.goto("/image/ai-canvas-expand");
|
|
await uploadFile(page, fixturePath("test-200x150.png"));
|
|
|
|
await expect(page.getByTestId("ai-canvas-expand-submit")).toBeDisabled();
|
|
});
|
|
|
|
test("standalone submit enables with extension set", async ({ loggedInPage: page }) => {
|
|
await page.goto("/image/ai-canvas-expand");
|
|
await uploadFile(page, fixturePath("test-200x150.png"));
|
|
|
|
await page.locator("#cac-top").fill("50");
|
|
|
|
await expect(page.getByTestId("ai-canvas-expand-submit")).toBeEnabled();
|
|
});
|
|
|
|
test("standalone aspect ratio preset fills extension values", async ({ loggedInPage: page }) => {
|
|
await page.goto("/image/ai-canvas-expand");
|
|
await uploadFile(page, fixturePath("test-200x150.png"));
|
|
|
|
await page.waitForTimeout(500);
|
|
await page.getByRole("button", { name: "16:9" }).click();
|
|
|
|
const topInput = page.locator("#cac-top");
|
|
const rightInput = page.locator("#cac-right");
|
|
|
|
const topVal = Number(await topInput.inputValue());
|
|
const rightVal = Number(await rightInput.inputValue());
|
|
|
|
expect(topVal > 0 || rightVal > 0).toBe(true);
|
|
await expect(page.getByTestId("ai-canvas-expand-submit")).toBeEnabled();
|
|
});
|
|
|
|
test("standalone shows new size display", async ({ loggedInPage: page }) => {
|
|
await page.goto("/image/ai-canvas-expand");
|
|
await uploadFile(page, fixturePath("test-200x150.png"));
|
|
|
|
await page.waitForTimeout(500);
|
|
await page.locator("#cac-top").fill("50");
|
|
await page.locator("#cac-bottom").fill("50");
|
|
|
|
await expect(page.getByText(/New size: \d+ x \d+/)).toBeVisible();
|
|
});
|
|
|
|
test("tier buttons render with Balanced selected by default", async ({ loggedInPage: page }) => {
|
|
await page.goto("/image/ai-canvas-expand");
|
|
await uploadFile(page, fixturePath("test-200x150.png"));
|
|
|
|
await expect(page.getByTestId("tier-fast")).toBeVisible();
|
|
await expect(page.getByTestId("tier-balanced")).toBeVisible();
|
|
await expect(page.getByTestId("tier-high")).toBeVisible();
|
|
|
|
const balanced = page.getByTestId("tier-balanced");
|
|
await expect(balanced).toHaveClass(/bg-primary/);
|
|
});
|
|
|
|
test("clicking tier button changes selection", async ({ loggedInPage: page }) => {
|
|
await page.goto("/image/ai-canvas-expand");
|
|
await uploadFile(page, fixturePath("test-200x150.png"));
|
|
|
|
await page.getByTestId("tier-fast").click();
|
|
await expect(page.getByTestId("tier-fast")).toHaveClass(/bg-primary/);
|
|
await expect(page.getByTestId("tier-balanced")).not.toHaveClass(/bg-primary/);
|
|
|
|
await expect(page.getByText("Quick preview, fewer AI passes")).toBeVisible();
|
|
});
|
|
|
|
test("tier description updates on selection", async ({ loggedInPage: page }) => {
|
|
await page.goto("/image/ai-canvas-expand");
|
|
await uploadFile(page, fixturePath("test-200x150.png"));
|
|
|
|
await expect(page.getByText("Good quality, moderate speed")).toBeVisible();
|
|
|
|
await page.getByTestId("tier-high").click();
|
|
await expect(page.getByText("Best results, slower")).toBeVisible();
|
|
});
|
|
|
|
// ── Processing (requires AI sidecar) ────────────────────────────────
|
|
|
|
test("processes image (AI sidecar required)", async ({ loggedInPage: page }) => {
|
|
// The assertion below intentionally allows up to five minutes for a real
|
|
// sidecar run, so the enclosing test must not retain Playwright's 30s
|
|
// default timeout.
|
|
test.setTimeout(330_000);
|
|
|
|
await page.goto("/image/ai-canvas-expand");
|
|
|
|
if (!(await isAiSidecarRunning(page))) {
|
|
test.skip(true, "AI sidecar not running");
|
|
}
|
|
|
|
await uploadFile(page, fixturePath("test-200x150.png"));
|
|
await page.locator("#cac-top").fill("30");
|
|
await page.locator("#cac-bottom").fill("30");
|
|
|
|
await page.getByTestId("ai-canvas-expand-submit").click();
|
|
|
|
const download = page.getByTestId("ai-canvas-expand-download");
|
|
const error = page.getByText(/failed|not available|not installed|requires.*feature|error/i);
|
|
|
|
await expect(download.or(error)).toBeVisible({ timeout: 300_000 });
|
|
});
|
|
});
|