This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resource-editor.git

commit 7e324177a036d05d2377eddd652411df87e25b39
Author: Sandro Boehme <[email protected]>
AuthorDate: Mon Apr 27 21:33:07 2015 +0000

    enabling "SLING-4555 Resource Editor: fixed e2e tests, node name handling 
in the add node dialog and added an initial version of the add node e2e test" 
again
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1676380 
13f79535-47bb-0310-9956-ffa450edef68
---
 README                                             |  7 ++-
 frontend/Gruntfile.js                              |  4 +-
 .../js/tree/AddNodeController.js                   | 29 ++++------
 .../SLING-INF/libs/sling/resource-editor/html.jsp  |  1 +
 src/test/javascript/e2e/spec/e2e_spec.js           | 62 +++++++++++++++++++---
 5 files changed, 73 insertions(+), 30 deletions(-)

diff --git a/README b/README
index dc9b33c..ac4e114 100644
--- a/README
+++ b/README
@@ -12,8 +12,13 @@ o Use `mvn install sling:install` to deploy changes of Java 
classes
 o To have frontend changes automatically deployed call `mvn install -P 
autoInstallBundle -Dsling.mountByFS=true`
 o To run the build on your local machine call './grunt desktop_build' within 
the frontend directory. It includes end to end tests with firefox and chrome.
 o To have the less sources automatically compiled on change call `./grunt 
watch:less` in the frontend directory. Press Ctrl-Z to stop watching.
-o To have the 'desktop_build' target triggered on changes in the frontend 
tests, less sources, JavaScript files and JSP sources use call `./grunt 
watch:all` in the frontend directory and also press Ctrl-Z to stop watching. 
+o To have the 'desktop_build' target triggered on changes in the frontend 
tests, less sources, JavaScript files and JSP sources use `./grunt watch:all` 
in the frontend directory and also press Ctrl-Z to stop watching.
+o To get the end to end tests triggered by changes use './grunt watch:e2e' in 
the frontend directory and also press Ctrl-Z to stop watching.
 
+++ Debugging the the end to end tests ++
+o You can still use 'console.log()' and JSON.stringify(display) to inspect 
JSON values of a test spec.
+o You can use 'client.pause([milliseconds]);' in you test spec to pause and 
also inspect the browser status.
+o To set breakpoints in a test spec you can use a JavaScript IDE like 
'Webstorm'
 
 
 Enjoy!
\ No newline at end of file
diff --git a/frontend/Gruntfile.js b/frontend/Gruntfile.js
index 7348b0e..0e53f05 100644
--- a/frontend/Gruntfile.js
+++ b/frontend/Gruntfile.js
@@ -57,6 +57,7 @@ module.exports = function(grunt) {
                                  'bootstrap/dist/js/bootstrap.min.js',
                                  'select2/select2.min.js',
                                  'jquery/dist/jquery.min.js',
+                                 'jquery/dist/jquery.min.map',
                                  'bootbox/bootbox.min.js',
                                  'jstree/dist/jstree.min.js'
                                 ], // Actual pattern(s) to match.
