Skip to content

Commit 32939ef

Browse files
committed
move new loading state test to its own file
1 parent b012fd6 commit 32939ef

File tree

2 files changed

+69
-62
lines changed

2 files changed

+69
-62
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from multiprocessing import Lock
2+
3+
import dash
4+
from dash.dependencies import Input, Output
5+
6+
import dash_core_components as dcc
7+
import dash_html_components as html
8+
9+
10+
def test_rdls001_multi_loading_components(dash_duo):
11+
lock = Lock()
12+
13+
app = dash.Dash(__name__)
14+
15+
app.layout = html.Div(
16+
children=[
17+
html.H3("Edit text input to see loading state"),
18+
dcc.Input(id="input-3", value='Input triggers the loading states'),
19+
dcc.Loading(className="loading-1", children=[
20+
html.Div(id="loading-output-1")
21+
], type="default"),
22+
html.Div(
23+
[
24+
dcc.Loading(
25+
className="loading-2",
26+
children=[html.Div([html.Div(id="loading-output-2")])],
27+
type="circle",
28+
),
29+
dcc.Loading(
30+
className="loading-3",
31+
children=dcc.Graph(id='graph'),
32+
type="cube",
33+
)
34+
]
35+
),
36+
],
37+
)
38+
39+
@app.callback(
40+
[
41+
Output("graph", "figure"),
42+
Output("loading-output-1", "children"),
43+
Output("loading-output-2", "children"),
44+
],
45+
[Input("input-3", "value")])
46+
def input_triggers_nested(value):
47+
with lock:
48+
return dict(data=[dict(y=[1, 4, 2, 3])]), value, value
49+
50+
def wait_for_all_spinners():
51+
dash_duo.find_element('.loading-1 .dash-spinner.dash-default-spinner')
52+
dash_duo.find_element('.loading-2 .dash-spinner.dash-sk-circle')
53+
dash_duo.find_element('.loading-3 .dash-spinner.dash-cube-container')
54+
55+
def wait_for_no_spinners():
56+
dash_duo.wait_for_no_elements('.dash-spinner')
57+
58+
with lock:
59+
dash_duo.start_server(app)
60+
wait_for_all_spinners()
61+
62+
wait_for_no_spinners()
63+
64+
with lock:
65+
dash_duo.find_element('#input-3').send_keys('X')
66+
wait_for_all_spinners()
67+
68+
wait_for_no_spinners()

tests/integration/renderer/test_multi_output.py

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from multiprocessing import Value, Lock
1+
from multiprocessing import Value
22

33
import dash
44
from dash.dependencies import Input, Output
@@ -164,64 +164,3 @@ def test_rdmo005_set_props_behavior(dash_duo):
164164

165165
dash_duo.find_element("#container input").send_keys("hello input w/o ID")
166166
dash_duo.wait_for_text_to_equal("#container input", "hello input w/o ID")
167-
168-
169-
def test_rdmo006_multi_loading_components(dash_duo):
170-
lock = Lock()
171-
172-
app = dash.Dash(__name__)
173-
174-
app.layout = html.Div(
175-
children=[
176-
html.H3("Edit text input to see loading state"),
177-
dcc.Input(id="input-3", value='Input triggers the loading states'),
178-
dcc.Loading(className="loading-1", children=[
179-
html.Div(id="loading-output-1")
180-
], type="default"),
181-
html.Div(
182-
[
183-
dcc.Loading(
184-
className="loading-2",
185-
children=[html.Div([html.Div(id="loading-output-2")])],
186-
type="circle",
187-
),
188-
dcc.Loading(
189-
className="loading-3",
190-
children=dcc.Graph(id='graph'),
191-
type="cube",
192-
)
193-
]
194-
),
195-
],
196-
)
197-
198-
@app.callback(
199-
[
200-
Output("graph", "figure"),
201-
Output("loading-output-1", "children"),
202-
Output("loading-output-2", "children"),
203-
],
204-
[Input("input-3", "value")])
205-
def input_triggers_nested(value):
206-
with lock:
207-
return dict(data=[dict(y=[1, 4, 2, 3])]), value, value
208-
209-
def wait_for_all_spinners():
210-
dash_duo.find_element('.loading-1 .dash-spinner.dash-default-spinner')
211-
dash_duo.find_element('.loading-2 .dash-spinner.dash-sk-circle')
212-
dash_duo.find_element('.loading-3 .dash-spinner.dash-cube-container')
213-
214-
def wait_for_no_spinners():
215-
dash_duo.wait_for_no_elements('.dash-spinner')
216-
217-
with lock:
218-
dash_duo.start_server(app)
219-
wait_for_all_spinners()
220-
221-
wait_for_no_spinners()
222-
223-
with lock:
224-
dash_duo.find_element('#input-3').send_keys('X')
225-
wait_for_all_spinners()
226-
227-
wait_for_no_spinners()

0 commit comments

Comments
 (0)