@gregoriusrippenstein/erlang-red-unittest 0.21.0 → 0.21.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/examples/assert values/ignores failures if requested and boolean not-equal test.json +1 -0
  2. package/examples/catch/catch all in group except those handler elsewhere.json +1 -1
  3. package/examples/catch/deal with it yourself.json +1 -1
  4. package/examples/catch/don't catch if the node isn't selected.json +1 -1
  5. package/examples/change/set functionality.json +1 -1
  6. package/examples/complete/split node.json +1 -1
  7. package/examples/debug/Jsonata expressions in output field.json +1 -0
  8. package/examples/debug/ensure debug messages are generated.json +1 -1
  9. package/examples/debug/handle largish json files as content.json +1 -1
  10. package/examples/debug/status message counter.json +1 -1
  11. package/examples/debug/type hadling of JSONata results (ered).json +1 -0
  12. package/examples/debug/type hadling of JSONata results (node-red).json +1 -0
  13. package/examples/delay/respect the reset flag and dont pass on the reset msg.json +1 -0
  14. package/examples/exec/handle multiple process at once (ered).json +1 -0
  15. package/examples/exec/handle multiple process at once (nred).json +1 -0
  16. package/examples/exec/support timeout specification (ered).json +1 -0
  17. package/examples/exec/support timeout specification (nred).json +1 -0
  18. package/examples/exec/synchronised execution (ered).json +1 -0
  19. package/examples/exec/synchronised execution (nred).json +1 -0
  20. package/examples/file in/basic functionality of being able to read a file.json +1 -1
  21. package/examples/file in/will accept file name from msg obj.json +1 -1
  22. package/examples/filter/ignore initial value.json +1 -1
  23. package/examples/filter/post if value changed.json +1 -1
  24. package/examples/flowhubpull/retrieve flow id.json +1 -1
  25. package/examples/function/divide by zero throws kills node.json +1 -1
  26. package/examples/function/ensure /"on stop/" code is executed.json" +1 -1
  27. package/examples/function/function and module work together.json +1 -1
  28. package/examples/function/handle corrupt code.json +1 -1
  29. package/examples/function/set node context.json +1 -1
  30. package/examples/function/support timeout setting.json +1 -1
  31. package/examples/function/supports completed node.json +1 -1
  32. package/examples/http/Dynamic Routing.json +1 -1
  33. package/examples/http/POST & GET have different endpoints.json +1 -1
  34. package/examples/http/dynamic redirect.json +1 -1
  35. package/examples/http/have params in the path.json +1 -1
  36. package/examples/http/http static routing.json +1 -1
  37. package/examples/http/multiple endpoints don't all get the request.json +1 -1
  38. package/examples/http/nodes should be able to handle requests.json +1 -1
  39. package/examples/http/post requests - json content.json +1 -1
  40. package/examples/http/request parses JSON conent.json +1 -1
  41. package/examples/http/set content type.json +1 -1
  42. package/examples/http/support query string on get request.json +1 -1
  43. package/examples/inject/repeat interval.json +1 -1
  44. package/examples/inject/trigger after - does not trigger.json +1 -1
  45. package/examples/inject/unsupported JSONata function.json +1 -1
  46. package/examples/join/manual config with count & nested property name.json +1 -1
  47. package/examples/json/parse example json content.json +1 -1
  48. package/examples/json/raise exception if content not valid.json +1 -1
  49. package/examples/json/support prettify json content.json +1 -1
  50. package/examples/link nodes/across flow tabs.json +1 -1
  51. package/examples/link nodes/cascading link calls.json +1 -1
  52. package/examples/markdown/allow for inline html.json +1 -1
  53. package/examples/markdown/convert markdown to html.json +1 -1
  54. package/examples/markdown/support code block.json +1 -1
  55. package/examples/mqtt/auto-(re)connect.json +1 -1
  56. package/examples/range/basic examples.json +1 -1
  57. package/examples/split/Array type.json +1 -1
  58. package/examples/split/binary type.json +1 -1
  59. package/examples/split/work with binary data as string data (ered).json +1 -0
  60. package/examples/split/work with binary data as string data (nred).json +1 -0
  61. package/examples/statemachine/exception if no action to perform.json +1 -1
  62. package/examples/status/basic working version.json +1 -1
  63. package/examples/status/only one message per status value.json +1 -1
  64. package/examples/switch/JSONata undefined value & exceptions.json +1 -1
  65. package/examples/switch/post debug on JSONata exception.json +1 -1
  66. package/examples/switch/raise exception if JSONata has exception.json +1 -1
  67. package/examples/tcp/Bad value on output port (3425).json +1 -1
  68. package/examples/tcp/multiple tcp in connectors (1194).json +1 -1
  69. package/examples/template/support mustache template (ered).json +1 -0
  70. package/examples/template/support mustache template.json +1 -1
  71. package/nodes/locales/en-US/ut-config.html +25 -0
  72. package/nodes/locales/en-US/ut-config.json +14 -0
  73. package/nodes/ut-assert-debug.js +239 -2
  74. package/nodes/ut-config.html +70 -0
  75. package/nodes/ut-config.js +74 -0
  76. package/package.json +3 -2
  77. package/plugins/sidebar.html +79 -13
  78. package/priv/testdata/helloworld.txt +1 -0
  79. package/priv/testdata/test.json +126 -0
  80. package/examples/.core/assert values ignores failures if requested.json +0 -1
  81. package/examples/debug/handling of Jsonata expressions.json +0 -1
  82. package/examples/debug/type hadling of JSONata reslults (ered).json +0 -1
  83. package/examples/debug/type hadling of JSONata reslults (node-red).json +0 -1
  84. package/examples/exec/handle multiple process at once.json +0 -1
  85. package/examples/exec/support timeout specification.json +0 -1
  86. package/examples/exec/synchronised execution.json +0 -1
  87. package/examples/split/work with binary data as string data.json +0 -1
  88. /package/examples/comment/{what is there to test?.json → what is there to test-.json} +0 -0
