gradio/js/app/test/stream_audio_out.spec.ts
aliabid94 5e66e01abc
Fix audio streaming out (#7881)
* changes

* add changeset

* changes

* changes

* changes

* changes

* changes

* changes

---------

Co-authored-by: Ali Abid <aliabid94@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
2024-04-01 02:25:16 -07:00

19 lines
655 B
TypeScript

import { test, expect } from "@gradio/tootils";
test("audio streams correctly", async ({ page }) => {
const uploader = await page.locator("input[type=file]");
await uploader.setInputFiles(["../../test/test_files/audio_sample.wav"]);
await page.getByRole("button", { name: "Stream as File" }).click();
await page.waitForSelector("audio");
const isAudioPlaying = await page.evaluate(async () => {
const audio = document.querySelector("audio");
if (!audio) {
return false;
}
await audio.play();
await new Promise((resolve) => setTimeout(resolve, 2000));
return audio.currentTime > 0;
});
await expect(isAudioPlaying).toBeTruthy();
});