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 2023/11/13 15:47:18 UTC
(myfaces-tobago) branch tobago-5.x updated: test(f:ajax): support for resetValues=true
This is an automated email from the ASF dual-hosted git repository.
hnoeth pushed a commit to branch tobago-5.x
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/tobago-5.x by this push:
new 2da6053c76 test(f:ajax): support for resetValues=true
2da6053c76 is described below
commit 2da6053c76af3dd45411dddc2293dfb94ec6b60b
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Mon Nov 13 16:38:37 2023 +0100
test(f:ajax): support for resetValues=true
Issue: TOBAGO-2259
---
.../webapp/content/900-test/5900-ajax/Ajax.test.js | 42 ++++++++++++++++++++++
.../webapp/content/900-test/5900-ajax/Ajax.xhtml | 35 ++++++++++++++++++
2 files changed, 77 insertions(+)
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/5900-ajax/Ajax.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/5900-ajax/Ajax.test.js
new file mode 100644
index 0000000000..07d444903b
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/5900-ajax/Ajax.test.js
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+import {elementByIdFn, querySelectorFn} from "/script/tobago-test.js";
+import {JasmineTestTool} from "/tobago/test/tobago-test-tool.js";
+
+it("no layout manager", function (done) {
+ const input = elementByIdFn("page:mainForm:form:input::field");
+ const output = querySelectorFn("#page\\:mainForm\\:form\\:output .form-control-plaintext")
+ const submit = elementByIdFn("page:mainForm:form:submit");
+ const reset = elementByIdFn("page:mainForm:form:reset");
+
+ const test = new JasmineTestTool(done);
+ test.setup(() => input().value === '', null, "click", reset);
+ test.do(() => expect(input().value).toBe(""));
+ test.do(() => expect(output().textContent).toBe(""));
+
+ test.do(() => input().value = "Tobago");
+ test.event("click", submit, () => output().textContent === "Tobago");
+ test.do(() => expect(input().value).toBe("Tobago"));
+ test.do(() => expect(output().textContent).toBe("Tobago"));
+
+ test.event("click", reset, () => output().textContent === "");
+ test.do(() => expect(input().value).toBe(""));
+ test.do(() => expect(output().textContent).toBe(""));
+
+ test.start();
+});
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/5900-ajax/Ajax.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/5900-ajax/Ajax.xhtml
new file mode 100644
index 0000000000..2174a79b33
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/5900-ajax/Ajax.xhtml
@@ -0,0 +1,35 @@
+<?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://xmlns.jcp.org/jsf/core"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
+
+ <tc:form id="form">
+ <tc:in id="input" label="Input" value="#{inController.changeValue}"/>
+ <tc:out id="output" label="Output" value="#{inController.changeValue}"/>
+ <tc:button id="submit" label="Submit"/>
+ <tc:button id="reset" label="Reset">
+ <f:ajax resetValues="true" render="form"/>
+ </tc:button>
+ </tc:form>
+
+</ui:composition>