mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-27 02:30:17 +08:00
75ddeb390d
* allow remove token via keyboard * more a11y enhancements * upload + dataset a11y tweaks * add changeset * add webcam label * improve checkbox focus styling and allow interaction via keyboard * add changeset * improve radio focus color * tweak * add radio label * add changeset * add annotated image alt + use button for labels * button tweaks * add changeset * tweak * more changes * tiny tweaks * galley / image * label tweaks and add semantic tags to confidence * nit + docstring * tweak * add changeset * fix tests * unit test fix * range tweak * fix alignment in gallery * range tweak * slider test tweak * tweak * more test fixes * last? test tweak --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
104 lines
3.4 KiB
TypeScript
104 lines
3.4 KiB
TypeScript
import { test, expect } from "@gradio/tootils";
|
|
|
|
test("selecting matplotlib should show matplotlib image and pressing clear should clear output", async ({
|
|
page
|
|
}) => {
|
|
await page.getByLabel("Plot Type").click();
|
|
await page.getByRole("option", { name: "Matplotlib" }).click();
|
|
await page.getByLabel("Month").click();
|
|
await page.getByRole("option", { name: "January" }).click();
|
|
await page.getByLabel("Social Distancing?").check();
|
|
|
|
await Promise.all([
|
|
page.click("text=Submit"),
|
|
page.waitForResponse("**/run/predict")
|
|
]);
|
|
|
|
const matplotlib_img = await page.getByTestId("matplotlib").getByRole("img");
|
|
const matplotlib_img_data = await matplotlib_img.getAttribute("src");
|
|
await expect(matplotlib_img_data).toBeTruthy();
|
|
|
|
await page.getByRole("button", { name: "Clear" }).click();
|
|
await expect(matplotlib_img).toHaveCount(0);
|
|
});
|
|
|
|
test("selecting plotly should show plotly plot and pressing clear should clear output", async ({
|
|
page
|
|
}) => {
|
|
await page.getByLabel("Plot Type").click();
|
|
await page.getByRole("option", { name: "Plotly" }).click();
|
|
await page.getByLabel("Month").click();
|
|
await page.getByRole("option", { name: "January" }).click();
|
|
await page.getByLabel("Social Distancing?").check();
|
|
|
|
await Promise.all([
|
|
page.click("text=Submit"),
|
|
page.waitForResponse("**/run/predict")
|
|
]);
|
|
await expect(page.locator(".js-plotly-plot")).toHaveCount(1);
|
|
await page.getByRole("button", { name: "Clear" }).click();
|
|
await expect(page.locator(".js-plotly-plot")).toHaveCount(0);
|
|
});
|
|
|
|
test("selecting altair should show altair plot and pressing clear should clear output", async ({
|
|
page
|
|
}) => {
|
|
await page.getByLabel("Plot Type").click();
|
|
await page.getByRole("option", { name: "altair" }).click();
|
|
await page.getByLabel("Month").click();
|
|
await page.getByRole("option", { name: "January" }).click();
|
|
await page.getByLabel("Social Distancing?").check();
|
|
|
|
await Promise.all([
|
|
page.click("text=Submit"),
|
|
page.waitForResponse("**/run/predict")
|
|
]);
|
|
|
|
const altair = await page.getByTestId("altair");
|
|
await expect(altair).toHaveCount(1);
|
|
|
|
await page.getByRole("button", { name: "Clear" }).click();
|
|
await expect(altair).toHaveCount(0);
|
|
});
|
|
|
|
test("switching between all 3 plot types and pressing submit should update output component to corresponding plot type", async ({
|
|
page
|
|
}) => {
|
|
//Matplotlib
|
|
await page.getByLabel("Plot Type").click();
|
|
await page.getByRole("option", { name: "Matplotlib" }).click();
|
|
await page.getByLabel("Month").click();
|
|
await page.getByRole("option", { name: "January" }).click();
|
|
await page.getByLabel("Social Distancing?").check();
|
|
|
|
await Promise.all([
|
|
page.click("text=Submit"),
|
|
page.waitForResponse("**/run/predict")
|
|
]);
|
|
|
|
const matplotlib_img = await page.getByTestId("matplotlib").getByRole("img");
|
|
const matplotlib_img_data = await matplotlib_img.getAttribute("src");
|
|
await expect(matplotlib_img_data).toBeTruthy();
|
|
|
|
//Plotly
|
|
await page.getByLabel("Plot Type").click();
|
|
await page.getByRole("option", { name: "Plotly" }).click();
|
|
|
|
await Promise.all([
|
|
page.click("text=Submit"),
|
|
page.waitForResponse("**/run/predict")
|
|
]);
|
|
await expect(page.locator(".js-plotly-plot")).toHaveCount(1);
|
|
|
|
//Altair
|
|
await page.getByLabel("Plot Type").click();
|
|
await page.getByRole("option", { name: "Altair" }).click();
|
|
|
|
await Promise.all([
|
|
page.click("text=Submit"),
|
|
page.waitForResponse("**/run/predict")
|
|
]);
|
|
const altair = await page.getByTestId("altair");
|
|
await expect(altair).toHaveCount(1);
|
|
});
|