gradio/js/app/test/clear_components.spec.ts
Abubakar Abid e671e5415f
Allow gr.ClearButton and gr.DuplicateButton to be made hidden (and otherwise updated) (#6932)
* clear visible

* test

* other buttons

* add changeset

* move resource to block cache

* revert

* Revert "revert"

This reverts commit 9830f253ac.

* notebook

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
2024-01-03 11:29:16 -08:00

31 lines
1.1 KiB
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 page.click("text=Get Values");
await expect(page.getByLabel("Are all cleared?")).toHaveValue("False");
await page.click("text=Clear");
await page.click("text=Get Values");
await expect(page.getByLabel("Are all cleared?")).toHaveValue("True");
});
test("gr.ClearButton can be made hidden and unhidden", async ({ page }) => {
await page.click("text=Hide");
const button = await page.locator("button", { hasText: "Clear" });
await expect(button).toBeHidden();
await page.click("text=Reveal");
await expect(button).not.toBeHidden();
});