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>
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { test, expect, drag_and_drop_file } from "@gradio/tootils";
|
|
|
|
test("Audio click-to-upload uploads audio successfuly.", async ({ page }) => {
|
|
await page
|
|
.getByRole("button", { name: "Drop Audio Here - or - Click to Upload" })
|
|
.click();
|
|
const uploader = await page.locator("input[type=file]");
|
|
await Promise.all([
|
|
uploader.setInputFiles(["../../test/test_files/audio_sample.wav"]),
|
|
page.waitForResponse("**/upload")
|
|
]);
|
|
|
|
await expect(page.getByLabel("# Change Events")).toHaveValue("1");
|
|
await expect(page.getByLabel("# Upload Events")).toHaveValue("1");
|
|
|
|
await page.getByLabel("Clear").click();
|
|
await expect(page.getByLabel("# Change Events")).toHaveValue("2");
|
|
await page
|
|
.getByRole("button", { name: "Drop Audio Here - or - Click to Upload" })
|
|
.click();
|
|
|
|
await Promise.all([
|
|
uploader.setInputFiles(["../../test/test_files/audio_sample.wav"]),
|
|
page.waitForResponse("**/upload")
|
|
]);
|
|
|
|
await expect(page.getByLabel("# Change Events")).toHaveValue("3");
|
|
await expect(page.getByLabel("# Upload Events")).toHaveValue("2");
|
|
});
|
|
|
|
test("Audio drag-and-drop uploads a file to the server correctly.", async ({
|
|
page
|
|
}) => {
|
|
await Promise.all([
|
|
drag_and_drop_file(
|
|
page,
|
|
"input[type=file]",
|
|
"../../test/test_files/audio_sample.wav",
|
|
"audio_sample.wav",
|
|
"audio/wav"
|
|
),
|
|
page.waitForResponse("**/upload")
|
|
]);
|
|
await expect(page.getByLabel("# Change Events")).toHaveValue("1");
|
|
await expect(page.getByLabel("# Upload Events")).toHaveValue("1");
|
|
});
|
|
|
|
test("Audio 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/test_files/audio_sample.wav",
|
|
"audio_sample.wav"
|
|
);
|
|
const toast = page.getByTestId("toast-body");
|
|
expect(toast).toContainText("warning");
|
|
});
|