forked from zauberzeug/nicegui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_dialog.py
46 lines (36 loc) · 1.17 KB
/
test_dialog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from typing import List
from selenium.webdriver.common.keys import Keys
from nicegui import ui
from .screen import Screen
def test_open_close_dialog(screen: Screen):
with ui.dialog() as d, ui.card():
ui.label('Content')
ui.button('Close', on_click=d.close)
ui.button('Open', on_click=d.open)
screen.open('/')
screen.should_not_contain('Content')
screen.click('Open')
screen.wait(0.5)
screen.should_contain('Content')
screen.click('Close')
screen.wait(0.5)
screen.should_not_contain('Content')
def test_await_dialog(screen: Screen):
with ui.dialog() as dialog, ui.card():
ui.label('Are you sure?')
with ui.row():
ui.button('Yes', on_click=lambda: dialog.submit('Yes'))
ui.button('No', on_click=lambda: dialog.submit('No'))
async def show() -> None:
results.append(await dialog)
results: List[str] = []
ui.button('Open', on_click=show)
screen.open('/')
screen.click('Open')
screen.click('Yes')
screen.click('Open')
screen.click('No')
screen.click('Open')
screen.type(Keys.ESCAPE)
screen.wait(0.5)
assert results == ['Yes', 'No', None]