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

373 provdiding CRUD tests for Breadcrumb v2 component, adding needed … #15

Merged
merged 4 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,19 @@
package com.cognifide.qa.bb.aem65.tests.pageobjects.corecomponents;

import com.cognifide.qa.bb.qualifier.CurrentScope;
import com.cognifide.qa.bb.qualifier.PageObject;
import org.openqa.selenium.WebElement;

import com.google.inject.Inject;

@PageObject(css = ".cmp-breadcrumb")
public class BreadcrumbComponent {

@Inject
@CurrentScope
private WebElement component;

public String getText() {
return component.getText();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.cognifide.qa.bb.aem65.tests.corecomponents;

import static org.assertj.core.api.Assertions.assertThat;

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.BreadcrumbComponent;
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("Breadcrumb Component configuration")
@DisplayName("Author can configure for Breadcrumb Component the...")
public class BreadcrumbComponentTest extends AbstractAemAuthorTest {

private static final String HIDDEN_PAGE_PATH = "/content/core-components-examples/breadcrumbhiddentestpage";
private static final String COMPONENT_PAGE_PATH =
"/content/core-components-examples/breadcrumbhiddentestpage/breadcrumbtestpage";

private TestPage testPage;
private BreadcrumbComponent component;

@BeforeEach
public void createAndOpenTestPage() throws ActionException {
controller.execute(AemActions.CREATE_PAGE_VIA_SLING, new SlingPageData(HIDDEN_PAGE_PATH,
SlingDataXMLBuilder.buildFromFile(
"testpages/core-components/breadcrumb/breadcrumbComponentHiddenTestPage.xml")));

controller.execute(AemActions.CREATE_PAGE_VIA_SLING, new SlingPageData(COMPONENT_PAGE_PATH,
SlingDataXMLBuilder.buildFromFile(
"testpages/core-components/breadcrumb/breadcrumbComponentTestPage.xml")));

testPage = bobcatPageFactory.create("/editor.html" + COMPONENT_PAGE_PATH + ".html", TestPage.class);
testPage.open();
}

@Test
@DisplayName("navigation start level - decrease default value")
public void decreaseNavigationStartLevel() throws ActionException {
controller.execute(AemActions.CONFIGURE_COMPONENT,
new ConfigureComponentData("container", "Breadcrumb (v2)", 0,
new ResourceFileLocation("component-configs/core-components/breadcrumb/navigation-start-level.yaml")));
component = testPage.getContent(BreadcrumbComponent.class, 0);
assertThat(component.getText()).as("Check if breadcrumb value contains first level page")
.contains("Core Components");
}

@Test
@DisplayName("checkbox values change to true")
public void changeCheckboxesToTrue() throws ActionException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You assert that the current page is not displayed in the breadcrumb component, but you don't check if the hidden page is displayed in it, right? If so, then an assertion is missing

controller.execute(AemActions.CONFIGURE_COMPONENT,
new ConfigureComponentData("container", "Breadcrumb (v2)", 0,
new ResourceFileLocation("component-configs/core-components/breadcrumb/checkbox-configuration.yaml")));
component = testPage.getContent(BreadcrumbComponent.class, 0);
assertThat(component.getText()).as("Check if current page is not present in breadcrumb")
.doesNotContain("breadcrumbTestPage").contains("breadcrumbHiddenTestPage");
}

@AfterEach
public void deleteTestPage() throws ActionException {
controller.execute(AemActions.DELETE_PAGE_VIA_SLING, new SlingPageData(COMPONENT_PAGE_PATH));
controller.execute(AemActions.DELETE_PAGE_VIA_SLING, new SlingPageData(HIDDEN_PAGE_PATH));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Properties:
- label: Show hidden navigation items
type: CHECKBOX
value: true
- label: Hide current page
type: CHECKBOX
value: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Properties:
- label: Navigation Start Level
type: TEXTFIELD
value: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root jcr:primaryType="cq:Page" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0">
<jcr:content jcr:title="breadcrumbHiddenTestPage" jcr:primaryType="cq:PageContent" hideInNav="true"
sling:resourceType="core-components-examples/components/page"
cq:template="/conf/core-components-examples/settings/wcm/templates/content-page"
cq:lastModifiedBy="admin" cq:lastModified="{Date}2019-10-18T14:26:02.995+02:00">
<root jcr:primaryType="nt:unstructured" sling:resourceType="wcm/foundation/components/responsivegrid">
<responsivegrid jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/foundation/components/responsivegrid" jcr:lastModifiedBy="admin"
jcr:lastModified="{Date}2018-12-20T14:47:57.433Z" jcr:createdBy="admin"
jcr:created="{Date}2018-12-20T12:31:03.201Z" cq:styleIds="[1545309110033]"/>
</root>
</jcr:content>
<breadcrumbmiddletestpage/>
</jcr:root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root jcr:primaryType="cq:Page" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0">
<jcr:content jcr:title="breadcrumbTestPage" jcr:primaryType="cq:PageContent"
sling:resourceType="core-components-examples/components/page"
cq:template="/conf/core-components-examples/settings/wcm/templates/content-page"
cq:lastModifiedBy="admin" cq:lastModified="{Date}2019-10-18T14:27:29.269+02:00">
<root jcr:primaryType="nt:unstructured" sling:resourceType="wcm/foundation/components/responsivegrid">
<responsivegrid jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/foundation/components/responsivegrid" jcr:lastModifiedBy="admin"
jcr:lastModified="{Date}2018-12-20T14:47:57.433Z" jcr:createdBy="admin"
jcr:created="{Date}2018-12-20T12:31:03.201Z" cq:styleIds="[1545309110033]">
<breadcrumb jcr:primaryType="nt:unstructured"
sling:resourceType="core/wcm/components/breadcrumb/v2/breadcrumb" jcr:lastModifiedBy="admin"
jcr:lastModified="{Date}2019-10-18T14:27:29.265+02:00" jcr:createdBy="admin"
jcr:created="{Date}2019-10-18T14:27:29.265+02:00"/>
</responsivegrid>
</root>
</jcr:content>
</jcr:root>