From 144e3d818b38ea78b6e6be58a503d3182994274e Mon Sep 17 00:00:00 2001
From: Michiel Spiritus
Date: Fri, 24 Nov 2023 09:42:22 +0100
Subject: [PATCH 1/3] solves #2625: Add feature to disable the featured page
image inheritance
---
.../com/adobe/cq/wcm/core/components/internal/Utils.java | 4 +++-
.../com/adobe/cq/wcm/core/components/models/Image.java | 7 +++++++
.../cq/wcm/core/components/models/package-info.java | 2 +-
.../image/v3/image/_cq_design_dialog/.content.xml | 9 +++++++++
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/Utils.java b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/Utils.java
index 4a3a04723a..67deba82ff 100644
--- a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/Utils.java
+++ b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/Utils.java
@@ -24,6 +24,7 @@
import java.util.Optional;
import java.util.Set;
+import com.adobe.cq.wcm.core.components.models.Image;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@@ -344,9 +345,10 @@ public static Resource getWrappedImageResourceWithInheritance(Resource resource,
String fileReference = properties.get(DownloadResource.PN_REFERENCE, String.class);
Resource fileResource = resource.getChild(DownloadResource.NN_FILE);
boolean imageFromPageImage = properties.get(PN_IMAGE_FROM_PAGE_IMAGE, StringUtils.isEmpty(fileReference) && fileResource == null);
+ boolean disblePageImageInheritance = currentStyle != null ? currentStyle.get(Image.PN_PAGE_IMAGE_INHERITANCE_DISABLED, false) : false;
boolean altValueFromPageImage = properties.get(PN_ALT_VALUE_FROM_PAGE_IMAGE, imageFromPageImage);
- if (imageFromPageImage) {
+ if (!disblePageImageInheritance && imageFromPageImage) {
Resource inheritedResource = null;
String linkURL = properties.get(ImageResource.PN_LINK_URL, String.class);
boolean actionsEnabled = (currentStyle != null) ?
diff --git a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/Image.java b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/Image.java
index eda135f923..0d4f07a5a1 100644
--- a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/Image.java
+++ b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/Image.java
@@ -40,6 +40,13 @@ public interface Image extends Component {
*/
String PN_IMAGE_FROM_PAGE_IMAGE = "imageFromPageImage";
+ /**
+ * Name of the content policy property that will indicate if the image inheritance the featured image of the page is disabled.
+ *
+ * @since com.adobe.cq.wcm.core.components.models 12.29.0
+ */
+ String PN_PAGE_IMAGE_INHERITANCE_DISABLED = "disablePageImageInheritance";
+
/**
* Name of the resource property that will indicate if the value of the {@code alt} attribute should be inherited
* from the featured image of the page.
diff --git a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/package-info.java b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/package-info.java
index 61420a667f..e2300ac85c 100644
--- a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/package-info.java
+++ b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/package-info.java
@@ -34,7 +34,7 @@
* version, is bound to this proxy component resource type.
*
*/
-@Version("12.28.1")
+@Version("12.29.0")
package com.adobe.cq.wcm.core.components.models;
import org.osgi.annotation.versioning.Version;
diff --git a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/_cq_design_dialog/.content.xml b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/_cq_design_dialog/.content.xml
index 106a4ddaa2..654747fe57 100644
--- a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/_cq_design_dialog/.content.xml
+++ b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/_cq_design_dialog/.content.xml
@@ -76,6 +76,15 @@
checked="{Boolean}false"
uncheckedValue="false"
value="{Boolean}true"/>
+
Date: Sun, 10 Dec 2023 18:50:43 +0100
Subject: [PATCH 2/3] fix typo
---
.../java/com/adobe/cq/wcm/core/components/internal/Utils.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/Utils.java b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/Utils.java
index 67deba82ff..f753bfe1aa 100644
--- a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/Utils.java
+++ b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/Utils.java
@@ -345,10 +345,10 @@ public static Resource getWrappedImageResourceWithInheritance(Resource resource,
String fileReference = properties.get(DownloadResource.PN_REFERENCE, String.class);
Resource fileResource = resource.getChild(DownloadResource.NN_FILE);
boolean imageFromPageImage = properties.get(PN_IMAGE_FROM_PAGE_IMAGE, StringUtils.isEmpty(fileReference) && fileResource == null);
- boolean disblePageImageInheritance = currentStyle != null ? currentStyle.get(Image.PN_PAGE_IMAGE_INHERITANCE_DISABLED, false) : false;
+ boolean disablePageImageInheritance = currentStyle != null ? currentStyle.get(Image.PN_PAGE_IMAGE_INHERITANCE_DISABLED, false) : false;
boolean altValueFromPageImage = properties.get(PN_ALT_VALUE_FROM_PAGE_IMAGE, imageFromPageImage);
- if (!disblePageImageInheritance && imageFromPageImage) {
+ if (!disablePageImageInheritance && imageFromPageImage) {
Resource inheritedResource = null;
String linkURL = properties.get(ImageResource.PN_LINK_URL, String.class);
boolean actionsEnabled = (currentStyle != null) ?
From 7e03821dcd7ec0dcef7690320d23fe9ded051538 Mon Sep 17 00:00:00 2001
From: Michiel
Date: Tue, 12 Dec 2023 21:02:24 +0100
Subject: [PATCH 3/3] Integration Tests Image WIP
---
.../it/seljup/tests/image/ImageTests.java | 34 +++++++++++++------
.../it/seljup/tests/image/v3/ImageIT.java | 26 +++++++++++++-
2 files changed, 48 insertions(+), 12 deletions(-)
diff --git a/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/ImageTests.java b/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/ImageTests.java
index 82ba05b717..9422388766 100644
--- a/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/ImageTests.java
+++ b/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/ImageTests.java
@@ -83,7 +83,7 @@ public void setup(CQClient client, String contextPath, String label, String imag
// 2.
policyPath = Commons.createPagePolicy(client, defaultPageTemplate, label, new HashMap() {{
- put("clientlibs", clientlibs);
+ put("clientlibs", clientlibs);
}});
// 4.
@@ -91,8 +91,8 @@ public void setup(CQClient client, String contextPath, String label, String imag
// 6.
compPath = Commons.addComponentWithRetry(client, proxyPath,testPage + Commons.relParentCompPath, "image", null,
- RequestConstants.TIMEOUT_TIME_MS, RequestConstants.RETRY_TIME_INTERVAL,
- HttpStatus.SC_OK, HttpStatus.SC_CREATED);
+ RequestConstants.TIMEOUT_TIME_MS, RequestConstants.RETRY_TIME_INTERVAL,
+ HttpStatus.SC_OK, HttpStatus.SC_CREATED);
// 7.
editorPage = new PageEditorPage(testPage);
@@ -106,8 +106,8 @@ public void setup(CQClient client, String contextPath, String label, String imag
public void cleanup(CQClient client) throws ClientException, InterruptedException {
client.deletePageWithRetry(testPage, true,false,
- RequestConstants.TIMEOUT_TIME_MS, RequestConstants.RETRY_TIME_INTERVAL,
- HttpStatus.SC_OK);
+ RequestConstants.TIMEOUT_TIME_MS, RequestConstants.RETRY_TIME_INTERVAL,
+ HttpStatus.SC_OK);
}
public void setMinimalProps() throws InterruptedException, TimeoutException {
@@ -183,7 +183,7 @@ public void testAddImage() throws TimeoutException, InterruptedException {
Commons.closeSidePanel();
Commons.switchContext("ContentFrame");
assertTrue(image.isImagePresentWithAltTextAndTitle(testPage, originalDamDescription, originalDamTitle), "Image should be present with alt text " + originalDamDescription
- + " and title " + originalDamTitle);
+ + " and title " + originalDamTitle);
}
public void testAddAltTextAndTitle() throws TimeoutException, InterruptedException {
@@ -199,7 +199,7 @@ public void testAddAltTextAndTitle() throws TimeoutException, InterruptedExcepti
Commons.closeSidePanel();
Commons.switchContext("ContentFrame");
assertTrue(image.isImagePresentWithAltTextAndTitle(testPage, altText, captionText), "Image should be present with alt text " + altText
- + " and title " + captionText);
+ + " and title " + captionText);
}
public void testSetAssetWithoutDescription() throws InterruptedException, TimeoutException {
@@ -209,7 +209,7 @@ public void testSetAssetWithoutDescription() throws InterruptedException, Timeou
editDialog.openMetadataTab();
Commons.saveConfigureDialog();
String assetWithoutDescriptionErrorMessageSelector = ".coral-Form-errorlabel, " +
- "coral-tooltip[variant='error'] > coral-tooltip-content";
+ "coral-tooltip[variant='error'] > coral-tooltip-content";
assertEquals("Error: Please provide an asset which has a description that can be used as alt text.", $(assetWithoutDescriptionErrorMessageSelector).innerText());
}
@@ -218,7 +218,7 @@ public void testSetAssetWithoutDescriptionV3() throws InterruptedException, Time
dragImageWithoutDescription();
Commons.saveConfigureDialog();
String assetWithoutDescriptionErrorMessageSelector = ".coral-Form-errorlabel, " +
- "coral-tooltip[variant='error'] > coral-tooltip-content";
+ "coral-tooltip[variant='error'] > coral-tooltip-content";
String errorIcon = "input[name='./alt'] + coral-icon[icon='alert']";
final WebDriver webDriver = WebDriverRunner.getWebDriver();
((JavascriptExecutor) webDriver).executeScript("arguments[0].scrollIntoView(true);", $(errorIcon));
@@ -238,7 +238,7 @@ public void testAddAltTextAndTitleV3() throws TimeoutException, InterruptedExcep
Commons.closeSidePanel();
Commons.switchContext("ContentFrame");
assertTrue(image.isImagePresentWithAltTextAndTitle(testPage, altText, captionText), "Image should be present with alt text " + altText
- + " and title " + captionText);
+ + " and title " + captionText);
}
public void testDisableCaptionAsPopup() throws TimeoutException, InterruptedException {
@@ -368,7 +368,7 @@ public void testSetSizes() throws TimeoutException, InterruptedException {
editorPage.enterPreviewMode();
Commons.switchContext("ContentFrame");
assertTrue(image.isImagePresentWithSizes(testPage, "(min-width: 36em) 33.3vw, 100vw"), "Image with sizes attribute should be " +
- "present");
+ "present");
}
public void testPageImageWithEmptyAltTextFromPageImage(boolean aem65) throws InterruptedException, ClientException {
@@ -450,6 +450,18 @@ public void testPageImageWithLinkedPage(boolean aem65) throws TimeoutException,
assertTrue(Commons.getCurrentUrl().endsWith(redirectPage+".html"),"Current page should be link URL set after redirection");
}
+ public void testPageImageWithFeaturedImageDisabled(boolean aem65) throws TimeoutException, InterruptedException, ClientException {
+ setPageImage(aem65, testPage, logoNodeName, true);
+ editorPage.open();
+ ImageEditDialog editDialog = image.getEditDialog();
+ Commons.openEditDialog(editorPage, compPath);
+ editDialog.openMetadataTab();
+ Commons.saveConfigureDialog();
+ editorPage.enterPreviewMode();
+ Commons.switchContext("ContentFrame");
+ assertFalse(image.isImagePresentWithFileName(climbingAssetFormatted),"image should not be rendered, page featured image inheritance is disabled");
+ }
+
public void testSetLinkWithTarget() throws TimeoutException, InterruptedException {
Commons.openSidePanel();
dragImage();
diff --git a/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/v3/ImageIT.java b/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/v3/ImageIT.java
index 8cfb300200..6321fd9efe 100644
--- a/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/v3/ImageIT.java
+++ b/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/image/v3/ImageIT.java
@@ -32,7 +32,6 @@
import com.adobe.cq.wcm.core.components.it.seljup.tests.image.ImageTests;
import com.adobe.cq.wcm.core.components.it.seljup.util.Commons;
import com.adobe.cq.wcm.core.components.it.seljup.util.components.image.v2.Image;
-import com.google.common.collect.ImmutableMap;
@Tag("group2")
public class ImageIT extends com.adobe.cq.wcm.core.components.it.seljup.tests.image.v2.ImageIT {
@@ -218,6 +217,31 @@ public void testPageImageWithLinkedPage65() throws TimeoutException, Interrupted
imageTests.testPageImageWithLinkedPage(true);
}
+ /**
+ * Test: set page featured image with featured image disabled
+ */
+ @Tag("IgnoreOnSDK")
+ @Test
+ @DisplayName("Test (6.5): set page featured image with featured image disabled")
+ public void testPageImageWithFeaturedImageDisabled65() throws TimeoutException, InterruptedException, ClientException {
+ testPageImageWithFeaturedImageDisabled(true);
+ }
+
+ /**
+ * Test: set page featured image with featured image disabled
+ */
+ @Test
+ @DisplayName("Test: set page featured image with featured image disabled")
+ public void testPageImageWithFeaturedImageDisabledSdk() throws TimeoutException, InterruptedException, ClientException {
+ testPageImageWithFeaturedImageDisabled(false);
+ }
+
+ private void testPageImageWithFeaturedImageDisabled(boolean aem65) throws ClientException, TimeoutException, InterruptedException {
+ String policyPath = createComponentPolicy("/image-v3", new HashMap() {{ put("disablePageImageInheritance", "true"); }} );
+ imageTests.testPageImageWithFeaturedImageDisabled(aem65);
+ deleteComponentPolicy("/image-v3", policyPath);
+ }
+
/**
* Test: set link with target on image
*/