[mapguide-commits] r8756 - in trunk/MgDev/UnitTest: . Acceptance Acceptance/logs Acceptance/tests Acceptance/tests/ajax

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Sep 10 07:18:59 PDT 2015


Author: jng
Date: 2015-09-10 07:18:59 -0700 (Thu, 10 Sep 2015)
New Revision: 8756

Added:
   trunk/MgDev/UnitTest/Acceptance/
   trunk/MgDev/UnitTest/Acceptance/logs/
   trunk/MgDev/UnitTest/Acceptance/logs/readme.txt
   trunk/MgDev/UnitTest/Acceptance/nightwatch.conf.js
   trunk/MgDev/UnitTest/Acceptance/nightwatch.json
   trunk/MgDev/UnitTest/Acceptance/package.json
   trunk/MgDev/UnitTest/Acceptance/readme.txt
   trunk/MgDev/UnitTest/Acceptance/tests/
   trunk/MgDev/UnitTest/Acceptance/tests/ajax/
   trunk/MgDev/UnitTest/Acceptance/tests/ajax/navigation.js
   trunk/MgDev/UnitTest/Acceptance/tests/ajax/weblayout.js
   trunk/MgDev/UnitTest/Acceptance/tests/ajaxcmds.js
   trunk/MgDev/UnitTest/Acceptance/tests/helper.js
   trunk/MgDev/UnitTest/Acceptance/tests/settings.js
Log:
#2573: First cut of acceptance tests. This covers basic navigation commands of the AJAX viewer.


Property changes on: trunk/MgDev/UnitTest/Acceptance
___________________________________________________________________
Added: svn:ignore
   + node_modules
reports



Property changes on: trunk/MgDev/UnitTest/Acceptance/logs
___________________________________________________________________
Added: svn:ignore
   + selenium-debug.log


Added: trunk/MgDev/UnitTest/Acceptance/logs/readme.txt
===================================================================
--- trunk/MgDev/UnitTest/Acceptance/logs/readme.txt	                        (rev 0)
+++ trunk/MgDev/UnitTest/Acceptance/logs/readme.txt	2015-09-10 14:18:59 UTC (rev 8756)
@@ -0,0 +1 @@
+Selenium debug logs are saved here
\ No newline at end of file

Added: trunk/MgDev/UnitTest/Acceptance/nightwatch.conf.js
===================================================================
--- trunk/MgDev/UnitTest/Acceptance/nightwatch.conf.js	                        (rev 0)
+++ trunk/MgDev/UnitTest/Acceptance/nightwatch.conf.js	2015-09-10 14:18:59 UTC (rev 8756)
@@ -0,0 +1,15 @@
+module.exports = (function(settings) {
+    if (process.env.MG_PARALLEL_TEST == "1") {
+        settings.test_workers = {
+            enabled: true,
+            workers: "auto"
+        }
+    }
+    if (process.platform == "win32") {
+        settings.selenium.cli_args["webdriver.chrome.driver"] = "./node_modules/chromedriver/lib/chromedriver/chromedriver.exe";
+        settings.selenium.cli_args["webdriver.ie.driver"] = "./node_modules/iedriver/lib/iedriver/IEDriverServer.exe";
+    } else {
+        throw "Testing on non-Windows platforms not supported yet";
+    }
+    return settings;
+})(require('./nightwatch.json'));
\ No newline at end of file

