-
Notifications
You must be signed in to change notification settings - Fork 224
/
Copy pathtest_popover.py
91 lines (74 loc) · 2.65 KB
/
test_popover.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import dash.testing.wait as wait
from dash import Dash, html
from dash_bootstrap_components import (
Popover,
PopoverBody,
PopoverHeader,
themes,
)
from selenium.webdriver.common.action_chains import ActionChains
def test_dbpo001_popover_click(dash_duo):
app = Dash(external_stylesheets=[themes.BOOTSTRAP])
app.layout = html.Div(
[
Popover(
[PopoverHeader("Test Header"), PopoverBody("Test content")],
id="popover",
target="popover-target",
trigger="click",
),
html.Div("Target", id="popover-target"),
],
className="container p-5",
)
dash_duo.start_server(app)
dash_duo.wait_for_element_by_id("popover-target").click()
dash_duo.wait_for_text_to_equal(".popover-body", "Test content", timeout=4)
def test_dbpo002_popover_hover(dash_duo):
app = Dash(external_stylesheets=[themes.BOOTSTRAP])
app.layout = html.Div(
[
Popover(
[PopoverHeader("Test Header"), PopoverBody("Test content")],
id="popover",
target="popover-target",
trigger="hover",
),
html.Div("Target", id="popover-target"),
],
className="container p-5",
)
dash_duo.start_server(app)
hover = ActionChains(dash_duo.driver).move_to_element(
dash_duo.wait_for_element_by_id("popover-target")
)
hover.perform()
dash_duo.wait_for_text_to_equal(".popover-body", "Test content", timeout=4)
def test_dbpo003_popover_legacy(dash_duo):
app = Dash(external_stylesheets=[themes.BOOTSTRAP])
app.layout = html.Div(
[
html.Div("No Target Here", id="not-a-target"),
html.Hr(),
Popover(
[PopoverHeader("Test Header"), PopoverBody("Test content")],
id="popover",
target="popover-target",
trigger="legacy",
),
html.Div("Target", id="popover-target"),
],
className="container p-5 w-50",
)
dash_duo.start_server(app)
dash_duo.wait_for_element_by_id("popover-target").click()
dash_duo.wait_for_text_to_equal(".popover-body", "Test content", timeout=4)
# Try clicking on the popover - shouldn't dismiss
dash_duo.wait_for_element_by_id("popover").click()
dash_duo.wait_for_text_to_equal(".popover-body", "Test content", timeout=4)
# Try clicking outside the popover - should dismiss
dash_duo.wait_for_element_by_id("not-a-target").click()
wait.until(
lambda: len(dash_duo.find_elements("#popover")) == 0,
timeout=4,
)