diff --git a/test/editor/editor_helper.js b/test/editor/editor_helper.js index 2cf103188..a6a25429f 100644 --- a/test/editor/editor_helper.js +++ b/test/editor/editor_helper.js @@ -75,7 +75,6 @@ module.exports = { var flowFilename = getFlowFilename(); browser.windowHandleMaximize(); browser.call(function () { - // return when.promise(function(resolve, reject) { return new Promise(function(resolve, reject) { cleanup(flowFilename); app.use("/",express.static("public")); diff --git a/test/editor/pageobjects/editor/debugTab_page.js b/test/editor/pageobjects/editor/debugTab_page.js index 3964d3f5d..99905c9cd 100644 --- a/test/editor/pageobjects/editor/debugTab_page.js +++ b/test/editor/pageobjects/editor/debugTab_page.js @@ -14,8 +14,13 @@ * limitations under the License. **/ -function open() { +function open(retainMessage) { browser.clickWithWait('#red-ui-tab-debug-link-button'); + + if (!retainMessage) { + // Clear old messages + browser.clickWithWait('//a[@id="debug-tab-clear"]'); + } } function getMessage(index) { diff --git a/test/editor/pageobjects/editor/workspace_page.js b/test/editor/pageobjects/editor/workspace_page.js index c212f17d3..b6c318879 100644 --- a/test/editor/pageobjects/editor/workspace_page.js +++ b/test/editor/pageobjects/editor/workspace_page.js @@ -73,6 +73,8 @@ function deploy() { }); }); browser.waitForText('#btn-deploy', 2000); + // Need additional wait until buttons becomes clickable. + browser.pause(50); } function init(width, height) { 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 238ce06f9..a692e0149 100644 --- a/test/editor/pageobjects/nodes/core/core/80-function_page.js +++ b/test/editor/pageobjects/nodes/core/core/80-function_page.js @@ -34,7 +34,7 @@ functionNode.prototype.setFunction = function(func) { browser.keys(['Control', 'Shift', 'End', 'Shift', 'Control']); browser.keys(['Delete']); // Need to wait until ace editor correctly checks the syntax. - browser.pause(50); + browser.pause(300); } 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 01e3a6af3..7d2ad0c82 100644 --- a/test/editor/pageobjects/nodes/core/core/80-template_page.js +++ b/test/editor/pageobjects/nodes/core/core/80-template_page.js @@ -41,6 +41,8 @@ templateNode.prototype.setTemplate = function(template) { } browser.keys(['Control', 'Shift', 'End', 'Shift', 'Control']); browser.keys(['Delete']); + // Need to wait until ace editor correctly checks the syntax. + browser.pause(300); } module.exports = templateNode; diff --git a/test/editor/pageobjects/nodes/node_page.js b/test/editor/pageobjects/nodes/node_page.js index 3937f15b7..fc16c873a 100644 --- a/test/editor/pageobjects/nodes/node_page.js +++ b/test/editor/pageobjects/nodes/node_page.js @@ -29,6 +29,7 @@ Node.prototype.clickOk = function() { browser.clickWithWait('#node-dialog-ok'); // Wait untile an edit dialog closes. browser.waitForVisible('#node-dialog-ok', 2000, true); + browser.pause(50); } Node.prototype.connect = function(targetNode) { diff --git a/test/editor/pageobjects/util/util_page.js b/test/editor/pageobjects/util/util_page.js index a53dae06a..02508c831 100644 --- a/test/editor/pageobjects/util/util_page.js +++ b/test/editor/pageobjects/util/util_page.js @@ -14,35 +14,68 @@ * limitations under the License. **/ +var waitTime = 5000; + +function repeatUntilSuccess(operation, args) { + // Wait at most 10 seconds. + for (var i = 0; i < 200; i++) { + try { + var ret = operation(args); + return ret; + } catch (e) { + if (i === 199) { + console.trace(); + throw e; + } + browser.pause(50); + } + } +} + function init() { browser.addCommand("clickWithWait", function(selector) { - browser.waitForVisible(selector); - // Wait at most 10 seconds. - for (var i = 0; i < 50; i++) { - try { - var ret = browser.click(selector); - return ret; - } catch (err) { - if (err.message.indexOf('is not clickable') !== -1) { - browser.pause(200); - } else { - throw err; - } - } + try { + // This is necessary because there is a case that the target may exist but still moving. + browser.pause(50); + browser.waitForVisible(selector); + + var ret = repeatUntilSuccess(function(selector) { + return browser.click(selector); + }, selector); + return ret; + } catch (e) { + console.trace(); + throw e; } }, false); browser.addCommand("getTextWithWait", function(selector) { - browser.waitForExist(selector); - browser.waitForValue(selector); - var ret = browser.getText(selector); - return ret; + try { + browser.waitForExist(selector); + browser.waitForValue(selector); + + var ret = repeatUntilSuccess(function(selector) { + return browser.getText(selector); + }, selector); + return ret; + } catch (e) { + console.trace(); + throw e; + } }, false); browser.addCommand("selectWithWait", function(selector, value) { - browser.waitForVisible(selector, 5000); - var ret = browser.selectByValue(selector, value); - return ret; + try { + browser.waitForVisible(selector, waitTime); + + var ret = repeatUntilSuccess(function(args) { + return browser.selectByValue(args[0], args[1]); + }, [selector, value]); + return ret; + } catch (e) { + console.trace(); + throw e; + } }, false); } diff --git a/test/editor/specs/editor/workspace_uispec.js b/test/editor/specs/editor/workspace_uispec.js index 3cb17415e..fb6c02b9a 100644 --- a/test/editor/specs/editor/workspace_uispec.js +++ b/test/editor/specs/editor/workspace_uispec.js @@ -48,7 +48,6 @@ describe('Workspace', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().should.within(1500000000000, 3000000000000); }); diff --git a/test/editor/specs/scenario/cookbook_endpoint_uispec.js b/test/editor/specs/scenario/cookbook_endpoint_uispec.js index 17f1ff970..b0ae1170e 100644 --- a/test/editor/specs/scenario/cookbook_endpoint_uispec.js +++ b/test/editor/specs/scenario/cookbook_endpoint_uispec.js @@ -72,7 +72,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().indexOf('Hello World!').should.not.eql(-1); }); @@ -112,7 +111,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().indexOf('Hello Nick!').should.not.eql(-1); }); @@ -152,7 +150,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().indexOf('Hello Dave!').should.not.eql(-1); }); @@ -198,7 +195,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().indexOf('Mozilla').should.not.eql(-1); }); @@ -257,7 +253,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNodeTimestamp.clickLeftButton(); injectNodeCheck.clickLeftButton(); var index = debugTab.getMessage().indexOf('Time: ') + 6; @@ -294,6 +289,7 @@ describe('cookbook', function() { // The code for confirmation starts from here. var injectNode = workspace.addNode("inject", 0, 200); var httpRequestNode = workspace.addNode("httpRequest"); + var changeNodeCheck = workspace.addNode("change"); var debugNode = workspace.addNode("debug"); httpRequestNode.edit(); @@ -301,21 +297,20 @@ describe('cookbook', function() { httpRequestNode.setUrl(helper.url() + httpNodeRoot + '/hello-json'); httpRequestNode.clickOk(); - debugNode.edit(); - debugNode.setOutput("headers"); - debugNode.clickOk(); + changeNodeCheck.edit(); + changeNodeCheck.ruleSet("payload", "msg", "headers.content-type", "msg", "1"); + changeNodeCheck.clickOk(); injectNode.connect(httpRequestNode); - httpRequestNode.connect(debugNode); + httpRequestNode.connect(changeNodeCheck); + changeNodeCheck.connect(debugNode); // The code for confirmation ends here. workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); var messages = debugTab.getMessage(); - var contents = messages.join([separator = ""]); - contents.indexOf('application/json').should.not.eql(-1); + messages.indexOf('application/json').should.not.eql(-1); }); it('serve a local file', function () { @@ -360,7 +355,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().indexOf('Text file').should.not.eql(-1); }); @@ -404,7 +398,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().indexOf('Hello Nick!').should.not.eql(-1); }); @@ -454,7 +447,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().indexOf('Hello Nick!').should.not.eql(-1); }); @@ -504,7 +496,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().indexOf('Hello Nick!').should.not.eql(-1); }); diff --git a/test/editor/specs/scenario/cookbook_mqtt_uispec.js b/test/editor/specs/scenario/cookbook_mqtt_uispec.js index 1de70afb0..ecfe8da7d 100644 --- a/test/editor/specs/scenario/cookbook_mqtt_uispec.js +++ b/test/editor/specs/scenario/cookbook_mqtt_uispec.js @@ -105,7 +105,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().should.eql('"22"'); }); @@ -141,7 +140,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().should.eql('"22"'); }); @@ -164,7 +162,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); injectNode.clickLeftButton(); - debugTab.clearMessage(); // The code for confirmation starts from here. var mqttInNode = workspace.addNode("mqttIn", 0, 100); @@ -178,7 +175,7 @@ describe('cookbook', function() { // The code for confirmation ends here. workspace.deploy(); - debugTab.open(); + debugTab.open(true); debugTab.getMessage().should.eql('"22"'); }); @@ -218,7 +215,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().should.eql(['1234', '13']); }); diff --git a/test/editor/specs/scenario/cookbook_uispec.js b/test/editor/specs/scenario/cookbook_uispec.js index 212080d77..f14f02469 100644 --- a/test/editor/specs/scenario/cookbook_uispec.js +++ b/test/editor/specs/scenario/cookbook_uispec.js @@ -55,7 +55,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().should.eql('"Hello World!"'); }); @@ -75,7 +74,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().should.eql("undefined"); }); @@ -99,7 +97,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().should.eql('"Hello"'); }); @@ -134,7 +131,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode1.clickLeftButton(); debugTab.getMessage(1).should.eql('0'); injectNode2.clickLeftButton(); @@ -156,7 +152,6 @@ describe('cookbook', function() { injectNode.connect(debugNode); debugTab.open(); - debugTab.clearMessage(); workspace.deploy(); debugTab.getMessage().should.eql('"Started!"'); }); @@ -174,12 +169,11 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); specUtil.pause(1000); var t1 = Number(debugTab.getMessage(1)); t1.should.within(1500000000000, 3000000000000); specUtil.pause(1000); - debugTab.getMessage(2).should.within(t1 + 1000, 3000000000000); + debugTab.getMessage(2).should.within(t1 + 900, 3000000000000); }); // skip this case since it needs up to one minite. @@ -209,7 +203,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().should.eql('"Node-RED"'); }); @@ -235,7 +228,6 @@ describe('cookbook', function() { workspace.deploy(); debugTab.open(); - debugTab.clearMessage(); injectNode.clickLeftButton(); debugTab.getMessage().should.containEql('