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

Core components content fragment list tests #18

Merged
merged 3 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<WebElement> articles;

public List<String> getArticleTexts() {
return articles.stream().map(WebElement::getText).collect(Collectors.toList());
}

public String getCollectiveText() {
return component.getText();
}

}
Original file line number Diff line number Diff line change
@@ -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));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Elements:
- label: Elements
type: MULTIFIELD
value:
- item:
- type: SELECT
value: Question
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Properties:
- label: Max Items
type: NUMBER_INPUT
value: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Properties:
- label: Model
type: SELECT
value: We.Retail Experience
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Properties:
- label: Parent Path
type: PATHBROWSER
value: /content/dam/we-retail/en/faqs/orders
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?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:primaryType="cq:PageContent"
jcr:title="Content Fragment List Component Test Page"
sling:resourceType="core-components-examples/components/page"
navTitle="Content Fragment List Component Test Page"
pageTitle="Content Fragment List Component Test Page">
<root
jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/foundation/components/responsivegrid">
<responsivegrid
cq:styleIds="[1545309110033]"
jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/foundation/components/responsivegrid">
<contentfragmentlist
jcr:primaryType="nt:unstructured"
sling:resourceType="core/wcm/components/contentfragmentlist/v1/contentfragmentlist"
maxItems="0"
modelPath="/conf/core-components-examples/settings/dam/cfm/models/office"
parentPath="/content/dam/core-components-examples/library/sample-assets"/>
<contentfragmentlist_1403754464
jcr:primaryType="nt:unstructured"
sling:resourceType="core/wcm/components/contentfragmentlist/v1/contentfragmentlist"
maxItems="0"
modelPath="/conf/we-retail/settings/dam/cfm/models/faq"
parentPath="/content/dam/we-retail/en/faqs/company"/>
<contentfragmentlist_2146348240
jcr:primaryType="nt:unstructured"
sling:resourceType="core/wcm/components/contentfragmentlist/v1/contentfragmentlist"
modelPath="/conf/we-retail/settings/dam/cfm/models/faq"
parentPath="/content/dam/we-retail/en/experiences/48-hours-of-wilderness"/>
</responsivegrid>
</root>
</jcr:content>
</jcr:root>