diff --git a/aem65/src/main/java/com/cognifide/qa/bb/aem65/tests/pageobjects/corecomponents/ContentFragmentListComponent.java b/aem65/src/main/java/com/cognifide/qa/bb/aem65/tests/pageobjects/corecomponents/ContentFragmentListComponent.java new file mode 100644 index 0000000..1c93fa2 --- /dev/null +++ b/aem65/src/main/java/com/cognifide/qa/bb/aem65/tests/pageobjects/corecomponents/ContentFragmentListComponent.java @@ -0,0 +1,31 @@ +package com.cognifide.qa.bb.aem65.tests.pageobjects.corecomponents; + +import java.util.List; +import java.util.stream.Collectors; + +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +import com.cognifide.qa.bb.qualifier.CurrentScope; +import com.cognifide.qa.bb.qualifier.PageObject; +import com.google.inject.Inject; + +@PageObject(css = ".cmp-contentfragmentlist") +public class ContentFragmentListComponent { + + @Inject + @CurrentScope + private WebElement component; + + @FindBy(css = "article") + private List articles; + + public List getArticleTexts() { + return articles.stream().map(WebElement::getText).collect(Collectors.toList()); + } + + public String getCollectiveText() { + return component.getText(); + } + +} diff --git a/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/ContentFragmentListComponentTest.java b/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/ContentFragmentListComponentTest.java new file mode 100644 index 0000000..770126d --- /dev/null +++ b/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/ContentFragmentListComponentTest.java @@ -0,0 +1,113 @@ +package com.cognifide.qa.bb.aem65.tests.corecomponents; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.assertj.core.api.SoftAssertions; +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.ContentFragmentListComponent; +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("Content Fragment List Component configuration") +@DisplayName("Author can configure for Content Fragment List the...") +public class ContentFragmentListComponentTest extends AbstractAemAuthorTest { + + private static final String TEST_PAGE_PATH = + "/content/core-components-examples/library/content-fragment-list-component-test-page"; + + private TestPage page; + private ContentFragmentListComponent component; + + @BeforeEach + public void setup() throws ActionException { + controller.execute(AemActions.CREATE_PAGE_VIA_SLING, new SlingPageData(TEST_PAGE_PATH, + SlingDataXMLBuilder + .buildFromFile("testpages/core-components/contentFragmentListComponentTestPage.xml"))); + page = bobcatPageFactory.create("/editor.html" + TEST_PAGE_PATH + ".html", TestPage.class); + page.open(); + } + + @Test + @DisplayName("model") + public void configureModel() throws ActionException { + controller.execute(AemActions.CONFIGURE_COMPONENT, + new ConfigureComponentData("container", "Content Fragment List (v1)", 2, + new ResourceFileLocation( + "component-configs/core-components/content-fragment-list/model.yaml"))); + component = page.getContent(ContentFragmentListComponent.class, 2); + assertThat(component.getArticleTexts().get(0)).as("Check if the model is configured properly") + .matches("^48 hours of Wilderness(.*|\\n)*move on to the next\\.$"); + } + + @Test + @DisplayName("parent path") + public void configureParentPath() throws ActionException { + controller.execute(AemActions.CONFIGURE_COMPONENT, + new ConfigureComponentData("container", "Content Fragment List (v1)", 1, + new ResourceFileLocation( + "component-configs/core-components/content-fragment-list/parent-path.yaml"))); + component = page.getContent(ContentFragmentListComponent.class, 1); + SoftAssertions softly = new SoftAssertions(); + softly.assertThat(component.getArticleTexts().get(0)) + .as("Check if the first article from the parent path is displayed") + .matches("^Accepted Currency(.*|\\n)*processing$"); + softly.assertThat(component.getArticleTexts().get(3)) + .as("Check if the last article from the parent path is displayed") + .matches("^Cancellations(.*|\\n)*processing$"); + softly.assertAll(); + } + + @Test + @DisplayName("max items") + public void configureMaxItems() throws ActionException { + controller.execute(AemActions.CONFIGURE_COMPONENT, + new ConfigureComponentData("container", "Content Fragment List (v1)", 0, + new ResourceFileLocation( + "component-configs/core-components/content-fragment-list/max-items.yaml"))); + component = page.getContent(ContentFragmentListComponent.class, 0); + assertThat(component.getCollectiveText()) + .as("Check if the max items limit is configured properly") + .matches("^Adobe Research Schweiz AG(.*|\\n)*europe-middleeast-africa$"); + } + + @Test + @DisplayName("elements to display") + public void configureElementsToDisplay() throws ActionException { + controller.execute(AemActions.CONFIGURE_COMPONENT, + new ConfigureComponentData("container", "Content Fragment List (v1)", 1, + new ResourceFileLocation( + "component-configs/core-components/content-fragment-list/elements.yaml"))); + component = page.getContent(ContentFragmentListComponent.class, 1); + SoftAssertions softly = new SoftAssertions(); + softly.assertThat(component.getArticleTexts().get(0)) + .as("Check if the element selection is configured properly for the first article") + .matches("^The Company Name(.*|\\n)*\"We.Retail\"\\?"); + softly.assertThat(component.getArticleTexts().get(2)) + .as("Check if the element selection is configured properly for the last article") + .matches("^Real Company(.*|\\n)*company\\?"); + softly.assertAll(); + } + + @AfterEach + public void cleanup() 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/content-fragment-list/elements.yaml b/aem65/src/test/resources/component-configs/core-components/content-fragment-list/elements.yaml new file mode 100644 index 0000000..e9f74b2 --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/content-fragment-list/elements.yaml @@ -0,0 +1,7 @@ +Elements: +- label: Elements + type: MULTIFIELD + value: + - item: + - type: SELECT + value: Question \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/content-fragment-list/max-items.yaml b/aem65/src/test/resources/component-configs/core-components/content-fragment-list/max-items.yaml new file mode 100644 index 0000000..8729063 --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/content-fragment-list/max-items.yaml @@ -0,0 +1,4 @@ +Properties: +- label: Max Items + type: NUMBER_INPUT + value: 1 \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/content-fragment-list/model.yaml b/aem65/src/test/resources/component-configs/core-components/content-fragment-list/model.yaml new file mode 100644 index 0000000..a3aa166 --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/content-fragment-list/model.yaml @@ -0,0 +1,4 @@ +Properties: +- label: Model + type: SELECT + value: We.Retail Experience \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/content-fragment-list/parent-path.yaml b/aem65/src/test/resources/component-configs/core-components/content-fragment-list/parent-path.yaml new file mode 100644 index 0000000..6c2f34c --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/content-fragment-list/parent-path.yaml @@ -0,0 +1,4 @@ +Properties: +- label: Parent Path + type: PATHBROWSER + value: /content/dam/we-retail/en/faqs/orders \ No newline at end of file diff --git a/aem65/src/test/resources/testpages/core-components/contentFragmentListComponentTestPage.xml b/aem65/src/test/resources/testpages/core-components/contentFragmentListComponentTestPage.xml new file mode 100644 index 0000000..efcfb50 --- /dev/null +++ b/aem65/src/test/resources/testpages/core-components/contentFragmentListComponentTestPage.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + +