2023-11-04 06:39:25 +08:00
|
|
|
import { test, expect } from "@gradio/tootils";
|
|
|
|
|
|
|
|
test("Gallery preview mode displays all images correctly.", async ({
|
|
|
|
page
|
|
|
|
}) => {
|
|
|
|
await page.getByRole("button", { name: "Run" }).click();
|
|
|
|
await page.getByLabel("Thumbnail 2 of 3").click();
|
|
|
|
|
2023-11-08 03:38:52 +08:00
|
|
|
await expect(
|
|
|
|
await page.getByTestId("detailed-image").getAttribute("src")
|
|
|
|
).toEqual("https://gradio-builds.s3.amazonaws.com/assets/lite-logo.png");
|
2023-11-04 06:39:25 +08:00
|
|
|
|
2023-11-08 03:38:52 +08:00
|
|
|
await expect(
|
|
|
|
await page.getByTestId("thumbnail 1").getAttribute("src")
|
|
|
|
).toEqual("https://gradio-builds.s3.amazonaws.com/assets/cheetah-003.jpg");
|
2023-11-04 06:39:25 +08:00
|
|
|
});
|
|
|
|
|
2023-12-10 00:58:19 +08:00
|
|
|
test("Gallery select event returns the right value and the download button works correctly", async ({
|
|
|
|
page
|
|
|
|
}) => {
|
2023-11-04 06:39:25 +08:00
|
|
|
await page.getByRole("button", { name: "Run" }).click();
|
|
|
|
await page.getByLabel("Thumbnail 2 of 3").click();
|
2023-11-08 03:38:52 +08:00
|
|
|
await expect(page.getByLabel("Select Data")).toHaveValue(
|
2023-11-04 06:39:25 +08:00
|
|
|
"https://gradio-builds.s3.amazonaws.com/assets/lite-logo.png"
|
|
|
|
);
|
2023-12-10 00:58:19 +08:00
|
|
|
|
|
|
|
const downloadPromise = page.waitForEvent("download");
|
|
|
|
await page.getByLabel("Download").click();
|
|
|
|
const download = await downloadPromise;
|
|
|
|
expect(download.suggestedFilename()).toBe("lite-logo.png");
|
2023-11-04 06:39:25 +08:00
|
|
|
});
|
2024-01-26 07:51:59 +08:00
|
|
|
|
|
|
|
test("Gallery click-to-upload, upload and change events work correctly", async ({
|
|
|
|
page
|
|
|
|
}) => {
|
|
|
|
await page
|
|
|
|
.getByRole("button", { name: "Drop Image(s) Here - or - Click to Upload" })
|
|
|
|
.first()
|
|
|
|
.click();
|
|
|
|
const uploader = await page.locator("input[type=file]").first();
|
|
|
|
await uploader.setInputFiles([
|
|
|
|
"./test/files/cheetah1.jpg",
|
|
|
|
"./test/files/cheetah1.jpg"
|
|
|
|
]);
|
|
|
|
|
|
|
|
await expect(page.getByLabel("Num Upload")).toHaveValue("1");
|
|
|
|
await page.getByLabel("Clear").first().click();
|
|
|
|
await expect(page.getByLabel("Num Change")).toHaveValue("1");
|
|
|
|
});
|