Added: trunk/MgDev/UnitTest/Acceptance/nightwatch.json
===================================================================
--- trunk/MgDev/UnitTest/Acceptance/nightwatch.json	                        (rev 0)
+++ trunk/MgDev/UnitTest/Acceptance/nightwatch.json	2015-09-10 14:18:59 UTC (rev 8756)
@@ -0,0 +1,70 @@
+{
+  "src_folders": [
+    "tests"
+  ],
+  "output_folder": "reports",
+  "custom_commands_path": "",
+  "custom_assertions_path": "",
+  "page_objects_path": "",
+  "globals_path": "",
+
+  "selenium": {
+    "start_process": true,
+    "server_path": "./node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-2.47.1.jar",
+    "log_path": "./logs",
+    "host": "127.0.0.1",
+    "port": 4444,
+    "cli_args": {
+      "webdriver.chrome.driver": "",
+      "webdriver.ie.driver": ""
+    }
+  },
+  "live_output": true,
+  "test_settings": {
+    "default": {
+      "launch_url": "http://localhost",
+      "selenium_port": 4444,
+      "selenium_host": "localhost",
+      "silent": true,
+      "screenshots": {
+        "enabled": false,
+        "path": "./screenshots/chrome"
+      },
+      "desiredCapabilities": {
+        "browserName": "chrome",
+        "javascriptEnabled": true,
+        "acceptSslCerts": true
+      }
+    },
+    "firefox": {
+      "launch_url": "http://localhost",
+      "selenium_port": 4444,
+      "selenium_host": "localhost",
+      "silent": true,
+      "screenshots": {
+        "enabled": false,
+        "path": "./screenshots/firefox"
+      },
+      "desiredCapabilities": {
+        "browserName": "firefox",
+        "javascriptEnabled": true,
+        "acceptSslCerts": true
+      }
+    },
+    "ie": {
+      "launch_url": "http://localhost",
+      "selenium_port": 4444,
+      "selenium_host": "localhost",
+      "silent": true,
+      "screenshots": {
+        "enabled": false,
+        "path": "./screenshots/ie"
+      },
+      "desiredCapabilities": {
+        "browserName": "internet explorer",
+        "javascriptEnabled": true,
+        "acceptSslCerts": true
+      }
+    }
+  }
+}
\ No newline at end of file

Added: trunk/MgDev/UnitTest/Acceptance/package.json
===================================================================
--- trunk/MgDev/UnitTest/Acceptance/package.json	                        (rev 0)
+++ trunk/MgDev/UnitTest/Acceptance/package.json	2015-09-10 14:18:59 UTC (rev 8756)
@@ -0,0 +1,13 @@
+{
+  "name": "MapGuideFunctionalTest",
+  "description": "Functional Test Suite for MapGuide",
+  "version": "1.0.0",
+  "private": true,
+  "devDependencies": {
+    "chromedriver": "^2.19.0",
+    "iedriver": "^2.47.0",
+    "nightwatch": "^0.7.11",
+    "nightwatch-html-reporter": "^1.0.2",
+    "selenium-server-standalone-jar": "^2.47.1"
+  }
+}

Added: trunk/MgDev/UnitTest/Acceptance/readme.txt
===================================================================
--- trunk/MgDev/UnitTest/Acceptance/readme.txt	                        (rev 0)
+++ trunk/MgDev/UnitTest/Acceptance/readme.txt	2015-09-10 14:18:59 UTC (rev 8756)
@@ -0,0 +1,48 @@
+MapGuide End-to-End Test Readme
+===============================
+
+This is a suite of end-to-end automated browser tests that will allow one to easily verify a given 
+installation of MapGuide satisfies the minimum validation criteria for a functional build (in addition to passing unit tests)
+
+Requirements
+============
+
+ - Node.js
+ - Java SDK (1.7)
+ - Google Chrome (latest)
+ - Mozilla Firefox (latest)
+ - Internet Explorer (latest)
+ - An installation of MapGuide with the loaded Sheboygan dataset
+
+First Time Setup
+================
+
+Run "npm install" to install the required node dependencies
+    - Nightwatch.js
+    - Nightwatch.js HTML reporter
+
+Ensure that MapGuide is running and the Sheboygan dataset has been loaded
+
+Running the Tests
+=================
+
+"./node_modules/.bin/nightwatch" --env [environment] (--tag [tag1], --tag [tag2] ...)
+
+    - environment: A comma-delimited list of environments, which can be:
+        - default (using Google Chrome)
+        - firefox
+        - ie
+        
+    - tag: A series of tagged test suites (specify a --tag for each tag), which can be:
+        - ajax (all suites)
+            - navigation
+        - fusion (all suites)
+
+Parallel test execution
+=======================
+
+To enable parallel execution, set an environment variable named MG_PARALLEL_TEST=1 before running the test suite.
+
+Parallel execution will farm out each individual test suite (.js file) to a separate worker, all results are collated at the end.
+
+Parallel execution has no effect if running for multiple environments.
\ No newline at end of file

