gradio

Форк
0
/
blocks_chained_events.spec.ts 
70 строк · 2.2 Кб
1
import { test, expect } from "@gradio/tootils";
2

3
test(".success should not run if function fails", async ({ page }) => {
4
	const textbox = page.getByLabel("Result");
5
	await expect(textbox).toHaveValue("");
6

7
	await page.click("text=Trigger Failure");
8
	expect(textbox).toHaveValue("");
9
});
10

11
test(".success event runs after function successfully completes", async ({
12
	page
13
}) => {
14
	const textbox = page.getByLabel("Result");
15
	await page.click("text=Trigger Success");
16
	await expect(textbox).toHaveValue("Success event triggered");
17
});
18

19
test("Consecutive .success event is triggered successfully", async ({
20
	page
21
}) => {
22
	const textbox = page.getByLabel("Consecutive Event");
23
	const first = page.getByLabel("Result");
24

25
	await page.click("text=Trigger Consecutive Success");
26
	await expect(textbox).toHaveValue("Consecutive Event Triggered");
27
	expect(first).toHaveValue("First Event Trigered");
28
});
29

30
test("gr.Error makes the toast show up", async ({ page }) => {
31
	await page.click("text=Trigger Failure");
32

33
	const toast = page.getByTestId("toast-body");
34
	expect(toast).toContainText("error");
35
	const close = page.getByTestId("toast-close");
36
	await close.click();
37
	await expect(page.getByTestId("toast-body")).toHaveCount(0);
38
});
39

40
test("ValueError makes the toast show up when show_error=True", async ({
41
	page
42
}) => {
43
	await page.click("text=Trigger Failure With ValueError");
44

45
	const toast = page.getByTestId("toast-body");
46
	expect(toast).toContainText("error");
47
	const close = page.getByTestId("toast-close");
48
	await close.click();
49
	await expect(page.getByTestId("toast-body")).toHaveCount(0);
50
});
51

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");
55

56
	expect(toast).toContainText("This is some info");
57
	const close = await page.getByTestId("toast-close");
58
	await close.click();
59
	await expect(page.getByTestId("toast-body")).toHaveCount(0);
60
});
61

62
test("gr.Warning makes the toast show up", async ({ page }) => {
63
	await page.click("text=Trigger Warning");
64

65
	const toast = page.getByTestId("toast-body");
66
	expect(toast).toContainText("This is a warning!");
67
	const close = page.getByTestId("toast-close");
68
	await close.click();
69
	await expect(page.getByTestId("toast-body")).toHaveCount(0);
70
});
71

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.