feat: add select format to download button

This commit is contained in:
2026-10-04 23:43:06 +05:00
parent 864f9cdc9f
commit e87bc1d715
13 changed files with 379 additions and 27 deletions
+10 -1
View File
@@ -117,7 +117,8 @@ export async function uploadViaDrop(
}
export async function downloadResultFile(page: Page): Promise<Download> {
const button = page.getByRole("button", { name: "Download result" });
// Split-кнопка: основная часть "Download" (image) или "Download ZIP" (files).
const button = page.getByRole("button", { name: /^Download( ZIP)?$/ });
await expect(button).toBeVisible();
const [download] = await Promise.all([
page.waitForEvent("download"),
@@ -126,6 +127,14 @@ export async function downloadResultFile(page: Page): Promise<Download> {
return download;
}
export async function chooseDownloadFormat(
page: Page,
format: string,
): Promise<void> {
await page.getByRole("button", { name: "Choose download format" }).click();
await page.getByRole("menuitemradio", { name: format, exact: true }).click();
}
export async function downloadResultBytes(
page: Page,
): Promise<{ name: string; bytes: Uint8Array }> {
+22
View File
@@ -6,8 +6,10 @@ import {
largePng,
onePixelPng,
opaquePng,
transparentPng,
} from "./helpers/fixtures";
import {
chooseDownloadFormat,
downloadResultBytes,
errorAlert,
expectNoErrorAlert,
@@ -144,6 +146,26 @@ test("convert-png-to-webp: produces WebP and quality affects size", async ({
expectNoErrors(sink);
});
test("download format selector: JPG warns about alpha and produces JPEG", async ({
page,
}) => {
const sink = trackErrors(page);
await openTool(page, "flip-png");
await uploadImage(page, transparentPng);
await expect(resultImage(page)).toBeVisible();
await chooseDownloadFormat(page, "JPG");
await expect(
page.getByRole("status").filter({ hasText: /transparency/ }),
).toBeVisible();
// у JPG в dropdown есть настройка качества
await rangeInput(page, "Quality").fill("10");
const { name, bytes } = await downloadResultBytes(page);
expect(name).toBe("flip-png.jpg");
expect(Array.from(bytes.subarray(0, 3))).toEqual([0xff, 0xd8, 0xff]);
await expectNoErrorAlert(page);
expectNoErrors(sink);
});
test("png-to-bmp: produces a BMP download", async ({ page }) => {
const sink = trackErrors(page);
await openTool(page, "png-to-bmp");