|
1 |
| -from multiprocessing import Value |
| 1 | +from multiprocessing import Value, Lock |
2 | 2 |
|
3 | 3 | import dash
|
4 | 4 | from dash.dependencies import Input, Output
|
@@ -164,3 +164,64 @@ def test_rdmo005_set_props_behavior(dash_duo):
|
164 | 164 |
|
165 | 165 | dash_duo.find_element("#container input").send_keys("hello input w/o ID")
|
166 | 166 | 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