gradio/js/spa/test/gallery_component_events.spec.ts
Yuichiro Tachibana (Tsuchiya) 9004b11064
Fix Lite to work on FireFox (#9528)
* Fix CrossOriginWorker to work in FireFox

* add changeset

* Add FireFox to the Lite E2E test

* Use request.arrayBuffer instead .body on FireFox

* add changeset

* Delete the user-agent header in PyodideHttpTransport

* Ignore the kitchen_sink E2E test for FireFox

* Fix

* Fix test files using file uploader so they work on FireFox, ref: https://stackoverflow.com/a/78701710

* Fix js/spa/test/outbreak_forecast.spec.ts

* Fix outbreak_forecast.spec.ts

* [wip] Comment out plotly part

* add changeset

* Skip Plotly tests on FireFox temporarily

* Revert "Fix"

This reverts commit 98e2495e9c.

* Fix

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
2024-10-10 11:25:41 -07:00

52 lines
1.6 KiB
TypeScript

import { test, expect } from "@self/tootils";
test("Gallery preview mode displays all images/videos correctly.", async ({
page
}) => {
await page.getByRole("button", { name: "Run" }).click();
await page.getByLabel("Thumbnail 2 of 3").click();
await expect(
await page.getByTestId("detailed-video").getAttribute("src")
).toEqual("https://gradio-static-files.s3.amazonaws.com/world.mp4");
await expect(
await page.getByTestId("thumbnail 1").getAttribute("src")
).toEqual("https://gradio-builds.s3.amazonaws.com/assets/cheetah-003.jpg");
});
test("Gallery select event returns the right value and the download button works correctly", async ({
page
}) => {
await page.getByRole("button", { name: "Run" }).click();
await page.getByLabel("Thumbnail 2 of 3").click();
await expect(page.getByLabel("Select Data")).toHaveValue(
"https://gradio-static-files.s3.amazonaws.com/world.mp4"
);
const downloadPromise = page.waitForEvent("download");
await page.getByLabel("Download").click();
const download = await downloadPromise;
expect(download.suggestedFilename()).toBe("world.mp4");
});
test("Gallery click-to-upload, upload and change events work correctly", async ({
page
}) => {
const [fileChooser] = await Promise.all([
page.waitForEvent("filechooser"),
page
.getByRole("button", { name: "Drop Media Here - or - Click to Upload" })
.first()
.click()
]);
await fileChooser.setFiles([
"./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");
});