gradio/js/app/test/outbreak_forecast.spec.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

104 lines
3.4 KiB
TypeScript
Raw Normal View History

import { test, expect } from "@gradio/tootils";
2023-07-07 01:43:49 +08:00
test("selecting matplotlib should show matplotlib image and pressing clear should clear output", async ({
page
}) => {
Dropdown Component Updates (#3211) * dropdown * more dropdown updates * dropdown styling + option visibility * changelog * notebook * fix test * Allow more image formats (#3225) * add wildcard to image input * simplify mime types * changelog * regen noteboks --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: pngwn <hello@pngwn.io> * fix webcam mirroring (#3245) * fix webcam * changelog * fix changelog * fix changelog * fix changelog --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Add `interactive=False` mode to `gr.Button` (#3266) * add interactive=False to button * add interactive=True by default * changelog * fix frontend * fix backend test * formatting * review changes * LaTeX height fix (#3258) * latex height fix * changelog * formatting * em * em * accidentally added script (#3273) * Adding a script to benchmark the queue (#3272) * added benchmark queue script * changelg * fix instructions * Fix matplotlib image size (#3274) * Fix matplotlib css * CHANGELOG * Undo lockfile * Add timeouts to queue messages (#3196) * Fix + test * Remove print statements + fix import for 3.7 * CHANGELOG * Remove more print statements * Add 60 second timeout for uploading data * Fix test --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * icons * separate options into component * formatting * changelog * changelog * fix ui tests * formatting again... * backend test fix * format * doc fixes --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: fienestar <fienestar@gmail.com> Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
2023-02-24 05:32:18 +08:00
await page.getByLabel("Plot Type").click();
await page.getByRole("option", { name: "Matplotlib" }).click();
Dropdown Component Updates (#3211) * dropdown * more dropdown updates * dropdown styling + option visibility * changelog * notebook * fix test * Allow more image formats (#3225) * add wildcard to image input * simplify mime types * changelog * regen noteboks --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: pngwn <hello@pngwn.io> * fix webcam mirroring (#3245) * fix webcam * changelog * fix changelog * fix changelog * fix changelog --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Add `interactive=False` mode to `gr.Button` (#3266) * add interactive=False to button * add interactive=True by default * changelog * fix frontend * fix backend test * formatting * review changes * LaTeX height fix (#3258) * latex height fix * changelog * formatting * em * em * accidentally added script (#3273) * Adding a script to benchmark the queue (#3272) * added benchmark queue script * changelg * fix instructions * Fix matplotlib image size (#3274) * Fix matplotlib css * CHANGELOG * Undo lockfile * Add timeouts to queue messages (#3196) * Fix + test * Remove print statements + fix import for 3.7 * CHANGELOG * Remove more print statements * Add 60 second timeout for uploading data * Fix test --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * icons * separate options into component * formatting * changelog * changelog * fix ui tests * formatting again... * backend test fix * format * doc fixes --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: fienestar <fienestar@gmail.com> Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
2023-02-24 05:32:18 +08:00
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")
]);
2023-07-07 01:43:49 +08:00
const matplotlib_img = await page.getByTestId("matplotlib").getByRole("img");
const matplotlib_img_data = await matplotlib_img.getAttribute("src");
await expect(matplotlib_img_data).toBeTruthy();
2023-07-07 01:43:49 +08:00
await page.getByRole("button", { name: "Clear" }).click();
await expect(matplotlib_img).toHaveCount(0);
});
2023-07-07 01:43:49 +08:00
test("selecting plotly should show plotly plot and pressing clear should clear output", async ({
page
}) => {
Dropdown Component Updates (#3211) * dropdown * more dropdown updates * dropdown styling + option visibility * changelog * notebook * fix test * Allow more image formats (#3225) * add wildcard to image input * simplify mime types * changelog * regen noteboks --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: pngwn <hello@pngwn.io> * fix webcam mirroring (#3245) * fix webcam * changelog * fix changelog * fix changelog * fix changelog --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Add `interactive=False` mode to `gr.Button` (#3266) * add interactive=False to button * add interactive=True by default * changelog * fix frontend * fix backend test * formatting * review changes * LaTeX height fix (#3258) * latex height fix * changelog * formatting * em * em * accidentally added script (#3273) * Adding a script to benchmark the queue (#3272) * added benchmark queue script * changelg * fix instructions * Fix matplotlib image size (#3274) * Fix matplotlib css * CHANGELOG * Undo lockfile * Add timeouts to queue messages (#3196) * Fix + test * Remove print statements + fix import for 3.7 * CHANGELOG * Remove more print statements * Add 60 second timeout for uploading data * Fix test --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * icons * separate options into component * formatting * changelog * changelog * fix ui tests * formatting again... * backend test fix * format * doc fixes --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: fienestar <fienestar@gmail.com> Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
2023-02-24 05:32:18 +08:00
await page.getByLabel("Plot Type").click();
await page.getByRole("option", { name: "Plotly" }).click();
Dropdown Component Updates (#3211) * dropdown * more dropdown updates * dropdown styling + option visibility * changelog * notebook * fix test * Allow more image formats (#3225) * add wildcard to image input * simplify mime types * changelog * regen noteboks --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: pngwn <hello@pngwn.io> * fix webcam mirroring (#3245) * fix webcam * changelog * fix changelog * fix changelog * fix changelog --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Add `interactive=False` mode to `gr.Button` (#3266) * add interactive=False to button * add interactive=True by default * changelog * fix frontend * fix backend test * formatting * review changes * LaTeX height fix (#3258) * latex height fix * changelog * formatting * em * em * accidentally added script (#3273) * Adding a script to benchmark the queue (#3272) * added benchmark queue script * changelg * fix instructions * Fix matplotlib image size (#3274) * Fix matplotlib css * CHANGELOG * Undo lockfile * Add timeouts to queue messages (#3196) * Fix + test * Remove print statements + fix import for 3.7 * CHANGELOG * Remove more print statements * Add 60 second timeout for uploading data * Fix test --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * icons * separate options into component * formatting * changelog * changelog * fix ui tests * formatting again... * backend test fix * format * doc fixes --------- Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: fienestar <fienestar@gmail.com> Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
2023-02-24 05:32:18 +08:00
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);
2023-07-07 01:43:49 +08:00
await page.getByRole("button", { name: "Clear" }).click();
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
}) => {
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")
]);
2023-07-07 01:43:49 +08:00
const altair = await page.getByTestId("altair");
await expect(altair).toHaveCount(1);
2023-07-07 01:43:49 +08:00
await page.getByRole("button", { name: "Clear" }).click();
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
}) => {
//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")
]);
2023-07-07 01:43:49 +08:00
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")
]);
2023-07-07 01:43:49 +08:00
const altair = await page.getByTestId("altair");
await expect(altair).toHaveCount(1);
});