mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-27 02:30:17 +08:00
c3e61e4f70
* file comp fixes * add changeset * test fixes * undo pr fixes * add changeset * file type fix * format * final fix --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { test, expect, drag_and_drop_file } from "@gradio/tootils";
|
|
|
|
test("File component properly dispatches load event for the single file case.", async ({
|
|
page
|
|
}) => {
|
|
await page
|
|
.getByRole("button", { name: "Drop File Here - or - Click to Upload" })
|
|
.first()
|
|
.click();
|
|
const uploader = await page.locator("input[type=file]").first();
|
|
await uploader.setInputFiles(["./test/files/cheetah1.jpg"]);
|
|
|
|
await expect(page.getByLabel("# Load Upload Single File")).toHaveValue("1");
|
|
|
|
const downloadPromise = page.waitForEvent("download");
|
|
await page.getByRole("link").nth(0).click();
|
|
const download = await downloadPromise;
|
|
await expect(download.suggestedFilename()).toBe("cheetah1.jpg");
|
|
});
|
|
|
|
test("File component drag-and-drop uploads a file to the server correctly.", async ({
|
|
page
|
|
}) => {
|
|
const uploader = await page.locator("input[type=file]").nth(1);
|
|
await uploader.setInputFiles(["./test/files/alphabet.txt"]);
|
|
|
|
await expect(
|
|
page.getByLabel("# Load Upload Multiple Files").first()
|
|
).toHaveValue("1");
|
|
});
|
|
|
|
test("File component properly handles drag and drop of image and video files.", async ({
|
|
page
|
|
}) => {
|
|
const uploader = await page.locator("input[type=file]").last();
|
|
await uploader.setInputFiles(["./test/files/cheetah1.jpg"]);
|
|
|
|
// Check that the image file was uploaded
|
|
await expect(
|
|
page.getByLabel("# Load Upload Multiple Files Image/Video")
|
|
).toHaveValue("1");
|
|
|
|
await page.getByLabel("Clear").click();
|
|
|
|
await uploader.setInputFiles(["./test/files/world.mp4"]);
|
|
|
|
// Check that the video file was uploaded
|
|
await expect(
|
|
page.getByLabel("# Load Upload Multiple Files Image/Video")
|
|
).toHaveValue("2");
|
|
});
|