Skip to content

Commit 92d0246

Browse files
committed
test server status indicator
1 parent 31f7102 commit 92d0246

File tree

2 files changed

+53
-6
lines changed

2 files changed

+53
-6
lines changed

tests/integration/devtools/test_devtools_ui.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from time import sleep
2+
13
import dash_core_components as dcc
24
import dash_html_components as html
35
import dash
@@ -25,9 +27,9 @@ def test_dvui001_disable_props_check_config(dash_duo):
2527
dash_duo.wait_for_text_to_equal("#tcid", "Hello Props Check")
2628
assert dash_duo.find_elements("#broken svg.main-svg"), "graph should be rendered"
2729

28-
assert dash_duo.find_elements(
29-
".dash-debug-menu"
30-
), "the debug menu icon should show up"
30+
# open the debug menu so we see the "hot reload off" indicator
31+
dash_duo.find_element(".dash-debug-menu").click()
32+
sleep(1) # wait for debug menu opening animation
3133

3234
dash_duo.percy_snapshot("devtools - disable props check - Graph should render")
3335

tests/integration/devtools/test_hot_reload.py

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import dash_html_components as html
55
import dash
6+
from dash.dependencies import Input, Output
7+
from dash.exceptions import PreventUpdate
68

79

810
RED_BG = """
@@ -14,15 +16,27 @@
1416

1517
def test_dvhr001_hot_reload(dash_duo):
1618
app = dash.Dash(__name__, assets_folder="hr_assets")
17-
app.layout = html.Div([html.H3("Hot reload")], id="hot-reload-content")
19+
app.layout = html.Div([
20+
html.H3("Hot reload", id="text"),
21+
html.Button("Click", id="btn")
22+
], id="hot-reload-content")
1823

19-
dash_duo.start_server(
20-
app,
24+
@app.callback(Output("text", "children"), [Input("btn", "n_clicks")])
25+
def new_text(n):
26+
if not n:
27+
raise PreventUpdate
28+
return n
29+
30+
hot_reload_settings = dict(
2131
dev_tools_hot_reload=True,
32+
dev_tools_ui=True,
33+
dev_tools_serve_dev_bundles=True,
2234
dev_tools_hot_reload_interval=0.1,
2335
dev_tools_hot_reload_max_retry=100,
2436
)
2537

38+
dash_duo.start_server(app, **hot_reload_settings)
39+
2640
# default overload color is blue
2741
dash_duo.wait_for_style_to_equal(
2842
"#hot-reload-content", "background-color", "rgba(0, 0, 255, 1)"
@@ -51,3 +65,34 @@ def test_dvhr001_hot_reload(dash_duo):
5165
dash_duo.wait_for_style_to_equal(
5266
"#hot-reload-content", "background-color", "rgba(0, 0, 255, 1)"
5367
)
68+
69+
# Now check the server status indicator functionality
70+
71+
dash_duo.find_element(".dash-debug-menu").click()
72+
dash_duo.find_element(".dash-debug-menu__button--available")
73+
sleep(1) # wait for opening animation
74+
dash_duo.percy_snapshot(name="hot-reload-available")
75+
76+
dash_duo.server.stop()
77+
sleep(1) # make sure we would have requested the reload hash multiple times
78+
dash_duo.find_element(".dash-debug-menu__button--unavailable")
79+
dash_duo.wait_for_no_elements(".dash-fe-error__title")
80+
dash_duo.percy_snapshot(name="hot-reload-unavailable")
81+
82+
dash_duo.find_element(".dash-debug-menu").click()
83+
sleep(1) # wait for opening animation
84+
dash_duo.find_element(".dash-debug-disconnected")
85+
dash_duo.percy_snapshot(name="hot-reload-unavailable-small")
86+
87+
dash_duo.find_element("#btn").click()
88+
dash_duo.wait_for_text_to_equal(
89+
".dash-fe-error__title", "Callback failed: the server did not respond."
90+
)
91+
92+
# start up the server again
93+
dash_duo.start_server(app, **hot_reload_settings)
94+
95+
# rerenders with debug menu closed after reload
96+
# reopen and check that server is now available
97+
dash_duo.find_element(".dash-debug-menu--closed").click()
98+
dash_duo.find_element(".dash-debug-menu__button--available")

0 commit comments

Comments
 (0)