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

Ensure that components are still in the DOM when they are loading. #740

Merged
merged 28 commits into from
Apr 9, 2020
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8e181d7
Ensure that components are still in the DOM when they are loading.
Jan 22, 2020
73db3ca
Define style prop for spinners as object and not bool.
Jan 22, 2020
377004b
Fix CSS property names.
Jan 22, 2020
a09a508
Merge branch 'dev' into 674-map-uirevision
Jan 22, 2020
284c3a3
Update loading component tests.
Jan 23, 2020
a90af15
Merge branch 'dev' into 674-map-uirevision
Feb 3, 2020
ceff132
Merge branch 'dev' into 674-map-uirevision
Feb 4, 2020
6167e15
Merge branch 'dev' into 674-map-uirevision
Marc-Andre-Rivet Mar 2, 2020
bfe6d15
Fix test name.
shammamah-zz Mar 3, 2020
8dc4529
Lock circleci python versions.
shammamah-zz Mar 3, 2020
1ead9bc
Merge branch 'dev' into 674-map-uirevision
Mar 5, 2020
ef5d193
Merge branch 'dev' into 674-map-uirevision
Mar 10, 2020
1cb8da3
Update CHANGELOG.
Mar 10, 2020
49fc1ea
Merge branch 'dev' into 674-map-uirevision
alexcjohnson Apr 9, 2020
f985ece
revert python version lock on CI
alexcjohnson Apr 9, 2020
01425ff
pyest.ini - mainly to speed up test discovery with `testpaths`
alexcjohnson Apr 9, 2020
6d398a2
extend --pause option to dashdcc fixture
alexcjohnson Apr 9, 2020
aa4fce7
fix typo in test_graph_basics that somehow we didn't care about before
alexcjohnson Apr 9, 2020
600a09f
more consistent structure for Loading component
alexcjohnson Apr 9, 2020
386137e
robustify store test
alexcjohnson Apr 9, 2020
22a1975
port loading component tests to dash.testing - without fixing them
alexcjohnson Apr 9, 2020
2bfaa28
update loading component tests for new class usage
alexcjohnson Apr 9, 2020
8bf9fbf
black test_loading_component
alexcjohnson Apr 9, 2020
26c6533
test that children retain identity inside loading components
alexcjohnson Apr 9, 2020
a80f0db
Update CHANGELOG.md
alexcjohnson Apr 9, 2020
4fc809a
include computed visibility in the loading/graph test
alexcjohnson Apr 9, 2020
fb15aa9
Merge branch '674-map-uirevision' of github.com:plotly/dash-core-comp…
alexcjohnson Apr 9, 2020
2b41ea0
robustify store test_data_lifecycle
alexcjohnson Apr 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions tests/integration/loading/test_loading_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,20 +227,28 @@ def test_ldcp006_children_identity(dash_dcc):
lock = Lock()

app = dash.Dash(__name__)
app.layout = html.Div([
html.Button("click", id="btn"),
dcc.Loading(dcc.Graph(id="graph"), className="loading")
])
app.layout = html.Div(
[
html.Button("click", id="btn"),
dcc.Loading(dcc.Graph(id="graph"), className="loading"),
]
)

@app.callback(Output("graph", "figure"), [Input("btn", "n_clicks")])
def update_graph(n):
with lock:
bars = list(range(2, (n or 0) + 5))
return {
"data": [{"type": "bar", "x": bars, "y": bars}],
"layout": {"width": 400, "height": 400}
"layout": {"width": 400, "height": 400},
}

def get_graph_visibility():
return dash_dcc.driver.execute_script(
"var gd_ = document.querySelector('.js-plotly-plot');"
"return getComputedStyle(gd_).visibility;"
)

with lock:
dash_dcc.start_server(app)
dash_dcc.find_element(".loading .dash-spinner")
Expand All @@ -249,20 +257,24 @@ def update_graph(n):
"window.gd = document.querySelector('.js-plotly-plot');"
"window.gd.__test__ = 'boo';"
)
assert get_graph_visibility() == "hidden"

test_identity = (
"var gd_ = document.querySelector('.js-plotly-plot');"
"return gd_ === window.gd && gd_.__test__ === 'boo';"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gd_.__test__ === 'boo' should be redundant after we already have gd_ === window.gd to show the DOM element is unchanged, just being paranoid again...

)

assert len(dash_dcc.find_elements('.js-plotly-plot .bars path')) == 3
assert len(dash_dcc.find_elements(".js-plotly-plot .bars path")) == 3
assert dash_dcc.driver.execute_script(test_identity)
assert get_graph_visibility() == "visible"

with lock:
dash_dcc.find_element("#btn").click()
dash_dcc.find_element(".loading .dash-spinner")
assert len(dash_dcc.find_elements('.js-plotly-plot .bars path')) == 3
assert len(dash_dcc.find_elements(".js-plotly-plot .bars path")) == 3
assert dash_dcc.driver.execute_script(test_identity)
assert get_graph_visibility() == "hidden"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇


assert len(dash_dcc.find_elements('.js-plotly-plot .bars path')) == 4
assert len(dash_dcc.find_elements(".js-plotly-plot .bars path")) == 4
assert dash_dcc.driver.execute_script(test_identity)
assert get_graph_visibility() == "visible"