gradio/js/app/test/model3d_component_events.spec.ts
Freddy Boulton 51e241addd
Fix flaky CI tests (again 😓 ) (#6780)
* network idle

* Use **/upload

* Test flakes

* Fix pythont tests

* add changeset

* Use right wait

* upload

* trigger ci

* swap order

* networkidle

* lint'

* df

* 2 workers

* networkidle

* Fix cli test

* pause

* 3.8 fix

* 3.8

* no promise.all

* trigger ci

* Add code

* mark xfail

* trigger ci

* timeout

* Empty

* Flake

* test

* Flakes

* change test

* awaits

* cleanup

* fixes

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
2023-12-14 12:40:36 -08:00

42 lines
1.4 KiB
TypeScript

import { test, expect, drag_and_drop_file } from "@gradio/tootils";
test("Model3D click-to-upload uploads file successfuly. Upload and clear events work correctly. Downloading works.", async ({
page
}) => {
await page
.getByRole("button", { name: "Drop File Here - or - Click to Upload" })
.click();
const uploader = await page.locator("input[type=file]");
const change_counter = await page.getByLabel("# Change Events");
const upload_counter = await page.getByLabel("# Upload Events");
const clear_counter = await page.getByLabel("# Clear Events");
await uploader.setInputFiles("./test/files/face.obj");
await expect(change_counter).toHaveValue("1");
await expect(upload_counter).toHaveValue("1");
await page.getByLabel("Clear").nth(0).click();
await expect(change_counter).toHaveValue("2");
await expect(clear_counter).toHaveValue("1");
await expect(await page.getByLabel("Clear Value")).toHaveValue("");
const downloadPromise = page.waitForEvent("download");
await page.getByLabel("Download").click();
const download = await downloadPromise;
await expect(download.suggestedFilename()).toBe("face.obj");
});
test("Model3D drag-and-drop uploads a file to the server correctly.", async ({
page
}) => {
await drag_and_drop_file(
page,
"input[type=file]",
"./test/files/face.obj",
"face.obj"
);
await expect(await page.getByLabel("# Change Events")).toHaveValue("1");
await expect(await page.getByLabel("# Upload Events")).toHaveValue("1");
});