Added: trunk/MgDev/UnitTest/Acceptance/tests/ajax/navigation.js
===================================================================
--- trunk/MgDev/UnitTest/Acceptance/tests/ajax/navigation.js	                        (rev 0)
+++ trunk/MgDev/UnitTest/Acceptance/tests/ajax/navigation.js	2015-09-10 14:18:59 UTC (rev 8756)
@@ -0,0 +1,153 @@
+var settings = require("../settings");
+var helper = require("../helper");
+var wl = require("./weblayout");
+
+module.exports = {
+    tags: ["ajax", "navigation"],
+    beforeEach: function(browser) {
+        helper.setDefaultBrowserSize(browser);
+    },
+    'NAV001 - Zoom In': function (client) {
+        client.url(settings.getAjaxViewerUrl())
+            .waitForElementPresent("#taskFrame", 5000, true)
+            //NOTE: For nested frames, you have to navigate down each frame individually. This is a selenium problem
+            .frame("taskFrame")
+                .waitForElementPresent("frame[name='taskPaneFrame']", 5000, true)
+                .frame("taskPaneFrame")
+                    .waitForElementVisible("table.RegText", 5000, true)
+                    .assert.containsText("table.RegText td.Title", "Overview")
+                .frame(null)
+            .frame(null)
+            .waitForElementPresent("#tbFrame", 5000, true)
+            .frame("tbFrame")
+                .useXpath()
+                    .waitForElementVisible(wl.getToolbarCommand(wl.toolbar.ZOOM_IN), 1000, true)
+                    .moveToElement(wl.getToolbarCommand(wl.toolbar.ZOOM_IN), 10, 10)
+                    .click(wl.getToolbarCommand(wl.toolbar.ZOOM_IN))
+                    //Snapshot and baseline compare
+                    .saveScreenshot(helper.screenshotName(client, "NAV001 - 001 - Zoom In clicked"))
+                .useCss()
+            .frame(null)
+            .waitForElementPresent("#mapFrame", 5000, true)
+            .frame("mapFrame")
+                .moveToElement("#map", 250, 250)
+                .click("#map")
+                //Snapshot and baseline compare
+                .saveScreenshot(helper.screenshotName(client, "NAV001 - 002 - Zoom In result"))
+            .end();
+    },
+    'NAV002 - Zoom Out': function (client) {
+        client.url(settings.getAjaxViewerUrl())
+            .waitForElementPresent("#taskFrame", 5000, true)
+            //NOTE: For nested frames, you have to navigate down each frame individually. This is a selenium problem
+            .frame("taskFrame")
+                .waitForElementPresent("frame[name='taskPaneFrame']", 5000, true)
+                .frame("taskPaneFrame")
+                    .waitForElementVisible("table.RegText", 5000, true)
+                    .assert.containsText("table.RegText td.Title", "Overview")
+                .frame(null)
+            .frame(null)
+            .waitForElementPresent("#tbFrame", 5000, true)
+            .frame("tbFrame")
+                .useXpath()
+                    .waitForElementVisible(wl.getToolbarCommand(wl.toolbar.ZOOM_OUT), 1000, true)
+                    .moveToElement(wl.getToolbarCommand(wl.toolbar.ZOOM_OUT), 10, 10)
+                    .click(wl.getToolbarCommand(wl.toolbar.ZOOM_OUT))
+                    //Snapshot and baseline compare
+                    .saveScreenshot(helper.screenshotName(client, "NAV002 - 001 - Zoom Out clicked"))
+                .useCss()
+            .frame(null)
+            .waitForElementPresent("#mapFrame", 5000, true)
+            .frame("mapFrame")
+                .moveToElement("#map", 250, 250)
+                .click("#map")
+                //Snapshot and baseline compare
+                .saveScreenshot(helper.screenshotName(client, "NAV002 - 002 - Zoom Out clicked"))
+            .end();
+    },
+    'NAV003 - Zoom Rectangle': function (client) {
+        client.url(settings.getAjaxViewerUrl())
+            .waitForElementPresent("#taskFrame", 5000, true)
+            //NOTE: For nested frames, you have to navigate down each frame individually. This is a selenium problem
+            .frame("taskFrame")
+                .waitForElementPresent("frame[name='taskPaneFrame']", 5000, true)
+                .frame("taskPaneFrame")
+                    .waitForElementVisible("table.RegText", 5000, true)
+                    .assert.containsText("table.RegText td.Title", "Overview")
+                .frame(null)
+            .frame(null)
+            .waitForElementPresent("#tbFrame", 5000, true)
+            .frame("tbFrame")
+                .useXpath()
+                    .waitForElementVisible(wl.getToolbarCommand(wl.toolbar.ZOOM_RECT), 1000, true)
+                    .moveToElement(wl.getToolbarCommand(wl.toolbar.ZOOM_RECT), 10, 10)
+                    .click(wl.getToolbarCommand(wl.toolbar.ZOOM_RECT))
+                    //Snapshot and baseline compare
+                    .saveScreenshot(helper.screenshotName(client, "NAV003 - 001 - Zoom Rectangle clicked"))
+                .useCss()
+            .frame(null)
+            .waitForElementPresent("#mapFrame", 5000, true)
+            .frame("mapFrame")
+                .moveToElement("#map", 250, 250)
+                .mouseButtonDown(0)
+                .moveToElement("#map", 350, 350)
+                //Snapshot and baseline compare
+                .saveScreenshot(helper.screenshotName(client, "NAV003 - 002 - Zoom Rectangle drag box"))
+                .mouseButtonUp(0)
+                .pause(3000) //Breathe for rendering
+                //Snapshot and baseline compare
+                .saveScreenshot(helper.screenshotName(client, "NAV003 - 003 - Zoom Rectangle result"))
+            .end();
+    },
+    'NAV004 - Pan': function (client) {
+        client.url(settings.getAjaxViewerUrl())
+            .waitForElementPresent("#taskFrame", 5000, true)
+            //NOTE: For nested frames, you have to navigate down each frame individually. This is a selenium problem
+            .frame("taskFrame")
+                .waitForElementPresent("frame[name='taskPaneFrame']", 5000, true)
+                .frame("taskPaneFrame")
+                    .waitForElementVisible("table.RegText", 5000, true)
+                    .assert.containsText("table.RegText td.Title", "Overview")
+                .frame(null)
+            .frame(null)
+            .waitForElementPresent("#tbFrame", 5000, true)
+            .frame("tbFrame")
+                .useXpath()
+                    .waitForElementVisible(wl.getToolbarCommand(wl.toolbar.PAN), 1000, true)
+                    .moveToElement(wl.getToolbarCommand(wl.toolbar.PAN), 10, 10)
+                    .click(wl.getToolbarCommand(wl.toolbar.PAN))
+                    //Snapshot and baseline compare
+                    .saveScreenshot(helper.screenshotName(client, "NAV004 - 001 - Pan clicked"))
+                .useCss()
+            .frame(null)
+            .waitForElementPresent("#mapFrame", 5000, true)
+            .frame("mapFrame")
+                .moveToElement("#map", 350, 350)
+                .mouseButtonDown(0)
+                .moveToElement("#map", 250, 250)
+                .mouseButtonUp(0)
+                //Snapshot and baseline compare
+                .saveScreenshot(helper.screenshotName(client, "NAV004 - 002 - Pan result"))
+            .end();
+    },
+    'NAV005 - Context Menu': function (client) {
+        client.url(settings.getAjaxViewerUrl())
+            .waitForElementPresent("#taskFrame", 5000, true)
+            //NOTE: For nested frames, you have to navigate down each frame individually. This is a selenium problem
+            .frame("taskFrame")
+                .waitForElementPresent("frame[name='taskPaneFrame']", 5000, true)
+                .frame("taskPaneFrame")
+                    .waitForElementVisible("table.RegText", 5000, true)
+                    .assert.containsText("table.RegText td.Title", "Overview")
+                .frame(null)
+            .frame(null)
+            .waitForElementPresent("#mapFrame", 5000, true)
+            .frame("mapFrame")
+                .moveToElement("#map", 250, 250)
+                .mouseButtonClick(2)
+                .waitForElementVisible("#CtxMenu", 1000, true)
+                //Snapshot and baseline compare
+                .saveScreenshot(helper.screenshotName(client, "NAV005 - 001 - Context Menu"))
+            .end();
+    }
+}
\ No newline at end of file

