Skip to content

Commit 8862956

Browse files
committed
updated patch test to use until instead of assert to allow timing flux
1 parent e2f89e9 commit 8862956

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

dash/dash-renderer/src/reducers/reducer.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ function adjustHashes(state, action) {
3131
const actionPath = action.payload.itempath;
3232
const strPath = stringifyPath(actionPath);
3333
const prev = pathOr(0, [strPath, 0], state);
34-
state = assoc(
35-
strPath,
36-
[prev + 1, action.payload.props],
37-
state
38-
);
34+
state = assoc(strPath, [prev + 1, action.payload.props], state);
3935
return state;
4036
}
4137

tests/integration/test_patch.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from selenium.webdriver.common.keys import Keys
66

77
from dash import Dash, html, dcc, Input, Output, State, ALL, Patch
8+
from dash.testing.wait import until
89

910

1011
@flaky.flaky(max_runs=3)
@@ -219,93 +220,93 @@ def get_output():
219220
_input.send_keys("Set Value")
220221
dash_duo.find_element("#set-btn").click()
221222

222-
assert get_output()["value"] == "Set Value"
223+
until(lambda: get_output()["value"] == "Set Value", 2)
223224

224225
_input = dash_duo.find_element("#append-value")
225226
_input.send_keys("Append")
226227
dash_duo.find_element("#append-btn").click()
227228

228-
assert get_output()["array"] == ["initial", "Append"]
229+
until(lambda: get_output()["array"] == ["initial", "Append"], 2)
229230

230231
_input = dash_duo.find_element("#prepend-value")
231232
_input.send_keys("Prepend")
232233
dash_duo.find_element("#prepend-btn").click()
233234

234-
assert get_output()["array"] == ["Prepend", "initial", "Append"]
235+
until(lambda: get_output()["array"] == ["Prepend", "initial", "Append"], 2)
235236

236237
_input = dash_duo.find_element("#extend-value")
237238
_input.send_keys("Extend")
238239
dash_duo.find_element("#extend-btn").click()
239240

240-
assert get_output()["array"] == ["Prepend", "initial", "Append", "Extend"]
241+
until(lambda: get_output()["array"] == ["Prepend", "initial", "Append", "Extend"], 2)
241242

242243
undef = object()
243-
assert get_output().get("merge", undef) is undef
244+
until(lambda: get_output().get("merge", undef) is undef, 2)
244245

245246
_input = dash_duo.find_element("#merge-value")
246247
_input.send_keys("Merged")
247248
dash_duo.find_element("#merge-btn").click()
248249

249-
assert get_output()["merged"] == "Merged"
250+
until(lambda: get_output()["merged"] == "Merged", 2)
250251

251-
assert get_output()["delete"] == "Delete me"
252+
until(lambda: get_output()["delete"] == "Delete me", 2)
252253

253254
dash_duo.find_element("#delete-btn").click()
254255

255-
assert get_output().get("delete", undef) is undef
256+
until(lambda: get_output().get("delete", undef) is undef, 2)
256257

257258
_input = dash_duo.find_element("#insert-value")
258259
_input.send_keys("Inserted")
259260
dash_duo.find_element("#insert-btn").click()
260261

261-
assert get_output().get("array") == [
262+
until(lambda: get_output().get("array") == [
262263
"Prepend",
263264
"Inserted",
264265
"initial",
265266
"Append",
266267
"Extend",
267-
]
268+
], 2)
268269

269270
_input.send_keys(" with negative index")
270271
_input = dash_duo.find_element("#insert-index")
271272
_input.send_keys(Keys.BACKSPACE)
272273
_input.send_keys("-1")
273274
dash_duo.find_element("#insert-btn").click()
274275

275-
assert get_output().get("array") == [
276+
until(lambda: get_output().get("array") == [
276277
"Prepend",
277278
"Inserted",
278279
"initial",
279280
"Append",
280281
"Inserted with negative index",
281282
"Extend",
282-
]
283+
], 2)
283284

284285
dash_duo.find_element("#delete-index").click()
285-
assert get_output().get("array") == [
286+
until(lambda: get_output().get("array") == [
286287
"Prepend",
287288
"initial",
288289
"Append",
289290
"Extend",
290-
]
291+
], 2)
291292

292293
dash_duo.find_element("#reverse-btn").click()
293-
assert get_output().get("array") == [
294+
until(lambda: get_output().get("array") == [
294295
"Extend",
295296
"Append",
296297
"initial",
297298
"Prepend",
298-
]
299+
], 2)
299300

300301
dash_duo.find_element("#remove-btn").click()
301-
assert get_output().get("array") == [
302+
until(lambda: get_output().get("array") == [
302303
"Extend",
303304
"Append",
304305
"Prepend",
305-
]
306+
], 2)
306307

307308
dash_duo.find_element("#clear-btn").click()
308-
assert get_output()["array"] == []
309+
until(lambda: get_output()["array"] == [], 2)
309310

310311

311312
def test_pch002_patch_app_pmc_callbacks(dash_duo):

0 commit comments

Comments
 (0)