gradio/js/app/test/clear_components.spec.ts
Freddy Boulton 3a6406e5d5
ClearButton browser test (#4749)
* Icon testids

* Simpler test

* Add test

* Demo check

* Add notebook

* Revert demo

* Fix code

* Add non-None callable value

* change

---------

Co-authored-by: pngwn <hello@pngwn.io>
2023-07-04 19:22:25 +01:00

29 lines
998 B
TypeScript

import { test, expect } from "@gradio/tootils";
test("Components value can be set via callable to a non-None value", async ({
page
}) => {
const textBoxValue = await page.getByLabel(`component_00`).inputValue();
expect(textBoxValue.length).toBeGreaterThan(1);
const sliderValue = await page.getByLabel(`component_01`).inputValue();
expect(parseFloat(sliderValue)).toBeGreaterThan(0);
const dropDownValue = await page.getByLabel(`component_07`).inputValue();
expect(Array("a", "b", "c").includes(dropDownValue)).toBeTruthy();
});
test("gr.ClearButton clears every component's value", async ({ page }) => {
await Promise.all([
page.waitForResponse("**/run/predict"),
page.click("text=Get Values")
]);
await expect(page.getByLabel("Are all cleared?")).toHaveValue("False");
await page.click("text=Clear");
await Promise.all([
page.waitForResponse("**/run/predict"),
page.click("text=Get Values")
]);
await expect(page.getByLabel("Are all cleared?")).toHaveValue("True");
});