@@ -73,6 +74,7 @@ module.exports = function(grunt) {
                    src: [
                          'select2/select2.css',
                          'select2/select2.png',
+                         'select2/select2-spinner.gif',
                          'animate.css/animate.min.css',
                          'jstree/dist/themes/default/style.min.css',
                          'jstree/dist/themes/default/32px.png',
@@ -115,8 +117,6 @@ module.exports = function(grunt) {
            },
         webdriver: {
             options: {
-               host: 'localhost',
-               port: 8080
             },
             chrome: {
                 tests: [e2eTestSpecFolder],
diff --git 
a/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/AddNodeController.js
 
b/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/AddNodeController.js
index e3f510e..76d8566 100644
--- 
a/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/AddNodeController.js
+++ 
b/src/main/resources/SLING-INF/libs/sling/resource-editor-static-content/js/tree/AddNodeController.js
@@ -73,12 +73,12 @@ org.apache.sling.reseditor.AddNodeController = (function() {
                        })
                });
        };
-
+       
        AddNodeController.prototype.addNode = function() {
                var thatAddNodeController = this;
-               var nodeName = this.latestEnteredNodeName.trim();
-               var nodeType = $("#nodeType").val();
-               var resourceType = (this.latestEnteredResType != null && 
this.latestEnteredResType != "") ? this.latestEnteredResType.trim() : "";
+               var nodeName = this.latestEnteredNodeName;
+               var nodeType = $("#nodeType").select2("val");
+               var resourceType = this.latestEnteredResType;
                
                var data = {"_charset_": "utf-8"};
                if ("" != nodeType){
@@ -205,19 +205,13 @@ org.apache.sling.reseditor.AddNodeController = 
(function() {
                $("#nodeName").select2({
                        placeholder: "Enter or select a node name",
                        allowClear: true, 
-                       selectOnBlur: true,
+                       dropdownCssClass: "node_name_dd_container",
                        data: nodeNameObjects,
                        createSearchChoice: function(searchTerm){
+                               thatAddNodeController.latestEnteredNodeName = 
searchTerm;
                                return {id:searchTerm, text:searchTerm};
                        }
                });
-               $("#nodeName").on("select2-highlight", function(e) { 
-                       /* In Select2 there is currently no way of getting
-                        * the highlighted (newly entered but not yet selected) 
text.
-                        * But there is this event. Thats why I use this one. 
-                        */ 
-                       thatAddNodeController.latestEnteredNodeName=e.val;
-               })
                
                var nodeNameList = Object.keys(appliCnTypesByNodeName);
                nodeNameList.sort();
@@ -270,16 +264,13 @@ org.apache.sling.reseditor.AddNodeController = 
(function() {
                                selectOnBlur: true,
                                data: data,
                                createSearchChoice: function(searchTerm){
+                                       
thatAddNodeController.latestEnteredResType = searchTerm;
                                        return {id:searchTerm, text:searchTerm};
                                }
                        }).data("select2");
-                       $("#resourceType").on("select2-highlight", function(e) {
-                               /* In Select2 there is currently no way of 
getting
-                                * the highlighted (newly entered but not yet 
selected) text.
-                                * But there is this event. Thats why I use 
this one. 
-                                */ 
-                               
thatAddNodeController.latestEnteredResType=e.val;
-                       })
+                       $("#resourceType").on("select2-loaded", function() {
+                               $('#addNodeDialog').append('<div 
class="add-node-finished"></div>');
+                       });
                });
        }
        
diff --git a/src/main/resources/SLING-INF/libs/sling/resource-editor/html.jsp 
b/src/main/resources/SLING-INF/libs/sling/resource-editor/html.jsp
index f5ed1d6..b1ff7e1 100644
--- a/src/main/resources/SLING-INF/libs/sling/resource-editor/html.jsp
+++ b/src/main/resources/SLING-INF/libs/sling/resource-editor/html.jsp
@@ -324,5 +324,6 @@ new 
org.apache.sling.reseditor.JSTreeAdapter(jsTreeAdapterSettings, treeControll
            </div>
          </div>
        </div>
+       <div id="last-element"></div>
 </body>
 </html>
diff --git a/src/test/javascript/e2e/spec/e2e_spec.js 
b/src/test/javascript/e2e/spec/e2e_spec.js
index 12b1408..091bd2b 100644
--- a/src/test/javascript/e2e/spec/e2e_spec.js
+++ b/src/test/javascript/e2e/spec/e2e_spec.js
@@ -2,16 +2,62 @@
 
 var assert = require('assert');
 
-describe('The Apache Sling Resource Editor', function() {
-       browser = browser.url('http://localhost:8080/reseditor/.html');
-       // Find a way to specify the host and the port via grunt. See 
+describe('A user of the Apache Sling Resource Editor', function() {
+       var homeURL = 'http://localhost:8080/reseditor/.html';
+       var client = browser.url(homeURL);
+       // TODO: Find a way to specify the host and the port via grunt. See 
        // 
http://stackoverflow.com/questions/29370075/how-to-pass-parameters-from-the-gruntfile-js-to-the-webdriverio-spec
-       
-         it('should have a title', function(done) {
-                 browser
-             .getTitle(function(err,title) {
-                 assert(title.indexOf('Apache Sling Resource Editor') !== -1);
+       client.timeouts("script", 500);
+
+       describe('can open the add node dialog with', function() {
+                 it('the icon', function(done) {
+                         client = client.url(homeURL);
+                         client.waitForExist('#last-element', function(err) {
+                                 client.click('#root_anchor i.add-icon', 
function(err, res) {
+                                         
client.waitForVisible('#addNodeDialog', function(err) {
+                                         
client.getCssProperty('#addNodeDialog', 'display', function(err, display) {
+                                                 assert(typeof err === 
"undefined" || err === null);
+                                                 assert(display.value === 
"block");
+                                         });
+                                 });
+                             })
+                     })
+                     .call(done);
+                 });
+
+                 it('the shortcut', function(done) {
+                         client = client.url(homeURL);
+                         client.waitForExist('#last-element', function(err) {
+                                 client.click('#root_anchor i.add-icon', 
function(err, res) {
+                                         client.keys("a", function(err) {
+                                                 
client.waitForVisible('#addNodeDialog', function(err) {
+                                                 
client.getCssProperty('#addNodeDialog', 'display', function(err, display) {
+                                                         assert(typeof err === 
"undefined" || err === null);
+                                                         assert(display.value 
=== "block");
+                                                 });
+                                         });
+                                         });
+                             })
+                     })
+                     .call(done);
+                 });
+       });
+
+         it('can add an unstructured node to the root node', function(done) {
+                 client = client.url(homeURL);
+                 client.waitForExist('#last-element', function(err) {
+                         client.click('#root_anchor i.add-icon', function(err, 
res) {
+                                 client.waitForVisible('#addNodeDialog 
.add-node-finished', function(err) {
+                                         
client.setValue('.node_name_dd_container input', 'testnode');
+                                         
client.addValue('.node_name_dd_container input', 'Return'); // presses the 
'return' key
+                                         client.click('#addNodeDialog 
.btn.btn-primary.submit', function(err, res) {
+                                                 client.pause(3000); 
+                                         });
+                         });
+                                 
+                     })  
              })
              .call(done);
          });
+       
 });
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to