Skip to content

Commit afcdba9

Browse files
author
Marc-André Rivet
committed
- undo redux_state_rqs regression
- new `redux_state_is_loading` method
1 parent b8af7e3 commit afcdba9

File tree

7 files changed

+20
-8
lines changed

7 files changed

+20
-8
lines changed

dash/testing/dash_page.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,19 @@ def redux_state_paths(self):
3636
def redux_state_rqs(self):
3737
return self.driver.execute_script(
3838
"""
39-
return !window.store.getState().isLoading;
39+
var callbacksState = Object.assign({}, window.store.getState().callbacks);
40+
delete callbacksState.stored;
41+
delete callbacksState.completed;
42+
43+
return Array.prototype.concat.apply([], Object.values(callbacksState));
44+
"""
45+
)
46+
47+
@property
48+
def redux_state_is_loading(self):
49+
return self.driver.execute_script(
50+
"""
51+
return window.store.getState().isLoading;
4052
"""
4153
)
4254

tests/integration/callbacks/test_basic_callback.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def update_output(value):
4141

4242
assert call_count.value == 2 + len("hello world"), "initial count + each key stroke"
4343

44-
assert dash_duo.redux_state_rqs
44+
assert not dash_duo.redux_state_is_loading
4545

4646
assert dash_duo.get_logs() == []
4747

@@ -133,7 +133,7 @@ def update_input(value):
133133
"#sub-output-1", pad_input.attrs["value"] + "deadbeef"
134134
)
135135

136-
assert dash_duo.redux_state_rqs, "loadingMap is empty"
136+
assert not dash_duo.redux_state_is_loading, "loadingMap is empty"
137137

138138
dash_duo.percy_snapshot(name="callback-generating-function-2")
139139
assert dash_duo.get_logs() == [], "console is clean"

tests/integration/callbacks/test_layout_paths_with_callbacks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def check_chapter(chapter):
176176
TIMEOUT,
177177
)
178178

179-
assert dash_duo.redux_state_rqs, "loadingMap is empty"
179+
assert not dash_duo.redux_state_is_loading, "loadingMap is empty"
180180

181181
def check_call_counts(chapters, count):
182182
for chapter in chapters:

tests/integration/callbacks/test_missing_inputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def wait_for_queue(dash_duo):
99
# mostly for cases where no callbacks should fire:
1010
# just wait until we have the button and the queue is empty
1111
dash_duo.wait_for_text_to_equal("#btn", "click")
12-
wait.until(lambda: dash_duo.redux_state_rqs, 3)
12+
wait.until(lambda: not dash_duo.redux_state_is_loading, 3)
1313

1414

1515
def test_cbmi001_all_missing_inputs(dash_duo):

tests/integration/callbacks/test_multiple_callbacks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def update_output(n_clicks):
3232
assert call_count.value == 4, "get called 4 times"
3333
assert dash_duo.find_element("#output").text == "3", "clicked button 3 times"
3434

35-
assert dash_duo.redux_state_rqs
35+
assert not dash_duo.redux_state_is_loading
3636

3737
dash_duo.percy_snapshot(
3838
name="test_callbacks_called_multiple_times_and_out_of_order"

tests/integration/renderer/test_dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ def update_output_2(value):
4040

4141
assert output_1_call_count.value == 2 and output_2_call_count.value == 0
4242

43-
assert dash_duo.redux_state_rqs
43+
assert not dash_duo.redux_state_is_loading
4444

4545
assert dash_duo.get_logs() == []

tests/integration/renderer/test_due_diligence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_rddd001_initial_state(dash_duo):
9595
)
9696
}, "paths should reflect to the component hierarchy"
9797

98-
assert dash_duo.redux_state_rqs, "no callback => no pendingCallbacks"
98+
assert not dash_duo.redux_state_is_loading, "no callback => no pendingCallbacks"
9999

100100
dash_duo.percy_snapshot(name="layout")
101101
assert dash_duo.get_logs() == [], "console has no errors"

0 commit comments

Comments
 (0)