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
Tests for Teaser component #12
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
53f64f8
tests for Teaser
jaskowskak 28b8dc4
remove test
jaskowskak f542572
merge resolve conflict
jaskowskak 0819028
merge resolve conflict2
jaskowskak 0d2260d
final version of tests for Teaser (without action button test)
jaskowskak e2ccbd9
removing unnecessary test
jaskowskak aeebe99
set proper bobcat version
jaskowskak a806003
changes for test page path - new path added - under core components l…
jaskowskak c9c4089
deleting interface and renaming class to TeaserComponent and moving a…
jaskowskak a46097c
deleting actionLink yaml file, reducing the number of String operatio…
jaskowskak e3215ed
updating formatting, fixing a typo
jaskowskak 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
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> |
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.
Instead of configuring multiple dialog fields in one test I suggest only to configure the verified fields, and the rest have preconfigured and created by Sling. So you then have multiple components with different configs delivered by Sling and only choose which component to work on during a test case - much faster than configuring everything with Bobcat in the UI
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.
done - I extended content on test page