Skip to content

Commit

Permalink
SITES-22027 - Issue with Image Component "Get caption from DAM" field…
Browse files Browse the repository at this point in the history
… persistence (adobe#2757)

* fixed Issue with Image Component Get caption from DAM field persistence
* revert import changes
* e2e test update
* e2e test for 6.5 added

---------

Co-authored-by: Egor_Cheptsov <[email protected]>
  • Loading branch information
YahorC and Egor_Cheptsov authored Jun 21, 2024
1 parent a32c8a6 commit 7582ad6
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
$cqFileUpload.on("click", "[coral-fileupload-clear]", function() {
altTuple.reset();
captionTuple.reset();
captionTuple.hideCheckbox(true);
altTuple.hideCheckbox(true);
});
$cqFileUpload.on("coral-fileupload:fileadded", function() {
if (isDecorative) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
$cqFileUpload.on("click", "[coral-fileupload-clear]", function() {
altTuple.reset();
captionTuple.reset();
captionTuple.hideCheckbox(true);
altTuple.hideCheckbox(true);
});
$cqFileUpload.on("coral-fileupload:fileadded", function() {
if (isDecorative) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
public class ImageEditDialog extends Dialog {

private static String fileUpload = "coral-fileupload[name='./file']";

private static String clearButtonSDK = "button[class='cq-FileUpload-clear _coral-Button _coral-Button--primary _coral-Button--quiet']";

private static String clearButton65 = "button[class='cq-FileUpload-clear coral3-Button coral3-Button--quiet']";
private static String imageInSidePanel = "coral-card.cq-draggable[data-path=\"%s\"]";
private static String altText = "input[name='./alt']";
private static String linkUrl = "[name='./linkURL']";
Expand All @@ -52,6 +56,8 @@ public class ImageEditDialog extends Dialog {
private static String linkTarget = "coral-checkbox[name='./linkTarget']";
private static String smartCropField = ".cmp-image__editor-dynamicmedia-smartcroprendition[name='./smartCropRendition']";

private static final String AEM_SDK = "sdk";

public void uploadImageFromSidePanel(String imagePath) {
$(String.format(imageInSidePanel,imagePath)).dragAndDropTo(fileUpload, DragAndDropOptions.usingActions());
}
Expand All @@ -78,6 +84,19 @@ public void setTitle(String value) {
content().find(title).sendKeys(value);
}

public void clickClearButton(String aemVersion) {
final WebDriver webDriver = WebDriverRunner.getWebDriver();
if (aemVersion.equals(AEM_SDK)) {
new WebDriverWait(webDriver, RequestConstants.DURATION_TIMEOUT)
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(String.format("%s coral-dialog-header", this.getCssSelector()))));
content().find(clearButtonSDK).click();
} else {
new WebDriverWait(webDriver, RequestConstants.DURATION_TIMEOUT)
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(String.format("%s coral-dialog-header", this.getCssSelector()))));
content().find(clearButton65).click();
}
}

public void checkCaptionAsPopUp() {
CoralCheckbox checkbox = new CoralCheckbox(popUpTitle);
checkbox.click();
Expand Down Expand Up @@ -146,6 +165,16 @@ public boolean isAltFromDAM() {
return checkbox.isChecked();
}

public boolean isTitleFromDAMVisible() {
CoralCheckbox checkbox = new CoralCheckbox(titleValueFromDAM);
return checkbox.isVisible();
}

public boolean isAltFromDAMVisible() {
CoralCheckbox checkbox = new CoralCheckbox(altValueFromDAM);
return checkbox.isVisible();
}

public boolean isPopUpTitle() {
CoralCheckbox checkbox = new CoralCheckbox(popUpTitle);
return checkbox.isChecked();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ public void setup(CQClient client, String contextPath, String label, String imag

// 2.
policyPath = Commons.createPagePolicy(client, defaultPageTemplate, label, new HashMap<String, String>() {{
put("clientlibs", clientlibs);
put("clientlibs", clientlibs);
}});

// 4.
proxyPath = imageRT;

// 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);
Expand All @@ -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 {
Expand Down Expand Up @@ -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 testDragImageToComponent(boolean imageV3) throws TimeoutException, InterruptedException {
Expand Down Expand Up @@ -221,7 +221,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 testSetAssetWithoutDescriptionAsDecorative(boolean imageV3) throws InterruptedException, TimeoutException {
Expand All @@ -243,7 +243,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());
}

Expand All @@ -252,7 +252,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));
Expand All @@ -272,7 +272,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 {
Expand Down Expand Up @@ -402,7 +402,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 {
Expand Down Expand Up @@ -555,6 +555,33 @@ public void testSmartCropOnNGDMImageV3(String cropName) throws TimeoutException,
editorPage.enterPreviewMode();
assertTrue(image.isImagePresentWithSmartCrop(cropName),"NGDM image should be rendered with a smartcrop");
}
public void testClearAssetInputGetDamInfoCheckboxesNotVisibleV3(String aemVersion) throws InterruptedException, TimeoutException {
Commons.openSidePanel();
dragImage();
ImageEditDialog editDialog = image.getEditDialog();
assertTrue(editDialog.isAltFromDAMVisible());
editDialog.openMetadataTab();
assertTrue(editDialog.isTitleFromDAMVisible());
editDialog.openAssetTab();
editDialog.clickClearButton(aemVersion);
assertFalse(editDialog.isAltFromDAMVisible());
editDialog.openMetadataTab();
assertFalse(editDialog.isTitleFromDAMVisible());
}

public void testClearAssetInputGetDamInfoCheckboxesNotVisibleV2(String aemVersion) throws InterruptedException, TimeoutException {
Commons.openSidePanel();
dragImage();
ImageEditDialog editDialog = image.getEditDialog();
editDialog.openMetadataTab();
assertTrue(editDialog.isAltFromDAMVisible());
assertTrue(editDialog.isTitleFromDAMVisible());
editDialog.openAssetTab();
editDialog.clickClearButton(aemVersion);
editDialog.openMetadataTab();
assertFalse(editDialog.isAltFromDAMVisible());
assertFalse(editDialog.isTitleFromDAMVisible());
}

// ----------------------------------------------------------
// private stuff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,18 @@ public void testSetAssetWithoutDescription() throws TimeoutException, Interrupte
public void testSetAssetWithoutDescriptionAsDecorative() throws TimeoutException, InterruptedException {
imageTests.testSetAssetWithoutDescriptionAsDecorative(false);
}
@Tag("IgnoreOn65")
@Test
@DisplayName("Test: clear asset input field, get Dam info checkboxes become invisible V2")
public void testClearAssetInputGetDamInfoCheckboxesNotVisibleSDK() throws InterruptedException, TimeoutException {
imageTests.testClearAssetInputGetDamInfoCheckboxesNotVisibleV2("sdk");
}

@Tag("IgnoreOnSDK")
@Test
@DisplayName("Test: clear asset input field, get Dam info checkboxes become invisible V2")
public void testClearAssetInputGetDamInfoCheckboxesNotVisible65() throws InterruptedException, TimeoutException {
imageTests.testClearAssetInputGetDamInfoCheckboxesNotVisibleV2("6.5");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,17 @@ public void testSmartCropOnNGDMImageV3_SmallCrop() throws TimeoutException, Inte
public void testSetAssetWithoutDescriptionAsDecorative() throws TimeoutException, InterruptedException {
imageTests.testSetAssetWithoutDescriptionAsDecorative(true);
}
@Tag("IgnoreOn65")
@Test
@DisplayName("Test: clear asset input field, get Dam info checkboxes become invisible V3")
public void testClearAssetInputGetDamInfoCheckboxesNotVisibleSDK() throws InterruptedException, TimeoutException {
imageTests.testClearAssetInputGetDamInfoCheckboxesNotVisibleV3("sdk");
}

@Tag("IgnoreOnSDK")
@Test
@DisplayName("Test: clear asset input field, get Dam info checkboxes become invisible V3")
public void testClearAssetInputGetDamInfoCheckboxesNotVisible65() throws InterruptedException, TimeoutException {
imageTests.testClearAssetInputGetDamInfoCheckboxesNotVisibleV3("6.5");
}
}

0 comments on commit 7582ad6

Please sign in to comment.