From 1aac3e78053fa0533c4036413187dc5b0969c642 Mon Sep 17 00:00:00 2001 From: Alexander Yuzhin Date: Wed, 11 Jan 2017 17:49:27 +0300 Subject: [PATCH] [DE mobile] Add UI Test --- .gitignore | 5 + .../mobile/test/nightwatch.json | 34 +++++ .../test/tests/de-mobile-edit-tablet-ios.js | 117 ++++++++++++++++++ apps/documenteditor/mobile/test/utils.js | 82 ++++++++++++ 4 files changed, 238 insertions(+) create mode 100644 apps/documenteditor/mobile/test/nightwatch.json create mode 100644 apps/documenteditor/mobile/test/tests/de-mobile-edit-tablet-ios.js create mode 100644 apps/documenteditor/mobile/test/utils.js diff --git a/.gitignore b/.gitignore index e02e885ff..d3dd6ed5d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,8 @@ apps/presentationeditor/mobile/document apps/spreadsheeteditor/embed/offlinedocs apps/spreadsheeteditor/main/offlinedocs apps/spreadsheeteditor/mobile/offlinedocs + +# tests +selenium-debug.log +**/test/bin +**/test/reports \ No newline at end of file diff --git a/apps/documenteditor/mobile/test/nightwatch.json b/apps/documenteditor/mobile/test/nightwatch.json new file mode 100644 index 000000000..5999d55c9 --- /dev/null +++ b/apps/documenteditor/mobile/test/nightwatch.json @@ -0,0 +1,34 @@ +{ + "src_folders" : ["tests"], + "output_folder" : "reports", + "custom_commands_path" : "", + "custom_assertions_path" : "", + "page_objects_path" : "", + "globals_path" : "", + + "selenium" : { + "start_process" : true, + "server_path" : "./bin/selenium-server-standalone-2.53.1.jar", + "log_path" : "", + "port" : 4444, + "cli_args" : { + "webdriver.chrome.driver" : "./bin/chromedriver" + } + }, + + "test_settings" : { + "default" : { + "launch_url" : "http://localhost", + "selenium_port" : 4444, + "selenium_host" : "localhost", + "silent": true, + "screenshots" : { + "enabled" : true, + "path" : "reports/screens" + }, + "desiredCapabilities": { + "browserName": "chrome" + } + } + } +} \ No newline at end of file diff --git a/apps/documenteditor/mobile/test/tests/de-mobile-edit-tablet-ios.js b/apps/documenteditor/mobile/test/tests/de-mobile-edit-tablet-ios.js new file mode 100644 index 000000000..e79654844 --- /dev/null +++ b/apps/documenteditor/mobile/test/tests/de-mobile-edit-tablet-ios.js @@ -0,0 +1,117 @@ +/* + * + * (c) Copyright Ascensio System Limited 2010-2017 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, + * EU, LV-1021. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +/** + * de-mobile-edit-tablet-ios.js + * + * Created by Alexander Yuzhin on 1/10/17 + * Copyright (c) 2017 Ascensio System SIA. All rights reserved. + * + */ + +var Utils = require('../utils'); + +module.exports = { + before : function (browser) { + Utils.init(browser); + browser.resizeWindow(800, 600); + }, + + 'Launch Document Editor' : function (browser) { + Utils.openEditor('http://local:3000/editor?type=mobile&mode=edit&fileName=sample.docx'); + }, + + 'Text settings' : function (browser) { + Utils.canvasClick(280, 280) + .click('#toolbar-edit') + .pause(500); + + Utils.isPresent('div.edit-root-view'); + Utils.isPresent('#edit-text'); + Utils.isPresent('#edit-paragraph'); + + // Text tap + Utils.hasClass('#edit-text', 'active'); + + browser.expect.element('#font-fonts .item-title').text.to.equal('Arial'); + browser.expect.element('#font-fonts .item-after span:first-child').text.to.equal('11 pt'); + + Utils.hasClass('#font-bold', 'active'); + Utils.hasNoClass('#font-italic', 'active'); + Utils.hasNoClass('#font-underline', 'active'); + Utils.hasNoClass('#font-strikethrough', 'active'); + + Utils.hasClass('#font-left', 'active'); + Utils.hasNoClass('#font-center', 'active'); + Utils.hasNoClass('#font-right', 'active'); + Utils.hasNoClass('#font-just', 'active'); + + // Fonts view + browser + .click('#font-fonts') + .waitForElementVisible('.page[data-page=edit-text-font-page]', 1000) + .pause(500); + + browser.expect.element('#font-size .item-after label').text.to.equal('11 pt'); + browser.elements('css selector', '#font-list li', function(result) { + browser.assert.ok(result.value.length > 1, 'Font name list is not empty'); + }); + + browser + .click('.navbar-on-center a.back') + .pause(500); + + // Paragraph tap + browser + .click('.categories a[href*=edit-paragraph]') + .pause(500); + + Utils.hasClass('#edit-paragraph', 'active'); + + browser.elements('css selector', '#paragraph-list li', function(result) { + browser.assert.ok(result.value.length > 1, 'Paragraph style list is not empty'); + }); + }, + + 'Exit from Document Editor' : function (browser) { + var delay = 3000; + + Utils.isPresent('.view-main'); + console.log('Finish testing after delay', delay, 'ms.'); + + browser + .pause(delay) + .frame(null) // Exit from iframe + .end(); // Close browser + } +}; \ No newline at end of file diff --git a/apps/documenteditor/mobile/test/utils.js b/apps/documenteditor/mobile/test/utils.js new file mode 100644 index 000000000..d40fec75c --- /dev/null +++ b/apps/documenteditor/mobile/test/utils.js @@ -0,0 +1,82 @@ +/* + * + * (c) Copyright Ascensio System Limited 2010-2017 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, + * EU, LV-1021. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +/** + * utils.js + * + * Created by Alexander Yuzhin on 1/11/17 + * Copyright (c) 2017 Ascensio System SIA. All rights reserved. + * + */ + +var browser; + +module.exports = { + init: function (client) { + browser = client; + }, + + openEditor: function (url) { + browser + .url(url) + .waitForElementVisible('body', 1000) + .frame(0) // Deep into editor iframe + .waitForElementPresent('.modal-preloader', 1000) + .waitForElementNotPresent('.modal-preloader', 10000); + // .frame(null); // Exit from iframe + // .end(); // Close browser + + return browser; + }, + + canvasClick: function (x, y) { + browser + .moveToElement('#area_id_main', x, y) + .mouseButtonDown('left') + .mouseButtonUp('left'); + + return browser; + }, + + isPresent: function (selector) { + return browser.expect.element(selector).to.be.present; + }, + + hasClass: function (selector, className) { + return browser.expect.element(selector).to.have.attribute('class').which.contains(className); + }, + + hasNoClass: function (selector, className) { + return browser.expect.element(selector).to.not.have.attribute('class').which.contains(className); + } +}; \ No newline at end of file