|
1 | 1 | import pytest
|
2 | 2 | import dash
|
3 |
| -from dash import Dash, Input, State, dcc, html |
| 3 | +from dash import Dash, Input, State, dcc, html, Output |
4 | 4 | from dash.dash import _ID_LOCATION
|
5 | 5 | from dash.exceptions import NoLayoutException
|
6 | 6 |
|
@@ -235,3 +235,32 @@ def test_pala005_routing_inputs(dash_duo, clear_pages_state):
|
235 | 235 | # Changing the language Input re-runs the layout function
|
236 | 236 | dash_duo.select_dcc_dropdown("#language", "fr")
|
237 | 237 | dash_duo.wait_for_text_to_equal("#contents", "Le hash dit: #123")
|
| 238 | + |
| 239 | + |
| 240 | +def test_pala006_pages_external_library(dash_duo): |
| 241 | + import dash_test_components as dt |
| 242 | + |
| 243 | + app = Dash(use_pages=True, pages_folder="") |
| 244 | + |
| 245 | + @app.callback( |
| 246 | + Output("out", "children"), |
| 247 | + Input("button", "n_clicks"), |
| 248 | + prevent_initial_call=True, |
| 249 | + ) |
| 250 | + def on_click(n_clicks): |
| 251 | + return f"Button has been clicked {n_clicks} times" |
| 252 | + |
| 253 | + dash.register_page( |
| 254 | + "page", |
| 255 | + path="/", |
| 256 | + layout=html.Div( |
| 257 | + [ |
| 258 | + dt.DelayedEventComponent(id="button"), |
| 259 | + html.Div("The button has not been clicked yet", id="out"), |
| 260 | + ] |
| 261 | + ), |
| 262 | + ) |
| 263 | + |
| 264 | + dash_duo.start_server(app) |
| 265 | + dash_duo.wait_for_element("#button").click() |
| 266 | + dash_duo.wait_for_text_to_equal("#out", "Button has been clicked 1 times") |
0 commit comments