@gregoriusrippenstein/erlang-red-unittest 0.15.2 → 0.20.0

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 (211) hide show
  1. package/examples/34f859d75b76d03c/flows.json +200 -0
  2. package/{testflows → examples}/6ff45e2a0ce77393/flows.json +11 -29
  3. package/examples/eb24c92ce5621760/flows.json +141 -0
  4. package/{testflows → examples}/f946aafaebb1398d/flows.json +8 -33
  5. package/{testflows → examples}/f94db507552f4934/flows.json +8 -26
  6. package/nodes/locales/en-US/ut-assert-debug.json +4 -1
  7. package/nodes/locales/en-US/ut-assert-status.json +4 -1
  8. package/nodes/ut-assert-debug.html +9 -2
  9. package/nodes/ut-assert-debug.js +55 -33
  10. package/nodes/ut-assert-status.html +34 -20
  11. package/nodes/ut-assert-status.js +60 -29
  12. package/nodes/ut-assert-success.js +1 -0
  13. package/nodes/ut-assert-values.js +1 -13
  14. package/package.json +1 -1
  15. /package/{testflows → examples}/01b074cfa6ae8818/flows.json +0 -0
  16. /package/{testflows → examples}/02b18fc0ed9de178/flows.json +0 -0
  17. /package/{testflows → examples}/0616f795a4aee63e/flows.json +0 -0
  18. /package/{testflows → examples}/069552b2eb6bce48/flows.json +0 -0
  19. /package/{testflows → examples}/08183069b5f8ef9c/flows.json +0 -0
  20. /package/{testflows → examples}/084fb0fc954b7156/flows.json +0 -0
  21. /package/{testflows → examples}/090eb2d5d71fd45f/flows.json +0 -0
  22. /package/{testflows → examples}/09aab59a2455cf15/flows.json +0 -0
  23. /package/{testflows → examples}/0b299a3175fc0df1/flows.json +0 -0
  24. /package/{testflows → examples}/0c35d269ca7178c6/flows.json +0 -0
  25. /package/{testflows → examples}/0cb8971e5f88ed1e/flows.json +0 -0
  26. /package/{testflows → examples}/0cc95e44532c14ec/flows.json +0 -0
  27. /package/{testflows → examples}/0e54563ba63b1501/flows.json +0 -0
  28. /package/{testflows → examples}/12572f9ac11e1786/flows.json +0 -0
  29. /package/{testflows → examples}/1566e453a88578a9/flows.json +0 -0
  30. /package/{testflows → examples}/15c2fad089960984/flows.json +0 -0
  31. /package/{testflows → examples}/1658196c31549916/flows.json +0 -0
  32. /package/{testflows → examples}/16b0bc0cdb0c5807/flows.json +0 -0
  33. /package/{testflows → examples}/16b254125478329a/flows.json +0 -0
  34. /package/{testflows → examples}/182731f54d855071/flows.json +0 -0
  35. /package/{testflows → examples}/1a196bce3e57f5c1/flows.json +0 -0
  36. /package/{testflows → examples}/1ace9e051618db79/flows.json +0 -0
  37. /package/{testflows → examples}/1bac0a78e0a36ec0/flows.json +0 -0
  38. /package/{testflows → examples}/1c1d2cb981cf9f01/flows.json +0 -0
  39. /package/{testflows → examples}/1d3326a724ecbea0/flows.json +0 -0
  40. /package/{testflows → examples}/1db9c9a1b92e0263/flows.json +0 -0
  41. /package/{testflows → examples}/1eb35963b752eca9/flows.json +0 -0
  42. /package/{testflows → examples}/2037454a5ee0d6c3/flows.json +0 -0
  43. /package/{testflows → examples}/20eeaf41372f7b17/flows.json +0 -0
  44. /package/{testflows → examples}/213803d61ecfde3a/flows.json +0 -0
  45. /package/{testflows → examples}/218350f2e240a15d/flows.json +0 -0
  46. /package/{testflows → examples}/24f35eaa8656755f/flows.json +0 -0
  47. /package/{testflows → examples}/27804627fb8f56bd/flows.json +0 -0
  48. /package/{testflows → examples}/2a12af161b544aa1/flows.json +0 -0
  49. /package/{testflows → examples}/2a2c508260b96236/flows.json +0 -0
  50. /package/{testflows → examples}/2a95a7b40a798878/flows.json +0 -0
  51. /package/{testflows → examples}/2c1c291ec8466bfb/flows.json +0 -0
  52. /package/{testflows → examples}/2c59ef974b2523ba/flows.json +0 -0
  53. /package/{testflows → examples}/30465efe017cc9b0/flows.json +0 -0
  54. /package/{testflows → examples}/30c79fc42a5c35eb/flows.json +0 -0
  55. /package/{testflows → examples}/338c5b411f4edfe8/flows.json +0 -0
  56. /package/{testflows → examples}/34d211e37618313c/flows.json +0 -0
  57. /package/{testflows → examples}/36846ad6698e1bc0/flows.json +0 -0
  58. /package/{testflows → examples}/37883612d913fd66/flows.json +0 -0
  59. /package/{testflows → examples}/38616d22e1569aa5/flows.json +0 -0
  60. /package/{testflows → examples}/3be6bc074c7647bd/flows.json +0 -0
  61. /package/{testflows → examples}/3e9e526b992d4c48/flows.json +0 -0
  62. /package/{testflows → examples}/3ea113b4ec3b6e5e/flows.json +0 -0
  63. /package/{testflows → examples}/3ed472eab9503b4f/flows.json +0 -0
  64. /package/{testflows → examples}/3edda6bd788f88c2/flows.json +0 -0
  65. /package/{testflows → examples}/435d3b48dd0f462c/flows.json +0 -0
  66. /package/{testflows → examples}/44f12f6e4a455084/flows.json +0 -0
  67. /package/{testflows → examples}/45209c67f865ce73/flows.json +0 -0
  68. /package/{testflows → examples}/459322e0f8e0b785/flows.json +0 -0
  69. /package/{testflows → examples}/4657dbc0aa4a97bb/flows.json +0 -0
  70. /package/{testflows → examples}/47514a335b4cd67e/flows.json +0 -0
  71. /package/{testflows → examples}/486c1412721bb241/flows.json +0 -0
  72. /package/{testflows → examples}/48d9fdcde317974e/flows.json +0 -0
  73. /package/{testflows → examples}/4de34883c5d93dc3/flows.json +0 -0
  74. /package/{testflows → examples}/50d5679818477b66/flows.json +0 -0
  75. /package/{testflows → examples}/51870a76d1aaf67a/flows.json +0 -0
  76. /package/{testflows → examples}/51bfa9456b1745c0/flows.json +0 -0
  77. /package/{testflows → examples}/538be5947c639b32/flows.json +0 -0
  78. /package/{testflows → examples}/538d2f4704cd2eca/flows.json +0 -0
  79. /package/{testflows → examples}/5433b57035d597f9/flows.json +0 -0
  80. /package/{testflows → examples}/545871d31c3f5f3f/flows.json +0 -0
  81. /package/{testflows → examples}/55f105cfd894b06c/flows.json +0 -0
  82. /package/{testflows → examples}/55f7fbe90e5befa8/flows.json +0 -0
  83. /package/{testflows → examples}/562c518969666f24/flows.json +0 -0
  84. /package/{testflows → examples}/57d44c342a1f00e2/flows.json +0 -0
  85. /package/{testflows → examples}/597ee2a683d9908f/flows.json +0 -0
  86. /package/{testflows → examples}/59aa8a866d8d7a70/flows.json +0 -0
  87. /package/{testflows → examples}/59da63b5adb460db/flows.json +0 -0
  88. /package/{testflows → examples}/5a06352874fa379d/flows.json +0 -0
  89. /package/{testflows → examples}/5cd133958df17529/flows.json +0 -0
  90. /package/{testflows → examples}/5cf6aec7d688fce4/flows.json +0 -0
  91. /package/{testflows → examples}/5d4908af3d4f95e5/flows.json +0 -0
  92. /package/{testflows → examples}/5e07acf2da13b504/flows.json +0 -0
  93. /package/{testflows → examples}/5f6929bb3374b782/flows.json +0 -0
  94. /package/{testflows → examples}/61142eb3e4e54eab/flows.json +0 -0
  95. /package/{testflows → examples}/61847d719e50f83f/flows.json +0 -0
  96. /package/{testflows → examples}/63ca9baf860d1d8f/flows.json +0 -0
  97. /package/{testflows → examples}/641ddaab2819c61d/flows.json +0 -0
  98. /package/{testflows → examples}/64445798b59d2630/flows.json +0 -0
  99. /package/{testflows → examples}/684b9066e98b9722/flows.json +0 -0
  100. /package/{testflows → examples}/698b83b8aeb5d5b6/flows.json +0 -0
  101. /package/{testflows → examples}/6a9ffd45c418497b/flows.json +0 -0
  102. /package/{testflows → examples}/6d46e3fe1f2245b8/flows.json +0 -0
  103. /package/{testflows → examples}/6dd3a5754f83dc2e/flows.json +0 -0
  104. /package/{testflows → examples}/6ea4c6b373eeaa8d/flows.json +0 -0
  105. /package/{testflows → examples}/6f0dcbf18234c5e2/flows.json +0 -0
  106. /package/{testflows → examples}/700c94899fdd3334/flows.json +0 -0
  107. /package/{testflows → examples}/71f65246c742cfc9/flows.json +0 -0
  108. /package/{testflows → examples}/7581c2be261f9c17/flows.json +0 -0
  109. /package/{testflows → examples}/77854a5ea962257b/flows.json +0 -0
  110. /package/{testflows → examples}/7b77600dcf78933f/flows.json +0 -0
  111. /package/{testflows → examples}/7dae2b1a7881c607/flows.json +0 -0
  112. /package/{testflows → examples}/7e1d04570c6bdff9/flows.json +0 -0
  113. /package/{testflows → examples}/7ecfd18f58fc6510/flows.json +0 -0
  114. /package/{testflows → examples}/7fea9696f6186962/flows.json +0 -0
  115. /package/{testflows → examples}/80655e5d4035fa71/flows.json +0 -0
  116. /package/{testflows → examples}/8180ae5891c673de/flows.json +0 -0
  117. /package/{testflows → examples}/8421f37b6c40e1ec/flows.json +0 -0
  118. /package/{testflows → examples}/84a5a362cafe703f/flows.json +0 -0
  119. /package/{testflows → examples}/866410b56fa42447/flows.json +0 -0
  120. /package/{testflows → examples}/894f6e38bfd1aca6/flows.json +0 -0
  121. /package/{testflows → examples}/89aeaeef64509bed/flows.json +0 -0
  122. /package/{testflows → examples}/8a627c9bfe3b4aff/flows.json +0 -0
  123. /package/{testflows → examples}/8bc7412d6a4869c6/flows.json +0 -0
  124. /package/{testflows → examples}/92054e0dd22f14c6/flows.json +0 -0
  125. /package/{testflows → examples}/93c6e969dcf84e70/flows.json +0 -0
  126. /package/{testflows → examples}/9463eba0ab843567/flows.json +0 -0
  127. /package/{testflows → examples}/96f6f83dcab507e5/flows.json +0 -0
  128. /package/{testflows → examples}/9746601768c3b3b6/flows.json +0 -0
  129. /package/{testflows → examples}/987cd33b9cda8529/flows.json +0 -0
  130. /package/{testflows → examples}/988f27b9abdde6e9/flows.json +0 -0
  131. /package/{testflows → examples}/9942fa1aeb1b2428/flows.json +0 -0
  132. /package/{testflows → examples}/9a1bdfdcd7b2be8e/flows.json +0 -0
  133. /package/{testflows → examples}/9b1023c95a2613cc/flows.json +0 -0
  134. /package/{testflows → examples}/9c51a179141515b2/flows.json +0 -0
  135. /package/{testflows → examples}/9d11bfc3a6d88535/flows.json +0 -0
  136. /package/{testflows → examples}/9e7ccc97f80d9afb/flows.json +0 -0
  137. /package/{testflows → examples}/9f0d6c3ad7798a77/flows.json +0 -0
  138. /package/{testflows → examples}/9f7351d7a7304584/flows.json +0 -0
  139. /package/{testflows → examples}/9ff2e8ab21d922c5/flows.json +0 -0
  140. /package/{testflows → examples}/a123cd431f1967cd/flows.json +0 -0
  141. /package/{testflows → examples}/a4c9cabf4b335488/flows.json +0 -0
  142. /package/{testflows → examples}/a6dc7002d0a8640e/flows.json +0 -0
  143. /package/{testflows → examples}/a862ae412a70ded1/flows.json +0 -0
  144. /package/{testflows → examples}/a916165378c446e3/flows.json +0 -0
  145. /package/{testflows → examples}/ad2bf1089481dcfb/flows.json +0 -0
  146. /package/{testflows → examples}/ae38b2dbd23d1681/flows.json +0 -0
  147. /package/{testflows → examples}/ae8a9b0bbbaff447/flows.json +0 -0
  148. /package/{testflows → examples}/b07b511dc8bb8339/flows.json +0 -0
  149. /package/{testflows → examples}/b1430ea37ba7cc19/flows.json +0 -0
  150. /package/{testflows → examples}/b1463d7bbf545725/flows.json +0 -0
  151. /package/{testflows → examples}/b1501de32c769cf2/flows.json +0 -0
  152. /package/{testflows → examples}/b2a67e301fabab0e/flows.json +0 -0
  153. /package/{testflows → examples}/b2fcc5806b2715c0/flows.json +0 -0
  154. /package/{testflows → examples}/b3f365d0b7d1f97d/flows.json +0 -0
  155. /package/{testflows → examples}/b50f775ae3b74d38/flows.json +0 -0
  156. /package/{testflows → examples}/b5fbcdbffb568569/flows.json +0 -0
  157. /package/{testflows → examples}/b6d4e4592b27a344/flows.json +0 -0
  158. /package/{testflows → examples}/b723353a316fa50e/flows.json +0 -0
  159. /package/{testflows → examples}/b7ebaf91f4d66ab3/flows.json +0 -0
  160. /package/{testflows → examples}/b85795a24882502b/flows.json +0 -0
  161. /package/{testflows → examples}/b864b3e3510cd120/flows.json +0 -0
  162. /package/{testflows → examples}/b98d0b05a760ad79/flows.json +0 -0
  163. /package/{testflows → examples}/b9cd19107a5145c4/flows.json +0 -0
  164. /package/{testflows → examples}/bbb1fc2d47c3cd5f/flows.json +0 -0
  165. /package/{testflows → examples}/bdbe94d065f3b3a6/flows.json +0 -0
  166. /package/{testflows → examples}/bfced61e72c69715/flows.json +0 -0
  167. /package/{testflows → examples}/c0b1cf6656eac77f/flows.json +0 -0
  168. /package/{testflows → examples}/c1370220fd37968e/flows.json +0 -0
  169. /package/{testflows → examples}/c163c627bd2a37c7/flows.json +0 -0
  170. /package/{testflows → examples}/c274a07715a87ca4/flows.json +0 -0
  171. /package/{testflows → examples}/c28048d859db3773/flows.json +0 -0
  172. /package/{testflows → examples}/c381b5135cc947cd/flows.json +0 -0
  173. /package/{testflows → examples}/c4690c0a085d6ef5/flows.json +0 -0
  174. /package/{testflows → examples}/c5f513bc380bc30a/flows.json +0 -0
  175. /package/{testflows → examples}/c6ee6e89a51c98fc/flows.json +0 -0
  176. /package/{testflows → examples}/c843dacf753a19d8/flows.json +0 -0
  177. /package/{testflows → examples}/caccb020fce3f485/flows.json +0 -0
  178. /package/{testflows → examples}/cd44a688eb2ab3cf/flows.json +0 -0
  179. /package/{testflows → examples}/ce2f98273da05245/flows.json +0 -0
  180. /package/{testflows → examples}/ced70c769db825eb/flows.json +0 -0
  181. /package/{testflows → examples}/cef9dd7dc179b8b3/flows.json +0 -0
  182. /package/{testflows → examples}/cfa8595b2e2b8269/flows.json +0 -0
  183. /package/{testflows → examples}/cffa610c817beb43/flows.json +0 -0
  184. /package/{testflows → examples}/d17062b01c4a9435/flows.json +0 -0
  185. /package/{testflows → examples}/d17fb2553fe8013a/flows.json +0 -0
  186. /package/{testflows → examples}/d206746f9f2594a6/flows.json +0 -0
  187. /package/{testflows → examples}/d4ce58359ff6ff96/flows.json +0 -0
  188. /package/{testflows → examples}/d5424657b497d5af/flows.json +0 -0
  189. /package/{testflows → examples}/d595c53abba88f72/flows.json +0 -0
  190. /package/{testflows → examples}/d61182e87a604efa/flows.json +0 -0
  191. /package/{testflows → examples}/def45a46c8f4da72/flows.json +0 -0
  192. /package/{testflows → examples}/def56742e02f6a75/flows.json +0 -0
  193. /package/{testflows → examples}/e1ced3b16782f7c8/flows.json +0 -0
  194. /package/{testflows → examples}/e2a801d2b3e2143f/flows.json +0 -0
  195. /package/{testflows → examples}/e7184b7ca4f07907/flows.json +0 -0
  196. /package/{testflows → examples}/ea246f68766c8630/flows.json +0 -0
  197. /package/{testflows → examples}/eb447048178f6e16/flows.json +0 -0
  198. /package/{testflows → examples}/ec921769b3c24fb6/flows.json +0 -0
  199. /package/{testflows → examples}/ed621e03921c13de/flows.json +0 -0
  200. /package/{testflows → examples}/eed68dbcecd1431f/flows.json +0 -0
  201. /package/{testflows → examples}/ef61f644d5436dbe/flows.json +0 -0
  202. /package/{testflows → examples}/f19fdae0c02b4f03/flows.json +0 -0
  203. /package/{testflows → examples}/f1e71f2ccb34fd6e/flows.json +0 -0
  204. /package/{testflows → examples}/f2f61ec9fc46a468/flows.json +0 -0
  205. /package/{testflows → examples}/f346d45c81f595e5/flows.json +0 -0
  206. /package/{testflows → examples}/f38603a59963386c/flows.json +0 -0
  207. /package/{testflows → examples}/f4c4a57e77439a1b/flows.json +0 -0
  208. /package/{testflows → examples}/f5bdafa844f6d280/flows.json +0 -0
  209. /package/{testflows → examples}/f5f82ca50317fda7/flows.json +0 -0
  210. /package/{testflows → examples}/f8727464c799eb22/flows.json +0 -0
  211. /package/{testflows → examples}/fb50bac16667fc54/flows.json +0 -0
