From ecc49736459ae723d5328009edded84a366262d5 Mon Sep 17 00:00:00 2001 From: nakanishi Date: Mon, 27 Aug 2018 17:34:04 +0900 Subject: [PATCH] Fixed the problems that were caused by timing issue --- .../nodes/core/core/80-function_page.js | 7 ++++++- .../nodes/core/core/80-template_page.js | 4 ++-- .../nodes/core/io/21-httpin_page.js | 2 +- .../nodes/core/io/21-httprequest_page.js | 4 ++-- .../nodes/core/logic/15-change_page.js | 2 +- .../nodes/core/logic/16-range_page.js | 2 +- test/editor/pageobjects/util/util_page.js | 6 ++++++ .../specs/scenario/cookbook_endpoint_uispec.js | 18 +++++++++--------- test/editor/specs/scenario/cookbook_uispec.js | 6 +++--- 9 files changed, 31 insertions(+), 20 deletions(-) diff --git a/test/editor/pageobjects/nodes/core/core/80-function_page.js b/test/editor/pageobjects/nodes/core/core/80-function_page.js index 56082c8a6..238ce06f9 100644 --- a/test/editor/pageobjects/nodes/core/core/80-function_page.js +++ b/test/editor/pageobjects/nodes/core/core/80-function_page.js @@ -28,8 +28,13 @@ functionNode.prototype.setFunction = function(func) { browser.click('#node-input-func-editor'); browser.keys(['Control', 'Home', 'Control']); 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; diff --git a/test/editor/pageobjects/nodes/core/core/80-template_page.js b/test/editor/pageobjects/nodes/core/core/80-template_page.js index a72be1347..01e3a6af3 100644 --- a/test/editor/pageobjects/nodes/core/core/80-template_page.js +++ b/test/editor/pageobjects/nodes/core/core/80-template_page.js @@ -25,11 +25,11 @@ function templateNode(id) { util.inherits(templateNode, nodePage); templateNode.prototype.setSyntax = function(syntax) { - browser.selectByValue('#node-input-syntax', syntax); + browser.selectWithWait('#node-input-syntax', syntax); } templateNode.prototype.setFormat = function(format) { - browser.selectByValue('#node-input-format', format); + browser.selectWithWait('#node-input-format', format); } templateNode.prototype.setTemplate = function(template) { diff --git a/test/editor/pageobjects/nodes/core/io/21-httpin_page.js b/test/editor/pageobjects/nodes/core/io/21-httpin_page.js index 7c81ae2d7..97648f395 100644 --- a/test/editor/pageobjects/nodes/core/io/21-httpin_page.js +++ b/test/editor/pageobjects/nodes/core/io/21-httpin_page.js @@ -25,7 +25,7 @@ function httpinNode(id) { util.inherits(httpinNode, nodePage); httpinNode.prototype.setMethod = function(method) { - browser.selectByValue('#node-input-method', method); + browser.selectWithWait('#node-input-method', method); } httpinNode.prototype.setUrl = function(url) { diff --git a/test/editor/pageobjects/nodes/core/io/21-httprequest_page.js b/test/editor/pageobjects/nodes/core/io/21-httprequest_page.js index d317ec103..b2ca812e3 100644 --- a/test/editor/pageobjects/nodes/core/io/21-httprequest_page.js +++ b/test/editor/pageobjects/nodes/core/io/21-httprequest_page.js @@ -29,11 +29,11 @@ httpRequestNode.prototype.setUrl = function(url) { } httpRequestNode.prototype.setMethod = function(method) { - browser.selectByValue('#node-input-method', method); + browser.selectWithWait('#node-input-method', method); } httpRequestNode.prototype.setReturn = function(ret) { - browser.selectByValue('#node-input-ret', ret); + browser.selectWithWait('#node-input-ret', ret); } module.exports = httpRequestNode; diff --git a/test/editor/pageobjects/nodes/core/logic/15-change_page.js b/test/editor/pageobjects/nodes/core/logic/15-change_page.js index 4d31c1b72..1336e8069 100644 --- a/test/editor/pageobjects/nodes/core/logic/15-change_page.js +++ b/test/editor/pageobjects/nodes/core/logic/15-change_page.js @@ -45,7 +45,7 @@ var ptType = { }; 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, diff --git a/test/editor/pageobjects/nodes/core/logic/16-range_page.js b/test/editor/pageobjects/nodes/core/logic/16-range_page.js index 63fcd9df8..230929995 100644 --- a/test/editor/pageobjects/nodes/core/logic/16-range_page.js +++ b/test/editor/pageobjects/nodes/core/logic/16-range_page.js @@ -25,7 +25,7 @@ function rangeNode(id) { util.inherits(rangeNode, nodePage); 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) { diff --git a/test/editor/pageobjects/util/util_page.js b/test/editor/pageobjects/util/util_page.js index e2b6c3177..a53dae06a 100644 --- a/test/editor/pageobjects/util/util_page.js +++ b/test/editor/pageobjects/util/util_page.js @@ -38,6 +38,12 @@ function init() { var ret = browser.getText(selector); return ret; }, false); + + browser.addCommand("selectWithWait", function(selector, value) { + browser.waitForVisible(selector, 5000); + var ret = browser.selectByValue(selector, value); + return ret; + }, false); } module.exports = { diff --git a/test/editor/specs/scenario/cookbook_endpoint_uispec.js b/test/editor/specs/scenario/cookbook_endpoint_uispec.js index f0eeea2fe..bb54da557 100644 --- a/test/editor/specs/scenario/cookbook_endpoint_uispec.js +++ b/test/editor/specs/scenario/cookbook_endpoint_uispec.js @@ -185,7 +185,7 @@ describe('cookbook', function() { var debugNode = workspace.addNode("debug", nodeWidth * 3, nodeHeight); 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(); httpRequestNode.edit(); @@ -280,7 +280,7 @@ describe('cookbook', function() { templateNode.edit(); templateNode.setSyntax("mustache"); templateNode.setFormat("handlebars"); - templateNode.setTemplate("{ \"Hello\": \"World\" }"); + templateNode.setTemplate('{ "Hello": "World" }'); templateNode.clickOk(); changeNode.edit(); @@ -440,7 +440,7 @@ describe('cookbook', function() { injectNode.clickOk(); 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(); httpRequestNode.edit(); @@ -486,11 +486,11 @@ describe('cookbook', function() { var debugNode = workspace.addNode("debug", nodeWidth * 3, nodeHeight); injectNode.edit() - injectNode.setPayload("json", "{\"name\":\"Nick\"}"); + injectNode.setPayload("json", '{"name":"Nick"}'); injectNode.clickOk(); changeNode.edit(); - changeNode.ruleSet("headers", "msg", "{\"content-type\":\"application/json\"}", "json"); + changeNode.ruleSet("headers", "msg", '{"content-type":"application/json"}', "json"); changeNode.clickOk(); httpRequestNode.edit(); @@ -531,13 +531,13 @@ describe('cookbook', function() { httpinNodeFormat.clickOk(); 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(); templateNode.edit(); templateNode.setSyntax("mustache"); templateNode.setFormat("handlebars"); - templateNode.setTemplate("\n\n\n

Cookies

\n

Add a cookieClear cookies

\n
{{ payload }}
\n\n"); + templateNode.setTemplate('\n\n\n

Cookies

\n

Add a cookieClear cookies

\n
{{ payload }}
\n\n'); templateNode.clickOk(); httpinNodeFormat.connect(functionNodeFormat); @@ -550,7 +550,7 @@ describe('cookbook', function() { httpinNodeAdd.clickOk(); 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(); changeNode.edit(); @@ -571,7 +571,7 @@ describe('cookbook', function() { httpinNodeClear.clickOk(); 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(); httpinNodeClear.connect(functionNodeClear); diff --git a/test/editor/specs/scenario/cookbook_uispec.js b/test/editor/specs/scenario/cookbook_uispec.js index 834eadd02..20bc4fe39 100644 --- a/test/editor/specs/scenario/cookbook_uispec.js +++ b/test/editor/specs/scenario/cookbook_uispec.js @@ -364,11 +364,11 @@ describe('cookbook', function() { templateNode.edit(); templateNode.setSyntax("mustache"); templateNode.setFormat("handlebars"); - templateNode.setTemplate("{\"title\": \"Hello\"}"); + templateNode.setTemplate('{"title": "Hello"}'); templateNode.clickOk(); changeNodeSetHeader.edit(); - changeNodeSetHeader.ruleSet("headers", "msg", "{\"content-type\":\"application/json\"}", "json"); + changeNodeSetHeader.ruleSet("headers", "msg", '{"content-type":"application/json"}', "json"); changeNodeSetHeader.clickOk(); httpinNode.connect(templateNode); @@ -413,7 +413,7 @@ describe('cookbook', function() { var debugNode = workspace.addNode("debug", nodeWidth * 3); functionNode.edit(); - functionNode.setFunction("msg.payload = \"data to post\";"); + functionNode.setFunction('msg.payload = "data to post";\nreturn msg;'); functionNode.clickOk(); httpRequetNode.edit();