1
import { test, expect } from "@gradio/tootils";
3
test(".success should not run if function fails", async ({ page }) => {
4
const textbox = page.getByLabel("Result");
5
await expect(textbox).toHaveValue("");
7
await page.click("text=Trigger Failure");
8
expect(textbox).toHaveValue("");
11
test(".success event runs after function successfully completes", async ({
14
const textbox = page.getByLabel("Result");
15
await page.click("text=Trigger Success");
16
await expect(textbox).toHaveValue("Success event triggered");
19
test("Consecutive .success event is triggered successfully", async ({
22
const textbox = page.getByLabel("Consecutive Event");
23
const first = page.getByLabel("Result");
25
await page.click("text=Trigger Consecutive Success");
26
await expect(textbox).toHaveValue("Consecutive Event Triggered");
27
expect(first).toHaveValue("First Event Trigered");
30
test("gr.Error makes the toast show up", async ({ page }) => {
31
await page.click("text=Trigger Failure");
33
const toast = page.getByTestId("toast-body");
34
expect(toast).toContainText("error");
35
const close = page.getByTestId("toast-close");
37
await expect(page.getByTestId("toast-body")).toHaveCount(0);
40
test("ValueError makes the toast show up when show_error=True", async ({
43
await page.click("text=Trigger Failure With ValueError");
45
const toast = page.getByTestId("toast-body");
46
expect(toast).toContainText("error");
47
const close = page.getByTestId("toast-close");
49
await expect(page.getByTestId("toast-body")).toHaveCount(0);
52
test("gr.Info makes the toast show up", async ({ page }) => {
53
await page.click("text=Trigger Info");
54
const toast = await page.getByTestId("toast-body");
56
expect(toast).toContainText("This is some info");
57
const close = await page.getByTestId("toast-close");
59
await expect(page.getByTestId("toast-body")).toHaveCount(0);
62
test("gr.Warning makes the toast show up", async ({ page }) => {
63
await page.click("text=Trigger Warning");
65
const toast = page.getByTestId("toast-body");
66
expect(toast).toContainText("This is a warning!");
67
const close = page.getByTestId("toast-close");
69
await expect(page.getByTestId("toast-body")).toHaveCount(0);