test: add download zip flow

This commit is contained in:
2026-09-26 02:54:01 +05:00
parent 0933f1cdea
commit 746d6a6c8f
12 changed files with 211 additions and 53 deletions
+36
View File
@@ -1,3 +1,5 @@
import { readFile } from "node:fs/promises";
import { unzipSync } from "fflate";
import { expect, test } from "playwright/test";
import {
corruptPng,
@@ -8,6 +10,7 @@ import {
} from "./helpers/fixtures";
import {
downloadResult,
downloadResultFile,
errorAlert,
expectNoErrorAlert,
expectNoErrors,
@@ -89,6 +92,39 @@ test("reset restores defaults and re-runs with the source", async ({
expectNoErrors(sink);
});
test("split-into-parts-png downloads a zip with named PNG parts", async ({
page,
}) => {
const sink = trackErrors(page);
await openTool(page, "split-into-parts-png");
await uploadImage(page, landscapePng);
await rangeInput(page, "Columns").fill("3");
await rangeInput(page, "Rows").fill("2");
await expect(page.getByText("part-1-3.png")).toBeVisible();
const download = await downloadResultFile(page);
expect(download.suggestedFilename()).toBe("split-into-parts-png.zip");
const path = await download.path();
if (!path) throw new Error("download path is unavailable");
const entries = unzipSync(new Uint8Array(await readFile(path)));
expect(Object.keys(entries)).toEqual([
"part-1-1.png",
"part-1-2.png",
"part-1-3.png",
"part-2-1.png",
"part-2-2.png",
"part-2-3.png",
]);
for (const bytes of Object.values(entries)) {
expect(Array.from(bytes.subarray(0, 8))).toEqual([
137, 80, 78, 71, 13, 10, 26, 10,
]);
}
await expectNoErrorAlert(page);
expectNoErrors(sink);
});
test("blur: changing slider updates result image", async ({ page }) => {
await openTool(page, "blur-png");
await uploadImage(page, opaquePng);