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 2024/02/07 10:54:09 UTC
(myfaces-tobago) branch tobago-5.x updated: test(segmentLayout): composite components are not rendered correctly
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 a784e0c6ab test(segmentLayout): composite components are not rendered correctly
a784e0c6ab is described below
commit a784e0c6ab97d21eb9d78d4fb9d94f4430f956cc
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Tue Feb 6 12:50:15 2024 +0100
test(segmentLayout): composite components are not rendered correctly
* test inputAsText.xhtml composite component
* test h:inputText
* test composite component with segment layout which includes another composite component
---
.../4650-segmentLayout/Segment_Layout.test.js | 38 ++++++++++++++++++++++
.../4650-segmentLayout/Segment_Layout.xhtml | 38 ++++++++++++++++++++++
.../Composite_Components.xhtml | 36 ++++++++++----------
.../resources/demo-components/inputAsText.xhtml | 6 ++--
...tAsText.xhtml => inputAsTextPanelWrapper.xhtml} | 4 +--
.../{inputAsText.xhtml => output.xhtml} | 13 +++-----
...tAsText.xhtml => segmentLayoutWithOutput.xhtml} | 18 +++++-----
7 files changed, 111 insertions(+), 42 deletions(-)
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4650-segmentLayout/Segment_Layout.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4650-segmentLayout/Segment_Layout.test.js
new file mode 100644
index 0000000000..9b6caca4fe
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4650-segmentLayout/Segment_Layout.test.js
@@ -0,0 +1,38 @@
+/*
+ * 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, querySelectorAllFn} from "/script/tobago-test.js";
+
+it("Check DOM of segement layout", function () {
+ const segmentLayout = elementByIdFn("page:mainForm:segmentLayout");
+ const segLayoutIn = elementByIdFn("page:mainForm:segLayoutIn:in");
+ const segLayoutOut = elementByIdFn("page:mainForm:segLayoutOut:out");
+ const segLayoutNotRendered = elementByIdFn("page:mainForm:segLayoutNotRendered:in");
+ const style = elementByIdFn("page:mainForm:style");
+ const segmentLayoutOutputs = querySelectorAllFn("tobago-segment-layout[id^='page:mainForm:segmentLayoutComposite'] tobago-out span");
+
+ expect(segmentLayout().children.length).toBe(4);
+ expect(segmentLayout().querySelectorAll("div").length).toBe(3);
+ expect(segLayoutIn()).not.toBeNull();
+ expect(segLayoutOut()).not.toBeNull();
+ expect(segLayoutNotRendered()).toBeNull();
+ expect(style()).not.toBeNull();
+ expect(style().parentElement.tagName).toBe("TOBAGO-SEGMENT-LAYOUT");
+ expect(segmentLayoutOutputs().length).toBe(2);
+ expect(segmentLayoutOutputs()[0].textContent).toBe("composite-composite output value");
+ expect(segmentLayoutOutputs()[1].textContent).toBe("composite out value");
+});
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4650-segmentLayout/Segment_Layout.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4650-segmentLayout/Segment_Layout.xhtml
new file mode 100644
index 0000000000..afd78eb586
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/4650-segmentLayout/Segment_Layout.xhtml
@@ -0,0 +1,38 @@
+<?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:dc="http://xmlns.jcp.org/jsf/composite/demo-components"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
+ <ui:param name="title" value="Composite Components"/>
+
+ <tc:segmentLayout id="segmentLayout" medium="6seg">
+ <dc:inputAsText id="segLayoutIn" value="tc:in"/>
+ <dc:inputAsText id="segLayoutOut" value="tc:out" asText="true"/>
+ <dc:inputAsText id="segLayoutNotRendered" value="this should NOT be rendered" rendered="false"/>
+ <h:inputText id="hInputText"/>
+ <tc:style id="style" width="200px"/>
+ </tc:segmentLayout>
+
+ <dc:segmentLayoutWithOutput id="segmentLayoutComposite" outValue="composite out value"
+ outputValue="composite-composite output value"/>
+</ui:composition>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/5500-compositeComponent/Composite_Components.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/5500-compositeComponent/Composite_Components.xhtml
index 736cab7d36..2fd01b877d 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/5500-compositeComponent/Composite_Components.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/5500-compositeComponent/Composite_Components.xhtml
@@ -25,43 +25,43 @@
<ui:param name="title" value="Composite Components"/>
<tc:section label="no layout manager">
- <dc:inputAsText id="noLayoutIn" value="tc:in"/>
- <dc:inputAsText id="noLayoutOut" value="tc:out" asText="true"/>
- <dc:inputAsText id="noLayoutNotRendered" value="this should NOT be rendered" rendered="false"/>
+ <dc:inputAsTextPanelWrapper id="noLayoutIn" value="tc:in"/>
+ <dc:inputAsTextPanelWrapper id="noLayoutOut" value="tc:out" asText="true"/>
+ <dc:inputAsTextPanelWrapper id="noLayoutNotRendered" value="this should NOT be rendered" rendered="false"/>
</tc:section>
<tc:section label="flowLayout">
<tc:flowLayout>
- <dc:inputAsText id="flowLayoutIn" value="tc:in"/>
- <dc:inputAsText id="flowLayoutOut" value="tc:out" asText="true"/>
- <dc:inputAsText id="flowLayoutNotRendered" value="this should NOT be rendered" rendered="false"/>
+ <dc:inputAsTextPanelWrapper id="flowLayoutIn" value="tc:in"/>
+ <dc:inputAsTextPanelWrapper id="flowLayoutOut" value="tc:out" asText="true"/>
+ <dc:inputAsTextPanelWrapper id="flowLayoutNotRendered" value="this should NOT be rendered" rendered="false"/>
</tc:flowLayout>
</tc:section>
<tc:section label="flexLayout">
<tc:flexLayout columns="1fr 1fr">
- <dc:inputAsText id="flexLayoutIn" value="tc:in"/>
- <dc:inputAsText id="flexLayoutOut" value="tc:out" asText="true"/>
- <dc:inputAsText id="flexLayoutNotRendered" value="this should NOT be rendered" rendered="false"/>
+ <dc:inputAsTextPanelWrapper id="flexLayoutIn" value="tc:in"/>
+ <dc:inputAsTextPanelWrapper id="flexLayoutOut" value="tc:out" asText="true"/>
+ <dc:inputAsTextPanelWrapper id="flexLayoutNotRendered" value="this should NOT be rendered" rendered="false"/>
</tc:flexLayout>
</tc:section>
<tc:section label="segmentLayout">
<tc:segmentLayout medium="6seg">
- <dc:inputAsText id="segLayoutIn" value="tc:in"/>
- <dc:inputAsText id="segLayoutOut" value="tc:out" asText="true"/>
- <dc:inputAsText id="segLayoutNotRendered" value="this should NOT be rendered" rendered="false"/>
+ <dc:inputAsTextPanelWrapper id="segLayoutIn" value="tc:in"/>
+ <dc:inputAsTextPanelWrapper id="segLayoutOut" value="tc:out" asText="true"/>
+ <dc:inputAsTextPanelWrapper id="segLayoutNotRendered" value="this should NOT be rendered" rendered="false"/>
</tc:segmentLayout>
</tc:section>
<tc:section label="gridLayout">
<tc:gridLayout columns="1fr 1fr" rows="auto">
- <dc:inputAsText id="gridLayoutIn" value="tc:in"/>
- <dc:inputAsText id="gridLayoutOut" value="tc:out" asText="true"/>
- <dc:inputAsText id="gridLayoutNotRendered" value="this should NOT be rendered" rendered="false"/>
+ <dc:inputAsTextPanelWrapper id="gridLayoutIn" value="tc:in"/>
+ <dc:inputAsTextPanelWrapper id="gridLayoutOut" value="tc:out" asText="true"/>
+ <dc:inputAsTextPanelWrapper id="gridLayoutNotRendered" value="this should NOT be rendered" rendered="false"/>
</tc:gridLayout>
</tc:section>
<tc:section label="splitLayout">
<tc:splitLayout columns="1fr 1fr">
- <dc:inputAsText id="splitLayoutIn" value="tc:in"/>
- <dc:inputAsText id="splitLayoutOut" value="tc:out" asText="true"/>
- <dc:inputAsText id="splitLayoutNotRendered" value="this should NOT be rendered" rendered="false"/>
+ <dc:inputAsTextPanelWrapper id="splitLayoutIn" value="tc:in"/>
+ <dc:inputAsTextPanelWrapper id="splitLayoutOut" value="tc:out" asText="true"/>
+ <dc:inputAsTextPanelWrapper id="splitLayoutNotRendered" value="this should NOT be rendered" rendered="false"/>
</tc:splitLayout>
</tc:section>
</ui:composition>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsText.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsText.xhtml
index f45a2fd27c..84b829304c 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsText.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsText.xhtml
@@ -26,9 +26,7 @@
<cc:attribute name="asText" default="false"/>
</cc:interface>
<cc:implementation>
- <tc:panel id="wrapper">
- <tc:in id="in" label="#{cc.attrs.label}" value="#{cc.attrs.value}" rendered="#{!cc.attrs.asText}"/>
- <tc:out id="out" label="#{cc.attrs.label}" value="#{cc.attrs.value}" rendered="#{cc.attrs.asText}"/>
- </tc:panel>
+ <tc:in id="in" label="#{cc.attrs.label}" value="#{cc.attrs.value}" rendered="#{!cc.attrs.asText}"/>
+ <tc:out id="out" label="#{cc.attrs.label}" value="#{cc.attrs.value}" rendered="#{cc.attrs.asText}"/>
</cc:implementation>
</html>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsText.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsTextPanelWrapper.xhtml
similarity index 92%
copy from tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsText.xhtml
copy to tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsTextPanelWrapper.xhtml
index f45a2fd27c..7c37245cfd 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsText.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsTextPanelWrapper.xhtml
@@ -16,8 +16,8 @@
* limitations under the License.
-->
<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:cc="http://xmlns.jcp.org/jsf/composite"
xmlns:tc="http://myfaces.apache.org/tobago/component">
<cc:interface>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsText.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/output.xhtml
similarity index 68%
copy from tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsText.xhtml
copy to tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/output.xhtml
index f45a2fd27c..c161bc2d6e 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsText.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/output.xhtml
@@ -16,19 +16,14 @@
* limitations under the License.
-->
<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:cc="http://xmlns.jcp.org/jsf/composite"
xmlns:tc="http://myfaces.apache.org/tobago/component">
<cc:interface>
- <cc:attribute name="label"/>
- <cc:attribute name="value"/>
- <cc:attribute name="asText" default="false"/>
+ <cc:attribute name="name"/>
</cc:interface>
<cc:implementation>
- <tc:panel id="wrapper">
- <tc:in id="in" label="#{cc.attrs.label}" value="#{cc.attrs.value}" rendered="#{!cc.attrs.asText}"/>
- <tc:out id="out" label="#{cc.attrs.label}" value="#{cc.attrs.value}" rendered="#{cc.attrs.asText}"/>
- </tc:panel>
+ <tc:out value="#{cc.attrs.name}"/>
</cc:implementation>
</html>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsText.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/segmentLayoutWithOutput.xhtml
similarity index 68%
copy from tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsText.xhtml
copy to tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/segmentLayoutWithOutput.xhtml
index f45a2fd27c..f25afda13d 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/inputAsText.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/resources/demo-components/segmentLayoutWithOutput.xhtml
@@ -16,19 +16,19 @@
* limitations under the License.
-->
<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:cc="http://xmlns.jcp.org/jsf/composite"
+ xmlns:dc="http://xmlns.jcp.org/jsf/composite/demo-components"
xmlns:tc="http://myfaces.apache.org/tobago/component">
<cc:interface>
- <cc:attribute name="label"/>
- <cc:attribute name="value"/>
- <cc:attribute name="asText" default="false"/>
+ <cc:attribute name="outputValue"/>
+ <cc:attribute name="outValue"/>
</cc:interface>
<cc:implementation>
- <tc:panel id="wrapper">
- <tc:in id="in" label="#{cc.attrs.label}" value="#{cc.attrs.value}" rendered="#{!cc.attrs.asText}"/>
- <tc:out id="out" label="#{cc.attrs.label}" value="#{cc.attrs.value}" rendered="#{cc.attrs.asText}"/>
- </tc:panel>
+ <tc:segmentLayout large="3seg 9seg">
+ <dc:output name="#{cc.attrs.outputValue}"/>
+ <tc:out value="#{cc.attrs.outValue}"/>
+ </tc:segmentLayout>
</cc:implementation>
</html>