Added: trunk/MgDev/UnitTest/Acceptance/tests/ajax/weblayout.js
===================================================================
--- trunk/MgDev/UnitTest/Acceptance/tests/ajax/weblayout.js	                        (rev 0)
+++ trunk/MgDev/UnitTest/Acceptance/tests/ajax/weblayout.js	2015-09-10 14:18:59 UTC (rev 8756)
@@ -0,0 +1,16 @@
+//This is the command layout of Library://Samples/Sheboygan/Layouts/SheboyganPhp.WebLayout
+
+module.exports = {
+    toolbar: {
+        BUFFER: 21,
+        MEASURE: 24,
+        ZOOM_RECT: 8,
+        ZOOM_IN: 6,
+        ZOOM_OUT: 7,
+        SELECT: 14,
+        PAN: 0
+    },
+    getToolbarCommand: function(cmdCode) {
+        return "//span[contains(@onclick, 'ExecuteCommand(" + cmdCode + "')]";
+    }
+};
\ No newline at end of file

Added: trunk/MgDev/UnitTest/Acceptance/tests/ajaxcmds.js
===================================================================
--- trunk/MgDev/UnitTest/Acceptance/tests/ajaxcmds.js	                        (rev 0)
+++ trunk/MgDev/UnitTest/Acceptance/tests/ajaxcmds.js	2015-09-10 14:18:59 UTC (rev 8756)
@@ -0,0 +1,22 @@
+module.exports = {
+    PAN_MODE: 1,
+    PAN_UP: 2,
+    PAN_DOWN: 3,
+    PAN_RIGHT: 4,
+    PAN_LEFT: 5,
+    ZOOM_MODE: 6,
+    ZOOM_IN: 7,
+    ZOOM_OUT: 8,
+    ZOOM_RECT: 9,
+    ZOOM_SELECTION: 10,
+    ZOOM_EXTENTS: 11,
+    PREV_VIEW: 12,
+    NEXT_VIEW: 13,
+    INITIAL_VIEW: 14,
+    SELECTION_MODE: 15,
+    SELECT_RADIUS: 16,
+    SELECT_POLYGON: 17,
+    CLEAR_SELECTION: 18,
+    REFRESH_MAP: 19,
+    ABOUT: 22
+};
\ No newline at end of file

