Repository: wicket
Updated Branches:
  refs/heads/master ea6cbc11a -> 4b99316d1


Fix the Gym test for Ajax Form example


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/4b99316d
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/4b99316d
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/4b99316d

Branch: refs/heads/master
Commit: 4b99316d160c2a1a1772f88838b4670e017e2329
Parents: ea6cbc1
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Sun Dec 13 01:29:32 2015 +0100
Committer: Martin Tzvetanov Grigorov <[email protected]>
Committed: Sun Dec 13 01:29:32 2015 +0100

----------------------------------------------------------------------
 .../src/main/webapp/js-test/all.html            |  1 +
 .../src/main/webapp/js-test/lib/gym.js          | 16 ++++++++++++-
 .../src/main/webapp/js-test/tests/ajax/form.js  | 25 ++++++++++++++++----
 3 files changed, 36 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/4b99316d/wicket-examples/src/main/webapp/js-test/all.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/webapp/js-test/all.html 
b/wicket-examples/src/main/webapp/js-test/all.html
index 658ec21..7396b8f 100644
--- a/wicket-examples/src/main/webapp/js-test/all.html
+++ b/wicket-examples/src/main/webapp/js-test/all.html
@@ -22,6 +22,7 @@
        <script type="text/javascript" src="tests/forminput.js"></script>
 
        <script type="text/javascript" src="tests/ajax/form.js"></script>
+
        <script type="text/javascript" src="tests/cdi/injection.js"></script>
        <script type="text/javascript" src="tests/cdi/conversation.js"></script>
        <script type="text/javascript" 
src="tests/cdi/auto-conversation.js"></script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/4b99316d/wicket-examples/src/main/webapp/js-test/lib/gym.js
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/webapp/js-test/lib/gym.js 
b/wicket-examples/src/main/webapp/js-test/lib/gym.js
index 34dd842..aee036f 100644
--- a/wicket-examples/src/main/webapp/js-test/lib/gym.js
+++ b/wicket-examples/src/main/webapp/js-test/lib/gym.js
@@ -91,6 +91,19 @@
                return deferred.promise();
        }
 
+       var ajaxKeydown = function($el) {
+               var deferred = $.Deferred();
+               var iframeWindow = _getIframe()[0].contentWindow;
+
+               _onAjaxComplete(iframeWindow, function($$) {
+                       deferred.resolve($$);
+               });
+
+               $el.keydown();
+
+               return deferred.promise();
+       }
+
        /**
         * Registers a callback when Wicket Ajax call is completed
         */
@@ -118,6 +131,7 @@
        window.gym = {
                load: load,
                click: click,
-               ajaxClick: ajaxClick
+               ajaxClick: ajaxClick,
+               ajaxKeydown: ajaxKeydown
        };
 })($q);

http://git-wip-us.apache.org/repos/asf/wicket/blob/4b99316d/wicket-examples/src/main/webapp/js-test/tests/ajax/form.js
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/webapp/js-test/tests/ajax/form.js 
b/wicket-examples/src/main/webapp/js-test/tests/ajax/form.js
index 8082e7f..2fcd03a 100644
--- a/wicket-examples/src/main/webapp/js-test/tests/ajax/form.js
+++ b/wicket-examples/src/main/webapp/js-test/tests/ajax/form.js
@@ -24,16 +24,32 @@ $q(document).ready(function() {
        module('Ajax');
 
        asyncTest('successful ajax form submit', function () {
-               expect(3);
+               expect(6);
+
+               var $nameInput, $emailInput;
 
                gym.load('/ajax/form').then(function($) {
+                       $nameInput = $('input[name="p::name"]');
+                       $emailInput = $('input[name=email]');
 
                        // enter just the name field
-                       var $nameInput = $('input[name="p::name"]');
+                       $nameInput.focus();
+                       var name = 'Aj';
+                       $nameInput.val(name);
+
+                       return gym.ajaxKeydown($emailInput);
+               }).then(function($) {
+
+                       // an error feedback message that email is mandatory is 
expected
+                       var $feedback = $('li.feedbackPanelERROR > span');
+                       equal($feedback.length, 2, 'The error feedback message 
that name is too short and the email is missing');
+                       equal($feedback.eq(0).text(), 'Name must be at least 4 
characters', 'The error feedback matches');
+                       equal($feedback.eq(1).text(), 'Email is required', 'The 
error feedback matches');
+
                        var name = 'Ajax form name';
                        $nameInput.val(name);
 
-                       return gym.ajaxClick($('input[name=ajax-button]'));
+                       return gym.ajaxKeydown($emailInput);
                }).then(function($) {
 
                        // an error feedback message that email is mandatory is 
expected
@@ -42,11 +58,10 @@ $q(document).ready(function() {
                        equal($feedback.text(), 'Email is required', 'The error 
feedback matches');
 
                        // enter the email field too
-                       var $emailInput = $('input[name=email]');
                        var email = '[email protected]';
                        $emailInput.val(email);
 
-                       return gym.ajaxClick($('input[name=ajax-button]'));
+                       return gym.ajaxKeydown($nameInput);
                }).then(function($) {
 
                        // the feedback panel must be empty now

Reply via email to