Add UI test cases for messages on cookbook (#1562)

This commit is contained in:
Kazuki Nakanishi
2018-01-17 18:50:46 +09:00
committed by Nick O'Leary
parent fd4fdb31b5
commit 8d7c157751
14 changed files with 600 additions and 178 deletions

View File

@@ -0,0 +1,52 @@
/**
* 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.
**/
var util = require("util");
var nodePage = require("../../node_page");
function injectNode(id) {
nodePage.call(this, id);
}
util.inherits(injectNode, nodePage);
var payloadType = {
"flow": 1,
"global": 2,
"string": 3,
"num": 4,
"bool": 5,
"json": 6,
"bin": 7,
"date": 8,
};
injectNode.prototype.setPayload = function(type, value) {
// Open a payload type list.
browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-container")]');
// Select a payload type.
var payloadTypeXPath = '//*[@class="red-ui-typedInput-options"]/a[' + payloadType[type] + ']';
browser.clickWithWait(payloadTypeXPath);
// Input a value.
browser.setValue('#node-input-payload', value);
}
injectNode.prototype.setTopic = function(value) {
browser.setValue('#node-input-topic', value);
}
module.exports = injectNode;

View File

@@ -0,0 +1,27 @@
/**
* 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.
**/
var util = require("util");
var nodePage = require("../../node_page");
function debugNode(id) {
nodePage.call(this, id);
}
util.inherits(debugNode, nodePage);
module.exports = debugNode;

View File

@@ -0,0 +1,53 @@
/**
* 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.
**/
var util = require("util");
var nodePage = require("../../node_page");
function changeNode(id) {
nodePage.call(this, id);
}
util.inherits(changeNode, nodePage);
function setT(rule, index) {
browser.selectByValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/select', rule);
}
changeNode.prototype.ruleSet = function(to, index) {
index = index ? index : 1;
setT("set", index);
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[2]/div[2]/div/input', to);
}
changeNode.prototype.ruleDelete = function(index) {
index = index ? index : 1;
setT("delete", index);
}
changeNode.prototype.ruleMove = function(p, to, index) {
index = index ? index : 1;
setT("move", index);
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[1]/div/div/input', p);
browser.setValue('//*[@id="node-input-rule-container"]/li[' + index + ']/div/div[4]/div[2]/div/input', to);
}
changeNode.prototype.addRule = function() {
browser.clickWithWait('//*[@id="dialog-form"]/div[3]/div/a');
}
module.exports = changeNode;

View File

@@ -0,0 +1,38 @@
/**
* 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.
**/
var util = require("util");
var nodePage = require("../../node_page");
function rangeNode(id) {
nodePage.call(this, id);
}
util.inherits(rangeNode, nodePage);
rangeNode.prototype.setAction = function(value) {
browser.selectByValue('#node-input-action', value);
}
rangeNode.prototype.setRange = function(minin, maxin, minout, maxout) {
browser.setValue('#node-input-minin', minin);
browser.setValue('#node-input-maxin', maxin);
browser.setValue('#node-input-minout', minout);
browser.setValue('#node-input-maxout', maxout);
}
module.exports = rangeNode;

View File

@@ -0,0 +1,44 @@
/**
* 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 Node(id) {
this.id = '//*[@id="' + id + '"]';
}
Node.prototype.edit = function() {
browser.clickWithWait(this.id);
browser.clickWithWait(this.id);
// Wait until an edit dialog opens.
browser.waitForVisible('#node-dialog-ok', 2000);
}
Node.prototype.clickOk = function() {
browser.clickWithWait('#node-dialog-ok');
// Wait untile an edit dialog closes.
browser.waitForVisible('#node-dialog-ok', 2000, true);
}
Node.prototype.connect = function(targetNode) {
var outputPort = this.id + '/*[@class="port_output"]';
var inputPort = targetNode.id + '/*[@class="port_input"]';
browser.dragAndDrop(outputPort, inputPort)
}
Node.prototype.clickLeftButton = function() {
browser.clickWithWait(this.id + '/*[@class="node_button node_left_button"]');
}
module.exports = Node;

View File

@@ -0,0 +1,39 @@
/**
* 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.
**/
var injectNode = require('./core/core/20-inject_page');
var debugNode = require('./core/core/58-debug_page');
var changeNode = require('./core/logic/15-change_page');
var rangeNode = require('./core/logic/16-range_page');
var nodeCatalog = {
// input
"inject": injectNode,
// output
"debug": debugNode,
// function
"change": changeNode,
"range": rangeNode,
}
function create(type, id) {
var node = nodeCatalog[type];
return new node(id);
}
module.exports = {
create: create,
};