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

Added test cases of flow control on cookbook

This commit is contained in:
nakanishi 2018-07-12 15:28:40 +09:00
parent c2675600f6
commit 9f5767ea16
5 changed files with 88 additions and 1 deletions

View File

@ -36,6 +36,13 @@ var payloadType = {
"env": 9,
};
var timeType = {
"none": 1,
"interval": 2,
"intervalBetweenTimes": 3,
"atASpecificTime": 4,
};
injectNode.prototype.setPayload = function(type, value) {
// Open a payload type list.
browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-container")]');
@ -50,4 +57,17 @@ injectNode.prototype.setTopic = function(value) {
browser.setValue('#node-input-topic', value);
}
injectNode.prototype.setOnce = function(value) {
browser.clickWithWait('#node-input-once');
}
injectNode.prototype.setTimeType = function(type) {
var timeTypeXPath = '//*[@id="inject-time-type-select"]/option[' + timeType[type] + ']';
browser.clickWithWait(timeTypeXPath);
}
injectNode.prototype.setRepeat = function(sec) {
browser.setValue('#inject-time-interval-count', sec);
}
module.exports = injectNode;

View File

@ -0,0 +1,23 @@
/**
* 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.
**/
function pause(msec) {
browser.pause(msec);
}
module.exports = {
pause: pause,
};

View File

@ -36,6 +36,7 @@ function addNode(type, x, y) {
}
function deleteAllNodes() {
browser.click('.innerCanvas');
browser.keys(['Control', 'a', 'a', 'Control']); // call twice to release the keys.
browser.keys(['Delete']);
}

View File

@ -21,6 +21,7 @@ var fs = require('fs-extra');
var helper = require("../../editor_helper");
var debugTab = require('../../pageobjects/workspace/debugTab_page');
var workspace = require('../../pageobjects/workspace/workspace_page');
var specUtil = require('../../pageobjects/util/spec_util_page');
var nodeWidth = 200;
@ -142,4 +143,46 @@ describe('cookbook', function() {
debugTab.getMessage(3).should.be.equal('5');
});
});
describe('flow control', function() {
it('trigger a flow whenever Node-RED starts', function() {
var injectNode = workspace.addNode("inject");
var debugNode = workspace.addNode("debug", nodeWidth * 2);
injectNode.edit();
injectNode.setPayload("string", "Started!")
injectNode.setOnce(true);
injectNode.clickOk();
injectNode.connect(debugNode);
debugTab.open();
debugTab.clearMessage();
workspace.deploy();
debugTab.getMessage().should.be.equal('"Started!"');
});
it('trigger a flow at regular intervals', function() {
var injectNode = workspace.addNode("inject");
var debugNode = workspace.addNode("debug", nodeWidth * 2);
injectNode.edit();
injectNode.setTimeType("interval");
injectNode.setRepeat(1);
injectNode.clickOk();
injectNode.connect(debugNode);
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);
});
// skip this case since it needs up to one minite.
it.skip('trigger a flow at a specific time');
});
});

View File

@ -155,7 +155,7 @@ exports.config = {
// Options to be passed to Mocha.
// See the full list at http://mochajs.org/
mochaOpts: {
timeout: 20000,
timeout: 60000,
ui: 'bdd'
},
//