Skip to content

Commit c2c62cc

Browse files
committed
✅ Add test_html
1 parent 5e25f86 commit c2c62cc

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

tests/components/pages/html2.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from dazzler.system import Page, transforms as t
2+
from dazzler.components import html
3+
4+
5+
page = Page(
6+
__name__,
7+
html.Div([
8+
html.H1('Dazzler html components'),
9+
html.Main([
10+
html.Section([
11+
html.H3('Inputs'),
12+
html.Div('clicker', identity='clicker', handle_clicks=True),
13+
html.Select([
14+
html.Option('opt 1', value=1),
15+
html.Option('opt 2', value=2),
16+
html.Option('opt 3', value=3)
17+
], handle_focus=True, identity='focus-select'),
18+
html.Div(
19+
'Hoverable',
20+
identity='hoverable',
21+
handle_hover=True,
22+
style={'padding': 12, 'background': '#dcdcdc'}
23+
),
24+
]),
25+
html.Section([
26+
html.H3('Outputs'),
27+
html.Div(identity='clicker-output'),
28+
html.Div(identity='clicker-event-output'),
29+
html.Div(identity='hover-output'),
30+
html.Div(identity='focus-output'),
31+
]),
32+
]),
33+
]),
34+
packages=['dazzler_html']
35+
)
36+
37+
page.tie('clicks@clicker', 'children@clicker-output')
38+
page.tie('click_event@clicker', 'children@clicker-event-output').transform(
39+
t.ToJson()
40+
)
41+
page.tie('is_focused@focus-select', 'children@focus-output').transform(
42+
t.Format('Focused: ${value}')
43+
)
44+
page.tie('is_hovered@hoverable', 'children@hover-output').transform(
45+
t.Format('Hovered: ${value}')
46+
)

tests/components/test_html.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import pytest
2+
3+
4+
@pytest.mark.async_test
5+
async def test_html_components(browser, start_page):
6+
from tests.components.pages.html2 import page
7+
8+
await start_page(page)
9+
10+
await browser.click('#clicker')
11+
await browser.wait_for_text_to_equal(
12+
'#clicker-output',
13+
'1'
14+
)
15+
16+
await browser.wait_for_text_to_equal(
17+
'main section:first-child > h3',
18+
'Inputs'
19+
)
20+
await browser.click('#focus-select')
21+
await browser.wait_for_text_to_equal(
22+
'#focus-output',
23+
'Focused: true'
24+
)

0 commit comments

Comments
 (0)