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

Merge pull request #1 from node-red/master

node-red/node-red changes
This commit is contained in:
Amo DelBello 2019-12-09 14:54:53 -07:00 committed by GitHub
commit 14c2005bbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 149 additions and 139 deletions

View File

@ -52,8 +52,11 @@ function getFlowFilename() {
} }
function cleanup(flowFile) { function cleanup(flowFile) {
deleteFile(homeDir+"/"+flowFile); var credentialFile = flowFile.replace(/\.json$/, '') + '_cred.json';
deleteFile(homeDir+"/."+flowFile+".backup"); deleteFile(homeDir + "/" + flowFile);
deleteFile(homeDir + "/." + flowFile + ".backup");
deleteFile(homeDir + "/" + credentialFile);
deleteFile(homeDir + "/." + credentialFile + ".backup");
} }
function deleteFile(flowFile) { function deleteFile(flowFile) {

View File

@ -17,7 +17,7 @@
var idMap = { var idMap = {
// input // input
"inject": ".red-ui-palette-node[data-palette-type='inject']", "inject": ".red-ui-palette-node[data-palette-type='inject']",
"httpin": ".red-ui-palette-node[data-palette-type='http in']", "httpIn": ".red-ui-palette-node[data-palette-type='http in']",
"mqttIn": ".red-ui-palette-node[data-palette-type='mqtt in']", "mqttIn": ".red-ui-palette-node[data-palette-type='mqtt in']",
// output // output
"debug": ".red-ui-palette-node[data-palette-type='debug']", "debug": ".red-ui-palette-node[data-palette-type='debug']",
@ -32,7 +32,7 @@ var idMap = {
"html": ".red-ui-palette-node[data-palette-type='html']", "html": ".red-ui-palette-node[data-palette-type='html']",
"json": ".red-ui-palette-node[data-palette-type='json']", "json": ".red-ui-palette-node[data-palette-type='json']",
// storage // storage
"filein": ".red-ui-palette-node[data-palette-type='file in']", "fileIn": ".red-ui-palette-node[data-palette-type='file in']",
}; };
function getId(type) { function getId(type) {

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
**/ **/
var when = require("when"); var when = require("when");
var events = require("nr-test-utils").require("@node-red/runtime/lib/events.js"); var events = require("nr-test-utils").require("@node-red/runtime/lib/events.js");
@ -44,6 +44,7 @@ function addNode(type, x, y) {
previousY = previousY + flowLayout.heightInterval; previousY = previousY + flowLayout.heightInterval;
} }
} }
browser.waitForVisible(palette.getId(type));
browser.moveToObject(palette.getId(type)); browser.moveToObject(palette.getId(type));
browser.buttonDown(); browser.buttonDown();
browser.moveToObject("#red-ui-palette-search", previousX + 300, previousY + 100); // adjust to the top-left corner of workspace. browser.moveToObject("#red-ui-palette-search", previousX + 300, previousY + 100); // adjust to the top-left corner of workspace.
@ -56,7 +57,12 @@ function addNode(type, x, y) {
} }
function deleteAllNodes() { function deleteAllNodes() {
browser.click('.red-ui-workspace-chart-event-layer'); browser.waitForVisible('.red-ui-workspace-chart-event-layer');
try {
browser.click('.red-ui-workspace-chart-event-layer');
} catch (e) {
console.log(e);
}
browser.keys(['Control', 'a', 'a', 'Control']); // call twice to release the keys. browser.keys(['Control', 'a', 'a', 'Control']); // call twice to release the keys.
browser.keys(['Delete']); browser.keys(['Delete']);
} }

View File

@ -47,11 +47,11 @@ injectNode.prototype.setPayload = function(payloadType, payload) {
// Open a payload type list. // Open a payload type list.
browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-container")]'); browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-container")]');
// Select a payload type. // Select a payload type.
var payloadTypeXPath = '//*[@class="red-ui-typedInput-options"]/a[' + payloadTypeList[payloadType] + ']'; var payloadTypeXPath = '//*[contains(@class, "red-ui-typedInput-options")]/a[' + payloadTypeList[payloadType] + ']';
browser.clickWithWait(payloadTypeXPath); browser.clickWithWait(payloadTypeXPath);
if (payload) { if (payload) {
// Input a value. // Input a value.
browser.setValue('//*[@class="red-ui-typedInput-input"]/input', payload); browser.setValue('//*[contains(@class, "red-ui-typedInput-input")]/input', payload);
} }
} }

View File

