@@ -227,20 +227,28 @@ def test_ldcp006_children_identity(dash_dcc):
227
227
lock = Lock ()
228
228
229
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
- ])
230
+ app .layout = html .Div (
231
+ [
232
+ html .Button ("click" , id = "btn" ),
233
+ dcc .Loading (dcc .Graph (id = "graph" ), className = "loading" ),
234
+ ]
235
+ )
234
236
235
237
@app .callback (Output ("graph" , "figure" ), [Input ("btn" , "n_clicks" )])
236
238
def update_graph (n ):
237
239
with lock :
238
240
bars = list (range (2 , (n or 0 ) + 5 ))
239
241
return {
240
242
"data" : [{"type" : "bar" , "x" : bars , "y" : bars }],
241
- "layout" : {"width" : 400 , "height" : 400 }
243
+ "layout" : {"width" : 400 , "height" : 400 },
242
244
}
243
245
246
+ def get_graph_visibility ():
247
+ return dash_dcc .driver .execute_script (
248
+ "var gd_ = document.querySelector('.js-plotly-plot');"
249
+ "return getComputedStyle(gd_).visibility;"
250
+ )
251
+
244
252
with lock :
245
253
dash_dcc .start_server (app )
246
254
dash_dcc .find_element (".loading .dash-spinner" )
@@ -249,20 +257,24 @@ def update_graph(n):
249
257
"window.gd = document.querySelector('.js-plotly-plot');"
250
258
"window.gd.__test__ = 'boo';"
251
259
)
260
+ assert get_graph_visibility () == "hidden"
252
261
253
262
test_identity = (
254
263
"var gd_ = document.querySelector('.js-plotly-plot');"
255
264
"return gd_ === window.gd && gd_.__test__ === 'boo';"
256
265
)
257
266
258
- assert len (dash_dcc .find_elements (' .js-plotly-plot .bars path' )) == 3
267
+ assert len (dash_dcc .find_elements (" .js-plotly-plot .bars path" )) == 3
259
268
assert dash_dcc .driver .execute_script (test_identity )
269
+ assert get_graph_visibility () == "visible"
260
270
261
271
with lock :
262
272
dash_dcc .find_element ("#btn" ).click ()
263
273
dash_dcc .find_element (".loading .dash-spinner" )
264
- assert len (dash_dcc .find_elements (' .js-plotly-plot .bars path' )) == 3
274
+ assert len (dash_dcc .find_elements (" .js-plotly-plot .bars path" )) == 3
265
275
assert dash_dcc .driver .execute_script (test_identity )
276
+ assert get_graph_visibility () == "hidden"
266
277
267
- assert len (dash_dcc .find_elements (' .js-plotly-plot .bars path' )) == 4
278
+ assert len (dash_dcc .find_elements (" .js-plotly-plot .bars path" )) == 4
268
279
assert dash_dcc .driver .execute_script (test_identity )
280
+ assert get_graph_visibility () == "visible"
0 commit comments