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

Merge pull request #2007 from node-red-hitachi/dev-uitest-mac

Update UI test for mac OS
This commit is contained in:
Nick O'Leary 2018-12-18 22:57:48 +00:00 committed by GitHub
commit 9bd9023cb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 64 additions and 8 deletions

View File

@ -18,6 +18,8 @@ var util = require("util");
var nodePage = require("../../node_page"); var nodePage = require("../../node_page");
var keyPage = require("../../../util/key_page");
function debugNode(id) { function debugNode(id) {
nodePage.call(this, id); nodePage.call(this, id);
} }
@ -32,7 +34,7 @@ debugNode.prototype.setOutput = function(complete) {
browser.clickWithWait('//div[@class="red-ui-typedInput-options"][1]/a[1]'); browser.clickWithWait('//div[@class="red-ui-typedInput-options"][1]/a[1]');
// Input the path in msg. // Input the path in msg.
browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-input")]/input'); browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-input")]/input');
browser.keys(['Control', 'a', 'Control']); browser.keys(keyPage.selectAll());
browser.keys(['Delete']); browser.keys(['Delete']);
browser.setValue('//*[contains(@class, "red-ui-typedInput-input")]/input', complete); browser.setValue('//*[contains(@class, "red-ui-typedInput-input")]/input', complete);
} else { } else {

View File

@ -18,6 +18,8 @@ var util = require("util");
var nodePage = require("../../node_page"); var nodePage = require("../../node_page");
var keyPage = require("../../../util/key_page");
function functionNode(id) { function functionNode(id) {
nodePage.call(this, id); nodePage.call(this, id);
} }
@ -25,13 +27,13 @@ function functionNode(id) {
util.inherits(functionNode, nodePage); util.inherits(functionNode, nodePage);
functionNode.prototype.setFunction = function(func) { functionNode.prototype.setFunction = function(func) {
browser.click('#node-input-func-editor'); browser.clickWithWait('#node-input-func-editor');
browser.keys(['Control', 'Home', 'Control']); browser.keys(keyPage.selectAll());
for (var i = 0; i < func.length; i++) { for (var i = 0; i < func.length; i++) {
browser.keys([func.charAt(i)]); browser.keys([func.charAt(i)]);
} }
// Delete the unnecessary code that ace editor does the autocompletion. // Delete the unnecessary code that ace editor does the autocompletion.
browser.keys(['Control', 'Shift', 'End', 'Shift', 'Control']); browser.keys(keyPage.selectToEnd());
browser.keys(['Delete']); browser.keys(['Delete']);
// Need to wait until ace editor correctly checks the syntax. // Need to wait until ace editor correctly checks the syntax.
browser.pause(300); browser.pause(300);

View File

@ -18,6 +18,8 @@ var util = require("util");
var nodePage = require("../../node_page"); var nodePage = require("../../node_page");
var keyPage = require("../../../util/key_page");
function templateNode(id) { function templateNode(id) {
nodePage.call(this, id); nodePage.call(this, id);
} }
@ -33,13 +35,13 @@ templateNode.prototype.setFormat = function(format) {
} }
templateNode.prototype.setTemplate = function(template) { templateNode.prototype.setTemplate = function(template) {
browser.click('#node-input-template-editor'); browser.clickWithWait('#node-input-template-editor');
browser.keys(['Control', 'a', 'Control']); // call twice to release the keys. browser.keys(keyPage.selectAll());
// Need to add a character one by one since some words such as 'Control' are treated as a special word. // Need to add a character one by one since some words such as 'Control' are treated as a special word.
for (var i = 0; i < template.length; i++) { for (var i = 0; i < template.length; i++) {
browser.keys([template.charAt(i)]); browser.keys([template.charAt(i)]);
} }
browser.keys(['Control', 'Shift', 'End', 'Shift', 'Control']); browser.keys(keyPage.selectToEnd());
browser.keys(['Delete']); browser.keys(['Delete']);
// Need to wait until ace editor correctly checks the syntax. // Need to wait until ace editor correctly checks the syntax.
browser.pause(300); browser.pause(300);

View File

@ -0,0 +1,50 @@
/**
* 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 os = require("os");
var shortCutKeyMap = {
"selectAll": ['Control', 'a', 'Control'],
"selectToEnd": ['Control', 'Shift', 'End', 'Shift', 'Control'],
};
var shortCutKeyMapForMac = {
"selectAll": ['Command', 'a', 'Command'],
"selectToEnd": ['Command', 'Shift', 'ArrowDown', 'Shift', 'Command'],
};
function getShortCutKey(type) {
if (os.type() === "Darwin") {
return shortCutKeyMapForMac[type];
} else {
return shortCutKeyMap[type];
}
}
function selectAll() {
var key = getShortCutKey('selectAll');
return key;
}
function selectToEnd() {
var key = getShortCutKey('selectToEnd');
return key;
}
module.exports = {
selectAll: selectAll,
selectToEnd: selectToEnd,
};

View File

@ -513,7 +513,7 @@ describe('cookbook', function() {
var changeNode = workspace.addNode("change", 400); var changeNode = workspace.addNode("change", 400);
var httpinNodeClear = workspace.addNode("httpin", 0, 200); var httpinNodeClear = workspace.addNode("httpin", 0, 200);
var functionNodeClear = workspace.addNode("function", 240); var functionNodeClear = workspace.addNode("function", 250);
httpinNodeFormat.edit(); httpinNodeFormat.edit();
httpinNodeFormat.setMethod("get"); httpinNodeFormat.setMethod("get");