From 715cc77e763acc2e8d4e67c76f1852037ed8c548 Mon Sep 17 00:00:00 2001 From: Yuma Matsuura Date: Tue, 18 Dec 2018 09:29:46 +0900 Subject: [PATCH] Update UI test for mac os --- .../nodes/core/core/58-debug_page.js | 4 +- .../nodes/core/core/80-function_page.js | 8 +-- .../nodes/core/core/80-template_page.js | 8 +-- test/editor/pageobjects/util/key_page.js | 50 +++++++++++++++++++ .../scenario/cookbook_endpoint_uispec.js | 2 +- 5 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 test/editor/pageobjects/util/key_page.js diff --git a/test/editor/pageobjects/nodes/core/core/58-debug_page.js b/test/editor/pageobjects/nodes/core/core/58-debug_page.js index 0dc4c298e..2b1eabe64 100644 --- a/test/editor/pageobjects/nodes/core/core/58-debug_page.js +++ b/test/editor/pageobjects/nodes/core/core/58-debug_page.js @@ -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 { diff --git a/test/editor/pageobjects/nodes/core/core/80-function_page.js b/test/editor/pageobjects/nodes/core/core/80-function_page.js index a692e0149..f39aba912 100644 --- a/test/editor/pageobjects/nodes/core/core/80-function_page.js +++ b/test/editor/pageobjects/nodes/core/core/80-function_page.js @@ -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); diff --git a/test/editor/pageobjects/nodes/core/core/80-template_page.js b/test/editor/pageobjects/nodes/core/core/80-template_page.js index 7d2ad0c82..68cf46acf 100644 --- a/test/editor/pageobjects/nodes/core/core/80-template_page.js +++ b/test/editor/pageobjects/nodes/core/core/80-template_page.js @@ -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); diff --git a/test/editor/pageobjects/util/key_page.js b/test/editor/pageobjects/util/key_page.js new file mode 100644 index 000000000..9a8a867b4 --- /dev/null +++ b/test/editor/pageobjects/util/key_page.js @@ -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, +}; diff --git a/test/editor/specs/scenario/cookbook_endpoint_uispec.js b/test/editor/specs/scenario/cookbook_endpoint_uispec.js index b0ae1170e..95b78d03c 100644 --- a/test/editor/specs/scenario/cookbook_endpoint_uispec.js +++ b/test/editor/specs/scenario/cookbook_endpoint_uispec.js @@ -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");