@@ -1 +1 @@
1
- [{"id":"069552b2eb6bce48","type":"tab","label":"[tcp] Bad value on output port (3425)","disabled":false,"info":"## gen_tcp:send(...) and numbers\n\nThere is a spot in the [connector code](https://github.com/gorenje/erlang-red/blob/dba90f15888503b4606cb41ac675878d16684841/src/ered_tcp_connector.erl#L39-L50) that highlights a minor issue with `gen_tcp:send/2` and numbers.\n\nThis test uses the connector code but the problem applies equally to the [listener code](https://github.com/gorenje/erlang-red/blob/dba90f15888503b4606cb41ac675878d16684841/src/ered_tcp_listener.erl#L52-L63).\n\nThe problem arises - for me - when using numbers, a single number. In particular it seems to be negative integer values that cause the issue:\n\n```\n08:47:02.788 [error] Bad value on output port 'tcp_inet'\n```\n\n[Stackoverflow](https://stackoverflow.com/questions/38750444/bad-value-on-output-port-tcp-inet) has many suggestions:\n\n> In my phoenix api that I had deployed to heroku. In my case, I was setting response headers with an atom. Once I changed the atom to a binary everything started working fine again.\n\nBut for me it was single numbers that caused the issues, not http headers.\n\nThis flow test demonstrates this. The value -12 will generates the error and the value 12 will not - both are numbers NOT strings.\n\n## What does this test do?\n\nFirst a <a class=\"ahl-node-only\" data-ids=\"7bec330797c929e4\">server on port 3425</a> is started, waiting for connections. Then a <a class=\"ahl-node-only\" data-ids=\"9d73ad81e2ed993c\">tcp request</a> node connects to the server.\n\nWhen it does, it will send the messages that have been sent to it, in this case we have three messages consisting of the value 12 and -12.\n\nThe <a class=\"ahl-node-only\" data-ids=\"6d6da201565de404,46385dd6aa371f45,6b30b8d45824c2ea\">delay nodes</a> ensure that the messages are sent in the order 12, -12 and 12.\n\nThe test is triggered by the <a class=\"ahl-node-only\" data-ids=\"146eaf26868b802c\">inject node</a> which in turn triggers the three messages.\n\nThe <a class=\"ahl-node-only\" data-ids=\"f0e3314691d12a74,046d9545fe9ab505\">join nodes</a> show that only two messages go through, with the third (-12) being lost on the way. This demonstrates that the tcp connection isn't actually closed and continues to function.\n\n## Why is this an issue?\n\nRandom errors are annoying and tracking this one down took a while. However there is nothing that can really be done. Since the value is set by the payload and the payload on a message can be anything, this can happen at any time - day or night.\n\nThe context of the message would be important to know - what is the meaning of a negative integer value being sent over a tcp connection?\n\nSince there isn't a general answer to that question, there isn't much that can be done - generally.\n\nPerhaps raising a debug message in the panel would be the best thing to do at this stage.\n\nAnnoyingly the error generated isn't an exception and cannot be captured, it seems more to be a warning than an error. As pointed out, the tcp connection isn't closed.\n\n","env":[{"name":"ERED_NOT_EUNIT","value":"true","type":"bool"},{"name":"ERED_PENDING","value":"false","type":"bool"}]},{"id":"7bec330797c929e4","type":"tcp request","z":"069552b2eb6bce48","name":"","server":"localhost","port":"3425","out":"time","ret":"string","splitc":"200000","newline":"","trim":false,"tls":"","x":839,"y":507,"wires":[[]]},{"id":"6d6da201565de404","type":"delay","z":"069552b2eb6bce48","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":599,"y":433,"wires":[["7bec330797c929e4"]]},{"id":"46385dd6aa371f45","type":"delay","z":"069552b2eb6bce48","name":"","pauseType":"delay","timeout":"300","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":599,"y":507,"wires":[["7bec330797c929e4"]]},{"id":"6b30b8d45824c2ea","type":"delay","z":"069552b2eb6bce48","name":"","pauseType":"delay","timeout":"600","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":599,"y":590,"wires":[["7bec330797c929e4"]]},{"id":"df1995777960982d","type":"switch","z":"069552b2eb6bce48","name":"only data packets","property":"_session.status","propertyType":"msg","rules":[{"t":"eq","v":"connected","vt":"str"}],"checkall":"false","repair":false,"outputs":1,"x":1077,"y":565,"wires":[["dd3a799aef6166c9"]]},{"id":"508ebb98927e404f","type":"change","z":"069552b2eb6bce48","name":"payload = 12","rules":[{"p":"payload","pt":"msg","t":"set","to":"12","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":398,"y":433,"wires":[["6d6da201565de404"]]},{"id":"53749a8b6ce5c205","type":"change","z":"069552b2eb6bce48","name":"payload = 12","rules":[{"p":"payload","pt":"msg","t":"set","to":"12","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":398,"y":590,"wires":[["6b30b8d45824c2ea"]]},{"id":"25d8b0221cd42ca2","type":"change","z":"069552b2eb6bce48","name":"payload = -12","rules":[{"p":"payload","pt":"msg","t":"set","to":"-12","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":388,"y":507,"wires":[["46385dd6aa371f45"]]},{"id":"146eaf26868b802c","type":"inject","z":"069552b2eb6bce48","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":128,"y":507,"wires":[["508ebb98927e404f","25d8b0221cd42ca2","53749a8b6ce5c205"]]},{"id":"dd3a799aef6166c9","type":"ut-assert-success","z":"069552b2eb6bce48","name":"","count":"2","x":1341,"y":565,"wires":[]},{"id":"9d73ad81e2ed993c","type":"tcp in","z":"069552b2eb6bce48","name":"","server":"server","host":"","port":"3425","datamode":"stream","datatype":"utf8","newline":"","topic":"","trim":false,"base64":false,"tls":"","x":843,"y":607,"wires":[["df1995777960982d"]]}]
1
+ [{"id":"069552b2eb6bce48","type":"tab","label":"[tcp] Bad value on output port (3425)","disabled":false,"info":"## gen_tcp:send(...) and numbers\n\nThere is a spot in the [connector code](https://github.com/gorenje/erlang-red/blob/dba90f15888503b4606cb41ac675878d16684841/src/ered_tcp_connector.erl#L39-L50) that highlights a minor issue with `gen_tcp:send/2` and numbers.\n\nThis test uses the connector code but the problem applies equally to the [listener code](https://github.com/gorenje/erlang-red/blob/dba90f15888503b4606cb41ac675878d16684841/src/ered_tcp_listener.erl#L52-L63).\n\nThe problem arises - for me - when using numbers, a single number. In particular it seems to be negative integer values that cause the issue:\n\n```\n08:47:02.788 [error] Bad value on output port 'tcp_inet'\n```\n\n[Stackoverflow](https://stackoverflow.com/questions/38750444/bad-value-on-output-port-tcp-inet) has many suggestions:\n\n> In my phoenix api that I had deployed to heroku. In my case, I was setting response headers with an atom. Once I changed the atom to a binary everything started working fine again.\n\nBut for me it was single numbers that caused the issues, not http headers.\n\nThis flow test demonstrates this. The value -12 will generates the error and the value 12 will not - both are numbers NOT strings.\n\n## What does this test do?\n\nFirst a <a class=\"ahl-node-only\" data-ids=\"7bec330797c929e4\">server on port 3425</a> is started, waiting for connections. Then a <a class=\"ahl-node-only\" data-ids=\"9d73ad81e2ed993c\">tcp request</a> node connects to the server.\n\nWhen it does, it will send the messages that have been sent to it, in this case we have three messages consisting of the value 12 and -12.\n\nThe <a class=\"ahl-node-only\" data-ids=\"6d6da201565de404,46385dd6aa371f45,6b30b8d45824c2ea\">delay nodes</a> ensure that the messages are sent in the order 12, -12 and 12.\n\nThe test is triggered by the <a class=\"ahl-node-only\" data-ids=\"146eaf26868b802c\">inject node</a> which in turn triggers the three messages.\n\nThe <a class=\"ahl-node-only\" data-ids=\"f0e3314691d12a74,046d9545fe9ab505\">join nodes</a> show that only two messages go through, with the third (-12) being lost on the way. This demonstrates that the tcp connection isn't actually closed and continues to function.\n\n## Why is this an issue?\n\nRandom errors are annoying and tracking this one down took a while. However there is nothing that can really be done. Since the value is set by the payload and the payload on a message can be anything, this can happen at any time - day or night.\n\nThe context of the message would be important to know - what is the meaning of a negative integer value being sent over a tcp connection?\n\nSince there isn't a general answer to that question, there isn't much that can be done - generally.\n\nPerhaps raising a debug message in the panel would be the best thing to do at this stage.\n\nAnnoyingly the error generated isn't an exception and cannot be captured, it seems more to be a warning than an error. As pointed out, the tcp connection isn't closed.\n\n","env":[{"name":"ERED_NOT_EUNIT","value":"true","type":"bool"},{"name":"ERED_PENDING","value":"false","type":"bool"}]},{"id":"7bec330797c929e4","type":"tcp request","z":"069552b2eb6bce48","name":"","server":"localhost","port":"3425","out":"time","ret":"string","splitc":"200000","newline":"","trim":false,"tls":"","x":839,"y":507,"wires":[[]]},{"id":"6d6da201565de404","type":"delay","z":"069552b2eb6bce48","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":599,"y":433,"wires":[["7bec330797c929e4"]]},{"id":"46385dd6aa371f45","type":"delay","z":"069552b2eb6bce48","name":"","pauseType":"delay","timeout":"300","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":599,"y":507,"wires":[["7bec330797c929e4"]]},{"id":"6b30b8d45824c2ea","type":"delay","z":"069552b2eb6bce48","name":"","pauseType":"delay","timeout":"600","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":599,"y":590,"wires":[["7bec330797c929e4"]]},{"id":"df1995777960982d","type":"switch","z":"069552b2eb6bce48","name":"only data packets","property":"_session.status","propertyType":"msg","rules":[{"t":"neq","v":"connected","vt":"str"}],"checkall":"false","repair":false,"outputs":1,"x":1077,"y":565,"wires":[["dd3a799aef6166c9"]]},{"id":"508ebb98927e404f","type":"change","z":"069552b2eb6bce48","name":"payload = 12","rules":[{"p":"payload","pt":"msg","t":"set","to":"12","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":398,"y":433,"wires":[["6d6da201565de404"]]},{"id":"53749a8b6ce5c205","type":"change","z":"069552b2eb6bce48","name":"payload = 12","rules":[{"p":"payload","pt":"msg","t":"set","to":"12","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":398,"y":590,"wires":[["6b30b8d45824c2ea"]]},{"id":"25d8b0221cd42ca2","type":"change","z":"069552b2eb6bce48","name":"payload = -12","rules":[{"p":"payload","pt":"msg","t":"set","to":"-12","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":388,"y":507,"wires":[["46385dd6aa371f45"]]},{"id":"146eaf26868b802c","type":"inject","z":"069552b2eb6bce48","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":128,"y":507,"wires":[["508ebb98927e404f","25d8b0221cd42ca2","53749a8b6ce5c205"]]},{"id":"dd3a799aef6166c9","type":"ut-assert-success","z":"069552b2eb6bce48","name":"","count":"2","x":1341,"y":565,"wires":[]},{"id":"9d73ad81e2ed993c","type":"tcp in","z":"069552b2eb6bce48","name":"","server":"server","host":"","port":"3425","datamode":"stream","datatype":"utf8","newline":"","topic":"","trim":false,"base64":false,"tls":"","x":843,"y":607,"wires":[["df1995777960982d"]]}]
@@ -1 +1 @@
1
- [{"id":"c381b5135cc947cd","type":"tab","label":"[tcp] multiple tcp in connectors (1194)","disabled":false,"info":"## Tcp in connect-to nodes\n\nStarting a tcp service, for example, using netcat `(while date ; do sleep 1 ; done) | nc -lk -p 9393` will cause all three connect to tcp in nodes to receive data.\n\nEach tcp in node will receive the *same* data from the from the host. That is because there is only one connection being maintained. \n\nErlang Red maintains single connections for multiple tcp nodes. Even when multiple tcp in nodes access the same connection, each will receive the same data instead of one connecting to the service and the other nodes not being able to connect.\n\nThis differs to original Node-RED behaviour that will connect a random tcp in node to the service and have it uniquely receive all the data. \n\nNode-RED [forum question](https://discourse.nodered.org/t/tcp-in-nodes-connecting-to-same-host/97975).\n\n\n\n","env":[{"name":"ERED_PENDING","type":"bool","value":"false"},{"name":"ERED_NOT_EUNIT","type":"bool","value":"true"}]},{"id":"564114edd5ba0caf","type":"group","z":"c381b5135cc947cd","style":{"color":"#a4a4a4","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","stroke":"#999999","stroke-opacity":"1"},"nodes":["91ea2827b42734f8","51db6f4e4fabe23e","79a3014b85623de5","8197f5db17d5faa6","6a9c6712d23a8ad9","19b359dc5d9c62d5","29a165c172dd6099","4d2e899d7a424d69","af91f00ddcc05b87"],"x":239,"y":186.875,"w":1285,"h":313.625},{"id":"91ea2827b42734f8","type":"tcp in","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"","server":"server","host":"","port":"1194","datamode":"stream","datatype":"utf8","newline":"","topic":"","trim":true,"base64":false,"tls":"","x":504,"y":343.6875,"wires":[["29a165c172dd6099"]]},{"id":"51db6f4e4fabe23e","type":"tcp in","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"","server":"server","host":"","port":"1194","datamode":"stream","datatype":"utf8","newline":"","topic":"","trim":true,"base64":false,"tls":"","x":685,"y":459.5,"wires":[["19b359dc5d9c62d5"]]},{"id":"eae4f7026d63b109","type":"tcp request","z":"c381b5135cc947cd","name":"","server":"localhost","port":"1194","out":"time","ret":"string","splitc":"3000","newline":"","trim":false,"tls":"","x":1290,"y":579.75,"wires":[[]]},{"id":"dc60341617690980","type":"inject","z":"c381b5135cc947cd","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"\" & $millis()","payloadType":"jsonata","x":919,"y":725,"wires":[["eae4f7026d63b109"]]},{"id":"f85b44b70643d362","type":"inject","z":"c381b5135cc947cd","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"\" & $millis()","payloadType":"jsonata","x":785,"y":688.6875,"wires":[["eae4f7026d63b109"]]},{"id":"a74eb5d8b2fc9c56","type":"inject","z":"c381b5135cc947cd","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"\" & $millis()","payloadType":"jsonata","x":651,"y":652.375,"wires":[["eae4f7026d63b109"]]},{"id":"97e3ad43a22731af","type":"inject","z":"c381b5135cc947cd","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"\" & $millis()","payloadType":"jsonata","x":517,"y":616.0625,"wires":[["eae4f7026d63b109"]]},{"id":"c741b86b0ddfdf7d","type":"inject","z":"c381b5135cc947cd","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"\" & $millis()","payloadType":"jsonata","x":383,"y":579.75,"wires":[["eae4f7026d63b109"]]},{"id":"79a3014b85623de5","type":"ut-assert-success","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"","count":"5","x":1039,"y":227.875,"wires":[]},{"id":"8197f5db17d5faa6","type":"ut-assert-success","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"","count":"5","x":1232,"y":266,"wires":[]},{"id":"6a9c6712d23a8ad9","type":"ut-assert-success","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"","count":"5","x":1418,"y":304,"wires":[]},{"id":"19b359dc5d9c62d5","type":"switch","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"only data packets","property":"_session.status","propertyType":"msg","rules":[{"t":"eq","v":"connected","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":911,"y":304,"wires":[["6a9c6712d23a8ad9"]]},{"id":"29a165c172dd6099","type":"switch","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"only data packets","property":"_session.status","propertyType":"msg","rules":[{"t":"eq","v":"connected","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":842,"y":266,"wires":[["8197f5db17d5faa6"]]},{"id":"4d2e899d7a424d69","type":"switch","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"only data packets","property":"_session.status","propertyType":"msg","rules":[{"t":"eq","v":"connected","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":797,"y":227.875,"wires":[["79a3014b85623de5"]]},{"id":"af91f00ddcc05b87","type":"tcp in","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"","server":"server","host":"","port":"1194","datamode":"stream","datatype":"utf8","newline":"","topic":"","trim":true,"base64":false,"tls":"","x":325,"y":229,"wires":[["4d2e899d7a424d69"]]}]
1
+ [{"id":"c381b5135cc947cd","type":"tab","label":"[tcp] multiple tcp in connectors (1194)","disabled":false,"info":"## Tcp in connect-to nodes\n\nStarting a tcp service, for example, using netcat `(while date ; do sleep 1 ; done) | nc -lk -p 9393` will cause all three connect to tcp in nodes to receive data.\n\nEach tcp in node will receive the *same* data from the from the host. That is because there is only one connection being maintained. \n\nErlang Red maintains single connections for multiple tcp nodes. Even when multiple tcp in nodes access the same connection, each will receive the same data instead of one connecting to the service and the other nodes not being able to connect.\n\nThis differs to original Node-RED behaviour that will connect a random tcp in node to the service and have it uniquely receive all the data. \n\nNode-RED [forum question](https://discourse.nodered.org/t/tcp-in-nodes-connecting-to-same-host/97975).\n\n\n\n","env":[{"name":"ERED_PENDING","value":"false","type":"bool"},{"name":"ERED_NOT_EUNIT","value":"true","type":"bool"},{"name":"NRED_PENDING","value":"true","type":"bool"}]},{"id":"564114edd5ba0caf","type":"group","z":"c381b5135cc947cd","style":{"color":"#a4a4a4","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","stroke":"#999999","stroke-opacity":"1"},"nodes":["91ea2827b42734f8","51db6f4e4fabe23e","79a3014b85623de5","8197f5db17d5faa6","6a9c6712d23a8ad9","19b359dc5d9c62d5","29a165c172dd6099","4d2e899d7a424d69","af91f00ddcc05b87"],"x":239,"y":186.875,"w":1295,"h":313.625},{"id":"91ea2827b42734f8","type":"tcp in","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"","server":"server","host":"","port":"1194","datamode":"stream","datatype":"utf8","newline":"","topic":"","trim":true,"base64":false,"tls":"","x":504,"y":343.6875,"wires":[["29a165c172dd6099"]]},{"id":"51db6f4e4fabe23e","type":"tcp in","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"","server":"server","host":"","port":"1194","datamode":"stream","datatype":"utf8","newline":"","topic":"","trim":true,"base64":false,"tls":"","x":685,"y":459.5,"wires":[["19b359dc5d9c62d5"]]},{"id":"eae4f7026d63b109","type":"tcp request","z":"c381b5135cc947cd","name":"","server":"localhost","port":"1194","out":"time","ret":"string","splitc":"3000","newline":"","trim":false,"tls":"","x":1290,"y":579.75,"wires":[[]]},{"id":"dc60341617690980","type":"inject","z":"c381b5135cc947cd","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"\" & $millis()","payloadType":"jsonata","x":919,"y":725,"wires":[["eae4f7026d63b109"]]},{"id":"f85b44b70643d362","type":"inject","z":"c381b5135cc947cd","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"\" & $millis()","payloadType":"jsonata","x":785,"y":688.6875,"wires":[["eae4f7026d63b109"]]},{"id":"a74eb5d8b2fc9c56","type":"inject","z":"c381b5135cc947cd","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"\" & $millis()","payloadType":"jsonata","x":651,"y":652.375,"wires":[["eae4f7026d63b109"]]},{"id":"97e3ad43a22731af","type":"inject","z":"c381b5135cc947cd","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"\" & $millis()","payloadType":"jsonata","x":517,"y":616.0625,"wires":[["eae4f7026d63b109"]]},{"id":"c741b86b0ddfdf7d","type":"inject","z":"c381b5135cc947cd","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"\" & $millis()","payloadType":"jsonata","x":383,"y":579.75,"wires":[["eae4f7026d63b109"]]},{"id":"79a3014b85623de5","type":"ut-assert-success","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"","count":"5","x":1039,"y":227.875,"wires":[]},{"id":"8197f5db17d5faa6","type":"ut-assert-success","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"","count":"5","x":1232,"y":266,"wires":[]},{"id":"6a9c6712d23a8ad9","type":"ut-assert-success","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"","count":"5","x":1418,"y":304,"wires":[]},{"id":"19b359dc5d9c62d5","type":"switch","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"only data packets","property":"_session.status","propertyType":"msg","rules":[{"t":"neq","v":"connected","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":911,"y":304,"wires":[["6a9c6712d23a8ad9"]]},{"id":"29a165c172dd6099","type":"switch","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"only data packets","property":"_session.status","propertyType":"msg","rules":[{"t":"neq","v":"connected","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":842,"y":266,"wires":[["8197f5db17d5faa6"]]},{"id":"4d2e899d7a424d69","type":"switch","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"only data packets","property":"_session.status","propertyType":"msg","rules":[{"t":"neq","v":"connected","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":797,"y":227.875,"wires":[["79a3014b85623de5"]]},{"id":"af91f00ddcc05b87","type":"tcp in","z":"c381b5135cc947cd","g":"564114edd5ba0caf","name":"","server":"server","host":"","port":"1194","datamode":"stream","datatype":"utf8","newline":"","topic":"","trim":true,"base64":false,"tls":"","x":325,"y":229,"wires":[["4d2e899d7a424d69"]]}]
@@ -0,0 +1 @@
1
+ [{"id":"56a4f6bde709ddae","type":"tab","label":"[template] support mustache template (ered)","disabled":false,"info":"Basic support mustache templating using [bbmustache](https://github.com/soranoba/bbmustache).","env":[{"name":"ERED_ONLY","value":"true","type":"bool"}]},{"id":"670633d166091f80","type":"inject","z":"56a4f6bde709ddae","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<b>hello world</b>","payloadType":"str","x":608,"y":882,"wires":[["a19c63d6c7b0b82c","0e2fcb987cb604d2","6fb4a505fbf513ba"]]},{"id":"a19c63d6c7b0b82c","type":"template","z":"56a4f6bde709ddae","name":"double {{ .. }}","field":"payload","fieldType":"msg","format":"text","syntax":"mustache","template":"This is the payload: {{payload}} !","output":"str","x":866,"y":882,"wires":[["cfeb41c5e62ef3ba"]]},{"id":"cfeb41c5e62ef3ba","type":"ut-assert-values","z":"56a4f6bde709ddae","name":"","ignore_failure_if_succeed":false,"rules":[{"t":"eql","p":"payload","pt":"msg","to":"This is the payload: &lt;b&gt;hello world&lt;/b&gt; !","tot":"str"}],"x":1102,"y":882,"wires":[[]]},{"id":"0e2fcb987cb604d2","type":"template","z":"56a4f6bde709ddae","name":"triple {{{ .. }}}","field":"payload","fieldType":"msg","format":"text","syntax":"mustache","template":"This is the payload: {{{payload}}} !","output":"str","x":866,"y":958,"wires":[["846dc2ca320c8fda"]]},{"id":"846dc2ca320c8fda","type":"ut-assert-values","z":"56a4f6bde709ddae","name":"","ignore_failure_if_succeed":false,"rules":[{"t":"eql","p":"payload","pt":"msg","to":"This is the payload: <b>hello world</b> !","tot":"str"}],"x":1102,"y":1017,"wires":[[]]},{"id":"6fb4a505fbf513ba","type":"template","z":"56a4f6bde709ddae","name":"single { .. }","field":"payload","fieldType":"msg","format":"text","syntax":"mustache","template":"This is the payload: {payload} !","output":"str","x":866,"y":813,"wires":[["cf1f20ec5a8ed119"]]},{"id":"cf1f20ec5a8ed119","type":"ut-assert-values","z":"56a4f6bde709ddae","name":"","ignore_failure_if_succeed":false,"rules":[{"t":"eql","p":"payload","pt":"msg","to":"This is the payload: {payload} !","tot":"str"}],"x":1102,"y":773,"wires":[[]]}]
@@ -1 +1 @@
1
- [{"id":"08183069b5f8ef9c","type":"tab","label":"[template] support mustache template","disabled":false,"info":"Basic support mustache templating using [bbmustache](https://github.com/soranoba/bbmustache).","env":[]},{"id":"bc81e6748b3aeb9c","type":"inject","z":"08183069b5f8ef9c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<b>hello world</b>","payloadType":"str","x":608,"y":882,"wires":[["44c609fe82ebf669","8e84e08b55c84671","f1d52f3c187a674e"]]},{"id":"44c609fe82ebf669","type":"template","z":"08183069b5f8ef9c","name":"double {{ .. }}","field":"payload","fieldType":"msg","format":"text","syntax":"mustache","template":"This is the payload: {{payload}} !","output":"str","x":866,"y":882,"wires":[["781a45ccaa1bf83f"]]},{"id":"781a45ccaa1bf83f","type":"ut-assert-values","z":"08183069b5f8ef9c","name":"","rules":[{"p":"payload","pt":"msg","t":"eql","to":"This is the payload: &lt;b&gt;hello world&lt;/b&gt; !","tot":"str"}],"x":1102,"y":882,"wires":[[]]},{"id":"8e84e08b55c84671","type":"template","z":"08183069b5f8ef9c","name":"triple {{{ .. }}}","field":"payload","fieldType":"msg","format":"text","syntax":"mustache","template":"This is the payload: {{{payload}}} !","output":"str","x":866,"y":958,"wires":[["74f729fd37514cd4"]]},{"id":"74f729fd37514cd4","type":"ut-assert-values","z":"08183069b5f8ef9c","name":"","rules":[{"p":"payload","pt":"msg","t":"eql","to":"This is the payload: <b>hello world</b> !","tot":"str"}],"x":1102,"y":1017,"wires":[[]]},{"id":"f1d52f3c187a674e","type":"template","z":"08183069b5f8ef9c","name":"single { .. }","field":"payload","fieldType":"msg","format":"text","syntax":"mustache","template":"This is the payload: {payload} !","output":"str","x":866,"y":813,"wires":[["cc3819b467390aab"]]},{"id":"cc3819b467390aab","type":"ut-assert-values","z":"08183069b5f8ef9c","name":"","rules":[{"p":"payload","pt":"msg","t":"eql","to":"This is the payload: {payload} !","tot":"str"}],"x":1102,"y":773,"wires":[[]]}]
1
+ [{"id":"08183069b5f8ef9c","type":"tab","label":"[template] support mustache template","disabled":false,"info":"Basic support mustache templating using [bbmustache](https://github.com/soranoba/bbmustache).","env":[{"name":"NODE_RED_ONLY","value":"true","type":"bool"}]},{"id":"bc81e6748b3aeb9c","type":"inject","z":"08183069b5f8ef9c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<b>hello world</b>","payloadType":"str","x":608,"y":882,"wires":[["44c609fe82ebf669","8e84e08b55c84671","f1d52f3c187a674e"]]},{"id":"44c609fe82ebf669","type":"template","z":"08183069b5f8ef9c","name":"double {{ .. }}","field":"payload","fieldType":"msg","format":"text","syntax":"mustache","template":"This is the payload: {{payload}} !","output":"str","x":866,"y":882,"wires":[["781a45ccaa1bf83f"]]},{"id":"781a45ccaa1bf83f","type":"ut-assert-values","z":"08183069b5f8ef9c","name":"","ignore_failure_if_succeed":false,"rules":[{"t":"eql","p":"payload","pt":"msg","to":"This is the payload: &lt;b&gt;hello world&lt;&#x2F;b&gt; !","tot":"str"}],"x":1102,"y":882,"wires":[[]]},{"id":"8e84e08b55c84671","type":"template","z":"08183069b5f8ef9c","name":"triple {{{ .. }}}","field":"payload","fieldType":"msg","format":"text","syntax":"mustache","template":"This is the payload: {{{payload}}} !","output":"str","x":866,"y":958,"wires":[["74f729fd37514cd4"]]},{"id":"74f729fd37514cd4","type":"ut-assert-values","z":"08183069b5f8ef9c","name":"","ignore_failure_if_succeed":false,"rules":[{"t":"eql","p":"payload","pt":"msg","to":"This is the payload: <b>hello world</b> !","tot":"str"}],"x":1102,"y":1017,"wires":[[]]},{"id":"f1d52f3c187a674e","type":"template","z":"08183069b5f8ef9c","name":"single { .. }","field":"payload","fieldType":"msg","format":"text","syntax":"mustache","template":"This is the payload: {payload} !","output":"str","x":866,"y":813,"wires":[["cc3819b467390aab"]]},{"id":"cc3819b467390aab","type":"ut-assert-values","z":"08183069b5f8ef9c","name":"","ignore_failure_if_succeed":false,"rules":[{"t":"eql","p":"payload","pt":"msg","to":"This is the payload: {payload} !","tot":"str"}],"x":1102,"y":773,"wires":[[]]}]
@@ -0,0 +1,25 @@
1
+ <script type="text/markdown" data-help-name="ut-config">
2
+ Configuration details of the unittesting setup
3
+
4
+ ### Inputs
5
+
6
+ : payload (any) : what is expected as payload input.
7
+ : topic (string) : (optional) is a topic expected or handled.
8
+
9
+ ### Outputs
10
+
11
+ : payload (any) : what is returned as payload.
12
+
13
+ ### Description
14
+
15
+ Sets the `utcfg` object with the following values:
16
+ ```
17
+ msg.utcfg = {
18
+ "priv": "", // directory containing test data for the tests
19
+ "host": "" // Node-RED/Erlang-Red server endpoint from within the runtime
20
+ }
21
+ ```
22
+
23
+ <!-- [Markdown documentation details](https://nodered.org/docs/creating-nodes/help-style-guide) -->
24
+
25
+ </script>
@@ -0,0 +1,14 @@
1
+ {
2
+ "ut-config": {
3
+
4
+
5
+ "label": {
6
+ "statusset": "Status Set"
7
+ },
8
+
9
+ "status": {
10
+ "waiting": "Waiting for Godot",
11
+ "timeout": "No more time to waiting"
12
+ }
13
+ }
14
+ }
@@ -68,6 +68,196 @@ module.exports = function(RED) {
68
68
  RED.nodes.registerType("ut-assert-debug", Coreut_assert_debugFunctionality);
69
69
 
70
70
  // Backend endpoints
71
+ RED.httpAdmin.post("/UnitTesting/:flowid/testworkspace",
72
+ RED.auth.needsPermission("flowhub.write"),
73
+ (req, res) => {
74
+ if (req.body) {
75
+
76
+ // API defined here --> https://github.com/node-red/node-red/blob/master/packages/node_modules/%40node-red/runtime/lib/index.js
77
+ const runtime = require("@node-red/runtime");
78
+ const jsonClone = require("rfdc")();
79
+
80
+ // if a test generates an uncaught exception, then captcha that and generate
81
+ // a failure - tests are considered failed if they generate uncaught exceptions/errors.
82
+ let createExtraCatchNode = () => {
83
+ let changeId = runtime.util.generateId()
84
+ let assertId = runtime.util.generateId()
85
+ let debugId = runtime.util.generateId()
86
+
87
+ return [
88
+ {
89
+ "id": runtime.util.generateId(),
90
+ "type": "catch",
91
+ "name": "",
92
+ "scope": null,
93
+ "uncaught": true,
94
+ "wires": [
95
+ [
96
+ changeId
97
+ ]
98
+ ]
99
+ },
100
+ {
101
+ "id": changeId,
102
+ "type": "change",
103
+ "name": "",
104
+ "rules": [
105
+ {
106
+ "t": "set",
107
+ "p": "_unittest_triggered",
108
+ "pt": "msg",
109
+ "to": "true",
110
+ "tot": "bool"
111
+ }
112
+ ],
113
+ "action": "",
114
+ "property": "",
115
+ "from": "",
116
+ "to": "",
117
+ "reg": false,
118
+ "wires": [
119
+ [
120
+ assertId,
121
+ debugId
122
+ ]
123
+ ]
124
+ },
125
+ {
126
+ "id": debugId,
127
+ "type": "debug",
128
+ "name": "",
129
+ "active": true,
130
+ "tosidebar": false,
131
+ "console": true,
132
+ "tostatus": false,
133
+ "complete": "payload",
134
+ "targetType": "msg",
135
+ "statusVal": "",
136
+ "statusType": "auto",
137
+ "wires": []
138
+ },
139
+ {
140
+ "id": assertId,
141
+ "type": "ut-assert-failure",
142
+ "name": "",
143
+ "wires": []
144
+ }
145
+ ]
146
+ }
147
+
148
+ let replacedPrivInFileNames = (flowdetails) => {
149
+ const path = require('path');
150
+ const runtime = require("@node-red/runtime");
151
+
152
+ let getHttpServer = (settings) => {
153
+ var port = settings.serverPort;
154
+ if (port === undefined) {
155
+ port = settings.uiPort;
156
+ }
157
+
158
+ var listenPath = 'http' + (settings.https ? 's' : '') + '://' +
159
+ (settings.uiHost == '::' ? 'localhost' : (settings.uiHost == '0.0.0.0' ? '127.0.0.1' : settings.uiHost)) +
160
+ ':' + port;
161
+
162
+ return listenPath;
163
+ }
164
+
165
+ let privDir = path.resolve(path.dirname(__filename), "..", "priv")
166
+ let httpServer = getHttpServer(runtime._.settings)
167
+
168
+ flowdetails.forEach( obj => {
169
+ if (obj.type == "inject") {
170
+ obj.props.forEach( prp => {
171
+ if (prp.v) prp.v = prp.v.replaceAll(/\${priv}/g, privDir).replaceAll(/\${host}/g, httpServer)
172
+ })
173
+ } else if (obj.type == "file in") {
174
+ if (obj.filenameType == "str" && obj.filename) obj.filename = obj.filename.replaceAll(/\${priv}/g, privDir)
175
+ } else if (obj.type == "http request") {
176
+ if (obj.url) obj.url = obj.url.replaceAll(/\${host}/g, httpServer)
177
+ } else if (obj.type == "change") {
178
+ obj.rules.forEach(prp => {
179
+ if (prp.tot == "str" && prp.to) {
180
+ prp.to = prp.to.replaceAll(/\${host}/g, httpServer).replaceAll(/\${priv}/g, privDir)
181
+ }
182
+ })
183
+ }
184
+ })
185
+
186
+ return flowdetails
187
+ }
188
+
189
+ let isErlangRedOnly = (tabDetails) => {
190
+ return tabDetails.env.filter(d => d.name == "ERED_ONLY")[0]?.value == "true"
191
+ }
192
+
193
+ let isTestPending = (tabDetails) => {
194
+ return tabDetails.env.filter(d => d.name == "NRED_PENDING")[0]?.value == "true"
195
+ }
196
+
197
+ // chunkify an array into chunks of `size` size
198
+ let chunkify = (array, size) => {
199
+ const chunkedArray = [];
200
+ for (let i = 0; i < array.length; i += size) {
201
+ chunkedArray.push(array.slice(i, i + size));
202
+ }
203
+ return chunkedArray;
204
+ }
205
+
206
+ // respond to request with a list of total tests to be done. The frontend then
207
+ // shows a progress indication of success / pending / failure
208
+ let respondWithCount = (res, count) => {
209
+ res.writeHead(200, { 'Content-Type': 'application/json' });
210
+ res.end(JSON.stringify({ status: "ok", todo: count }));
211
+ }
212
+
213
+
214
+ setTimeout( () => {
215
+ let flowDetails = req.body["flowdata"]
216
+
217
+ let origFlowId = flowDetails.filter(d => d.type == "tab")[0].id
218
+ let tabDetails = flowDetails.filter(d => d.type == "tab")[0]
219
+ let injNodesIds = flowDetails.filter(d => d.type == "inject").map(d => d.id)
220
+
221
+ if (isErlangRedOnly(tabDetails)) {
222
+ RED.comms.publish("unittesting:testresults", {
223
+ flowid: origFlowId,
224
+ status: "not-supported"
225
+ })
226
+ return null
227
+ }
228
+
229
+ flowDetails = replacedPrivInFileNames(flowDetails)
230
+
231
+ // add an catch all and trigger a assert false if any exceptions are
232
+ // raised by the test - if there isn't already a catch all node.
233
+ if (flowDetails.filter(d => d.type == "catch").filter(d => d.scope == null).length == 0) {
234
+ flowDetails = flowDetails.concat(createExtraCatchNode())
235
+ }
236
+
237
+
238
+ var newConfig = jsonClone(runtime._.flows.getFlows().flows);
239
+ newConfig = newConfig.concat(flowDetails);
240
+
241
+ runtime._.flows.removeFlow(origFlowId, "root").then(result => {
242
+ runtime._.flows.setFlows(newConfig, null, 'flows', false, null, "root").then((rev) => {
243
+ runtime._.flows.startFlows("full", null, false, true).then(d => {
244
+ setTimeout(() => {
245
+ injNodesIds.forEach(ndeId => {
246
+ RED.nodes.getNode(ndeId)?.receive({ "_unittest_triggered": true })
247
+ })
248
+ }, 200)
249
+ })
250
+ })
251
+ })
252
+ }, 10)
253
+
254
+ res.sendStatus(200);
255
+ } else {
256
+ res.sendStatus(405);
257
+ }
258
+ }
259
+ );
260
+
71
261
  RED.httpAdmin.get("/UnitTesting/:flowid/runtest",
72
262
  (req, res) => {
73
263
  const path = require('path');
@@ -147,6 +337,47 @@ let createExtraCatchNode = () => {
147
337
  ]
148
338
  }
149
339
 
340
+ let replacedPrivInFileNames = (flowdetails) => {
341
+ const path = require('path');
342
+ const runtime = require("@node-red/runtime");
343
+
344
+ let getHttpServer = (settings) => {
345
+ var port = settings.serverPort;
346
+ if (port === undefined) {
347
+ port = settings.uiPort;
348
+ }
349
+
350
+ var listenPath = 'http' + (settings.https ? 's' : '') + '://' +
351
+ (settings.uiHost == '::' ? 'localhost' : (settings.uiHost == '0.0.0.0' ? '127.0.0.1' : settings.uiHost)) +
352
+ ':' + port;
353
+
354
+ return listenPath;
355
+ }
356
+
357
+ let privDir = path.resolve(path.dirname(__filename), "..", "priv")
358
+ let httpServer = getHttpServer(runtime._.settings)
359
+
360
+ flowdetails.forEach( obj => {
361
+ if (obj.type == "inject") {
362
+ obj.props.forEach( prp => {
363
+ if (prp.v) prp.v = prp.v.replaceAll(/\${priv}/g, privDir).replaceAll(/\${host}/g, httpServer)
364
+ })
365
+ } else if (obj.type == "file in") {
366
+ if (obj.filenameType == "str" && obj.filename) obj.filename = obj.filename.replaceAll(/\${priv}/g, privDir)
367
+ } else if (obj.type == "http request") {
368
+ if (obj.url) obj.url = obj.url.replaceAll(/\${host}/g, httpServer)
369
+ } else if (obj.type == "change") {
370
+ obj.rules.forEach(prp => {
371
+ if (prp.tot == "str" && prp.to) {
372
+ prp.to = prp.to.replaceAll(/\${host}/g, httpServer).replaceAll(/\${priv}/g, privDir)
373
+ }
374
+ })
375
+ }
376
+ })
377
+
378
+ return flowdetails
379
+ }
380
+
150
381
  let isErlangRedOnly = (tabDetails) => {
151
382
  return tabDetails.env.filter(d => d.name == "ERED_ONLY")[0]?.value == "true"
152
383
  }
@@ -185,7 +416,9 @@ let respondWithCount = (res, count) => {
185
416
 
186
417
  let allTests = [...a, ...b]
187
418
 
188
- // if a limit (i.e. a list of testFlow ids) is provided, only peform those tests.
419
+ // if a limit (i.e. a list of testFlow ids) is provided, only perform those tests.
420
+ // the limit is defined when a group is tested --> only the flowids in the group
421
+ // are tested.
189
422
  if (req.query.limit) {
190
423
  let testIds = req.query.limit.split(",")
191
424
 
@@ -244,6 +477,8 @@ let respondWithCount = (res, count) => {
244
477
  timeoutValues.push(parseInt(d.value) * 1000)
245
478
  })
246
479
 
480
+ flowDetails = replacedPrivInFileNames(flowDetails)
481
+
247
482
  // add an catch all and trigger a assert false if any exceptions are
248
483
  // raised by the test - if there isn't already a catch all node.
249
484
  if (flowDetails.filter(d => d.type == "catch").filter(d => d.scope == null).length == 0) {
@@ -369,7 +604,9 @@ let respondWithCount = (res, count) => {
369
604
  tabDetails.env.filter(d => d.name == "NRED_TIMEOUT").forEach(d => {
370
605
  timeoutValues.push(parseInt(d.value) * 1000)
371
606
  })
372
-
607
+
608
+ flowDetails = replacedPrivInFileNames(flowDetails)
609
+
373
610
  // add an catch all and trigger a assert false if any exceptions are
374
611
  // raised by the test - if there isn't already a catch all node.
375
612
  if (flowDetails.filter(d => d.type == "catch").filter(d => d.scope == null).length == 0) {
@@ -0,0 +1,70 @@
1
+ <script type="text/javascript">
2
+ (function(){
3
+
4
+
5
+ function frontendSupportFunction() {
6
+ }
7
+
8
+ var functTwo = (arg) => {
9
+
10
+ };
11
+
12
+ RED.nodes.registerType('ut-config',{
13
+ color: '#FDF0C2',
14
+ icon: "font-awesome/fa-th",
15
+ category: 'testing',
16
+ paletteLabel: 'Unittest Config',
17
+ defaults: {
18
+ name: {
19
+ value:"",
20
+ },
21
+ },
22
+
23
+ inputs: 1,
24
+
25
+ outputs: 1,
26
+
27
+ label: function() {
28
+ return (this.name || this._def.paletteLabel);
29
+ },
30
+
31
+ labelStyle: function() {
32
+ return this.name?"node_label_italic":"";
33
+ },
34
+
35
+ // called when node is added to workspace also if copied and pasted.
36
+ // once for each node added to the workspace
37
+ onadd: function() {
38
+ },
39
+
40
+ // called when node added to palette - one time
41
+ onpaletteadd: function() {
42
+ },
43
+
44
+ onpaletteremove: function() {
45
+ },
46
+
47
+ oneditprepare: function() {
48
+ },
49
+
50
+ oneditcancel: function() {
51
+ },
52
+
53
+ oneditsave: function() {
54
+ },
55
+
56
+ oneditresize: function(size) {
57
+ },
58
+
59
+
60
+ });
61
+ })();
62
+
63
+ </script>
64
+
65
+ <script type="text/html" data-template-name="ut-config">
66
+ <div class="form-row">
67
+ <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
68
+ <input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
69
+ </div>
70
+ </script>
@@ -0,0 +1,74 @@
1
+ module.exports = function(RED) {
2
+ function Coreut_configFunctionality(config) {
3
+ RED.nodes.createNode(this,config);
4
+
5
+ var node = this;
6
+ var cfg = config;
7
+
8
+ node.on('close', function() {
9
+ node.status({});
10
+ });
11
+
12
+ /* msg handler, in this case pass the message on unchanged */
13
+ node.on("input", function(msg, send, done) {
14
+
15
+ const path = require('path');
16
+ const runtime = require("@node-red/runtime");
17
+
18
+ let getListenPath = (settings) => {
19
+ var port = settings.serverPort;
20
+ if (port === undefined) {
21
+ port = settings.uiPort;
22
+ }
23
+
24
+ var listenPath = 'http' + (settings.https ? 's' : '') + '://' +
25
+ (settings.uiHost == '::' ? 'localhost' : (settings.uiHost == '0.0.0.0' ? '127.0.0.1' : settings.uiHost)) +
26
+ ':' + port;
27
+ if (settings.httpAdminRoot !== false) {
28
+ listenPath += settings.httpAdminRoot;
29
+ } else if (settings.httpStatic) {
30
+ listenPath += "/";
31
+ }
32
+ return listenPath;
33
+ }
34
+
35
+ let getHttpServer = (settings) => {
36
+ var port = settings.serverPort;
37
+ if (port === undefined) {
38
+ port = settings.uiPort;
39
+ }
40
+
41
+ var listenPath = 'http' + (settings.https ? 's' : '') + '://' +
42
+ (settings.uiHost == '::' ? 'localhost' : (settings.uiHost == '0.0.0.0' ? '127.0.0.1' : settings.uiHost)) +
43
+ ':' + port;
44
+
45
+ return listenPath;
46
+ }
47
+
48
+ // Send a message and how to handle errors.
49
+ try {
50
+ try {
51
+ msg.utcfg = {
52
+ "priv": path.resolve(path.dirname(__filename), "..", "priv"),
53
+ // "editor": getListenPath(runtime._.settings),
54
+ "host": getHttpServer(runtime._.settings)
55
+ }
56
+ send(msg);
57
+ done();
58
+ } catch ( err ) {
59
+ // use node.error if the node might send subsequent messages
60
+ node.error("error occurred", { ...msg, error: err })
61
+ done();
62
+ }
63
+ } catch (err) {
64
+ // use done if the node won't send anymore messages for the
65
+ // message it received.
66
+ msg.error = err
67
+ done(err.message, msg)
68
+ }
69
+ });
70
+ }
71
+
72
+ RED.nodes.registerType("ut-config", Coreut_configFunctionality);
73
+
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gregoriusrippenstein/erlang-red-unittest",
3
- "version": "0.21.0",
3
+ "version": "0.21.7",
4
4
  "dependencies": {
5
5
  },
6
6
 
@@ -32,7 +32,8 @@
32
32
  "ut-assert-values": "nodes/ut-assert-values.js",
33
33
  "ut-assert-success": "nodes/ut-assert-success.js",
34
34
  "ut-assert-status": "nodes/ut-assert-status.js",
35
- "ut-assert-debug": "nodes/ut-assert-debug.js"
35
+ "ut-assert-debug": "nodes/ut-assert-debug.js",
36
+ "ut-config": "nodes/ut-config.js"
36
37
  }
37
38
  },
38
39