1
- from dash import Dash , html
1
+ from dash import Dash , html , Input , Output , no_update
2
2
3
3
from dash_test_components import AddPropsComponent , ReceivePropsComponent
4
4
5
5
6
- def test_dvui001_add_receive_props (dash_duo ):
6
+ def test_rdarp001_add_receive_props (dash_duo ):
7
7
app = Dash (__name__ )
8
8
app .layout = html .Div (
9
9
[
@@ -18,14 +18,55 @@ def test_dvui001_add_receive_props(dash_duo):
18
18
id = 'test-receive2' ,
19
19
text = 'receive component2' ,
20
20
),
21
+ html .Button (
22
+ 'load no pass props' ,
23
+ id = 'load-no-pass-props' ,
24
+ ),
25
+ html .Pre ('load-no-pass-props-output' ),
26
+ html .Div (id = 'load-no-pass-props-output' ),
27
+ html .Button (
28
+ 'load pass props' ,
29
+ id = 'load-pass-props' ,
30
+ ),
31
+ html .Pre ('load-pass-props-output' ),
32
+ html .Div (id = 'load-pass-props-output' )
21
33
]
22
34
)
23
35
24
- dash_duo .start_server (
25
- app ,
26
- debug = True ,
27
- use_reloader = False ,
28
- use_debugger = True ,
29
- dev_tools_hot_reload = False ,
30
- dev_tools_props_check = False ,
36
+ @app .callback (
37
+ Output ('load-no-pass-props-output' , 'children' ),
38
+ Input ('load-no-pass-props' , 'n_clicks' ),
39
+ )
40
+ def load_no_pass_props (n_clicks ):
41
+ if n_clicks :
42
+ return ReceivePropsComponent (
43
+ id = 'test-receive-no-pass' ,
44
+ text = 'receive component no pass' ,
45
+ )
46
+ return no_update
47
+
48
+ @app .callback (
49
+ Output ('load-pass-props-output' , 'children' ),
50
+ Input ('load-pass-props' , 'n_clicks' ),
31
51
)
52
+ def load_pass_props (n_clicks ):
53
+ if n_clicks :
54
+ return AddPropsComponent (
55
+ ReceivePropsComponent (
56
+ id = 'test-receive-pass' ,
57
+ text = 'receive component pass' ,
58
+ ),
59
+ id = 'test-add-pass'
60
+ )
61
+ return no_update
62
+
63
+ dash_duo .start_server (app )
64
+ dash_duo .wait_for_text_to_equal ("#test-receive1" , "Element #test-add pass" )
65
+ dash_duo .wait_for_text_to_equal ("#test-receive2" , "receive component2" )
66
+
67
+ clicker_no_pass = dash_duo .wait_for_element ("#load-no-pass-props" )
68
+ clicker_no_pass .click ()
69
+ dash_duo .wait_for_text_to_equal ("#test-receive-no-pass" , "receive component no pass" )
70
+ clicker_pass = dash_duo .wait_for_element ("#load-pass-props" )
71
+ clicker_pass .click ()
72
+ dash_duo .wait_for_text_to_equal ("#test-receive-pass" , "Element #test-add-pass pass" )
0 commit comments