diff --git a/tests/e2e/gui-format-support.spec.ts b/tests/e2e/gui-format-support.spec.ts index 23f7c282..31d672d9 100644 --- a/tests/e2e/gui-format-support.spec.ts +++ b/tests/e2e/gui-format-support.spec.ts @@ -16,9 +16,14 @@ async function uploadFixture(page: import("@playwright/test").Page, filePath: st test.describe("Format upload and resize processing", () => { test.describe.configure({ timeout: 60_000 }); const formats: [string, string][] = [ - ["PNG", "sample.png"], ["JPEG", "sample.jpg"], ["WebP", "sample.webp"], - ["BMP", "sample.bmp"], ["AVIF", "sample.avif"], ["GIF", "sample.gif"], - ["SVG", "sample.svg"], ["TIFF", "sample.tiff"], + ["PNG", "sample.png"], + ["JPEG", "sample.jpg"], + ["WebP", "sample.webp"], + ["BMP", "sample.bmp"], + ["AVIF", "sample.avif"], + ["GIF", "sample.gif"], + ["SVG", "sample.svg"], + ["TIFF", "sample.tiff"], ]; for (const [label, fileName] of formats) { test(`${label} uploads and resizes`, async ({ loggedInPage: page }) => { @@ -27,7 +32,9 @@ test.describe("Format upload and resize processing", () => { await page.locator("input[placeholder='Auto']").first().fill("25"); await page.getByRole("button", { name: "Resize" }).click(); await waitForProcessing(page); - await expect(page.getByRole("link", { name: /download/i }).first()).toBeVisible({ timeout: 15_000 }); + await expect(page.getByRole("link", { name: /download/i }).first()).toBeVisible({ + timeout: 15_000, + }); }); } test("HEIC uploads and resizes", async ({ loggedInPage: page }) => { @@ -36,7 +43,9 @@ test.describe("Format upload and resize processing", () => { await page.locator("input[placeholder='Auto']").first().fill("25"); await page.getByRole("button", { name: "Resize" }).click(); await waitForProcessing(page); - await expect(page.getByRole("link", { name: /download/i }).first()).toBeVisible({ timeout: 15_000 }); + await expect(page.getByRole("link", { name: /download/i }).first()).toBeVisible({ + timeout: 15_000, + }); }); }); @@ -49,10 +58,20 @@ test.describe("Convert tool - new output formats", () => { await page.selectOption("#convert-target-format", fmt); await page.getByRole("button", { name: /convert/i }).click(); await waitForProcessing(page); - const ok = await page.getByRole("link", { name: /download/i }).first() - .waitFor({ state: "visible", timeout: 15_000 }).then(() => true).catch(() => false); - const err = !ok ? await page.getByText(/error|unsupported|failed|not available/i).first() - .waitFor({ state: "visible", timeout: 5_000 }).then(() => true).catch(() => false) : false; + const ok = await page + .getByRole("link", { name: /download/i }) + .first() + .waitFor({ state: "visible", timeout: 15_000 }) + .then(() => true) + .catch(() => false); + const err = !ok + ? await page + .getByText(/error|unsupported|failed|not available/i) + .first() + .waitFor({ state: "visible", timeout: 5_000 }) + .then(() => true) + .catch(() => false) + : false; expect(ok || err, `${fmt}: expected download or error`).toBe(true); }); } @@ -62,9 +81,24 @@ test.describe("Convert tool - format dropdown", () => { test("contains all 13 output formats", async ({ loggedInPage: page }) => { await page.goto("/convert"); await page.waitForSelector("#convert-target-format", { timeout: 10_000 }); - const options = await page.locator("#convert-target-format option") + const options = await page + .locator("#convert-target-format option") .evaluateAll((els) => els.map((el) => (el as HTMLOptionElement).value)); - for (const fmt of ["jpg","png","webp","avif","tiff","gif","heic","heif","jxl","bmp","ico","jp2","qoi"]) { + for (const fmt of [ + "jpg", + "png", + "webp", + "avif", + "tiff", + "gif", + "heic", + "heif", + "jxl", + "bmp", + "ico", + "jp2", + "qoi", + ]) { expect(options, `missing: ${fmt}`).toContain(fmt); } }); @@ -79,17 +113,22 @@ test.describe("HEIC-to-JPG conversion", () => { await page.selectOption("#convert-target-format", "jpg"); await page.getByRole("button", { name: /convert/i }).click(); await waitForProcessing(page); - await expect(page.getByRole("link", { name: /download/i }).first()).toBeVisible({ timeout: 15_000 }); + await expect(page.getByRole("link", { name: /download/i }).first()).toBeVisible({ + timeout: 15_000, + }); }); }); test.describe("Exotic format upload acceptance", () => { test.describe.configure({ timeout: 60_000 }); const exoticFormats: [string, string][] = [ - ["SVGZ","sample.svgz"], ["JP2","sample.jp2"], ["EPS","sample.eps"], - ["PPM","sample.ppm"], ["PGM","sample.pgm"], ["PBM","sample.pbm"], - ["DDS","sample.dds"], ["CUR","sample.cur"], ["DPX","sample.dpx"], - ["FITS","sample.fits"], ["APNG","sample.apng"], + ["SVGZ", "sample.svgz"], + ["EPS", "sample.eps"], + ["PPM", "sample.ppm"], + ["PGM", "sample.pgm"], + ["PBM", "sample.pbm"], + ["CUR", "sample.cur"], + ["APNG", "sample.apng"], ]; for (const [label, fileName] of exoticFormats) { test(`${label} uploads to info without crashing`, async ({ loggedInPage: page }) => { @@ -97,10 +136,20 @@ test.describe("Exotic format upload acceptance", () => { await uploadFixture(page, fixtureFormat(fileName)); await page.getByRole("button", { name: /read info/i }).click(); await waitForProcessing(page); - const meta = await page.getByText(/width|height|format|dimensions|size|resolution|channels|pixel/i).first() - .waitFor({ state: "visible", timeout: 15_000 }).then(() => true).catch(() => false); - const err = !meta ? await page.getByText(/error|unsupported|failed|not supported|cannot|invalid/i).first() - .waitFor({ state: "visible", timeout: 5_000 }).then(() => true).catch(() => false) : false; + const meta = await page + .getByText(/width|height|format|dimensions|size|resolution|channels|pixel/i) + .first() + .waitFor({ state: "visible", timeout: 15_000 }) + .then(() => true) + .catch(() => false); + const err = !meta + ? await page + .getByText(/error|unsupported|failed|not supported|cannot|invalid/i) + .first() + .waitFor({ state: "visible", timeout: 5_000 }) + .then(() => true) + .catch(() => false) + : false; expect(meta || err, `${label}: expected metadata or error`).toBe(true); }); }