Skip to content

Commit

Permalink
Merge branch 'main' into audio-change
Browse files Browse the repository at this point in the history
  • Loading branch information
abidlabs committed Jul 10, 2023
2 parents 1876a4e + c17b91e commit 74cc008
Showing 1 changed file with 7 additions and 26 deletions.
33 changes: 7 additions & 26 deletions js/app/test/blocks_chained_events.spec.ts
Original file line number Diff line number Diff line change
@@ -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("");
Expand All @@ -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 ({
Expand Down Expand Up @@ -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");
Expand All @@ -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!");
Expand Down

0 comments on commit 74cc008

Please sign in to comment.