@@ -651,3 +651,54 @@ def update_output(n1, t1, n2, t2):
651
651
assert timestamp_2 .value > timestamp_1 .value
652
652
assert call_count .value == 4
653
653
dash_duo .percy_snapshot ("button-2 click again" )
654
+
655
+
656
+ def test_cbsc015_input_output_callback (dash_duo ):
657
+ lock = Lock ()
658
+
659
+ app = dash .Dash (__name__ )
660
+ app .layout = html .Div (
661
+ [
662
+ html .Div (id = "input-text" ),
663
+ dcc .Input (id = "input" , type = "number" , value = 0 ),
664
+ ]
665
+ )
666
+
667
+ @app .callback (
668
+ Output ("input" , "value" ),
669
+ Input ("input" , "value" ),
670
+ )
671
+ def circular_output (v ):
672
+ ctx = dash .callback_context
673
+ if not ctx .triggered :
674
+ value = v
675
+ else :
676
+ value = v + 1
677
+ return value
678
+
679
+ call_count = Value ("i" , 0 )
680
+ @app .callback (
681
+ Output ("input-text" , "children" ),
682
+ Input ("input" , "value" ),
683
+ )
684
+ def follower_output (v ):
685
+ with lock :
686
+ call_count .value = call_count .value + 1
687
+ return str (v )
688
+
689
+ dash_duo .start_server (app )
690
+
691
+ wait .until (lambda : dash_duo .find_element ("#input-text" ).text == "0" , 2 )
692
+
693
+ input_ = dash_duo .find_element ("#input" )
694
+ for key in "2" :
695
+ with lock :
696
+ input_ .send_keys (key )
697
+
698
+ wait .until (lambda : dash_duo .find_element ("#input-text" ).text == "3" , 2 )
699
+
700
+ assert call_count .value == 2 , "initial + changed once"
701
+
702
+ assert not dash_duo .redux_state_is_loading
703
+
704
+ assert dash_duo .get_logs () == []
0 commit comments