Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 26c6533

Browse files
committed
test that children retain identity inside loading components
1 parent 8bf9fbf commit 26c6533

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/integration/loading/test_loading_component.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,48 @@ def updateDynamic(n_clicks):
221221
dash_dcc.wait_for_text_to_equal("#btn-3", "changed")
222222

223223
assert not dash_dcc.get_logs()
224+
225+
226+
def test_ldcp006_children_identity(dash_dcc):
227+
lock = Lock()
228+
229+
app = dash.Dash(__name__)
230+
app.layout = html.Div([
231+
html.Button("click", id="btn"),
232+
dcc.Loading(dcc.Graph(id="graph"), className="loading")
233+
])
234+
235+
@app.callback(Output("graph", "figure"), [Input("btn", "n_clicks")])
236+
def update_graph(n):
237+
with lock:
238+
bars = list(range(2, (n or 0) + 5))
239+
return {
240+
"data": [{"type": "bar", "x": bars, "y": bars}],
241+
"layout": {"width": 400, "height": 400}
242+
}
243+
244+
with lock:
245+
dash_dcc.start_server(app)
246+
dash_dcc.find_element(".loading .dash-spinner")
247+
dash_dcc.find_element("#graph .js-plotly-plot")
248+
dash_dcc.driver.execute_script(
249+
"window.gd = document.querySelector('.js-plotly-plot');"
250+
"window.gd.__test__ = 'boo';"
251+
)
252+
253+
test_identity = (
254+
"var gd_ = document.querySelector('.js-plotly-plot');"
255+
"return gd_ === window.gd && gd_.__test__ === 'boo';"
256+
)
257+
258+
assert len(dash_dcc.find_elements('.js-plotly-plot .bars path')) == 3
259+
assert dash_dcc.driver.execute_script(test_identity)
260+
261+
with lock:
262+
dash_dcc.find_element("#btn").click()
263+
dash_dcc.find_element(".loading .dash-spinner")
264+
assert len(dash_dcc.find_elements('.js-plotly-plot .bars path')) == 3
265+
assert dash_dcc.driver.execute_script(test_identity)
266+
267+
assert len(dash_dcc.find_elements('.js-plotly-plot .bars path')) == 4
268+
assert dash_dcc.driver.execute_script(test_identity)

0 commit comments

Comments
 (0)