forked from h2oai/wave
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_copy_button.py
65 lines (54 loc) · 1.6 KB
/
test_copy_button.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
import signal
from utils import start_waved, AppRunner
import pytest
from playwright.sync_api import Page, expect
@pytest.fixture(scope='module', autouse=True)
def setup_teardown():
waved_p = None
expect.set_options(timeout=10_000)
try:
waved_p = start_waved()
yield
finally:
if waved_p:
os.killpg(os.getpgid(waved_p.pid), signal.SIGTERM)
def test_show_on_hover_copyable_text(page: Page):
code = f'''
from h2o_wave import main, app, Q, ui
@app('/')
async def serve(q: Q):
q.page['example'] = ui.form_card(box='1 1 3 5', items=[
ui.copyable_text(label='Multiline Copyable text', value='Sample text.', multiline=True),
])
await q.page.save()
'''
with AppRunner(code):
page.goto('http://localhost:10101')
textfield = page.locator('text=Sample text.')
button = page.locator('button')
expect(button).to_be_hidden()
textfield.hover()
expect(button).to_be_visible()
def test_show_on_hover_markdown_code_block(page: Page):
code = f'''
from h2o_wave import main, app, Q, ui
@app('/')
async def serve(q: Q):
q.page['example'] = ui.markdown_card(
box='1 1 3 5',
title='I was made using markdown!',
content=\'\'\'
```py
print('Hello World!')
\'\'\'
)
await q.page.save()
'''
with AppRunner(code):
page.goto('http://localhost:10101')
codeblock = page.get_by_role('code').first
button = page.locator('button')
expect(button).to_be_hidden()
codeblock.hover()
expect(button).to_be_visible()