diff --git a/aem65/src/main/java/com/cognifide/qa/bb/aem65/tests/pageobjects/corecomponents/TeaserComponent.java b/aem65/src/main/java/com/cognifide/qa/bb/aem65/tests/pageobjects/corecomponents/TeaserComponent.java new file mode 100644 index 0000000..9e22c01 --- /dev/null +++ b/aem65/src/main/java/com/cognifide/qa/bb/aem65/tests/pageobjects/corecomponents/TeaserComponent.java @@ -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 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(); + } +} diff --git a/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/TeaserComponentTest.java b/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/TeaserComponentTest.java new file mode 100644 index 0000000..b94d77b --- /dev/null +++ b/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/TeaserComponentTest.java @@ -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)); + } +} diff --git a/aem65/src/test/resources/component-configs/core-components/teaser/description.yaml b/aem65/src/test/resources/component-configs/core-components/teaser/description.yaml new file mode 100644 index 0000000..f790acc --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/teaser/description.yaml @@ -0,0 +1,4 @@ +Text: + - label: Description + type: RICHTEXT + value: This is teaser description \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/teaser/descriptionEmptyFromLinkedPage.yaml b/aem65/src/test/resources/component-configs/core-components/teaser/descriptionEmptyFromLinkedPage.yaml new file mode 100644 index 0000000..647a99f --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/teaser/descriptionEmptyFromLinkedPage.yaml @@ -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 \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/teaser/descriptionFromLinkedPage.yaml b/aem65/src/test/resources/component-configs/core-components/teaser/descriptionFromLinkedPage.yaml new file mode 100644 index 0000000..0d96a9f --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/teaser/descriptionFromLinkedPage.yaml @@ -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 \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/teaser/image.yaml b/aem65/src/test/resources/component-configs/core-components/teaser/image.yaml new file mode 100644 index 0000000..957e656 --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/teaser/image.yaml @@ -0,0 +1,3 @@ +Image: + - type: IMAGE + value: lava-rock-formation.jpg \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/teaser/title.yaml b/aem65/src/test/resources/component-configs/core-components/teaser/title.yaml new file mode 100644 index 0000000..80f544b --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/teaser/title.yaml @@ -0,0 +1,4 @@ +Text: + - label: Title + type: TEXTFIELD + value: This is teaser title \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/teaser/titleFromLinkedPage.yaml b/aem65/src/test/resources/component-configs/core-components/teaser/titleFromLinkedPage.yaml new file mode 100644 index 0000000..62c3919 --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/teaser/titleFromLinkedPage.yaml @@ -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 \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/teaser/titleLink.yaml b/aem65/src/test/resources/component-configs/core-components/teaser/titleLink.yaml new file mode 100644 index 0000000..ebb9ef6 --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/teaser/titleLink.yaml @@ -0,0 +1,4 @@ +Link & Actions: + - label: Link + type: PATHBROWSER + value: /content/core-components-examples/library/teaser \ No newline at end of file diff --git a/aem65/src/test/resources/testpages/core-components/teaserComponentTestPage.xml b/aem65/src/test/resources/testpages/core-components/teaserComponentTestPage.xml new file mode 100644 index 0000000..0b33304 --- /dev/null +++ b/aem65/src/test/resources/testpages/core-components/teaserComponentTestPage.xml @@ -0,0 +1,28 @@ + + + + + + + + + +