You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2015/03/18 09:18:59 UTC

[2/2] tapestry-5 git commit: TAP5-2467: Test for the JS event when client side form validation fails

TAP5-2467: Test for the JS event when client side form validation fails


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/65b9671c
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/65b9671c
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/65b9671c

Branch: refs/heads/master
Commit: 65b9671c244ebca826de6958264aa5f4b8de7c7d
Parents: 9ee2a92
Author: Charlouze <me...@charlouze.com>
Authored: Tue Mar 17 20:08:01 2015 +0100
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Wed Mar 18 09:13:20 2015 +0100

----------------------------------------------------------------------
 tapestry-core/src/test/app1/ValidateInErrorEvent.tml     |  6 ++++++
 .../META-INF/modules/validate-in-error.coffee            |  7 +++++++
 .../org/apache/tapestry5/integration/app1/FormTests.java | 11 +++++++++++
 .../apache/tapestry5/integration/app1/pages/Index.java   |  5 ++++-
 .../integration/app1/pages/ValidateInErrorEvent.java     | 10 ++++++++++
 5 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/app1/ValidateInErrorEvent.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/ValidateInErrorEvent.tml b/tapestry-core/src/test/app1/ValidateInErrorEvent.tml
new file mode 100644
index 0000000..c4b0d12
--- /dev/null
+++ b/tapestry-core/src/test/app1/ValidateInErrorEvent.tml
@@ -0,0 +1,6 @@
+<html t:type="border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+<t:form>
+    <t:textfield value="value" validate="required"/>
+    <t:submit/>
+</t:form>
+</html>

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.coffee b/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.coffee
new file mode 100644
index 0000000..75edfe8
--- /dev/null
+++ b/tapestry-core/src/test/coffeescript/META-INF/modules/validate-in-error.coffee
@@ -0,0 +1,7 @@
+define ['t5/core/dom', 't5/core/events'], (dom, events)->
+  dom.onDocument events.form.validateInError, 'form', ->
+    attributes =
+      id: 'validate-in-error'
+    @prepend dom.create 'div', attributes, 'Validate in error'
+    return
+  return

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
index 70f77e7..4f8a55f 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/FormTests.java
@@ -1230,4 +1230,15 @@ public class FormTests extends App1TestCase
         assertTextPresent("This parameter is not allowed to be null.");
     }
 
+    /** TAP5-2467 **/
+    @Test
+    public void validate_in_error_event() {
+        openLinks("Validate in error Event");
+
+        click(SUBMIT);
+
+        waitForElementToAppear("validate-in-error");
+
+        assertTextPresent("Validate in error");
+    }
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
index f146ec1..3c75ce7 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
@@ -585,7 +585,10 @@ public class Index
 
                     new Item("gridwithsubmitwithcontextdemo", "Grid with Submit with context", "A grid whose rows contain a Submit component with context"),
 
-                    new Item("textfieldwithnullvalidateparameter", "TextField with null validate parameter", "A TextField whose validate parameter is bound to null")
+                    new Item("textfieldwithnullvalidateparameter", "TextField with null validate parameter", "A TextField whose validate parameter is bound to null"),
+
+                    new Item("validateInErrorEvent", "Validate in error Event", "A form that trigger validate in " +
+                            "error event on submit when textfield is empty")
             );
 
     static

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65b9671c/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ValidateInErrorEvent.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ValidateInErrorEvent.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ValidateInErrorEvent.java
new file mode 100644
index 0000000..645703a
--- /dev/null
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ValidateInErrorEvent.java
@@ -0,0 +1,10 @@
+package org.apache.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.annotations.Import;
+import org.apache.tapestry5.annotations.Property;
+
+@Import(module = {"validate-in-error"})
+public class ValidateInErrorEvent {
+    @Property
+    private String value;
+}