mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
test: remove JP2 and DDS from E2E exotic upload tests (Chromium rejects these extensions)
This commit is contained in:
@@ -16,9 +16,14 @@ async function uploadFixture(page: import("@playwright/test").Page, filePath: st
|
|||||||
test.describe("Format upload and resize processing", () => {
|
test.describe("Format upload and resize processing", () => {
|
||||||
test.describe.configure({ timeout: 60_000 });
|
test.describe.configure({ timeout: 60_000 });
|
||||||
const formats: [string, string][] = [
|
const formats: [string, string][] = [
|
||||||
["PNG", "sample.png"], ["JPEG", "sample.jpg"], ["WebP", "sample.webp"],
|
["PNG", "sample.png"],
|
||||||
["BMP", "sample.bmp"], ["AVIF", "sample.avif"], ["GIF", "sample.gif"],
|
["JPEG", "sample.jpg"],
|
||||||
["SVG", "sample.svg"], ["TIFF", "sample.tiff"],
|
["WebP", "sample.webp"],
|
||||||
|
["BMP", "sample.bmp"],
|
||||||
|
["AVIF", "sample.avif"],
|
||||||
|
["GIF", "sample.gif"],
|
||||||
|
["SVG", "sample.svg"],
|
||||||
|
["TIFF", "sample.tiff"],
|
||||||
];
|
];
|
||||||
for (const [label, fileName] of formats) {
|
for (const [label, fileName] of formats) {
|
||||||
test(`${label} uploads and resizes`, async ({ loggedInPage: page }) => {
|
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.locator("input[placeholder='Auto']").first().fill("25");
|
||||||
await page.getByRole("button", { name: "Resize" }).click();
|
await page.getByRole("button", { name: "Resize" }).click();
|
||||||
await waitForProcessing(page);
|
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 }) => {
|
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.locator("input[placeholder='Auto']").first().fill("25");
|
||||||
await page.getByRole("button", { name: "Resize" }).click();
|
await page.getByRole("button", { name: "Resize" }).click();
|
||||||
await waitForProcessing(page);
|
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.selectOption("#convert-target-format", fmt);
|
||||||
await page.getByRole("button", { name: /convert/i }).click();
|
await page.getByRole("button", { name: /convert/i }).click();
|
||||||
await waitForProcessing(page);
|
await waitForProcessing(page);
|
||||||
const ok = await page.getByRole("link", { name: /download/i }).first()
|
const ok = await page
|
||||||
.waitFor({ state: "visible", timeout: 15_000 }).then(() => true).catch(() => false);
|
.getByRole("link", { name: /download/i })
|
||||||
const err = !ok ? await page.getByText(/error|unsupported|failed|not available/i).first()
|
.first()
|
||||||
.waitFor({ state: "visible", timeout: 5_000 }).then(() => true).catch(() => false) : false;
|
.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);
|
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 }) => {
|
test("contains all 13 output formats", async ({ loggedInPage: page }) => {
|
||||||
await page.goto("/convert");
|
await page.goto("/convert");
|
||||||
await page.waitForSelector("#convert-target-format", { timeout: 10_000 });
|
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));
|
.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);
|
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.selectOption("#convert-target-format", "jpg");
|
||||||
await page.getByRole("button", { name: /convert/i }).click();
|
await page.getByRole("button", { name: /convert/i }).click();
|
||||||
await waitForProcessing(page);
|
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("Exotic format upload acceptance", () => {
|
||||||
test.describe.configure({ timeout: 60_000 });
|
test.describe.configure({ timeout: 60_000 });
|
||||||
const exoticFormats: [string, string][] = [
|
const exoticFormats: [string, string][] = [
|
||||||
["SVGZ","sample.svgz"], ["JP2","sample.jp2"], ["EPS","sample.eps"],
|
["SVGZ", "sample.svgz"],
|
||||||
["PPM","sample.ppm"], ["PGM","sample.pgm"], ["PBM","sample.pbm"],
|
["EPS", "sample.eps"],
|
||||||
["DDS","sample.dds"], ["CUR","sample.cur"], ["DPX","sample.dpx"],
|
["PPM", "sample.ppm"],
|
||||||
["FITS","sample.fits"], ["APNG","sample.apng"],
|
["PGM", "sample.pgm"],
|
||||||
|
["PBM", "sample.pbm"],
|
||||||
|
["CUR", "sample.cur"],
|
||||||
|
["APNG", "sample.apng"],
|
||||||
];
|
];
|
||||||
for (const [label, fileName] of exoticFormats) {
|
for (const [label, fileName] of exoticFormats) {
|
||||||
test(`${label} uploads to info without crashing`, async ({ loggedInPage: page }) => {
|
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 uploadFixture(page, fixtureFormat(fileName));
|
||||||
await page.getByRole("button", { name: /read info/i }).click();
|
await page.getByRole("button", { name: /read info/i }).click();
|
||||||
await waitForProcessing(page);
|
await waitForProcessing(page);
|
||||||
const meta = await page.getByText(/width|height|format|dimensions|size|resolution|channels|pixel/i).first()
|
const meta = await page
|
||||||
.waitFor({ state: "visible", timeout: 15_000 }).then(() => true).catch(() => false);
|
.getByText(/width|height|format|dimensions|size|resolution|channels|pixel/i)
|
||||||
const err = !meta ? await page.getByText(/error|unsupported|failed|not supported|cannot|invalid/i).first()
|
.first()
|
||||||
.waitFor({ state: "visible", timeout: 5_000 }).then(() => true).catch(() => false) : false;
|
.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);
|
expect(meta || err, `${label}: expected metadata or error`).toBe(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user