Added: trunk/MgDev/UnitTest/Acceptance/tests/helper.js
===================================================================
--- trunk/MgDev/UnitTest/Acceptance/tests/helper.js	                        (rev 0)
+++ trunk/MgDev/UnitTest/Acceptance/tests/helper.js	2015-09-10 14:18:59 UTC (rev 8756)
@@ -0,0 +1,8 @@
+module.exports = {
+    setDefaultBrowserSize: function(browser) {
+        browser.resizeWindow(1280, 800);
+    },
+    screenshotName: function(browser, test) {
+        return "./screenshots/" + process.platform + "_" + process.arch + "_" + browser.options.desiredCapabilities.browserName + "/" + test + ".png";
+    }
+};
\ No newline at end of file

Added: trunk/MgDev/UnitTest/Acceptance/tests/settings.js
===================================================================
--- trunk/MgDev/UnitTest/Acceptance/tests/settings.js	                        (rev 0)
+++ trunk/MgDev/UnitTest/Acceptance/tests/settings.js	2015-09-10 14:18:59 UTC (rev 8756)
@@ -0,0 +1,13 @@
+var settings = {
+    host: "localhost",
+    port: process.env.MG_PORT || 80,
+    vdir: "mapguide",
+    defaultWebLayout: "Library://Samples/Sheboygan/Layouts/SheboyganPhp.WebLayout",
+    getAjaxViewerUrl: function(webLayout) {
+        return "http://" + this.host + ":" + this.port + "/" + this.vdir + "/mapviewerajax/?USERNAME=Anonymous&WEBLAYOUT=" + (webLayout || this.defaultWebLayout);
+    },
+    getFusionUrl: function(template, layout) {
+        return "http://" + this.host + ":" + this.port + "/" + this.vdir + "/fusion/templates/mapguide/" + template + "/index.html?ApplicationDefinition=" + layout;
+    }
+};
+module.exports = settings;
\ No newline at end of file



More information about the mapguide-commits mailing list