@@ -4,42 +4,64 @@ module.exports = function(RED) {
4
4
 
5
5
  var node = this;
6
6
  var cfg = config;
7
+
8
+ var testFailed = (msgstr) => {
9
+ node.status({ fill: "red", shape: "ring", text: RED._("ut-assert-debug.status.failed") });
10
+ RED.comms.publish("unittesting:testresults", { flowid: node.z, status: "failed" })
11
+ // sending a message to the debug panel will faile because the node isn't part
12
+ // of the workspace, hence use `log` instead of `error`.
13
+ node.log(`FAILED [${node.z}] Assert Debug '${msgstr}'`)
14
+ }
7
15
 
8
- node.on('close', function (removed, done) {
9
- if (removed) {
10
- node.status({});
16
+ var testSucceed = () => {
17
+ node.status({ fill: "green", shape: "dot", text: RED._("ut-assert-debug.status.succeed") })
18
+ setTimeout(() => { node.status({}); }, 1000)
19
+ }
20
+
21
+ var handler = (msg) => {
22
+ // msg has to be debug and also originating from the node we've been configured to check
23
+ if (msg.topic != "debug" || cfg.scope.indexOf(msg.data.id) < 0) { return }
24
+
25
+ node.context().set("receivedmsg", true)
26
+
27
+ // set status according to .... settings
28
+ if (cfg.inverse) {
29
+ testFailed("recevied debug message where none was expected")
11
30
  } else {
12
- // use node.log(..) here because node.error(..) sends a message to the debug
13
- // panel but that errors out because the frontend can't find the workspace:
14
- // Uncaught TypeError: can't access property "label", RED.nodes.workspace(...) is undefined
15
- // that has follow-on effects.
16
- node.log(`UNSUPPORTED [${node.z}] debug is not supported`)
31
+ if ( (cfg.msgtype == "warning" && msg.data.level == 30)
32
+ || (cfg.msgtype == "error" && msg.data.level == 20)
33
+ || (cfg.msgtype == "normal" && !msg.data.level) ) {
34
+ testSucceed()
35
+ } else {
36
+ testFailed(`debug message type did not match ${cfg.msgtype} != ${msg.data.level}`)
37
+ }
17
38
  }
18
- done()
19
- });
20
39
 
21
- /* msg handler, in this case pass the message on unchanged */
22
- node.on("input", function(msg, send, done) {
23
- // How to send a status update
24
- node.status({ fill: "green", shape: "ring", text: RED._("ut-assert-debug.label.statusset") });
25
- setTimeout(() => { node.status({}); }, 1000)
26
-
27
- // Send a message and how to handle errors.
28
- try {
29
- try {
30
- send(msg);
31
- done();
32
- } catch ( err ) {
33
- // use node.error if the node might send subsequent messages
34
- node.error("error occurred", { ...msg, error: err })
35
- done();
40
+ node.send(msg)
41
+ }
42
+
43
+ node.context().set("receivedmsg", false)
44
+ require("@node-red/util").events.on('comms', handler)
45
+
46
+ node.on('close', function (removed, done) {
47
+ if (removed) {
48
+ // This node has been disabled/deleted
49
+ let receivedmsg = (node.context().get("receivedmsg") ?? false)
50
+ if (!receivedmsg) {
51
+ if (!cfg.inverse) {
52
+ testFailed("expected debug message but none received")
53
+ } else {
54
+ testSucceed()
55
+ }
36
56
  }
37
- } catch (err) {
38
- // use done if the node won't send anymore messages for the
39
- // message it received.
40
- msg.error = err
41
- done(err.message, msg)
57
+ } else {
58
+ // This node is being restarted
59
+ node.status({})
60
+ node.context().set("receivedmsg", false)
42
61
  }
62
+
63
+ require("@node-red/util").events.off("comms", handler)
64
+ done();
43
65
  });
44
66
  }
45
67
 
@@ -55,7 +77,7 @@ RED.httpAdmin.get("/UnitTesting/:flowid/runtest",
55
77
  // API defined here --> https://github.com/node-red/node-red/blob/master/packages/node_modules/%40node-red/runtime/lib/index.js
56
78
  const runtime = require("@node-red/runtime");
57
79
 
58
- let testDir = path.resolve(path.dirname(__filename), "..", "testflows")
80
+ let testDir = path.resolve(path.dirname(__filename), "..", "examples")
59
81
 
60
82
  // if a test generates an uncaught exception, then captcha that and generate
61
83
  // a failure - tests are considered failed if they generate uncaught exceptions/errors.
@@ -376,7 +398,7 @@ RED.httpAdmin.get("/UnitTesting/:flowid/retrieve",
376
398
  const path = require('path');
377
399
  const fs = require('fs')
378
400
 
379
- let fileName = path.resolve(path.dirname(__filename), "..", "testflows", req.params.flowid, "flows.json")
401
+ let fileName = path.resolve(path.dirname(__filename), "..", "examples", req.params.flowid, "flows.json")
380
402
  const data = fs.readFileSync(fileName);
381
403
 
382
404
  try {
@@ -399,7 +421,7 @@ RED.httpAdmin.get("/UnitTesting/tests.json",
399
421
  const path = require('path');
400
422
  const fs = require('fs')
401
423
 
402
- let testDir = path.resolve(path.dirname(__filename), "..", "testflows")
424
+ let testDir = path.resolve(path.dirname(__filename), "..", "examples")
403
425
 
404
426
  fs.globSync(`${testDir}/**/*.json`).forEach(filename => {
405
427
  let details = path.parse(filename)
@@ -1,14 +1,6 @@
1
1
  <script type="text/javascript">
2
2
  (function(){
3
3
 
4
-
5
- function frontendSupportFunction() {
6
- }
7
-
8
- var functTwo = (arg) => {
9
-
10
- };
11
-
12
4
  RED.nodes.registerType('ut-assert-status',{
13
5
  color: '#C0DEED',
14
6
  icon: "font-awesome/fa-window-minimize",
@@ -18,9 +10,19 @@
18
10
  name: {
19
11
  value:"",
20
12
  },
13
+
14
+ scope: {
15
+ value: null,
16
+ type: "*[]",
17
+ required: true,
18
+ validate: function (v) {
19
+ if (!v) { return false }
20
+ return Array.isArray(v) && v.length > 0
21
+ }
22
+ },
23
+
21
24
  nodeid: {
22
25
  value: "",
23
- required: true
24
26
  },
25
27
  content: {
26
28
  value: "",
@@ -41,26 +43,34 @@
41
43
 
42
44
  inputs: 0,
43
45
 
44
- outputs: 0,
46
+ outputs: 1,
45
47
 
46
48
  label: function() {
47
- if ( this.nodeid && !this.name) {
48
- let nodeLabel = `[${this.nodeid}]`;
49
- let node = RED.nodes.node(this.nodeid)
49
+ if (this.nodeid && (!this.scope || !this.scope[0])) {
50
+ this.scope = [this.nodeid]
51
+ }
52
+
53
+ if (this.scope && this.scope[0] && !this.name) {
54
+ let nodeLabel = `[${this.scope[0]}]`;
55
+ let node = RED.nodes.node(this.scope[0])
50
56
  if (node) {
51
57
  nodeLabel = RED.utils.getNodeLabel(node)
52
58
  }
53
-
54
- if ( this.inverse ) {
55
- return `Assert No Status for ${nodeLabel}`
59
+
60
+ if (this.inverse) {
61
+ return `Assert No Status from ${nodeLabel}`
56
62
  } else {
57
- return `Assert Status for ${nodeLabel}: ${this.colour} ${this.shape}`
63
+ return `Assert Status of ${this.msgtype} for ${nodeLabel}`
58
64
  }
59
65
  } else { return (this.name || this._def.paletteLabel) }
60
66
  },
61
67
 
62
68
  labelStyle: function() {
63
- return (this.name || this.nodeid) ? "node_label_italic" : "";
69
+ if (this.nodeid && (!this.scope || !this.scope[0])) {
70
+ this.scope = [this.nodeid]
71
+ }
72
+
73
+ return (this.name || (this.scope && this.scope[0])) ? "node_label_italic" : "";
64
74
  },
65
75
 
66
76
  onpaletteadd: function() {
@@ -125,7 +135,7 @@
125
135
  nodeid: nde.id,
126
136
  node: nde,
127
137
  sublabel: nde.type,
128
- selected: nde.id == this.nodeid,
138
+ selected: this.scope && this.scope.indexOf(nde.id) > -1,
129
139
  checkbox: false,
130
140
  radio: true,
131
141
  children: undefined
@@ -139,7 +149,11 @@
139
149
  },
140
150
 
141
151
  oneditsave: function() {
142
- this.nodeid = $("#node-input-assert-status-target-container-div").treeList('selected').nodeid;
152
+ if ($("#node-input-assert-status-target-container-div").treeList('selected').nodeid) {
153
+ this.scope = [$("#node-input-assert-status-target-container-div").treeList('selected').nodeid]
154
+ } else {
155
+ this.scope = []
156
+ }
143
157
  },
144
158
 
145
159
  oneditresize: function(size) {
@@ -5,42 +5,73 @@ module.exports = function(RED) {
5
5
  var node = this;
6
6
  var cfg = config;
7
7
 
8
- node.on('close', function(removed, done) {
9
- if ( removed) {
10
- node.status({});
8
+ var testFailed = (msgstr) => {
9
+ node.status({ fill: "red", shape: "ring", text: RED._("ut-assert-status.status.failed") });
10
+ RED.comms.publish("unittesting:testresults", { flowid: node.z, status: "failed" })
11
+ // sending a message to the debug panel will faile because the node isn't part
12
+ // of the workspace, hence use `log` instead of `error`.
13
+ node.log(`FAILED [${node.z}] Assert Status '${msgstr}'`)
14
+ }
15
+
16
+ var testSucceed = () => {
17
+ node.status({ fill: "green", shape: "dot", text: RED._("ut-assert-status.status.succeed") })
18
+ setTimeout(() => { node.status({}); }, 1000)
19
+ }
20
+
21
+ var handler = (msg) => {
22
+ if ((cfg.scope || [cfg.nodeid]).indexOf(msg.id) < 0) { return }
23
+
24
+ // ignore status resets - these are when status is undefined or is empty `{}`
25
+ if (!msg.status || (typeof msg.status == "object" && Object.keys(msg.status).length == 0)) { return }
26
+
27
+ node.context().set("receivedmsg", true)
28
+
29
+ if (cfg.inverse) {
30
+ testFailed("received status where none was expected")
11
31
  } else {
12
- // use node.log(..) here because node.error(..) sends a message to the debug
13
- // panel but that errors out because the frontend can't find the workspace:
14
- // Uncaught TypeError: can't access property "label", RED.nodes.workspace(...) is undefined
15
- // that has follow-on effects.
16
- node.log(`UNSUPPORTED [${node.z}] status is not supported`)
32
+ if ((cfg.colour == msg.status.fill) && (cfg.shape == msg.status.shape) ) {
33
+ if (cfg.content) {
34
+ if (cfg.content == msg.status.text) {
35
+ testSucceed()
36
+ } else {
37
+ testFailed(`content mismatch: '${cfg.content}' != '${msg.status.text}'`)
38
+ }
39
+ } else {
40
+ testSucceed()
41
+ }
42
+ } else {
43
+ testFailed(`shape/colour mismatch: expected ${cfg.colour},${cfg.shape} got ${msg.status.fill},${msg.status.shape}`)
44
+ }
17
45
  }
18
- done()
19
- });
20
46
 
21
- /* msg handler, in this case pass the message on unchanged */
22
- node.on("input", function(msg, send, done) {
23
- // How to send a status update
24
- node.status({ fill: "green", shape: "ring", text: RED._("ut-assert-status.label.statusset") });
25
- setTimeout(() => { node.status({}); }, 1000)
47
+ node.send(msg)
48
+ }
49
+
50
+ node.context().set("receivedmsg", false)
51
+ require("@node-red/util").events.on('node-status', handler)
26
52
 
27
- // Send a message and how to handle errors.
28
- try {
29
- try {
30
- send(msg);
31
- done();
32
- } catch ( err ) {
33
- // use node.error if the node might send subsequent messages
34
- node.error("error occurred", { ...msg, error: err })
35
- done();
53
+ node.on('close', function (removed, done) {
54
+ if (removed) {
55
+ // This node has been disabled/deleted
56
+ let receivedmsg = (node.context().get("receivedmsg") ?? false)
57
+
58
+ if (!receivedmsg) {
59
+ if (!cfg.inverse) {
60
+ testFailed("expected status message but none received")
61
+ } else {
62
+ testSucceed()
63
+ }
36
64
  }
37
- } catch (err) {
38
- // use done if the node won't send anymore messages for the
39
- // message it received.
40
- msg.error = err
41
- done(err.message, msg)
65
+ } else {
66
+ // This node is being restarted
67
+ node.status({})
68
+ node.context().set("receivedmsg", false)
42
69
  }
70
+
71
+ require("@node-red/util").events.off("node-status", handler)
72
+ done();
43
73
  });
74
+
44
75
  }
45
76
 
46
77
  RED.nodes.registerType("ut-assert-status", Coreut_assert_statusFunctionality);
@@ -33,6 +33,7 @@ module.exports = function (RED) {
33
33
  node.log(`FAILED [${node.z}] assert success node failed: ${cfg.count} ${cfg.msglimit} ${node.context().get("msgcnt") || 0}`)
34
34
  }
35
35
  } else {
36
+ // node was restarted
36
37
  node.status({});
37
38
  }
38
39
 
@@ -12,19 +12,6 @@ module.exports = function(RED) {
12
12
  //
13
13
  //
14
14
 
15
-
16
- /*
17
- * Note to self: getMessageProperty(..) and getObjectProperty(...) only differ in that
18
- * getMessageProperty will remove any 'msg.' prefix from the property name. This is not
19
- * the case here since we're using the Node-RED inbuilt helpers for setting values.
20
- * --> here: https://github.com/node-red/node-red/blob/0f653ed7b2640feba8885e48b9448df7d42acaf0/packages/node_modules/%40node-red/util/lib/util.js#L397-L402
21
- *
22
- *
23
- * from --> https://github.com/node-red/node-red/blob/0f653ed7b2640feba8885e48b9448df7d42acaf0/packages/node_modules/%40node-red/util/lib/util.js#L407-L418
24
- *
25
- * getObjectProperty will return undefined if a property isn't set.
26
- */
27
-
28
15
  var sendToDebug = (nde,rule,msgc,lvl) => {
29
16
  try {
30
17
  let msg = {
@@ -102,6 +89,7 @@ module.exports = function(RED) {
102
89
  }
103
90
  }
104
91
  } else {
92
+ // node was restarted
105
93
  node.status({});
106
94
  node.context().set("succeed", false)
107
95
  node.context().set("received_message", false)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gregoriusrippenstein/erlang-red-unittest",
3
- "version": "0.15.2",
3
+ "version": "0.20.0",
4
4
  "dependencies": {
5
5
  },
6
6