This repository has been archived by the owner on Dec 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Add Image Component tests #8
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
.../main/java/com/cognifide/qa/bb/aem65/tests/pageobjects/corecomponents/ImageComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.cognifide.qa.bb.aem65.tests.pageobjects.corecomponents; | ||
|
||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.FindBy; | ||
|
||
import com.cognifide.qa.bb.constants.HtmlTags.Attributes; | ||
import com.cognifide.qa.bb.qualifier.CurrentScope; | ||
import com.cognifide.qa.bb.qualifier.PageObject; | ||
import com.google.inject.Inject; | ||
|
||
@PageObject(css = ".cmp-image__image") | ||
public class ImageComponent { | ||
|
||
@Inject | ||
@CurrentScope | ||
private WebElement component; | ||
|
||
@FindBy(xpath = "../span[contains(@class,'cmp-image__title')]") | ||
private WebElement caption; | ||
|
||
@FindBy(xpath = "..") | ||
private WebElement link; | ||
|
||
public String getSrc() { | ||
return component.getAttribute(Attributes.SRC); | ||
} | ||
|
||
public String getAlt() { | ||
return component.getAttribute(Attributes.ALT); | ||
} | ||
|
||
public String getCaption() { | ||
return caption.getText(); | ||
} | ||
|
||
public String getLink() { | ||
return link.getAttribute(Attributes.HREF); | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/ImageComponentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.cognifide.qa.bb.aem65.tests.corecomponents; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.cognifide.qa.bb.aem.core.api.AemActions; | ||
import com.cognifide.qa.bb.aem.core.component.actions.ConfigureComponentData; | ||
import com.cognifide.qa.bb.aem.core.component.configuration.ResourceFileLocation; | ||
import com.cognifide.qa.bb.aem.core.pages.sling.SlingDataXMLBuilder; | ||
import com.cognifide.qa.bb.aem.core.pages.sling.SlingPageData; | ||
import com.cognifide.qa.bb.aem65.tests.AbstractAemAuthorTest; | ||
import com.cognifide.qa.bb.aem65.tests.pageobjects.corecomponents.ImageComponent; | ||
import com.cognifide.qa.bb.aem65.tests.pages.TestPage; | ||
import com.cognifide.qa.bb.api.actions.ActionException; | ||
import com.cognifide.qa.bb.junit5.guice.Modules; | ||
import com.cognifide.qa.bb.modules.BobcatRunModule; | ||
|
||
import io.qameta.allure.Epic; | ||
import io.qameta.allure.Feature; | ||
|
||
@Modules(BobcatRunModule.class) | ||
@Epic("Core Components authoring tests") | ||
@Feature("Image Component configuration") | ||
@DisplayName("Author can configure for Image Component the...") | ||
public class ImageComponentTest extends AbstractAemAuthorTest { | ||
|
||
private static final String TEST_PAGE_PATH = "/content/we-retail/us/en/image-component-test-page"; | ||
|
||
private TestPage page; | ||
private ImageComponent component; | ||
|
||
@BeforeEach | ||
public void setup() throws ActionException { | ||
controller.execute(AemActions.CREATE_PAGE_VIA_SLING, new SlingPageData(TEST_PAGE_PATH, | ||
SlingDataXMLBuilder.buildFromFile("testpages/core-components/imageComponentTestPage.xml"))); | ||
page = bobcatPageFactory.create("/editor.html" + TEST_PAGE_PATH + ".html", TestPage.class); | ||
page.open(); | ||
} | ||
|
||
@Test | ||
@DisplayName("asset") | ||
public void configureAsset() throws ActionException { | ||
controller.execute(AemActions.CONFIGURE_COMPONENT, | ||
new ConfigureComponentData("container", "Image", 1, | ||
new ResourceFileLocation("component-configs/core-components/image/asset.yaml"))); | ||
component = page.getContent(ImageComponent.class, 1); | ||
assertThat(component.getSrc()).as("Check if the img src is configured") | ||
.matches(String.format(".*%s.*majestic-rainbow.jpeg", TEST_PAGE_PATH)); | ||
} | ||
|
||
@Test | ||
@DisplayName("decorative image metadata") | ||
public void configureDecorativeImage() throws ActionException { | ||
controller.execute(AemActions.CONFIGURE_COMPONENT, | ||
new ConfigureComponentData("container", "Image", 0, new ResourceFileLocation( | ||
"component-configs/core-components/image/decorative-image.yaml"))); | ||
component = page.getContent(ImageComponent.class, 0); | ||
assertThat(component.getAlt()).as("Check if the alt attribute is empty").isEmpty(); | ||
} | ||
|
||
@Test | ||
@DisplayName("alternative text metadata") | ||
public void configureAlternativeText() throws ActionException { | ||
controller.execute(AemActions.CONFIGURE_COMPONENT, | ||
new ConfigureComponentData("container", "Image", 0, new ResourceFileLocation( | ||
"component-configs/core-components/image/alt-text.yaml"))); | ||
component = page.getContent(ImageComponent.class, 0); | ||
assertThat(component.getAlt()).as("Check if the alt text is configured") | ||
.matches("Custom alt text"); | ||
|
||
} | ||
|
||
@Test | ||
@DisplayName("caption metadata") | ||
public void configureCaption() throws ActionException { | ||
controller.execute(AemActions.CONFIGURE_COMPONENT, | ||
new ConfigureComponentData("container", "Image", 0, | ||
new ResourceFileLocation("component-configs/core-components/image/caption.yaml"))); | ||
component = page.getContent(ImageComponent.class, 0); | ||
assertThat(component.getCaption()).as("Check if the caption text is configured") | ||
.matches("Custom caption"); | ||
} | ||
|
||
@Test | ||
@DisplayName("link metadata") | ||
public void configureLink() throws ActionException { | ||
controller.execute(AemActions.CONFIGURE_COMPONENT, | ||
new ConfigureComponentData("container", "Image", 0, | ||
new ResourceFileLocation("component-configs/core-components/image/link.yaml"))); | ||
component = page.getContent(ImageComponent.class, 0); | ||
assertThat(component.getLink()).as("Check if the link is configured") | ||
.endsWith("/content/we-retail/us/en.html"); | ||
} | ||
|
||
@AfterEach | ||
public void cleanup() throws ActionException { | ||
controller.execute(AemActions.DELETE_PAGE_VIA_SLING, new SlingPageData(TEST_PAGE_PATH)); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
aem65/src/test/resources/component-configs/core-components/image/alt-text.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Metadata: | ||
- label: Get alternative text from DAM | ||
type: CHECKBOX | ||
value: false | ||
- label: Alternative Text * | ||
type: TEXTFIELD | ||
value: Custom alt text |
3 changes: 3 additions & 0 deletions
3
aem65/src/test/resources/component-configs/core-components/image/asset.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Asset: | ||
- type: IMAGE | ||
value: majestic-rainbow.jpg | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this asset available in OOTB AEM :)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AEM or core-components-examples, not sure |
10 changes: 10 additions & 0 deletions
10
aem65/src/test/resources/component-configs/core-components/image/caption.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Metadata: | ||
- label: Get caption from DAM | ||
type: CHECKBOX | ||
value: false | ||
- label: Caption | ||
type: TEXTFIELD | ||
value: Custom caption | ||
- label: Display caption as pop-up | ||
type: CHECKBOX | ||
value: false |
4 changes: 4 additions & 0 deletions
4
aem65/src/test/resources/component-configs/core-components/image/decorative-image.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Metadata: | ||
- label: Image is decorative | ||
type: CHECKBOX | ||
value: true |
4 changes: 4 additions & 0 deletions
4
aem65/src/test/resources/component-configs/core-components/image/link.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Metadata: | ||
- label: Link | ||
type: PATHBROWSER | ||
value: /content/we-retail/us/en |
33 changes: 33 additions & 0 deletions
33
aem65/src/test/resources/testpages/core-components/imageComponentTestPage.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" | ||
xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" | ||
xmlns:nt="http://www.jcp.org/jcr/nt/1.0" | ||
jcr:primaryType="cq:Page"> | ||
<jcr:content | ||
cq:template="/conf/we-retail/settings/wcm/templates/content-page" | ||
jcr:primaryType="cq:PageContent" | ||
jcr:title="Image Component Test Page" | ||
sling:resourceType="weretail/components/structure/page" | ||
navTitle="Image Component Test Page" | ||
pageTitle="Image Component Test Page"> | ||
<root | ||
jcr:primaryType="nt:unstructured" | ||
sling:resourceType="wcm/foundation/components/responsivegrid"> | ||
<responsivegrid | ||
jcr:primaryType="nt:unstructured" | ||
sling:resourceType="wcm/foundation/components/responsivegrid"> | ||
<image | ||
jcr:primaryType="nt:unstructured" | ||
sling:resourceType="weretail/components/content/image" | ||
altValueFromDAM="true" | ||
displayPopupTitle="true" | ||
fileReference="/content/dam/we-retail/en/experiences/arctic-surfing-in-lofoten/northern-lights.jpg" | ||
isDecorative="false" | ||
titleValueFromDAM="true"/> | ||
<image_642178494 | ||
jcr:primaryType="nt:unstructured" | ||
sling:resourceType="weretail/components/content/image"/> | ||
</responsivegrid> | ||
</root> | ||
</jcr:content> | ||
</jcr:root> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as in previous one - set this via command line