florianMo commented on code in PR #547:
URL: https://github.com/apache/ofbiz-framework/pull/547#discussion_r989175096


##########
framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRendererTest.java:
##########
@@ -887,6 +887,55 @@ public void renderSortFieldUsesQueryString(@Mocked 
ModelForm modelForm) throws I
                 "linkUrl", new FreemarkerRawString(linkFromQbeString)));
     }
 
+    @Test
+    public void hyperlinkFieldMacroRenderedTitleNotTruncated(@Mocked 
ModelFormField.HyperlinkField hyperlinkField) throws IOException {
+        final String description = "DESCRIPTION";
+        final String title = "TITLE";
+
+        new Expectations() {
+            {
+                hyperlinkField.getDescription(withNotNull()); result = 
description;
+                hyperlinkField.getTarget(withNotNull()); result = "#";
+                request.getAttribute("title"); result = title;
+            }
+        };
+
+        macroFormRenderer.renderHyperlinkField(appendable, new HashMap<>(), 
hyperlinkField);
+        assertAndGetMacroString("makeHyperlinkString", 
ImmutableMap.of("description", description, "title", title));
+    }
+
+    @Test
+    public void hyperlinkFieldMacroRenderedTruncatedNoTitle(@Mocked 
ModelFormField.HyperlinkField hyperlinkField) throws IOException {
+        final String description = "DESCRIPTION";
+
+        new Expectations() {
+            {
+                hyperlinkField.getDescription(withNotNull()); result = 
description;
+                hyperlinkField.getTarget(withNotNull()); result = "#";
+                request.getAttribute("descriptionSize"); result = 5;
+            }
+        };
+
+        macroFormRenderer.renderHyperlinkField(appendable, new HashMap<>(), 
hyperlinkField);
+        assertAndGetMacroString("makeHyperlinkString", 
ImmutableMap.of("description", "DESCR…", "title", description));
+    }
+
+    @Test
+    public void hyperlinkFieldMacroRenderedTruncatedWithTitle(@Mocked 
ModelFormField.HyperlinkField hyperlinkField) throws IOException {
+        final String description = "DESCRIPTION";
+
+        new Expectations() {
+            {
+                hyperlinkField.getDescription(withNotNull()); result = 
description;
+                hyperlinkField.getTarget(withNotNull()); result = "#";
+                request.getAttribute("descriptionSize"); result = 5;
+            }
+        };
+
+        macroFormRenderer.renderHyperlinkField(appendable, new HashMap<>(), 
hyperlinkField);
+        assertAndGetMacroString("makeHyperlinkString", 
ImmutableMap.of("description", "DESCR…", "title", description));

Review Comment:
   - `hyperlinkFieldMacroRenderedTruncatedNoTitle` : we use full `description` 
as title if `description` is truncated (hovering "DESC…" will show 
"DESCRIPTION")
   - `hyperlinkFieldMacroRenderedTruncatedWithTitle` : user provided a `title` 
attribute, but since the text content of the link (`description`) is truncated, 
we use untruncated `description` as the title attribute (hovering "DESC…" will 
show "DESCRIPTION", and the provided `title` won't be used). This is an 
opinionated choice, we can choose the other way around (always use `title` for 
title attribute) if it feels more logical ?
   
   So indeed these 2 tests have the same outcome but for different test 
conditions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to