1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge branch 'master' into repackage

This commit is contained in:
Nick O'Leary 2018-08-29 09:55:40 +01:00
commit 55d71659f8
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
23 changed files with 165 additions and 177 deletions

View File

@ -40,6 +40,7 @@
"fs-extra": "5.0.0", "fs-extra": "5.0.0",
"fs.notify": "0.0.4", "fs.notify": "0.0.4",
"hash-sum": "1.0.2", "hash-sum": "1.0.2",
"https-proxy-agent": "2.2.1",
"i18next": "11.6.0", "i18next": "11.6.0",
"is-utf8": "0.2.1", "is-utf8": "0.2.1",
"js-yaml": "3.12.0", "js-yaml": "3.12.0",

View File

@ -522,10 +522,18 @@
this.selectLabel.empty(); this.selectLabel.empty();
var image; var image;
if (opt.icon) { if (opt.icon) {
image = new Image(); if (opt.icon.indexOf("<") === 0) {
image.name = opt.icon; $(opt.icon).prependTo(this.selectLabel);
image.src = opt.icon; }
$('<img>',{src:opt.icon,style:"margin-right: 4px;height: 18px;"}).prependTo(this.selectLabel); else if (opt.icon.indexOf("/") !== -1) {
image = new Image();
image.name = opt.icon;
image.src = opt.icon;
$('<img>',{src:opt.icon,style:"margin-right: 4px;height: 18px;"}).prependTo(this.selectLabel);
}
else {
$('<i>',{class:"red-ui-typedInput-icon "+opt.icon}).prependTo(this.selectLabel);
}
} else { } else {
this.selectLabel.text(opt.label); this.selectLabel.text(opt.label);
} }

View File

