-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathtest_title_props.py
85 lines (64 loc) · 2.63 KB
/
test_title_props.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
# -*- coding: UTF-8 -*-
from dash.testing import wait
from dash import Dash, Input, Output, dcc, html
def test_ddot001_dropdown_radioitems_checklist_option_title(dash_dcc):
app = Dash(__name__)
options = [
{"label": "New York City", "value": "NYC"},
{"label": "Montréal", "value": "MTL"},
{"label": "San Francisco", "value": "SF"},
]
app.layout = html.Div(
[
dcc.Input(
id="title_input",
type="text",
placeholder="Enter a title for New York City",
),
dcc.Dropdown(id="dropdown_1", options=options, multi=True, value="NYC"),
dcc.Dropdown(id="dropdown_2", options=options, multi=False, value="NYC"),
dcc.Checklist(
id="checklist_1",
options=options,
value=["NYC"],
labelClassName="Select-value-label",
),
dcc.RadioItems(
id="radioitems_1",
options=options,
value="NYC",
labelClassName="Select-value-label",
),
]
)
ids = ["dropdown_1", "dropdown_2", "checklist_1", "radioitems_1"]
for id in ids:
@app.callback(Output(id, "options"), [Input("title_input", "value")])
def add_title_to_option(title):
return [
{"label": "New York City", "title": title, "value": "NYC"},
{"label": "Montréal", "value": "MTL"},
{"label": "San Francisco", "value": "SF"},
]
dash_dcc.start_server(app)
elements = [
dash_dcc.wait_for_element("#dropdown_1 .Select-value"),
dash_dcc.wait_for_element("#dropdown_2 .Select-value"),
dash_dcc.wait_for_element("#checklist_1 .Select-value-label"),
dash_dcc.wait_for_element("#radioitems_1 .Select-value-label"),
]
component_title_input = dash_dcc.wait_for_element("#title_input")
# Empty string title ('') (default for no title)
for element in elements:
wait.until(lambda: element.get_attribute("title") == "", 3)
component_title_input.send_keys("The Big Apple")
for element in elements:
wait.until(lambda: element.get_attribute("title") == "The Big Apple", 3)
dash_dcc.clear_input(component_title_input)
component_title_input.send_keys("Gotham City?")
for element in elements:
wait.until(lambda: element.get_attribute("title") == "Gotham City?", 3)
dash_dcc.clear_input(component_title_input)
for element in elements:
wait.until(lambda: element.get_attribute("title") == "", 3)
assert dash_dcc.get_logs() == []