2023-06-20 04:02:03 +08:00
|
|
|
import { test, expect } from "@gradio/tootils";
|
2022-07-26 00:48:59 +08:00
|
|
|
|
2023-07-07 01:43:49 +08:00
|
|
|
test("selecting matplotlib should show matplotlib image and pressing clear should clear output", async ({
|
|
|
|
page
|
|
|
|
}) => {
|
2023-02-24 05:32:18 +08:00
|
|
|
await page.getByLabel("Plot Type").click();
|
2023-09-22 20:12:26 +08:00
|
|
|
await page.getByRole("option", { name: "Matplotlib" }).click();
|
2023-02-24 05:32:18 +08:00
|
|
|
await page.getByLabel("Month").click();
|
2023-09-22 20:12:26 +08:00
|
|
|
await page.getByRole("option", { name: "January" }).click();
|
2022-10-13 00:30:42 +08:00
|
|
|
await page.getByLabel("Social Distancing?").check();
|
|
|
|
|
2022-07-26 00:48:59 +08:00
|
|
|
await Promise.all([
|
2022-10-13 00:30:42 +08:00
|
|
|
page.click("text=Submit"),
|
2023-03-08 00:36:25 +08:00
|
|
|
page.waitForResponse("**/run/predict")
|
2022-07-26 00:48:59 +08:00
|
|
|
]);
|
|
|
|
|
2023-07-07 01:43:49 +08:00
|
|
|
const matplotlib_img = await page.getByTestId("matplotlib").getByRole("img");
|
2022-07-26 00:48:59 +08:00
|
|
|
const matplotlib_img_data = await matplotlib_img.getAttribute("src");
|
2023-06-20 04:02:03 +08:00
|
|
|
await expect(matplotlib_img_data).toBeTruthy();
|
2023-07-05 03:23:50 +08:00
|
|
|
|
2023-07-07 01:43:49 +08:00
|
|
|
await page.getByRole("button", { name: "Clear" }).click();
|
2023-07-05 03:23:50 +08:00
|
|
|
await expect(matplotlib_img).toHaveCount(0);
|
2022-07-26 00:48:59 +08:00
|
|
|
});
|
|
|
|
|
2023-07-07 01:43:49 +08:00
|
|
|
test("selecting plotly should show plotly plot and pressing clear should clear output", async ({
|
|
|
|
page
|
|
|
|
}) => {
|
2023-02-24 05:32:18 +08:00
|
|
|
await page.getByLabel("Plot Type").click();
|
2023-09-22 20:12:26 +08:00
|
|
|
await page.getByRole("option", { name: "Plotly" }).click();
|
2023-02-24 05:32:18 +08:00
|
|
|
await page.getByLabel("Month").click();
|
2023-09-22 20:12:26 +08:00
|
|
|
await page.getByRole("option", { name: "January" }).click();
|
2022-10-13 00:30:42 +08:00
|
|
|
await page.getByLabel("Social Distancing?").check();
|
|
|
|
|
2022-07-26 00:48:59 +08:00
|
|
|
await Promise.all([
|
2022-10-13 00:30:42 +08:00
|
|
|
page.click("text=Submit"),
|
2023-03-08 00:36:25 +08:00
|
|
|
page.waitForResponse("**/run/predict")
|
2022-07-26 00:48:59 +08:00
|
|
|
]);
|
|
|
|
await expect(page.locator(".js-plotly-plot")).toHaveCount(1);
|
2023-07-07 01:43:49 +08:00
|
|
|
await page.getByRole("button", { name: "Clear" }).click();
|
2023-07-05 03:23:50 +08:00
|
|
|
await expect(page.locator(".js-plotly-plot")).toHaveCount(0);
|
|
|
|
});
|
|
|
|
|
2023-07-07 01:43:49 +08:00
|
|
|
test("selecting altair should show altair plot and pressing clear should clear output", async ({
|
|
|
|
page
|
|
|
|
}) => {
|
2023-07-05 03:23:50 +08:00
|
|
|
await page.getByLabel("Plot Type").click();
|
2023-09-22 20:12:26 +08:00
|
|
|
await page.getByRole("option", { name: "altair" }).click();
|
2023-07-05 03:23:50 +08:00
|
|
|
await page.getByLabel("Month").click();
|
2023-09-22 20:12:26 +08:00
|
|
|
await page.getByRole("option", { name: "January" }).click();
|
2023-07-05 03:23:50 +08:00
|
|
|
await page.getByLabel("Social Distancing?").check();
|
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
page.click("text=Submit"),
|
|
|
|
page.waitForResponse("**/run/predict")
|
|
|
|
]);
|
|
|
|
|
2023-07-07 01:43:49 +08:00
|
|
|
const altair = await page.getByTestId("altair");
|
2023-07-05 03:23:50 +08:00
|
|
|
await expect(altair).toHaveCount(1);
|
|
|
|
|
2023-07-07 01:43:49 +08:00
|
|
|
await page.getByRole("button", { name: "Clear" }).click();
|
2023-07-05 03:23:50 +08:00
|
|
|
await expect(altair).toHaveCount(0);
|
|
|
|
});
|
|
|
|
|
2023-07-07 01:43:49 +08:00
|
|
|
test("switching between all 3 plot types and pressing submit should update output component to corresponding plot type", async ({
|
|
|
|
page
|
|
|
|
}) => {
|
2023-07-05 03:23:50 +08:00
|
|
|
//Matplotlib
|
|
|
|
await page.getByLabel("Plot Type").click();
|
2023-09-22 20:12:26 +08:00
|
|
|
await page.getByRole("option", { name: "Matplotlib" }).click();
|
2023-07-05 03:23:50 +08:00
|
|
|
await page.getByLabel("Month").click();
|
2023-09-22 20:12:26 +08:00
|
|
|
await page.getByRole("option", { name: "January" }).click();
|
2023-07-05 03:23:50 +08:00
|
|
|
await page.getByLabel("Social Distancing?").check();
|
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
page.click("text=Submit"),
|
|
|
|
page.waitForResponse("**/run/predict")
|
|
|
|
]);
|
|
|
|
|
2023-07-07 01:43:49 +08:00
|
|
|
const matplotlib_img = await page.getByTestId("matplotlib").getByRole("img");
|
2023-07-05 03:23:50 +08:00
|
|
|
const matplotlib_img_data = await matplotlib_img.getAttribute("src");
|
|
|
|
await expect(matplotlib_img_data).toBeTruthy();
|
|
|
|
|
|
|
|
//Plotly
|
|
|
|
await page.getByLabel("Plot Type").click();
|
2023-09-22 20:12:26 +08:00
|
|
|
await page.getByRole("option", { name: "Plotly" }).click();
|
2023-07-05 03:23:50 +08:00
|
|
|
|
|
|
|
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();
|
2023-09-22 20:12:26 +08:00
|
|
|
await page.getByRole("option", { name: "Altair" }).click();
|
2023-07-05 03:23:50 +08:00
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
page.click("text=Submit"),
|
|
|
|
page.waitForResponse("**/run/predict")
|
|
|
|
]);
|
2023-07-07 01:43:49 +08:00
|
|
|
const altair = await page.getByTestId("altair");
|
2023-07-05 03:23:50 +08:00
|
|
|
await expect(altair).toHaveCount(1);
|
2022-07-26 00:48:59 +08:00
|
|
|
});
|