mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Merge pull request #2007 from node-red-hitachi/dev-uitest-mac
Update UI test for mac OS
This commit is contained in:
		| @@ -18,6 +18,8 @@ var util = require("util"); | ||||
|  | ||||
| var nodePage = require("../../node_page"); | ||||
|  | ||||
| var keyPage = require("../../../util/key_page"); | ||||
|  | ||||
| function debugNode(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]'); | ||||
|         // Input the path in msg. | ||||
|         browser.clickWithWait('//*[contains(@class, "red-ui-typedInput-input")]/input'); | ||||
|         browser.keys(['Control', 'a', 'Control']); | ||||
|         browser.keys(keyPage.selectAll()); | ||||
|         browser.keys(['Delete']); | ||||
|         browser.setValue('//*[contains(@class, "red-ui-typedInput-input")]/input', complete); | ||||
|     } else { | ||||
|   | ||||
| @@ -18,6 +18,8 @@ var util = require("util"); | ||||
|  | ||||
| var nodePage = require("../../node_page"); | ||||
|  | ||||
| var keyPage = require("../../../util/key_page"); | ||||
|  | ||||
| function functionNode(id) { | ||||
|     nodePage.call(this, id); | ||||
| } | ||||
| @@ -25,13 +27,13 @@ function functionNode(id) { | ||||
| util.inherits(functionNode, nodePage); | ||||
|  | ||||
| functionNode.prototype.setFunction = function(func) { | ||||
|     browser.click('#node-input-func-editor'); | ||||
|     browser.keys(['Control', 'Home', 'Control']); | ||||
|     browser.clickWithWait('#node-input-func-editor'); | ||||
|     browser.keys(keyPage.selectAll()); | ||||
|     for (var i = 0; i < func.length; i++) { | ||||
|         browser.keys([func.charAt(i)]); | ||||
|     } | ||||
|     // Delete the unnecessary code that ace editor does the autocompletion. | ||||
|     browser.keys(['Control', 'Shift', 'End', 'Shift', 'Control']); | ||||
|     browser.keys(keyPage.selectToEnd()); | ||||
|     browser.keys(['Delete']); | ||||
|     // Need to wait until ace editor correctly checks the syntax. | ||||
|     browser.pause(300); | ||||
|   | ||||
| @@ -18,6 +18,8 @@ var util = require("util"); | ||||
|  | ||||
| var nodePage = require("../../node_page"); | ||||
|  | ||||
| var keyPage = require("../../../util/key_page"); | ||||
|  | ||||
| function templateNode(id) { | ||||
|     nodePage.call(this, id); | ||||
| } | ||||
| @@ -33,13 +35,13 @@ templateNode.prototype.setFormat = function(format) { | ||||
| } | ||||
|  | ||||
| templateNode.prototype.setTemplate = function(template) { | ||||
|     browser.click('#node-input-template-editor'); | ||||
|     browser.keys(['Control', 'a', 'Control']); // call twice to release the keys. | ||||
|     browser.clickWithWait('#node-input-template-editor'); | ||||
|     browser.keys(keyPage.selectAll()); | ||||
|     // 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++) { | ||||
|         browser.keys([template.charAt(i)]); | ||||
|     } | ||||
|     browser.keys(['Control', 'Shift', 'End', 'Shift', 'Control']); | ||||
|     browser.keys(keyPage.selectToEnd()); | ||||
|     browser.keys(['Delete']); | ||||
|     // Need to wait until ace editor correctly checks the syntax. | ||||
|     browser.pause(300); | ||||
|   | ||||
							
								
								
									
										50
									
								
								test/editor/pageobjects/util/key_page.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								test/editor/pageobjects/util/key_page.js
									
									
									
									
									
										Normal 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, | ||||
| }; | ||||
| @@ -513,7 +513,7 @@ describe('cookbook', function() { | ||||
|             var changeNode = workspace.addNode("change", 400); | ||||
|  | ||||
|             var httpinNodeClear = workspace.addNode("httpin", 0, 200); | ||||
|             var functionNodeClear = workspace.addNode("function", 240); | ||||
|             var functionNodeClear = workspace.addNode("function", 250); | ||||
|  | ||||
|             httpinNodeFormat.edit(); | ||||
|             httpinNodeFormat.setMethod("get"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user