1
- from dash import Dash , html , dcc , html , Input , Output , State
1
+ from dash import Dash , html , dcc , html , Input , Output , State , MATCH
2
2
from dash_test_components import ExternalComponent
3
3
4
4
@@ -8,7 +8,22 @@ def test_rext001_render_external_component(dash_duo):
8
8
[
9
9
dcc .Input (id = "sync" , value = "synced" ),
10
10
html .Button ("sync" , id = "sync-btn" ),
11
- ExternalComponent ("ext" , input_id = "external" , text = "external" ),
11
+ ExternalComponent (
12
+ id = "ext" ,
13
+ input_id = "external" ,
14
+ text = "external" ,
15
+ extra_component = {
16
+ "type" : "Div" ,
17
+ "namespace" : "dash_html_components" ,
18
+ "props" : {
19
+ "id" : "extra" ,
20
+ "children" : [
21
+ html .Div ("extra children" , id = {"type" : "extra" , "index" : 1 })
22
+ ],
23
+ },
24
+ },
25
+ ),
26
+ html .Div (html .Div (id = {"type" : "output" , "index" : 1 }), id = "out" ),
12
27
]
13
28
)
14
29
@@ -21,7 +36,20 @@ def test_rext001_render_external_component(dash_duo):
21
36
def on_sync (_ , value ):
22
37
return value
23
38
39
+ @app .callback (
40
+ Output ({"type" : "output" , "index" : MATCH }, "children" ),
41
+ Input ({"type" : "extra" , "index" : MATCH }, "n_clicks" ),
42
+ prevent_initial_call = True ,
43
+ )
44
+ def click (* _ ):
45
+ return "clicked"
46
+
24
47
dash_duo .start_server (app )
25
48
dash_duo .wait_for_text_to_equal ("#external" , "external" )
26
49
dash_duo .find_element ("#sync-btn" ).click ()
27
50
dash_duo .wait_for_text_to_equal ("#external" , "synced" )
51
+
52
+ dash_duo .wait_for_text_to_equal ("#extra" , "extra children" )
53
+
54
+ dash_duo .find_element ("#extra > div" ).click ()
55
+ dash_duo .wait_for_text_to_equal ("#out" , "clicked" )
0 commit comments