@ -42,7 +42,7 @@ module.exports = function(RED) {
if (type === 'object') { if (type === 'object') {
type = Buffer.isBuffer(msg)?'Buffer':(util.isArray(msg)?'Array':'Date'); type = Buffer.isBuffer(msg)?'Buffer':(util.isArray(msg)?'Array':'Date');
} }
node.error(RED._("function.error.non-message-returned",{ type: type })) node.error(RED._("function.error.non-message-returned",{ type: type }));
} }
} }
} }
@ -203,9 +203,9 @@ module.exports = function(RED) {
if (util.hasOwnProperty('promisify')) { if (util.hasOwnProperty('promisify')) {
sandbox.setTimeout[util.promisify.custom] = function(after, value) { sandbox.setTimeout[util.promisify.custom] = function(after, value) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
sandbox.setTimeout(function(){ resolve(value) }, after); sandbox.setTimeout(function(){ resolve(value); }, after);
}); });
} };
} }
var context = vm.createContext(sandbox); var context = vm.createContext(sandbox);
try { try {
@ -241,7 +241,6 @@ module.exports = function(RED) {
var line = 0; var line = 0;
var errorMessage; var errorMessage;
var stack = err.stack.split(/\r?\n/);
if (stack.length > 0) { if (stack.length > 0) {
while (line < stack.length && stack[line].indexOf("ReferenceError") !== 0) { while (line < stack.length && stack[line].indexOf("ReferenceError") !== 0) {
line++; line++;
@ -265,13 +264,13 @@ module.exports = function(RED) {
}); });
this.on("close", function() { this.on("close", function() {
while (node.outstandingTimers.length > 0) { while (node.outstandingTimers.length > 0) {
clearTimeout(node.outstandingTimers.pop()) clearTimeout(node.outstandingTimers.pop());
} }
while (node.outstandingIntervals.length > 0) { while (node.outstandingIntervals.length > 0) {
clearInterval(node.outstandingIntervals.pop()) clearInterval(node.outstandingIntervals.pop());
} }
this.status({}); this.status({});
}) });
} catch(err) { } catch(err) {
// eg SyntaxError - which v8 doesn't include line number information // eg SyntaxError - which v8 doesn't include line number information
// so we can't do better than this // so we can't do better than this
@ -280,4 +279,4 @@ module.exports = function(RED) {
} }
RED.nodes.registerType("function",FunctionNode); RED.nodes.registerType("function",FunctionNode);
RED.library.register("functions"); RED.library.register("functions");
} };

View File

@ -19,11 +19,26 @@ module.exports = function(RED) {
var mqtt = require("mqtt"); var mqtt = require("mqtt");
var util = require("util"); var util = require("util");
var isUtf8 = require('is-utf8'); var isUtf8 = require('is-utf8');
var HttpsProxyAgent = require('https-proxy-agent');
var url = require('url');
function matchTopic(ts,t) { function matchTopic(ts,t) {
if (ts == "#") { if (ts == "#") {
return true; return true;
} }
/* The following allows shared subscriptions (as in MQTT v5)
http://docs.oasis-open.org/mqtt/mqtt/v5.0/cs02/mqtt-v5.0-cs02.html#_Toc514345522
4.8.2 describes shares like:
$share/{ShareName}/{filter}
$share is a literal string that marks the Topic Filter as being a Shared Subscription Topic Filter.
{ShareName} is a character string that does not include "/", "+" or "#"
{filter} The remainder of the string has the same syntax and semantics as a Topic Filter in a non-shared subscription. Refer to section 4.7.
*/
else if(ts.startsWith("$share")){
ts = ts.replace(/^\$share\/[^#+/]+\/(.*)/g,"$1");
}
var re = new RegExp("^"+ts.replace(/([\[\]\?\(\)\\\\$\^\*\.|])/g,"\\$1").replace(/\+/g,"[^/]+").replace(/\/#$/,"(\/.*)?")+"$"); var re = new RegExp("^"+ts.replace(/([\[\]\?\(\)\\\\$\^\*\.|])/g,"\\$1").replace(/\+/g,"[^/]+").replace(/\/#$/,"(\/.*)?")+"$");
return re.test(t); return re.test(t);
} }
@ -96,12 +111,29 @@ module.exports = function(RED) {
if (typeof this.cleansession === 'undefined') { if (typeof this.cleansession === 'undefined') {
this.cleansession = true; this.cleansession = true;
} }
var prox;
if (process.env.http_proxy != null) { prox = process.env.http_proxy; }
if (process.env.HTTP_PROXY != null) { prox = process.env.HTTP_PROXY; }
// Create the URL to pass in to the MQTT.js library // Create the URL to pass in to the MQTT.js library
if (this.brokerurl === "") { if (this.brokerurl === "") {
// if the broker may be ws:// or wss:// or even tcp:// // if the broker may be ws:// or wss:// or even tcp://
if (this.broker.indexOf("://") > -1) { if (this.broker.indexOf("://") > -1) {
this.brokerurl = this.broker; this.brokerurl = this.broker;
// Only for ws or wss, check if proxy env var for additional configuration
if (this.brokerurl.indexOf("wss://") > -1 || this.brokerurl.indexOf("ws://") > -1 )
// check if proxy is set in env
if (prox) {
var parsedUrl = url.parse(this.brokerurl);
var proxyOpts = url.parse(prox);
// true for wss
proxyOpts.secureEndpoint = parsedUrl.protocol ? parsedUrl.protocol === 'wss:' : true;
// Set Agent for wsOption in MQTT
var agent = new HttpsProxyAgent(proxyOpts);
this.options.wsOptions = {
agent: agent
}
}
} else { } else {
// construct the std mqtt:// url // construct the std mqtt:// url
if (this.usetls) { if (this.usetls) {
@ -435,4 +467,4 @@ module.exports = function(RED) {
} }
} }
RED.nodes.registerType("mqtt out",MQTTOutNode); RED.nodes.registerType("mqtt out",MQTTOutNode);
}; };

View File

@ -22,6 +22,7 @@
"fs-extra": "5.0.0", "fs-extra": "5.0.0",
"fs.notify": "0.0.4", "fs.notify": "0.0.4",
"hash-sum": "1.0.2", "hash-sum": "1.0.2",
"https-proxy-agent": "2.2.1",
"is-utf8": "0.2.1", "is-utf8": "0.2.1",
"js-yaml": "3.12.0", "js-yaml": "3.12.0",
"media-typer": "0.3.0", "media-typer": "0.3.0",

View File

@ -24,7 +24,7 @@ function injectNode(id) {
util.inherits(injectNode, nodePage); util.inherits(injectNode, nodePage);
var payloadType = { var payloadTypeList = {
"flow": 1, "flow": 1,
"global": 2, "global": 2,
"str": 3, "str": 3,
@ -36,54 +36,43 @@ var payloadType = {
"env": 9, "env": 9,
}; };
var timeType = { var repeatTypeList = {
"none": 1, "none": 1,
"interval": 2, "interval": 2,
"intervalBetweenTimes": 3, "intervalBetweenTimes": 3,
"atASpecificTime": 4, "atASpecificTime": 4,
}; };
var timeType = { injectNode.prototype.setPayload = function(payloadType, payload) {
"none": 1,
"interval": 2,
"intervalBetweenTimes": 3,
"atASpecificTime": 4,
};
var timeType = {
"none": 1,
"interval": 2,
"intervalBetweenTimes": 3,
"atASpecificTime": 4,
};
injectNode.prototype.setPayload = function(type, value) {
// Open a payload type list. // Open a payload type list.
browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-container")]'); browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-container")]');
// Select a payload type. // Select a payload type.
var payloadTypeXPath = '//*[@class="red-ui-typedInput-options"]/a[' + payloadType[type] + ']'; var payloadTypeXPath = '//*[@class="red-ui-typedInput-options"]/a[' + payloadTypeList[payloadType] + ']';
browser.clickWithWait(payloadTypeXPath); browser.clickWithWait(payloadTypeXPath);
if (value) { if (payload) {
// Input a value. // Input a value.
browser.setValue('//*[@class="red-ui-typedInput-input"]/input', value); browser.setValue('//*[@class="red-ui-typedInput-input"]/input', payload);
} }
} }
injectNode.prototype.setTopic = function(value) { injectNode.prototype.setTopic = function(topic) {
browser.setValue('#node-input-topic', value); browser.setValue('#node-input-topic', topic);
} }
injectNode.prototype.setOnce = function(value) { injectNode.prototype.setOnce = function(once) {
browser.clickWithWait('#node-input-once'); var isChecked = browser.isSelected('#node-input-once');
if (isChecked !== once) {
browser.clickWithWait('#node-input-once');
}
} }
injectNode.prototype.setTimeType = function(type) { injectNode.prototype.setRepeat = function(repeatType) {
var timeTypeXPath = '//*[@id="inject-time-type-select"]/option[' + timeType[type] + ']'; var repeatTypeXPath = '//*[@id="inject-time-type-select"]/option[' + repeatTypeList[repeatType] + ']';
browser.clickWithWait(timeTypeXPath); browser.clickWithWait(repeatTypeXPath);
} }
injectNode.prototype.setRepeat = function(sec) { injectNode.prototype.setRepeatInterval = function(repeat) {
browser.setValue('#inject-time-interval-count', sec); browser.setValue('#inject-time-interval-count', repeat);
} }
module.exports = injectNode; module.exports = injectNode;

View File

@ -24,22 +24,20 @@ function debugNode(id) {
util.inherits(debugNode, nodePage); util.inherits(debugNode, nodePage);
var target = { debugNode.prototype.setOutput = function(complete) {
"msg": 1,
"full": 2
};
debugNode.prototype.setTarget = function(type, value) {
// Open a payload type list. // Open a payload type list.
browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-container")]/button'); browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-container")]/button');
// Select a payload type. if (complete !== 'true') {
var xPath = '/html/body/div[11]/a[' + target[type] + ']'; // Select the "msg" type.
browser.clickWithWait(xPath); browser.clickWithWait('/html/body/div[11]/a[1]');
if (value) { // Input the path in msg.
browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-input")]/input'); browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-input")]/input');
browser.keys(['Control', 'a', 'Control']); browser.keys(['Control', 'a', 'Control']);
browser.keys(['Delete']); browser.keys(['Delete']);
browser.setValue('//*[contains(@class, "red-ui-typedInput-input")]/input', value); browser.setValue('//*[contains(@class, "red-ui-typedInput-input")]/input', complete);
} else {
// Select the "complete msg object" type.
browser.clickWithWait('/html/body/div[11]/a[2]');
} }
} }

View File

@ -24,12 +24,17 @@ function functionNode(id) {
util.inherits(functionNode, nodePage); util.inherits(functionNode, nodePage);
functionNode.prototype.setCode = function(value) { functionNode.prototype.setFunction = function(func) {
browser.click('#node-input-func-editor'); browser.click('#node-input-func-editor');
browser.keys(['Control', 'Home', 'Control']); browser.keys(['Control', 'Home', 'Control']);
for (var i=0; i<value.length; i++) { for (var i = 0; i < func.length; i++) {
browser.keys([value.substr(i, 1)]); browser.keys([func.charAt(i)]);
} }
// Delete the unnecessary code that ace editor does the autocompletion.
browser.keys(['Control', 'Shift', 'End', 'Shift', 'Control']);
browser.keys(['Delete']);
// Need to wait until ace editor correctly checks the syntax.
browser.pause(50);
} }
module.exports = functionNode; module.exports = functionNode;

View File

@ -24,29 +24,20 @@ function templateNode(id) {
util.inherits(templateNode, nodePage); util.inherits(templateNode, nodePage);
var syntaxType = { templateNode.prototype.setSyntax = function(syntax) {
"mustache": 1, browser.selectWithWait('#node-input-syntax', syntax);
"plain": 2
};
templateNode.prototype.setSyntax = function(type) {
// Open a method type list.
browser.clickWithWait('#node-input-syntax');
// Select a method type.
var syntaxTypeXPath = '//*[@id="node-input-syntax"]/option[' + syntaxType[type] + ']';
browser.clickWithWait(syntaxTypeXPath);
} }
templateNode.prototype.setFormat = function(type) { templateNode.prototype.setFormat = function(format) {
browser.selectByValue('#node-input-format', type); browser.selectWithWait('#node-input-format', format);
} }
templateNode.prototype.setTemplate = function(value) { templateNode.prototype.setTemplate = function(template) {
browser.click('#node-input-template-editor'); browser.click('#node-input-template-editor');
browser.keys(['Control', 'a', 'Control']); // call twice to release the keys. browser.keys(['Control', 'a', 'Control']); // call twice to release the keys.
// Need to add a character one by one since some words such as 'Control' are treated as a special word. // Need to add a character one by one since some words such as 'Control' are treated as a special word.
for (var i=0; i<value.length; i++) { for (var i = 0; i < template.length; i++) {
browser.keys([value.charAt(i)]); browser.keys([template.charAt(i)]);
} }
browser.keys(['Control', 'Shift', 'End', 'Shift', 'Control']); browser.keys(['Control', 'Shift', 'End', 'Shift', 'Control']);
browser.keys(['Delete']); browser.keys(['Delete']);

View File

@ -22,30 +22,14 @@ function httpinNode(id) {
nodePage.call(this, id); nodePage.call(this, id);
} }
function setMethod(type) {
browser.selectByValue('#node-input-method', type);
}
util.inherits(httpinNode, nodePage); util.inherits(httpinNode, nodePage);
var methodType = { httpinNode.prototype.setMethod = function(method) {
"get": 1, browser.selectWithWait('#node-input-method', method);
"post": 2,
"put": 3,
"delete": 4,
"patch": 5,
};
httpinNode.prototype.setMethod = function(type) {
// Open a method type list.
browser.clickWithWait('#node-input-method');
// Select a method type.
var methodTypeXPath = '//*[@id="node-input-method"]/option[' + methodType[type] + ']';
browser.clickWithWait(methodTypeXPath);
} }
httpinNode.prototype.setUrl = function(value) { httpinNode.prototype.setUrl = function(url) {
browser.setValue('#node-input-url', value); browser.setValue('#node-input-url', url);
} }
module.exports = httpinNode; module.exports = httpinNode;

View File

@ -24,36 +24,16 @@ function httpRequestNode(id) {
util.inherits(httpRequestNode, nodePage); util.inherits(httpRequestNode, nodePage);
var methodType = { httpRequestNode.prototype.setUrl = function(url) {
"get": 1, browser.setValue('#node-input-url', url);
"post": 2,
"put": 3,
"delete": 4,
"setByMsgMethod": 5,
};
var retType = {
"txt": 1,
"bin": 2,
"obj": 3,
};
httpRequestNode.prototype.setUrl = function(value) {
browser.setValue('#node-input-url', value);
} }
httpRequestNode.prototype.setMethod = function(type) { httpRequestNode.prototype.setMethod = function(method) {
// Open a method type list. browser.selectWithWait('#node-input-method', method);
browser.clickWithWait('#node-input-method');
// Select a method type.
var methodTypeXPath = '//*[@id="node-input-method"]/option[' + methodType[type] + ']';
browser.clickWithWait(methodTypeXPath);
} }
httpRequestNode.prototype.setRet = function(type) { httpRequestNode.prototype.setReturn = function(ret) {
browser.clickWithWait('#node-input-ret'); browser.selectWithWait('#node-input-ret', ret);
var retTypeXPath = '//*[@id="node-input-ret"]/option[' + retType[type] + ']';
browser.clickWithWait(retTypeXPath);
} }
module.exports = httpRequestNode; module.exports = httpRequestNode;

View File

@ -24,13 +24,6 @@ function changeNode(id) {
util.inherits(changeNode, nodePage); util.inherits(changeNode, nodePage);
var tType = {
"set": 1,
"change": 2,
"delete": 3,
"move": 4,
};
var totType = { var totType = {
"msg": 1, "msg": 1,
"flow": 2, "flow": 2,
@ -42,6 +35,7 @@ var totType = {
"bin": 8, "bin": 8,
"date": 9, "date": 9,
"jsonata": 10, "jsonata": 10,
"env": 11,
}; };
var ptType = { var ptType = {
@ -50,8 +44,8 @@ var ptType = {
"global": 3, "global": 3,
}; };
function setT(rule, index) { function setT(t, index) {
browser.selectByValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/select', rule); browser.selectWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/select', t);
} }
// It is better to create a function whose input value is the object type in the future, // It is better to create a function whose input value is the object type in the future,

View File

@ -24,8 +24,8 @@ function rangeNode(id) {
util.inherits(rangeNode, nodePage); util.inherits(rangeNode, nodePage);
rangeNode.prototype.setAction = function(value) { rangeNode.prototype.setAction = function(action) {
browser.selectByValue('#node-input-action', value); browser.selectWithWait('#node-input-action', action);
} }
rangeNode.prototype.setRange = function(minin, maxin, minout, maxout) { rangeNode.prototype.setRange = function(minin, maxin, minout, maxout) {

View File

@ -24,8 +24,8 @@ function htmlNode(id) {
util.inherits(htmlNode, nodePage); util.inherits(htmlNode, nodePage);
htmlNode.prototype.setTag = function(value) { htmlNode.prototype.setSelector = function(tag) {
browser.setValue('#node-input-tag', value); browser.setValue('#node-input-tag', tag);
} }
module.exports = htmlNode; module.exports = htmlNode;

View File

@ -31,13 +31,13 @@ var formatType = {
"stream": 4 "stream": 4
}; };
fileinNode.prototype.setFilename = function(value) { fileinNode.prototype.setFilename = function(filename) {
browser.setValue('#node-input-filename', value); browser.setValue('#node-input-filename', filename);
} }
fileinNode.prototype.setFormat = function(type) { fileinNode.prototype.setOutput = function(format) {
browser.clickWithWait('#node-input-format'); browser.clickWithWait('#node-input-format');
var formatTypeXPath = '//*[@id="node-input-format"]/option[' + formatType[type] + ']'; var formatTypeXPath = '//*[@id="node-input-format"]/option[' + formatType[format] + ']';
browser.clickWithWait(formatTypeXPath); browser.clickWithWait(formatTypeXPath);
} }

View File

@ -38,6 +38,12 @@ function init() {
var ret = browser.getText(selector); var ret = browser.getText(selector);
return ret; return ret;
}, false); }, false);
browser.addCommand("selectWithWait", function(selector, value) {
browser.waitForVisible(selector, 5000);
var ret = browser.selectByValue(selector, value);
return ret;
}, false);
} }
module.exports = { module.exports = {

View File

@ -19,8 +19,8 @@ var should = require("should");
var fs = require('fs-extra'); var fs = require('fs-extra');
var helper = require("../../editor_helper"); var helper = require("../../editor_helper");
var debugTab = require('../../pageobjects/workspace/debugTab_page'); var debugTab = require('../../pageobjects/editor/debugTab_page');
var workspace = require('../../pageobjects/workspace/workspace_page'); var workspace = require('../../pageobjects/editor/workspace_page');
var nodeWidth = 200; var nodeWidth = 200;

View File

@ -17,8 +17,8 @@
var should = require("should"); var should = require("should");
var helper = require("../../editor_helper"); var helper = require("../../editor_helper");
var debugTab = require('../../pageobjects/workspace/debugTab_page'); var debugTab = require('../../pageobjects/editor/debugTab_page');
var workspace = require('../../pageobjects/workspace/workspace_page'); var workspace = require('../../pageobjects/editor/workspace_page');
var nodeWidth = 200; var nodeWidth = 200;
var nodeHeight = 100; var nodeHeight = 100;
@ -65,7 +65,7 @@ describe('cookbook', function() {
httpRequestNode.edit(); httpRequestNode.edit();
httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello'); httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello');
httpRequestNode.setMethod("get"); httpRequestNode.setMethod("GET");
httpRequestNode.clickOk(); httpRequestNode.clickOk();
injectNode.connect(httpRequestNode); injectNode.connect(httpRequestNode);
@ -105,7 +105,7 @@ describe('cookbook', function() {
httpRequestNode.edit(); httpRequestNode.edit();
httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-query?name=Nick'); httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-query?name=Nick');
httpRequestNode.setMethod("get"); httpRequestNode.setMethod("GET");
httpRequestNode.clickOk(); httpRequestNode.clickOk();
injectNode.connect(httpRequestNode); injectNode.connect(httpRequestNode);
@ -145,7 +145,7 @@ describe('cookbook', function() {
httpRequestNode.edit(); httpRequestNode.edit();
httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-param/Dave'); httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-param/Dave');
httpRequestNode.setMethod("get"); httpRequestNode.setMethod("GET");
httpRequestNode.clickOk(); httpRequestNode.clickOk();
injectNode.connect(httpRequestNode); injectNode.connect(httpRequestNode);
@ -185,12 +185,12 @@ describe('cookbook', function() {
var debugNode = workspace.addNode("debug", nodeWidth * 3, nodeHeight); var debugNode = workspace.addNode("debug", nodeWidth * 3, nodeHeight);
changeNode.edit(); changeNode.edit();
changeNode.ruleSet("headers", "msg", "{\"user-agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64)\"}", "json"); changeNode.ruleSet("headers", "msg", '{"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)"}', "json");
changeNode.clickOk(); changeNode.clickOk();
httpRequestNode.edit(); httpRequestNode.edit();
httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-headers'); httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-headers');
httpRequestNode.setMethod("get"); httpRequestNode.setMethod("GET");
httpRequestNode.clickOk(); httpRequestNode.clickOk();
injectNode.connect(changeNode); injectNode.connect(changeNode);
@ -249,7 +249,7 @@ describe('cookbook', function() {
var debugNode = workspace.addNode("debug", nodeWidth * 2, nodeHeight * 2); var debugNode = workspace.addNode("debug", nodeWidth * 2, nodeHeight * 2);
httpRequestNode.edit(); httpRequestNode.edit();
httpRequestNode.setMethod("get"); httpRequestNode.setMethod("GET");
httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-data'); httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-data');
httpRequestNode.clickOk(); httpRequestNode.clickOk();
@ -280,7 +280,7 @@ describe('cookbook', function() {
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
templateNode.setFormat("handlebars"); templateNode.setFormat("handlebars");
templateNode.setTemplate("{ \"Hello\": \"World\" }"); templateNode.setTemplate('{ "Hello": "World" }');
templateNode.clickOk(); templateNode.clickOk();
changeNode.edit(); changeNode.edit();
@ -299,12 +299,12 @@ describe('cookbook', function() {
var debugNode = workspace.addNode("debug", nodeWidth * 2, nodeHeight); var debugNode = workspace.addNode("debug", nodeWidth * 2, nodeHeight);
httpRequestNode.edit(); httpRequestNode.edit();
httpRequestNode.setMethod("get"); httpRequestNode.setMethod("GET");
httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-json'); httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-json');
httpRequestNode.clickOk(); httpRequestNode.clickOk();
debugNode.edit(); debugNode.edit();
debugNode.setTarget("msg", "headers"); debugNode.setOutput("headers");
debugNode.clickOk(); debugNode.clickOk();
injectNode.connect(httpRequestNode); injectNode.connect(httpRequestNode);
@ -332,7 +332,7 @@ describe('cookbook', function() {
fileinNode.edit(); fileinNode.edit();
fileinNode.setFilename("test/resources/file-in-node/test.txt"); fileinNode.setFilename("test/resources/file-in-node/test.txt");
fileinNode.setFormat(""); fileinNode.setOutput("");
fileinNode.clickOk(); fileinNode.clickOk();
changeNode.edit(); changeNode.edit();
@ -352,7 +352,7 @@ describe('cookbook', function() {
httpRequestNode.edit(); httpRequestNode.edit();
httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-file'); httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-file');
httpRequestNode.setMethod("get"); httpRequestNode.setMethod("GET");
httpRequestNode.clickOk(); httpRequestNode.clickOk();
injectNode.connect(httpRequestNode); injectNode.connect(httpRequestNode);
@ -396,7 +396,7 @@ describe('cookbook', function() {
httpRequestNode.edit(); httpRequestNode.edit();
httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-raw'); httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-raw');
httpRequestNode.setMethod("post"); httpRequestNode.setMethod("POST");
httpRequestNode.clickOk(); httpRequestNode.clickOk();
injectNode.connect(httpRequestNode); injectNode.connect(httpRequestNode);
@ -440,12 +440,12 @@ describe('cookbook', function() {
injectNode.clickOk(); injectNode.clickOk();
changeNode.edit(); changeNode.edit();
changeNode.ruleSet("headers", "msg", "{\"content-type\":\"application/x-www-form-urlencoded\"}", "json"); changeNode.ruleSet("headers", "msg", '{"content-type":"application/x-www-form-urlencoded"}', "json");
changeNode.clickOk(); changeNode.clickOk();
httpRequestNode.edit(); httpRequestNode.edit();
httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-form'); httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-form');
httpRequestNode.setMethod("post"); httpRequestNode.setMethod("POST");
httpRequestNode.clickOk(); httpRequestNode.clickOk();
injectNode.connect(changeNode); injectNode.connect(changeNode);
@ -486,16 +486,16 @@ describe('cookbook', function() {
var debugNode = workspace.addNode("debug", nodeWidth * 3, nodeHeight); var debugNode = workspace.addNode("debug", nodeWidth * 3, nodeHeight);
injectNode.edit() injectNode.edit()
injectNode.setPayload("json", "{\"name\":\"Nick\"}"); injectNode.setPayload("json", '{"name":"Nick"}');
injectNode.clickOk(); injectNode.clickOk();
changeNode.edit(); changeNode.edit();
changeNode.ruleSet("headers", "msg", "{\"content-type\":\"application/json\"}", "json"); changeNode.ruleSet("headers", "msg", '{"content-type":"application/json"}', "json");
changeNode.clickOk(); changeNode.clickOk();
httpRequestNode.edit(); httpRequestNode.edit();
httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-json'); httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-json');
httpRequestNode.setMethod("post"); httpRequestNode.setMethod("POST");
httpRequestNode.clickOk(); httpRequestNode.clickOk();
injectNode.connect(changeNode); injectNode.connect(changeNode);
@ -531,13 +531,13 @@ describe('cookbook', function() {
httpinNodeFormat.clickOk(); httpinNodeFormat.clickOk();
functionNodeFormat.edit(); functionNodeFormat.edit();
functionNodeFormat.setCode("msg.payload = JSON.stringify(msg.req.cookies,null,4);"); functionNodeFormat.setFunction("msg.payload = JSON.stringify(msg.req.cookies,null,4);\nreturn msg;");
functionNodeFormat.clickOk(); functionNodeFormat.clickOk();
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
templateNode.setFormat("handlebars"); templateNode.setFormat("handlebars");
templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Cookies</h1>\n<p></p><a href=\"hello-cookie/add\">Add a cookie</a> &bull; <a href=\"hello-cookie/clear\">Clear cookies</a></p>\n<pre>{{ payload }}</pre>\n</body>\n</html>"); templateNode.setTemplate('<html>\n<head></head>\n<body>\n<h1>Cookies</h1>\n<p></p><a href="hello-cookie/add">Add a cookie</a> &bull; <a href="hello-cookie/clear">Clear cookies</a></p>\n<pre>{{ payload }}</pre>\n</body>\n</html>');
templateNode.clickOk(); templateNode.clickOk();
httpinNodeFormat.connect(functionNodeFormat); httpinNodeFormat.connect(functionNodeFormat);
@ -550,7 +550,7 @@ describe('cookbook', function() {
httpinNodeAdd.clickOk(); httpinNodeAdd.clickOk();
functionNodeAdd.edit(); functionNodeAdd.edit();
functionNodeAdd.setCode("msg.cookies = { };\n msg.cookies[\"demo-\"+(Math.floor(Math.random()*1000))] = Date.now();"); functionNodeAdd.setFunction('msg.cookies = { };\n msg.cookies["demo-"+(Math.floor(Math.random()*1000))] = Date.now();\nreturn msg;');
functionNodeAdd.clickOk(); functionNodeAdd.clickOk();
changeNode.edit(); changeNode.edit();
@ -571,7 +571,7 @@ describe('cookbook', function() {
httpinNodeClear.clickOk(); httpinNodeClear.clickOk();
functionNodeClear.edit(); functionNodeClear.edit();
functionNodeClear.setCode("var cookieNames = Object.keys(msg.req.cookies).filter(function(cookieName) { return /^demo-/.test(cookieName);});\nmsg.cookies = {};\n\ncookieNames.forEach(function(cookieName) {\n msg.cookies[cookieName] = null;\n});\n\n"); functionNodeClear.setFunction("var cookieNames = Object.keys(msg.req.cookies).filter(function(cookieName) { return /^demo-/.test(cookieName);});\nmsg.cookies = {};\n\ncookieNames.forEach(function(cookieName) {\n msg.cookies[cookieName] = null;\n});\nreturn msg;\n");
functionNodeClear.clickOk(); functionNodeClear.clickOk();
httpinNodeClear.connect(functionNodeClear); httpinNodeClear.connect(functionNodeClear);

View File

@ -19,8 +19,8 @@ var should = require("should");
var fs = require('fs-extra'); var fs = require('fs-extra');
var helper = require("../../editor_helper"); var helper = require("../../editor_helper");
var debugTab = require('../../pageobjects/workspace/debugTab_page'); var debugTab = require('../../pageobjects/editor/debugTab_page');
var workspace = require('../../pageobjects/workspace/workspace_page'); var workspace = require('../../pageobjects/editor/workspace_page');
var specUtil = require('../../pageobjects/util/spec_util_page'); var specUtil = require('../../pageobjects/util/spec_util_page');
var nodeWidth = 200; var nodeWidth = 200;
@ -168,8 +168,8 @@ describe('cookbook', function() {
var debugNode = workspace.addNode("debug", nodeWidth * 2); var debugNode = workspace.addNode("debug", nodeWidth * 2);
injectNode.edit(); injectNode.edit();
injectNode.setTimeType("interval"); injectNode.setRepeat("interval");
injectNode.setRepeat(1); injectNode.setRepeatInterval(1);
injectNode.clickOk(); injectNode.clickOk();
injectNode.connect(debugNode); injectNode.connect(debugNode);
@ -196,12 +196,12 @@ describe('cookbook', function() {
var debugNode = workspace.addNode("debug", nodeWidth * 3); var debugNode = workspace.addNode("debug", nodeWidth * 3);
httpRequetNode.edit(); httpRequetNode.edit();
httpRequetNode.setMethod("get"); httpRequetNode.setMethod("GET");
httpRequetNode.setUrl(helper.url()); httpRequetNode.setUrl(helper.url());
httpRequetNode.clickOk(); httpRequetNode.clickOk();
htmlNode.edit(); htmlNode.edit();
htmlNode.setTag("title"); htmlNode.setSelector("title");
htmlNode.clickOk(); htmlNode.clickOk();
injectNode.connect(httpRequetNode); injectNode.connect(httpRequetNode);
@ -336,14 +336,14 @@ describe('cookbook', function() {
changeNodeSetPost.clickOk(); changeNodeSetPost.clickOk();
httpRequetNode.edit(); httpRequetNode.edit();
httpRequetNode.setMethod("get"); httpRequetNode.setMethod("GET");
var url = helper.url() + httpNodeRoot + "/{{post}}"; var url = helper.url() + httpNodeRoot + "/{{post}}";
httpRequetNode.setUrl(url); httpRequetNode.setUrl(url);
httpRequetNode.setRet("obj"); httpRequetNode.setReturn("obj");
httpRequetNode.clickOk(); httpRequetNode.clickOk();
debugNode.edit(); debugNode.edit();
debugNode.setTarget("msg", "payload.title"); debugNode.setOutput("payload.title");
debugNode.clickOk(); debugNode.clickOk();
injectNode.connect(changeNodeSetPost); injectNode.connect(changeNodeSetPost);
@ -364,11 +364,11 @@ describe('cookbook', function() {
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
templateNode.setFormat("handlebars"); templateNode.setFormat("handlebars");
templateNode.setTemplate("{\"title\": \"Hello\"}"); templateNode.setTemplate('{"title": "Hello"}');
templateNode.clickOk(); templateNode.clickOk();
changeNodeSetHeader.edit(); changeNodeSetHeader.edit();
changeNodeSetHeader.ruleSet("headers", "msg", "{\"content-type\":\"application/json\"}", "json"); changeNodeSetHeader.ruleSet("headers", "msg", '{"content-type":"application/json"}', "json");
changeNodeSetHeader.clickOk(); changeNodeSetHeader.clickOk();
httpinNode.connect(templateNode); httpinNode.connect(templateNode);
@ -389,9 +389,9 @@ describe('cookbook', function() {
var debugNode = workspace.addNode("debug", nodeWidth * 2); var debugNode = workspace.addNode("debug", nodeWidth * 2);
httpRequetNode.edit(); httpRequetNode.edit();
httpRequetNode.setMethod("get"); httpRequetNode.setMethod("GET");
httpRequetNode.setUrl(helper.url() + "/settings"); httpRequetNode.setUrl(helper.url() + "/settings");
httpRequetNode.setRet("bin"); httpRequetNode.setReturn("bin");
httpRequetNode.clickOk(); httpRequetNode.clickOk();
injectNode.connect(httpRequetNode); injectNode.connect(httpRequetNode);
@ -413,11 +413,11 @@ describe('cookbook', function() {
var debugNode = workspace.addNode("debug", nodeWidth * 3); var debugNode = workspace.addNode("debug", nodeWidth * 3);
functionNode.edit(); functionNode.edit();
functionNode.setCode("msg.payload = \"data to post\";"); functionNode.setFunction('msg.payload = "data to post";\nreturn msg;');
functionNode.clickOk(); functionNode.clickOk();
httpRequetNode.edit(); httpRequetNode.edit();
httpRequetNode.setMethod("post"); httpRequetNode.setMethod("POST");
var url = helper.url() + httpNodeRoot + "/set-header"; var url = helper.url() + httpNodeRoot + "/set-header";
httpRequetNode.setUrl(url); httpRequetNode.setUrl(url);
httpRequetNode.clickOk(); httpRequetNode.clickOk();

View File

@ -1216,7 +1216,7 @@ describe('function node', function() {
msg.should.have.property('payload', n1.id); msg.should.have.property('payload', n1.id);
done(); done();
}); });
n1.receive({payload:"foo",topicb: "bar"}); n1.receive({payload:"foo",topic: "bar"});
}); });
}); });
@ -1230,7 +1230,7 @@ describe('function node', function() {
msg.should.have.property('payload', n1.name); msg.should.have.property('payload', n1.name);
done(); done();
}); });
n1.receive({payload:"foo",topicb: "bar"}); n1.receive({payload:"foo",topic: "bar"});
}); });
}); });