Skip to content

Commit

Permalink
Move test client inline restarts to own file
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Apr 3, 2023
1 parent 2538532 commit 3a0287b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 51 deletions.
51 changes: 0 additions & 51 deletions tests/integration/clientside/test_clientside.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,54 +829,3 @@ def test_clsd019_clientside_inline_promise(dash_duo):

dash_duo.start_server(app)
dash_duo.wait_for_text_to_equal("#output-div", "initial-inline")


def test_clsd020_clientside_inline_restarts(dash_duo_mp):
reloads = 0

def create_app():
nonlocal reloads

app = Dash(__name__)

app.layout = html.Div([
html.Button("Click", id="click"),
html.Div(id="output"),
html.Div(reloads, id="reload")
])

app.clientside_callback(
"(n_clicks) => `clicked ${n_clicks}`",
Output("output", "children"),
Input("click", "n_clicks"),
prevent_initial_call=True
)
reloads += 1
return app

hot_reload_settings = dict(
dev_tools_hot_reload=True,
dev_tools_ui=True,
dev_tools_serve_dev_bundles=True,
dev_tools_hot_reload_interval=0.1,
dev_tools_hot_reload_max_retry=100,
)

dash_duo_mp.start_server(
create_app(),
**hot_reload_settings
)
dash_duo_mp.find_element("#click").click()
dash_duo_mp.wait_for_text_to_equal("#output", "clicked 1")

dash_duo_mp.server.stop()

dash_duo_mp.start_server(
create_app(),
navigate=False,
**hot_reload_settings
)
dash_duo_mp.wait_for_text_to_equal("#reload", "1")
dash_duo_mp.find_element("#click").click()
# reloaded so 1 again.
dash_duo_mp.wait_for_text_to_equal("#output", "clicked 1")
52 changes: 52 additions & 0 deletions tests/integration/clientside/test_clientside_restarts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from dash import Dash, html, Output, Input


def test_clrs001_clientside_inline_restarts(dash_duo_mp):
reloads = 0

def create_app():
nonlocal reloads

app = Dash(__name__)

app.layout = html.Div([
html.Button("Click", id="click"),
html.Div(id="output"),
html.Div(reloads, id="reload")
])

app.clientside_callback(
"(n_clicks) => `clicked ${n_clicks}`",
Output("output", "children"),
Input("click", "n_clicks"),
prevent_initial_call=True
)
reloads += 1
return app

hot_reload_settings = dict(
dev_tools_hot_reload=True,
dev_tools_ui=True,
dev_tools_serve_dev_bundles=True,
dev_tools_hot_reload_interval=0.1,
dev_tools_hot_reload_max_retry=100,
)

dash_duo_mp.start_server(
create_app(),
**hot_reload_settings
)
dash_duo_mp.find_element("#click").click()
dash_duo_mp.wait_for_text_to_equal("#output", "clicked 1")

dash_duo_mp.server.stop()

dash_duo_mp.start_server(
create_app(),
navigate=False,
**hot_reload_settings
)
dash_duo_mp.wait_for_text_to_equal("#reload", "1")
dash_duo_mp.find_element("#click").click()
# reloaded so 1 again.
dash_duo_mp.wait_for_text_to_equal("#output", "clicked 1")

0 comments on commit 3a0287b

Please sign in to comment.