From 44db2c28a354449bf219d01c79fc3cc6830368e3 Mon Sep 17 00:00:00 2001 From: dansu Date: Sat, 17 Jan 2015 10:51:10 +0100 Subject: [PATCH 1/3] added tests for websocket-client cleanup and prettify --- test/nodes/core/io/22-websocket_spec.js | 451 +++++++++++++++++------- 1 file changed, 319 insertions(+), 132 deletions(-) diff --git a/test/nodes/core/io/22-websocket_spec.js b/test/nodes/core/io/22-websocket_spec.js index 4f1da5319..d6643a7a6 100644 --- a/test/nodes/core/io/22-websocket_spec.js +++ b/test/nodes/core/io/22-websocket_spec.js @@ -21,10 +21,15 @@ var helper = require("../../helper.js"); var websocketNode = require("../../../../nodes/core/io/22-websocket.js"); var sockets = []; + +function getWsUrl(path) { + return helper.url().replace(/http/, "ws") + path; +} + function createClient(listenerid) { return when.promise(function(resolve, reject) { var node = helper.getNode(listenerid); - var url = helper.url().replace(/http/, "ws") + node.path; + var url = getWsUrl(node.path); var sock = new ws(url); sockets.push(sock); @@ -39,184 +44,366 @@ function createClient(listenerid) { } function closeAll() { - for(var i=0;i 20) { + helper.clearFlows(); + done(); + } }); - sock.send('{"text":"hello"}'); - }); - }); - }); - - it('should broadcast', function(done) { - var flow = [{id:"n1", type:"websocket-listener", path: "/ws" }, - {id:"n2", server:"n1", type:"websocket out" }, - {id:"n3", type: "helper", wires: [["n2"]]} - ]; - helper.load(websocketNode, flow, function() { - var def1 = when.defer(), def2 = when.defer(); - when.all([createClient("n1"), createClient("n1")]).then(function(socks){ - socks[0].on("message", function(msg, flags) { - msg.should.equal("hello"); - def1.resolve(); - }); - socks[1].on("message", function(msg, flags) { - msg.should.equal("hello"); - def2.resolve(); - }); - var n3 = helper.getNode("n3"); - n3.send({payload:"hello"}); - }); - - when.all([def1.promise, def2.promise]).then(function(){ - done(); }); }); }); From 3f0fcb70a47a8245645058ffff1861bdea0a3424 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sat, 17 Jan 2015 21:02:28 +0000 Subject: [PATCH 2/3] Make subflow delete option more obvious Fixes #514 --- public/index.html | 3 ++- public/red/ui/editor.js | 39 --------------------------------------- public/red/ui/view.js | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 40 deletions(-) diff --git a/public/index.html b/public/index.html index f09db2039..d6c2f463b 100644 --- a/public/index.html +++ b/public/index.html @@ -54,9 +54,10 @@
diff --git a/public/red/ui/editor.js b/public/red/ui/editor.js index 3e30343c2..3e121a968 100644 --- a/public/red/ui/editor.js +++ b/public/red/ui/editor.js @@ -700,45 +700,6 @@ RED.editor = (function() { closeOnEscape: false, width: 500, buttons: [ - { - class: 'leftButton', - text: "Delete", - click: function() { - var removedNodes = []; - var removedLinks = []; - var startDirty = RED.view.dirty(); - - RED.nodes.eachNode(function(n) { - if (n.type == "subflow:"+editing_node.id) { - removedNodes.push(n); - } - if (n.z == editing_node.id) { - removedNodes.push(n); - } - }); - - for (var i=0;i Date: Sat, 17 Jan 2015 21:36:16 +0000 Subject: [PATCH 3/3] Allow node to provide dynamic content to Info tab Closes #492 The node definition can now include an `info` property. This property can be either a string or a Function. Whenever the info tab is refreshed, such as the node is selected, the value of this property, or the result of the Function, will be appended to the Info tab. --- public/red/ui/tab-info.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/red/ui/tab-info.js b/public/red/ui/tab-info.js index 9aa194872..9d5b241d9 100644 --- a/public/red/ui/tab-info.js +++ b/public/red/ui/tab-info.js @@ -94,6 +94,12 @@ RED.sidebar.info = (function() { table += "
"; var helpText = $("script[data-help-name|='"+node.type+"']").html()||""; table += '
'+helpText+"
"; + + if (node._def.info) { + var info = node._def.info; + table += '
'+(typeof info === "function" ? info.call(node) : info)+'
'; + } + $("#tab-info").html(table); }