|
4 | 4 | from dash import Dash, Input, Output, State, ClientsideFunction, ALL, html, dcc
|
5 | 5 | from selenium.webdriver.common.keys import Keys
|
6 | 6 |
|
| 7 | +from dash.dependencies import MATCH |
| 8 | + |
7 | 9 |
|
8 | 10 | def test_clsd001_simple_clientside_serverside_callback(dash_duo):
|
9 | 11 | app = Dash(__name__, assets_folder="assets")
|
@@ -905,3 +907,33 @@ def update_output(value):
|
905 | 907 | dash_duo.find_element("#input").send_keys("hello world")
|
906 | 908 | dash_duo.wait_for_text_to_equal("#output-serverside", 'Server says "hello world"')
|
907 | 909 | dash_duo.wait_for_text_to_equal("#output-clientside", 'Client says "hello world"')
|
| 910 | + |
| 911 | + |
| 912 | +def test_clsd022_clientside_pattern_matching_dots(dash_duo): |
| 913 | + # Test for bug https://github.com/plotly/dash/issues/3163 |
| 914 | + # Allow dict id to contains a dot in the dict when using clientside callback. |
| 915 | + app = Dash() |
| 916 | + app.layout = html.Div( |
| 917 | + [ |
| 918 | + html.Button("click", id={"type": "input", "index": 3.1}), |
| 919 | + html.Div(id={"type": "output", "index": 3.1}, className="output"), |
| 920 | + ] |
| 921 | + ) |
| 922 | + |
| 923 | + app.clientside_callback( |
| 924 | + """ |
| 925 | + function(n_clicks) { |
| 926 | + return `clicked ${n_clicks}`; |
| 927 | + } |
| 928 | + """, |
| 929 | + Output({"type": "output", "index": MATCH}, "children"), |
| 930 | + Input({"type": "input", "index": MATCH}, "n_clicks"), |
| 931 | + prevent_initial_call=True, |
| 932 | + ) |
| 933 | + |
| 934 | + dash_duo.start_server(app) |
| 935 | + |
| 936 | + dash_duo.find_element("button").click() |
| 937 | + dash_duo.wait_for_text_to_equal(".output", "clicked 1") |
| 938 | + |
| 939 | + assert dash_duo.get_logs() == [] |
0 commit comments