From c05811758fcba99198f6728741be3c0f68a1f113 Mon Sep 17 00:00:00 2001 From: Igor Vlasiuk Date: Thu, 30 Nov 2023 15:47:50 +0300 Subject: [PATCH] tests of Divider page, task # 4941 --- .../java/io/github/com/pages/DividerPage.java | 7 +-- .../tests/elements/common/DividerTests.java | 12 ++--- .../light/angular/asserts/DividerAssert.java | 25 --------- .../asserts/DividerSeparatorAssert.java | 48 +++++++++++++++++ .../angular/elements/common/Divider.java | 24 ++------- .../elements/common/DividerSeparator.java | 54 +++++++++++++++++++ 6 files changed, 115 insertions(+), 55 deletions(-) delete mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/DividerAssert.java create mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/DividerSeparatorAssert.java create mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/DividerSeparator.java diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/pages/DividerPage.java b/jdi-light-angular-tests/src/main/java/io/github/com/pages/DividerPage.java index efcc77469d..0f0e65b3d0 100644 --- a/jdi-light-angular-tests/src/main/java/io/github/com/pages/DividerPage.java +++ b/jdi-light-angular-tests/src/main/java/io/github/com/pages/DividerPage.java @@ -1,6 +1,7 @@ package io.github.com.pages; import com.epam.jdi.light.angular.elements.common.Divider; +import com.epam.jdi.light.angular.elements.common.DividerSeparator; import com.epam.jdi.light.elements.common.UIElement; import com.epam.jdi.light.elements.complex.JList; import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; @@ -14,7 +15,7 @@ public class DividerPage extends NewAngularPage { public static JList defaultDividersList; @UI("#divider-list:first-of-type > mat-divider[role=\"separator\"]") - public static JList defaultDividersSeparators; + public static JList defaultDividersSeparators; @UI("#divider-list:first-of-type > mat-list-item:nth-of-type(1)") public static UIElement elementDefaultItemOneDivider; @@ -32,7 +33,7 @@ public class DividerPage extends NewAngularPage { public static JList insetDividersList; @UI("#divider-list:nth-of-type(2) > mat-divider[role=\"separator\"]") - public static JList insetDividerSeparators; + public static JList insetDividerSeparators; @UI("#divider-list:nth-of-type(2) > mat-list-item:nth-of-type(1)") public static UIElement elementInsetItemOneDivider; @@ -50,7 +51,7 @@ public class DividerPage extends NewAngularPage { public static JList verticalDividersList; @UI(".vertical-dividers > mat-divider[role=\"separator\"]") - public static JList verticalDividerSeparators; + public static JList verticalDividerSeparators; @UI(".vertical-dividers > mat-list-item:nth-of-type(1)") public static UIElement elementVerticalItemOneDivider; diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/DividerTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/DividerTests.java index c4ad455f90..796b65d8aa 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/DividerTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/DividerTests.java @@ -25,21 +25,21 @@ public void before() { @Test(description = "Test checks presence of mat-divider-horizontal class for default divider separators") public void defaultDividersSeparatorsTest() { defaultDividersSeparators.has().size(equalTo(2)); - defaultDividersSeparators.get(1).hasClass("mat-divider-horizontal"); - defaultDividersSeparators.get(2).hasClass("mat-divider-horizontal"); + defaultDividersSeparators.get(1).is().horizontal(); + defaultDividersSeparators.get(2).is().horizontal(); } @Test(description = "Test checks presence of mat-divider-inset class for inset divider separators") public void insetDividersSeparatorsTest() { insetDividerSeparators.has().size(equalTo(2)); - insetDividerSeparators.get(1).hasClass("mat-divider-inset"); - insetDividerSeparators.get(2).hasClass("mat-divider-inset"); + insetDividerSeparators.get(1).has().inset(); + insetDividerSeparators.get(2).has().inset(); } @Test(description = "Test checks presence of mat-divider-vertical class for vertical divider separators") public void verticalDividerSeparatorsTest() { verticalDividerSeparators.has().size(equalTo(2)); - verticalDividerSeparators.get(1).hasClass("mat-divider-vertical"); - verticalDividerSeparators.get(2).hasClass("mat-divider-vertical"); + verticalDividerSeparators.get(1).is().vertical(); + verticalDividerSeparators.get(2).is().vertical(); } } \ No newline at end of file diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/DividerAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/DividerAssert.java deleted file mode 100644 index d0c3731c8f..0000000000 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/DividerAssert.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.epam.jdi.light.angular.asserts; - -import com.epam.jdi.light.angular.elements.common.Divider; -import com.epam.jdi.light.asserts.generic.UIAssert; -import com.epam.jdi.light.common.JDIAction; -import org.hamcrest.Matchers; - -import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; - -/** - * Assertions for {@link Divider} - */ -public class DividerAssert extends UIAssert { - - /** - * Check that {@link Divider} is horizontal orientation - * - * @return this {@link DividerAssert} instance - */ - @JDIAction("Assert that '{name}' is horizontal orientation") - public DividerAssert horizontal() { - jdiAssert(element().isHorizontal() ? "is horizontal" : "is not horizontal", Matchers.is("is horizontal")); - return this; - } -} diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/DividerSeparatorAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/DividerSeparatorAssert.java new file mode 100644 index 0000000000..667453a908 --- /dev/null +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/DividerSeparatorAssert.java @@ -0,0 +1,48 @@ +package com.epam.jdi.light.angular.asserts; + +import com.epam.jdi.light.angular.elements.common.DividerSeparator; +import com.epam.jdi.light.asserts.generic.UIAssert; +import com.epam.jdi.light.common.JDIAction; +import org.hamcrest.Matchers; + +import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; + +/** + * Assertions for {@link DividerSeparator} + */ +public class DividerSeparatorAssert extends UIAssert { + + /** + * Check that {@link DividerSeparator} is horizontal orientation + * + * @return this {@link DividerSeparatorAssert} instance + */ + @JDIAction("Assert that '{name}' is horizontal orientation") + public DividerSeparatorAssert horizontal() { + jdiAssert(element().isHorizontal() ? "is horizontal" : "is not horizontal", Matchers.is("is horizontal")); + return this; + } + + /** + * Check that {@link DividerSeparator} is vertical orientation + * + * @return this {@link DividerSeparatorAssert} instance + */ + @JDIAction("Assert that '{name}' is vertical orientation") + public DividerSeparatorAssert vertical() { + jdiAssert(element().isVertical() ? "is vertical" : "is not vertical", Matchers.is("is vertical")); + return this; + } + + /** + * Check that {@link DividerSeparator} has inset + * + * @return this {@link DividerSeparatorAssert} instance + */ + @JDIAction("Assert that '{name}' has inset") + public DividerSeparatorAssert inset() { + jdiAssert(element().hasInset() ? "has inset" : "has no inset", Matchers.is("has inset")); + return this; + } + +} \ No newline at end of file diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Divider.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Divider.java index 5d77911d28..b323630a4d 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Divider.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Divider.java @@ -1,7 +1,6 @@ package com.epam.jdi.light.angular.elements.common; -import com.epam.jdi.light.angular.asserts.DividerAssert; -import com.epam.jdi.light.common.JDIAction; +import com.epam.jdi.light.angular.asserts.DividerSeparatorAssert; import com.epam.jdi.light.elements.base.UIBaseElement; /** @@ -11,23 +10,6 @@ * * @see Divider Overview */ -public class Divider extends UIBaseElement { +public class Divider extends UIBaseElement { - private static final String ORIENTATION_ATTRIBUTE = "aria-orientation"; - private static final String HORIZONTAL_VALUE = "horizontal"; - - /** - * Check whether Divider is horizontal orientation or not - * - * @return {@code true} if Divider is horizontal orientation - */ - @JDIAction("Check if '{name}' is horizontal orientation") - public boolean isHorizontal() { - return core().attr(ORIENTATION_ATTRIBUTE).equals(HORIZONTAL_VALUE); - } - - @Override - public DividerAssert is() { - return new DividerAssert().set(this); - } -} +} \ No newline at end of file diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/DividerSeparator.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/DividerSeparator.java new file mode 100644 index 0000000000..294f42b088 --- /dev/null +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/DividerSeparator.java @@ -0,0 +1,54 @@ +package com.epam.jdi.light.angular.elements.common; + +import com.epam.jdi.light.angular.asserts.DividerSeparatorAssert; +import com.epam.jdi.light.common.JDIAction; +import com.epam.jdi.light.elements.base.UIBaseElement; + +public class DividerSeparator extends UIBaseElement { + + private static final String ORIENTATION_ATTRIBUTE = "aria-orientation"; + private static final String HORIZONTAL_VALUE = "horizontal"; + private static final String VERTICAL_VALUE = "vertical"; + private static final String INSET_CLASS = "mat-divider-inset"; + + /** + * Check whether Divider separator is horizontal orientation or not + * + * @return {@code true} if Divider separator is horizontal orientation + */ + @JDIAction("Check if '{name}' is horizontal orientation") + public boolean isHorizontal() { + return core().attr(ORIENTATION_ATTRIBUTE).equals(HORIZONTAL_VALUE); + } + + /** + * Check whether Divider separator is vertical orientation or not + * + * @return {@code true} if Divider separator is vertical orientation + */ + + @JDIAction("Check if '{name}' is vertical orientation") + public boolean isVertical() { + return core().attr(ORIENTATION_ATTRIBUTE).equals(VERTICAL_VALUE); + } + + /** + * Check whether Divider separator has inset or not + * + * @return {@code true} if Divider separator has inset + */ + @JDIAction("Check if '{name}' has inset") + public boolean hasInset() { + return core().hasClass(INSET_CLASS); + } + + @Override + public DividerSeparatorAssert is() { + return new DividerSeparatorAssert().set(this); + } + + @Override + public DividerSeparatorAssert has() { + return new DividerSeparatorAssert().set(this); + } +} \ No newline at end of file