From 681d4e7339c65547e3dfc7297b1bd6992276bd07 Mon Sep 17 00:00:00 2001 From: Andrzej Dolinski Date: Mon, 21 Oct 2019 15:14:55 +0200 Subject: [PATCH 1/3] 373 provdiding CRUD tests for Breadcrumb v2 component, adding needed test pages, configurations and page objects --- .../corecomponents/BreadcrumbComponent.java | 19 +++ .../BreadcrumbComponentTest.java | 113 ++++++++++++++++++ .../hidden-navigation-item-true.yaml | 4 + .../breadcrumb/hide-current-page-true.yaml | 4 + .../max-navigation-start-level.yaml | 4 + .../min-navigation-start-level.yaml | 4 + .../breadcrumb/modify-all-properties.yaml | 10 ++ .../breadcrumbComponentHiddenTestPage.xml | 16 +++ .../breadcrumbComponentMiddleTestPage.xml | 16 +++ .../breadcrumbComponentTestPage.xml | 20 ++++ 10 files changed, 210 insertions(+) create mode 100644 aem65/src/main/java/com/cognifide/qa/bb/aem65/tests/pageobjects/corecomponents/BreadcrumbComponent.java create mode 100644 aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java create mode 100644 aem65/src/test/resources/component-configs/core-components/breadcrumb/hidden-navigation-item-true.yaml create mode 100644 aem65/src/test/resources/component-configs/core-components/breadcrumb/hide-current-page-true.yaml create mode 100644 aem65/src/test/resources/component-configs/core-components/breadcrumb/max-navigation-start-level.yaml create mode 100644 aem65/src/test/resources/component-configs/core-components/breadcrumb/min-navigation-start-level.yaml create mode 100644 aem65/src/test/resources/component-configs/core-components/breadcrumb/modify-all-properties.yaml create mode 100644 aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentHiddenTestPage.xml create mode 100644 aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentMiddleTestPage.xml create mode 100644 aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentTestPage.xml diff --git a/aem65/src/main/java/com/cognifide/qa/bb/aem65/tests/pageobjects/corecomponents/BreadcrumbComponent.java b/aem65/src/main/java/com/cognifide/qa/bb/aem65/tests/pageobjects/corecomponents/BreadcrumbComponent.java new file mode 100644 index 0000000..e9b38c4 --- /dev/null +++ b/aem65/src/main/java/com/cognifide/qa/bb/aem65/tests/pageobjects/corecomponents/BreadcrumbComponent.java @@ -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(); + } +} diff --git a/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java b/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java new file mode 100644 index 0000000..caceaa6 --- /dev/null +++ b/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java @@ -0,0 +1,113 @@ +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/min-navigation-start-level.yaml"))); + component = testPage.getContent(BreadcrumbComponent.class, 0); + assertThat(component.getText()).as("Check if the root name is present") + .contains("Core Components"); + } + + @Test + @DisplayName("navigation start level - increase default value") + public void increaseNavigationStartLevel() throws ActionException { + controller.execute(AemActions.CONFIGURE_COMPONENT, + new ConfigureComponentData("container", "Breadcrumb (v2)", 0, + new ResourceFileLocation("component-configs/core-components/breadcrumb/max-navigation-start-level.yaml"))); + component = testPage.getContent(BreadcrumbComponent.class, 0); + assertThat(component.getText()).as("Check if breadcrumb value is equal to page title") + .doesNotContain("breadcrumbHiddenTestPage"); + } + + @Test + @DisplayName("show hidden navigation items checkbox") + public void showHiddenNavigationItems() throws ActionException { + controller.execute(AemActions.CONFIGURE_COMPONENT, + new ConfigureComponentData("container", "Breadcrumb (v2)", 0, + new ResourceFileLocation("component-configs/core-components/breadcrumb/hidden-navigation-item-true.yaml"))); + component = testPage.getContent(BreadcrumbComponent.class, 0); + assertThat(component.getText()).as("Check if hidden page is visible in breadcrumb") + .contains("breadcrumbHiddenTestPage"); + } + + @Test + @DisplayName("hide current page checkbox") + public void hideCurrentPage() throws ActionException { + controller.execute(AemActions.CONFIGURE_COMPONENT, + new ConfigureComponentData("container", "Breadcrumb (v2)", 0, + new ResourceFileLocation("component-configs/core-components/breadcrumb/hide-current-page-true.yaml"))); + component = testPage.getContent(BreadcrumbComponent.class, 0); + assertThat(component.getText()).as("Check if title of current page is not visible in breadcrumb") + .doesNotContain("breadcrumbTestPage"); + } + + @Test + @DisplayName("check combination of all properties") + public void modifeAllProperties() throws ActionException { + controller.execute(AemActions.CONFIGURE_COMPONENT, + new ConfigureComponentData("container", "Breadcrumb (v2)", 0, + new ResourceFileLocation("component-configs/core-components/breadcrumb/modify-all-properties.yaml"))); + component = testPage.getContent(BreadcrumbComponent.class, 0); + assertThat(component.getText()).as("Check if combination of all properties does not break anything") + .doesNotContain("breadcrumbTestPage").contains("Core Components"); + } + + @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)); + } +} diff --git a/aem65/src/test/resources/component-configs/core-components/breadcrumb/hidden-navigation-item-true.yaml b/aem65/src/test/resources/component-configs/core-components/breadcrumb/hidden-navigation-item-true.yaml new file mode 100644 index 0000000..34ed736 --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/breadcrumb/hidden-navigation-item-true.yaml @@ -0,0 +1,4 @@ +Properties: +- label: Show hidden navigation items + type: CHECKBOX + value: true \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/breadcrumb/hide-current-page-true.yaml b/aem65/src/test/resources/component-configs/core-components/breadcrumb/hide-current-page-true.yaml new file mode 100644 index 0000000..65b48e7 --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/breadcrumb/hide-current-page-true.yaml @@ -0,0 +1,4 @@ +Properties: + - label: Hide current page + type: CHECKBOX + value: true \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/breadcrumb/max-navigation-start-level.yaml b/aem65/src/test/resources/component-configs/core-components/breadcrumb/max-navigation-start-level.yaml new file mode 100644 index 0000000..a15279f --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/breadcrumb/max-navigation-start-level.yaml @@ -0,0 +1,4 @@ +Properties: +- label: Navigation Start Level + type: TEXTFIELD + value: 3 \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/breadcrumb/min-navigation-start-level.yaml b/aem65/src/test/resources/component-configs/core-components/breadcrumb/min-navigation-start-level.yaml new file mode 100644 index 0000000..5cd9ab0 --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/breadcrumb/min-navigation-start-level.yaml @@ -0,0 +1,4 @@ +Properties: +- label: Navigation Start Level + type: TEXTFIELD + value: 1 \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/breadcrumb/modify-all-properties.yaml b/aem65/src/test/resources/component-configs/core-components/breadcrumb/modify-all-properties.yaml new file mode 100644 index 0000000..e695a6b --- /dev/null +++ b/aem65/src/test/resources/component-configs/core-components/breadcrumb/modify-all-properties.yaml @@ -0,0 +1,10 @@ +Properties: +- label: Navigation Start Level + type: TEXTFIELD + value: 1 +- label: Show hidden navigation items + type: CHECKBOX + value: true +- label: Hide current page + type: CHECKBOX + value: true \ No newline at end of file diff --git a/aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentHiddenTestPage.xml b/aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentHiddenTestPage.xml new file mode 100644 index 0000000..fe1ff59 --- /dev/null +++ b/aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentHiddenTestPage.xml @@ -0,0 +1,16 @@ + + + + + + + + + \ No newline at end of file diff --git a/aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentMiddleTestPage.xml b/aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentMiddleTestPage.xml new file mode 100644 index 0000000..45623eb --- /dev/null +++ b/aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentMiddleTestPage.xml @@ -0,0 +1,16 @@ + + + + + + + + s + \ No newline at end of file diff --git a/aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentTestPage.xml b/aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentTestPage.xml new file mode 100644 index 0000000..dc4887a --- /dev/null +++ b/aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentTestPage.xml @@ -0,0 +1,20 @@ + + + + + + + + + + \ No newline at end of file From 628ef9b7e94efc2ada092b17935eb0888b2a931c Mon Sep 17 00:00:00 2001 From: Andrzej Dolinski Date: Tue, 22 Oct 2019 22:34:08 +0200 Subject: [PATCH 2/3] 373 - addressing code review comments - removing one of the test for navigation start level, removig test for combining all dialog options, renaming and changing configuration of yaml files, removing not used configuration of sample test page --- .../BreadcrumbComponentTest.java | 46 +++---------------- ...rties.yaml => checkbox-configuration.yaml} | 3 -- .../hidden-navigation-item-true.yaml | 4 -- .../breadcrumb/hide-current-page-true.yaml | 4 -- .../max-navigation-start-level.yaml | 4 -- ...level.yaml => navigation-start-level.yaml} | 0 .../breadcrumbComponentMiddleTestPage.xml | 16 ------- 7 files changed, 6 insertions(+), 71 deletions(-) rename aem65/src/test/resources/component-configs/core-components/breadcrumb/{modify-all-properties.yaml => checkbox-configuration.yaml} (66%) delete mode 100644 aem65/src/test/resources/component-configs/core-components/breadcrumb/hidden-navigation-item-true.yaml delete mode 100644 aem65/src/test/resources/component-configs/core-components/breadcrumb/hide-current-page-true.yaml delete mode 100644 aem65/src/test/resources/component-configs/core-components/breadcrumb/max-navigation-start-level.yaml rename aem65/src/test/resources/component-configs/core-components/breadcrumb/{min-navigation-start-level.yaml => navigation-start-level.yaml} (100%) delete mode 100644 aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentMiddleTestPage.xml diff --git a/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java b/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java index caceaa6..d0197f9 100644 --- a/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java +++ b/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java @@ -54,57 +54,23 @@ public void createAndOpenTestPage() throws ActionException { public void decreaseNavigationStartLevel() throws ActionException { controller.execute(AemActions.CONFIGURE_COMPONENT, new ConfigureComponentData("container", "Breadcrumb (v2)", 0, - new ResourceFileLocation( - "component-configs/core-components/breadcrumb/min-navigation-start-level.yaml"))); + new ResourceFileLocation("component-configs/core-components/breadcrumb/navigation-start-level.yaml"))); component = testPage.getContent(BreadcrumbComponent.class, 0); - assertThat(component.getText()).as("Check if the root name is present") + assertThat(component.getText()).as("Check if breadcrumb value contains first level page") .contains("Core Components"); } @Test - @DisplayName("navigation start level - increase default value") - public void increaseNavigationStartLevel() throws ActionException { + @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/max-navigation-start-level.yaml"))); + new ResourceFileLocation("component-configs/core-components/breadcrumb/checkbox-configuration.yaml"))); component = testPage.getContent(BreadcrumbComponent.class, 0); - assertThat(component.getText()).as("Check if breadcrumb value is equal to page title") - .doesNotContain("breadcrumbHiddenTestPage"); - } - - @Test - @DisplayName("show hidden navigation items checkbox") - public void showHiddenNavigationItems() throws ActionException { - controller.execute(AemActions.CONFIGURE_COMPONENT, - new ConfigureComponentData("container", "Breadcrumb (v2)", 0, - new ResourceFileLocation("component-configs/core-components/breadcrumb/hidden-navigation-item-true.yaml"))); - component = testPage.getContent(BreadcrumbComponent.class, 0); - assertThat(component.getText()).as("Check if hidden page is visible in breadcrumb") - .contains("breadcrumbHiddenTestPage"); - } - - @Test - @DisplayName("hide current page checkbox") - public void hideCurrentPage() throws ActionException { - controller.execute(AemActions.CONFIGURE_COMPONENT, - new ConfigureComponentData("container", "Breadcrumb (v2)", 0, - new ResourceFileLocation("component-configs/core-components/breadcrumb/hide-current-page-true.yaml"))); - component = testPage.getContent(BreadcrumbComponent.class, 0); - assertThat(component.getText()).as("Check if title of current page is not visible in breadcrumb") + assertThat(component.getText()).as("Check if current page is not present in breadcrumb") .doesNotContain("breadcrumbTestPage"); } - @Test - @DisplayName("check combination of all properties") - public void modifeAllProperties() throws ActionException { - controller.execute(AemActions.CONFIGURE_COMPONENT, - new ConfigureComponentData("container", "Breadcrumb (v2)", 0, - new ResourceFileLocation("component-configs/core-components/breadcrumb/modify-all-properties.yaml"))); - component = testPage.getContent(BreadcrumbComponent.class, 0); - assertThat(component.getText()).as("Check if combination of all properties does not break anything") - .doesNotContain("breadcrumbTestPage").contains("Core Components"); - } - @AfterEach public void deleteTestPage() throws ActionException { controller.execute(AemActions.DELETE_PAGE_VIA_SLING, new SlingPageData(COMPONENT_PAGE_PATH)); diff --git a/aem65/src/test/resources/component-configs/core-components/breadcrumb/modify-all-properties.yaml b/aem65/src/test/resources/component-configs/core-components/breadcrumb/checkbox-configuration.yaml similarity index 66% rename from aem65/src/test/resources/component-configs/core-components/breadcrumb/modify-all-properties.yaml rename to aem65/src/test/resources/component-configs/core-components/breadcrumb/checkbox-configuration.yaml index e695a6b..1ef4a5b 100644 --- a/aem65/src/test/resources/component-configs/core-components/breadcrumb/modify-all-properties.yaml +++ b/aem65/src/test/resources/component-configs/core-components/breadcrumb/checkbox-configuration.yaml @@ -1,7 +1,4 @@ Properties: -- label: Navigation Start Level - type: TEXTFIELD - value: 1 - label: Show hidden navigation items type: CHECKBOX value: true diff --git a/aem65/src/test/resources/component-configs/core-components/breadcrumb/hidden-navigation-item-true.yaml b/aem65/src/test/resources/component-configs/core-components/breadcrumb/hidden-navigation-item-true.yaml deleted file mode 100644 index 34ed736..0000000 --- a/aem65/src/test/resources/component-configs/core-components/breadcrumb/hidden-navigation-item-true.yaml +++ /dev/null @@ -1,4 +0,0 @@ -Properties: -- label: Show hidden navigation items - type: CHECKBOX - value: true \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/breadcrumb/hide-current-page-true.yaml b/aem65/src/test/resources/component-configs/core-components/breadcrumb/hide-current-page-true.yaml deleted file mode 100644 index 65b48e7..0000000 --- a/aem65/src/test/resources/component-configs/core-components/breadcrumb/hide-current-page-true.yaml +++ /dev/null @@ -1,4 +0,0 @@ -Properties: - - label: Hide current page - type: CHECKBOX - value: true \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/breadcrumb/max-navigation-start-level.yaml b/aem65/src/test/resources/component-configs/core-components/breadcrumb/max-navigation-start-level.yaml deleted file mode 100644 index a15279f..0000000 --- a/aem65/src/test/resources/component-configs/core-components/breadcrumb/max-navigation-start-level.yaml +++ /dev/null @@ -1,4 +0,0 @@ -Properties: -- label: Navigation Start Level - type: TEXTFIELD - value: 3 \ No newline at end of file diff --git a/aem65/src/test/resources/component-configs/core-components/breadcrumb/min-navigation-start-level.yaml b/aem65/src/test/resources/component-configs/core-components/breadcrumb/navigation-start-level.yaml similarity index 100% rename from aem65/src/test/resources/component-configs/core-components/breadcrumb/min-navigation-start-level.yaml rename to aem65/src/test/resources/component-configs/core-components/breadcrumb/navigation-start-level.yaml diff --git a/aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentMiddleTestPage.xml b/aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentMiddleTestPage.xml deleted file mode 100644 index 45623eb..0000000 --- a/aem65/src/test/resources/testpages/core-components/breadcrumb/breadcrumbComponentMiddleTestPage.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - s - \ No newline at end of file From 951e5fc31db6cafce30b2842da704fdf0f0d3fe0 Mon Sep 17 00:00:00 2001 From: Andrzej Dolinski Date: Wed, 23 Oct 2019 13:08:21 +0200 Subject: [PATCH 3/3] adding missing assertion for checkbox test --- .../bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java b/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java index d0197f9..8069a28 100644 --- a/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java +++ b/aem65/src/test/java/com/cognifide/qa/bb/aem65/tests/corecomponents/BreadcrumbComponentTest.java @@ -68,7 +68,7 @@ public void changeCheckboxesToTrue() throws ActionException { 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"); + .doesNotContain("breadcrumbTestPage").contains("breadcrumbHiddenTestPage"); } @AfterEach