fyhao / tns-webform-client

MIT License
1 stars 0 forks source link

To test and make sure main flow and events are parallel and not affect each other #69

Closed fyhao closed 7 years ago

fyhao commented 7 years ago

To prepare a flow that:

To test such that the FlowEngine in main flow, and FlowEngine initiated from click event, are running parallel, and not affect each other (by setting some variables, and observe how it is, what in the local vars and global vars)

fyhao commented 7 years ago
array(
        'type' => 'webform',
        'title' => 'Perf Test',
        'webform' => array(
            'heading' => 'someheading',
            'endpoint' => '##',
            'params' => array(
            array('type' => 'button', 'buttons' => array(
                array('name' => 'Test1Btn', 'title' => 'Btn1'),
            )),
            array('type' => 'label', 'name' => '', 'id' => 'log'),
            array('type' => 'label', 'name' => '', 'id' => 'log1'),
            array('type' => 'label', 'name' => '', 'id' => 'log2'),
            )
            ,
            'events' => array(
                'Test1Btn_onclick' => 'Test1Btn_click_flow',
            ),
            'flow' => 'main_flow',
            'flows' => array(
                'Test1Btn_click_flow' => array(
                    'steps' => array(
                        array('type' => 'setVar', 'name' => 'counter', 'value' => 0),
                        array('type' => 'runLoop', 'start' => 0, 'end' => 100, 'flow' => 'LoopWF'),
                        array('type' => 'setHtml', 'name' => 'log', 'value' => 'Value 1 == ##a## and counter = ##counter##'),
                    )
                )
                ,
                'LoopWF' => array(
                    'steps' => array(
                        array('type' => 'setValue', 'name' => 'a', 'value' => '1'),
                        array('type' => 'evaljs', 'var' => 'counter', 'code' => '++vars["counter"]'),
                        array('type' => 'setHtml', 'name' => 'log', 'value' => 'Value 1 == ##a## and counter = ##counter##<br />'),
                    )
                ),
                'main_flow' => array(
                    'steps' => array(
                        array('type' => 'setVar', 'name' => 'counter', 'value' => 0),
                        array('type' => 'runLoop', 'start' => 0, 'end' => 100, 'flow' => 'LoopMainWF'),
                        array('type' => 'setHtml', 'name' => 'log1', 'value' => 'Value 1 == ##a## and counter = ##counter##'),
                    )
                ),
                'LoopMainWF' => array(
                    'steps' => array(
                        array('type' => 'setValue', 'name' => 'a', 'value' => '1'),
                        array('type' => 'evaljs', 'var' => 'counter', 'code' => '++vars["counter"]'),
                        array('type' => 'setHtml', 'name' => 'log1', 'value' => 'Value 1 == ##a## and counter = ##counter##<br />'),
                    )
                )
            ),

        )
    );

This workflow run a flow when loaded, and also a button to trigger a second flow. Both flow running for few seconds with interrupt with each other