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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Cognifide/coreComponents-Teaser
Tests for Teaser component
- Loading branch information
Showing
10 changed files
with
275 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
...main/java/com/cognifide/qa/bb/aem65/tests/pageobjects/corecomponents/TeaserComponent.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,64 @@ | ||
package com.cognifide.qa.bb.aem65.tests.pageobjects.corecomponents; | ||
|
||
import com.cognifide.qa.bb.constants.HtmlTags; | ||
import com.cognifide.qa.bb.qualifier.CurrentScope; | ||
import com.cognifide.qa.bb.qualifier.PageObject; | ||
import com.google.inject.Inject; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.FindBy; | ||
|
||
import java.util.List; | ||
|
||
@PageObject(css = ".cmp-teaser") | ||
public class TeaserComponent { | ||
|
||
@Inject | ||
@CurrentScope | ||
private WebElement component; | ||
|
||
@FindBy(css = ".cmp-image__image") | ||
private WebElement image; | ||
|
||
@FindBy(css = ".cmp-teaser__title") | ||
private WebElement title; | ||
|
||
@FindBy(css = ".cmp-teaser__title-link") | ||
private WebElement titleLink; | ||
|
||
@FindBy(css = ".cmp-teaser__description > p") | ||
private WebElement description; | ||
|
||
@FindBy(css = ".cmp-teaser__description") | ||
private List<WebElement> elements; | ||
|
||
@FindBy(css = ".cmp-teaser__description") | ||
private WebElement isDescriptionVisible; | ||
|
||
public boolean isTeaserDescriptionEmpty() { | ||
return elements.isEmpty(); | ||
} | ||
|
||
public String getTeaserDescriptionFromLinkedPage() { | ||
return isDescriptionVisible.getText(); | ||
} | ||
|
||
public String getTeaserImage() { | ||
return image.getAttribute(HtmlTags.Attributes.TITLE); | ||
} | ||
|
||
public String getTeaserTitle() { | ||
return title.getText(); | ||
} | ||
|
||
public String getTeaserTitleFromLinkedPage() { | ||
return titleLink.getText(); | ||
} | ||
|
||
public String getTeaserTitleLink() { | ||
return titleLink.getAttribute(HtmlTags.Attributes.HREF); | ||
} | ||
|
||
public String getTeaserDescription() { | ||
return description.getText(); | ||
} | ||
} |
141 changes: 141 additions & 0 deletions
141
aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/TeaserComponentTest.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,141 @@ | ||
package com.cognifide.qa.bb.aem65.tests.corecomponents; | ||
|
||
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.TeaserComponent; | ||
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; | ||
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 static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* These tests verify if Bobcat can handle the configuration of the Teaser Component | ||
* https://opensource.adobe.com/aem-core-wcm-components/library/teaser.html | ||
*/ | ||
|
||
@Modules(BobcatRunModule.class) | ||
@Epic("Core Components authoring tests") | ||
@Feature("Teaser Component configuration") | ||
@DisplayName("Author can configure for Teaser Component the...") | ||
|
||
public class TeaserComponentTest extends AbstractAemAuthorTest { | ||
|
||
private static final String TEST_PAGE_PATH = "/content/core-components-examples/library/teaserComponentTestPage"; | ||
|
||
private TestPage page; | ||
private TeaserComponent component; | ||
|
||
@BeforeEach | ||
public void createAndOpenTestPage() throws ActionException { | ||
controller.execute(AemActions.CREATE_PAGE_VIA_SLING, new SlingPageData(TEST_PAGE_PATH, | ||
SlingDataXMLBuilder | ||
.buildFromFile("testpages/core-components/teaserComponentTestPage.xml"))); | ||
page = bobcatPageFactory.create("/editor.html" + TEST_PAGE_PATH + ".html", TestPage.class); | ||
page.open(); | ||
} | ||
|
||
@Test | ||
@DisplayName("image") | ||
public void configureImageTeaser() throws ActionException { | ||
controller.execute(AemActions.CONFIGURE_COMPONENT, | ||
new ConfigureComponentData("container", "Teaser (v1)", 0, | ||
new ResourceFileLocation("component-configs/core-components/teaser/image.yaml"))); | ||
component = page.getContent(TeaserComponent.class, 0); | ||
assertThat(component.getTeaserImage()) | ||
.as("Check if image is configured") | ||
.matches("Gray lava rock formation"); | ||
} | ||
|
||
@Test | ||
@DisplayName("title") | ||
public void configureTitle() throws ActionException { | ||
controller.execute(AemActions.CONFIGURE_COMPONENT, | ||
new ConfigureComponentData("container", "Teaser (v1)", 0, | ||
new ResourceFileLocation("component-configs/core-components/teaser/title.yaml"))); | ||
component = page.getContent(TeaserComponent.class, 0); | ||
assertThat(component.getTeaserTitle()) | ||
.as("Check if the title is configured") | ||
.matches("This is teaser title"); | ||
} | ||
|
||
@Test | ||
@DisplayName("link on title") | ||
public void configureTitleLink() throws ActionException { | ||
controller.execute(AemActions.CONFIGURE_COMPONENT, | ||
new ConfigureComponentData("container", "Teaser (v1)", 0, | ||
new ResourceFileLocation("component-configs/core-components/teaser/titleLink.yaml"))); | ||
component = page.getContent(TeaserComponent.class, 0); | ||
assertThat(component.getTeaserTitleLink()) | ||
.as("Check if the link is configured") | ||
.endsWith("/content/core-components-examples/library/teaser.html"); | ||
} | ||
|
||
|
||
@Test | ||
@DisplayName("title taken from linked page") | ||
public void configureTitleFromLinkedPage() throws ActionException { | ||
controller.execute(AemActions.CONFIGURE_COMPONENT, | ||
new ConfigureComponentData("container", "Teaser (v1)", 0, | ||
new ResourceFileLocation( | ||
"component-configs/core-components/teaser/titleFromLinkedPage.yaml"))); | ||
component = page.getContent(TeaserComponent.class, 0); | ||
assertThat(component.getTeaserTitleFromLinkedPage()) | ||
.as("Check if the title is taken from linked page") | ||
.matches("Women"); | ||
} | ||
|
||
@Test | ||
@DisplayName("description") | ||
public void configureDescription() throws ActionException { | ||
controller.execute(AemActions.CONFIGURE_COMPONENT, | ||
new ConfigureComponentData("container", "Teaser (v1)", 0, | ||
new ResourceFileLocation("component-configs/core-components/teaser/description.yaml"))); | ||
component = page.getContent(TeaserComponent.class, 0); | ||
assertThat(component.getTeaserDescription()) | ||
.as("Check if the description is configured") | ||
.matches("This is teaser description"); | ||
} | ||
|
||
@Test | ||
@DisplayName("empty description taken from linked page") | ||
public void configureDescriptionFromLinkedPage() throws ActionException { | ||
controller.execute(AemActions.CONFIGURE_COMPONENT, | ||
new ConfigureComponentData("container", "Teaser (v1)", 0, | ||
new ResourceFileLocation( | ||
"component-configs/core-components/teaser/descriptionEmptyFromLinkedPage.yaml"))); | ||
component = page.getContent(TeaserComponent.class, 0); | ||
assertThat(component.isTeaserDescriptionEmpty()) | ||
.as("Check if empty description isn't added into component") | ||
.isTrue(); | ||
} | ||
|
||
@Test | ||
@DisplayName("description taken from linked page") | ||
public void configureDescriptionFromLinkedPage2() throws ActionException { | ||
controller.execute(AemActions.CONFIGURE_COMPONENT, | ||
new ConfigureComponentData("container", "Teaser (v1)", 0, | ||
new ResourceFileLocation( | ||
"component-configs/core-components/teaser/descriptionFromLinkedPage.yaml"))); | ||
component = page.getContent(TeaserComponent.class, 0); | ||
assertThat(component.getTeaserDescriptionFromLinkedPage()) | ||
.as("Check if the description is taken from linked page") | ||
.matches("Test description from Properties"); | ||
} | ||
|
||
@AfterEach | ||
public void deleteTestPage() throws ActionException { | ||
controller.execute(AemActions.DELETE_PAGE_VIA_SLING, new SlingPageData(TEST_PAGE_PATH)); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
aem65/src/test/resources/component-configs/core-components/teaser/description.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 @@ | ||
Text: | ||
- label: Description | ||
type: RICHTEXT | ||
value: This is teaser description |
9 changes: 9 additions & 0 deletions
9
...st/resources/component-configs/core-components/teaser/descriptionEmptyFromLinkedPage.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,9 @@ | ||
Link & Actions: | ||
- label: Link | ||
type: PATHBROWSER | ||
value: /content/we-retail/language-masters/en/women | ||
|
||
Text: | ||
- label: Get description from linked page | ||
type: CHECKBOX | ||
value: true |
9 changes: 9 additions & 0 deletions
9
...rc/test/resources/component-configs/core-components/teaser/descriptionFromLinkedPage.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,9 @@ | ||
Link & Actions: | ||
- label: Link | ||
type: PATHBROWSER | ||
value: /content/core-components-examples/library/teaserComponentTestPage | ||
|
||
Text: | ||
- label: Get description from linked page | ||
type: CHECKBOX | ||
value: true |
3 changes: 3 additions & 0 deletions
3
aem65/src/test/resources/component-configs/core-components/teaser/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,3 @@ | ||
Image: | ||
- type: IMAGE | ||
value: lava-rock-formation.jpg |
4 changes: 4 additions & 0 deletions
4
aem65/src/test/resources/component-configs/core-components/teaser/title.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 @@ | ||
Text: | ||
- label: Title | ||
type: TEXTFIELD | ||
value: This is teaser title |
9 changes: 9 additions & 0 deletions
9
aem65/src/test/resources/component-configs/core-components/teaser/titleFromLinkedPage.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,9 @@ | ||
Text: | ||
- label: Get title from linked page | ||
type: CHECKBOX | ||
value: true | ||
|
||
Link & Actions: | ||
- label: Link | ||
type: PATHBROWSER | ||
value: /content/we-retail/language-masters/en/women |
4 changes: 4 additions & 0 deletions
4
aem65/src/test/resources/component-configs/core-components/teaser/titleLink.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 @@ | ||
Link & Actions: | ||
- label: Link | ||
type: PATHBROWSER | ||
value: /content/core-components-examples/library/teaser |
28 changes: 28 additions & 0 deletions
28
aem65/src/test/resources/testpages/core-components/teaserComponentTestPage.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,28 @@ | ||
<?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/core-components-examples/settings/wcm/templates/content-page" | ||
jcr:description="Test description from Properties" | ||
jcr:primaryType="cq:PageContent" | ||
jcr:title="Teaser Component Test Page" | ||
sling:resourceType="core-components-examples/components/page" | ||
navTitle="Teaser Component Test Page" | ||
pageTitle="Teaser 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"> | ||
<teaser | ||
jcr:description="Teaser description text" | ||
jcr:primaryType="nt:unstructured" | ||
jcr:title="Teaser title text" | ||
sling:resourceType="core/wcm/components/teaser/v1/teaser"/> | ||
</responsivegrid> | ||
</root> | ||
</jcr:content> | ||
</jcr:root> |