myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject [myfaces-tobago] branch tobago-4.x updated: add update-row test for tc:sheet
Date Wed, 04 Mar 2020 10:58:47 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/tobago-4.x by this push:
     new 86417b9  add update-row test for tc:sheet
     new 840af4d  Merge pull request #27 from henningn/tobago-4.x
86417b9 is described below

commit 86417b9ca52a59bee12cfcd25eed17206b9bd874
Author: Henning Noeth <hnoeth@apache.org>
AuthorDate: Wed Mar 4 09:36:23 2020 +0100

    add update-row test for tc:sheet
---
 .../tobago/example/demo/DateController.java        |  4 ++
 .../3000-sheet/30-update-row/update-row.test.js    | 54 ++++++++++++++++++++++
 .../3000-sheet/30-update-row/update-row.xhtml      | 42 +++++++++++++++++
 3 files changed, 100 insertions(+)

diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/DateController.java
b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/DateController.java
index d1755f2..727e9e3 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/DateController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/DateController.java
@@ -69,6 +69,10 @@ public class DateController implements Serializable {
     return new Date();
   }
 
+  public long getTimestamp() {
+    return new Date().getTime();
+  }
+
   public Date getSubmitDate() {
     return submitDate;
   }
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/3000-sheet/30-update-row/update-row.test.js
b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/3000-sheet/30-update-row/update-row.test.js
new file mode 100644
index 0000000..46c78aa
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/3000-sheet/30-update-row/update-row.test.js
@@ -0,0 +1,54 @@
+/*
+ * 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("Update timestamp for row 'Mercury' and 'Mars'", function (assert) {
+  var mercuryTimestamp = jQueryFrameFn("#page\\:mainForm\\:sheet\\:1\\:timestamp");
+  var mercuryRefresh = jQueryFrameFn("#page\\:mainForm\\:sheet\\:1\\:refresh");
+  var marsTimestamp = jQueryFrameFn("#page\\:mainForm\\:sheet\\:4\\:timestamp");
+  var marsRefresh = jQueryFrameFn("#page\\:mainForm\\:sheet\\:4\\:refresh");
+
+  var oldMercuryTimestamp = Number(mercuryTimestamp().text().trim());
+  var oldMarsTimestamp = Number(marsTimestamp().text().trim());
+
+  var TTT = new TobagoTestTool(assert);
+  TTT.action(function () {
+    mercuryRefresh().click();
+  });
+  TTT.waitForResponse();
+  TTT.asserts(2, function () {
+    var newMercuryTimestamp = Number(mercuryTimestamp().text().trim());
+    var newMarsTimestamp = Number(marsTimestamp().text().trim());
+
+    assert.ok(newMercuryTimestamp > oldMercuryTimestamp);
+    assert.equal(newMarsTimestamp, oldMarsTimestamp);
+
+    oldMercuryTimestamp = newMercuryTimestamp;
+    oldMarsTimestamp = newMarsTimestamp;
+  });
+  TTT.action(function () {
+    marsRefresh().click();
+  });
+  TTT.waitForResponse();
+  TTT.asserts(2, function () {
+    var newMercuryTimestamp = Number(mercuryTimestamp().text().trim());
+    var newMarsTimestamp = Number(marsTimestamp().text().trim());
+
+    assert.equal(newMercuryTimestamp, oldMercuryTimestamp);
+    assert.ok(newMarsTimestamp > oldMarsTimestamp);
+  });
+  TTT.startTest();
+});
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/3000-sheet/30-update-row/update-row.xhtml
b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/3000-sheet/30-update-row/update-row.xhtml
new file mode 100644
index 0000000..958710f
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/3000-sheet/30-update-row/update-row.xhtml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * 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.
+-->
+
+<ui:composition template="/main.xhtml"
+                xmlns="http://www.w3.org/1999/xhtml"
+                xmlns:f="http://java.sun.com/jsf/core"
+                xmlns:tc="http://myfaces.apache.org/tobago/component"
+                xmlns:ui="http://java.sun.com/jsf/facelets">
+  <tc:sheet value="#{sheetController.solarList}" id="sheet" var="luminary"
+            rows="10" markup="small">
+    <tc:column label="Name">
+      <tc:out value="#{luminary.name}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Orbit">
+      <tc:out value="#{luminary.orbit}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Timestamp">
+      <tc:out id="timestamp" value="#{dateController.timestamp}" labelLayout="skip"/>
+    </tc:column>
+    <tc:column label="Refresh Time">
+      <tc:button id="refresh" label="Refresh">
+        <f:ajax render="timestamp"/>
+      </tc:button>
+    </tc:column>
+  </tc:sheet>
+</ui:composition>


Mime
View raw message