Example flow used in Dashboard 2.0 Cypress E2E tests
Can be used in conjunction with this flow to check the messages being output from a node in Node-RED.
In this flow, our "Store Latest Msg" function node stores the received msg
value into the global context store at global.msg
. Then the Test Helper can be used in Cypress to retrieve this value to check validity of the output.
This flow, for example, provides Cypress with various instances of ui-button
with which it can automate clicking/interaction and check the outputs.
[{"id":"node-red-tab-buttons","type":"tab","label":"UI Buttons","disabled":false,"info":"","env":[]},{"id":"dashboard-ui-base","type":"ui-base","name":"UI Name","path":"/dashboard","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"]},{"id":"dashboard-ui-page-1","type":"ui-page","name":"Page 1","ui":"dashboard-ui-base","path":"/page1","icon":"","layout":"grid","theme":"dashboard-ui-theme","order":-1,"className":"","visible":"true","disabled":false},{"id":"dashboard-ui-theme","type":"ui-theme","name":"Theme Name","colors":{"surface":"#ffffff","primary":"#0094ce","bgPage":"#eeeeee","groupBg":"#ffffff","groupOutline":"#cccccc"}},{"id":"test-helper","type":"function","z":"node-red-tab-buttons","name":"Store Latest Msg","func":"global.set('msg', msg)\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":80,"wires":[[]]},{"id":"dashboard-ui-group","type":"ui-group","name":"Group 1","page":"dashboard-ui-page-1","width":"6","height":"1","order":-1,"showTitle":true,"className":"","visible":"true","disabled":"false"},{"id":"dashboard-ui-button-str","type":"ui-button","z":"node-red-tab-buttons","group":"dashboard-ui-group","name":"","label":"Button 1 (str)","order":0,"width":0,"height":0,"passthru":false,"tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"button 1 clicked","payloadType":"str","topic":"button-str-topic","topicType":"str","x":100,"y":80,"wires":[["test-helper"]]},{"id":"dashboard-ui-button-json","type":"ui-button","z":"node-red-tab-buttons","group":"dashboard-ui-group","name":"","label":"Button 1 (json)","order":0,"width":0,"height":0,"passthru":false,"tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"{\"hello\": \"world\"}","payloadType":"json","topic":"button-json-topic","topicType":"str","x":120,"y":120,"wires":[["test-helper"]]}]