From ff0c0f28611aa8769525f85c4a0bb32f38d8e1a8 Mon Sep 17 00:00:00 2001 From: Alexandru Marian Stancioiu Date: Mon, 22 Jul 2024 16:17:48 +0300 Subject: [PATCH 1/2] [SITES-22335] Selenium flaky test fix - add timeout before rolling out --- .../cq/wcm/core/components/it/seljup/tests/page/PageTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/page/PageTests.java b/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/page/PageTests.java index 99469ce491..c2c58394a4 100644 --- a/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/page/PageTests.java +++ b/testing/it/e2e-selenium/src/test/java/com/adobe/cq/wcm/core/components/it/seljup/tests/page/PageTests.java @@ -661,7 +661,7 @@ public void testBlueprintPageProperties() throws ClientException, InterruptedExc propertiesPage.clickTab("blueprint", BlueprintTab.class); rolloutDialog = blueprintTab.rollout(); - + Commons.webDriverWait(RequestConstants.WEBDRIVER_WAIT_TIME_MS); // check rollout now rolloutDialog.rolloutNow(); From 9a28610eb20505d4c005d639360d2793f0797248 Mon Sep 17 00:00:00 2001 From: Alexandru Marian Stancioiu Date: Thu, 25 Jul 2024 14:07:05 +0300 Subject: [PATCH 2/2] [SITES-23452] Further alt text validation improvements for Image Component Alt Text --- .../v3/image/clientlibs/editor/js/image.js | 80 +++++++++---------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/editor/js/image.js b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/editor/js/image.js index ff3982c458..3243efed07 100644 --- a/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/editor/js/image.js +++ b/content/src/content/jcr_root/apps/core/wcm/components/image/v3/image/clientlibs/editor/js/image.js @@ -139,6 +139,7 @@ ); }); $cqFileUpload.on("click", "[coral-fileupload-clear]", function() { + $altTextField.adaptTo("foundation-field").setRequired(false); altTuple.reset(); captionTuple.reset(); captionTuple.hideCheckbox(true); @@ -148,6 +149,7 @@ if (isDecorative) { altTuple.hideTextfield(isDecorative.checked); } + $altTextField.adaptTo("foundation-field").setRequired(!isDecorative.checked); altTuple.hideCheckbox(true); captionTuple.hideTextfield(false); captionTuple.hideCheckbox(true); @@ -193,7 +195,13 @@ selector: altInputSelector, validate: function() { var seededValue = document.querySelector(altInputSelector).getAttribute("data-seeded-value"); - var isImageFromPageImageChecked = document.querySelector('coral-checkbox[name="./imageFromPageImage"]').checked; + var imageFromPageImage = document.querySelector('coral-checkbox[name="./imageFromPageImage"]'); + var isImageFromPageImageChecked; + if (imageFromPageImage != null) { + isImageFromPageImageChecked = imageFromPageImage.checked; + } else { + isImageFromPageImageChecked = false; + } var altFromDAM = document.querySelector('coral-checkbox[name="./altValueFromDAM"]'); var isAltFromDAMChecked = altFromDAM.checked; var isAltFromDAMDisabled = altFromDAM.disabled; @@ -604,49 +612,12 @@ mutations.forEach(function(mutation) { if (mutation.type === "attributes") { var isAltCheckboxChecked = $(altCheckboxSelector).attr("checked"); - var alertIcon = $(altInputAlertIconSelector); - var assetTab = $(assetTabSelector); - var assetTabAlertIcon = $(assetTabAlertIconSelector); - if (mutation.attributeName === "data-seeded-value") { - if (isAltCheckboxChecked) { - if ($(altInputSelector).val()) { - if (alertIcon.length) { - $(altInputSelector).removeClass("is-invalid"); - alertIcon.hide(); - assetTab.removeClass("is-invalid"); - assetTabAlertIcon.hide(); - } - } else { - if (alertIcon.length) { - $(altInputSelector).addClass("is-invalid"); - alertIcon.show(); - assetTab.addClass("is-invalid"); - assetTabAlertIcon.show(); - } - } - } - } - - if (mutation.attributeName === "disabled") { - if ($(altInputSelector).val()) { - if (alertIcon.length) { - $(altInputSelector).removeClass("is-invalid"); - alertIcon.hide(); - assetTab.removeClass("is-invalid"); - assetTabAlertIcon.hide(); - } - } + if (mutation.attributeName === "data-seeded-value" && isAltCheckboxChecked) { + toggleAltTextValidity(); } - if (mutation.attributeName === "invalid") { - if (!$(altInputSelector).val()) { - if (alertIcon.length) { - $(altInputSelector).addClass("is-invalid"); - alertIcon.show(); - assetTab.addClass("is-invalid"); - assetTabAlertIcon.show(); - } - } + if (["invalid", "disabled"].includes(mutation.attributeName)) { + toggleAltTextValidity(); } } }); @@ -660,4 +631,29 @@ } } + /** + * Toggles alt text validity based on the value of the alt text field + */ + function toggleAltTextValidity() { + var alertIcon = $(altInputAlertIconSelector); + if (!alertIcon.length) { + return; + } + + var assetTab = $(assetTabSelector); + var assetTabAlertIcon = $(assetTabAlertIconSelector); + + if ($(altInputSelector).val()) { + $(altInputSelector).removeClass("is-invalid"); + alertIcon.hide(); + assetTab.removeClass("is-invalid"); + assetTabAlertIcon.hide(); + } else { + $(altInputSelector).addClass("is-invalid"); + alertIcon.show(); + assetTab.addClass("is-invalid"); + assetTabAlertIcon.show(); + } + } + })(jQuery, Granite);