diff --git a/js/app/test/blocks_chained_events.spec.ts b/js/app/test/blocks_chained_events.spec.ts index 382bc5de63..df3c73cf07 100644 --- a/js/app/test/blocks_chained_events.spec.ts +++ b/js/app/test/blocks_chained_events.spec.ts @@ -1,9 +1,7 @@ import { test, expect } from "@gradio/tootils"; import type { Response } from "@playwright/test"; -test(".success event runs after function successfully completes. .success should not run if function fails", async ({ - page -}) => { +test(".success should not run if function fails", async ({ page }) => { let last_iteration; const textbox = page.getByLabel("Result"); await expect(textbox).toHaveValue(""); @@ -19,10 +17,14 @@ test(".success event runs after function successfully completes. .success should await page.click("text=Trigger Failure"); await last_iteration; expect(textbox).toHaveValue(""); +}); +test(".success event runs after function successfully completes", async ({ + page +}) => { + const textbox = page.getByLabel("Result"); await page.click("text=Trigger Success"); - await last_iteration; - expect(textbox).toHaveValue("Success event triggered"); + await expect(textbox).toHaveValue("Success event triggered"); }); test("Consecutive .success event is triggered successfully", async ({ @@ -79,18 +81,7 @@ test("ValueError makes the toast show up when show_error=True", async ({ }); test("gr.Info makes the toast show up", async ({ page }) => { - let complete; - page.on("websocket", (ws) => { - complete = ws.waitForEvent("framereceived", { - predicate: (event) => { - return JSON.parse(event.payload as string).msg === "process_completed"; - } - }); - }); - await page.click("text=Trigger Info"); - await complete; - const toast = page.getByTestId("toast-body"); expect(toast).toContainText("This is some info"); @@ -100,17 +91,7 @@ test("gr.Info makes the toast show up", async ({ page }) => { }); test("gr.Warning makes the toast show up", async ({ page }) => { - let complete; - page.on("websocket", (ws) => { - complete = ws.waitForEvent("framereceived", { - predicate: (event) => { - return JSON.parse(event.payload as string).msg === "process_completed"; - } - }); - }); - page.click("text=Trigger Warning"); - await complete; const toast = page.getByTestId("toast-body"); expect(toast).toContainText("This is a warning!");