gradio

Форк
0
/
kitchen_sink.spec.ts 
109 строк · 3.6 Кб
1
import { test, expect } from "@gradio/tootils";
2
import { chromium } from "playwright";
3

4
test("test inputs", async ({ page }) => {
5
	const browser = await chromium.launch();
6
	const context = await browser.newContext({
7
		permissions: ["camera"]
8
	});
9
	context.grantPermissions(["camera"]);
10

11
	const textbox = await page.getByLabel("Textbox").nth(0);
12
	await expect(textbox).toHaveValue("Lorem ipsum");
13

14
	await textbox.fill("hello world");
15
	await expect(textbox).toHaveValue("hello world");
16

17
	const textbox2 = await page.getByLabel("Textbox 2");
18
	await textbox2.fill("hello world");
19
	await expect(textbox2).toHaveValue("hello world");
20

21
	const number = await page.getByLabel("Number").first();
22
	await expect(number).toHaveValue("42");
23
	await number.fill("10");
24
	await expect(number).toHaveValue("10");
25

26
	// Image Input
27
	const image = await page.locator("input").nth(10);
28
	await image.setInputFiles("./test/files/cheetah1.jpg");
29

30
	const uploaded_image = await page.locator("img").nth(0);
31
	const image_data = await uploaded_image.getAttribute("src");
32
	await expect(image_data).toBeTruthy();
33

34
	// Image Input w/ Cropper
35
	const image_cropper = await page.locator("input").nth(10);
36
	await image_cropper.setInputFiles("./test/files/cheetah1.jpg");
37

38
	const uploaded_image_cropper = await page.locator("img").nth(0);
39
	const image_data_cropper = await uploaded_image_cropper.getAttribute("src");
40
	await expect(image_data_cropper).toBeTruthy();
41

42
	// Image Input w/ Webcam
43
	await page.getByRole("button", { name: "Click to Access Webcam" }).click();
44
	await page.getByRole("button", { name: "select input source" }).click();
45
	expect(await page.getByText("fake_device_0")).toBeTruthy();
46
});
47

48
test("test outputs", async ({ page }) => {
49
	const submit_button = await page.locator("button", { hasText: /Submit/ });
50

51
	await submit_button.click();
52

53
	const textbox = await page.getByLabel("Textbox").nth(2);
54
	await expect(textbox).toHaveValue(", selected:foo, bar");
55

56
	const label = await page.getByTestId("label");
57
	await expect(label).toContainText(
58
		`  Label positive  positive  74%  negative  26%  neutral  0%`
59
	);
60

61
	const highlight_text_color_map = await page
62
		.getByTestId("highlighted-text")
63
		.nth(0);
64
	const highlight_text_legend = await page
65
		.getByTestId("highlighted-text")
66
		.nth(1);
67
	await expect(highlight_text_color_map).toContainText(
68
		"  HighlightedText  The art quick brown adj fox nn jumped vrb testing testing testing  over prp the art testing  lazy adj dogs nn . punc test 0 test 0 test 1 test 1 test 2 test 2 test 3 test 3 test 4 test 4 test 5 test 5 test 6 test 6 test 7 test 7 test 8 test 8 test 9 test 9"
69
	);
70
	await expect(highlight_text_legend).toContainText(
71
		"The testing testing testing over the testing lazy dogs . test test test test test test test test test test test test test test test test test test test test"
72
	);
73

74
	const json = await page.locator("data-testid=json");
75
	await expect(json).toContainText(`{
76
        items:  {
77
        item:  [
78
        0:  {
79
        id:  "0001",
80
        type:  null,
81
        is_good:  false,
82
        ppu:  0.55,
83
        batters:  {
84
        batter:  expand 4 children
85
        },
86
        topping:  [
87
        0:  {+2 items} ,
88
        1:  {+2 items} ,
89
        2:  {+2 items} ,
90
        3:  {+2 items} ,
91
        4:  {+2 items} ,
92
        5:  {+2 items} ,
93
        6:  {+2 items}
94
        ]
95
        }
96
        ]
97
        }
98
        }`);
99

100
	const image = page.locator("img").nth(0);
101
	const image_data = await image.getAttribute("src");
102
	expect(image_data).toBeTruthy();
103

104
	const audio = page.getByTestId("unlabelled-audio");
105
	expect(audio).toBeTruthy();
106

107
	const controls = page.getByTestId("waveform-controls");
108
	await expect(controls).toBeVisible();
109
});
110

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

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

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

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