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

Fixed the problems that were caused by timing issue

This commit is contained in:
nakanishi 2018-08-27 17:34:04 +09:00
parent 72fe30892e
commit ecc4973645
9 changed files with 31 additions and 20 deletions

View File

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

View File

@ -25,11 +25,11 @@ function templateNode(id) {
util.inherits(templateNode, nodePage); util.inherits(templateNode, nodePage);
templateNode.prototype.setSyntax = function(syntax) { templateNode.prototype.setSyntax = function(syntax) {
browser.selectByValue('#node-input-syntax', syntax); browser.selectWithWait('#node-input-syntax', syntax);
} }
templateNode.prototype.setFormat = function(format) { templateNode.prototype.setFormat = function(format) {
browser.selectByValue('#node-input-format', format); browser.selectWithWait('#node-input-format', format);
} }
templateNode.prototype.setTemplate = function(template) { templateNode.prototype.setTemplate = function(template) {

View File

@ -25,7 +25,7 @@ function httpinNode(id) {
util.inherits(httpinNode, nodePage); util.inherits(httpinNode, nodePage);
httpinNode.prototype.setMethod = function(method) { httpinNode.prototype.setMethod = function(method) {
browser.selectByValue('#node-input-method', method); browser.selectWithWait('#node-input-method', method);
} }
httpinNode.prototype.setUrl = function(url) { httpinNode.prototype.setUrl = function(url) {

View File

@ -29,11 +29,11 @@ httpRequestNode.prototype.setUrl = function(url) {
} }
httpRequestNode.prototype.setMethod = function(method) { httpRequestNode.prototype.setMethod = function(method) {
browser.selectByValue('#node-input-method', method); browser.selectWithWait('#node-input-method', method);
} }
httpRequestNode.prototype.setReturn = function(ret) { httpRequestNode.prototype.setReturn = function(ret) {
browser.selectByValue('#node-input-ret', ret); browser.selectWithWait('#node-input-ret', ret);
} }
module.exports = httpRequestNode; module.exports = httpRequestNode;

View File

@ -45,7 +45,7 @@ var ptType = {
}; };
function setT(t, index) { function setT(t, index) {
browser.selectByValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/select', t); browser.selectWithWait('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/select', t);
} }
// It is better to create a function whose input value is the object type in the future, // It is better to create a function whose input value is the object type in the future,

View File

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

View File

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

View File

@ -185,7 +185,7 @@ describe('cookbook', function() {
var debugNode = workspace.addNode("debug", nodeWidth * 3, nodeHeight); var debugNode = workspace.addNode("debug", nodeWidth * 3, nodeHeight);
changeNode.edit(); changeNode.edit();
changeNode.ruleSet("headers", "msg", "{\"user-agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64)\"}", "json"); changeNode.ruleSet("headers", "msg", '{"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64)"}', "json");
changeNode.clickOk(); changeNode.clickOk();
httpRequestNode.edit(); httpRequestNode.edit();
@ -280,7 +280,7 @@ describe('cookbook', function() {
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
templateNode.setFormat("handlebars"); templateNode.setFormat("handlebars");
templateNode.setTemplate("{ \"Hello\": \"World\" }"); templateNode.setTemplate('{ "Hello": "World" }');
templateNode.clickOk(); templateNode.clickOk();
changeNode.edit(); changeNode.edit();
@ -440,7 +440,7 @@ describe('cookbook', function() {
injectNode.clickOk(); injectNode.clickOk();
changeNode.edit(); changeNode.edit();
changeNode.ruleSet("headers", "msg", "{\"content-type\":\"application/x-www-form-urlencoded\"}", "json"); changeNode.ruleSet("headers", "msg", '{"content-type":"application/x-www-form-urlencoded"}', "json");
changeNode.clickOk(); changeNode.clickOk();
httpRequestNode.edit(); httpRequestNode.edit();
@ -486,11 +486,11 @@ describe('cookbook', function() {
var debugNode = workspace.addNode("debug", nodeWidth * 3, nodeHeight); var debugNode = workspace.addNode("debug", nodeWidth * 3, nodeHeight);
injectNode.edit() injectNode.edit()
injectNode.setPayload("json", "{\"name\":\"Nick\"}"); injectNode.setPayload("json", '{"name":"Nick"}');
injectNode.clickOk(); injectNode.clickOk();
changeNode.edit(); changeNode.edit();
changeNode.ruleSet("headers", "msg", "{\"content-type\":\"application/json\"}", "json"); changeNode.ruleSet("headers", "msg", '{"content-type":"application/json"}', "json");
changeNode.clickOk(); changeNode.clickOk();
httpRequestNode.edit(); httpRequestNode.edit();
@ -531,13 +531,13 @@ describe('cookbook', function() {
httpinNodeFormat.clickOk(); httpinNodeFormat.clickOk();
functionNodeFormat.edit(); functionNodeFormat.edit();
functionNodeFormat.setFunction("msg.payload = JSON.stringify(msg.req.cookies,null,4);"); functionNodeFormat.setFunction("msg.payload = JSON.stringify(msg.req.cookies,null,4);\nreturn msg;");
functionNodeFormat.clickOk(); functionNodeFormat.clickOk();
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
templateNode.setFormat("handlebars"); templateNode.setFormat("handlebars");
templateNode.setTemplate("<html>\n<head></head>\n<body>\n<h1>Cookies</h1>\n<p></p><a href=\"hello-cookie/add\">Add a cookie</a> &bull; <a href=\"hello-cookie/clear\">Clear cookies</a></p>\n<pre>{{ payload }}</pre>\n</body>\n</html>"); templateNode.setTemplate('<html>\n<head></head>\n<body>\n<h1>Cookies</h1>\n<p></p><a href="hello-cookie/add">Add a cookie</a> &bull; <a href="hello-cookie/clear">Clear cookies</a></p>\n<pre>{{ payload }}</pre>\n</body>\n</html>');
templateNode.clickOk(); templateNode.clickOk();
httpinNodeFormat.connect(functionNodeFormat); httpinNodeFormat.connect(functionNodeFormat);
@ -550,7 +550,7 @@ describe('cookbook', function() {
httpinNodeAdd.clickOk(); httpinNodeAdd.clickOk();
functionNodeAdd.edit(); functionNodeAdd.edit();
functionNodeAdd.setFunction("msg.cookies = { };\n msg.cookies[\"demo-\"+(Math.floor(Math.random()*1000))] = Date.now();"); functionNodeAdd.setFunction('msg.cookies = { };\n msg.cookies["demo-"+(Math.floor(Math.random()*1000))] = Date.now();\nreturn msg;');
functionNodeAdd.clickOk(); functionNodeAdd.clickOk();
changeNode.edit(); changeNode.edit();
@ -571,7 +571,7 @@ describe('cookbook', function() {
httpinNodeClear.clickOk(); httpinNodeClear.clickOk();
functionNodeClear.edit(); functionNodeClear.edit();
functionNodeClear.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});\n\n"); functionNodeClear.setFunction("var cookieNames = Object.keys(msg.req.cookies).filter(function(cookieName) { return /^demo-/.test(cookieName);});\nmsg.cookies = {};\n\ncookieNames.forEach(function(cookieName) {\n msg.cookies[cookieName] = null;\n});\nreturn msg;\n");
functionNodeClear.clickOk(); functionNodeClear.clickOk();
httpinNodeClear.connect(functionNodeClear); httpinNodeClear.connect(functionNodeClear);

View File

@ -364,11 +364,11 @@ describe('cookbook', function() {
templateNode.edit(); templateNode.edit();
templateNode.setSyntax("mustache"); templateNode.setSyntax("mustache");
templateNode.setFormat("handlebars"); templateNode.setFormat("handlebars");
templateNode.setTemplate("{\"title\": \"Hello\"}"); templateNode.setTemplate('{"title": "Hello"}');
templateNode.clickOk(); templateNode.clickOk();
changeNodeSetHeader.edit(); changeNodeSetHeader.edit();
changeNodeSetHeader.ruleSet("headers", "msg", "{\"content-type\":\"application/json\"}", "json"); changeNodeSetHeader.ruleSet("headers", "msg", '{"content-type":"application/json"}', "json");
changeNodeSetHeader.clickOk(); changeNodeSetHeader.clickOk();
httpinNode.connect(templateNode); httpinNode.connect(templateNode);
@ -413,7 +413,7 @@ describe('cookbook', function() {
var debugNode = workspace.addNode("debug", nodeWidth * 3); var debugNode = workspace.addNode("debug", nodeWidth * 3);
functionNode.edit(); functionNode.edit();
functionNode.setFunction("msg.payload = \"data to post\";"); functionNode.setFunction('msg.payload = "data to post";\nreturn msg;');
functionNode.clickOk(); functionNode.clickOk();
httpRequetNode.edit(); httpRequetNode.edit();