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

@@ -15,17 +15,17 @@
**/
function open() {
browser.click('#red-ui-tab-debug');
browser.clickWithWait('#red-ui-tab-debug');
}
function getMessage() {
var debugMessagePath = '//div[@class="debug-content debug-content-list"]//span[contains(@class, "debug-message-type")]';
browser.waitForExist(debugMessagePath);
return browser.getText(debugMessagePath);
function getMessage(index) {
index = index ? index : 1;
var debugMessagePath = '//div[@class="debug-content debug-content-list"]/div[contains(@class,"debug-message")][' + index + ']//span[contains(@class, "debug-message-type")]';
return browser.getTextWithWait(debugMessagePath);
}
function clearMessage() {
browser.click('//a[@id="debug-tab-clear"]');
browser.clickWithWait('//a[@id="debug-tab-clear"]');
}
module.exports = {

View File

@@ -1,52 +0,0 @@
/**
* 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 icons = {
// input
"inject": "icons/node-red/inject.png",
// output
"debug": "icons/node-red/debug.png",
// function
"change": "icons/node-red/swap.png",
};
function getIdWithIcon(icon) {
//*[name()="image" and @*="icons/node-red/inject.png"]/../..
var id = browser.getAttribute('//*[name()="image" and @*="' + icon + '"]/../..', 'id');
return id;
}
function Node(type) {
this.id = '//*[@id="' + getIdWithIcon(icons[type]) + '"]';
}
Node.prototype.edit = function() {
browser.click(this.id);
browser.click(this.id);
browser.pause(500); // Necessary for headless mode.
}
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.click(this.id + '/*[@class="node_button node_left_button"]');
}
module.exports = Node;

View File

@@ -14,11 +14,20 @@
* limitations under the License.
**/
function clickOk() {
browser.click('#node-dialog-ok');
browser.pause(300);
var idMap = {
// input
"inject": "#palette_node_inject",
// output
"debug": "#palette_node_debug",
// function
"change": "#palette_node_change",
"range": "#palette_node_range",
};
function getId(type) {
return idMap[type];
}
module.exports = {
clickOk: clickOk,
getId: getId,
};

View File

@@ -14,26 +14,25 @@
* limitations under the License.
**/
var when = require('when');
var when = require("when");
var events = require("../../../../red/runtime/events.js");
var node = require('./node_page');
var palette = {
"inject": "#palette_node_inject",
"debug": "#palette_node_debug",
"change": "#palette_node_change",
};
var palette = require("./palette_page");
var nodeFactory = require("../nodes/nodefactory_page");
function addNode(type, x, y) {
var offsetX = x ? x : 0;
var offsetY = y ? y : 0;
browser.moveToObject(palette[type]);
browser.moveToObject(palette.getId(type));
browser.buttonDown();
browser.moveToObject("#palette-search", offsetX + 300, offsetY + 100); // adjust to the top-left corner of workspace.
browser.buttonUp();
return new node(type);
// Last node is the one that has been created right now.
var nodeElement = browser.elements('//*[@class="node nodegroup"][last()]');
var nodeId = nodeElement.getAttribute('id');
var node = nodeFactory.create(type, nodeId);
return node;
}
function deleteAllNodes() {
@@ -49,10 +48,10 @@ function deploy() {
resolve();
}
});
browser.click('#btn-deploy');
browser.clickWithWait('#btn-deploy');
});
});
browser.pause(500); // Necessary for headless mode.
browser.waitForText('#btn-deploy', 2000);
}
module.exports = {