File size: 1,539 Bytes
a03b3ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { test, expect } from "@gradio/tootils";

test("UploadButton properly dispatches load event and click event for the single file case.", async ({
	page
}) => {
	await page.getByRole("button", { name: "Upload Single File" }).click();
	const uploader = await page.getByTestId("Upload Single File-upload-button");
	await uploader.setInputFiles(["./test/files/cheetah1.jpg"]);

	await expect(page.getByLabel("# Load Upload Single File")).toHaveValue("1");
	await expect(
		page.getByLabel("# Click Upload Single File Output")
	).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.skip("UploadButton properly dispatches load event and click event for the multiple file case.", async ({
	page
}) => {
	await page.getByRole("button", { name: "Upload Multiple Files" }).click();
	const uploader = await page.getByTestId(
		"Upload Multiple Files-upload-button"
	);
	await uploader.setInputFiles([
		"./test/files/face.obj",
		"./test/files/cheetah1.jpg"
	]);

	await expect(page.getByLabel("# Load Upload Multiple Files")).toHaveValue(
		"1"
	);
	await expect(
		page.getByLabel("# Click Upload Multiple Files Output")
	).toHaveValue("1");

	const downloadPromise = page.waitForEvent("download");
	await page.getByRole("link").nth(1).click();
	const download = await downloadPromise;
	await expect(download.suggestedFilename()).toBe("cheetah1.jpg");
});