You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2017/09/19 11:51:46 UTC

[myfaces-tobago] branch master updated: fix demo tests

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

hnoeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new 29aac6b  fix demo tests
29aac6b is described below

commit 29aac6be3106091e35846fb36f3aaa777ba8b42d
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Tue Sep 19 13:51:33 2017 +0200

    fix demo tests
---
 .../content/20-component/060-popup/popup.test.js   | 64 +++++++++++++++---
 .../070-tab/02-server/tab-server.xhtml             |  9 ---
 .../10-collapsible-popup/collapsible-popup.xhtml   | 76 ++++++++++++++++++----
 3 files changed, 118 insertions(+), 31 deletions(-)

diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/popup.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/popup.test.js
index 3083b01..c782f54 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/popup.test.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/060-popup/popup.test.js
@@ -162,6 +162,8 @@ QUnit.test("Open 'Client Popup', press 'Submit & Close' while field has content.
 
 QUnit.test("Open 'Large Popup'.", function (assert) {
   assert.expect(8);
+  var done = assert.async(2);
+  var step = 1;
 
   var $dropdownContainer = jQueryFrame("#page\\:mainForm\\:dropdownButton");
   var $dropdownButton = jQueryFrame("#page\\:mainForm\\:dropdownButton\\:\\:command");
@@ -186,17 +188,40 @@ QUnit.test("Open 'Large Popup'.", function (assert) {
 
   $openButton.click();
 
-  assert.equal($dropdownContainer.hasClass("show"), false);
-  assert.equal($popup.hasClass("show"), true);
+  //we need to wait, because of the fading animation of the popup
+  waitForAjax(function () {
+    $popup = jQueryFrame($popup.selector);
+    return step === 1
+        && $popup.hasClass("show")
+        && $popup.css("display") === "block";
+  }, function () {
+    $popup = jQueryFrame($popup.selector);
 
-  $closeButton.click();
+    assert.equal($dropdownContainer.hasClass("show"), false);
+    assert.equal($popup.hasClass("show"), true);
 
-  assert.equal($dropdownContainer.hasClass("show"), false);
-  assert.equal($popup.hasClass("show"), false);
+    waitForAjax(function () {
+      $closeButton.click();
+      $popup = jQueryFrame($popup.selector);
+      return step === 2 && !$popup.hasClass("show");
+    }, function () {
+      $popup = jQueryFrame($popup.selector);
+
+      assert.equal($dropdownContainer.hasClass("show"), false);
+      assert.equal($popup.hasClass("show"), false);
+
+      step++;
+      done();
+    });
+    step++;
+    done();
+  });
 });
 
 QUnit.test("Open 'Small Popup'.", function (assert) {
   assert.expect(8);
+  var done = assert.async(2);
+  var step = 1;
 
   var $dropdownContainer = jQueryFrame("#page\\:mainForm\\:dropdownButton");
   var $dropdownButton = jQueryFrame("#page\\:mainForm\\:dropdownButton\\:\\:command");
@@ -221,11 +246,30 @@ QUnit.test("Open 'Small Popup'.", function (assert) {
 
   $openButton.click();
 
-  assert.equal($dropdownContainer.hasClass("show"), false);
-  assert.equal($popup.hasClass("show"), true);
+  //we need to wait, because of the fading animation of the popup
+  waitForAjax(function () {
+    $popup = jQueryFrame($popup.selector);
+    return step === 1 && $popup.hasClass("show");
+  }, function () {
+    $popup = jQueryFrame($popup.selector);
 
-  $closeButton.click();
+    assert.equal($dropdownContainer.hasClass("show"), false);
+    assert.equal($popup.hasClass("show"), true);
 
-  assert.equal($dropdownContainer.hasClass("show"), false);
-  assert.equal($popup.hasClass("show"), false);
+    waitForAjax(function () {
+      $closeButton.click();
+      $popup = jQueryFrame($popup.selector);
+      return step === 2 && !$popup.hasClass("show");
+    }, function () {
+      $popup = jQueryFrame($popup.selector);
+
+      assert.equal($dropdownContainer.hasClass("show"), false);
+      assert.equal($popup.hasClass("show"), false);
+
+      step++;
+      done();
+    });
+    step++;
+    done();
+  });
 });
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/02-server/tab-server.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/02-server/tab-server.xhtml
index 383fdef..06b3be7 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/02-server/tab-server.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/070-tab/02-server/tab-server.xhtml
@@ -36,20 +36,11 @@
     <tc:link label="&lt;tc:tabChangeListener/>" image="#{request.contextPath}/image/feather-leaf.png"
              link="#{demoBundle.tagDocUrl}/#{info.stableVersion}/tld/tc/tabChangeListener.html"/></p>
 
-  <tc:popup id="xy" collapsed="false">
-    <tc:button label="close">
-      <tc:operation name="hide" for="xy"/>
-    </tc:button>
-  </tc:popup>
-
   <tc:section label="Basics">
     <p>A simple tabgroup. The second tab is disabled.</p>
     <tc:tabGroup id="tg1" switchType="reloadPage">
       <tc:tab id="t11" label="One">
         First tab.
-        <tc:button label="open">
-          <tc:operation name="show" for=":::xy"/>
-        </tc:button>
       </tc:tab>
       <tc:tab id="t12" label="Two" disabled="true">
         Second tab.
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.xhtml
index 1e03bf2..5a80a92 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/10-collapsible-popup/collapsible-popup.xhtml
@@ -26,19 +26,71 @@
     <tc:link label="#{demoBundle.popup}" outcome="/content/20-component/060-popup/popup.xhtml"/> page
     in the components section for more details.</p>
 
-  <tc:button label="click me"/>
+  <tc:section label="Simple Popup">
+    <tc:form id="simple">
+      <p>A popup opened with the help of a controller. The popup contain a required inputfield.
+        The attribute <code>collapsedMode="absent"</code> is set,
+        so the 'Submit'-button outside the popup could be executed while popup is hidden.
+        Even if the required inputfield is empty.</p>
+      <tc:button id="open1" label="Open" action="#{collapsiblePopupController.open}"/>
+      <tc:button id="submitOnPage1" label="Submit"/>
+      <tc:popup id="controllerPopup" collapsed="#{collapsiblePopupController.collapsed}">
+        <tc:box label="Simple Popup">
+          <tc:in id="in1" label="Required" required="true"/>
+          <tc:button id="submitOnPopup1" label="Submit"/>
+          <tc:button id="close1" label="Close" immediate="true" action="#{collapsiblePopupController.close}"/>
+        </tc:box>
+      </tc:popup>
+    </tc:form>
+  </tc:section>
 
-  <tc:button id="open3" label="Open" omit="true">
-    <tc:operation name="show" for="clientPopup"/>
-  </tc:button>
-
-  <tc:popup id="clientPopup" collapsedMode="hidden">
-    <tc:box label="Full Server Request">
-
-      <tc:button id="close3" label="Close" omit="true">
-        <tc:operation name="hide" for="clientPopup"/>
+  <tc:section label="Full Server Request">
+    <tc:form id="server">
+      <p>Server sided popup with <code class="language-markup">&lt;tc:operation/></code>.
+        The attribute <code>collapsedMode="absent"</code> is set by default.
+        If you press the 'Submit'-button in the popup, the popup remains open,
+        because the server know the current state.</p>
+      <tc:button id="open2" label="Open">
+        <tc:operation name="show" for="fullServerRequestPopup"/>
       </tc:button>
-    </tc:box>
-  </tc:popup>
+      <tc:button id="submitOnPage2" label="Submit"/>
+      <tc:popup id="fullServerRequestPopup">
+        <tc:box label="Full Server Request">
+          <tc:in id="in2" label="Required" required="true"/>
+          <tc:button id="submitOnPopup2" label="Submit"/>
+          <tc:button id="close2" label="Close" immediate="true">
+            <tc:operation name="hide" for="fullServerRequestPopup"/>
+          </tc:button>
+        </tc:box>
+      </tc:popup>
+    </tc:form>
+  </tc:section>
 
+  <tc:section label="Client Sided">
+    <tc:form id="client">
+      <p>For the client sided popup the attribute <code>collapsedMode="hidden"</code> must be set.
+        So the hidden popup is already rendered on the site. Otherwise a client sided opened popup has no content.</p>
+      <p>This leads to the problem of violations of hidden content.
+        In this case you cannot press the 'Submit'-button if the required field is empty.
+        Even if the popup is hidden.</p>
+      <p>The 'Submit'-button in the popup will close the popup, because the server didn't know the current state.</p>
+      <p>To avoid server request, the attribute <code>omit="true"</code>
+        is added to the 'Open'-button and the 'Close'-button.</p>
+      <tc:button id="open3" label="Open" omit="true">
+        <tc:operation name="show" for="clientPopup"/>
+      </tc:button>
+      <tc:button id="submitOnPage3" label="Submit"/>
+      <tc:popup id="clientPopup" collapsedMode="hidden">
+        <tc:box label="Full Server Request">
+          <p>The opening of the popup is client sided.
+            Therefor the popup will be closed after pressing the 'Submit'-button which reload the page.</p>
+          <tc:in id="in3" label="Required" required="true"/>
+          <tc:button id="submitOnPopup3" label="Submit"/>
+          <tc:button id="close3" label="Close" omit="true">
+            <tc:operation name="hide" for="clientPopup"/>
+          </tc:button>
+        </tc:box>
+      </tc:popup>
+    </tc:form>
+  </tc:section>
 </ui:composition>

-- 
To stop receiving notification emails like this one, please contact
['"commits@myfaces.apache.org" <co...@myfaces.apache.org>'].