mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge branch 'master' into dev
This commit is contained in:
@@ -15,22 +15,40 @@
|
||||
**/
|
||||
|
||||
var idMap = {
|
||||
// input
|
||||
// common
|
||||
"inject": ".red-ui-palette-node[data-palette-type='inject']",
|
||||
"httpIn": ".red-ui-palette-node[data-palette-type='http in']",
|
||||
"mqttIn": ".red-ui-palette-node[data-palette-type='mqtt in']",
|
||||
// output
|
||||
"debug": ".red-ui-palette-node[data-palette-type='debug']",
|
||||
"httpResponse": ".red-ui-palette-node[data-palette-type='http response']",
|
||||
"mqttOut": ".red-ui-palette-node[data-palette-type='mqtt out']",
|
||||
"complete": ".red-ui-palette-node[data-palette-type='complete']",
|
||||
"catch": ".red-ui-palette-node[data-palette-type='catch']",
|
||||
"status": ".red-ui-palette-node[data-palette-type='status']",
|
||||
"comment": ".red-ui-palette-node[data-palette-type='comment']",
|
||||
// function
|
||||
"function": ".red-ui-palette-node[data-palette-type='function']",
|
||||
"template": ".red-ui-palette-node[data-palette-type='template']",
|
||||
"switch": ".red-ui-palette-node[data-palette-type='switch']",
|
||||
"change": ".red-ui-palette-node[data-palette-type='change']",
|
||||
"range": ".red-ui-palette-node[data-palette-type='range']",
|
||||
"template": ".red-ui-palette-node[data-palette-type='template']",
|
||||
"delay": ".red-ui-palette-node[data-palette-type='delay']",
|
||||
"trigger": ".red-ui-palette-node[data-palette-type='trigger']",
|
||||
"exec": ".red-ui-palette-node[data-palette-type='exec']",
|
||||
// network
|
||||
"mqttIn": ".red-ui-palette-node[data-palette-type='mqtt in']",
|
||||
"mqttOut": ".red-ui-palette-node[data-palette-type='mqtt out']",
|
||||
"httpIn": ".red-ui-palette-node[data-palette-type='http in']",
|
||||
"httpResponse": ".red-ui-palette-node[data-palette-type='http response']",
|
||||
"httpRequest": ".red-ui-palette-node[data-palette-type='http request']",
|
||||
"websocketIn": ".red-ui-palette-node[data-palette-type='websocket in']",
|
||||
"websocketOut": ".red-ui-palette-node[data-palette-type='websocket out']",
|
||||
// sequence
|
||||
"split": ".red-ui-palette-node[data-palette-type='split']",
|
||||
"join": ".red-ui-palette-node[data-palette-type='join']",
|
||||
"batch": ".red-ui-palette-node[data-palette-type='batch']",
|
||||
// parser
|
||||
"csv": ".red-ui-palette-node[data-palette-type='csv']",
|
||||
"html": ".red-ui-palette-node[data-palette-type='html']",
|
||||
"json": ".red-ui-palette-node[data-palette-type='json']",
|
||||
"xml": ".red-ui-palette-node[data-palette-type='xml']",
|
||||
"yaml": ".red-ui-palette-node[data-palette-type='yaml']",
|
||||
// storage
|
||||
"fileIn": ".red-ui-palette-node[data-palette-type='file in']",
|
||||
};
|
||||
|
@@ -42,7 +42,7 @@ function addNode(type, x, y) {
|
||||
}
|
||||
}
|
||||
browser.waitForVisible('#red-ui-palette-search');
|
||||
browser.setValue('//*[@id="red-ui-palette-search"]/div/input', type.replace(/([A-Z])/g,' $1').toLowerCase());
|
||||
browser.setValue('//*[@id="red-ui-palette-search"]/div/form/input', type.replace(/([A-Z])/g, ' $1').toLowerCase());
|
||||
browser.pause(300);
|
||||
browser.waitForVisible(palette.getId(type));
|
||||
browser.moveToObject(palette.getId(type));
|
||||
@@ -66,8 +66,8 @@ function deleteAllNodes() {
|
||||
|
||||
function deploy() {
|
||||
browser.call(function () {
|
||||
return when.promise(function(resolve, reject) {
|
||||
events.on("runtime-event", function(event) {
|
||||
return when.promise(function (resolve, reject) {
|
||||
events.on("runtime-event", function (event) {
|
||||
if (event.id === 'runtime-deploy') {
|
||||
events.removeListener("runtime-event", arguments.callee);
|
||||
resolve();
|
||||
|
@@ -18,8 +18,6 @@ var util = require("util");
|
||||
|
||||
var nodePage = require("../../node_page");
|
||||
|
||||
var keyPage = require("../../../util/key_page");
|
||||
|
||||
function debugNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
@@ -33,6 +31,8 @@ debugNode.prototype.setOutput = function (complete) {
|
||||
// Select the "msg" type.
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options")][1]/a[1]');
|
||||
// Input the path in msg.
|
||||
browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-input")]/input');
|
||||
browser.keys(Array('payload'.length).fill('Backspace'));
|
||||
browser.setValue('//*[contains(@class, "red-ui-typedInput-input")]/input', complete);
|
||||
} else {
|
||||
// Select the "complete msg object" type.
|
||||
|
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var nodePage = require('../../node_page');
|
||||
|
||||
function completeNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(completeNode, nodePage);
|
||||
|
||||
completeNode.prototype.setScope = function (scope) {
|
||||
if (scope) {
|
||||
browser.clickWithWait('//*[@id="node-input-complete-target-select"]');
|
||||
browser.pause(1000);
|
||||
if (Array.isArray(scope)) {
|
||||
for (var i = 0; i < scope.length; i++) {
|
||||
browser.moveToObject(scope[i].id);
|
||||
browser.buttonDown();
|
||||
browser.buttonUp();
|
||||
}
|
||||
} else {
|
||||
browser.moveToObject(scope.id);
|
||||
browser.buttonDown();
|
||||
browser.buttonUp();
|
||||
}
|
||||
browser.clickWithWait('//*[contains(@class, "red-ui-notification")]/div/button[2]');
|
||||
browser.pause(1000);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = completeNode;
|
48
test/editor/pageobjects/nodes/core/common/25-catch_page.js
Normal file
48
test/editor/pageobjects/nodes/core/common/25-catch_page.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var nodePage = require('../../node_page');
|
||||
|
||||
function catchNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(catchNode, nodePage);
|
||||
|
||||
catchNode.prototype.setScope = function (scope) {
|
||||
if (scope) {
|
||||
browser.selectWithWait('#node-input-scope-select', 'target');
|
||||
browser.clickWithWait('//*[@id="node-input-catch-target-select"]');
|
||||
browser.pause(1000);
|
||||
if (Array.isArray(scope)) {
|
||||
for (var i = 0; i < scope.length; i++) {
|
||||
browser.moveToObject(scope[i].id);
|
||||
browser.buttonDown();
|
||||
browser.buttonUp();
|
||||
}
|
||||
} else {
|
||||
browser.moveToObject(scope.id);
|
||||
browser.buttonDown();
|
||||
browser.buttonUp();
|
||||
}
|
||||
browser.clickWithWait('//*[contains(@class, "red-ui-notification")]/div/button[2]');
|
||||
browser.pause(1000);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = catchNode;
|
48
test/editor/pageobjects/nodes/core/common/25-status_page.js
Normal file
48
test/editor/pageobjects/nodes/core/common/25-status_page.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var nodePage = require('../../node_page');
|
||||
|
||||
function statusNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(statusNode, nodePage);
|
||||
|
||||
statusNode.prototype.setScope = function (scope) {
|
||||
if (scope) {
|
||||
browser.selectWithWait('#node-input-scope-select', 'target');
|
||||
browser.clickWithWait('//*[@id="node-input-status-target-select"]');
|
||||
browser.pause(1000);
|
||||
if (Array.isArray(scope)) {
|
||||
for (var i = 0; i < scope.length; i++) {
|
||||
browser.moveToObject(scope[i].id);
|
||||
browser.buttonDown();
|
||||
browser.buttonUp();
|
||||
}
|
||||
} else {
|
||||
browser.moveToObject(scope.id);
|
||||
browser.buttonDown();
|
||||
browser.buttonUp();
|
||||
}
|
||||
browser.clickWithWait('//*[contains(@class, "red-ui-notification")]/div/button[2]');
|
||||
browser.pause(1000);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = statusNode;
|
27
test/editor/pageobjects/nodes/core/common/90-comment_page.js
Normal file
27
test/editor/pageobjects/nodes/core/common/90-comment_page.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var nodePage = require('../../node_page');
|
||||
|
||||
function commentNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(commentNode, nodePage);
|
||||
|
||||
module.exports = commentNode;
|
234
test/editor/pageobjects/nodes/core/function/10-switch_page.js
Normal file
234
test/editor/pageobjects/nodes/core/function/10-switch_page.js
Normal file
@@ -0,0 +1,234 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var nodePage = require('../../node_page');
|
||||
|
||||
function switchNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(switchNode, nodePage);
|
||||
|
||||
var vtType = {
|
||||
"msg": 1,
|
||||
"flow": 2,
|
||||
"global": 3,
|
||||
"str": 4,
|
||||
"num": 5,
|
||||
"jsonata": 6,
|
||||
"env": 7,
|
||||
"prev": 8
|
||||
};
|
||||
|
||||
function setT(t, index) {
|
||||
browser.selectWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/select', t);
|
||||
}
|
||||
|
||||
function setV(v, vt, index) {
|
||||
if (vt) {
|
||||
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + vtType[vt] + ']');
|
||||
}
|
||||
if (v) {
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/div/input', v);
|
||||
}
|
||||
}
|
||||
|
||||
function setBetweenV(v, vt, v2, v2t, index) {
|
||||
if (vt) {
|
||||
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div[2]/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + vtType[vt] + ']');
|
||||
}
|
||||
if (v) {
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div[2]/div[1]/input', v);
|
||||
}
|
||||
if (v2t) {
|
||||
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[3]/div/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + vtType[v2t] + ']');
|
||||
}
|
||||
if (v2) {
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[3]/div/div[1]/input', v2);
|
||||
}
|
||||
}
|
||||
|
||||
function setSequenceV(v, vt, index) {
|
||||
var sType = {
|
||||
"flow": 1,
|
||||
"global": 2,
|
||||
"num": 3,
|
||||
"jsonata": 4,
|
||||
"env": 5,
|
||||
};
|
||||
|
||||
if (vt) {
|
||||
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div[2]/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + sType[vt] + ']');
|
||||
}
|
||||
if (v) {
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div[2]/div[1]/input', v);
|
||||
}
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleEqual = function (v, vt, index) {
|
||||
index = index || 1;
|
||||
setT('eq', index);
|
||||
setV(v, vt, index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleNotEqual = function (v, vt, index) {
|
||||
index = index || 1;
|
||||
setT('neq', index);
|
||||
setV(v, vt, index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleLessThan = function (v, vt, index) {
|
||||
index = index || 1;
|
||||
setT('lt', index);
|
||||
setV(v, vt, index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleLessThanOrEqual = function (v, vt, index) {
|
||||
index = index || 1;
|
||||
setT('lte', index);
|
||||
setV(v, vt, index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleGreaterThan = function (v, vt, index) {
|
||||
index = index || 1;
|
||||
setT('gt', index);
|
||||
setV(v, vt, index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleGreaterThanOrEqual = function (v, vt, index) {
|
||||
index = index || 1;
|
||||
setT('gte', index);
|
||||
setV(v, vt, index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleHasKey = function (v, vt, index) {
|
||||
index = index || 1;
|
||||
setT('hask', index);
|
||||
setV(v, vt, index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleIsBetween = function (v, vt, v2, v2t, index) {
|
||||
index = index || 1;
|
||||
setT('btwn', index);
|
||||
setBetweenV(v, vt, v2, v2t, index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleContains = function (v, vt, index) {
|
||||
index = index || 1;
|
||||
setT('cont', index);
|
||||
setV(v, vt, index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleMatchesRegex = function (v, vt, index) {
|
||||
index = index || 1;
|
||||
setT('regex', index);
|
||||
setV(v, vt, index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleIsTrue = function (index) {
|
||||
index = index || 1;
|
||||
setT('true', index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleIsFalse = function (index) {
|
||||
index = index || 1;
|
||||
setT('false', index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleIsNull = function (index) {
|
||||
index = index || 1;
|
||||
setT('null', index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleIsNotNull = function (index) {
|
||||
index = index || 1;
|
||||
setT('nnull', index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleIsOfType = function (t, index) {
|
||||
index = index || 1;
|
||||
setT('istype', index);
|
||||
|
||||
var tType = {
|
||||
"str": 1,
|
||||
"num": 2,
|
||||
"boolean": 3,
|
||||
"array": 4,
|
||||
"buffer": 5,
|
||||
"object": 6,
|
||||
"json": 7,
|
||||
"undefined": 8,
|
||||
"null": 9
|
||||
};
|
||||
|
||||
if (t) {
|
||||
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div[2]/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + tType[t] + ']');
|
||||
}
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleIsEmpty = function (index) {
|
||||
index = index || 1;
|
||||
setT('empty', index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleIsNotEmpty = function (index) {
|
||||
index = index || 1;
|
||||
setT('nempty', index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleHead = function (v, vt, index) {
|
||||
index = index || 1;
|
||||
setT('head', index);
|
||||
setSequenceV(v, vt, index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleIndexBetween = function (v, vt, v2, v2t, index) {
|
||||
index = index || 1;
|
||||
setT('index', index);
|
||||
setBetweenV(v, vt, v2, v2t, index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleTail = function (v, vt, index) {
|
||||
index = index || 1;
|
||||
setT('tail', index);
|
||||
setSequenceV(v, vt, index);
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleJSONataExp = function (v, index) {
|
||||
index = index || 1;
|
||||
setT('jsonata_exp', index);
|
||||
if (v) {
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div[2]/div[1]/input', v);
|
||||
}
|
||||
}
|
||||
|
||||
switchNode.prototype.ruleOtherwise = function (index) {
|
||||
index = index || 1;
|
||||
setT('else', index);
|
||||
}
|
||||
|
||||
switchNode.prototype.addRule = function () {
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-editableList")]/a');
|
||||
}
|
||||
|
||||
module.exports = switchNode;
|
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require("util");
|
||||
var util = require('util');
|
||||
|
||||
var nodePage = require("../../node_page");
|
||||
var nodePage = require('../../node_page');
|
||||
|
||||
function changeNode(id) {
|
||||
nodePage.call(this, id);
|
||||
@@ -51,41 +51,82 @@ function setT(t, index) {
|
||||
// It is better to create a function whose input value is the object type in the future,
|
||||
changeNode.prototype.ruleSet = function (p, pt, to, tot, index) {
|
||||
index = index || 1;
|
||||
setT("set", index);
|
||||
setT('set', index);
|
||||
if (pt) {
|
||||
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/button[1]');
|
||||
var num = 5 * (index - 1) + 1;
|
||||
var ptXPath = '//div[contains(@class, "red-ui-typedInput-options")][' + num + ']/a[' + ptType[pt] + ']';
|
||||
browser.clickWithWait(ptXPath);
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + ptType[pt] + ']');
|
||||
}
|
||||
if (p) {
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/div/input', p);
|
||||
}
|
||||
if (tot) {
|
||||
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[2]/div[2]/button[1]');
|
||||
var num = 5 * (index - 1) + 2;
|
||||
var totXPath = '//div[contains(@class, "red-ui-typedInput-options")][' + num + ']/a[' + totType[tot] + ']';
|
||||
browser.clickWithWait(totXPath);
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + totType[tot] + ']');
|
||||
}
|
||||
if (to) {
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[2]/div[2]/div/input', to);
|
||||
}
|
||||
}
|
||||
|
||||
changeNode.prototype.ruleDelete = function (index) {
|
||||
changeNode.prototype.ruleChange = function (p, pt, from, fromt, to, tot, index) {
|
||||
index = index || 1;
|
||||
setT("delete", index);
|
||||
setT('change', index);
|
||||
if (pt) {
|
||||
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + ptType[pt] + ']');
|
||||
}
|
||||
if (p) {
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/div/input', p);
|
||||
}
|
||||
if (fromt) {
|
||||
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[3]/div[1]/div[2]/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + totType[pt] + ']');
|
||||
}
|
||||
if (from) {
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[3]/div[1]/div[2]/div[1]/input', from);
|
||||
}
|
||||
if (tot) {
|
||||
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[3]/div[2]/div[2]/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + totType[pt] + ']');
|
||||
}
|
||||
if (to) {
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[3]/div[2]/div[2]/div[1]/input', to);
|
||||
}
|
||||
}
|
||||
|
||||
changeNode.prototype.ruleMove = function (p, to, index) {
|
||||
changeNode.prototype.ruleDelete = function (p, pt, index) {
|
||||
index = index || 1;
|
||||
setT("move", index);
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/div/input', p);
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[4]/div[2]/div/input', to);
|
||||
setT('delete', index);
|
||||
if (pt) {
|
||||
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + ptType[pt] + ']');
|
||||
}
|
||||
if (p) {
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/div/input', p);
|
||||
}
|
||||
}
|
||||
|
||||
changeNode.prototype.ruleMove = function (p, pt, to, tot, index) {
|
||||
index = index || 1;
|
||||
setT('move', index);
|
||||
if (pt) {
|
||||
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + ptType[pt] + ']');
|
||||
}
|
||||
if (p) {
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/div/input', p);
|
||||
}
|
||||
if (tot) {
|
||||
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[4]/div[2]/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + totType[pt] + ']');
|
||||
}
|
||||
if (to) {
|
||||
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[4]/div[2]/div/input', to);
|
||||
}
|
||||
}
|
||||
|
||||
changeNode.prototype.addRule = function () {
|
||||
browser.clickWithWait('//*[@id="dialog-form"]/div[3]/div/a');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-editableList")]/a');
|
||||
}
|
||||
|
||||
module.exports = changeNode;
|
||||
|
@@ -18,18 +18,14 @@ var util = require("util");
|
||||
|
||||
var nodePage = require("../../node_page");
|
||||
|
||||
function mqttInNode(id) {
|
||||
function delayNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(mqttInNode, nodePage);
|
||||
util.inherits(delayNode, nodePage);
|
||||
|
||||
mqttInNode.prototype.setTopic = function (topic) {
|
||||
browser.setValue('#node-input-topic', topic);
|
||||
delayNode.prototype.setTimeout = function (timeout) {
|
||||
browser.setValue('//*[@id="node-input-timeout"]', timeout);
|
||||
}
|
||||
|
||||
mqttInNode.prototype.setQoS = function (qos) {
|
||||
browser.selectWithWait('#node-input-qos', qos);
|
||||
}
|
||||
|
||||
module.exports = mqttInNode;
|
||||
module.exports = delayNode;
|
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require("util");
|
||||
|
||||
var nodePage = require("../../node_page");
|
||||
|
||||
function triggerNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(triggerNode, nodePage);
|
||||
|
||||
triggerNode.prototype.setSend = function (send, sendt) {
|
||||
var sendType = {
|
||||
"flow": 1,
|
||||
"global": 2,
|
||||
"str": 3,
|
||||
"num": 4,
|
||||
"bool": 5,
|
||||
"json": 6,
|
||||
"bin": 7,
|
||||
"date": 8,
|
||||
"env": 9,
|
||||
"pay": 10,
|
||||
"nul": 11
|
||||
};
|
||||
|
||||
if (sendt) {
|
||||
browser.clickWithWait('//*[@id="dialog-form"]/div[1]/div/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + sendType[sendt] + ']');
|
||||
}
|
||||
if (send) {
|
||||
browser.setValue('//*[@id="dialog-form"]/div[1]/div/div[1]/input', send);
|
||||
}
|
||||
}
|
||||
|
||||
triggerNode.prototype.setDuration = function (duration, units) {
|
||||
browser.setValue('//*[@id="node-input-duration"]', duration);
|
||||
if (units) {
|
||||
browser.selectWithWait('//*[@id="node-input-units"]', units);
|
||||
}
|
||||
}
|
||||
|
||||
triggerNode.prototype.setThenSend = function (thenSend, thenSendt) {
|
||||
var thenSendType = {
|
||||
"flow": 1,
|
||||
"global": 2,
|
||||
"str": 3,
|
||||
"num": 4,
|
||||
"bool": 5,
|
||||
"json": 6,
|
||||
"bin": 7,
|
||||
"date": 8,
|
||||
"env": 9,
|
||||
"pay": 10,
|
||||
"payl": 11,
|
||||
"nul": 12
|
||||
};
|
||||
|
||||
if (thenSendt) {
|
||||
browser.clickWithWait('//*[@id="dialog-form"]/div[5]/div/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + thenSendType[thenSendt] + ']');
|
||||
}
|
||||
if (thenSend) {
|
||||
browser.setValue('//*[@id="dialog-form"]/div[5]/div/div[1]/input', thenSend);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = triggerNode;
|
@@ -18,18 +18,20 @@ var util = require("util");
|
||||
|
||||
var nodePage = require("../../node_page");
|
||||
|
||||
function mqttOutNode(id) {
|
||||
function execNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(mqttOutNode, nodePage);
|
||||
util.inherits(execNode, nodePage);
|
||||
|
||||
mqttOutNode.prototype.setTopic = function(topic) {
|
||||
browser.setValue('#node-input-topic', topic);
|
||||
execNode.prototype.setCommand = function (command) {
|
||||
browser.setValue('//*[@id="node-input-command"]', command);
|
||||
}
|
||||
|
||||
mqttOutNode.prototype.setRetain = function (retain) {
|
||||
browser.selectWithWait('#node-input-retain', retain);
|
||||
execNode.prototype.setAppend = function (checkbox) {
|
||||
if (browser.isSelected('#node-input-addpay') !== checkbox) {
|
||||
browser.click('#node-input-addpay');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = mqttOutNode;
|
||||
module.exports = execNode;
|
@@ -14,27 +14,61 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
function setServer(broker, port) {
|
||||
var util = require("util");
|
||||
|
||||
var nodePage = require("../../node_page");
|
||||
|
||||
var mqttBrokerNode = {};
|
||||
|
||||
mqttBrokerNode.setServer = function (broker, port) {
|
||||
browser.setValue('#node-config-input-broker', broker);
|
||||
port = port ? port : 1883;
|
||||
browser.setValue('#node-config-input-port', port);
|
||||
}
|
||||
};
|
||||
|
||||
function clickOk() {
|
||||
mqttBrokerNode.clickOk = function () {
|
||||
browser.clickWithWait('#node-config-dialog-ok');
|
||||
// Wait until an config dialog closes.
|
||||
browser.waitForVisible('#node-config-dialog-ok', 10000, true);
|
||||
}
|
||||
};
|
||||
|
||||
function edit() {
|
||||
mqttBrokerNode.edit = function () {
|
||||
browser.waitForVisible('#node-input-lookup-broker');
|
||||
browser.click('#node-input-lookup-broker');
|
||||
// Wait until a config dialog opens.
|
||||
browser.waitForVisible('#node-config-dialog-ok', 10000);
|
||||
};
|
||||
|
||||
function mqttInNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
setServer: setServer,
|
||||
clickOk: clickOk,
|
||||
edit: edit
|
||||
util.inherits(mqttInNode, nodePage);
|
||||
|
||||
mqttInNode.prototype.setTopic = function (topic) {
|
||||
browser.setValue('#node-input-topic', topic);
|
||||
};
|
||||
|
||||
mqttInNode.prototype.setQoS = function (qos) {
|
||||
browser.selectWithWait('#node-input-qos', qos);
|
||||
};
|
||||
|
||||
mqttInNode.prototype.mqttBrokerNode = mqttBrokerNode;
|
||||
module.exports.mqttInNode = mqttInNode;
|
||||
|
||||
function mqttOutNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(mqttOutNode, nodePage);
|
||||
|
||||
mqttOutNode.prototype.setTopic = function (topic) {
|
||||
browser.setValue('#node-input-topic', topic);
|
||||
};
|
||||
|
||||
mqttOutNode.prototype.setRetain = function (retain) {
|
||||
browser.selectWithWait('#node-input-retain', retain);
|
||||
};
|
||||
|
||||
mqttOutNode.prototype.mqttBrokerNode = mqttBrokerNode;
|
||||
module.exports.mqttOutNode = mqttOutNode;
|
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require("util");
|
||||
|
||||
var nodePage = require("../../node_page");
|
||||
|
||||
var websocketListenerNode = {};
|
||||
|
||||
websocketListenerNode.setPath = function (path) {
|
||||
browser.setValue('#node-config-input-path', path);
|
||||
};
|
||||
|
||||
websocketListenerNode.setSendReceive = function (wholemsg) {
|
||||
browser.selectWithWait('#node-config-input-wholemsg', wholemsg);
|
||||
};
|
||||
|
||||
websocketListenerNode.clickOk = function () {
|
||||
browser.clickWithWait('#node-config-dialog-ok');
|
||||
// Wait until an config dialog closes.
|
||||
browser.waitForVisible('#node-config-dialog-ok', 10000, true);
|
||||
};
|
||||
|
||||
websocketListenerNode.edit = function () {
|
||||
browser.waitForVisible('#node-input-lookup-server');
|
||||
browser.click('#node-input-lookup-server');
|
||||
// Wait until a config dialog opens.
|
||||
browser.waitForVisible('#node-config-dialog-ok', 10000);
|
||||
};
|
||||
|
||||
var websocketClientNode = {};
|
||||
|
||||
websocketClientNode.setPath = function (path) {
|
||||
browser.setValue('#node-config-input-path', path);
|
||||
};
|
||||
|
||||
websocketClientNode.setSendReceive = function (wholemsg) {
|
||||
browser.selectWithWait('#node-config-input-wholemsg', wholemsg);
|
||||
};
|
||||
|
||||
websocketClientNode.clickOk = function () {
|
||||
browser.clickWithWait('#node-config-dialog-ok');
|
||||
// Wait until an config dialog closes.
|
||||
browser.waitForVisible('#node-config-dialog-ok', 10000, true);
|
||||
};
|
||||
|
||||
websocketClientNode.edit = function () {
|
||||
browser.waitForVisible('#node-input-lookup-client');
|
||||
browser.click('#node-input-lookup-client');
|
||||
// Wait until a config dialog opens.
|
||||
browser.waitForVisible('#node-config-dialog-ok', 10000);
|
||||
};
|
||||
|
||||
function websocketInNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(websocketInNode, nodePage);
|
||||
|
||||
websocketInNode.prototype.setType = function (type) {
|
||||
browser.selectWithWait('#node-input-mode', type);
|
||||
};
|
||||
|
||||
websocketInNode.prototype.websocketListenerNode = websocketListenerNode;
|
||||
websocketInNode.prototype.websocketClientNode = websocketClientNode;
|
||||
module.exports.websocketInNode = websocketInNode;
|
||||
|
||||
function websocketOutNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(websocketOutNode, nodePage);
|
||||
|
||||
websocketOutNode.prototype.setType = function (type) {
|
||||
browser.selectWithWait('#node-input-mode', type);
|
||||
};
|
||||
|
||||
websocketOutNode.prototype.websocketListenerNode = websocketListenerNode;
|
||||
websocketOutNode.prototype.websocketClientNode = websocketClientNode;
|
||||
module.exports.websocketOutNode = websocketOutNode;
|
51
test/editor/pageobjects/nodes/core/parsers/70-CSV_page.js
Normal file
51
test/editor/pageobjects/nodes/core/parsers/70-CSV_page.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var nodePage = require('../../node_page');
|
||||
|
||||
function csvNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(csvNode, nodePage);
|
||||
|
||||
csvNode.prototype.setColumns = function (columns) {
|
||||
browser.setValue('#node-input-temp', columns);
|
||||
}
|
||||
|
||||
csvNode.prototype.setSkipLines = function (skip) {
|
||||
browser.setValue('#node-input-skip', skip);
|
||||
}
|
||||
|
||||
csvNode.prototype.setFirstRow4Names = function (checkbox) {
|
||||
if (browser.isSelected('#node-input-hdrin') !== checkbox) {
|
||||
browser.click('#node-input-hdrin');
|
||||
}
|
||||
}
|
||||
|
||||
csvNode.prototype.setOutput = function (output) {
|
||||
browser.selectWithWait('#node-input-multi', output);
|
||||
}
|
||||
|
||||
csvNode.prototype.setIncludeRow = function (checkbox) {
|
||||
if (browser.isSelected('#node-input-hdrout') !== checkbox) {
|
||||
browser.click('#node-input-hdrout');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = csvNode;
|
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require("util");
|
||||
var util = require('util');
|
||||
|
||||
var nodePage = require("../../node_page");
|
||||
var nodePage = require('../../node_page');
|
||||
|
||||
function htmlNode(id) {
|
||||
nodePage.call(this, id);
|
||||
@@ -24,7 +24,7 @@ function htmlNode(id) {
|
||||
|
||||
util.inherits(htmlNode, nodePage);
|
||||
|
||||
htmlNode.prototype.setSelector = function(tag) {
|
||||
htmlNode.prototype.setSelector = function (tag) {
|
||||
browser.setValue('#node-input-tag', tag);
|
||||
}
|
||||
|
||||
|
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require("util");
|
||||
var util = require('util');
|
||||
|
||||
var nodePage = require("../../node_page");
|
||||
var nodePage = require('../../node_page');
|
||||
|
||||
function jsonNode(id) {
|
||||
nodePage.call(this, id);
|
||||
@@ -28,8 +28,8 @@ jsonNode.prototype.setAction = function (action) {
|
||||
browser.setValue('node-input-action', action);
|
||||
}
|
||||
|
||||
jsonNode.prototype.setProperty = function(property) {
|
||||
browser.setValue('//*[@id="dialog-form"]/div[2]/div/div/input', property);
|
||||
jsonNode.prototype.setProperty = function (property) {
|
||||
browser.setValue('//*[contains(@class, "red-ui-typedInput-container")]/div[1]/input', property);
|
||||
}
|
||||
|
||||
module.exports = jsonNode;
|
||||
|
35
test/editor/pageobjects/nodes/core/parsers/70-XML_page.js
Normal file
35
test/editor/pageobjects/nodes/core/parsers/70-XML_page.js
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var nodePage = require('../../node_page');
|
||||
|
||||
function xmlNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(xmlNode, nodePage);
|
||||
|
||||
xmlNode.prototype.setAction = function (action) {
|
||||
browser.setValue('node-input-action', action);
|
||||
}
|
||||
|
||||
xmlNode.prototype.setProperty = function (property) {
|
||||
browser.setValue('//*[contains(@class, "red-ui-typedInput-container")]/div[1]/input', property);
|
||||
}
|
||||
|
||||
module.exports = xmlNode;
|
35
test/editor/pageobjects/nodes/core/parsers/70-YAML_page.js
Normal file
35
test/editor/pageobjects/nodes/core/parsers/70-YAML_page.js
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var nodePage = require('../../node_page');
|
||||
|
||||
function yamlNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(yamlNode, nodePage);
|
||||
|
||||
yamlNode.prototype.setAction = function (action) {
|
||||
browser.setValue('node-input-action', action);
|
||||
}
|
||||
|
||||
yamlNode.prototype.setProperty = function (property) {
|
||||
browser.setValue('//*[contains(@class, "red-ui-typedInput-container")]/div[1]/input', property);
|
||||
}
|
||||
|
||||
module.exports = yamlNode;
|
47
test/editor/pageobjects/nodes/core/sequence/17-split_page.js
Normal file
47
test/editor/pageobjects/nodes/core/sequence/17-split_page.js
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var nodePage = require('../../node_page');
|
||||
|
||||
function splitNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(splitNode, nodePage);
|
||||
|
||||
splitNode.prototype.setSplitUsing = function (splt, spltt) {
|
||||
var spltType = {
|
||||
"str": 1,
|
||||
"bin": 2,
|
||||
"len": 3
|
||||
};
|
||||
|
||||
browser.clickWithWait('//*[@id="dialog-form"]/div[3]/div/button[1]');
|
||||
browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options") and not(contains(@style, "display: none"))]/a[' + spltType[spltt] + ']');
|
||||
browser.setValue('//*[@id="dialog-form"]/div[3]/div/div[1]/input', splt);
|
||||
};
|
||||
|
||||
module.exports.splitNode = splitNode;
|
||||
|
||||
function joinNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
util.inherits(joinNode, nodePage);
|
||||
|
||||
module.exports.joinNode = joinNode;
|
39
test/editor/pageobjects/nodes/core/sequence/19-batch_page.js
Normal file
39
test/editor/pageobjects/nodes/core/sequence/19-batch_page.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var nodePage = require('../../node_page');
|
||||
|
||||
function batchNode(id) {
|
||||
nodePage.call(this, id);
|
||||
}
|
||||
|
||||
batchNode.prototype.setMode = function (mode) {
|
||||
browser.selectWithWait('#node-input-mode', mode);
|
||||
}
|
||||
|
||||
batchNode.prototype.setCount = function (count) {
|
||||
browser.setValue('#node-input-count', count);
|
||||
}
|
||||
|
||||
batchNode.prototype.setOverlap = function (overlap) {
|
||||
browser.setValue('#node-input-overlap', overlap);
|
||||
}
|
||||
|
||||
util.inherits(batchNode, nodePage);
|
||||
|
||||
module.exports = batchNode;
|
@@ -35,10 +35,11 @@ Node.prototype.clickOk = function () {
|
||||
browser.pause(50);
|
||||
}
|
||||
|
||||
Node.prototype.connect = function (targetNode) {
|
||||
var outputPort = this.id + '/*[@class="red-ui-flow-port-output"]';
|
||||
Node.prototype.connect = function (targetNode, port) {
|
||||
port = port || 1;
|
||||
var outputPort = this.id + '/*[@class="red-ui-flow-port-output"][' + port + ']';
|
||||
var inputPort = targetNode.id + '/*[@class="red-ui-flow-port-input"]';
|
||||
browser.dragAndDrop(outputPort, inputPort)
|
||||
browser.dragAndDrop(outputPort, inputPort);
|
||||
}
|
||||
|
||||
Node.prototype.clickLeftButton = function () {
|
||||
|
@@ -16,37 +16,70 @@
|
||||
|
||||
var injectNode = require('./core/common/20-inject_page');
|
||||
var debugNode = require('./core/common/21-debug_page');
|
||||
var completeNode = require('./core/common/24-complete_page');
|
||||
var catchNode = require('./core/common/25-catch_page');
|
||||
var statusNode = require('./core/common/25-status_page');
|
||||
var commentNode = require('./core/common/90-comment_page');
|
||||
var functionNode = require('./core/function/10-function_page');
|
||||
var switchNode = require('./core/function/10-switch_page');
|
||||
var changeNode = require('./core/function/15-change_page');
|
||||
var rangeNode = require('./core/function/16-range_page');
|
||||
var templateNode = require('./core/function/80-template_page');
|
||||
var mqttInNode = require('./core/network/10-mqttin_page');
|
||||
var mqttOutNode = require('./core/network/10-mqttout_page');
|
||||
var delayNode = require('./core/function/89-delay_page');
|
||||
var triggerNode = require('./core/function/89-trigger_page');
|
||||
var execNode = require('./core/function/90-exec_page');
|
||||
var mqttInNode = require('./core/network/10-mqtt_page').mqttInNode;
|
||||
var mqttOutNode = require('./core/network/10-mqtt_page').mqttOutNode;
|
||||
var httpInNode = require('./core/network/21-httpin_page');
|
||||
var httpResponseNode = require('./core/network/21-httpresponse_page');
|
||||
var httpRequestNode = require('./core/network/21-httprequest_page');
|
||||
var websocketInNode = require('./core/network/22-websocket_page').websocketInNode;
|
||||
var websocketOutNode = require('./core/network/22-websocket_page').websocketOutNode;
|
||||
var splitNode = require('./core/sequence/17-split_page').splitNode;
|
||||
var joinNode = require('./core/sequence/17-split_page').joinNode;
|
||||
var batchNode = require('./core/sequence/19-batch_page');
|
||||
var csvNode = require('./core/parsers/70-CSV_page');
|
||||
var htmlNode = require('./core/parsers/70-HTML_page');
|
||||
var jsonNode = require('./core/parsers/70-JSON_page');
|
||||
var xmlNode = require('./core/parsers/70-XML_page');
|
||||
var yamlNode = require('./core/parsers/70-YAML_page');
|
||||
var fileInNode = require('./core/storage/10-filein_page');
|
||||
|
||||
var nodeCatalog = {
|
||||
// common
|
||||
"inject": injectNode,
|
||||
"debug": debugNode,
|
||||
"complete": completeNode,
|
||||
"catch": catchNode,
|
||||
"status": statusNode,
|
||||
"comment": commentNode,
|
||||
// function
|
||||
"function": functionNode,
|
||||
"switch": switchNode,
|
||||
"change": changeNode,
|
||||
"range": rangeNode,
|
||||
"template": templateNode,
|
||||
"delay": delayNode,
|
||||
"trigger": triggerNode,
|
||||
"exec": execNode,
|
||||
// network
|
||||
"mqttIn": mqttInNode,
|
||||
"mqttOut": mqttOutNode,
|
||||
"httpIn": httpInNode,
|
||||
"httpResponse": httpResponseNode,
|
||||
"httpRequest": httpRequestNode,
|
||||
"websocketIn": websocketInNode,
|
||||
"websocketOut": websocketOutNode,
|
||||
// sequence
|
||||
"split": splitNode,
|
||||
"join": joinNode,
|
||||
"batch": batchNode,
|
||||
// parser
|
||||
"csv": csvNode,
|
||||
"html": htmlNode,
|
||||
"json": jsonNode,
|
||||
"xml": xmlNode,
|
||||
"yaml": yamlNode,
|
||||
// storage
|
||||
"fileIn": fileInNode
|
||||
};
|
||||
|
@@ -70,7 +70,7 @@ function init() {
|
||||
|
||||
var ret = repeatUntilSuccess(function(args) {
|
||||
return browser.selectByValue(args[0], args[1]);
|
||||
}, [selector, value]);
|
||||
}, [selector, value.toString()]);
|
||||
return ret;
|
||||
} catch (e) {
|
||||
console.trace();
|
||||
|
364
test/editor/specs/scenario/cookbook_dataformats_uispec.js
Normal file
364
test/editor/specs/scenario/cookbook_dataformats_uispec.js
Normal file
@@ -0,0 +1,364 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var when = require('when');
|
||||
var should = require('should');
|
||||
var fs = require('fs-extra');
|
||||
|
||||
var helper = require('../../editor_helper');
|
||||
var debugTab = require('../../pageobjects/editor/debugTab_page');
|
||||
var workspace = require('../../pageobjects/editor/workspace_page');
|
||||
var specUtil = require('../../pageobjects/util/spec_util_page');
|
||||
|
||||
var httpNodeRoot = '/api';
|
||||
|
||||
// https://cookbook.nodered.org/
|
||||
describe('cookbook', function () {
|
||||
beforeEach(function () {
|
||||
workspace.init();
|
||||
});
|
||||
|
||||
before(function () {
|
||||
helper.startServer();
|
||||
});
|
||||
|
||||
after(function () {
|
||||
helper.stopServer();
|
||||
});
|
||||
|
||||
describe('working with data formats', function () {
|
||||
it('convert to/from JSON', function () {
|
||||
var injectNode1 = workspace.addNode('inject');
|
||||
var jsonNode1 = workspace.addNode('json');
|
||||
var debugNode1 = workspace.addNode('debug');
|
||||
|
||||
injectNode1.edit();
|
||||
injectNode1.setPayload('str', '{"a":1}');
|
||||
injectNode1.clickOk();
|
||||
|
||||
jsonNode1.edit();
|
||||
jsonNode1.setProperty('payload');
|
||||
jsonNode1.clickOk();
|
||||
|
||||
injectNode1.connect(jsonNode1);
|
||||
jsonNode1.connect(debugNode1);
|
||||
|
||||
var injectNode2 = workspace.addNode('inject');
|
||||
var jsonNode2 = workspace.addNode('json');
|
||||
var debugNode2 = workspace.addNode('debug');
|
||||
|
||||
injectNode2.edit();
|
||||
injectNode2.setPayload('json', '{"a":1}');
|
||||
injectNode2.clickOk();
|
||||
|
||||
jsonNode2.edit();
|
||||
jsonNode2.setProperty('payload');
|
||||
jsonNode2.clickOk();
|
||||
|
||||
injectNode2.connect(jsonNode2);
|
||||
jsonNode2.connect(debugNode2);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode1.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('1');
|
||||
debugTab.clearMessage();
|
||||
injectNode2.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"{"a":1}"');
|
||||
});
|
||||
|
||||
it('convert to/from XML', function () {
|
||||
var injectNode1 = workspace.addNode('inject', 0);
|
||||
var templateNode1 = workspace.addNode('template', 200);
|
||||
var xmlNode1 = workspace.addNode('xml', 400);
|
||||
var debugNode1 = workspace.addNode('debug', 600);
|
||||
|
||||
injectNode1.edit();
|
||||
injectNode1.setPayload('str', '{"a":1}');
|
||||
injectNode1.clickOk();
|
||||
|
||||
templateNode1.edit();
|
||||
templateNode1.setFormat('text');
|
||||
templateNode1.setSyntax('plain');
|
||||
templateNode1.setTemplate('<note priority="high">'
|
||||
+ ' <to>Nick</to>'
|
||||
+ ' <from>Dave</from>'
|
||||
+ ' <heading>Reminder</heading>'
|
||||
+ ' <body>Update the website</body>'
|
||||
+ '</note>');
|
||||
templateNode1.clickOk();
|
||||
|
||||
xmlNode1.edit();
|
||||
xmlNode1.setProperty('payload');
|
||||
xmlNode1.clickOk();
|
||||
|
||||
injectNode1.connect(templateNode1);
|
||||
templateNode1.connect(xmlNode1);
|
||||
xmlNode1.connect(debugNode1);
|
||||
|
||||
var injectNode2 = workspace.addNode('inject');
|
||||
var xmlNode2 = workspace.addNode('xml');
|
||||
var debugNode2 = workspace.addNode('debug');
|
||||
|
||||
injectNode2.edit();
|
||||
injectNode2.setPayload('json', '{'
|
||||
+ ' "note": {'
|
||||
+ ' "$": { "priority": "high" },'
|
||||
+ ' "to": [ "Nick" ],'
|
||||
+ ' "from": [ "Dave" ],'
|
||||
+ ' "heading": [ "Reminder" ],'
|
||||
+ ' "body": [ "Update the website" ]'
|
||||
+ ' }'
|
||||
+ '}');
|
||||
injectNode2.clickOk();
|
||||
|
||||
xmlNode2.edit();
|
||||
xmlNode2.setProperty('payload');
|
||||
xmlNode2.clickOk();
|
||||
|
||||
injectNode2.connect(xmlNode2);
|
||||
xmlNode2.connect(debugNode2);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode1.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('object');
|
||||
debugTab.clearMessage();
|
||||
injectNode2.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
|
||||
+ '<note priority="high">'
|
||||
+ '<to>Nick</to>'
|
||||
+ '<from>Dave</from>'
|
||||
+ '<heading>Reminder</heading>'
|
||||
+ '<body>Update the website</body>'
|
||||
+ '</note>"');
|
||||
});
|
||||
|
||||
it('convert to/from YAML', function () {
|
||||
var injectNode1 = workspace.addNode('inject', 0);
|
||||
var templateNode1 = workspace.addNode('template', 200);
|
||||
var yamlNode1 = workspace.addNode('yaml', 400);
|
||||
var debugNode1 = workspace.addNode('debug', 600);
|
||||
|
||||
injectNode1.edit();
|
||||
injectNode1.setPayload('str', '{"a":1}');
|
||||
injectNode1.clickOk();
|
||||
|
||||
templateNode1.edit();
|
||||
templateNode1.setFormat('yaml');
|
||||
templateNode1.setSyntax('plain');
|
||||
templateNode1.setTemplate('a: 1\n'
|
||||
+ 'b:\n'
|
||||
+ ' - 1\n'
|
||||
+ '- 2\n'
|
||||
+ '- 3');
|
||||
templateNode1.clickOk();
|
||||
|
||||
yamlNode1.edit();
|
||||
yamlNode1.setProperty('payload');
|
||||
yamlNode1.clickOk();
|
||||
|
||||
injectNode1.connect(templateNode1);
|
||||
templateNode1.connect(yamlNode1);
|
||||
yamlNode1.connect(debugNode1);
|
||||
|
||||
var injectNode2 = workspace.addNode('inject');
|
||||
var yamlNode2 = workspace.addNode('yaml');
|
||||
var debugNode2 = workspace.addNode('debug');
|
||||
|
||||
injectNode2.edit();
|
||||
injectNode2.setPayload('json', '{"a":1, "b":[1,2,3]}');
|
||||
injectNode2.clickOk();
|
||||
|
||||
yamlNode2.edit();
|
||||
yamlNode2.setProperty('payload');
|
||||
yamlNode2.clickOk();
|
||||
|
||||
injectNode2.connect(yamlNode2);
|
||||
yamlNode2.connect(debugNode2);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode1.clickLeftButton();
|
||||
debugTab.getMessage().should.eql([ '1', 'array[3]' ]);
|
||||
debugTab.clearMessage();
|
||||
injectNode2.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"a: 1↵b:↵ - 1↵ - 2↵ - 3↵"');
|
||||
});
|
||||
|
||||
it('generate CSV output', function () {
|
||||
var injectNode1 = workspace.addNode('inject', 0);
|
||||
var changeNode1 = workspace.addNode('change', 200);
|
||||
var csvNode1 = workspace.addNode('csv', 400);
|
||||
var debugNode1 = workspace.addNode('debug', 600);
|
||||
|
||||
changeNode1.edit();
|
||||
changeNode1.ruleSet('payload', 'msg', '{'
|
||||
+ ' "a": $floor(100*$random()),'
|
||||
+ ' "b": $floor(100*$random()),'
|
||||
+ ' "c": $floor(100*$random())'
|
||||
+ '}', 'jsonata');
|
||||
changeNode1.clickOk();
|
||||
|
||||
csvNode1.edit();
|
||||
csvNode1.setColumns('a,b,c');
|
||||
csvNode1.clickOk();
|
||||
|
||||
injectNode1.connect(changeNode1);
|
||||
changeNode1.connect(csvNode1);
|
||||
csvNode1.connect(debugNode1);
|
||||
|
||||
var injectNode2 = workspace.addNode('inject', 0, 80);
|
||||
var changeNode2 = workspace.addNode('change', 200, 80);
|
||||
var csvNode2 = workspace.addNode('csv', 400, 80);
|
||||
var debugNode2 = workspace.addNode('debug', 600, 80);
|
||||
|
||||
changeNode2.edit();
|
||||
changeNode2.ruleSet('payload', 'msg', '['
|
||||
+ ' {'
|
||||
+ ' "a": $floor(100*$random()),'
|
||||
+ ' "b": $floor(100*$random()),'
|
||||
+ ' "c": $floor(100*$random())'
|
||||
+ ' }, {'
|
||||
+ ' "a": $floor(100*$random()),'
|
||||
+ ' "b": $floor(100*$random()),'
|
||||
+ ' "c": $floor(100*$random())'
|
||||
+ ' }, {'
|
||||
+ ' "a": $floor(100*$random()),'
|
||||
+ ' "b": $floor(100*$random()),'
|
||||
+ ' "c": $floor(100*$random())'
|
||||
+ ' }, {'
|
||||
+ ' "a": $floor(100*$random()),'
|
||||
+ ' "b": $floor(100*$random()),'
|
||||
+ ' "c": $floor(100*$random())'
|
||||
+ ' }'
|
||||
+ ']', 'jsonata');
|
||||
changeNode2.clickOk();
|
||||
|
||||
csvNode2.edit();
|
||||
csvNode2.setColumns('a,b,c');
|
||||
csvNode2.setIncludeRow(true);
|
||||
csvNode2.clickOk();
|
||||
|
||||
injectNode2.connect(changeNode2);
|
||||
changeNode2.connect(csvNode2);
|
||||
csvNode2.connect(debugNode2);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode1.clickLeftButton();
|
||||
debugTab.getMessage().should.match(/^"([1-9]?[0-9],){2}[1-9]?[0-9]↵"$/);
|
||||
debugTab.clearMessage();
|
||||
injectNode2.clickLeftButton();
|
||||
debugTab.getMessage().should.match(/^"a,b,c↵(([1-9]?[0-9],){2}[1-9]?[0-9]↵){4}"$/);
|
||||
});
|
||||
|
||||
it('parse CSV input', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var templateNode = workspace.addNode('template');
|
||||
var csvNode = workspace.addNode('csv');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
templateNode.edit();
|
||||
templateNode.setFormat('handlebars');
|
||||
templateNode.setSyntax('mustache');
|
||||
templateNode.setTemplate('# This is some random data\n'
|
||||
+ 'a,b,c\n'
|
||||
+ '80,18,2\n'
|
||||
+ '52,36,10\n'
|
||||
+ '91,18,61\n'
|
||||
+ '32,47,65');
|
||||
templateNode.clickOk();
|
||||
|
||||
csvNode.edit();
|
||||
csvNode.setSkipLines(1);
|
||||
csvNode.setFirstRow4Names(true);
|
||||
csvNode.setOutput('mult');
|
||||
csvNode.clickOk();
|
||||
|
||||
injectNode.connect(templateNode);
|
||||
templateNode.connect(csvNode);
|
||||
csvNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql([ 'object', 'object', 'object', 'object' ]);
|
||||
});
|
||||
|
||||
it('simple GET request', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var httpRequestNode = workspace.addNode('httpRequest');
|
||||
var htmlNode = workspace.addNode('html');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
httpRequestNode.edit();
|
||||
httpRequestNode.setMethod('GET');
|
||||
httpRequestNode.setUrl('https://nodered.org');
|
||||
httpRequestNode.clickOk();
|
||||
|
||||
htmlNode.edit();
|
||||
htmlNode.setSelector('.node-red-latest-version');
|
||||
htmlNode.clickOk();
|
||||
|
||||
injectNode.connect(httpRequestNode);
|
||||
httpRequestNode.connect(htmlNode);
|
||||
htmlNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.match(/^"v[0-9]+\.[0-9]+\.[0-9]"$/);
|
||||
});
|
||||
|
||||
it('split text into one message per line', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var templateNode = workspace.addNode('template');
|
||||
var splitNode = workspace.addNode('split');
|
||||
var changeNode = workspace.addNode('change');
|
||||
var joinNode = workspace.addNode('join');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
templateNode.edit();
|
||||
templateNode.setFormat('handlebars');
|
||||
templateNode.setSyntax('mustache');
|
||||
templateNode.setTemplate('one\ntwo\nthree\nfour\nfive');
|
||||
templateNode.clickOk();
|
||||
|
||||
changeNode.edit();
|
||||
changeNode.ruleSet('payload', 'msg', '(parts.index+1) & ": " & payload', 'jsonata');
|
||||
changeNode.clickOk();
|
||||
|
||||
injectNode.connect(templateNode);
|
||||
templateNode.connect(splitNode);
|
||||
splitNode.connect(changeNode);
|
||||
changeNode.connect(joinNode);
|
||||
joinNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"1: one↵2: two↵3: three↵4: four↵5: five"');
|
||||
});
|
||||
});
|
||||
});
|
74
test/editor/specs/scenario/cookbook_errorhandling_uispec.js
Normal file
74
test/editor/specs/scenario/cookbook_errorhandling_uispec.js
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var when = require('when');
|
||||
var should = require('should');
|
||||
var fs = require('fs-extra');
|
||||
|
||||
var helper = require('../../editor_helper');
|
||||
var debugTab = require('../../pageobjects/editor/debugTab_page');
|
||||
var workspace = require('../../pageobjects/editor/workspace_page');
|
||||
var specUtil = require('../../pageobjects/util/spec_util_page');
|
||||
|
||||
var httpNodeRoot = '/api';
|
||||
|
||||
// https://cookbook.nodered.org/
|
||||
describe('cookbook', function () {
|
||||
beforeEach(function () {
|
||||
workspace.init();
|
||||
});
|
||||
|
||||
before(function () {
|
||||
helper.startServer();
|
||||
});
|
||||
|
||||
after(function () {
|
||||
helper.stopServer();
|
||||
});
|
||||
|
||||
describe('messages', function () {
|
||||
it('trigger a flow when a node throws an error', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var functionNode = workspace.addNode('function');
|
||||
var catchNode = workspace.addNode('catch', 0 , 80);
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
functionNode.edit();
|
||||
functionNode.setFunction('node.error("an example error", msg);');
|
||||
functionNode.clickOk();
|
||||
|
||||
catchNode.edit();
|
||||
catchNode.setScope(functionNode);
|
||||
catchNode.clickOk();
|
||||
|
||||
debugNode.edit();
|
||||
debugNode.setOutput('error');
|
||||
debugNode.clickOk();
|
||||
|
||||
injectNode.connect(functionNode);
|
||||
catchNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql(['"an example error"', 'function']);
|
||||
});
|
||||
|
||||
// skip this case since the flow outputs random results.
|
||||
it.skip('automatically retry an action after an error');
|
||||
});
|
||||
});
|
81
test/editor/specs/scenario/cookbook_flowcontrol_uispec.js
Normal file
81
test/editor/specs/scenario/cookbook_flowcontrol_uispec.js
Normal file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var when = require('when');
|
||||
var should = require('should');
|
||||
var fs = require('fs-extra');
|
||||
|
||||
var helper = require('../../editor_helper');
|
||||
var debugTab = require('../../pageobjects/editor/debugTab_page');
|
||||
var workspace = require('../../pageobjects/editor/workspace_page');
|
||||
var specUtil = require('../../pageobjects/util/spec_util_page');
|
||||
|
||||
var httpNodeRoot = '/api';
|
||||
|
||||
// https://cookbook.nodered.org/
|
||||
describe('cookbook', function () {
|
||||
beforeEach(function () {
|
||||
workspace.init();
|
||||
});
|
||||
|
||||
before(function () {
|
||||
helper.startServer();
|
||||
});
|
||||
|
||||
after(function () {
|
||||
helper.stopServer();
|
||||
});
|
||||
|
||||
describe('flow control', function () {
|
||||
it('trigger a flow whenever Node-RED starts', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setPayload('str', 'Started!');
|
||||
injectNode.setOnce(true);
|
||||
injectNode.clickOk();
|
||||
injectNode.connect(debugNode);
|
||||
|
||||
debugTab.open();
|
||||
workspace.deploy();
|
||||
debugTab.getMessage().should.eql('"Started!"');
|
||||
});
|
||||
|
||||
it('trigger a flow at regular intervals', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setRepeat('interval');
|
||||
injectNode.setRepeatInterval(1);
|
||||
injectNode.clickOk();
|
||||
injectNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
specUtil.pause(1000);
|
||||
var t1 = Number(debugTab.getMessage(1));
|
||||
t1.should.within(1500000000000, 3000000000000);
|
||||
specUtil.pause(1000);
|
||||
debugTab.getMessage(2).should.within(t1 + 900, 3000000000000);
|
||||
});
|
||||
|
||||
// skip this case since it needs up to one minite.
|
||||
it.skip('trigger a flow at a specific time');
|
||||
});
|
||||
});
|
@@ -23,16 +23,16 @@ var workspace = require('../../pageobjects/editor/workspace_page');
|
||||
var httpNodeRoot = "/api";
|
||||
|
||||
// https://cookbook.nodered.org/
|
||||
describe('cookbook', function() {
|
||||
beforeEach(function() {
|
||||
describe('cookbook', function () {
|
||||
beforeEach(function () {
|
||||
workspace.init();
|
||||
});
|
||||
|
||||
before(function() {
|
||||
before(function () {
|
||||
helper.startServer();
|
||||
});
|
||||
|
||||
after(function() {
|
||||
after(function () {
|
||||
helper.stopServer();
|
||||
});
|
||||
|
||||
@@ -359,7 +359,7 @@ describe('cookbook', function() {
|
||||
debugTab.getMessage().indexOf('Text file').should.not.eql(-1);
|
||||
});
|
||||
|
||||
it('post raw data to a flow', function() {
|
||||
it('post raw data to a flow', function () {
|
||||
var httpInNode = workspace.addNode("httpIn");
|
||||
var templateNode = workspace.addNode("template");
|
||||
var httpResponseNode = workspace.addNode("httpResponse");
|
||||
@@ -383,7 +383,7 @@ describe('cookbook', function() {
|
||||
var httpRequestNode = workspace.addNode("httpRequest");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
injectNode.edit()
|
||||
injectNode.edit();
|
||||
injectNode.setPayload("str", "Nick");
|
||||
injectNode.clickOk();
|
||||
|
||||
@@ -427,7 +427,7 @@ describe('cookbook', function() {
|
||||
var httpRequestNode = workspace.addNode("httpRequest");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
injectNode.edit()
|
||||
injectNode.edit();
|
||||
injectNode.setPayload("str", "name=Nick");
|
||||
injectNode.clickOk();
|
||||
|
||||
@@ -451,7 +451,7 @@ describe('cookbook', function() {
|
||||
debugTab.getMessage().indexOf('Hello Nick!').should.not.eql(-1);
|
||||
});
|
||||
|
||||
it('post JSON data to a flow', function() {
|
||||
it('post JSON data to a flow', function () {
|
||||
var httpInNode = workspace.addNode("httpIn");
|
||||
var templateNode = workspace.addNode("template");
|
||||
var httpResponseNode = workspace.addNode("httpResponse");
|
||||
@@ -476,7 +476,7 @@ describe('cookbook', function() {
|
||||
var httpRequestNode = workspace.addNode("httpRequest");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
injectNode.edit()
|
||||
injectNode.edit();
|
||||
injectNode.setPayload("json", '{"name":"Nick"}');
|
||||
injectNode.clickOk();
|
||||
|
300
test/editor/specs/scenario/cookbook_httprequests_uispec.js
Normal file
300
test/editor/specs/scenario/cookbook_httprequests_uispec.js
Normal file
@@ -0,0 +1,300 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var when = require('when');
|
||||
var should = require('should');
|
||||
var fs = require('fs-extra');
|
||||
|
||||
var helper = require('../../editor_helper');
|
||||
var debugTab = require('../../pageobjects/editor/debugTab_page');
|
||||
var workspace = require('../../pageobjects/editor/workspace_page');
|
||||
var specUtil = require('../../pageobjects/util/spec_util_page');
|
||||
|
||||
var httpNodeRoot = '/api';
|
||||
|
||||
// https://cookbook.nodered.org/
|
||||
describe('cookbook', function () {
|
||||
beforeEach(function () {
|
||||
workspace.init();
|
||||
});
|
||||
|
||||
before(function () {
|
||||
helper.startServer();
|
||||
});
|
||||
|
||||
after(function () {
|
||||
helper.stopServer();
|
||||
});
|
||||
|
||||
describe('HTTP requests', function () {
|
||||
it('simple get request', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var httpRequestNode = workspace.addNode('httpRequest');
|
||||
var htmlNode = workspace.addNode('html');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
httpRequestNode.edit();
|
||||
httpRequestNode.setMethod('GET');
|
||||
httpRequestNode.setUrl(helper.url());
|
||||
httpRequestNode.clickOk();
|
||||
|
||||
htmlNode.edit();
|
||||
htmlNode.setSelector('title');
|
||||
htmlNode.clickOk();
|
||||
|
||||
injectNode.connect(httpRequestNode);
|
||||
httpRequestNode.connect(htmlNode);
|
||||
htmlNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"Node-RED"');
|
||||
});
|
||||
|
||||
it('set the URL of a request', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var changeNode = workspace.addNode('change');
|
||||
var httpRequestNode = workspace.addNode('httpRequest');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setPayload('str', helper.url());
|
||||
injectNode.clickOk();
|
||||
|
||||
changeNode.edit();
|
||||
changeNode.ruleSet('url', 'msg', 'payload', 'msg');
|
||||
changeNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNode);
|
||||
changeNode.connect(httpRequestNode);
|
||||
httpRequestNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.containEql('<title>Node-RED</title>');
|
||||
});
|
||||
|
||||
it('set the URL of a request using a template', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var changeNode = workspace.addNode('change');
|
||||
var httpRequestNode = workspace.addNode('httpRequest');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setPayload('str', 'settings');
|
||||
injectNode.clickOk();
|
||||
|
||||
changeNode.edit();
|
||||
changeNode.ruleSet('query', 'msg', 'payload', 'msg');
|
||||
changeNode.clickOk();
|
||||
|
||||
httpRequestNode.edit();
|
||||
httpRequestNode.setUrl(helper.url() + '/{{{query}}}');
|
||||
httpRequestNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNode);
|
||||
changeNode.connect(httpRequestNode);
|
||||
httpRequestNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.containEql('httpNodeRoot');
|
||||
});
|
||||
|
||||
it('set the query string parameters', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var changeNode = workspace.addNode('change');
|
||||
var httpRequestNode = workspace.addNode('httpRequest');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setPayload('str', 'Nick');
|
||||
injectNode.clickOk();
|
||||
|
||||
changeNode.edit();
|
||||
changeNode.ruleSet('query', 'msg', 'payload', 'msg');
|
||||
changeNode.clickOk();
|
||||
|
||||
httpRequestNode.edit();
|
||||
httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/set-query?q={{{query}}}');
|
||||
httpRequestNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNode);
|
||||
changeNode.connect(httpRequestNode);
|
||||
httpRequestNode.connect(debugNode);
|
||||
|
||||
// The code for confirmation starts from here.
|
||||
var httpInNode = workspace.addNode('httpIn', 0, 200);
|
||||
var templateNode = workspace.addNode('template');
|
||||
var httpResponseNode = workspace.addNode('httpResponse');
|
||||
|
||||
httpInNode.edit();
|
||||
httpInNode.setMethod('get');
|
||||
httpInNode.setUrl('/set-query');
|
||||
httpInNode.clickOk();
|
||||
|
||||
templateNode.edit();
|
||||
templateNode.setSyntax('mustache');
|
||||
templateNode.setFormat('handlebars');
|
||||
templateNode.setTemplate('Hello {{req.query.q}}');
|
||||
templateNode.clickOk();
|
||||
|
||||
httpInNode.connect(templateNode);
|
||||
templateNode.connect(httpResponseNode);
|
||||
// The code for confirmation ends here.
|
||||
|
||||
workspace.deploy();
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"Hello Nick"');
|
||||
});
|
||||
|
||||
it('get a parsed JSON response', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var changeNodeSetPost = workspace.addNode('change');
|
||||
var httpRequestNode = workspace.addNode('httpRequest');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setPayload('str', 'json-response');
|
||||
injectNode.clickOk();
|
||||
|
||||
changeNodeSetPost.edit();
|
||||
changeNodeSetPost.ruleSet('post', 'msg', 'payload', 'msg');
|
||||
changeNodeSetPost.clickOk();
|
||||
|
||||
httpRequestNode.edit();
|
||||
httpRequestNode.setMethod('GET');
|
||||
var url = helper.url() + httpNodeRoot + '/{{post}}';
|
||||
httpRequestNode.setUrl(url);
|
||||
httpRequestNode.setReturn('obj');
|
||||
httpRequestNode.clickOk();
|
||||
|
||||
debugNode.edit();
|
||||
debugNode.setOutput('payload.title');
|
||||
debugNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNodeSetPost);
|
||||
changeNodeSetPost.connect(httpRequestNode);
|
||||
httpRequestNode.connect(debugNode);
|
||||
|
||||
// The code for confirmation starts from here.
|
||||
var httpInNode = workspace.addNode('httpIn', 0, 200);
|
||||
var templateNode = workspace.addNode('template');
|
||||
var changeNodeSetHeader = workspace.addNode('change');
|
||||
var httpResponseNode = workspace.addNode('httpResponse');
|
||||
|
||||
httpInNode.edit();
|
||||
httpInNode.setMethod('get');
|
||||
httpInNode.setUrl('/json-response');
|
||||
httpInNode.clickOk();
|
||||
|
||||
templateNode.edit();
|
||||
templateNode.setSyntax('mustache');
|
||||
templateNode.setFormat('handlebars');
|
||||
templateNode.setTemplate('{"title": "Hello"}');
|
||||
templateNode.clickOk();
|
||||
|
||||
changeNodeSetHeader.edit();
|
||||
changeNodeSetHeader.ruleSet('headers', 'msg', '{"content-type":"application/json"}', 'json');
|
||||
changeNodeSetHeader.clickOk();
|
||||
|
||||
httpInNode.connect(templateNode);
|
||||
templateNode.connect(changeNodeSetHeader);
|
||||
changeNodeSetHeader.connect(httpResponseNode);
|
||||
// The code for confirmation ends here.
|
||||
|
||||
workspace.deploy();
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"Hello"');
|
||||
});
|
||||
|
||||
it('get a binary response', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var httpRequestNode = workspace.addNode('httpRequest');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
httpRequestNode.edit();
|
||||
httpRequestNode.setMethod('GET');
|
||||
httpRequestNode.setUrl(helper.url() + '/settings');
|
||||
httpRequestNode.setReturn('bin');
|
||||
httpRequestNode.clickOk();
|
||||
|
||||
injectNode.connect(httpRequestNode);
|
||||
httpRequestNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
|
||||
debugTab.getMessage().should.eql(['123', '34', '104', '116', '116', '112', '78', '111', '100', '101']);
|
||||
});
|
||||
|
||||
it('set a request header', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var functionNode = workspace.addNode('function');
|
||||
var httpRequestNode = workspace.addNode('httpRequest');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
functionNode.edit();
|
||||
functionNode.setFunction('msg.payload = "data to post";\nreturn msg;');
|
||||
functionNode.clickOk();
|
||||
|
||||
httpRequestNode.edit();
|
||||
httpRequestNode.setMethod('POST');
|
||||
var url = helper.url() + httpNodeRoot + '/set-header';
|
||||
httpRequestNode.setUrl(url);
|
||||
httpRequestNode.clickOk();
|
||||
|
||||
injectNode.connect(functionNode);
|
||||
functionNode.connect(httpRequestNode);
|
||||
httpRequestNode.connect(debugNode);
|
||||
|
||||
// The code for confirmation starts from here.
|
||||
var httpInNode = workspace.addNode('httpIn', 0, 200);
|
||||
var templateNode = workspace.addNode('template');
|
||||
var httpResponseNode = workspace.addNode('httpResponse');
|
||||
|
||||
httpInNode.edit();
|
||||
httpInNode.setMethod('post');
|
||||
httpInNode.setUrl('/set-header');
|
||||
httpInNode.clickOk();
|
||||
|
||||
templateNode.edit();
|
||||
templateNode.setSyntax('mustache');
|
||||
templateNode.setFormat('handlebars');
|
||||
templateNode.setTemplate('{{ payload }}');
|
||||
templateNode.clickOk();
|
||||
|
||||
httpInNode.connect(templateNode);
|
||||
templateNode.connect(httpResponseNode);
|
||||
// The code for confirmation ends here.
|
||||
|
||||
workspace.deploy();
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"data to post"');
|
||||
});
|
||||
});
|
||||
});
|
142
test/editor/specs/scenario/cookbook_messages_uispec.js
Normal file
142
test/editor/specs/scenario/cookbook_messages_uispec.js
Normal file
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var when = require('when');
|
||||
var should = require('should');
|
||||
var fs = require('fs-extra');
|
||||
|
||||
var helper = require('../../editor_helper');
|
||||
var debugTab = require('../../pageobjects/editor/debugTab_page');
|
||||
var workspace = require('../../pageobjects/editor/workspace_page');
|
||||
var specUtil = require('../../pageobjects/util/spec_util_page');
|
||||
|
||||
var httpNodeRoot = '/api';
|
||||
|
||||
// https://cookbook.nodered.org/
|
||||
describe('cookbook', function () {
|
||||
beforeEach(function () {
|
||||
workspace.init();
|
||||
});
|
||||
|
||||
before(function () {
|
||||
helper.startServer();
|
||||
});
|
||||
|
||||
after(function () {
|
||||
helper.stopServer();
|
||||
});
|
||||
|
||||
describe('messages', function () {
|
||||
it('set a message property to a fixed value', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var changeNode = workspace.addNode('change');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
changeNode.edit();
|
||||
changeNode.ruleSet('payload', 'msg', 'Hello World!');
|
||||
changeNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNode);
|
||||
changeNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"Hello World!"');
|
||||
});
|
||||
|
||||
it('delete a message property', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var changeNode = workspace.addNode('change');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
changeNode.edit();
|
||||
changeNode.ruleDelete();
|
||||
changeNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNode);
|
||||
changeNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('undefined');
|
||||
});
|
||||
|
||||
it('move a message property', function () {
|
||||
var injectNode = workspace.addNode('inject');
|
||||
var changeNode = workspace.addNode('change');
|
||||
var debugNode = workspace.addNode('debug');
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setTopic('Hello');
|
||||
injectNode.clickOk();
|
||||
|
||||
changeNode.edit();
|
||||
changeNode.ruleMove('topic', 'msg', 'payload', 'msg');
|
||||
changeNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNode);
|
||||
changeNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"Hello"');
|
||||
});
|
||||
|
||||
it('map a property between different numeric ranges', function () {
|
||||
var injectNode1 = workspace.addNode('inject');
|
||||
var injectNode2 = workspace.addNode('inject', 0, 100);
|
||||
var injectNode3 = workspace.addNode('inject', 0, 200);
|
||||
var rangeNode = workspace.addNode('range', 200, 100);
|
||||
var debugNode = workspace.addNode('debug', 400);
|
||||
|
||||
injectNode1.edit();
|
||||
injectNode1.setPayload('num', 0);
|
||||
injectNode1.clickOk();
|
||||
injectNode2.edit();
|
||||
injectNode2.setPayload('num', 512);
|
||||
injectNode2.clickOk();
|
||||
injectNode3.edit();
|
||||
injectNode3.setPayload('num', 1023);
|
||||
injectNode3.clickOk();
|
||||
|
||||
rangeNode.edit();
|
||||
rangeNode.setAction('clamp');
|
||||
rangeNode.setRange(0, 1023, 0, 5);
|
||||
rangeNode.clickOk();
|
||||
|
||||
injectNode1.connect(rangeNode);
|
||||
injectNode2.connect(rangeNode);
|
||||
injectNode3.connect(rangeNode);
|
||||
rangeNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode1.clickLeftButton();
|
||||
debugTab.getMessage(1).should.eql('0');
|
||||
injectNode2.clickLeftButton();
|
||||
debugTab.getMessage(2).should.eql('2.5024437927663734');
|
||||
injectNode3.clickLeftButton();
|
||||
debugTab.getMessage(3).should.eql('5');
|
||||
});
|
||||
});
|
||||
});
|
@@ -22,7 +22,6 @@ var helper = require("../../editor_helper");
|
||||
var debugTab = require('../../pageobjects/editor/debugTab_page');
|
||||
var workspace = require('../../pageobjects/editor/workspace_page');
|
||||
var specUtil = require('../../pageobjects/util/spec_util_page');
|
||||
var mqttConfig = require('../../pageobjects/nodes/core/network/10-mqttconfig_page.js');
|
||||
|
||||
var httpNodeRoot = "/api";
|
||||
|
||||
@@ -73,9 +72,9 @@ describe('cookbook', function () {
|
||||
var mqttOutNode = workspace.addNode("mqttOut");
|
||||
|
||||
mqttOutNode.edit();
|
||||
mqttConfig.edit();
|
||||
mqttConfig.setServer("localhost", moscaSettings.port);
|
||||
mqttConfig.clickOk();
|
||||
mqttOutNode.mqttBrokerNode.edit();
|
||||
mqttOutNode.mqttBrokerNode.setServer("localhost", moscaSettings.port);
|
||||
mqttOutNode.mqttBrokerNode.clickOk();
|
||||
mqttOutNode.clickOk();
|
||||
|
||||
workspace.deploy();
|
||||
|
@@ -1,441 +0,0 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var when = require('when');
|
||||
var should = require("should");
|
||||
var fs = require('fs-extra');
|
||||
|
||||
var helper = require("../../editor_helper");
|
||||
var debugTab = require('../../pageobjects/editor/debugTab_page');
|
||||
var workspace = require('../../pageobjects/editor/workspace_page');
|
||||
var specUtil = require('../../pageobjects/util/spec_util_page');
|
||||
|
||||
var httpNodeRoot = "/api";
|
||||
|
||||
// https://cookbook.nodered.org/
|
||||
describe('cookbook', function() {
|
||||
beforeEach(function() {
|
||||
workspace.init();
|
||||
});
|
||||
|
||||
before(function() {
|
||||
helper.startServer();
|
||||
});
|
||||
|
||||
after(function() {
|
||||
helper.stopServer();
|
||||
});
|
||||
|
||||
describe('messages', function() {
|
||||
it('set a message property to a fixed value', function() {
|
||||
var injectNode = workspace.addNode("inject");
|
||||
var changeNode = workspace.addNode("change");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
changeNode.edit();
|
||||
changeNode.ruleSet("payload", "msg", "Hello World!");
|
||||
changeNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNode);
|
||||
changeNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"Hello World!"');
|
||||
});
|
||||
|
||||
it('delete a message property', function() {
|
||||
var injectNode = workspace.addNode("inject");
|
||||
var changeNode = workspace.addNode("change");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
changeNode.edit();
|
||||
changeNode.ruleDelete();
|
||||
changeNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNode);
|
||||
changeNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql("undefined");
|
||||
});
|
||||
|
||||
it('move a message property', function() {
|
||||
var injectNode = workspace.addNode("inject");
|
||||
var changeNode = workspace.addNode("change");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setTopic("Hello");
|
||||
injectNode.clickOk();
|
||||
|
||||
changeNode.edit();
|
||||
changeNode.ruleMove("topic", "payload");
|
||||
changeNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNode);
|
||||
changeNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"Hello"');
|
||||
});
|
||||
|
||||
it('map a property between different numeric ranges', function() {
|
||||
var injectNode1 = workspace.addNode("inject");
|
||||
var injectNode2 = workspace.addNode("inject", 0, 100);
|
||||
var injectNode3 = workspace.addNode("inject", 0, 200);
|
||||
var rangeNode = workspace.addNode("range", 200, 100);
|
||||
var debugNode = workspace.addNode("debug", 400);
|
||||
|
||||
injectNode1.edit();
|
||||
injectNode1.setPayload("num", 0);
|
||||
injectNode1.clickOk();
|
||||
injectNode2.edit();
|
||||
injectNode2.setPayload("num", 512);
|
||||
injectNode2.clickOk();
|
||||
injectNode3.edit();
|
||||
injectNode3.setPayload("num", 1023);
|
||||
injectNode3.clickOk();
|
||||
|
||||
rangeNode.edit();
|
||||
rangeNode.setAction("clamp");
|
||||
rangeNode.setRange(0, 1023, 0, 5);
|
||||
rangeNode.clickOk();
|
||||
|
||||
injectNode1.connect(rangeNode);
|
||||
injectNode2.connect(rangeNode);
|
||||
injectNode3.connect(rangeNode);
|
||||
rangeNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode1.clickLeftButton();
|
||||
debugTab.getMessage(1).should.eql('0');
|
||||
injectNode2.clickLeftButton();
|
||||
debugTab.getMessage(2).should.eql('2.5024437927663734');
|
||||
injectNode3.clickLeftButton();
|
||||
debugTab.getMessage(3).should.eql('5');
|
||||
});
|
||||
});
|
||||
|
||||
describe('flow control', function() {
|
||||
it('trigger a flow whenever Node-RED starts', function() {
|
||||
var injectNode = workspace.addNode("inject");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setPayload("str", "Started!")
|
||||
injectNode.setOnce(true);
|
||||
injectNode.clickOk();
|
||||
injectNode.connect(debugNode);
|
||||
|
||||
debugTab.open();
|
||||
workspace.deploy();
|
||||
debugTab.getMessage().should.eql('"Started!"');
|
||||
});
|
||||
|
||||
it('trigger a flow at regular intervals', function() {
|
||||
var injectNode = workspace.addNode("inject");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setRepeat("interval");
|
||||
injectNode.setRepeatInterval(1);
|
||||
injectNode.clickOk();
|
||||
injectNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
specUtil.pause(1000);
|
||||
var t1 = Number(debugTab.getMessage(1));
|
||||
t1.should.within(1500000000000, 3000000000000);
|
||||
specUtil.pause(1000);
|
||||
debugTab.getMessage(2).should.within(t1 + 900, 3000000000000);
|
||||
});
|
||||
|
||||
// skip this case since it needs up to one minite.
|
||||
it.skip('trigger a flow at a specific time');
|
||||
});
|
||||
|
||||
describe('HTTP requests', function() {
|
||||
it('simple get request', function() {
|
||||
var injectNode = workspace.addNode("inject");
|
||||
var httpRequetNode = workspace.addNode("httpRequest");
|
||||
var htmlNode = workspace.addNode("html");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
httpRequetNode.edit();
|
||||
httpRequetNode.setMethod("GET");
|
||||
httpRequetNode.setUrl(helper.url());
|
||||
httpRequetNode.clickOk();
|
||||
|
||||
htmlNode.edit();
|
||||
htmlNode.setSelector("title");
|
||||
htmlNode.clickOk();
|
||||
|
||||
injectNode.connect(httpRequetNode);
|
||||
httpRequetNode.connect(htmlNode);
|
||||
htmlNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"Node-RED"');
|
||||
});
|
||||
|
||||
it('set the URL of a request', function() {
|
||||
var injectNode = workspace.addNode("inject");
|
||||
var changeNode = workspace.addNode("change");
|
||||
var httpRequetNode = workspace.addNode("httpRequest");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setPayload("str", helper.url());
|
||||
injectNode.clickOk();
|
||||
|
||||
changeNode.edit();
|
||||
changeNode.ruleSet("url", "msg", "payload", "msg");
|
||||
changeNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNode);
|
||||
changeNode.connect(httpRequetNode);
|
||||
httpRequetNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.containEql('<title>Node-RED</title>');
|
||||
});
|
||||
|
||||
it('set the URL of a request using a template', function() {
|
||||
var injectNode = workspace.addNode("inject");
|
||||
var changeNode = workspace.addNode("change");
|
||||
var httpRequetNode = workspace.addNode("httpRequest");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setPayload("str", 'settings');
|
||||
injectNode.clickOk();
|
||||
|
||||
changeNode.edit();
|
||||
changeNode.ruleSet("query", "msg", "payload", "msg");
|
||||
changeNode.clickOk();
|
||||
|
||||
httpRequetNode.edit();
|
||||
httpRequetNode.setUrl(helper.url() + "/{{{query}}}");
|
||||
httpRequetNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNode);
|
||||
changeNode.connect(httpRequetNode);
|
||||
httpRequetNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.containEql('httpNodeRoot');
|
||||
});
|
||||
|
||||
it('set the query string parameters', function() {
|
||||
var injectNode = workspace.addNode("inject");
|
||||
var changeNode = workspace.addNode("change");
|
||||
var httpRequetNode = workspace.addNode("httpRequest");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setPayload("str", 'Nick');
|
||||
injectNode.clickOk();
|
||||
|
||||
changeNode.edit();
|
||||
changeNode.ruleSet("query", "msg", "payload", "msg");
|
||||
changeNode.clickOk();
|
||||
|
||||
httpRequetNode.edit();
|
||||
httpRequetNode.setUrl(helper.url() + httpNodeRoot + '/set-query?q={{{query}}}');
|
||||
httpRequetNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNode);
|
||||
changeNode.connect(httpRequetNode);
|
||||
httpRequetNode.connect(debugNode);
|
||||
|
||||
// The code for confirmation starts from here.
|
||||
var httpInNode = workspace.addNode("httpIn", 0, 200);
|
||||
var templateNode = workspace.addNode("template");
|
||||
var httpResponseNode = workspace.addNode("httpResponse");
|
||||
|
||||
httpInNode.edit();
|
||||
httpInNode.setMethod("get");
|
||||
httpInNode.setUrl("/set-query");
|
||||
httpInNode.clickOk();
|
||||
|
||||
templateNode.edit();
|
||||
templateNode.setSyntax("mustache");
|
||||
templateNode.setFormat("handlebars");
|
||||
templateNode.setTemplate("Hello {{req.query.q}}");
|
||||
templateNode.clickOk();
|
||||
|
||||
httpInNode.connect(templateNode);
|
||||
templateNode.connect(httpResponseNode);
|
||||
// The code for confirmation ends here.
|
||||
|
||||
workspace.deploy();
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"Hello Nick"');
|
||||
});
|
||||
|
||||
it('get a parsed JSON response', function() {
|
||||
var injectNode = workspace.addNode("inject");
|
||||
var changeNodeSetPost = workspace.addNode("change");
|
||||
var httpRequetNode = workspace.addNode("httpRequest");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
injectNode.edit();
|
||||
injectNode.setPayload("str", "json-response");
|
||||
injectNode.clickOk();
|
||||
|
||||
changeNodeSetPost.edit();
|
||||
changeNodeSetPost.ruleSet("post", "msg", "payload", "msg");
|
||||
changeNodeSetPost.clickOk();
|
||||
|
||||
httpRequetNode.edit();
|
||||
httpRequetNode.setMethod("GET");
|
||||
var url = helper.url() + httpNodeRoot + "/{{post}}";
|
||||
httpRequetNode.setUrl(url);
|
||||
httpRequetNode.setReturn("obj");
|
||||
httpRequetNode.clickOk();
|
||||
|
||||
debugNode.edit();
|
||||
debugNode.setOutput(".title");
|
||||
debugNode.clickOk();
|
||||
|
||||
injectNode.connect(changeNodeSetPost);
|
||||
changeNodeSetPost.connect(httpRequetNode);
|
||||
httpRequetNode.connect(debugNode);
|
||||
|
||||
// The code for confirmation starts from here.
|
||||
var httpInNode = workspace.addNode("httpIn", 0, 200);
|
||||
var templateNode = workspace.addNode("template");
|
||||
var changeNodeSetHeader = workspace.addNode("change");
|
||||
var httpResponseNode = workspace.addNode("httpResponse");
|
||||
|
||||
httpInNode.edit();
|
||||
httpInNode.setMethod("get");
|
||||
httpInNode.setUrl("/json-response");
|
||||
httpInNode.clickOk();
|
||||
|
||||
templateNode.edit();
|
||||
templateNode.setSyntax("mustache");
|
||||
templateNode.setFormat("handlebars");
|
||||
templateNode.setTemplate('{"title": "Hello"}');
|
||||
templateNode.clickOk();
|
||||
|
||||
changeNodeSetHeader.edit();
|
||||
changeNodeSetHeader.ruleSet("headers", "msg", '{"content-type":"application/json"}', "json");
|
||||
changeNodeSetHeader.clickOk();
|
||||
|
||||
httpInNode.connect(templateNode);
|
||||
templateNode.connect(changeNodeSetHeader);
|
||||
changeNodeSetHeader.connect(httpResponseNode);
|
||||
// The code for confirmation ends here.
|
||||
|
||||
workspace.deploy();
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"Hello"');
|
||||
});
|
||||
|
||||
it('get a binary response', function() {
|
||||
var injectNode = workspace.addNode("inject");
|
||||
var httpRequetNode = workspace.addNode("httpRequest");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
httpRequetNode.edit();
|
||||
httpRequetNode.setMethod("GET");
|
||||
httpRequetNode.setUrl(helper.url() + "/settings");
|
||||
httpRequetNode.setReturn("bin");
|
||||
httpRequetNode.clickOk();
|
||||
|
||||
injectNode.connect(httpRequetNode);
|
||||
httpRequetNode.connect(debugNode);
|
||||
|
||||
workspace.deploy();
|
||||
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
|
||||
debugTab.getMessage().should.eql(['123', '34', '104', '116', '116', '112', '78', '111', '100', '101']);
|
||||
});
|
||||
|
||||
it('set a request header', function() {
|
||||
var injectNode = workspace.addNode("inject");
|
||||
var functionNode = workspace.addNode("function");
|
||||
var httpRequetNode = workspace.addNode("httpRequest");
|
||||
var debugNode = workspace.addNode("debug");
|
||||
|
||||
functionNode.edit();
|
||||
functionNode.setFunction('msg.payload = "data to post";\nreturn msg;');
|
||||
functionNode.clickOk();
|
||||
|
||||
httpRequetNode.edit();
|
||||
httpRequetNode.setMethod("POST");
|
||||
var url = helper.url() + httpNodeRoot + "/set-header";
|
||||
httpRequetNode.setUrl(url);
|
||||
httpRequetNode.clickOk();
|
||||
|
||||
injectNode.connect(functionNode);
|
||||
functionNode.connect(httpRequetNode);
|
||||
httpRequetNode.connect(debugNode);
|
||||
|
||||
// The code for confirmation starts from here.
|
||||
var httpInNode = workspace.addNode("httpIn", 0, 200);
|
||||
var templateNode = workspace.addNode("template");
|
||||
var httpResponseNode = workspace.addNode("httpResponse");
|
||||
|
||||
httpInNode.edit();
|
||||
httpInNode.setMethod("post");
|
||||
httpInNode.setUrl("/set-header");
|
||||
httpInNode.clickOk();
|
||||
|
||||
templateNode.edit();
|
||||
templateNode.setSyntax("mustache");
|
||||
templateNode.setFormat("handlebars");
|
||||
templateNode.setTemplate("{{ payload }}");
|
||||
templateNode.clickOk();
|
||||
|
||||
httpInNode.connect(templateNode);
|
||||
templateNode.connect(httpResponseNode);
|
||||
// The code for confirmation ends here.
|
||||
|
||||
workspace.deploy();
|
||||
debugTab.open();
|
||||
injectNode.clickLeftButton();
|
||||
debugTab.getMessage().should.eql('"data to post"');
|
||||
});
|
||||
});
|
||||
});
|
@@ -759,6 +759,41 @@ describe('trigger node', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able output the 2nd payload and handle multiple topics', function(done) {
|
||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"false", op1type:"nul", op2type:"payl", op1:"false", op2:"true", duration:"80", bytopic:"topic", wires:[["n2"]] },
|
||||
{id:"n2", type:"helper"} ];
|
||||
helper.load(triggerNode, flow, function() {
|
||||
var n1 = helper.getNode("n1");
|
||||
var n2 = helper.getNode("n2");
|
||||
var c = 0;
|
||||
n2.on("input", function(msg) {
|
||||
try {
|
||||
if (c === 0) {
|
||||
msg.should.have.a.property("payload", "Goodbye1");
|
||||
msg.should.have.a.property("topic", "test1");
|
||||
c += 1;
|
||||
}
|
||||
else {
|
||||
msg.should.have.a.property("payload", "Goodbye2");
|
||||
msg.should.have.a.property("topic", "test2");
|
||||
done();
|
||||
}
|
||||
}
|
||||
catch(err) { done(err); }
|
||||
});
|
||||
n1.emit("input", {payload:"Hello1", topic:"test1"});
|
||||
setTimeout( function() {
|
||||
n1.emit("input", {payload:"Hello2", topic:"test2"});
|
||||
},20);
|
||||
setTimeout( function() {
|
||||
n1.emit("input", {payload:"Goodbye2", topic:"test2"});
|
||||
},20);
|
||||
setTimeout( function() {
|
||||
n1.emit("input", {payload:"Goodbye1", topic:"test1"});
|
||||
},20);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to apply mustache templates to payloads', function(done) {
|
||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op1type:"val", op2type:"val", op1:"{{payload}}", op2:"{{topic}}", duration:"50", wires:[["n2"]] },
|
||||
{id:"n2", type:"helper"} ];
|
||||
|
@@ -517,6 +517,49 @@ describe('JOIN node', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should join things into an array after a count with a buffer join set', function(done) {
|
||||
var flow = [{id:"n1", type:"join", wires:[["n2"]], count:3, joinerType:"bin", joiner:"" ,mode:"custom"},
|
||||
{id:"n2", type:"helper"}];
|
||||
helper.load(joinNode, flow, function() {
|
||||
var n1 = helper.getNode("n1");
|
||||
var n2 = helper.getNode("n2");
|
||||
n2.on("input", function(msg) {
|
||||
try {
|
||||
msg.should.have.property("payload");
|
||||
msg.payload.should.be.an.Array();
|
||||
msg.payload[0].should.equal(1);
|
||||
msg.payload[1].should.equal(true);
|
||||
//msg.payload[2].a.should.equal(1);
|
||||
done();
|
||||
}
|
||||
catch(e) {done(e);}
|
||||
});
|
||||
n1.receive({payload:1});
|
||||
n1.receive({payload:true});
|
||||
n1.receive({payload:{a:1}});
|
||||
});
|
||||
});
|
||||
|
||||
it('should join strings into a buffer after a count', function(done) {
|
||||
var flow = [{id:"n1", type:"join", wires:[["n2"]], count:2, build:"buffer", joinerType:"bin", joiner:"", mode:"custom"},
|
||||
{id:"n2", type:"helper"}];
|
||||
helper.load(joinNode, flow, function() {
|
||||
var n1 = helper.getNode("n1");
|
||||
var n2 = helper.getNode("n2");
|
||||
n2.on("input", function(msg) {
|
||||
try {
|
||||
msg.should.have.property("payload");
|
||||
msg.payload.length.should.equal(10);
|
||||
msg.payload.toString().should.equal("helloworld");
|
||||
done();
|
||||
}
|
||||
catch(e) {done(e);}
|
||||
});
|
||||
n1.receive({payload:"hello"});
|
||||
n1.receive({payload:"world"});
|
||||
});
|
||||
});
|
||||
|
||||
it('should join things into an object after a count', function(done) {
|
||||
var flow = [{id:"n1", type:"join", wires:[["n2"]], count:5, build:"object", mode:"custom"},
|
||||
{id:"n2", type:"helper"}];
|
||||
|
@@ -53,7 +53,7 @@ describe("runtime-api/flows", function() {
|
||||
var loadFlows;
|
||||
var reloadError = false;
|
||||
beforeEach(function() {
|
||||
setFlows = sinon.spy(function(flows,type) {
|
||||
setFlows = sinon.spy(function(flows,credentials,type) {
|
||||
if (flows[0] === "error") {
|
||||
var err = new Error("error");
|
||||
err.code = "error";
|
||||
@@ -91,7 +91,19 @@ describe("runtime-api/flows", function() {
|
||||
result.should.eql({rev:"newRev"});
|
||||
setFlows.called.should.be.true();
|
||||
setFlows.lastCall.args[0].should.eql([4,5,6]);
|
||||
setFlows.lastCall.args[1].should.eql("full");
|
||||
setFlows.lastCall.args[2].should.eql("full");
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
it("includes credentials when part of the request", function(done) {
|
||||
flows.setFlows({
|
||||
flows: {flows:[4,5,6], credentials: {$:"creds"}},
|
||||
}).then(function(result) {
|
||||
result.should.eql({rev:"newRev"});
|
||||
setFlows.called.should.be.true();
|
||||
setFlows.lastCall.args[0].should.eql([4,5,6]);
|
||||
setFlows.lastCall.args[1].should.eql({$:"creds"});
|
||||
setFlows.lastCall.args[2].should.eql("full");
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
@@ -103,7 +115,7 @@ describe("runtime-api/flows", function() {
|
||||
result.should.eql({rev:"newRev"});
|
||||
setFlows.called.should.be.true();
|
||||
setFlows.lastCall.args[0].should.eql([4,5,6]);
|
||||
setFlows.lastCall.args[1].should.eql("nodes");
|
||||
setFlows.lastCall.args[2].should.eql("nodes");
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
@@ -125,7 +137,7 @@ describe("runtime-api/flows", function() {
|
||||
result.should.eql({rev:"newRev"});
|
||||
setFlows.called.should.be.true();
|
||||
setFlows.lastCall.args[0].should.eql([4,5,6]);
|
||||
setFlows.lastCall.args[1].should.eql("nodes");
|
||||
setFlows.lastCall.args[2].should.eql("nodes");
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
@@ -32,17 +32,20 @@ describe('context', function() {
|
||||
return Context.close();
|
||||
});
|
||||
it('stores local property',function() {
|
||||
var flowContext = Context.getFlowContext("flowA")
|
||||
var context1 = Context.get("1","flowA");
|
||||
should.not.exist(context1.get("foo"));
|
||||
context1.set("foo","test");
|
||||
context1.get("foo").should.equal("test");
|
||||
});
|
||||
it('stores local property - creates parent properties',function() {
|
||||
var flowContext = Context.getFlowContext("flowA")
|
||||
var context1 = Context.get("1","flowA");
|
||||
context1.set("foo.bar","test");
|
||||
context1.get("foo").should.eql({bar:"test"});
|
||||
});
|
||||
it('deletes local property',function() {
|
||||
var flowContext = Context.getFlowContext("flowA")
|
||||
var context1 = Context.get("1","flowA");
|
||||
context1.set("foo.abc.bar1","test1");
|
||||
context1.set("foo.abc.bar2","test2");
|
||||
@@ -55,12 +58,14 @@ describe('context', function() {
|
||||
should.not.exist(context1.get("foo"));
|
||||
});
|
||||
it('stores flow property',function() {
|
||||
var flowContext = Context.getFlowContext("flowA")
|
||||
var context1 = Context.get("1","flowA");
|
||||
should.not.exist(context1.flow.get("foo"));
|
||||
context1.flow.set("foo","test");
|
||||
context1.flow.get("foo").should.equal("test");
|
||||
});
|
||||
it('stores global property',function() {
|
||||
var flowContext = Context.getFlowContext("flowA")
|
||||
var context1 = Context.get("1","flowA");
|
||||
should.not.exist(context1.global.get("foo"));
|
||||
context1.global.set("foo","test");
|
||||
@@ -68,6 +73,7 @@ describe('context', function() {
|
||||
});
|
||||
|
||||
it('keeps local context local', function() {
|
||||
var flowContext = Context.getFlowContext("flowA")
|
||||
var context1 = Context.get("1","flowA");
|
||||
var context2 = Context.get("2","flowA");
|
||||
|
||||
@@ -79,6 +85,7 @@ describe('context', function() {
|
||||
should.not.exist(context2.get("foo"));
|
||||
});
|
||||
it('flow context accessible to all flow nodes', function() {
|
||||
var flowContext = Context.getFlowContext("flowA")
|
||||
var context1 = Context.get("1","flowA");
|
||||
var context2 = Context.get("2","flowA");
|
||||
|
||||
@@ -91,6 +98,8 @@ describe('context', function() {
|
||||
});
|
||||
|
||||
it('flow context not shared to nodes on other flows', function() {
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var flowContextB = Context.getFlowContext("flowB")
|
||||
var context1 = Context.get("1","flowA");
|
||||
var context2 = Context.get("2","flowB");
|
||||
|
||||
@@ -103,6 +112,9 @@ describe('context', function() {
|
||||
});
|
||||
|
||||
it('global context shared to all nodes', function() {
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var flowContextB = Context.getFlowContext("flowB")
|
||||
|
||||
var context1 = Context.get("1","flowA");
|
||||
var context2 = Context.get("2","flowB");
|
||||
|
||||
@@ -115,6 +127,7 @@ describe('context', function() {
|
||||
});
|
||||
|
||||
it('context.flow/global are not enumerable', function() {
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var context1 = Context.get("1","flowA");
|
||||
Object.keys(context1).length.should.equal(0);
|
||||
Object.keys(context1.flow).length.should.equal(0);
|
||||
@@ -122,6 +135,7 @@ describe('context', function() {
|
||||
})
|
||||
|
||||
it('context.flow/global cannot be deleted', function() {
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var context1 = Context.get("1","flowA");
|
||||
delete context1.flow;
|
||||
should.exist(context1.flow);
|
||||
@@ -130,6 +144,7 @@ describe('context', function() {
|
||||
})
|
||||
|
||||
it('deletes context',function() {
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var context = Context.get("1","flowA");
|
||||
should.not.exist(context.get("foo"));
|
||||
context.set("foo","abc");
|
||||
@@ -142,6 +157,7 @@ describe('context', function() {
|
||||
});
|
||||
|
||||
it('enumerates context keys - sync', function() {
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var context = Context.get("1","flowA");
|
||||
|
||||
var keys = context.keys();
|
||||
@@ -160,6 +176,7 @@ describe('context', function() {
|
||||
});
|
||||
|
||||
it('enumerates context keys - async', function(done) {
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var context = Context.get("1","flowA");
|
||||
|
||||
var keys = context.keys(function(err,keys) {
|
||||
@@ -183,6 +200,7 @@ describe('context', function() {
|
||||
it('should enumerate only context keys when GlobalContext was given - sync', function() {
|
||||
Context.init({functionGlobalContext: {foo:"bar"}});
|
||||
Context.load().then(function(){
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var context = Context.get("1","flowA");
|
||||
context.global.set("foo2","bar2");
|
||||
var keys = context.global.keys();
|
||||
@@ -195,6 +213,7 @@ describe('context', function() {
|
||||
it('should enumerate only context keys when GlobalContext was given - async', function(done) {
|
||||
Context.init({functionGlobalContext: {foo:"bar"}});
|
||||
Context.load().then(function(){
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var context = Context.get("1","flowA");
|
||||
context.global.set("foo2","bar2");
|
||||
context.global.keys(function(err,keys) {
|
||||
@@ -210,6 +229,7 @@ describe('context', function() {
|
||||
it('returns functionGlobalContext value if store value undefined', function() {
|
||||
Context.init({functionGlobalContext: {foo:"bar"}});
|
||||
return Context.load().then(function(){
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var context = Context.get("1","flowA");
|
||||
var v = context.global.get('foo');
|
||||
v.should.equal('bar');
|
||||
@@ -219,6 +239,7 @@ describe('context', function() {
|
||||
it('returns functionGlobalContext sub-value if store value undefined', function() {
|
||||
Context.init({functionGlobalContext: {foo:{bar:123}}});
|
||||
return Context.load().then(function(){
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var context = Context.get("1","flowA");
|
||||
var v = context.global.get('foo.bar');
|
||||
should.equal(v,123);
|
||||
@@ -227,40 +248,67 @@ describe('context', function() {
|
||||
|
||||
describe("$parent", function() {
|
||||
it('should get undefined for $parent without key', function() {
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var flowContextB = Context.getFlowContext("flowB","flowA")
|
||||
var context0 = Context.get("0","flowA");
|
||||
var context1 = Context.get("1","flowB", context0);
|
||||
var context1 = Context.get("1","flowB");
|
||||
var parent = context1.get("$parent");
|
||||
should.equal(parent, undefined);
|
||||
});
|
||||
|
||||
it('should get undefined for $parent of root', function() {
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var flowContextB = Context.getFlowContext("flowB","flowA")
|
||||
var context0 = Context.get("0","flowA");
|
||||
var context1 = Context.get("1","flowB", context0);
|
||||
var parent = context1.get("$parent.$parent.K");
|
||||
var context1 = Context.get("1","flowB");
|
||||
var parent = context1.flow.get("$parent.$parent.K");
|
||||
should.equal(parent, undefined);
|
||||
});
|
||||
|
||||
it('should get value in $parent', function() {
|
||||
it('should get undefined for $parent of root - callback', function(done) {
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var flowContextB = Context.getFlowContext("flowB","flowA")
|
||||
var context0 = Context.get("0","flowA");
|
||||
var context1 = Context.get("1","flowB", context0);
|
||||
context0.set("K", "v");
|
||||
var v = context1.get("$parent.K");
|
||||
var context1 = Context.get("1","flowB");
|
||||
context1.flow.get("$parent.$parent.K", function(err, result) {
|
||||
try {
|
||||
should.equal(err, undefined);
|
||||
should.equal(result, undefined);
|
||||
done();
|
||||
} catch(err) {
|
||||
done(err);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should get value in $parent', function() {
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var flowContextB = Context.getFlowContext("flowB","flowA")
|
||||
var context0 = Context.get("0","flowA");
|
||||
var context1 = Context.get("1","flowB");
|
||||
flowContextA.set("K", "v");
|
||||
var v = context1.flow.get("$parent.K");
|
||||
should.equal(v, "v");
|
||||
});
|
||||
|
||||
it('should set value in $parent', function() {
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var flowContextB = Context.getFlowContext("flowB","flowA")
|
||||
var context0 = Context.get("0","flowA");
|
||||
var context1 = Context.get("1","flowB", context0);
|
||||
context1.set("$parent.K", "v");
|
||||
var v = context0.get("K");
|
||||
var context1 = Context.get("1","flowB");
|
||||
context1.flow.set("$parent.K", "v");
|
||||
var v = flowContextA.get("K");
|
||||
should.equal(v, "v");
|
||||
});
|
||||
|
||||
it('should not contain $parent in keys', function() {
|
||||
var flowContextA = Context.getFlowContext("flowA")
|
||||
var flowContextB = Context.getFlowContext("flowB","flowA")
|
||||
var context0 = Context.get("0","flowA");
|
||||
var context1 = Context.get("1","flowB", context0);
|
||||
var context1 = Context.get("1","flowB");
|
||||
var parent = context1.get("$parent");
|
||||
context0.set("K0", "v0");
|
||||
flowContextA.set("K0", "v0");
|
||||
context1.set("K1", "v1");
|
||||
var keys = context1.keys();
|
||||
keys.should.have.length(1);
|
||||
@@ -366,6 +414,7 @@ describe('context', function() {
|
||||
it('should ignore reserved storage name `_`', function(done) {
|
||||
Context.init({contextStorage:{_:{module:testPlugin}}});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow")
|
||||
var context = Context.get("1","flow");
|
||||
var cb = function(){}
|
||||
context.set("foo","bar","_",cb);
|
||||
@@ -452,6 +501,7 @@ describe('context', function() {
|
||||
Context.init({contextStorage:contextStorage});
|
||||
var cb = function(){done("An error occurred")}
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
context.set("foo","bar","test",cb);
|
||||
context.get("foo","test",cb);
|
||||
@@ -465,6 +515,7 @@ describe('context', function() {
|
||||
it('should store flow property to external context storage',function(done) {
|
||||
Context.init({contextStorage:contextStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
var cb = function(){done("An error occurred")}
|
||||
context.flow.set("foo","bar","test",cb);
|
||||
@@ -479,6 +530,7 @@ describe('context', function() {
|
||||
it('should store global property to external context storage',function(done) {
|
||||
Context.init({contextStorage:contextStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
var cb = function(){done("An error occurred")}
|
||||
context.global.set("foo","bar","test",cb);
|
||||
@@ -493,6 +545,7 @@ describe('context', function() {
|
||||
it('should store data to the default context when non-existent context storage was specified', function(done) {
|
||||
Context.init({contextStorage:contextDefaultStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
var cb = function(){done("An error occurred")}
|
||||
context.set("foo","bar","nonexist",cb);
|
||||
@@ -510,6 +563,7 @@ describe('context', function() {
|
||||
it('should use the default context', function(done) {
|
||||
Context.init({contextStorage:contextDefaultStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
var cb = function(){done("An error occurred")}
|
||||
context.set("foo","bar","default",cb);
|
||||
@@ -527,6 +581,7 @@ describe('context', function() {
|
||||
it('should use the alias of default context', function(done) {
|
||||
Context.init({contextStorage:contextDefaultStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
var cb = function(){done("An error occurred")}
|
||||
context.set("foo","alias",cb);
|
||||
@@ -541,10 +596,11 @@ describe('context', function() {
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
|
||||
it('should allow the store name to be provide in the key', function(done) {
|
||||
Context.init({contextStorage:contextDefaultStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
var cb = function(){done("An error occurred")}
|
||||
context.set("#:(test)::foo","bar");
|
||||
@@ -561,6 +617,7 @@ describe('context', function() {
|
||||
it('should use default as the alias of other context', function(done) {
|
||||
Context.init({contextStorage:contextAlias});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
var cb = function(){done("An error occurred")}
|
||||
context.set("foo","alias",cb);
|
||||
@@ -575,6 +632,7 @@ describe('context', function() {
|
||||
it('should not throw an error using undefined storage for local context', function(done) {
|
||||
Context.init({contextStorage:contextStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
var cb = function(){done("An error occurred")}
|
||||
context.get("local","nonexist",cb);
|
||||
@@ -584,6 +642,7 @@ describe('context', function() {
|
||||
it('should throw an error using undefined storage for flow context', function(done) {
|
||||
Context.init({contextStorage:contextStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
var cb = function(){done("An error occurred")}
|
||||
context.flow.get("flow","nonexist",cb);
|
||||
@@ -595,6 +654,7 @@ describe('context', function() {
|
||||
var fGC = { "foo": 456 };
|
||||
Context.init({contextStorage:memoryStorage, functionGlobalContext:fGC });
|
||||
Context.load().then(function() {
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
// Get foo - should be value from fGC
|
||||
var v = context.global.get("foo");
|
||||
@@ -615,6 +675,7 @@ describe('context', function() {
|
||||
var fGC = { "foo": 456 };
|
||||
Context.init({contextStorage:memoryStorage, functionGlobalContext:fGC });
|
||||
Context.load().then(function() {
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
// Get foo - should be value from fGC
|
||||
context.global.get("foo", function(err, v) {
|
||||
@@ -647,6 +708,7 @@ describe('context', function() {
|
||||
it('should return multiple values if key is an array', function(done) {
|
||||
Context.init({contextStorage:memoryStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
context.set("foo1","bar1","memory");
|
||||
context.set("foo2","bar2","memory");
|
||||
@@ -667,6 +729,7 @@ describe('context', function() {
|
||||
var fGC = { "foo1": 456, "foo2": {"bar":789} };
|
||||
Context.init({contextStorage:memoryStorage, functionGlobalContext:fGC });
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
context.global.get(["foo1","foo2.bar","foo3"], "memory", function(err,foo1,foo2,foo3){
|
||||
if (err) {
|
||||
@@ -685,6 +748,7 @@ describe('context', function() {
|
||||
Context.init({contextStorage:contextStorage});
|
||||
stubGet.onFirstCall().callsArgWith(2, "error2", "bar1");
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow")
|
||||
var context = Context.get("1","flow");
|
||||
context.global.get(["foo1","foo2","foo3"], "memory", function(err,foo1,foo2,foo3){
|
||||
if (err === "error2") {
|
||||
@@ -702,6 +766,7 @@ describe('context', function() {
|
||||
stubGet.onSecondCall().callsArgWith(2, null, "bar2");
|
||||
stubGet.onThirdCall().callsArgWith(2, "error3");
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
context.get(["foo1","foo2","foo3"], "memory", function(err,foo1,foo2,foo3){
|
||||
if (err === "error1") {
|
||||
@@ -716,6 +781,7 @@ describe('context', function() {
|
||||
it('should store multiple properties if key and value are arrays', function(done) {
|
||||
Context.init({contextStorage:memoryStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
context.set(["foo1","foo2","foo3"], ["bar1","bar2","bar3"], "memory", function(err){
|
||||
if (err) {
|
||||
@@ -739,6 +805,7 @@ describe('context', function() {
|
||||
it('should deletes multiple properties', function(done) {
|
||||
Context.init({contextStorage:memoryStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
context.set(["foo1","foo2","foo3"], ["bar1","bar2","bar3"], "memory", function(err){
|
||||
if (err) {
|
||||
@@ -777,6 +844,7 @@ describe('context', function() {
|
||||
it('should use null for missing values if the value array is shorter than the key array', function(done) {
|
||||
Context.init({contextStorage:memoryStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
context.set(["foo1","foo2","foo3"], ["bar1","bar2"], "memory", function(err){
|
||||
if (err) {
|
||||
@@ -804,6 +872,7 @@ describe('context', function() {
|
||||
it('should use null for missing values if the value is not array', function(done) {
|
||||
Context.init({contextStorage:memoryStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
context.set(["foo1","foo2","foo3"], "bar1", "memory", function(err){
|
||||
if (err) {
|
||||
@@ -831,6 +900,7 @@ describe('context', function() {
|
||||
it('should ignore the extra values if the value array is longer than the key array', function(done) {
|
||||
Context.init({contextStorage:memoryStorage});
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
context.set(["foo1","foo2","foo3"], ["bar1","bar2","bar3","ignored"], "memory", function(err){
|
||||
if (err) {
|
||||
@@ -859,6 +929,7 @@ describe('context', function() {
|
||||
Context.init({contextStorage:contextStorage});
|
||||
stubSet.onFirstCall().callsArgWith(3, "error2");
|
||||
Context.load().then(function(){
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1","flow");
|
||||
context.set(["foo1","foo2","foo3"], ["bar1","bar2","bar3"], "memory", function(err){
|
||||
if (err === "error2") {
|
||||
@@ -873,6 +944,7 @@ describe('context', function() {
|
||||
it('should throw an error if callback of context.get is not a function', function (done) {
|
||||
Context.init({ contextStorage: memoryStorage });
|
||||
Context.load().then(function () {
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1", "flow");
|
||||
context.get("foo", "memory", "callback");
|
||||
done("should throw an error.");
|
||||
@@ -884,6 +956,7 @@ describe('context', function() {
|
||||
it('should not throw an error if callback of context.get is not specified', function (done) {
|
||||
Context.init({ contextStorage: memoryStorage });
|
||||
Context.load().then(function () {
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1", "flow");
|
||||
context.get("foo", "memory");
|
||||
done();
|
||||
@@ -893,6 +966,7 @@ describe('context', function() {
|
||||
it('should throw an error if callback of context.set is not a function', function (done) {
|
||||
Context.init({ contextStorage: memoryStorage });
|
||||
Context.load().then(function () {
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1", "flow");
|
||||
context.set("foo", "bar", "memory", "callback");
|
||||
done("should throw an error.");
|
||||
@@ -904,6 +978,7 @@ describe('context', function() {
|
||||
it('should not throw an error if callback of context.set is not specified', function (done) {
|
||||
Context.init({ contextStorage: memoryStorage });
|
||||
Context.load().then(function () {
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1", "flow");
|
||||
context.set("foo", "bar", "memory");
|
||||
done();
|
||||
@@ -913,6 +988,7 @@ describe('context', function() {
|
||||
it('should throw an error if callback of context.keys is not a function', function (done) {
|
||||
Context.init({ contextStorage: memoryStorage });
|
||||
Context.load().then(function () {
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1", "flow");
|
||||
context.keys("memory", "callback");
|
||||
done("should throw an error.");
|
||||
@@ -924,6 +1000,7 @@ describe('context', function() {
|
||||
it('should not throw an error if callback of context.keys is not specified', function (done) {
|
||||
Context.init({ contextStorage: memoryStorage });
|
||||
Context.load().then(function () {
|
||||
var flowContext = Context.getFlowContext("flow");
|
||||
var context = Context.get("1", "flow");
|
||||
context.keys("memory");
|
||||
done();
|
||||
@@ -953,7 +1030,6 @@ describe('context', function() {
|
||||
}).catch(done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('delete context',function(){
|
||||
it('should not call delete() when external context storage is used', function(done) {
|
||||
Context.init({contextStorage:contextDefaultStorage});
|
||||
|
@@ -67,7 +67,10 @@ describe('flows/index', function() {
|
||||
});
|
||||
return when.resolve();
|
||||
});
|
||||
credentialsLoad = sinon.stub(credentials,"load",function() {
|
||||
credentialsLoad = sinon.stub(credentials,"load",function(creds) {
|
||||
if (creds && creds.hasOwnProperty("$") && creds['$'] === "fail") {
|
||||
return when.reject("creds error");
|
||||
}
|
||||
return when.resolve();
|
||||
});
|
||||
flowCreate = sinon.stub(Flow,"create",function(parent, global, flow) {
|
||||
@@ -177,6 +180,23 @@ describe('flows/index', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('sets the full flow including credentials', function(done) {
|
||||
var originalConfig = [
|
||||
{id:"t1-1",x:10,y:10,z:"t1",type:"test",wires:[]},
|
||||
{id:"t1",type:"tab"}
|
||||
];
|
||||
var credentials = {"t1-1":{"a":1}};
|
||||
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.setFlows(originalConfig,credentials).then(function() {
|
||||
credentialsClean.called.should.be.false();
|
||||
credentialsLoad.called.should.be.true();
|
||||
credentialsLoad.lastCall.args[0].should.eql(credentials);
|
||||
flows.getFlows().flows.should.eql(originalConfig);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('updates existing flows with partial deployment - nodes', function(done) {
|
||||
var originalConfig = [
|
||||
{id:"t1-1",x:10,y:10,z:"t1",type:"test",wires:[]},
|
||||
@@ -235,6 +255,20 @@ describe('flows/index', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('returns error if it cannot decrypt credentials', function(done) {
|
||||
var originalConfig = [
|
||||
{id:"t1-1",x:10,y:10,z:"t1",type:"test",wires:[]},
|
||||
{id:"t1",type:"tab"}
|
||||
];
|
||||
var credentials = {"$":"fail"};
|
||||
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.setFlows(originalConfig,credentials).then(function() {
|
||||
done("Unexpected success when credentials couldn't be decrypted")
|
||||
}).catch(function(err) {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#load', function() {
|
||||
|
@@ -72,45 +72,52 @@ describe('storage/localfilesystem/library', function() {
|
||||
});
|
||||
|
||||
function createObjectLibrary(type) {
|
||||
type = type ||"object";
|
||||
var objLib = path.join(userDir,"lib",type);
|
||||
type = type || "object";
|
||||
var objLib = path.join(userDir, "lib", type);
|
||||
try {
|
||||
fs.mkdirSync(objLib);
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
}
|
||||
fs.mkdirSync(path.join(objLib,"A"));
|
||||
fs.mkdirSync(path.join(objLib,"B"));
|
||||
fs.mkdirSync(path.join(objLib,"B","C"));
|
||||
fs.mkdirSync(path.join(objLib, "A"));
|
||||
fs.mkdirSync(path.join(objLib, "B"));
|
||||
fs.mkdirSync(path.join(objLib, "B", "C"));
|
||||
fs.mkdirSync(path.join(objLib, "D"));
|
||||
if (type === "functions" || type === "object") {
|
||||
fs.writeFileSync(path.join(objLib,"file1.js"),"// abc: def\n// not a metaline \n\n Hi",'utf8');
|
||||
fs.writeFileSync(path.join(objLib,"B","file2.js"),"// ghi: jkl\n// not a metaline \n\n Hi",'utf8');
|
||||
fs.writeFileSync(path.join(objLib, "file1.js"), "// abc: def\n// not a metaline \n\n Hi", 'utf8');
|
||||
fs.writeFileSync(path.join(objLib, "B", "file2.js"), "// ghi: jkl\n// not a metaline \n\n Hi", 'utf8');
|
||||
fs.writeFileSync(path.join(objLib, "D", "file3.js"), "// mno: 日本語テスト\n\nこんにちわ", 'utf8');
|
||||
}
|
||||
if (type === "flows" || type === "object") {
|
||||
fs.writeFileSync(path.join(objLib,"B","flow.json"),"Hi",'utf8');
|
||||
fs.writeFileSync(path.join(objLib, "B", "flow.json"), "Hi", 'utf8');
|
||||
}
|
||||
}
|
||||
|
||||
it('should return a directory listing of library objects',function(done) {
|
||||
localfilesystemLibrary.init({userDir:userDir}).then(function() {
|
||||
it('should return a directory listing of library objects', function (done) {
|
||||
localfilesystemLibrary.init({userDir: userDir}).then(function () {
|
||||
createObjectLibrary();
|
||||
|
||||
localfilesystemLibrary.getLibraryEntry('object','').then(function(flows) {
|
||||
flows.should.eql([ 'A', 'B', { abc: 'def', fn: 'file1.js' } ]);
|
||||
localfilesystemLibrary.getLibraryEntry('object','B').then(function(flows) {
|
||||
flows.should.eql([ 'C', { ghi: 'jkl', fn: 'file2.js' }, { fn: 'flow.json' } ]);
|
||||
localfilesystemLibrary.getLibraryEntry('object','B/C').then(function(flows) {
|
||||
localfilesystemLibrary.getLibraryEntry('object', '').then(function (flows) {
|
||||
flows.should.eql([ 'A', 'B', 'D', { abc: 'def', fn: 'file1.js' }]);
|
||||
localfilesystemLibrary.getLibraryEntry('object', 'B').then(function (flows) {
|
||||
flows.should.eql([ 'C', { ghi: 'jkl', fn: 'file2.js' }, { fn: 'flow.json' }]);
|
||||
localfilesystemLibrary.getLibraryEntry('object', 'B/C').then(function (flows) {
|
||||
flows.should.eql([]);
|
||||
done();
|
||||
}).catch(function(err) {
|
||||
localfilesystemLibrary.getLibraryEntry('object', 'D').then(function (flows) {
|
||||
flows.should.eql([{ mno: '日本語テスト', fn: 'file3.js' }]);
|
||||
done();
|
||||
}).catch(function (err) {
|
||||
done(err);
|
||||
});
|
||||
}).catch(function (err) {
|
||||
done(err);
|
||||
});
|
||||
}).catch(function(err) {
|
||||
}).catch(function (err) {
|
||||
done(err);
|
||||
});
|
||||
}).catch(function(err) {
|
||||
}).catch(function (err) {
|
||||
done(err);
|
||||
});
|
||||
}).catch(function(err) {
|
||||
}).catch(function (err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
@@ -203,4 +210,35 @@ describe('storage/localfilesystem/library', function() {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return a newly saved library flow (multi-byte character)',function(done) {
|
||||
localfilesystemLibrary.init({userDir:userDir}).then(function() {
|
||||
createObjectLibrary("flows");
|
||||
localfilesystemLibrary.getLibraryEntry('flows','B').then(function(flows) {
|
||||
flows.should.eql([ 'C', {fn:'flow.json'} ]);
|
||||
var ft = path.join("B","D","file4");
|
||||
localfilesystemLibrary.saveLibraryEntry('flows',ft,{mno:'pqr'},"こんにちわこんにちわこんにちわ").then(function() {
|
||||
setTimeout(function() {
|
||||
localfilesystemLibrary.getLibraryEntry('flows',path.join("B","D")).then(function(flows) {
|
||||
flows.should.eql([ { mno: 'pqr', fn: 'file4.json' } ]);
|
||||
localfilesystemLibrary.getLibraryEntry('flows',ft+".json").then(function(body) {
|
||||
body.should.eql("こんにちわこんにちわこんにちわ");
|
||||
done();
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
})
|
||||
}, 50);
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user