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

Commit 4fc809a

Browse files
committed
include computed visibility in the loading/graph test
1 parent 26c6533 commit 4fc809a

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

tests/integration/loading/test_loading_component.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,20 +227,28 @@ def test_ldcp006_children_identity(dash_dcc):
227227
lock = Lock()
228228

229229
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+
)
234236

235237
@app.callback(Output("graph", "figure"), [Input("btn", "n_clicks")])
236238
def update_graph(n):
237239
with lock:
238240
bars = list(range(2, (n or 0) + 5))
239241
return {
240242
"data": [{"type": "bar", "x": bars, "y": bars}],
241-
"layout": {"width": 400, "height": 400}
243+
"layout": {"width": 400, "height": 400},
242244
}
243245

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+
244252
with lock:
245253
dash_dcc.start_server(app)
246254
dash_dcc.find_element(".loading .dash-spinner")
@@ -249,20 +257,24 @@ def update_graph(n):
249257
"window.gd = document.querySelector('.js-plotly-plot');"
250258
"window.gd.__test__ = 'boo';"
251259
)
260+
assert get_graph_visibility() == "hidden"
252261

253262
test_identity = (
254263
"var gd_ = document.querySelector('.js-plotly-plot');"
255264
"return gd_ === window.gd && gd_.__test__ === 'boo';"
256265
)
257266

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
259268
assert dash_dcc.driver.execute_script(test_identity)
269+
assert get_graph_visibility() == "visible"
260270

261271
with lock:
262272
dash_dcc.find_element("#btn").click()
263273
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
265275
assert dash_dcc.driver.execute_script(test_identity)
276+
assert get_graph_visibility() == "hidden"
266277

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
268279
assert dash_dcc.driver.execute_script(test_identity)
280+
assert get_graph_visibility() == "visible"

0 commit comments

Comments
 (0)