gradio/js/app/test/upload_button_component_events.spec.ts
aliabid94 6e285be8ed
Fix the reloader (#6983)
* changes

* add changeset

* changes

* add changeset

* changes

* changes

* changes

* changes

* changes

---------

Co-authored-by: Ali Abid <aliabid@Alis-MacBook-Pro.local>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
2024-01-09 15:18:07 -08:00

45 lines
1.5 KiB
TypeScript

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");
});