Skip to content
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.

Commit

Permalink
Merge pull request #12 from Cognifide/coreComponents-Teaser
Browse files Browse the repository at this point in the history
Tests for Teaser component
  • Loading branch information
jaskowskak authored Oct 15, 2019
2 parents e2d0304 + e3215ed commit a354611
Show file tree
Hide file tree
Showing 10 changed files with 275 additions and 0 deletions.
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();
}
}
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));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Text:
- label: Description
type: RICHTEXT
value: This is teaser description
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
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Image:
- type: IMAGE
value: lava-rock-formation.jpg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Text:
- label: Title
type: TEXTFIELD
value: This is teaser title
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
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
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>

0 comments on commit a354611

Please sign in to comment.