1
import { test, expect, drag_and_drop_file } from "@gradio/tootils";
3
test("File component properly dispatches load event for the single file case.", async ({
7
.getByRole("button", { name: "Drop File Here - or - Click to Upload" })
10
const uploader = await page.locator("input[type=file]").first();
11
await uploader.setInputFiles(["./test/files/cheetah1.jpg"]);
13
await expect(page.getByLabel("# Load Upload Single File")).toHaveValue("1");
15
const downloadPromise = page.waitForEvent("download");
16
await page.getByRole("link").nth(0).click();
17
const download = await downloadPromise;
18
await expect(download.suggestedFilename()).toBe("cheetah1.jpg");
21
test("File component drag-and-drop uploads a file to the server correctly.", async ({
24
const uploader = await page.locator("input[type=file]").nth(1);
25
await uploader.setInputFiles(["./test/files/alphabet.txt"]);
28
page.getByLabel("# Load Upload Multiple Files").first()
32
test("File component properly handles drag and drop of image and video files.", async ({
35
const uploader = await page.locator("input[type=file]").nth(2);
36
await uploader.setInputFiles(["./test/files/cheetah1.jpg"]);
40
page.getByLabel("# Load Upload Multiple Files Image/Video")
43
await page.getByLabel("Clear").click();
45
await uploader.setInputFiles(["./test/files/world.mp4"]);
49
page.getByLabel("# Load Upload Multiple Files Image/Video")
53
test("File component properly handles drag and drop of pdf file.", async ({
56
const uploader = await page.locator("input[type=file]").nth(3);
57
await uploader.setInputFiles(["./test/files/contract.pdf"]);
60
await expect(page.getByLabel("# Load Upload PDF File")).toHaveValue("1");
63
test("File component properly handles invalid file_types.", async ({
66
const uploader = await page.locator("input[type=file]").last();
67
await uploader.setInputFiles(["./test/files/cheetah1.jpg"]);
71
page.getByLabel("# Load Upload File with Invalid file_types")