mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-27 02:30:17 +08:00
aaa55ce85e
* Add code * Add code * add changeset * Add code * Add code * prevent resetting source when clearing value * Add code * Add drag-and-drop tests * add changeset * remove console log * Format * Add code * add changeset * Audio components * add changeset * add changeset * Add return type * Add code * promise --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Hannah <hannahblair@users.noreply.github.com>
70 lines
2.3 KiB
TypeScript
70 lines
2.3 KiB
TypeScript
import { test, expect, drag_and_drop_file } from "@gradio/tootils";
|
|
|
|
test("Video click-to-upload uploads video successfuly. Clear, play, and pause buttons dispatch events correctly.", async ({
|
|
page
|
|
}) => {
|
|
await page
|
|
.getByRole("button", { name: "Drop Video Here - or - Click to Upload" })
|
|
.click();
|
|
const uploader = await page.locator("input[type=file]");
|
|
await Promise.all([
|
|
uploader.setInputFiles(["./test/files/file_test.ogg"]),
|
|
page.waitForResponse("**/upload")
|
|
]);
|
|
|
|
await expect(page.getByLabel("# Change Events")).toHaveValue("1");
|
|
await expect(page.getByLabel("# Upload Events")).toHaveValue("1");
|
|
|
|
await page.getByLabel("play-pause-replay-button").nth(0).click();
|
|
await page.getByLabel("play-pause-replay-button").nth(0).click();
|
|
await expect(page.getByLabel("# Play Events")).toHaveValue("1");
|
|
await expect(page.getByLabel("# Pause Events")).toHaveValue("1");
|
|
|
|
await page.getByLabel("Clear").click();
|
|
await expect(page.getByLabel("# Change Events")).toHaveValue("2");
|
|
await page
|
|
.getByRole("button", { name: "Drop Video Here - or - Click to Upload" })
|
|
.click();
|
|
|
|
await Promise.all([
|
|
uploader.setInputFiles(["./test/files/file_test.ogg"]),
|
|
page.waitForResponse("**/upload")
|
|
]);
|
|
|
|
await expect(page.getByLabel("# Change Events")).toHaveValue("3");
|
|
await expect(page.getByLabel("# Upload Events")).toHaveValue("2");
|
|
|
|
await page.getByLabel("play-pause-replay-button").first().click();
|
|
await page.getByLabel("play-pause-replay-button").first().click();
|
|
await expect(page.getByLabel("# Play Events")).toHaveValue("2");
|
|
await expect(page.getByLabel("# Pause Events")).toHaveValue("2");
|
|
});
|
|
|
|
test("Video drag-and-drop uploads a file to the server correctly.", async ({
|
|
page
|
|
}) => {
|
|
await drag_and_drop_file(
|
|
page,
|
|
"input[type=file]",
|
|
"./test/files/file_test.ogg",
|
|
"file_test.ogg",
|
|
"video/*"
|
|
);
|
|
await page.waitForResponse("**/upload");
|
|
await expect(page.getByLabel("# Change Events")).toHaveValue("1");
|
|
await expect(page.getByLabel("# Upload Events")).toHaveValue("1");
|
|
});
|
|
|
|
test("Video drag-and-drop displays a warning when the file is of the wrong mime type.", async ({
|
|
page
|
|
}) => {
|
|
await drag_and_drop_file(
|
|
page,
|
|
"input[type=file]",
|
|
"./test/files/file_test.ogg",
|
|
"file_test.ogg"
|
|
);
|
|
const toast = page.getByTestId("toast-body");
|
|
expect(toast).toContainText("warning");
|
|
});
|