@ -31,7 +31,7 @@ debugNode.prototype.setOutput = function(complete) {
browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-container")]/button'); browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-container")]/button');
if (complete !== 'true') { if (complete !== 'true') {
// Select the "msg" type. // Select the "msg" type.
browser.clickWithWait('//div[@class="red-ui-typedInput-options"][1]/a[1]'); browser.clickWithWait('//div[contains(@class, "red-ui-typedInput-options")][1]/a[1]');
// Input the path in msg. // Input the path in msg.
browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-input")]/input'); browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-input")]/input');
browser.keys(keyPage.selectAll()); browser.keys(keyPage.selectAll());

View File

@ -23,13 +23,14 @@ function setServer(broker, port) {
function clickOk() { function clickOk() {
browser.clickWithWait('#node-config-dialog-ok'); browser.clickWithWait('#node-config-dialog-ok');
// Wait until an config dialog closes. // Wait until an config dialog closes.
browser.waitForVisible('#node-config-dialog-ok', 2000, true); browser.waitForVisible('#node-config-dialog-ok', 4000, true);
} }
function edit() { function edit() {
browser.clickWithWait('#node-input-lookup-broker'); browser.waitForVisible('#node-input-lookup-broker');
browser.click('#node-input-lookup-broker');
// Wait until a config dialog opens. // Wait until a config dialog opens.
browser.waitForVisible('#node-config-dialog-ok', 2000); browser.waitForVisible('#node-config-dialog-ok', 4000);
} }
module.exports = { module.exports = {

View File

@ -18,18 +18,18 @@ var util = require("util");
var nodePage = require("../../node_page"); var nodePage = require("../../node_page");
function httpinNode(id) { function httpInNode(id) {
nodePage.call(this, id); nodePage.call(this, id);
} }
util.inherits(httpinNode, nodePage); util.inherits(httpInNode, nodePage);
httpinNode.prototype.setMethod = function(method) { httpInNode.prototype.setMethod = function(method) {
browser.selectWithWait('#node-input-method', method); browser.selectWithWait('#node-input-method', method);
} }
httpinNode.prototype.setUrl = function(url) { httpInNode.prototype.setUrl = function(url) {
browser.setValue('#node-input-url', url); browser.setValue('#node-input-url', url);
} }
module.exports = httpinNode; module.exports = httpInNode;

View File

@ -55,7 +55,7 @@ changeNode.prototype.ruleSet = function(p, pt, to, tot, index) {
if (pt) { if (pt) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/button[1]'); browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/button[1]');
var num = 5 * (index - 1) + 1; var num = 5 * (index - 1) + 1;
var ptXPath = '//div[@class="red-ui-typedInput-options"][' + num + ']/a[' + ptType[pt] + ']'; var ptXPath = '//div[contains(@class, "red-ui-typedInput-options")][' + num + ']/a[' + ptType[pt] + ']';
browser.clickWithWait(ptXPath); browser.clickWithWait(ptXPath);
} }
if (p) { if (p) {
@ -64,7 +64,7 @@ changeNode.prototype.ruleSet = function(p, pt, to, tot, index) {
if (tot) { if (tot) {
browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[2]/div[2]/button[1]'); browser.clickWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[2]/div[2]/button[1]');
var num = 5 * (index - 1) + 2; var num = 5 * (index - 1) + 2;
var totXPath = '//div[@class="red-ui-typedInput-options"][' + num + ']/a[' + totType[tot] + ']'; var totXPath = '//div[contains(@class, "red-ui-typedInput-options")][' + num + ']/a[' + totType[tot] + ']';
browser.clickWithWait(totXPath); browser.clickWithWait(totXPath);
} }
if (to) { if (to) {

View File

@ -18,11 +18,11 @@ var util = require("util");
var nodePage = require("../../node_page"); var nodePage = require("../../node_page");
function fileinNode(id) { function fileInNode(id) {
nodePage.call(this, id); nodePage.call(this, id);
} }
util.inherits(fileinNode, nodePage); util.inherits(fileInNode, nodePage);
var formatType = { var formatType = {
"utf8": 1, "utf8": 1,
@ -31,14 +31,14 @@ var formatType = {
"stream": 4 "stream": 4
}; };
fileinNode.prototype.setFilename = function(filename) { fileInNode.prototype.setFilename = function(filename) {
browser.setValue('#node-input-filename', filename); browser.setValue('#node-input-filename', filename);
} }
fileinNode.prototype.setOutput = function(format) { fileInNode.prototype.setOutput = function(format) {
browser.clickWithWait('#node-input-format'); browser.clickWithWait('#node-input-format');
var formatTypeXPath = '//*[@id="node-input-format"]/option[' + formatType[format] + ']'; var formatTypeXPath = '//*[@id="node-input-format"]/option[' + formatType[format] + ']';
browser.clickWithWait(formatTypeXPath); browser.clickWithWait(formatTypeXPath);
} }
module.exports = fileinNode; module.exports = fileInNode;

View File

@ -22,13 +22,13 @@ Node.prototype.edit = function() {
browser.clickWithWait(this.id); browser.clickWithWait(this.id);
browser.clickWithWait(this.id); browser.clickWithWait(this.id);
// Wait until an edit dialog opens. // Wait until an edit dialog opens.
browser.waitForVisible('#node-dialog-ok', 2000); browser.waitForVisible('#node-dialog-ok', 4000);
} }
Node.prototype.clickOk = function() { Node.prototype.clickOk = function() {
browser.clickWithWait('#node-dialog-ok'); browser.clickWithWait('#node-dialog-ok');
// Wait untile an edit dialog closes. // Wait untile an edit dialog closes.
browser.waitForVisible('#node-dialog-ok', 2000, true); browser.waitForVisible('#node-dialog-ok', 4000, true);
browser.pause(50); browser.pause(50);
} }
@ -38,8 +38,10 @@ Node.prototype.connect = function(targetNode) {
browser.dragAndDrop(outputPort, inputPort) browser.dragAndDrop(outputPort, inputPort)
} }
Node.prototype.clickLeftButton = function() { Node.prototype.clickLeftButton = function () {
browser.clickWithWait(this.id + '/*[@class="red-ui-flow-node-button"]'); browser.moveToObject(this.id + '/*[@class="red-ui-flow-node-button"]');
browser.buttonDown();
browser.buttonUp();
} }
module.exports = Node; module.exports = Node;

View File

@ -20,20 +20,20 @@ var templateNode = require('./core/core/80-template_page');
var functionNode = require('./core/core/80-function_page'); var functionNode = require('./core/core/80-function_page');
var mqttInNode = require('./core/io/10-mqttin_page'); var mqttInNode = require('./core/io/10-mqttin_page');
var mqttOutNode = require('./core/io/10-mqttout_page'); var mqttOutNode = require('./core/io/10-mqttout_page');
var httpinNode = require('./core/io/21-httpin_page'); var httpInNode = require('./core/io/21-httpin_page');
var httpResponseNode = require('./core/io/21-httpresponse_page'); var httpResponseNode = require('./core/io/21-httpresponse_page');
var changeNode = require('./core/logic/15-change_page'); var changeNode = require('./core/logic/15-change_page');
var rangeNode = require('./core/logic/16-range_page'); var rangeNode = require('./core/logic/16-range_page');
var httpRequestNode = require('./core/io/21-httprequest_page'); var httpRequestNode = require('./core/io/21-httprequest_page');
var htmlNode = require('./core/parsers/70-HTML_page'); var htmlNode = require('./core/parsers/70-HTML_page');
var jsonNode = require('./core/parsers/70-JSON_page'); var jsonNode = require('./core/parsers/70-JSON_page');
var fileinNode = require('./core/storage/50-filein_page'); var fileInNode = require('./core/storage/50-filein_page');
var nodeCatalog = { var nodeCatalog = {
// input // input
"inject": injectNode, "inject": injectNode,
"httpin": httpinNode, "httpIn": httpInNode,
"mqttIn":mqttInNode, "mqttIn":mqttInNode,
// output // output
"debug": debugNode, "debug": debugNode,
@ -48,7 +48,7 @@ var nodeCatalog = {
"html": htmlNode, "html": htmlNode,
"json":jsonNode, "json":jsonNode,
// storage // storage
"filein": fileinNode, "fileIn": fileInNode,
} }
function create(type, id) { function create(type, id) {

View File

@ -37,7 +37,7 @@ describe('Workspace', function() {
}); });
it('should have a right title', function () { it('should have a right title', function () {
browser.getTitle().should.equal('Node-RED'); browser.getTitle().should.startWith('Node-RED');
}); });
it('should output a timestamp', function() { it('should output a timestamp', function() {

View File

@ -38,14 +38,14 @@ describe('cookbook', function() {
describe('HTTP endpoints', function () { describe('HTTP endpoints', function () {
it('create an HTTP endpoint', function () { it('create an HTTP endpoint', function () {
var httpinNode = workspace.addNode("httpin"); var httpInNode = workspace.addNode("httpIn");
var templateNode = workspace.addNode("template"); var templateNode = workspace.addNode("template");
var httpResponseNode = workspace.addNode("httpResponse"); var httpResponseNode = workspace.addNode("httpResponse");
httpinNode.edit(); httpInNode.edit();
httpinNode.setMethod("get"); httpInNode.setMethod("get");
httpinNode.setUrl("/hello"); httpInNode.setUrl("/hello");
httpinNode.clickOk(); httpInNode.clickOk();
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
@ -53,7 +53,7 @@ describe('cookbook', function() {
templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Hello World!</h1>\n</body>\n</html>"); templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Hello World!</h1>\n</body>\n</html>");
templateNode.clickOk(); templateNode.clickOk();
httpinNode.connect(templateNode); httpInNode.connect(templateNode);
templateNode.connect(httpResponseNode); templateNode.connect(httpResponseNode);
// The code for confirmation starts from here. // The code for confirmation starts from here.
@ -77,14 +77,14 @@ describe('cookbook', function() {
}); });
it('handle query parameters passed to an HTTP endpoint', function () { it('handle query parameters passed to an HTTP endpoint', function () {
var httpinNode = workspace.addNode("httpin"); var httpInNode = workspace.addNode("httpIn");
var templateNode = workspace.addNode("template"); var templateNode = workspace.addNode("template");
var httpResponseNode = workspace.addNode("httpResponse"); var httpResponseNode = workspace.addNode("httpResponse");
httpinNode.edit(); httpInNode.edit();
httpinNode.setMethod("get"); httpInNode.setMethod("get");
httpinNode.setUrl("/hello-query"); httpInNode.setUrl("/hello-query");
httpinNode.clickOk(); httpInNode.clickOk();
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
@ -92,7 +92,7 @@ describe('cookbook', function() {
templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Hello {{req.query.name}}!</h1>\n</body>\n</html>"); templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Hello {{req.query.name}}!</h1>\n</body>\n</html>");
templateNode.clickOk(); templateNode.clickOk();
httpinNode.connect(templateNode); httpInNode.connect(templateNode);
templateNode.connect(httpResponseNode); templateNode.connect(httpResponseNode);
// The code for confirmation starts from here. // The code for confirmation starts from here.
@ -116,14 +116,14 @@ describe('cookbook', function() {
}); });
it('handle url parameters in an HTTP endpoint', function () { it('handle url parameters in an HTTP endpoint', function () {
var httpinNode = workspace.addNode("httpin"); var httpInNode = workspace.addNode("httpIn");
var templateNode = workspace.addNode("template"); var templateNode = workspace.addNode("template");
var httpResponseNode = workspace.addNode("httpResponse"); var httpResponseNode = workspace.addNode("httpResponse");
httpinNode.edit(); httpInNode.edit();
httpinNode.setMethod("get"); httpInNode.setMethod("get");
httpinNode.setUrl("/hello-param/:name"); httpInNode.setUrl("/hello-param/:name");
httpinNode.clickOk(); httpInNode.clickOk();
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
@ -131,7 +131,7 @@ describe('cookbook', function() {
templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Hello {{req.params.name}}!</h1>\n</body>\n</html>"); templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Hello {{req.params.name}}!</h1>\n</body>\n</html>");
templateNode.clickOk(); templateNode.clickOk();
httpinNode.connect(templateNode); httpInNode.connect(templateNode);
templateNode.connect(httpResponseNode); templateNode.connect(httpResponseNode);
// The code for confirmation starts from here. // The code for confirmation starts from here.
@ -155,14 +155,14 @@ describe('cookbook', function() {
}); });
it('access HTTP request headers', function () { it('access HTTP request headers', function () {
var httpinNode = workspace.addNode("httpin"); var httpInNode = workspace.addNode("httpIn");
var templateNode = workspace.addNode("template"); var templateNode = workspace.addNode("template");
var httpResponseNode = workspace.addNode("httpResponse"); var httpResponseNode = workspace.addNode("httpResponse");
httpinNode.edit(); httpInNode.edit();
httpinNode.setMethod("get"); httpInNode.setMethod("get");
httpinNode.setUrl("/hello-headers"); httpInNode.setUrl("/hello-headers");
httpinNode.clickOk(); httpInNode.clickOk();
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
@ -170,7 +170,7 @@ describe('cookbook', function() {
templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>User agent: {{req.headers.user-agent}}</h1>\n</body>\n</html>"); templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>User agent: {{req.headers.user-agent}}</h1>\n</body>\n</html>");
templateNode.clickOk(); templateNode.clickOk();
httpinNode.connect(templateNode); httpInNode.connect(templateNode);
templateNode.connect(httpResponseNode); templateNode.connect(httpResponseNode);
// The code for confirmation starts from here. // The code for confirmation starts from here.
@ -203,7 +203,7 @@ describe('cookbook', function() {
var injectNodeTimestamp = workspace.addNode("inject"); var injectNodeTimestamp = workspace.addNode("inject");
var changeNodeStore = workspace.addNode("change"); var changeNodeStore = workspace.addNode("change");
var httpinNode = workspace.addNode("httpin", 0, 100); var httpInNode = workspace.addNode("httpIn", 0, 100);
var changeNodeCopy = workspace.addNode("change"); var changeNodeCopy = workspace.addNode("change");
var templateNode = workspace.addNode("template"); var templateNode = workspace.addNode("template");
var httpResponseNode = workspace.addNode("httpResponse"); var httpResponseNode = workspace.addNode("httpResponse");
@ -218,10 +218,10 @@ describe('cookbook', function() {
injectNodeTimestamp.connect(changeNodeStore); injectNodeTimestamp.connect(changeNodeStore);
httpinNode.edit(); httpInNode.edit();
httpinNode.setMethod("get"); httpInNode.setMethod("get");
httpinNode.setUrl("/hello-data"); httpInNode.setUrl("/hello-data");
httpinNode.clickOk(); httpInNode.clickOk();
changeNodeCopy.edit(); changeNodeCopy.edit();
changeNodeCopy.ruleSet("timestamp", "msg", "timestamp", "flow"); changeNodeCopy.ruleSet("timestamp", "msg", "timestamp", "flow");
@ -233,7 +233,7 @@ describe('cookbook', function() {
templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Time: {{ timestamp }}</h1>\n</body>\n</html>"); templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Time: {{ timestamp }}</h1>\n</body>\n</html>");
templateNode.clickOk(); templateNode.clickOk();
httpinNode.connect(changeNodeCopy); httpInNode.connect(changeNodeCopy);
changeNodeCopy.connect(templateNode); changeNodeCopy.connect(templateNode);
templateNode.connect(httpResponseNode); templateNode.connect(httpResponseNode);
@ -260,15 +260,15 @@ describe('cookbook', function() {
}); });
it('serve JSON content', function () { it('serve JSON content', function () {
var httpinNode = workspace.addNode("httpin"); var httpInNode = workspace.addNode("httpIn");
var templateNode = workspace.addNode("template"); var templateNode = workspace.addNode("template");
var changeNode = workspace.addNode("change"); var changeNode = workspace.addNode("change");
var httpResponseNode = workspace.addNode("httpResponse"); var httpResponseNode = workspace.addNode("httpResponse");
httpinNode.edit(); httpInNode.edit();
httpinNode.setMethod("get"); httpInNode.setMethod("get");
httpinNode.setUrl("/hello-json"); httpInNode.setUrl("/hello-json");
httpinNode.clickOk(); httpInNode.clickOk();
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
@ -282,7 +282,7 @@ describe('cookbook', function() {
changeNode.ruleSet("headers.content-type", "msg", "application/json", "str", "2"); changeNode.ruleSet("headers.content-type", "msg", "application/json", "str", "2");
changeNode.clickOk(); changeNode.clickOk();
httpinNode.connect(templateNode); httpInNode.connect(templateNode);
templateNode.connect(changeNode); templateNode.connect(changeNode);
changeNode.connect(httpResponseNode); changeNode.connect(httpResponseNode);
@ -314,20 +314,20 @@ describe('cookbook', function() {
}); });
it('serve a local file', function () { it('serve a local file', function () {
var httpinNode = workspace.addNode("httpin"); var httpInNode = workspace.addNode("httpIn");
var fileinNode = workspace.addNode("filein"); var fileInNode = workspace.addNode("fileIn");
var changeNode = workspace.addNode("change", 200, 100); var changeNode = workspace.addNode("change", 200, 100);
var httpResponseNode = workspace.addNode("httpResponse"); var httpResponseNode = workspace.addNode("httpResponse");
httpinNode.edit(); httpInNode.edit();
httpinNode.setMethod("get"); httpInNode.setMethod("get");
httpinNode.setUrl("/hello-file"); httpInNode.setUrl("/hello-file");
httpinNode.clickOk(); httpInNode.clickOk();
fileinNode.edit(); fileInNode.edit();
fileinNode.setFilename("test/resources/file-in-node/test.txt"); fileInNode.setFilename("test/resources/file-in-node/test.txt");
fileinNode.setOutput(""); fileInNode.setOutput("");
fileinNode.clickOk(); fileInNode.clickOk();
changeNode.edit(); changeNode.edit();
changeNode.ruleSet("headers", "msg", "{}", "json"); changeNode.ruleSet("headers", "msg", "{}", "json");
@ -335,8 +335,8 @@ describe('cookbook', function() {
changeNode.ruleSet("headers.content-type", "msg", "text/plain", "str", "2"); changeNode.ruleSet("headers.content-type", "msg", "text/plain", "str", "2");
changeNode.clickOk(); changeNode.clickOk();
httpinNode.connect(fileinNode); httpInNode.connect(fileInNode);
fileinNode.connect(changeNode); fileInNode.connect(changeNode);
changeNode.connect(httpResponseNode); changeNode.connect(httpResponseNode);
// The code for confirmation starts from here. // The code for confirmation starts from here.
@ -360,14 +360,14 @@ describe('cookbook', function() {
}); });
it('post raw data to a flow', function() { it('post raw data to a flow', function() {
var httpinNode = workspace.addNode("httpin"); var httpInNode = workspace.addNode("httpIn");
var templateNode = workspace.addNode("template"); var templateNode = workspace.addNode("template");
var httpResponseNode = workspace.addNode("httpResponse"); var httpResponseNode = workspace.addNode("httpResponse");
httpinNode.edit(); httpInNode.edit();
httpinNode.setMethod("post"); httpInNode.setMethod("post");
httpinNode.setUrl("/hello-raw"); httpInNode.setUrl("/hello-raw");
httpinNode.clickOk(); httpInNode.clickOk();
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
@ -375,7 +375,7 @@ describe('cookbook', function() {
templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Hello {{ payload }}!</h1>\n</body>\n</html>"); templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Hello {{ payload }}!</h1>\n</body>\n</html>");
templateNode.clickOk(); templateNode.clickOk();
httpinNode.connect(templateNode); httpInNode.connect(templateNode);
templateNode.connect(httpResponseNode); templateNode.connect(httpResponseNode);
// The code for confirmation starts from here. // The code for confirmation starts from here.
@ -403,14 +403,14 @@ describe('cookbook', function() {
}); });
it('post form data to a flow', function () { it('post form data to a flow', function () {
var httpinNode = workspace.addNode("httpin"); var httpInNode = workspace.addNode("httpIn");
var templateNode = workspace.addNode("template"); var templateNode = workspace.addNode("template");
var httpResponseNode = workspace.addNode("httpResponse"); var httpResponseNode = workspace.addNode("httpResponse");
httpinNode.edit(); httpInNode.edit();
httpinNode.setMethod("post"); httpInNode.setMethod("post");
httpinNode.setUrl("/hello-form"); httpInNode.setUrl("/hello-form");
httpinNode.clickOk(); httpInNode.clickOk();
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
@ -418,7 +418,7 @@ describe('cookbook', function() {
templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Hello {{ payload.name }}!</h1>\n</body>\n</html>"); templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Hello {{ payload.name }}!</h1>\n</body>\n</html>");
templateNode.clickOk(); templateNode.clickOk();
httpinNode.connect(templateNode); httpInNode.connect(templateNode);
templateNode.connect(httpResponseNode); templateNode.connect(httpResponseNode);
// The code for confirmation starts from here. // The code for confirmation starts from here.
@ -452,14 +452,14 @@ describe('cookbook', function() {
}); });
it('post JSON data to a flow', function() { it('post JSON data to a flow', function() {
var httpinNode = workspace.addNode("httpin"); var httpInNode = workspace.addNode("httpIn");
var templateNode = workspace.addNode("template"); var templateNode = workspace.addNode("template");
var httpResponseNode = workspace.addNode("httpResponse"); var httpResponseNode = workspace.addNode("httpResponse");
httpinNode.edit(); httpInNode.edit();
httpinNode.setMethod("post"); httpInNode.setMethod("post");
httpinNode.setUrl("/hello-json"); httpInNode.setUrl("/hello-json");
httpinNode.clickOk(); httpInNode.clickOk();
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
@ -467,7 +467,7 @@ describe('cookbook', function() {
templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Hello {{ payload.name }}!</h1>\n</body>\n</html>"); templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Hello {{ payload.name }}!</h1>\n</body>\n</html>");
templateNode.clickOk(); templateNode.clickOk();
httpinNode.connect(templateNode); httpInNode.connect(templateNode);
templateNode.connect(httpResponseNode); templateNode.connect(httpResponseNode);
// The code for confirmation starts from here. // The code for confirmation starts from here.
@ -501,24 +501,22 @@ describe('cookbook', function() {
}); });
it('work with cookies', function () { it('work with cookies', function () {
this.timeout(60000); var httpInNodeFormat = workspace.addNode("httpIn");
var httpinNodeFormat = workspace.addNode("httpin");
var functionNodeFormat = workspace.addNode("function", 240); var functionNodeFormat = workspace.addNode("function", 240);
var templateNode = workspace.addNode("template", 400); var templateNode = workspace.addNode("template", 400);
var httpResponseNode = workspace.addNode("httpResponse", 600); var httpResponseNode = workspace.addNode("httpResponse", 600);
var httpinNodeAdd = workspace.addNode("httpin", 0, 100); var httpInNodeAdd = workspace.addNode("httpIn", 0, 100);
var functionNodeAdd = workspace.addNode("function", 240); var functionNodeAdd = workspace.addNode("function", 240);
var changeNode = workspace.addNode("change", 400); var changeNode = workspace.addNode("change", 400);
var httpinNodeClear = workspace.addNode("httpin", 0, 200); var httpInNodeClear = workspace.addNode("httpIn", 0, 200);
var functionNodeClear = workspace.addNode("function", 250); var functionNodeClear = workspace.addNode("function", 250);
httpinNodeFormat.edit(); httpInNodeFormat.edit();
httpinNodeFormat.setMethod("get"); httpInNodeFormat.setMethod("get");
httpinNodeFormat.setUrl("/hello-cookie"); httpInNodeFormat.setUrl("/hello-cookie");
httpinNodeFormat.clickOk(); httpInNodeFormat.clickOk();
functionNodeFormat.edit(); functionNodeFormat.edit();
functionNodeFormat.setFunction("msg.payload = JSON.stringify(msg.req.cookies,null,4);\nreturn msg;"); functionNodeFormat.setFunction("msg.payload = JSON.stringify(msg.req.cookies,null,4);\nreturn msg;");
@ -530,14 +528,14 @@ describe('cookbook', function() {
templateNode.setTemplate('<html>\n<head></head>\n<body>\n<h1>Cookies</h1>\n<p></p><a href="hello-cookie/add">Add a cookie</a> &bull; <a href="hello-cookie/clear">Clear cookies</a></p>\n<pre>{{ payload }}</pre>\n</body>\n</html>'); templateNode.setTemplate('<html>\n<head></head>\n<body>\n<h1>Cookies</h1>\n<p></p><a href="hello-cookie/add">Add a cookie</a> &bull; <a href="hello-cookie/clear">Clear cookies</a></p>\n<pre>{{ payload }}</pre>\n</body>\n</html>');
templateNode.clickOk(); templateNode.clickOk();
httpinNodeFormat.connect(functionNodeFormat); httpInNodeFormat.connect(functionNodeFormat);
functionNodeFormat.connect(templateNode); functionNodeFormat.connect(templateNode);
templateNode.connect(httpResponseNode); templateNode.connect(httpResponseNode);
httpinNodeAdd.edit(); httpInNodeAdd.edit();
httpinNodeAdd.setMethod("get"); httpInNodeAdd.setMethod("get");
httpinNodeAdd.setUrl("/hello-cookie/add"); httpInNodeAdd.setUrl("/hello-cookie/add");
httpinNodeAdd.clickOk(); httpInNodeAdd.clickOk();
functionNodeAdd.edit(); functionNodeAdd.edit();
functionNodeAdd.setFunction('msg.cookies = { };\n msg.cookies["demo-"+(Math.floor(Math.random()*1000))] = Date.now();\nreturn msg;'); functionNodeAdd.setFunction('msg.cookies = { };\n msg.cookies["demo-"+(Math.floor(Math.random()*1000))] = Date.now();\nreturn msg;');
@ -551,20 +549,20 @@ describe('cookbook', function() {
changeNode.ruleSet("headers.location", "msg", httpNodeRoot + "/hello-cookie", "str", "3"); changeNode.ruleSet("headers.location", "msg", httpNodeRoot + "/hello-cookie", "str", "3");
changeNode.clickOk(); changeNode.clickOk();
httpinNodeAdd.connect(functionNodeAdd); httpInNodeAdd.connect(functionNodeAdd);
functionNodeAdd.connect(changeNode); functionNodeAdd.connect(changeNode);
changeNode.connect(httpResponseNode); changeNode.connect(httpResponseNode);
httpinNodeClear.edit(); httpInNodeClear.edit();
httpinNodeClear.setMethod("get"); httpInNodeClear.setMethod("get");
httpinNodeClear.setUrl("/hello-cookie/clear"); httpInNodeClear.setUrl("/hello-cookie/clear");
httpinNodeClear.clickOk(); httpInNodeClear.clickOk();
functionNodeClear.edit(); functionNodeClear.edit();
functionNodeClear.setFunction("var cookieNames = Object.keys(msg.req.cookies).filter(function(cookieName) { return /^demo-/.test(cookieName);});\nmsg.cookies = {};\n\ncookieNames.forEach(function(cookieName) {\n msg.cookies[cookieName] = null;\n});\nreturn msg;\n"); functionNodeClear.setFunction("var cookieNames = Object.keys(msg.req.cookies).filter(function(cookieName) { return /^demo-/.test(cookieName);});\nmsg.cookies = {};\n\ncookieNames.forEach(function(cookieName) {\n msg.cookies[cookieName] = null;\n});\nreturn msg;\n");
functionNodeClear.clickOk(); functionNodeClear.clickOk();
httpinNodeClear.connect(functionNodeClear); httpInNodeClear.connect(functionNodeClear);
functionNodeClear.connect(changeNode); functionNodeClear.connect(changeNode);
workspace.deploy(); workspace.deploy();

View File

@ -284,14 +284,14 @@ describe('cookbook', function() {
httpRequetNode.connect(debugNode); httpRequetNode.connect(debugNode);
// The code for confirmation starts from here. // The code for confirmation starts from here.
var httpinNode = workspace.addNode("httpin", 0, 200); var httpInNode = workspace.addNode("httpIn", 0, 200);
var templateNode = workspace.addNode("template"); var templateNode = workspace.addNode("template");
var httpResponseNode = workspace.addNode("httpResponse"); var httpResponseNode = workspace.addNode("httpResponse");
httpinNode.edit(); httpInNode.edit();
httpinNode.setMethod("get"); httpInNode.setMethod("get");
httpinNode.setUrl("/set-query"); httpInNode.setUrl("/set-query");
httpinNode.clickOk(); httpInNode.clickOk();
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
@ -299,7 +299,7 @@ describe('cookbook', function() {
templateNode.setTemplate("Hello {{req.query.q}}"); templateNode.setTemplate("Hello {{req.query.q}}");
templateNode.clickOk(); templateNode.clickOk();
httpinNode.connect(templateNode); httpInNode.connect(templateNode);
templateNode.connect(httpResponseNode); templateNode.connect(httpResponseNode);
// The code for confirmation ends here. // The code for confirmation ends here.
@ -339,15 +339,15 @@ describe('cookbook', function() {
httpRequetNode.connect(debugNode); httpRequetNode.connect(debugNode);
// The code for confirmation starts from here. // The code for confirmation starts from here.
var httpinNode = workspace.addNode("httpin", 0, 200); var httpInNode = workspace.addNode("httpIn", 0, 200);
var templateNode = workspace.addNode("template"); var templateNode = workspace.addNode("template");
var changeNodeSetHeader = workspace.addNode("change"); var changeNodeSetHeader = workspace.addNode("change");
var httpResponseNode = workspace.addNode("httpResponse"); var httpResponseNode = workspace.addNode("httpResponse");
httpinNode.edit(); httpInNode.edit();
httpinNode.setMethod("get"); httpInNode.setMethod("get");
httpinNode.setUrl("/json-response"); httpInNode.setUrl("/json-response");
httpinNode.clickOk(); httpInNode.clickOk();
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
@ -359,7 +359,7 @@ describe('cookbook', function() {
changeNodeSetHeader.ruleSet("headers", "msg", '{"content-type":"application/json"}', "json"); changeNodeSetHeader.ruleSet("headers", "msg", '{"content-type":"application/json"}', "json");
changeNodeSetHeader.clickOk(); changeNodeSetHeader.clickOk();
httpinNode.connect(templateNode); httpInNode.connect(templateNode);
templateNode.connect(changeNodeSetHeader); templateNode.connect(changeNodeSetHeader);
changeNodeSetHeader.connect(httpResponseNode); changeNodeSetHeader.connect(httpResponseNode);
// The code for confirmation ends here. // The code for confirmation ends here.
@ -413,14 +413,14 @@ describe('cookbook', function() {
httpRequetNode.connect(debugNode); httpRequetNode.connect(debugNode);
// The code for confirmation starts from here. // The code for confirmation starts from here.
var httpinNode = workspace.addNode("httpin", 0, 200); var httpInNode = workspace.addNode("httpIn", 0, 200);
var templateNode = workspace.addNode("template"); var templateNode = workspace.addNode("template");
var httpResponseNode = workspace.addNode("httpResponse"); var httpResponseNode = workspace.addNode("httpResponse");
httpinNode.edit(); httpInNode.edit();
httpinNode.setMethod("post"); httpInNode.setMethod("post");
httpinNode.setUrl("/set-header"); httpInNode.setUrl("/set-header");
httpinNode.clickOk(); httpInNode.clickOk();
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
@ -428,7 +428,7 @@ describe('cookbook', function() {
templateNode.setTemplate("{{ payload }}"); templateNode.setTemplate("{{ payload }}");
templateNode.clickOk(); templateNode.clickOk();
httpinNode.connect(templateNode); httpInNode.connect(templateNode);
templateNode.connect(httpResponseNode); templateNode.connect(httpResponseNode);
// The code for confirmation ends here. // The code for confirmation ends here.

View File

@ -64,9 +64,9 @@ exports.config = {
'goog:chromeOptions': { 'goog:chromeOptions': {
args: process.env.NODE_RED_NON_HEADLESS args: process.env.NODE_RED_NON_HEADLESS
// Runs tests with opening a browser. // Runs tests with opening a browser.
? ['--disable-gpu'] ? ['--disable-gpu', '--no-sandbox']
// Runs tests without opening a browser. // Runs tests without opening a browser.
: ['--headless', '--disable-gpu', 'window-size=1920,1080'] : ['--headless', '--disable-gpu', 'window-size=1920,1080', '--no-sandbox']
}, },
}], }],
// //