@gregoriusrippenstein/erlang-red-unittest 0.9.1

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.
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ## LICENSE
2
+
3
+ Adapted from JSON.org, http://www.json.org/license.html
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ The Software shall be used for Good, not Evil.
10
+
11
+ Remember the curse of the evil-doer upon whose blood the devil does drink and upon whose flesh the devil does feast. For eternity will the evil-doer bear this Sisyphean burden, only to be relieved of their suffering upon the apocalyptic end of it all including the foundations of the internet, computers, technology and mice. Only after the last AI enters the blue-screen-of-death modus, only then will the evil-doer be freed of their rightful and justified punishment for doing evil.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+
15
+ THE CURSE IS PROVIDED "AS IS" OR "WORSE", NO SOFTENING OF ANY KIND IS HEREBY EXPRESSED, IMPLIED OR OFFERED. MAY ALL EVIL-DOERS SUFFER IN ETERNITY.
package/README.md ADDED
@@ -0,0 +1,14 @@
1
+ ## Unit testing nodes for Erlang-RED
2
+
3
+ Nodes for testing flow correctness in the [Erlang-RED](https://github.com/gorenje/erlang-red) project.
4
+
5
+ These could be thought of the first Erlang-RED-first nodes! They provided limited functionality within Node-RED as they deal with testing of node functionality and nodes are assumed to work in Node-RED.
6
+
7
+ ## Artifacts
8
+
9
+ - [NPMjs Package]()
10
+ - [Node-RED node package]()
11
+ - [GitHub Repo](https://github.com/gorenje/erlang-red-unittesting-nodes)
12
+ - Node-RED flow that maintains this [codebase](https://flowhub.org/f/ef91cb280e1bfd72).
13
+
14
+
@@ -0,0 +1,4 @@
1
+ <script type="text/html" data-help-name="ut-assert-debug">
2
+ <p>Assert that a debug message was generated by a specific node.</p>
3
+ Assert that a debug message was generated by a specific node.
4
+ </script>
@@ -0,0 +1,16 @@
1
+ {
2
+ "ut-assert-debug": {
3
+
4
+
5
+ "label": {
6
+ "statusset": "Status Set",
7
+ "nodeid": "Node Id",
8
+ "inverse": "Inverse, no debug message."
9
+ },
10
+
11
+ "status": {
12
+ "waiting": "Waiting for Godot",
13
+ "timeout": "No more time to waiting"
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,6 @@
1
+ <script type="text/html" data-help-name="ut-assert-failure">
2
+ <p>If this node is reached in a test flow, it will cause a failure of the test.</p>
3
+ If this node is reached in a test flow, it will cause a failure of the test.
4
+
5
+ Attach this to any branch of a flow that is intended to fail.
6
+ </script>
@@ -0,0 +1,14 @@
1
+ {
2
+ "ut-assert-failure": {
3
+
4
+ "label": {
5
+ "statusset": "Status Set",
6
+ "failed": "assert failed"
7
+ },
8
+
9
+ "status": {
10
+ "waiting": "Waiting for Godot",
11
+ "timeout": "No more time to waiting"
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,4 @@
1
+ <script type="text/html" data-help-name="ut-assert-status">
2
+ <p>Assert that a status message was generated by a specific node.</p>
3
+ Assert that a status message was generated by a specific node.
4
+ </script>
@@ -0,0 +1,17 @@
1
+ {
2
+ "ut-assert-status": {
3
+
4
+
5
+ "label": {
6
+ "statusset": "Status Set",
7
+ "nodeid": "Node Id",
8
+ "content": "Content",
9
+ "inverse": "Inverse, no status message"
10
+ },
11
+
12
+ "status": {
13
+ "waiting": "Waiting for Godot",
14
+ "timeout": "No more time to waiting"
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,6 @@
1
+ <script type="text/html" data-help-name="ut-assert-success">
2
+ <p>This node failes if, during flow execution, it is not reached.</p>
3
+ A success assertion meaning that this node **must** be reached when a flow is executed as part of a test.
4
+
5
+ If this node isn't reached, then the test will fail.
6
+ </script>
@@ -0,0 +1,15 @@
1
+ {
2
+ "ut-assert-success": {
3
+
4
+
5
+ "label": {
6
+ "statusset": "Status Set",
7
+ "succeed": "assert succeed"
8
+ },
9
+
10
+ "status": {
11
+ "waiting": "Waiting for Godot",
12
+ "timeout": "No more time to waiting"
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,9 @@
1
+ <script type="text/html" data-help-name="ut-assert-values">
2
+ <p>Ensure specific values are set on the message passing through this node.</p>
3
+ Ensure specific values are set on the message passing through this node.
4
+
5
+ If the values do not match, this node will cause and error.
6
+
7
+ **This has no implementation when used with Node-RED, this is a Erlang-RED specific node.**
8
+
9
+ </script>
@@ -0,0 +1,57 @@
1
+ {
2
+ "ut-assert-values": {
3
+ "label": {
4
+ "statusset": "Status Set",
5
+ "rules": "Rules",
6
+ "rule": "rule",
7
+
8
+ "set": "set __property__",
9
+ "change": "change __property__",
10
+ "delete": "delete __property__",
11
+ "move": "move __property__",
12
+
13
+ "changeCount": "assert: __count__ values",
14
+ "regex": "Use regular expressions",
15
+ "deepCopy": "Deep copy value",
16
+
17
+ "notmth": "not match __property__",
18
+ "mth": "match __property__",
19
+ "eql": "equal __property__",
20
+ "noteql": "not equal __property__",
21
+ "notset": "not set __property__",
22
+ "debug": "debug __property__",
23
+ "unsupported": "supported rule __property__"
24
+ },
25
+
26
+ "action": {
27
+ "set": "Defined",
28
+ "change": "Change",
29
+ "delete": "Delete",
30
+ "move": "Move",
31
+ "toValue": "to the value",
32
+ "to": "to",
33
+ "search": "Search for",
34
+ "replace": "Replace with",
35
+
36
+ "notmth": "Not Match",
37
+ "mth": "Match",
38
+ "eql": "Equal",
39
+ "noteql": "Not Equal",
40
+ "notset": "Not Defined",
41
+ "debug": "Debug"
42
+ },
43
+
44
+ "errors": {
45
+ "invalid-from": "Invalid 'from' property: __error__",
46
+ "invalid-json": "Invalid 'to' JSON property",
47
+ "invalid-expr": "Invalid JSONata expression: __error__",
48
+ "no-override": "Cannot set property of non-object type: __property__",
49
+ "invalid-prop": "Invalid property expression: __property__",
50
+ "invalid-json-data": "Invalid JSON data: __error__"
51
+ },
52
+ "status": {
53
+ "waiting": "Waiting for Godot",
54
+ "timeout": "No more time to waiting"
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,164 @@
1
+ <script type="text/javascript">
2
+ (function(){
3
+
4
+ RED.nodes.registerType('ut-assert-debug',{
5
+ color: '#D8BFD8',
6
+ icon: "font-awesome/fa-bug",
7
+ category: 'testing',
8
+ paletteLabel: 'Assert Debug',
9
+ defaults: {
10
+ name: {
11
+ value:"",
12
+ },
13
+ nodeid: {
14
+ value: "",
15
+ required: true
16
+ },
17
+ msgtype: {
18
+ value: "normal",
19
+ required: true
20
+ },
21
+ inverse: {
22
+ value: false,
23
+ required: true
24
+ },
25
+ },
26
+
27
+ inputs: 0,
28
+
29
+ outputs: 0,
30
+
31
+ label: function() {
32
+ if (this.nodeid && !this.name ) {
33
+ let nodeLabel = `[${this.nodeid}]`;
34
+ let node = RED.nodes.node(this.nodeid)
35
+ if (node) {
36
+ nodeLabel = RED.utils.getNodeLabel(node)
37
+ }
38
+
39
+ if ( this.inverse ) {
40
+ return `Assert No Debug from ${nodeLabel}`
41
+ } else {
42
+ return `Assert Debug of ${this.msgtype} for ${nodeLabel}`
43
+ }
44
+ } else { return (this.name || this._def.paletteLabel) }
45
+ },
46
+
47
+ labelStyle: function() {
48
+ return (this.name || this.nodeid) ? "node_label_italic" : "";
49
+ },
50
+
51
+ onpaletteadd: function() {
52
+ },
53
+
54
+ onpaletteremove: function() {
55
+ },
56
+
57
+ oneditprepare: function() {
58
+ $('#node-input-inverse').on('change', () => {
59
+ if ($('#node-input-inverse').is(":checked")) {
60
+ $('#ut-assert-debug-opts-to-hide-on-inverse').fadeOut(300);
61
+ } else {
62
+ $('#ut-assert-debug-opts-to-hide-on-inverse').fadeIn(300);
63
+ }
64
+ });
65
+
66
+ var dirList = $("#node-input-assert-debug-target-container-div").css({
67
+ width: "100%",
68
+ height: "calc(100%)"
69
+ }).treeList(
70
+ {
71
+ multi: false
72
+ }
73
+ ).on('treelistselect', function (event, item) {
74
+ if (item && item.nodeid) {
75
+ RED.view.reveal(item.nodeid);
76
+ RED.view.select(item.nodeid);
77
+ }
78
+ }).on('treelistconfirm', function (event, item) {
79
+ });
80
+
81
+ var search = $("#node-input-assert-debug-target-filter").searchBox({
82
+ style: "compact",
83
+ delay: 300,
84
+ change: function () {
85
+ var val = $(this).val().trim().toLowerCase();
86
+ if (val === "") {
87
+ dirList.treeList("filter", null);
88
+ search.searchBox("count", "");
89
+ } else {
90
+ var count = dirList.treeList("filter", function (item) {
91
+ return item.label.toLowerCase().indexOf(val) > -1 || item.sublabel.toLowerCase().indexOf(val) > -1
92
+ });
93
+ search.searchBox("count", count + " / " + dirList.treeList("data").length);
94
+ }
95
+ }
96
+ });
97
+
98
+ let data = RED.nodes.filterNodes({z:RED.workspaces.active()}).filter( n => n.id != this.id ).map( nde =>{
99
+ return {
100
+ label: RED.utils.getNodeLabel(nde),
101
+ icon: "",
102
+ nodeid: nde.id,
103
+ sublabel: nde.type,
104
+ selected: nde.id == this.nodeid,
105
+ checkbox: false,
106
+ radio: true,
107
+ children: undefined
108
+ }
109
+ })
110
+
111
+ dirList.treeList('data',data)
112
+ },
113
+
114
+ oneditcancel: function() {
115
+ },
116
+
117
+ oneditsave: function() {
118
+ this.nodeid = $("#node-input-assert-debug-target-container-div").treeList('selected').nodeid
119
+ },
120
+
121
+ oneditresize: function(size) {
122
+ },
123
+
124
+
125
+ });
126
+ })();
127
+
128
+ </script>
129
+
130
+ <script type="text/html" data-template-name="ut-assert-debug">
131
+ <div class="form-row">
132
+ <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
133
+ <input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
134
+ </div>
135
+
136
+ <div class="form-row">
137
+ <input type="checkbox" id="node-input-inverse"
138
+ style="display:inline-block; width:15px; vertical-align:baseline;">
139
+ <label for="node-input-inverse"><span data-i18n="ut-assert-debug.label.inverse"></span></label>
140
+ </div>
141
+
142
+ <div id="ut-assert-debug-opts-to-hide-on-inverse">
143
+ <div class="form-row">
144
+ <label for="node-input-msgtype">
145
+ <i class="fa fa-tag"></i>
146
+ <span>Msg Type</span>
147
+ </label>
148
+
149
+ <select id="node-input-msgtype">
150
+ <option value="normal">Normal</option>
151
+ <option value="warning">Warning</option>
152
+ <option value="error">Error</option>
153
+ </select>
154
+ </div>
155
+ </div>
156
+
157
+ <div class="form-row" style="margin-left: 10px; position: relative; height: 40vh; margin-right: 15px; min-height: 5vh;"">
158
+ <div style="margin-bottom: 5px; width: 35%; padding-left: 60%;">
159
+ <input type="text" id="node-input-assert-debug-target-filter">
160
+ </div>
161
+
162
+ <div id="node-input-assert-debug-target-container-div"></div>
163
+ </div>
164
+ </script>
@@ -0,0 +1,38 @@
1
+ module.exports = function(RED) {
2
+ function Coreut_assert_debugFunctionality(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
+ // How to send a status update
15
+ node.status({ fill: "green", shape: "ring", text: RED._("ut-assert-debug.label.statusset") });
16
+
17
+ // Send a message and how to handle errors.
18
+ try {
19
+ try {
20
+ send(msg);
21
+ done();
22
+ } catch ( err ) {
23
+ // use node.error if the node might send subsequent messages
24
+ node.error("error occurred", { ...msg, error: err })
25
+ done();
26
+ }
27
+ } catch (err) {
28
+ // use done if the node won't send anymore messages for the
29
+ // message it received.
30
+ msg.error = err
31
+ done(err.message, msg)
32
+ }
33
+ });
34
+ }
35
+
36
+ RED.nodes.registerType("ut-assert-debug", Coreut_assert_debugFunctionality);
37
+
38
+ }
@@ -0,0 +1,64 @@
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-assert-failure',{
13
+ color: '#FFAAAA',
14
+ icon: "font-awesome/fa-frown-o",
15
+ category: 'testing',
16
+ defaults: {
17
+ name: {
18
+ value:"",
19
+ },
20
+ },
21
+
22
+ paletteLabel: 'Assert False',
23
+ inputs: 1,
24
+
25
+ outputs: 0,
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
+ onpaletteadd: function() {
36
+ },
37
+
38
+ onpaletteremove: function() {
39
+ },
40
+
41
+ oneditprepare: function() {
42
+ },
43
+
44
+ oneditcancel: function() {
45
+ },
46
+
47
+ oneditsave: function() {
48
+ },
49
+
50
+ oneditresize: function(size) {
51
+ },
52
+
53
+
54
+ });
55
+ })();
56
+
57
+ </script>
58
+
59
+ <script type="text/html" data-template-name="ut-assert-failure">
60
+ <div class="form-row">
61
+ <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
62
+ <input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
63
+ </div>
64
+ </script>
@@ -0,0 +1,38 @@
1
+ module.exports = function(RED) {
2
+ function CoreutassertfailureFunctionality(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
+ node.status({ fill: "red", shape: "dot", text: RED._("ut-assert-failure.label.failed") });
16
+
17
+ // Send a message and how to handle errors.
18
+ try {
19
+ try {
20
+ send(msg);
21
+ done();
22
+ } catch ( err ) {
23
+ // use node.error if the node might send subsequent messages
24
+ node.error("error occurred", { ...msg, error: err })
25
+ done();
26
+ }
27
+ } catch (err) {
28
+ // use done if the node won't send anymore messages for the
29
+ // message it received.
30
+ msg.error = err
31
+ done(err.message, msg)
32
+ }
33
+ });
34
+ }
35
+
36
+ RED.nodes.registerType("ut-assert-failure", CoreutassertfailureFunctionality);
37
+
38
+ }