MCPcopy Index your code
hub / github.com/plotly/dash / test_rdls003_update_title

Function test_rdls003_update_title

tests/integration/renderer/test_loading_states.py:183–247  ·  view source on GitHub ↗
(
    dash_duo, kwargs, expected_update_title, clientside_title
)

Source from the content-addressed store, hash-verified

181 ],
182)
183def test_rdls003_update_title(
184 dash_duo, kwargs, expected_update_title, clientside_title
185):
186 app = Dash("Dash", **kwargs)
187 lock = Lock()
188
189 app.layout = html.Div(
190 children=[
191 html.H3("Press button see document title updating"),
192 html.Div(id="output"),
193 html.Button("Update", id="button", n_clicks=0),
194 html.Button("Update Page", id="page", n_clicks=0),
195 html.Div(id="dummy"),
196 ]
197 )
198 if clientside_title:
199 app.clientside_callback(
200 """
201 function(n_clicks) {
202 document.title = 'Page ' + n_clicks;
203 return 'Page ' + n_clicks;
204 }
205 """,
206 Output("dummy", "children"),
207 [Input("page", "n_clicks")],
208 )
209
210 @app.callback(Output("output", "children"), [Input("button", "n_clicks")])
211 def update(n):
212 with lock:
213 return n
214
215 with lock:
216 dash_duo.start_server(app)
217 # check for update-title during startup
218 # the clientside callback isn't blocking so it may update the title
219 if not clientside_title:
220 until(lambda: dash_duo.driver.title == expected_update_title, timeout=1)
221
222 # check for original title after loading
223 until(
224 lambda: dash_duo.driver.title == "Page 0" if clientside_title else "Dash",
225 timeout=1,
226 )
227
228 with lock:
229 dash_duo.find_element("#button").click()
230 # check for update-title while processing callback
231 if clientside_title and not kwargs.get("update_title", True):
232 until(lambda: dash_duo.driver.title == "Page 0", timeout=1)
233 else:
234 until(lambda: dash_duo.driver.title == expected_update_title, timeout=1)
235
236 if clientside_title:
237 dash_duo.find_element("#page").click()
238 dash_duo.wait_for_text_to_equal("#dummy", "Page 1")
239 until(lambda: dash_duo.driver.title == "Page 1", timeout=1)
240

Callers

nothing calls this directly

Calls 10

clientside_callbackMethod · 0.95
DashClass · 0.90
OutputClass · 0.90
InputClass · 0.90
untilFunction · 0.90
find_elementMethod · 0.80
start_serverMethod · 0.45
clickMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…