This repository has been archived by the owner on Dec 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Cognifide/feature/373-core-components-bre…
…adcrumbs-tests 373 provdiding CRUD tests for Breadcrumb v2 component, adding needed …
- Loading branch information
Showing
6 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
.../java/com/cognifide/qa/bb/aem65/tests/pageobjects/corecomponents/BreadcrumbComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
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)); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...c/test/resources/component-configs/core-components/breadcrumb/checkbox-configuration.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
4 changes: 4 additions & 0 deletions
4
...c/test/resources/component-configs/core-components/breadcrumb/navigation-start-level.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Properties: | ||
- label: Navigation Start Level | ||
type: TEXTFIELD | ||
value: 1 |
16 changes: 16 additions & 0 deletions
16
...test/resources/testpages/core-components/breadcrumb/breadcrumbComponentHiddenTestPage.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
20 changes: 20 additions & 0 deletions
20
...5/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentTestPage.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |