|
1 | 1 | import pytest
|
2 | 2 | import re
|
3 | 3 | from selenium.webdriver.common.keys import Keys
|
| 4 | +import json |
4 | 5 |
|
5 | 6 | from dash.testing import wait
|
6 | 7 | import dash
|
|
10 | 11 | from tests.assets.grouping_app import grouping_app
|
11 | 12 |
|
12 | 13 |
|
| 14 | +def stringify_id(id_): |
| 15 | + if isinstance(id_, dict): |
| 16 | + return json.dumps(id_, sort_keys=True, separators=(",", ":")) |
| 17 | + return id_ |
| 18 | + |
| 19 | + |
13 | 20 | def css_escape(s):
|
14 | 21 | sel = re.sub("[\\{\\}\\\"\\'.:,]", lambda m: "\\" + m.group(0), s)
|
15 | 22 | print(sel)
|
@@ -413,14 +420,38 @@ def assert_callback_context(items_text):
|
413 | 420 | args_grouping = dict(
|
414 | 421 | items=dict(
|
415 | 422 | all=[
|
416 |
| - {"id": {"item": i}, "property": "children", "value": text} |
| 423 | + { |
| 424 | + "id": {"item": i}, |
| 425 | + "property": "children", |
| 426 | + "value": text, |
| 427 | + "str_id": stringify_id({"item": i}), |
| 428 | + "triggered": False, |
| 429 | + } |
417 | 430 | for i, text in enumerate(items_text[:-1])
|
418 | 431 | ],
|
419 |
| - new=dict(id="new-item", property="value", value=items_text[-1]), |
| 432 | + new=dict( |
| 433 | + id="new-item", |
| 434 | + property="value", |
| 435 | + value=items_text[-1], |
| 436 | + str_id="new-item", |
| 437 | + triggered=False, |
| 438 | + ), |
420 | 439 | ),
|
421 | 440 | triggers=[
|
422 |
| - {"id": "add", "property": "n_clicks", "value": len(items_text)}, |
423 |
| - {"id": "new-item", "property": "n_submit"}, |
| 441 | + { |
| 442 | + "id": "add", |
| 443 | + "property": "n_clicks", |
| 444 | + "value": len(items_text), |
| 445 | + "str_id": "add", |
| 446 | + "triggered": True, |
| 447 | + }, |
| 448 | + { |
| 449 | + "id": "new-item", |
| 450 | + "property": "n_submit", |
| 451 | + "value": None, |
| 452 | + "str_id": "new-item", |
| 453 | + "triggered": False, |
| 454 | + }, |
424 | 455 | ],
|
425 | 456 | )
|
426 | 457 | dash_duo.wait_for_text_to_equal("#cc-args-grouping", repr(args_grouping))
|
|
0 commit comments