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 2019/01/12 12:28:53 UTC
[myfaces-tobago] branch master updated: add tests for input group
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 563753b add tests for input group
563753b is described below
commit 563753b8466a615972e954dc092dc2a34d674c1d
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Sat Jan 12 13:27:53 2019 +0100
add tests for input group
* small changes in demo page
---
.../tobago/example/demo/GroupController.java | 15 ++-
.../010-input/50-input-group/Group.test.js | 118 +++++++++++++++++++++
.../010-input/50-input-group/Group.xhtml | 10 +-
3 files changed, 136 insertions(+), 7 deletions(-)
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/GroupController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/GroupController.java
index 92d7ac7..6e5a67d 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/GroupController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/GroupController.java
@@ -74,8 +74,19 @@ public class GroupController implements Serializable {
}
public void sendChat() {
- chatlog += "\nUser Two: " + newMessage;
- newMessage = "";
+ if (newMessage.equals("delete chat")) {
+ deleteChat();
+ } else {
+ if (!chatlog.isEmpty()) {
+ chatlog += "\n";
+ }
+ chatlog += "User Two: " + newMessage;
+ newMessage = "";
+ }
+ }
+
+ public void deleteChat() {
+ chatlog = "";
}
public String getSendTo() {
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/Group.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/Group.test.js
new file mode 100644
index 0000000..a3e65a5
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/Group.test.js
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+QUnit.test("ajax: chat send button", function (assert) {
+ var chatlogFn = jQueryFrameFn("#page\\:mainForm\\:tachatlog\\:\\:field");
+ var inputFn = jQueryFrameFn("#page\\:mainForm\\:inewmessage\\:\\:field");
+ var sendButtonFn = jQueryFrameFn("#page\\:mainForm\\:sendButton");
+
+ var TTT = new TobagoTestTool(assert);
+ TTT.action(function () {
+ inputFn().val("delete chat");
+ sendButtonFn().click();
+ });
+ TTT.waitForResponse();
+ TTT.asserts(1, function () {
+ assert.equal(chatlogFn().text(), "");
+ });
+ TTT.action(function () {
+ inputFn().val("Hi Peter, how are you?");
+ sendButtonFn().click();
+ });
+ TTT.waitForResponse();
+ TTT.asserts(1, function () {
+ assert.equal(chatlogFn().text(), "User Two: Hi Peter, how are you?");
+ });
+ TTT.startTest();
+});
+
+QUnit.test("ajax: dropdown button", function (assert) {
+ var buttonFn = jQueryFrameFn("#page\\:mainForm\\:lsendtoc\\:\\:command");
+ var buttonLabelFn = jQueryFrameFn("#page\\:mainForm\\:lsendtoc\\:\\:command span");
+ var sendToPeterFn = jQueryFrameFn("#page\\:mainForm\\:sendToPeter");
+ var sendToBobFn = jQueryFrameFn("#page\\:mainForm\\:sendToBob");
+ var sendToAllFn = jQueryFrameFn("#page\\:mainForm\\:sendToAll");
+
+ var TTT = new TobagoTestTool(assert);
+ TTT.action(function () {
+ buttonFn().click();
+ sendToPeterFn().click();
+ });
+ TTT.waitForResponse();
+ TTT.asserts(1, function () {
+ assert.equal(buttonLabelFn().text(), "SendTo: Peter");
+ });
+ TTT.action(function () {
+ buttonFn().click();
+ sendToBobFn().click();
+ });
+ TTT.waitForResponse();
+ TTT.asserts(1, function () {
+ assert.equal(buttonLabelFn().text(), "SendTo: Bob");
+ });
+ TTT.action(function () {
+ buttonFn().click();
+ sendToAllFn().click();
+ });
+ TTT.waitForResponse();
+ TTT.asserts(1, function () {
+ assert.equal(buttonLabelFn().text(), "SendTo: All");
+ });
+ TTT.startTest();
+});
+
+QUnit.test("ajax: currency change event", function (assert) {
+ var currencyInputFn = jQueryFrameFn("#page\\:mainForm\\:value\\:\\:field");
+ var currencyOptionFn = jQueryFrameFn("#page\\:mainForm\\:currency option");
+ var outputFieldFn = jQueryFrameFn("#page\\:mainForm\\:valueInEuro .tobago-out");
+
+ var TTT = new TobagoTestTool(assert);
+ TTT.action(function () {
+ currencyInputFn().val("1000");
+ currencyOptionFn().eq(1).prop("selected", false);
+ currencyOptionFn().eq(2).prop("selected", false);
+ currencyOptionFn().eq(3).prop("selected", false);
+ currencyOptionFn().eq(0).prop("selected", true).trigger("change"); // Yen
+ });
+ TTT.waitForResponse();
+ TTT.asserts(1, function () {
+ assert.equal(outputFieldFn().text(), "8,85");
+ });
+ TTT.action(function () {
+ currencyInputFn().val("2000");
+ currencyOptionFn().eq(0).prop("selected", false);
+ currencyOptionFn().eq(2).prop("selected", false);
+ currencyOptionFn().eq(3).prop("selected", false);
+ currencyOptionFn().eq(1).prop("selected", true).trigger("change"); // Trinidad-Tobago Dollar
+ });
+ TTT.waitForResponse();
+ TTT.asserts(1, function () {
+ assert.equal(outputFieldFn().text(), "267,50");
+ });
+ TTT.action(function () {
+ currencyInputFn().val("3000");
+ currencyOptionFn().eq(0).prop("selected", false);
+ currencyOptionFn().eq(1).prop("selected", false);
+ currencyOptionFn().eq(3).prop("selected", false);
+ currencyOptionFn().eq(2).prop("selected", true).trigger("change"); // US Dollar
+ });
+ TTT.waitForResponse();
+ TTT.asserts(1, function () {
+ assert.equal(outputFieldFn().text(), "2.688,29");
+ });
+ TTT.startTest();
+});
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/Group.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/Group.xhtml
index f86d361..040daf5 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/Group.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/50-input-group/Group.xhtml
@@ -66,7 +66,7 @@
<tc:in id="inewmessage" value="#{groupController.newMessage}">
<f:facet name="before">User Two</f:facet>
<f:facet name="after">
- <tc:button label="Send" action="#{groupController.sendChat}">
+ <tc:button id="sendButton" label="Send" action="#{groupController.sendChat}">
<f:ajax execute="inewmessage" render="tachatlog inewmessage"/>
</tc:button>
</f:facet>
@@ -97,13 +97,13 @@
<tc:in id="isendtoc" placeholder="type a message">
<f:facet name="before">
<tc:button id="lsendtoc" label="#{groupController.sendTo}" omit="true">
- <tc:link label="SendTo: Peter">
+ <tc:link id="sendToPeter" label="SendTo: Peter">
<f:ajax render="isendtoc" execute="isendtoc" listener="#{groupController.sendToListener}"/>
</tc:link>
- <tc:link label="SendTo: Bob">
+ <tc:link id="sendToBob" label="SendTo: Bob">
<f:ajax render="isendtoc" execute="isendtoc" listener="#{groupController.sendToListener}"/>
</tc:link>
- <tc:link label="SendTo: All">
+ <tc:link id="sendToAll" label="SendTo: All">
<f:ajax render="isendtoc" execute="isendtoc" listener="#{groupController.sendToListener}"/>
</tc:link>
</tc:button>
@@ -142,7 +142,7 @@
<tc:in id="value" placeholder="type an amount" value="#{groupController.value}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2"/>
<f:facet name="after">
- <tc:selectOneChoice value="#{groupController.currency}">
+ <tc:selectOneChoice id="currency" value="#{groupController.currency}">
<tc:selectItems value="#{groupController.currencies}" var="currency"
itemValue="#{currency}" itemLabel="#{currency.displayName}"/>
<f:ajax listener="#{groupController.compute}" render="valueInEuro" execute="value"/>