From 01e3ac029b7626c21f528d765d9404f1ef535d9d Mon Sep 17 00:00:00 2001 From: Ekaterina_Semenova1 Date: Thu, 20 Jul 2023 14:13:24 +0400 Subject: [PATCH 1/9] 4903: tests refactoring BADGE --- .../main/java/io/github/com/StaticSite.java | 6 +- .../java/io/github/com/pages/AngularPage.java | 28 +++++- .../java/io/github/com/pages/BadgePage.java | 17 ++++ .../com/pages/sections/BadgeSection.java | 10 --- .../tests/elements/common/BadgeTests.java | 82 +++++++++++++++--- .../angular/tests/unit/BadgeUnitTests.java | 13 ++- .../light/angular/asserts/BadgeAssert.java | 59 ++++++++++++- .../light/angular/elements/common/Badge.java | 86 ++++++++++++++++++- 8 files changed, 267 insertions(+), 34 deletions(-) create mode 100644 jdi-light-angular-tests/src/main/java/io/github/com/pages/BadgePage.java delete mode 100644 jdi-light-angular-tests/src/main/java/io/github/com/pages/sections/BadgeSection.java diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java b/jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java index 33d54ee238..dffb766c01 100644 --- a/jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java +++ b/jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java @@ -1,8 +1,9 @@ package io.github.com; import com.epam.jdi.light.elements.pageobjects.annotations.JSite; -import com.epam.jdi.light.elements.pageobjects.annotations.Url;; +import com.epam.jdi.light.elements.pageobjects.annotations.Url; import io.github.com.pages.AngularPage; +import io.github.com.pages.BadgePage; import io.github.com.pages.ButtonsPage; import io.github.com.pages.ProgressBarPage; import io.github.com.pages.ProgressSpinnerPage; @@ -21,4 +22,7 @@ public class StaticSite { @Url("buttons") public static ButtonsPage buttonsPage; + + @Url("badges") + public static BadgePage badgePage; } diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java b/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java index 0dbc577623..c31a21450c 100644 --- a/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java +++ b/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java @@ -6,7 +6,31 @@ import com.epam.jdi.light.elements.composite.WebPage; import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; import com.epam.jdi.light.ui.html.elements.common.Icon; -import io.github.com.pages.sections.*; +import io.github.com.pages.sections.AutocompleteSection; +import io.github.com.pages.sections.ButtonToggleSection; +import io.github.com.pages.sections.CardSection; +import io.github.com.pages.sections.CheckboxSection; +import io.github.com.pages.sections.ChipsSection; +import io.github.com.pages.sections.DatepickerSection; +import io.github.com.pages.sections.DividerSection; +import io.github.com.pages.sections.ExpansionPanelSection; +import io.github.com.pages.sections.FormFieldsSection; +import io.github.com.pages.sections.GridListSection; +import io.github.com.pages.sections.InputSection; +import io.github.com.pages.sections.ListSection; +import io.github.com.pages.sections.MenuSection; +import io.github.com.pages.sections.PaginatorSection; +import io.github.com.pages.sections.RadioButtonSection; +import io.github.com.pages.sections.SelectSection; +import io.github.com.pages.sections.SideNavSection; +import io.github.com.pages.sections.SlideToggleSection; +import io.github.com.pages.sections.SliderSection; +import io.github.com.pages.sections.SnackbarSection; +import io.github.com.pages.sections.SortingOverviewSection; +import io.github.com.pages.sections.TabGroupSection; +import io.github.com.pages.sections.TableSection; +import io.github.com.pages.sections.ToolbarSection; +import io.github.com.pages.sections.TooltipSection; public class AngularPage extends WebPage { @@ -26,7 +50,7 @@ public class AngularPage extends WebPage { public static SelectSection selectSection; public static ListSection listSection; public static GridListSection gridListSection; - public static BadgeSection badgeSection; + public static BasicButtonsSection basicButtonsSection; public static AutocompleteSection autocompleteSection; public static SnackbarSection snackbarSection; public static ButtonToggleSection buttonToggleSection; diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/pages/BadgePage.java b/jdi-light-angular-tests/src/main/java/io/github/com/pages/BadgePage.java new file mode 100644 index 0000000000..067b937742 --- /dev/null +++ b/jdi-light-angular-tests/src/main/java/io/github/com/pages/BadgePage.java @@ -0,0 +1,17 @@ +package io.github.com.pages; + +import com.epam.jdi.light.angular.elements.common.Badge; + +public class BadgePage extends NewAngularPage { + + public static Badge textWithBadge; + public static Badge buttonWithBadge; + public static Badge iconWithBadge; + public static Badge largeBadge; + public static Badge smallBadge; + public static Badge customSizeBadge; + public static Badge bellowPositionBadge; + public static Badge toggleVisibilityBadge; + public static Badge toggleDisabledBadge; + +} diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/pages/sections/BadgeSection.java b/jdi-light-angular-tests/src/main/java/io/github/com/pages/sections/BadgeSection.java deleted file mode 100644 index f2e19109ce..0000000000 --- a/jdi-light-angular-tests/src/main/java/io/github/com/pages/sections/BadgeSection.java +++ /dev/null @@ -1,10 +0,0 @@ -package io.github.com.pages.sections; - -import com.epam.jdi.light.angular.elements.common.Badge; -import com.epam.jdi.light.elements.composite.Section; - -public class BadgeSection extends Section { - public static Badge textWithBadge; - public static Badge buttonWithBadge; - public static Badge iconWithBadge; -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java index 0c7a71a604..522f1cb974 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java @@ -2,23 +2,27 @@ import io.github.epam.TestsInit; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.BadgeSection.buttonWithBadge; -import static io.github.com.pages.sections.BadgeSection.iconWithBadge; -import static io.github.com.pages.sections.BadgeSection.textWithBadge; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; +import static com.jdiai.tools.Timer.waitCondition; +import static io.github.com.StaticSite.badgePage; +import static io.github.com.pages.BadgePage.bellowPositionBadge; +import static io.github.com.pages.BadgePage.buttonWithBadge; +import static io.github.com.pages.BadgePage.customSizeBadge; +import static io.github.com.pages.BadgePage.iconWithBadge; +import static io.github.com.pages.BadgePage.largeBadge; +import static io.github.com.pages.BadgePage.smallBadge; +import static io.github.com.pages.BadgePage.textWithBadge; +import static io.github.com.pages.BadgePage.toggleDisabledBadge; +import static io.github.com.pages.BadgePage.toggleVisibilityBadge; -// TODO Move to the new page -@Ignore public class BadgeTests extends TestsInit { - @BeforeMethod(alwaysRun = true) + @BeforeMethod public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); + badgePage.open(); + waitCondition(() -> badgePage.isOpened()); + badgePage.checkOpened(); } @Test @@ -44,4 +48,60 @@ public void iconBadgeTest() { iconWithBadge.badge().has().text("15"); iconWithBadge.has().color("Red"); } + + @Test + public void badgeWithTextTest() { + customSizeBadge.badge().is().displayed(); + customSizeBadge.badge().has().text("Best"); + customSizeBadge.has().color("Violet"); + + } + + @Test + public void disabledBadgeTest() { + toggleDisabledBadge.is().disabled(); + toggleVisibilityBadge.click(); + toggleVisibilityBadge.is().enabled(); + toggleVisibilityBadge.click(); + toggleDisabledBadge.is().disabled(); + } + + @Test + public void hiddenBadgeTest() { + toggleVisibilityBadge.is().displayed(); + toggleVisibilityBadge.click(); + toggleVisibilityBadge.is().hidden(); + toggleVisibilityBadge.click(); + toggleVisibilityBadge.is().displayed(); + } + + @Test + public void overlapBadgeTest() { + textWithBadge.is().overlap(false); + buttonWithBadge.is().overlap(true); + } + + @Test + public void positionOfTheBadgeTest() { + buttonWithBadge.has().positionVertical("above"); + buttonWithBadge.has().positionHorizontal("before"); + + textWithBadge.has().positionVertical("above"); + textWithBadge.has().positionHorizontal("after"); + + bellowPositionBadge.has().positionVertical("below"); + bellowPositionBadge.has().positionHorizontal("after"); + } + + @Test + public void sizeOfTheBadgeTest() { + largeBadge.badge().is().displayed(); + largeBadge.has().size("large"); + + smallBadge.badge().is().displayed(); + smallBadge.has().size("small"); + + textWithBadge.badge().is().displayed(); + textWithBadge.has().size("medium"); + } } diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java index 5f5d2b5795..94b2e257e7 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java @@ -5,19 +5,18 @@ import org.testng.annotations.Ignore; import org.testng.annotations.Test; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.BadgeSection.textWithBadge; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; +import static com.jdiai.tools.Timer.waitCondition; +import static io.github.com.StaticSite.badgePage; +import static io.github.com.pages.BadgePage.textWithBadge; import static org.testng.Assert.assertTrue; -// TODO Move to the new page -@Ignore public class BadgeUnitTests extends TestsInit { @BeforeMethod(alwaysRun = true) public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); + badgePage.open(); + waitCondition(() -> badgePage.isOpened()); + badgePage.checkOpened(); } @Test diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java index 2a9bb2b226..11640b705a 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java @@ -7,11 +7,66 @@ import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; -public class BadgeAssert extends UIAssert { +public class BadgeAssert extends UIAssert { - @JDIAction("'{name}' has '{0}' color") + @JDIAction("Assert that '{name}' has '{0}' color") public BadgeAssert color(String value) { jdiAssert(element().color(value), Matchers.is(true)); return this; } + + @JDIAction("Assert that '{name}' has '{0}' size") + public BadgeAssert size(String value) { + jdiAssert(element().size(value), Matchers.is(true)); + return this; + + } + + @JDIAction("Assert that '{name}' has '{0}' position (vertical)") + public BadgeAssert positionVertical(String value) { + jdiAssert(element().positionVertical(value), Matchers.is(true)); + return this; + + } + + @JDIAction("Assert that '{name}' has '{0}' position (horizontal)") + public BadgeAssert positionHorizontal(String value) { + jdiAssert(element().positionHorizontal(value), Matchers.is(true)); + return this; + + } + + @JDIAction("Assert that '{name}' is overlap: {0}") + public BadgeAssert overlap(boolean value) { + jdiAssert(element().overlap(), Matchers.is(value)); + return this; + } + + @Override + @JDIAction("Assert that '{name}' is displayed") + public BadgeAssert displayed() { + jdiAssert(element().hidden(), Matchers.is(false)); + return super.displayed(); + } + + @Override + @JDIAction("Assert that '{name}' is hidden") + public BadgeAssert hidden() { + jdiAssert(element().hidden(), Matchers.is(true)); + return this; + } + + @Override + @JDIAction("Assert that '{name}' is enabled") + public BadgeAssert enabled() { + jdiAssert(element().disabled(), Matchers.is(false)); + return super.enabled(); + } + + @Override + @JDIAction("Assert that '{name}' is disabled") + public BadgeAssert disabled() { + jdiAssert(element().disabled(), Matchers.is(true)); + return this; + } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java index 8328cef034..791b198731 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java @@ -4,12 +4,13 @@ import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.common.UIElement; +import com.epam.jdi.light.elements.interfaces.base.HasClick; /** * To see an example of Badge web element please visit https://material.angular.io/components/badge/overview. */ -public class Badge extends UIBaseElement { +public class Badge extends UIBaseElement implements HasClick { @JDIAction("Get '{name}' badge") public UIElement badge() { @@ -26,6 +27,7 @@ public BadgeAssert is() { return new BadgeAssert().set(this); } + @JDIAction("Get '{name}' color") private String getColor() { return getColor(badge().css("background-color")); } @@ -42,4 +44,86 @@ private String getColor(String bgValue) { return "unknown color"; } } + + public boolean size(String value) { + return getBadgeSize().equalsIgnoreCase(value); + } + + private String getAttrClass() { + return attr("class"); + } + + private String getBadgeSize() { + return getBadgeSize(getAttrClass()); + } + + private String getBadgeSize(String aClass) { + String medium = "mat-badge-medium"; + String large = "mat-badge-large"; + String small = "mat-badge-small"; + if (aClass.contains(medium)) { + return "medium"; + } + if (aClass.contains(large)) { + return "large"; + } + if (aClass.contains(small)) { + return "small"; + } + return "unknown size"; + } + + public boolean positionVertical(String position) { + return getPositionVertical().equalsIgnoreCase(position); + } + + private String getPositionVertical() { + return getPositionVertical(getAttrClass()); + + } + + private String getPositionVertical(String aClass) { + String above = "mat-badge-above"; + String below = "mat-badge-below"; + if (aClass.contains(above)) { + return "above"; + } + if (aClass.contains(below)) { + return "below"; + } + return "unknown vertical position"; + } + + public boolean positionHorizontal(String position) { + return getPositionHorizontal().equalsIgnoreCase(position); + } + + private String getPositionHorizontal() { + return getPositionHorizontal(getAttrClass()); + } + + private String getPositionHorizontal(String aClass) { + String before = "mat-badge-before"; + String after = "mat-badge-after"; + if (aClass.contains(before)) { + return "before"; + } + if (aClass.contains(after)) { + return "after"; + } + return "unknown horizontal position"; + } + + public boolean overlap() { + return getAttrClass().contains("mat-badge-overlap"); + } + + public boolean hidden() { + return getAttrClass().contains("mat-badge-hidden"); + } + + public boolean disabled() { + return getAttrClass().contains("mat-badge-disabled"); + } + } From 7ca902fd2a3261530ca859a1723b40b61209a78f Mon Sep 17 00:00:00 2001 From: Ekaterina_Semenova1 Date: Wed, 2 Aug 2023 17:30:45 +0400 Subject: [PATCH 2/9] 4903: tests refactoring BADGE. fix 4 --- .../java/io/github/com/pages/AngularPage.java | 27 +--- .../tests/elements/common/BadgeTests.java | 93 ++++++------ .../angular/tests/unit/BadgeUnitTests.java | 21 +-- .../light/angular/asserts/BadgeAssert.java | 43 +++--- .../light/angular/elements/common/Badge.java | 136 +++++++----------- .../angular/elements/enums/BadgePosition.java | 10 ++ .../angular/elements/enums/BadgeSize.java | 8 ++ 7 files changed, 149 insertions(+), 189 deletions(-) create mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgePosition.java create mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgeSize.java diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java b/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java index c31a21450c..e063f343ff 100644 --- a/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java +++ b/jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java @@ -6,31 +6,7 @@ import com.epam.jdi.light.elements.composite.WebPage; import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; import com.epam.jdi.light.ui.html.elements.common.Icon; -import io.github.com.pages.sections.AutocompleteSection; -import io.github.com.pages.sections.ButtonToggleSection; -import io.github.com.pages.sections.CardSection; -import io.github.com.pages.sections.CheckboxSection; -import io.github.com.pages.sections.ChipsSection; -import io.github.com.pages.sections.DatepickerSection; -import io.github.com.pages.sections.DividerSection; -import io.github.com.pages.sections.ExpansionPanelSection; -import io.github.com.pages.sections.FormFieldsSection; -import io.github.com.pages.sections.GridListSection; -import io.github.com.pages.sections.InputSection; -import io.github.com.pages.sections.ListSection; -import io.github.com.pages.sections.MenuSection; -import io.github.com.pages.sections.PaginatorSection; -import io.github.com.pages.sections.RadioButtonSection; -import io.github.com.pages.sections.SelectSection; -import io.github.com.pages.sections.SideNavSection; -import io.github.com.pages.sections.SlideToggleSection; -import io.github.com.pages.sections.SliderSection; -import io.github.com.pages.sections.SnackbarSection; -import io.github.com.pages.sections.SortingOverviewSection; -import io.github.com.pages.sections.TabGroupSection; -import io.github.com.pages.sections.TableSection; -import io.github.com.pages.sections.ToolbarSection; -import io.github.com.pages.sections.TooltipSection; +import io.github.com.pages.sections.*; public class AngularPage extends WebPage { @@ -50,7 +26,6 @@ public class AngularPage extends WebPage { public static SelectSection selectSection; public static ListSection listSection; public static GridListSection gridListSection; - public static BasicButtonsSection basicButtonsSection; public static AutocompleteSection autocompleteSection; public static SnackbarSection snackbarSection; public static ButtonToggleSection buttonToggleSection; diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java index 522f1cb974..4ed2887d1a 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java @@ -4,8 +4,18 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import static com.epam.jdi.light.angular.elements.enums.BadgePosition.ABOVE; +import static com.epam.jdi.light.angular.elements.enums.BadgePosition.AFTER; +import static com.epam.jdi.light.angular.elements.enums.BadgePosition.BEFORE; +import static com.epam.jdi.light.angular.elements.enums.BadgePosition.BELOW; +import static com.epam.jdi.light.angular.elements.enums.BadgeSize.LARGE; +import static com.epam.jdi.light.angular.elements.enums.BadgeSize.MEDIUM; +import static com.epam.jdi.light.angular.elements.enums.BadgeSize.SMALL; import static com.jdiai.tools.Timer.waitCondition; import static io.github.com.StaticSite.badgePage; +import static io.github.com.enums.Colors.AMBER_ACCENT_2; +import static io.github.com.enums.Colors.DEEP_PURPLE; +import static io.github.com.enums.Colors.RED; import static io.github.com.pages.BadgePage.bellowPositionBadge; import static io.github.com.pages.BadgePage.buttonWithBadge; import static io.github.com.pages.BadgePage.customSizeBadge; @@ -23,50 +33,34 @@ public void before() { badgePage.open(); waitCondition(() -> badgePage.isOpened()); badgePage.checkOpened(); - } - - @Test - public void basicBadgeTest() { textWithBadge.show(); - textWithBadge.badge().is().displayed(); - textWithBadge.badge().has().text("4"); - textWithBadge.has().color("Violet"); - } - - @Test - public void buttonBadgeTest() { - buttonWithBadge.show(); - buttonWithBadge.badge().is().displayed(); - buttonWithBadge.badge().has().text("8"); - buttonWithBadge.has().color("Yellow"); - } - - @Test - public void iconBadgeTest() { - iconWithBadge.show(); - iconWithBadge.badge().is().displayed(); - iconWithBadge.badge().has().text("15"); - iconWithBadge.has().color("Red"); } - @Test - public void badgeWithTextTest() { - customSizeBadge.badge().is().displayed(); - customSizeBadge.badge().has().text("Best"); - customSizeBadge.has().color("Violet"); - + @Test(description = "The test checks color of the badge and content (string/number)") + public void colorAndContentBadgeTest() { + iconWithBadge.is().displayed() + .has().text("15") + .and().has().color(RED.value()); + buttonWithBadge.is().displayed() + .has().text("8") + .and().has().color(AMBER_ACCENT_2.value()); + customSizeBadge.is().displayed() + .has().text("Best") + .and().has().color(DEEP_PURPLE.value()); } - @Test + @Test(description = "Test checks if the badge is disabled/enabled") public void disabledBadgeTest() { toggleDisabledBadge.is().disabled(); - toggleVisibilityBadge.click(); - toggleVisibilityBadge.is().enabled(); - toggleVisibilityBadge.click(); + + toggleDisabledBadge.click(); + toggleDisabledBadge.is().enabled(); + + toggleDisabledBadge.click(); toggleDisabledBadge.is().disabled(); } - @Test + @Test(description = "Test checks the visibility of the badge") public void hiddenBadgeTest() { toggleVisibilityBadge.is().displayed(); toggleVisibilityBadge.click(); @@ -75,33 +69,34 @@ public void hiddenBadgeTest() { toggleVisibilityBadge.is().displayed(); } - @Test + @Test(description = "Test checks if badge overlaps") public void overlapBadgeTest() { textWithBadge.is().overlap(false); + buttonWithBadge.is().overlap(true); } - @Test + @Test(description = "Test check position of the badge") public void positionOfTheBadgeTest() { - buttonWithBadge.has().positionVertical("above"); - buttonWithBadge.has().positionHorizontal("before"); + buttonWithBadge.has().positionVertical(ABOVE) + .and().has().positionHorizontal(BEFORE); - textWithBadge.has().positionVertical("above"); - textWithBadge.has().positionHorizontal("after"); + textWithBadge.has().positionVertical(ABOVE) + .and().has().positionHorizontal(AFTER); - bellowPositionBadge.has().positionVertical("below"); - bellowPositionBadge.has().positionHorizontal("after"); + bellowPositionBadge.has().positionVertical(BELOW) + .and().has().positionHorizontal(AFTER); } - @Test + @Test(description = "Test checks size of the badge") public void sizeOfTheBadgeTest() { - largeBadge.badge().is().displayed(); - largeBadge.has().size("large"); + largeBadge.is().displayed() + .and().has().size(LARGE); - smallBadge.badge().is().displayed(); - smallBadge.has().size("small"); + smallBadge.is().displayed() + .and().has().size(SMALL); - textWithBadge.badge().is().displayed(); - textWithBadge.has().size("medium"); + textWithBadge.is().displayed() + .and().has().size(MEDIUM); } } diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java index 94b2e257e7..39b6079c4f 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java @@ -5,27 +5,18 @@ import org.testng.annotations.Ignore; import org.testng.annotations.Test; -import static com.jdiai.tools.Timer.waitCondition; -import static io.github.com.StaticSite.badgePage; -import static io.github.com.pages.BadgePage.textWithBadge; +import static io.github.com.StaticSite.angularPage; +import static io.github.epam.site.steps.States.shouldBeLoggedIn; import static org.testng.Assert.assertTrue; +// TODO Move to the new page +@Ignore public class BadgeUnitTests extends TestsInit { @BeforeMethod(alwaysRun = true) public void before() { - badgePage.open(); - waitCondition(() -> badgePage.isOpened()); - badgePage.checkOpened(); + shouldBeLoggedIn(); + angularPage.shouldBeOpened(); } - @Test - public void badgeTest() { - assertTrue(textWithBadge.badge().isDisplayed()); - } - - @Test - public void colorTest() { - assertTrue(textWithBadge.color("Violet")); - } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java index 11640b705a..2a0cf91382 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java @@ -1,72 +1,79 @@ package com.epam.jdi.light.angular.asserts; import com.epam.jdi.light.angular.elements.common.Badge; +import com.epam.jdi.light.angular.elements.enums.BadgePosition; +import com.epam.jdi.light.angular.elements.enums.BadgeSize; 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; +import static java.lang.String.format; public class BadgeAssert extends UIAssert { @JDIAction("Assert that '{name}' has '{0}' color") public BadgeAssert color(String value) { - jdiAssert(element().color(value), Matchers.is(true)); + String actualColor = element().color(); + jdiAssert(actualColor, Matchers.equalTo(value), format("%s is not equal to %s", actualColor, value)); return this; } @JDIAction("Assert that '{name}' has '{0}' size") - public BadgeAssert size(String value) { - jdiAssert(element().size(value), Matchers.is(true)); + public BadgeAssert size(BadgeSize size) { + final BadgeSize actualBadgeSize = element().size(); + jdiAssert(actualBadgeSize, Matchers.is(size), format("%s is not equal to %s", actualBadgeSize, size)); return this; } @JDIAction("Assert that '{name}' has '{0}' position (vertical)") - public BadgeAssert positionVertical(String value) { - jdiAssert(element().positionVertical(value), Matchers.is(true)); + public BadgeAssert positionVertical(BadgePosition value) { + final BadgePosition actualPosition = element().positionVertical(); + jdiAssert(actualPosition, Matchers.is(value), format("%s is not equal to %s", actualPosition, value)); return this; } @JDIAction("Assert that '{name}' has '{0}' position (horizontal)") - public BadgeAssert positionHorizontal(String value) { - jdiAssert(element().positionHorizontal(value), Matchers.is(true)); + public BadgeAssert positionHorizontal(BadgePosition value) { + final BadgePosition actualPosition = element().positionHorizontal(); + jdiAssert(actualPosition, Matchers.is(value), format("%s is not equal to %s", actualPosition, value)); return this; } @JDIAction("Assert that '{name}' is overlap: {0}") public BadgeAssert overlap(boolean value) { - jdiAssert(element().overlap(), Matchers.is(value)); + jdiAssert(element().isOverlap(), Matchers.is(value), value ? "should be overlap" : "should NOT be overlap"); return this; } @Override @JDIAction("Assert that '{name}' is displayed") public BadgeAssert displayed() { - jdiAssert(element().hidden(), Matchers.is(false)); + jdiAssert(element().isDisplayed(), Matchers.is(true), "should be displayed"); return super.displayed(); } - @Override - @JDIAction("Assert that '{name}' is hidden") - public BadgeAssert hidden() { - jdiAssert(element().hidden(), Matchers.is(true)); - return this; - } - @Override @JDIAction("Assert that '{name}' is enabled") public BadgeAssert enabled() { - jdiAssert(element().disabled(), Matchers.is(false)); + jdiAssert(element().isEnabled(), Matchers.is(true), "should be enabled"); return super.enabled(); } @Override @JDIAction("Assert that '{name}' is disabled") public BadgeAssert disabled() { - jdiAssert(element().disabled(), Matchers.is(true)); + jdiAssert(element().isDisabled(), Matchers.is(true), "should be disabled"); + return this; + } + + @JDIAction("Assert that '{name}' has text {0}") + public BadgeAssert text(String value) { + final String actualText = element().getText(); + jdiAssert(actualText, Matchers.is(value), format("%s is not equal to %s", actualText, value)); return this; } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java index 791b198731..30cad80d51 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java @@ -1,25 +1,27 @@ package com.epam.jdi.light.angular.elements.common; import com.epam.jdi.light.angular.asserts.BadgeAssert; +import com.epam.jdi.light.angular.elements.enums.BadgePosition; +import com.epam.jdi.light.angular.elements.enums.BadgeSize; import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.common.UIElement; import com.epam.jdi.light.elements.interfaces.base.HasClick; +import com.epam.jdi.light.elements.interfaces.common.IsText; + +import static com.epam.jdi.light.angular.elements.enums.BadgeSize.LARGE; +import static com.epam.jdi.light.angular.elements.enums.BadgeSize.MEDIUM; +import static com.epam.jdi.light.angular.elements.enums.BadgeSize.SMALL; /** * To see an example of Badge web element please visit https://material.angular.io/components/badge/overview. */ -public class Badge extends UIBaseElement implements HasClick { +public class Badge extends UIBaseElement implements HasClick, IsText { @JDIAction("Get '{name}' badge") - public UIElement badge() { - return this.find(".mat-badge-content"); - } - - @JDIAction("'{name}' has color '{0}'") - public boolean color(String color) { - return getColor().equalsIgnoreCase(color); + private UIElement badge() { + return core().find(".mat-badge-content"); } @Override @@ -28,102 +30,74 @@ public BadgeAssert is() { } @JDIAction("Get '{name}' color") - private String getColor() { - return getColor(badge().css("background-color")); - } - - private String getColor(String bgValue) { - switch (bgValue) { - case "rgba(103, 58, 183, 1)": - return "violet"; - case "rgba(244, 67, 54, 1)": - return "red"; - case "rgba(255, 215, 64, 1)": - return "yellow"; - default: - return "unknown color"; - } - } - - public boolean size(String value) { - return getBadgeSize().equalsIgnoreCase(value); - } - - private String getAttrClass() { - return attr("class"); - } - - private String getBadgeSize() { - return getBadgeSize(getAttrClass()); + public String color() { + return badge().css("background-color"); } - private String getBadgeSize(String aClass) { - String medium = "mat-badge-medium"; - String large = "mat-badge-large"; - String small = "mat-badge-small"; - if (aClass.contains(medium)) { - return "medium"; + @JDIAction("Get '{name}' size") + public BadgeSize size() { + if (hasClass("mat-badge-medium")) { + return MEDIUM; } - if (aClass.contains(large)) { - return "large"; + if (hasClass("mat-badge-large")) { + return LARGE; } - if (aClass.contains(small)) { - return "small"; + if (hasClass("mat-badge-small")) { + return SMALL; } - return "unknown size"; + return BadgeSize.UNKNOWN; } - public boolean positionVertical(String position) { - return getPositionVertical().equalsIgnoreCase(position); + @JDIAction("Get '{name}' vertical position") + public BadgePosition positionVertical() { + if (hasClass("mat-badge-above")) { + return BadgePosition.ABOVE; + } + if (hasClass("mat-badge-below")) { + return BadgePosition.BELOW; + } + return BadgePosition.UNKNOWN; } - private String getPositionVertical() { - return getPositionVertical(getAttrClass()); - - } - private String getPositionVertical(String aClass) { - String above = "mat-badge-above"; - String below = "mat-badge-below"; - if (aClass.contains(above)) { - return "above"; + @JDIAction("Get '{name}' horizontal position") + public BadgePosition positionHorizontal() { + if (hasClass("mat-badge-before")) { + return BadgePosition.BEFORE; } - if (aClass.contains(below)) { - return "below"; + if (hasClass("mat-badge-after")) { + return BadgePosition.AFTER; } - return "unknown vertical position"; + return BadgePosition.UNKNOWN; } - public boolean positionHorizontal(String position) { - return getPositionHorizontal().equalsIgnoreCase(position); + @JDIAction(value = "Check that '{name}' is overlap") + public boolean isOverlap() { + return hasClass("mat-badge-overlap"); } - private String getPositionHorizontal() { - return getPositionHorizontal(getAttrClass()); + @Override + public boolean isHidden() { + return hasClass("mat-badge-hidden"); } - private String getPositionHorizontal(String aClass) { - String before = "mat-badge-before"; - String after = "mat-badge-after"; - if (aClass.contains(before)) { - return "before"; - } - if (aClass.contains(after)) { - return "after"; - } - return "unknown horizontal position"; + @Override + public boolean isDisplayed() { + return !isHidden(); } - public boolean overlap() { - return getAttrClass().contains("mat-badge-overlap"); + @Override + public boolean isDisabled() { + return hasClass("mat-badge-disabled"); } - public boolean hidden() { - return getAttrClass().contains("mat-badge-hidden"); + @Override + public boolean isEnabled() { + return !isDisabled(); } - public boolean disabled() { - return getAttrClass().contains("mat-badge-disabled"); + @Override + public String getText() { + return badge().getText(); } - } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgePosition.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgePosition.java new file mode 100644 index 0000000000..458da6f811 --- /dev/null +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgePosition.java @@ -0,0 +1,10 @@ +package com.epam.jdi.light.angular.elements.enums; + +public enum BadgePosition { + BELOW, + ABOVE, + AFTER, + BEFORE, + UNKNOWN + +} diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgeSize.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgeSize.java new file mode 100644 index 0000000000..f2b784b8bc --- /dev/null +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgeSize.java @@ -0,0 +1,8 @@ +package com.epam.jdi.light.angular.elements.enums; + +public enum BadgeSize { + LARGE, + MEDIUM, + SMALL, + UNKNOWN +} From 2ef52541bbe97047674fb2cbd6f74825459f0907 Mon Sep 17 00:00:00 2001 From: Natalia Pozhidaeva Date: Sun, 10 Sep 2023 21:59:02 -0500 Subject: [PATCH 3/9] Delete unit's --- .../tests/unit/AutocompleteUnitTests.java | 205 -------- .../angular/tests/unit/BadgeUnitTests.java | 22 - .../tests/unit/BottomSheetUnitTests.java | 59 --- .../tests/unit/ButtonToggleUnitTests.java | 49 -- .../angular/tests/unit/CardUnitTests.java | 40 -- .../angular/tests/unit/CheckboxUnitTests.java | 58 --- .../angular/tests/unit/ChipsUnitTests.java | 78 --- .../unit/DatepickerContainerUnitTests.java | 354 -------------- .../tests/unit/DatepickerUnitTests.java | 448 ------------------ .../angular/tests/unit/DialogUnitTests.java | 52 -- .../angular/tests/unit/DividerUnitTests.java | 36 -- .../tests/unit/ExpansionPanelUnitTests.java | 174 ------- .../tests/unit/FormFieldUnitTests.java | 86 ---- .../MaterialSelectorContainerUnitTests.java | 128 ----- .../tests/unit/MaterialSelectorUnitTests.java | 128 ----- .../angular/tests/unit/MenuUnitTests.java | 75 --- .../tests/unit/NativeSelectorUnitTests.java | 94 ---- .../tests/unit/PaginatorUnitTests.java | 92 ---- .../tests/unit/ProgressBarUnitTests.java | 115 ----- .../tests/unit/RadioButtonsUnitTests.java | 28 -- .../angular/tests/unit/RippleUnitTests.java | 135 ------ .../angular/tests/unit/SideNavUnitTests.java | 70 --- .../tests/unit/SlideToggleUnitTests.java | 54 --- .../angular/tests/unit/SliderUnitTests.java | 113 ----- .../angular/tests/unit/SnackbarUnitTests.java | 47 -- .../tests/unit/SortingOverviewUnitTests.java | 69 --- .../angular/tests/unit/TabGroupUnitTests.java | 94 ---- .../angular/tests/unit/TooltipUnitTests.java | 65 --- .../src/test/resources/general.xml | 1 - .../src/test/resources/unit.xml | 12 - .../light/angular/asserts/BadgeAssert.java | 55 +-- .../light/angular/elements/common/Badge.java | 74 +-- .../angular/elements/enums/BadgePosition.java | 1 - .../angular/elements/interfaces/HasBadge.java | 79 +++ .../interfaces/asserts/HasBadgeAssert.java | 59 +++ 35 files changed, 143 insertions(+), 3106 deletions(-) delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/AutocompleteUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BottomSheetUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ButtonToggleUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/CardUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/CheckboxUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ChipsUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DatepickerContainerUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DatepickerUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DialogUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DividerUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ExpansionPanelUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/FormFieldUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/MaterialSelectorContainerUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/MaterialSelectorUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/MenuUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/NativeSelectorUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/PaginatorUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ProgressBarUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/RadioButtonsUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/RippleUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SideNavUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SlideToggleUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SliderUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SnackbarUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SortingOverviewUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/TabGroupUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/TooltipUnitTests.java delete mode 100644 jdi-light-angular-tests/src/test/resources/unit.xml create mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasBadge.java create mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/asserts/HasBadgeAssert.java diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/AutocompleteUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/AutocompleteUnitTests.java deleted file mode 100644 index 491ec0312f..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/AutocompleteUnitTests.java +++ /dev/null @@ -1,205 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static com.jdiai.tools.LinqUtils.safeException; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.AngularPage.autocompleteSection; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsString; -import static org.testng.Assert.*; - -// TODO Move to the new page -@Ignore -public class AutocompleteUnitTests extends TestsInit { - - @BeforeMethod - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void getPlaceHolderValueTest() { - assertEquals(autocompleteSection. - autocompleteOverview.placeholder(), "State"); - autocompleteSection.autocompleteDisableInput.check(); - assertEquals(autocompleteSection. - autocompleteOverview.placeholder(), "State"); - autocompleteSection.autocompleteDisableInput.uncheck(); - assertEquals(autocompleteSection. - simpleAutocomplete.placeholder(), "Pick one"); - } - - @Test - public void getDisplayValueTest() { - assertEquals(autocompleteSection. - displayValueAutocomplete.displayValue(), "Assignee"); - autocompleteSection.displayValueAutocomplete.setUniqueAutoCompleteAttribute("_ngcontent"); - autocompleteSection. - displayValueAutocomplete.setValue("Mar", "Mary"); - assertEquals(autocompleteSection. - displayValueAutocomplete.displayValue(), "Assignee"); - autocompleteSection.displayValueAutocomplete.clear(); - } - - @Test - public void inputOverviewSelectTest() { - autocompleteSection.autocompleteOverview. - setValue("Ark", - "ArkansasPopulation: 2.978M"); - assertEquals(autocompleteSection.autocompleteOverview.getValue(), "Arkansas"); - } - - @Test - public void clickOverviewSelectTest() { - autocompleteSection.autocompleteOverview. - setValue("TexasPopulation: 27.47M"); - assertEquals(autocompleteSection.autocompleteOverview.getValue(), "Texas"); - } - - @Test - public void simpleAutocompleteGetItemsValuesTest() { - String expectedValuesArray[] = {"One", "Two", "Three"}; - List expectedValues = Arrays.asList(expectedValuesArray); - assertEquals(autocompleteSection. - simpleAutocomplete. - options(), - expectedValues); - } - - @Test - public void optionGroupsAutocompleteGetItemsValuesTest() { - String expectedValuesArray[] = {"California", "Colorado", "Connecticut"}; - List expectedValues = Arrays.asList(expectedValuesArray); - assertEquals(autocompleteSection. - optionGroupsAutocomplete. - options("C"), - expectedValues); - } - - @Test - public void disabledInputThrowsExceptionUponInputTest() { - autocompleteSection.autocompleteOverview.clear(); - autocompleteSection.autocompleteDisableInput.check(); - autocompleteSection.autocompleteOverview.waitFor(2); - try { - autocompleteSection. - autocompleteOverview. - setValue("Ark", - "ArkansasPopulation: 2.978M"); - } catch (Exception e) { - assertThat(safeException(e), containsString("Element is not currently interactable")); - } - autocompleteSection.autocompleteDisableInput.uncheck(); - } - - @Test - public void getGroupsValuesTest() { - autocompleteSection.autocompleteOverview.clear(); - autocompleteSection.autocompleteOverview.click(); - assertEquals(autocompleteSection. - autocompleteOverview.groups(), Collections.emptyList()); - autocompleteSection.optionGroupsAutocomplete.clear(); - autocompleteSection.optionGroupsAutocomplete.click(); - String[] values = {"A", "C", "D", "F", "G", "H", "I", "K", "L", "M", "N", "O", "P", "R", "S", "T", "U", "V", "W"}; - List groupsValues = Arrays.asList(values); - assertEquals(autocompleteSection. - optionGroupsAutocomplete.groups(), groupsValues); - autocompleteSection.optionGroupsAutocomplete.input("C"); - assertEquals(autocompleteSection. - optionGroupsAutocomplete.groups(), Arrays.asList(new String[]{"C"})); - } - - @Test - public void getGroupsAndOptionsValuesTest() { - Map> emptyGroupAndOptionsValues = new HashMap<>(); - emptyGroupAndOptionsValues.put("", Collections.emptyList()); - autocompleteSection.optionGroupsAutocomplete.input("B"); - assertEquals(autocompleteSection. - optionGroupsAutocomplete.groupsAndOptionsValues(), emptyGroupAndOptionsValues); - autocompleteSection.optionGroupsAutocomplete.input("C"); - Map> groupAndOptionsValues = new HashMap<>(); - String[] options = {"California", "Colorado", "Connecticut"}; - List optionsValues = Arrays.asList(options); - groupAndOptionsValues.put("C", optionsValues); - assertEquals(autocompleteSection. - optionGroupsAutocomplete.groupsAndOptionsValues(), groupAndOptionsValues); - } - - @Test - public void clearTest() { - autocompleteSection.simpleAutocomplete.setValue("Two"); - autocompleteSection.simpleAutocomplete.clear(); - assertEquals(autocompleteSection.simpleAutocomplete.getValue(), ""); - } - - @Test - public void isMandatoryTest() { - assertFalse(autocompleteSection.autocompleteOverview.isMandatory()); - assertFalse(autocompleteSection.simpleAutocomplete.isMandatory()); - assertTrue(autocompleteSection.optionGroupsAutocomplete.isMandatory()); - } - - @Test - public void isInvalidatedTest() { - autocompleteSection.autocompleteOverview.click(); - assertFalse(autocompleteSection.autocompleteOverview.isInvalidated()); - autocompleteSection.optionGroupsAutocomplete.setValue("Florida"); - autocompleteSection.optionGroupsAutocomplete.clear(); - assertTrue(autocompleteSection.optionGroupsAutocomplete.isInvalidated()); - } - - @Test - public void isEnabledTest() { - assertTrue(autocompleteSection.autocompleteOverview.isEnabled()); - assertTrue(autocompleteSection.simpleAutocomplete.isEnabled()); - assertTrue(autocompleteSection.displayValueAutocomplete.isEnabled()); - assertTrue(autocompleteSection.filterAutocomplete.isEnabled()); - assertTrue(autocompleteSection.optionGroupsAutocomplete.isEnabled()); - assertTrue(autocompleteSection.autocompleteFirstOptionHighlighted.isEnabled()); - } - - @Test - public void isDisabledTest() { - autocompleteSection.autocompleteDisableInput.check(); - assertTrue(autocompleteSection.autocompleteOverview.isDisabled()); - autocompleteSection.autocompleteDisableInput.uncheck(); - } - - @Test - public void isExpandedTest() { - autocompleteSection.autocompleteOverview.click(); - assertTrue(autocompleteSection.autocompleteOverview.expanded()); - autocompleteSection.simpleAutocomplete.click(); - assertTrue(autocompleteSection.simpleAutocomplete.expanded()); - autocompleteSection.displayValueAutocomplete.click(); - assertTrue(autocompleteSection.displayValueAutocomplete.expanded()); - autocompleteSection.filterAutocomplete.click(); - assertTrue(autocompleteSection.filterAutocomplete.expanded()); - autocompleteSection.optionGroupsAutocomplete.click(); - assertTrue(autocompleteSection.optionGroupsAutocomplete.expanded()); - autocompleteSection.autocompleteFirstOptionHighlighted.click(); - assertTrue(autocompleteSection.autocompleteFirstOptionHighlighted.expanded()); - } - - @Test - public void isCollapsedTest() { - assertTrue(autocompleteSection.autocompleteOverview.collapsed()); - assertTrue(autocompleteSection.simpleAutocomplete.collapsed()); - assertTrue(autocompleteSection.displayValueAutocomplete.collapsed()); - assertTrue(autocompleteSection.filterAutocomplete.collapsed()); - assertTrue(autocompleteSection.optionGroupsAutocomplete.collapsed()); - assertTrue(autocompleteSection.autocompleteFirstOptionHighlighted.collapsed()); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java deleted file mode 100644 index 39b6079c4f..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BadgeUnitTests.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class BadgeUnitTests extends TestsInit { - - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BottomSheetUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BottomSheetUnitTests.java deleted file mode 100644 index b4611940cf..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/BottomSheetUnitTests.java +++ /dev/null @@ -1,59 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.*; - -import java.util.Arrays; -import java.util.List; - -import static com.epam.jdi.light.elements.composite.WebPage.reload; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.AngularPage.bottomSheet; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class BottomSheetUnitTests extends TestsInit { - private static final List BOTTOM_SHEET_VALUES = - Arrays.asList("Google Keep", "Google Docs", "Google Plus", "Google Hangouts"); - - @BeforeClass(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - bottomSheet.show(); - } - - @BeforeMethod - // required to reload before each test - public void reloadPage() { - reload(); - bottomSheet.show(); - } - - @Test - public void openedTest() { - bottomSheet.open(); - assertTrue(bottomSheet.isOpened()); - } - - @Test - public void closedTest() { - bottomSheet.open(); - bottomSheet.close(); - assertTrue(bottomSheet.isClosed()); - } - - @Test - public void valuesTest() { - bottomSheet.open(); - assertEquals(bottomSheet.values(), BOTTOM_SHEET_VALUES); - } - - @AfterClass - public void tearDownClass() { - reload(); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ButtonToggleUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ButtonToggleUnitTests.java deleted file mode 100644 index 4d9901e9a0..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ButtonToggleUnitTests.java +++ /dev/null @@ -1,49 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.ButtonToggleSection.basicButtonToggle; -import static io.github.com.pages.sections.ButtonToggleSection.basicButtonToggleAlign; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class ButtonToggleUnitTests extends TestsInit { - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void isButtonToggleSelectedTest() { - String ITALIC = "italic"; - basicButtonToggle.clickButtonToggleByValue(ITALIC); - assertTrue(basicButtonToggle.isButtonToggleSelected(ITALIC)); - } - - @Test - public void isButtonToggleButtonPressedTest() { - String BOLD = "bold"; - basicButtonToggle.clickButtonToggleByValue(BOLD); - assertTrue(basicButtonToggle.isButtonToggleButtonPressed(BOLD)); - } - - @Test - public void buttonToggleHasTextTest() { - String UNDERLINE = "underline"; - basicButtonToggle.clickButtonToggleByValue(UNDERLINE); - assertTrue(basicButtonToggle.buttonToggleHasText(UNDERLINE)); - } - - @Test(expectedExceptions = UnsupportedOperationException.class) - public void verifyExclusiveButtonToggleJustifyButton() { - String JUSTIFY = "justify"; - basicButtonToggleAlign.is().assertButtonToggleIsSelected(JUSTIFY); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/CardUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/CardUnitTests.java deleted file mode 100644 index 2e974f1964..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/CardUnitTests.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.CardSection.card; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; - -// TODO Move to the new page -@Ignore -public class CardUnitTests extends TestsInit { - @BeforeMethod - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void cardButtonsClickByBtnTextTest() { - card.getButtonByText("LIKE").click(); - card.getButtonByText("LIKE").has().cssClass("cdk-focused"); - card.getButtonByText("LIKE").has().cssClass("cdk-mouse-focused"); - card.getButtonByText("SHARE").click(); - card.getButtonByText("SHARE").has().cssClass("cdk-focused"); - card.getButtonByText("SHARE").has().cssClass("cdk-mouse-focused"); - } - - @Test - public void cardButtonsClickByBtnNumberTest() { - card.getButtonByNumber(1).click(); - card.getButtonByNumber(1).has().cssClass("cdk-focused"); - card.getButtonByNumber(1).has().cssClass("cdk-mouse-focused"); - card.getButtonByNumber(2).click(); - card.getButtonByNumber(2).has().cssClass("cdk-focused"); - card.getButtonByNumber(2).has().cssClass("cdk-mouse-focused"); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/CheckboxUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/CheckboxUnitTests.java deleted file mode 100644 index 8aeb7b7a32..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/CheckboxUnitTests.java +++ /dev/null @@ -1,58 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.CheckboxSection.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.*; - -// TODO Move to the new page -@Ignore -public class CheckboxUnitTests extends TestsInit { - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - disabledCheckbox.show(); - } - - @Test - public void checkTest() { - basicCheckbox.check(); - assertTrue(basicCheckbox.isSelected()); - } - - @Test - public void uncheckTest() { - basicCheckbox.uncheck(); - assertFalse(basicCheckbox.isSelected()); - } - - @Test - public void labelTest() { - assertEquals(basicCheckbox.label().getValue(), "Check me!"); - } - - @Test - public void indeterminateTest() { - indeterminateCheckbox.click(); - assertTrue(resultCheckbox.isIndeterminate()); - } - - @Test - public void enabledOptionTest() { - disabledCheckbox.uncheck(); - assertTrue(resultCheckbox.isEnabled()); - } - - @Test - public void disabledOptionTest() { - disabledCheckbox.check(); - assertTrue(resultCheckbox.isDisabled()); - } - -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ChipsUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ChipsUnitTests.java deleted file mode 100644 index 043b253417..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ChipsUnitTests.java +++ /dev/null @@ -1,78 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import java.util.Arrays; -import java.util.List; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.ChipsSection.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class ChipsUnitTests extends TestsInit { - - private static final String ONEFISH = "One fish"; - private static final String NONE = "none"; - private static final String PRIMARY = "Primary"; - private static final String ACCENT = "Accent"; - private static final String WARN = "Warn"; - private static final String PLACEHOLDER = "New fruit..."; - - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void isChipsDisplayedTest() { - assertTrue(basicChipsRow.isDisplayed()); - } - - @Test - public void basicChipsHasTextTest() { - basicChipsRow.clickChipsByTextValue(ONEFISH); - Assert.assertTrue(basicChipsRow.chipsHasText(ONEFISH)); - } - - @Test - public void stackedChipsHasTextTest() { - // The first click is on last element to prevent additional scrolls - stackedChipsList.clickChipsByTextValue(WARN); - Assert.assertTrue(stackedChipsList.chipsHasText(WARN)); - stackedChipsList.clickChipsByTextValue(NONE); - Assert.assertTrue(stackedChipsList.chipsHasText(NONE)); - stackedChipsList.clickChipsByTextValue(PRIMARY); - Assert.assertTrue(stackedChipsList.chipsHasText(PRIMARY)); - stackedChipsList.clickChipsByTextValue(ACCENT); - Assert.assertTrue(stackedChipsList.chipsHasText(ACCENT)); - - } - - @Test - public void chipsHasPlaceholderTest() { - assertEquals(chipsAutocompleteInput.getPlaceholderForChips(), PLACEHOLDER); - } - - @Test - public void chipsAutocompleteGetValuesTest() { - String[] expectedValuesArray = {"Apple", "Lemon", "Lime", "Orange", "Strawberry"}; - List expectedValues = Arrays.asList(expectedValuesArray); - assertEquals(chipsAutocompleteInput.options(), expectedValues); - } - - @Test - public void clearInputFieldTest() { - chipsWithInputInput.input("Melon"); - chipsWithInputInput.clearInputField(); - Assert.assertTrue(chipsWithInputInput.isEmpty()); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DatepickerContainerUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DatepickerContainerUnitTests.java deleted file mode 100644 index 396b746e1f..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DatepickerContainerUnitTests.java +++ /dev/null @@ -1,354 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import com.epam.jdi.light.angular.elements.composite.DatepickerContainer; -import com.epam.jdi.light.angular.entities.DatepickerNavigation; -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import java.time.LocalDate; -import java.time.Month; -import java.time.Year; -import java.util.Arrays; -import java.util.Locale; -import java.util.stream.Collectors; - -import static com.epam.jdi.light.angular.entities.DatepickerNavigation.*; -import static com.epam.jdi.light.elements.composite.WebPage.refresh; -import static com.jdiai.tools.StringUtils.format; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.DatepickerSection.*; -import static io.github.epam.angular.tests.elements.complex.datepicker.TestsDatepickerBase.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.*; - -// TODO Move to the new page -@Ignore -public class DatepickerContainerUnitTests extends TestsInit { - private DatepickerContainer container; - - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - container = new DatepickerContainer(); - } - - private void reInit() { - refresh(); - container = new DatepickerContainer(); - } - - @Test - public void displayedTest() { - basicDatepicker.show(); - basicDatepicker.expand(); - assertTrue(container.isDisplayed()); - } - - @Test - public void hiddenTest() { - reInit(); - basicDatepicker.show(); - assertTrue(container.isHidden()); - } - - @Test - public void monthTest() { - reInit(); - basicDatepicker.show(); - basicDatepicker.expand(); - assertEquals(container.selectedMonth(), LocalDate.now().getMonth()); - } - - @Test - public void startMonthTest() { - reInit(); - startDateDatepicker.show(); - startDateDatepicker.expand(); - assertEquals(container.startMonth(), Month.JANUARY); - } - - @Test - public void startMonthWithLocaleTest() { - reInit(); - startDateDatepicker.show(); - startDateDatepicker.expand(); - assertEquals(container.startMonth(Locale.US), Month.JANUARY); - } - - @Test - public void selectedMonthWithLocaleTest() { - reInit(); - differentLocaleDatepicker.show(); - differentLocaleDatepicker.switchLocale(); - differentLocaleDatepicker.expand(); - assertEquals(container.selectedMonth(Locale.FRANCE), LocalDate.now().getMonth()); - } - - @Test - public void yearTest() { - reInit(); - basicDatepicker.show(); - basicDatepicker.expand(); - assertEquals(container.selectedYear(), Year.now()); - } - - @Test - public void startYearTest() { - startDateDatepicker.show(); - startDateDatepicker.expand(); - assertEquals(container.startYear(), Year.of(1990)); - } - - @Test - public void todayDayTest() { - reInit(); - basicDatepicker.show(); - basicDatepicker.expand(); - assertEquals(container.todayDay(), LocalDate.now().getDayOfMonth()); - } - - @Test - public void startDayTest() { - reInit(); - startDateDatepicker.show(); - startDateDatepicker.expand(); - container.selectActiveMonth(); - assertEquals(container.activeDay(), 1); - } - - @Test - public void startDayWithLocaleTest() { - reInit(); - startDateDatepicker.show(); - startDateDatepicker.expand(); - container.selectActiveMonth(Locale.US); - assertEquals(container.activeDay(), 1); - } - - @Test - public void startDayWithDifferentLocaleTest() { - reInit(); - differentLocaleDatepicker.show(); - differentLocaleDatepicker.expand(); - assertEquals(container.activeDay(), LocalDate.now().getDayOfMonth()); - } - - @Test - public void dayInPreviousMonthTest() { - reInit(); - int currentMonth = LocalDate.now().getMonth().getValue(); - int previousMonth = currentMonth == 1 ? 12 : currentMonth - 1; - basicDatepicker.show(); - basicDatepicker.expand(); - container.selectPreviousMonth(); - container.selectDay(1); - basicDatepicker.expand(); - assertEquals(container.selectedMonth().getValue(), previousMonth); - } - - @Test - public void dayInNextMonthTest() { - reInit(); - int currentMonth = LocalDate.now().getMonth().getValue(); - int nextMonth = currentMonth == 12 ? 1 : currentMonth + 1; - basicDatepicker.show(); - basicDatepicker.expand(); - container.selectNextMonth(); - container.selectDay(2); - basicDatepicker.expand(); - assertEquals(container.selectedMonth().getValue(), nextMonth); - } - - @Test - public void selectDayByStringValueTest() { - basicDatepicker.show(); - basicDatepicker.expand(); - container.selectDay("25"); - basicDatepicker.expand(); - assertEquals(container.selectedDay(), 25); - } - - @Test - public void selectDayByIntegerValueTest() { - basicDatepicker.show(); - basicDatepicker.expand(); - container.selectDay(4); - basicDatepicker.expand(); - assertEquals(container.selectedDay(), 4); - } - - @Test - public void selectDateTest() { - basicDatepicker.show(); - basicDatepicker.expand(); - container.select(LocalDate.of(2033, 2, 3)); - basicDatepicker.expand(); - assertEquals(container.selectedDate(), LocalDate.of(2033, 2, 3)); - } - - @Test - public void selectDateWithLocaleTest() { - basicDatepicker.show(); - basicDatepicker.expand(); - container.select(LocalDate.of(2030, 12, 4), Locale.US); - basicDatepicker.expand(); - assertEquals(container.selectedDate(Locale.US), LocalDate.of(2030, 12, 4)); - } - - @Test - public void selectDateWithDifferentLocaleTest() { - differentLocaleDatepicker.show(); - differentLocaleDatepicker.expand(); - container.select(LocalDate.of(2017, 6, 14), Locale.JAPAN); - differentLocaleDatepicker.expand(); - assertEquals(container.selectedDate(Locale.JAPAN), LocalDate.of(2017, 6, 14)); - } - - @Test - public void selectDateFromPreviousRangeOfYearsTest() { - basicDatepicker.show(); - basicDatepicker.expand(); - container.select(LocalDate.of(1975, 10, 9), Locale.US); - basicDatepicker.expand(); - assertEquals(container.selectedDate(), LocalDate.of(1975, 10, 9)); - } - - @Test - public void selectDateByStringValueTest() { - basicDatepicker.show(); - basicDatepicker.expand(); - container.select("12/13/2016"); - basicDatepicker.expand(); - assertEquals(container.selectedDate(), LocalDate.of(2016, 12, 13)); - } - - @Test - public void selectDateWithLocaleValueTest() { - basicDatepicker.show(); - basicDatepicker.expand(); - container.select("12/7/2018", Locale.US); - basicDatepicker.expand(); - assertEquals(container.selectedDate(), LocalDate.of(2018, 12, 7)); - } - - @Test - public void selectDateWithDifferentLocaleValueTest() { - differentLocaleDatepicker.show(); - differentLocaleDatepicker.expand(); - container.select("4/23/2019", Locale.JAPAN); - differentLocaleDatepicker.expand(); - assertEquals(container.selectedDate(Locale.JAPAN), LocalDate.of(2019, 4, 23)); - } - - @Test - public void selectDateFromNextRangeOfYearsTest() { - basicDatepicker.show(); - basicDatepicker.expand(); - container.select("10/09/2075"); - basicDatepicker.expand(); - assertEquals(container.selectedDate(), LocalDate.of(2075, 10, 9)); - } - - @Test - public void disabledPreviousMonthNavigationTest() { - String minDate = getMinDate(); - minMaxDatepicker.show(); - minMaxDatepicker.setText(minDate); - minMaxDatepicker.expand(); - assertTrue(container.disabled(PREVIOUS_MONTH.getName())); - } - - @Test - public void disabledNextMonthNavigationTest() { - String maxDate = getMaxDate(); - minMaxDatepicker.show(); - minMaxDatepicker.setText(maxDate); - minMaxDatepicker.expand(); - assertTrue(container.disabled(NEXT_MONTH.getName())); - } - - @Test - public void disabledMonthsAndYearsNavigationTest() { - String firstDisabledYearCell = format(CELL.getName(), MIN_YEAR - 2); - String secondDisabledYearCell = format(CELL.getName(), MIN_YEAR - 1); - minMaxDatepicker.show(); - minMaxDatepicker.expand(); - container.openYearsView(); - assertTrue(container.disabled(PREVIOUS_TWENTY_YEARS.getName(), NEXT_TWENTY_YEARS.getName(), - firstDisabledYearCell, secondDisabledYearCell)); - } - - @Test - public void disabledSaturdayDaysTest() { - String[] saturdays = new String[5]; - Arrays.stream(new String[] {" 1 ", " 8 ", " 15 ", " 22 ", " 29 "}).map(d -> format(CELL.getName(), d)) - .collect(Collectors.toList()).toArray(saturdays); - filterDatepicker.show(); - filterDatepicker.setDate(LocalDate.of(2020, 8, 1)); - filterDatepicker.expand(); - assertTrue(container.disabled(saturdays)); - } - - @Test - public void disabledSundayDaysTest() { - String[] sundays = new String[4]; - Arrays.stream(new String[] {" 5 ", " 12 ", " 19 ", " 26 "}).map(d -> format(CELL.getName(), d)) - .collect(Collectors.toList()).toArray(sundays); - filterDatepicker.show(); - filterDatepicker.setDate(LocalDate.of(2020, 7, 1)); - filterDatepicker.expand(); - assertTrue(container.disabled(sundays)); - } - - @Test - public void disabledSaturdaysTest() { - filterDatepicker.show(); - filterDatepicker.setDate(LocalDate.of(2020, 3, 1)); - filterDatepicker.expand(); - assertTrue(container.disabled(container.getWeekDayNumbers(SATURDAY))); - } - - @Test - public void checkEnabledThursdaysTest() { - filterDatepicker.show(); - filterDatepicker.setDate(LocalDate.of(2020, 8, 1)); - filterDatepicker.expand(); - assertFalse(container.disabled(container.getWeekDayNumbers(THURSDAY))); - } - - @Test - public void disabledSundaysTest() { - filterDatepicker.show(); - filterDatepicker.setDate(LocalDate.of(2020, 11, 1)); - filterDatepicker.expand(); - assertTrue(container.disabled(container.getWeekDayNumbers(DatepickerNavigation.SUNDAY))); - } - - @Test - public void basicLocaleTest() { - basicDatepicker.show(); - basicDatepicker.expand(); - assertTrue(container.isSelectedLocale(Locale.US)); - - } - - @Test - public void differentLocaleTest() { - differentLocaleDatepicker.show(); - differentLocaleDatepicker.expand(); - assertTrue(container.isSelectedLocale(Locale.JAPAN)); - - } - - @Test - public void switchLocaleTest() { - differentLocaleDatepicker.show(); - differentLocaleDatepicker.switchLocale(); - differentLocaleDatepicker.expand(); - assertTrue(container.isSelectedLocale(Locale.FRANCE)); - } - -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DatepickerUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DatepickerUnitTests.java deleted file mode 100644 index 487bd61a9a..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DatepickerUnitTests.java +++ /dev/null @@ -1,448 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import java.time.LocalDate; -import java.time.Month; -import java.time.Year; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -import static com.epam.jdi.light.angular.entities.DatepickerNavigation.*; -import static com.epam.jdi.light.elements.composite.WebPage.reload; -import static com.jdiai.tools.StringUtils.format; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.DatepickerSection.*; -import static io.github.epam.angular.tests.elements.complex.datepicker.TestsDatepickerBase.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class DatepickerUnitTests extends TestsInit { - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - basicDatepicker.show(); - } - - public void reInit() { - reload(); - basicDatepicker.show(); - } - - @Test - public void checkLabelTest() { - assertEquals(basicDatepicker.labelText(), CHOOSE_A_DATE); - } - - @Test - public void checkExpandedTest() { - basicDatepicker.expand(); - assertTrue(basicDatepicker.isExpanded()); - } - - @Test - public void checkOpenByButtonTest() { - openMethodDatepicker.show(); - openMethodDatepicker.expand(); - assertTrue(openMethodDatepicker.isExpanded()); - openMethodDatepicker.collapse(); - } - - @Test - public void checkEnabledTest() { - assertTrue(basicDatepicker.isEnabled()); - } - - @Test - public void checkDisabledTest() { - completelyDisabledDatepicker.show(); - assertTrue(completelyDisabledDatepicker.isDisabled()); - } - - @Test - public void checkEnabledToggleTest() { - assertTrue(basicDatepicker.isToggleEnabled()); - } - - @Test - public void checkDisabledToggleTest() { - completelyDisabledDatepicker.show(); - assertTrue(completelyDisabledDatepicker.isToggleDisabled()); - } - - @Test - public void checkEnabledInputTest() { - completelyDisabledDatepicker.show(); - assertTrue(basicDatepicker.isInputEnabled()); - } - - @Test - public void checkDisabledInputTest() { - completelyDisabledDatepicker.show(); - assertTrue(completelyDisabledDatepicker.isInputDisabled()); - } - - @Test - public void checkCollapsedTest() { - basicDatepicker.collapse(); - assertTrue(basicDatepicker.isCollapsed()); - } - - @Test - public void checkClearTest() { - basicDatepicker.select(LocalDate.now()); - basicDatepicker.clear(); - assertTrue(basicDatepicker.isEmpty()); - } - - @Test - public void checkFocusTest() { - basicDatepicker.focus(); - assertTrue(basicDatepicker.isFocused()); - } - - @Test - public void checkSetNotValidTextTest() { - basicDatepicker.setText("2008-13-08"); - assertEquals(basicDatepicker.getText(), "2008-13-08"); - } - - @Test - public void checkInputTest() { - basicDatepicker.input("12/8/2017"); - assertEquals(basicDatepicker.value(), "12/8/2017"); - } - - @Test - public void checkSendKeysTest() { - reInit(); - basicDatepicker.sendKeys("31-DEC-1812"); - assertEquals(basicDatepicker.getValue(), "12/31/1812"); - } - - @Test - public void checkSelectDateTest() { - basicDatepicker.select(LocalDate.of(2019, 11, 1)); - assertEquals(basicDatepicker.selectedDate(), LocalDate.of(2019, 11, 1)); - } - - @Test - public void checkSelectWithLocaleDateTest() { - basicDatepicker.select(LocalDate.of(2010, 1, 18), Locale.US); - assertEquals(basicDatepicker.selectedDate(), LocalDate.of(2010, 1, 18)); - } - - @Test - public void checkSelectWithDifferentLocaleDateTest() { - differentLocaleDatepicker.show(); - differentLocaleDatepicker.switchLocale(); - differentLocaleDatepicker.select(LocalDate.of(2008, 1, 12), Locale.FRANCE); - assertEquals(differentLocaleDatepicker.selectedDate(Locale.FRANCE), LocalDate.of(2008, 1, 12)); - } - - @Test - public void checkSelectStringDateWithLocaleTest() { - basicDatepicker.select("3/24/2041", Locale.US); - assertEquals(basicDatepicker.selectedDate(), LocalDate.of(2041, 3, 24)); - } - - @Test - public void checkSelectStringDateWithDifferentLocaleTest() { - differentLocaleDatepicker.show(); - differentLocaleDatepicker.select("7/17/2040", Locale.JAPAN); - assertEquals(differentLocaleDatepicker.selectedDate(Locale.JAPAN), LocalDate.of(2040, 7, 17)); - } - - @Test - public void checkSelectStringDateFromNextRangeOfYearsTest() { - basicDatepicker.select("2/12/2044"); - assertEquals(basicDatepicker.selectedDate(), LocalDate.of(2044, 2, 12)); - } - - @Test - public void checkSelectDateFromPreviousRangeOfYearsTest() { - basicDatepicker.select(LocalDate.of(2009, 7, 18)); - assertEquals(basicDatepicker.selectedDate(), LocalDate.of(2009, 7, 18)); - } - - @Test - public void checkInputMonthTest() { - basicDatepicker.input(LocalDate.now().toString()); - assertEquals(basicDatepicker.getMonth(), LocalDate.now().getMonth()); - } - - @Test - public void checkSelectedMonthTest() { - basicDatepicker.setDate(LocalDate.of(2019, 6, 1)); - assertEquals(basicDatepicker.selectedMonth(), Month.JUNE); - } - - @Test - public void checkStartMonthTest() { - reInit(); - startDateDatepicker.show(); - assertEquals(startDateDatepicker.startMonth(), Month.JANUARY); - } - - @Test - public void checkSelectDayInPreviousMonthTest() { - reInit(); - int currentMonth = LocalDate.now().getMonth().getValue(); - int previousMonth = currentMonth == 1 ? 12 : currentMonth - 1; - basicDatepicker.selectDayInPreviousMonth(1); - assertEquals(basicDatepicker.selectedMonth().getValue(), previousMonth); - } - - @Test - public void checkSelectDayInNextMonthTest() { - reInit(); - int currentMonth = LocalDate.now().getMonth().getValue(); - int nextMonth = currentMonth == 12 ? 1 : currentMonth + 1; - basicDatepicker.selectDayInNextMonth(2); - assertEquals(basicDatepicker.selectedMonth().getValue(), nextMonth); - } - - @Test - public void checkNavigateToDayInPreviousMonthsTest() { - reInit(); - int currentMonth = LocalDate.now().getMonth().getValue(); - int previousMonth = currentMonth == 1 ? 12 : currentMonth - 1; - basicDatepicker.navigateToDayInPreviousMonths(1, 12); - assertEquals(basicDatepicker.selectedMonth().getValue(), previousMonth); - } - - @Test - public void checkNavigateToDayInNextMonthsTest() { - reInit(); - int currentMonth = LocalDate.now().getMonth().getValue(); - int monthCountLater = 3; - int monthCount = monthCountLater % 12; - int nextMonth = monthCount == 0 ? - currentMonth : - (currentMonth + monthCount) > 12 ? (currentMonth + monthCount) - 12 : currentMonth + monthCount; - basicDatepicker.navigateToDayInNextMonths(monthCountLater, 12); - assertEquals(basicDatepicker.selectedMonth().getValue(), nextMonth); - } - - @Test - public void checkInputYearTest() { - basicDatepicker.input("07-OCTOBER-2021"); - assertEquals(basicDatepicker.getYear(), Year.of(2021)); - } - - @Test - public void checkSelectedYearTest() { - basicDatepicker.setText("16-sep-2003"); - assertEquals(basicDatepicker.selectedYear(), Year.of(2003)); - } - - @Test - public void checkStartYearTest() { - startDateDatepicker.show(); - assertEquals(startDateDatepicker.startYear(), Year.of(1990)); - } - - @Test - public void checkTodayDayTest() { - assertEquals(basicDatepicker.todayDay(), LocalDate.now().getDayOfMonth()); - } - - @Test - public void checkStartDayTest() { - startDateDatepicker.show(); - assertEquals(startDateDatepicker.startDay(), 1); - } - - @Test - public void checkStartDayWithLocaleTest() { - startDateDatepicker.show(); - assertEquals(startDateDatepicker.startDay(Locale.US), 1); - } - - @Test - public void checkSetDayTest() { - basicDatepicker.setText("5/25/2005"); - assertEquals(basicDatepicker.selectedDay(), 25); - } - - @Test - public void checkSelectedDayTest() { - basicDatepicker.selectDay(14); - assertEquals(basicDatepicker.getDay(), 14); - assertEquals(basicDatepicker.selectedDay(), 14); - } - - @Test - public void checkInputValidDateValueTest() { - deserializeDatepicker.show(); - deserializeDatepicker.input("12/12/2020"); - assertTrue(deserializeDatepicker.isValid()); - } - - @Test - public void checkInputInvalidDateValueTest() { - deserializeDatepicker.show(); - deserializeDatepicker.input("13/1/2020"); - assertTrue(deserializeDatepicker.isInvalid()); - } - - @Test - public void checkEnabledPreviousMonthNavigationTest() { - String minDate = getMinDate(); - basicDatepicker.setText(minDate); - assertTrue(basicDatepicker.isEnabledNavigationElements(PREVIOUS_MONTH.getName())); - } - - @Test - public void checkDisabledPreviousMonthNavigationTest() { - String minDate = getMinDate(); - minMaxDatepicker.show(); - minMaxDatepicker.setText(minDate); - assertTrue(minMaxDatepicker.isDisabledNavigationElements(PREVIOUS_MONTH.getName())); - } - - @Test - public void checkEnabledNextMonthNavigationTest() { - String maxDate = getMaxDate(); - basicDatepicker.setText(maxDate); - assertTrue(basicDatepicker.isEnabledNavigationElements(NEXT_MONTH.getName())); - } - - @Test - public void checkDisabledNextMonthNavigationTest() { - String maxDate = getMaxDate(); - minMaxDatepicker.show(); - minMaxDatepicker.setText(maxDate); - assertTrue(minMaxDatepicker.isDisabledNavigationElements(NEXT_MONTH.getName())); - } - - @Test - public void checkEnabledYearsNavigationTest() { - basicDatepicker.openYearsView(); - assertTrue(basicDatepicker - .isEnabledNavigationElements(PREVIOUS_TWENTY_YEARS.getName(), NEXT_TWENTY_YEARS.getName())); - } - - @Test - public void checkDisabledYearsNavigationTest() { - String firstDisabledYearCell = format(CELL.getName(), MIN_YEAR - 2); - String secondDisabledYearCell = format(CELL.getName(), MIN_YEAR - 1); - minMaxDatepicker.show(); - minMaxDatepicker.clear(); - minMaxDatepicker.openYearsView(); - assertTrue(minMaxDatepicker - .isDisabledNavigationElements(PREVIOUS_TWENTY_YEARS.getName(), NEXT_TWENTY_YEARS.getName(), - firstDisabledYearCell, secondDisabledYearCell)); - } - - @Test - public void checkDisabledSaturdaysTest() { - filterDatepicker.show(); - filterDatepicker.setDate(LocalDate.of(2019, 9, 1)); - String[] disabledElemtnts = filterDatepicker.getWeekDayNumbers(SATURDAY); - assertTrue(filterDatepicker.isDisabledNavigationElements(disabledElemtnts)); - } - - @Test - public void checkDisabledSundaysTest() { - filterDatepicker.show(); - filterDatepicker.setDate(LocalDate.of(2019, 12, 1)); - assertTrue(filterDatepicker.isDisabledNavigationElements(filterDatepicker.getWeekDayNumbers(SUNDAY))); - } - - @Test - public void checkEnabledTuesdaysTest() { - filterDatepicker.show(); - filterDatepicker.setDate(LocalDate.of(2020, 8, 1)); - assertTrue(filterDatepicker.isEnabledNavigationElements(filterDatepicker.getWeekDayNumbers(TUESDAY))); - } - - @Test - public void basicLocaleTest() { - assertTrue(basicDatepicker.isSelectedLocale(Locale.US)); - } - - @Test - public void differentLocaleTest() { - reInit(); - differentLocaleDatepicker.show(); - assertTrue(differentLocaleDatepicker.isSelectedLocale(Locale.JAPAN)); - - } - - @Test - public void switchLocaleTest() { - differentLocaleDatepicker.show(); - differentLocaleDatepicker.switchLocale(); - assertTrue(differentLocaleDatepicker.isSelectedLocale(Locale.FRANCE)); - } - - @Test - public void selectFirstInputChangeEventsTest() { - reInit(); - LocalDate firstEventDate = LocalDate.of(2020, 9, 14); - List inputChangeEvents = getInputChangeEvents(firstEventDate); - inputChangeEventsDatepicker.show(); - inputChangeEventsDatepicker.select(firstEventDate); - inputChangeEventsDatepicker.select(LocalDate.of(2021, 11, 3)); - assertTrue(inputChangeEventsDatepicker.isFirstInputChangeEvents(inputChangeEvents)); - } - - @Test - public void selectLastInputChangeEventsTest() { - LocalDate lastEventDate = LocalDate.of(2020, 8, 25); - List inputChangeEvents = getInputChangeEvents(lastEventDate); - inputChangeEventsDatepicker.show(); - inputChangeEventsDatepicker.select(LocalDate.of(2019, 12, 4)); - inputChangeEventsDatepicker.select(lastEventDate); - assertTrue(inputChangeEventsDatepicker.isLastInputChangeEvents(inputChangeEvents)); - } - - @Test - public void selectLastNullInputChangeEventsTest() { - LocalDate eventDate = LocalDate.now(); - List inputChangeEvents = new ArrayList<>(Arrays.asList("input: null", "change: null")); - inputChangeEventsDatepicker.show(); - inputChangeEventsDatepicker.select(eventDate); - inputChangeEventsDatepicker.clear(); - assertTrue(inputChangeEventsDatepicker.isLastInputChangeEvents(inputChangeEvents)); - } - - @Test - public void selectLastNullChangeEventTest() { - LocalDate eventDate = LocalDate.now(); - String changeEvent = "change: null"; - inputChangeEventsDatepicker.show(); - inputChangeEventsDatepicker.select(eventDate); - inputChangeEventsDatepicker.clear(); - assertTrue(inputChangeEventsDatepicker.isLastChangeEvent(changeEvent)); - } - - @Test - public void selectLastNullInputEventTest() { - String inputEvent = "input: null"; - inputChangeEventsDatepicker.show(); - inputChangeEventsDatepicker.sendKeys("1"); - inputChangeEventsDatepicker.clear(); - assertTrue(inputChangeEventsDatepicker.isLastInputEvent(inputEvent)); - } - - @Test - public void selectLastUndefinedChangeEventTest() { - reInit(); - String changeEvent = "change: undefined"; - inputChangeEventsDatepicker.show(); - inputChangeEventsDatepicker.setText("wrong date"); - inputChangeEventsDatepicker.clear(); - assertTrue(inputChangeEventsDatepicker.isLastChangeEvent(changeEvent)); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DialogUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DialogUnitTests.java deleted file mode 100644 index 5fb8371f6e..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DialogUnitTests.java +++ /dev/null @@ -1,52 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.AngularPage.dialog; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class DialogUnitTests extends TestsInit { - @BeforeClass(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - dialog.show(); - } - - @Test - public void openedTest() { - dialog.open(); - assertTrue(dialog.isOpened()); - dialog.close(); - } - - @Test - public void closedTest() { - dialog.open(); - dialog.close(); - assertTrue(dialog.isClosed()); - } - - @Test - public void verifySendKeysToNameFormFieldTest() { - dialog.sendKeysToNameFormField("EPAM Systems"); - dialog.open(); - assertTrue(dialog.nameText("EPAM Systems")); - dialog.close(); - } - - @Test - public void verifySendKeysToAnswerFormFieldTest() { - dialog.open(); - dialog.sendKeysToAnswerFormField("Lion"); - dialog.submitAnswer(); - assertTrue(dialog.answerText("Lion")); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DividerUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DividerUnitTests.java deleted file mode 100644 index 5306fa76bd..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/DividerUnitTests.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.AngularPage.dividerSection; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class DividerUnitTests extends TestsInit { - - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void displayTest() { - assertEquals(dividerSection.dividers.size(), 2); - assertTrue(dividerSection.dividers.get(1).isDisplayed()); - assertTrue(dividerSection.dividers.get(2).isDisplayed()); - } - - @Test - public void horizontalOrientationTest() { - assertTrue(dividerSection.dividers.get(1).isHorizontal()); - assertTrue(dividerSection.dividers.get(2).isHorizontal()); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ExpansionPanelUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ExpansionPanelUnitTests.java deleted file mode 100644 index a13be3a3b9..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ExpansionPanelUnitTests.java +++ /dev/null @@ -1,174 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static com.epam.jdi.light.elements.composite.WebPage.refresh; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.ExpansionPanelSection.accordionExpansionPanel; -import static io.github.com.pages.sections.ExpansionPanelSection.basicExpansionPanel; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class ExpansionPanelUnitTests extends TestsInit { - public static final String FIRST_NAME = "First name"; - public static final String AGE = "Age"; - public static final String COUNTRY = "Country"; - public static final String DATE = "Date"; - - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - basicExpansionPanel.show(); - } - - @Test - public void displayedTest() { - assertTrue(basicExpansionPanel.isDisplayed() && accordionExpansionPanel.isDisplayed()); - } - - @Test - public void expandByIndicatorTest() { - basicExpansionPanel.expand(1); - assertTrue(basicExpansionPanel.isExpanded(1)); - } - - @Test - public void expandByIconTest() { - accordionExpansionPanel.show(); - accordionExpansionPanel.expand(2); - assertTrue(accordionExpansionPanel.isExpanded(2)); - } - - @Test - public void collapseByIndicatorTest() { - basicExpansionPanel.expand(2); - basicExpansionPanel.collapse(2); - assertTrue(basicExpansionPanel.isCollapsed(2)); - } - - @Test - public void collapseByIconTest() { - accordionExpansionPanel.show(); - accordionExpansionPanel.expand(3); - accordionExpansionPanel.collapse(3); - assertTrue(accordionExpansionPanel.isCollapsed(3)); - } - - @Test - public void expandCollapseByIndicatorTest() { - basicExpansionPanel.expand(2); - basicExpansionPanel.expand(1); - assertTrue(basicExpansionPanel.isExpanded(1) && basicExpansionPanel.isCollapsed(2)); - } - - @Test - public void expandCollapseByIconTest() { - accordionExpansionPanel.show(); - accordionExpansionPanel.expand(2); - accordionExpansionPanel.expand(1); - accordionExpansionPanel.expand(3); - assertTrue(accordionExpansionPanel.isExpanded(3) && accordionExpansionPanel.isCollapsed(1) - && accordionExpansionPanel.isCollapsed(2)); - } - - @Test - public void nextTest() { - accordionExpansionPanel.show(); - accordionExpansionPanel.expand(1); - accordionExpansionPanel.next("Personal data"); - accordionExpansionPanel.next("Destination"); - assertTrue(accordionExpansionPanel.isExpanded(3) && accordionExpansionPanel.isCollapsed(1) - && accordionExpansionPanel.isCollapsed(2)); - } - - @Test - public void previousTest() { - accordionExpansionPanel.show(); - accordionExpansionPanel.expand(3); - accordionExpansionPanel.previous("Day of the trip"); - accordionExpansionPanel.previous("Destination"); - assertTrue(accordionExpansionPanel.isExpanded(1) && accordionExpansionPanel.isCollapsed(2) - && accordionExpansionPanel.isCollapsed(3)); - } - - @Test - public void endTest() { - accordionExpansionPanel.show(); - accordionExpansionPanel.expand(3); - accordionExpansionPanel.end("Day of the trip"); - assertTrue(accordionExpansionPanel.isCollapsed(1) && accordionExpansionPanel.isCollapsed(2) - && accordionExpansionPanel.isCollapsed(3)); - } - - @Test - public void inputTest() { - String expectedName = "Ihar"; - String expectedAge = "45"; - basicExpansionPanel.expand(1); - basicExpansionPanel.clear(FIRST_NAME); - basicExpansionPanel.clear(AGE); - basicExpansionPanel.input(FIRST_NAME, expectedName); - basicExpansionPanel.input(AGE, expectedAge); - assertTrue((expectedName.equalsIgnoreCase(basicExpansionPanel.value(FIRST_NAME)) && expectedAge - .equalsIgnoreCase(basicExpansionPanel.value(AGE)))); - } - - @Test - public void multiInputTest() { - String expectedName = "Alexander"; - String expectedAge = "66"; - String expectedDestination = "Netherlands"; - String expectedDate = "9/30/2020"; - accordionExpansionPanel.show(); - accordionExpansionPanel.expand(1); - accordionExpansionPanel.clear(FIRST_NAME); - accordionExpansionPanel.clear(AGE); - accordionExpansionPanel.input(FIRST_NAME, expectedName); - accordionExpansionPanel.input(AGE, expectedAge); - accordionExpansionPanel.expand(2); - accordionExpansionPanel.clear(COUNTRY); - accordionExpansionPanel.input(COUNTRY, expectedDestination); - accordionExpansionPanel.expand(3); - accordionExpansionPanel.input(DATE, expectedDate); - accordionExpansionPanel.expand(1); - assertTrue((expectedName.equalsIgnoreCase(accordionExpansionPanel.value(FIRST_NAME)) && expectedAge - .equalsIgnoreCase(accordionExpansionPanel.value(AGE)))); - accordionExpansionPanel.expand(2); - assertEquals(accordionExpansionPanel.value(COUNTRY), expectedDestination); - accordionExpansionPanel.expand(3); - assertEquals(accordionExpansionPanel.value(DATE), expectedDate); - } - - @Test - public void titleTest() { - assertEquals(basicExpansionPanel.title(1), "Personal data"); - assertEquals(basicExpansionPanel.title(2), "Self aware panel"); - } - - @Test - public void descriptionTest() { - refresh(); - basicExpansionPanel.show(); - assertEquals(basicExpansionPanel.description(1), "Type your name and age"); - assertEquals(basicExpansionPanel.description(2), "Currently I am closed"); - } - - @Test - public void variableDescriptionTest() { - basicExpansionPanel.expand(2); - assertEquals(basicExpansionPanel.description(2), "Currently I am open"); - } - - @Test - public void contentTest() { - basicExpansionPanel.expand(2); - assertEquals(basicExpansionPanel.content(2), "I'm visible because I am open"); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/FormFieldUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/FormFieldUnitTests.java deleted file mode 100644 index acce8ee3b8..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/FormFieldUnitTests.java +++ /dev/null @@ -1,86 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.FormFieldsSection.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertEquals; - -// TODO Move to the new page -@Ignore -public class FormFieldUnitTests extends TestsInit { - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void getInputsTest() { - assertEquals(simpleFormFieldInput.getInputs().size(), 1); - assertEquals(formFieldWithLabelInputSimplePlaceholder.getInputs().size(), 2); - assertEquals(formFieldEmailInput.getInputs().size(), 1); - assertEquals(formFieldExampleContainerInputLimited.getInputs().size(), 1); - } - - @Test - public void getTextAreasTest() { - assertEquals(simpleFormFieldInput.getTextAreas().size(), 1); - } - - @Test - public void getDropdownsTest() { - assertEquals(simpleFormFieldInput.getDropdowns().size(), 1); - assertEquals(formFieldWithLabelInputSimplePlaceholder.getDropdowns().size(), 1); - assertEquals(formFieldExampleContainerInputLimited.getDropdowns().size(), 1); - } - - @Test - public void setInputsTest() { - simpleFormFieldInput.input(1, "Fancy test input"); - assertEquals(simpleFormFieldInput.inputText(1), "Fancy test input"); - simpleFormFieldInput.clearInput(1); - assertEquals(simpleFormFieldInput.inputText(1), ""); - } - - @Test - public void setTextAreaTest() { - simpleFormFieldInput.setTextArea(1, "Fancy text area value"); - assertEquals(simpleFormFieldInput.textAreaText(1), "Fancy text area value"); - simpleFormFieldInput.clearTextArea(1); - assertEquals(simpleFormFieldInput.textAreaText(1), ""); - } - - @Test - public void setDropdownTest() { - modifiedLayoutFormFieldColor.select(1, "Warn"); - assertEquals(modifiedLayoutFormFieldColor.getDropdownValue(1), "Warn"); - } - - @Test - public void setValuesTest() { - simpleFormFieldInput.set(1, "Fancy input value"); - assertEquals(simpleFormFieldInput.value(1), "Fancy input value"); - simpleFormFieldInput.set(2, "Option"); - assertEquals(simpleFormFieldInput.value(2), "Option"); - simpleFormFieldInput.set(3, "Fancy text area value"); - assertEquals(simpleFormFieldInput.value(3), "Fancy text area value"); - } - - @Test - public void getPlaceHolderValueTest() { - assertEquals(formFieldWithLabelInputSimplePlaceholder.placeholder(1), "Simple placeholder"); - assertEquals(formFieldWithLabelInputSimplePlaceholder.placeholder(2), "Simple placeholder"); - } - - @Test - public void errorInputTest() { - formFieldEmailInput.input(1, "test@"); - formFieldEmailInput.focusOut(); - assertEquals(formFieldEmailInput.error(1), "Not a valid email"); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/MaterialSelectorContainerUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/MaterialSelectorContainerUnitTests.java deleted file mode 100644 index 05f48fe799..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/MaterialSelectorContainerUnitTests.java +++ /dev/null @@ -1,128 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import com.epam.jdi.light.angular.elements.composite.MaterialSelectorContainer; -import com.epam.jdi.light.elements.complex.WebList; -import io.github.epam.TestsInit; -import org.openqa.selenium.By; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import java.util.Arrays; - -import static com.epam.jdi.light.settings.JDISettings.ELEMENT; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.SelectSection.*; -import static io.github.epam.angular.tests.elements.complex.select.TestsSelectBase.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class MaterialSelectorContainerUnitTests extends TestsInit { - private MaterialSelectorContainer container; - private String[] multiOptions = new String[3]; - - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - container = new MaterialSelectorContainer(); - } - - @Test - public void listSizeTest() { - assertEquals(container.list().size(), new WebList(By.cssSelector("mat-option span")).size()); - } - - @Test - public void listHtmlTest() { - WebList webList = new WebList(By.cssSelector("mat-option span")); - for (int i = 1; i <= container.list().size(); i++) { - assertEquals(container.list().get(i).printHtml(), webList.get(i).printHtml()); - } - } - - @Test - public void selectByValueTest() { - basicMatSelect.show(); - basicMatSelect.expand(); - container.select(TACOS); - assertTrue(basicMatSelect.selected(TACOS)); - } - - @Test - public void selectByIndexTest() { - basicMatSelect.show(); - basicMatSelect.expand(); - container.select(ELEMENT.startIndex); - assertTrue(basicMatSelect.selected(STEAK)); - } - - @Test(enabled = false) - // duplicated. Page should be reload for this test, skip to increase performance - public void multipleSelectByValuesTest() { - multipleSelect.show(); - multipleSelect.expand(); - multiOptions[0] = MUSHROOM; - multiOptions[1] = PEPPERONI; - multiOptions[2] = TOMATO; - container.multipleSelect(multiOptions); - assertTrue(multipleSelect.selected(multiOptions[0] + ", " + multiOptions[1] + ", " + multiOptions[2])); - } - - @Test - public void multipleSelectByIndexesTest() { - multipleSelect.show(); - multipleSelect.expand(); - int[] multiSelect = new int[] {1, 3, 5}; - container.multipleSelect(multiSelect); - assertTrue(multipleSelect.selected(EXTRA_CHEESE + ", " + ONION + ", " + SAUSAGE)); - } - - @Test - public void valuesTest() { - basicMatSelect.show(); - basicMatSelect.expand(); - assertEquals(container.values(), Arrays.asList(STEAK, PIZZA, TACOS)); - } - - @Test - public void getGroupsTest() { - optionGroupsMatSelect.show(); - optionGroupsMatSelect.expand(); - assertEquals(container.getGroups(), Arrays.asList(GRASS, WATER, FIRE, PSYCHIC)); - } - - @Test - public void getMapGroupsAndOptionsTest() { - optionGroupsMatSelect.show(); - optionGroupsMatSelect.expand(); - assertEquals(container.getMapGroupsAndOptions(), getPokemonsMap()); - } - - @Test - public void listEnabledTest() { - optionGroupsMatSelect.show(); - optionGroupsMatSelect.expand(); - assertEquals(container.listEnabled(), - Arrays.asList("-- None --", BULBASAUR, ODDISH, BELLSPROUT, SQUIRTLE, PSYDUCK, HORSEA, MEW, - MEWTWO)); - } - - @Test - public void listDisabledTest() { - optionGroupsMatSelect.show(); - optionGroupsMatSelect.expand(); - assertEquals(container.listDisabled(), Arrays.asList(CHARMANDER, VULPIX, FLAREON)); - } - - @Test - public void colorTest() { - customPanelStylingSelect.show(); - customPanelStylingSelect.select(RED); - customPanelStylingSelect.expand(); - assertTrue(container.color(255, 0, 0, 0.5)); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/MaterialSelectorUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/MaterialSelectorUnitTests.java deleted file mode 100644 index 57743e0f2c..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/MaterialSelectorUnitTests.java +++ /dev/null @@ -1,128 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.SelectSection.*; -import static io.github.epam.angular.tests.elements.complex.select.TestsSelectBase.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static java.util.Arrays.asList; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class MaterialSelectorUnitTests extends TestsInit { - private final String[] multiOptions = new String[3]; - - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void expandedTest() { - basicMatSelect.show(); - basicMatSelect.expand(); - assertTrue(basicMatSelect.isExpanded()); - basicMatSelect.collapse(); - assertTrue(basicMatSelect.isCollapsed()); - } - - @Test - public void collapsedTest() { - basicMatSelect.show(); - basicMatSelect.collapse(); - assertTrue(basicMatSelect.isCollapsed()); - } - - @Test - public void selectByValueTest() { - basicMatSelect.show(); - basicMatSelect.select(PIZZA); - assertEquals(basicMatSelect.selected(), PIZZA); - } - - @Test - public void selectByIndexTest() { - basicMatSelect.show(); - basicMatSelect.select(TACOS); - assertTrue(basicMatSelect.selected(TACOS)); - } - - @Test - public void multipleSelectByValuesTest() { - multipleSelect.show(); - multiOptions[0] = MUSHROOM; - multiOptions[1] = PEPPERONI; - multiOptions[2] = SAUSAGE; - multipleSelect.multipleSelect(multiOptions); - assertEquals(multipleSelect.selected(), multiOptions[0] + ", " + multiOptions[1] + ", " + multiOptions[2]); - } - - @Test(enabled = false) - // duplicated. Page should be reload for this test, skip to increase performance - public void multipleSelectByIndexesTest() { - multipleSelect.show(); - int[] multiSelect = new int[] {2, 4, 6}; - multipleSelect.multipleSelect(multiSelect); - assertEquals(multipleSelect.selected(), MUSHROOM + ", " + PEPPERONI + ", " + TOMATO); - } - - @Test - public void valuesTest() { - multipleSelect.show(); - assertEquals(basicMatSelect.values(), asList(STEAK, PIZZA, TACOS)); - } - - @Test - public void getGroupsTest() { - optionGroupsMatSelect.show(); - assertEquals(optionGroupsMatSelect.groups(), asList(GRASS, WATER, FIRE, PSYCHIC)); - } - - @Test - public void getGroupsAndOptionsTest() { - optionGroupsMatSelect.show(); - assertEquals(optionGroupsMatSelect.groupsAndOptions(), getPokemonsMap()); - } - - @Test - public void listEnabledTest() { - optionGroupsMatSelect.show(); - assertEquals(optionGroupsMatSelect.listEnabled(), - asList("-- None --", BULBASAUR, ODDISH, BELLSPROUT, SQUIRTLE, PSYDUCK, HORSEA, MEW, MEWTWO)); - } - - @Test - public void listDisabledTest() { - optionGroupsMatSelect.show(); - assertEquals(optionGroupsMatSelect.listDisabled(), asList(CHARMANDER, VULPIX, FLAREON)); - } - - @Test - public void colorTest() { - customPanelStylingSelect.show(); - customPanelStylingSelect.select(RED); - assertTrue(customPanelStylingSelect.color(255, 0, 0, 0.5)); - } - - @Test - public void hintTest() { - matErrorStateMatcherSelect.show(); - matErrorStateMatcherSelect.select(VALID_OPTION); - assertEquals(matErrorStateMatcherSelect.hint().text(), "Errors appear instantly!"); - } - - @Test - public void errorTest() { - matErrorStateMatcherSelect.show(); - matErrorStateMatcherSelect.select(INVALID_OPTION); - assertEquals(matErrorStateMatcherSelect.error().text(), INVALID_SELECTION); - } - -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/MenuUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/MenuUnitTests.java deleted file mode 100644 index 85ed07e93a..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/MenuUnitTests.java +++ /dev/null @@ -1,75 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import java.util.Arrays; - -import static com.epam.jdi.light.angular.elements.complex.NestedDropdownMenu.*; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.MenuSection.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class MenuUnitTests extends TestsInit { - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void displayedTest() { - basicMenuButton.show(); - assertTrue(basicMenuButton.isDisplayed()); - } - - @Test - public void expandTest() { - basicMenuButton.show(); - basicMenuButton.expand(); - assertTrue(basicMenuButton.isExpanded()); - } - - @Test - public void closedTest() { - basicMenuButton.show(); - basicMenuButton.expand(); - basicMenuButton.close(); - assertTrue(basicMenuButton.isClosed()); - } - - @Test - public void selectByValueTest() { - basicMenuButton.show(); - basicMenuButton.expand(); - basicMenuButton.select("Item 1"); - assertEquals(basicMenuSelectedOption.getText(), "Item 1"); - } - - @Test - public void valuesTestForNestedMenu() { - nestedMenuButton.show(); - assertEquals(nestedMenuButton.valuesForNestedMenu(), Arrays.asList(NESTED_MENU_VALUES)); - nestedMenuButton.close(); - } - - @Test - public void valuesForMenuWithIconsTest() { - menuWithIconsButton.show(); - assertEquals(menuWithIconsButton.valuesForMenuWithIcons(), Arrays.asList(MENU_WITH_ICONS_VALUES)); - menuWithIconsButton.close(); - } - - @Test(enabled = false) - // failed in CI - public void valuesTest() { - basicMenuButton.show(); - assertEquals(basicMenuButton.values(), Arrays.asList(BASIC_MENU_VALUES)); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/NativeSelectorUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/NativeSelectorUnitTests.java deleted file mode 100644 index 7ba128df6d..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/NativeSelectorUnitTests.java +++ /dev/null @@ -1,94 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import com.epam.jdi.light.common.TextTypes; -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import java.util.Arrays; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.SelectSection.*; -import static io.github.epam.angular.tests.elements.complex.select.TestsSelectBase.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.Matchers.hasSize; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class NativeSelectorUnitTests extends TestsInit { - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void listTest() { - assertThat(basicNativeSelect.list(), hasSize(4)); - assertThat(basicNativeSelect.list().values(), hasItems(VOLVO, SAAB, MERCEDES, AUDI)); - } - - @Test - public void selectByValueTest() { - basicNativeSelect.show(); - basicNativeSelect.select(VOLVO); - assertEquals(basicNativeSelect.selected(), VOLVO); - } - - @Test - public void selectByIndexTest() { - basicNativeSelect.show(); - basicNativeSelect.select(SAAB); - assertTrue(basicNativeSelect.selected(SAAB)); - } - - @Test - public void valuesTest() { - assertEquals(basicNativeSelect.values(), Arrays.asList(VOLVO, SAAB, MERCEDES, AUDI)); - } - - @Test - public void valuesByTextTypeTest() { - assertEquals(basicNativeSelect.values(TextTypes.TEXT), Arrays.asList(VOLVO, SAAB, MERCEDES, AUDI)); - } - - @Test - public void getGroupsTest() { - assertEquals(optionGroupsNativeSelect.groups(), Arrays.asList(SWEDISH_CARS, GERMAN_CARS)); - } - - @Test - public void getGroupsAndOptionsTest() { - assertEquals(optionGroupsNativeSelect.groupsAndOptions(), getCarsMap()); - } - - @Test - public void listEnabledTest() { - assertEquals(disableNativeSelect.listEnabled(), Arrays.asList(VOLVO, MERCEDES, AUDI)); - } - - @Test - public void listDisabledTest() { - assertEquals(disableNativeSelect.listDisabled(), Arrays.asList("", SAAB)); - } - - @Test - public void hintTest() { - formNativeFeatureSelect.show(); - formNativeFeatureSelect.select(MERCEDES); - formNativeFeatureSelect.waitFor().attr(ARIA_INVALID, "false"); - assertEquals(formNativeFeatureSelect.hint().text(), "You can pick up your favorite car here"); - } - - @Test - public void errorTest() { - nativeErrorStateMatcherSelect.show(); - nativeErrorStateMatcherSelect.select(""); - assertEquals(nativeErrorStateMatcherSelect.error().text(), MUST_MAKE_SELECTION); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/PaginatorUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/PaginatorUnitTests.java deleted file mode 100644 index a84c03e80f..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/PaginatorUnitTests.java +++ /dev/null @@ -1,92 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.openqa.selenium.Dimension; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import static com.epam.jdi.light.driver.WebDriverFactory.getDriver; -import static com.jdiai.tools.StringUtils.format; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.PaginatorSection.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.*; - -// TODO Move to the new page -@Ignore -public class PaginatorUnitTests extends TestsInit { - - @BeforeMethod - public void before() { - getDriver().manage().window().setSize(new Dimension(1920, 1080)); - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void verifyLabelTest() { - assertEquals(paginator.label(), "Items per page:"); - } - - @Test - public void verifyItemsPerPageListTest() { - final List optionList = Arrays.asList(-1, 0, 1, 5, 10, 25, 100); - final String options = optionList - .stream() - .map(String::valueOf) - .collect(Collectors.joining(",")); - pageSizeOptions.setValue(options); - - assertEquals(optionList, paginator.options()); - } - - @Test - public void verifyItemsPerPageSelectedTest() { - final int option = 5; - paginator.select(option); - - assertEquals(paginator.selected(), option); - } - - @Test - public void verifyNavigationTest() { - listLength.setValue("75"); - paginator.select(25); - - assertFalse(paginator.isPreviousEnabled()); - assertTrue(paginator.isNextEnabled()); - - paginator.next(); - assertTrue(paginator.isPreviousEnabled()); - assertTrue(paginator.isNextEnabled()); - - paginator.next(); - assertTrue(paginator.isPreviousEnabled()); - assertFalse(paginator.isNextEnabled()); - } - - @Test - public void verifyEmptyRangeTest() { - listLength.setValue("0"); - - assertEquals(paginator.range(), "0 of 0"); - } - - @Test - public void verifyRangeTest() { - final String TOTAL = "50"; - final int STEP = 25; - - listLength.setValue(TOTAL); - paginator.select(100); - paginator.select(STEP); - - String expected = format("1 – %d of %s", STEP, TOTAL); - assertEquals(paginator.range(), expected); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ProgressBarUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ProgressBarUnitTests.java deleted file mode 100644 index e3fdfc0ae0..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/ProgressBarUnitTests.java +++ /dev/null @@ -1,115 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import static com.epam.jdi.light.angular.elements.enums.ProgressBarModes.BUFFER; -import static com.epam.jdi.light.angular.elements.enums.ProgressBarModes.DETERMINATE; -import static com.epam.jdi.light.angular.elements.enums.ProgressBarModes.INDETERMINATE; -import static com.epam.jdi.light.angular.elements.enums.ProgressBarModes.QUERY; -import static com.epam.jdi.light.elements.composite.WebPage.refresh; -import static com.jdiai.tools.Timer.waitCondition; -import static io.github.com.StaticSite.progressBarPage; -import static io.github.com.pages.ProgressBarPage.matProgressBarBuffer; -import static io.github.com.pages.ProgressBarPage.matProgressBarConfigurable; -import static io.github.com.pages.ProgressBarPage.matProgressBarDeterminate; -import static io.github.com.pages.ProgressBarPage.matProgressBarIndeterminate; -import static io.github.com.pages.ProgressBarPage.matProgressBarQuery; -import static io.github.com.pages.ProgressBarPage.showBufferProgressBarButton; -import static io.github.com.pages.ProgressBarPage.showIndeterminateProgressBarButton; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -public class ProgressBarUnitTests extends TestsInit { - @BeforeMethod - public void before() { - progressBarPage.open(); - waitCondition(() -> progressBarPage.isOpened()); - progressBarPage.checkOpened(); - } - - @Test(description = "Unit test checks whether element is displayed") - public void isDisplayedTest() { - assertTrue(matProgressBarDeterminate.isDisplayed()); - assertTrue(matProgressBarQuery.isDisplayed()); - showIndeterminateProgressBarButton.click(); - assertTrue(matProgressBarIndeterminate.isDisplayed()); - showBufferProgressBarButton.click(); - assertTrue(matProgressBarBuffer.isDisplayed()); - assertTrue(matProgressBarConfigurable.isDisplayed()); - } - - @Test(description = "Unit test checks whether element is visible") - public void isVisibleTest() { - matProgressBarDeterminate.show(); - assertTrue(matProgressBarDeterminate.isVisible()); - showIndeterminateProgressBarButton.click(); - assertTrue(matProgressBarIndeterminate.isVisible()); - showBufferProgressBarButton.click(); - assertTrue(matProgressBarBuffer.isVisible()); - matProgressBarQuery.show(); - assertTrue(matProgressBarQuery.isVisible()); - matProgressBarConfigurable.show(); - assertTrue(matProgressBarConfigurable.isVisible()); - } - - @Test(description = "Unit test checks that after stated period of time element becomes hidden") - public void verifyDisappearTest() { - refresh(); - assertFalse(matProgressBarIndeterminate.isDisplayed()); - showIndeterminateProgressBarButton.click(); - assertTrue(matProgressBarIndeterminate.isDisplayed()); - matProgressBarIndeterminate.is().disappear(5); - assertTrue(matProgressBarIndeterminate.isHidden()); - showBufferProgressBarButton.click(); - assertTrue(matProgressBarBuffer.isDisplayed()); - matProgressBarBuffer.is().disappear(5); - assertTrue(matProgressBarBuffer.isHidden()); - } - - @Test(description = "Unit test checks progress bar modes: DETERMINATE, INDETERMINATE, QUERY, BUFFER") - public void verifyModesTest() { - assertEquals(matProgressBarDeterminate.mode(), DETERMINATE.getMode()); - assertEquals(matProgressBarQuery.mode(), QUERY.getMode()); - showIndeterminateProgressBarButton.click(); - assertEquals(matProgressBarIndeterminate.mode(), INDETERMINATE.getMode()); - showBufferProgressBarButton.click(); - assertEquals(matProgressBarBuffer.mode(), BUFFER.getMode()); - assertEquals(matProgressBarConfigurable.mode(), DETERMINATE.getMode()); - } - - @Test(description = "Unit test checks progress bar values") - public void verifyValuesTest() throws Exception { - assertEquals(matProgressBarDeterminate.value(), 40); - showBufferProgressBarButton.click(); - assertEquals(matProgressBarBuffer.bufferValue(), 0); - assertEquals(matProgressBarBuffer.value(), 0); - assertEquals(matProgressBarConfigurable.value(), 50); - } - - @Test(description = "Unit test checks progress bar MIN values") - public void verifyMinValuesTest() { - assertEquals(matProgressBarDeterminate.min(), 0); - showBufferProgressBarButton.click(); - assertEquals(matProgressBarBuffer.min(), 0); - assertEquals(matProgressBarBuffer.min(), 0); - showIndeterminateProgressBarButton.click(); - assertEquals(matProgressBarIndeterminate.min(), 0); - assertEquals(matProgressBarQuery.min(), 0); - assertEquals(matProgressBarConfigurable.min(), 0); - } - - @Test(description = "Unit test checks progress bar MAX values") - public void verifyMaxValuesTest() { - assertEquals(matProgressBarDeterminate.max(), 100); - showBufferProgressBarButton.click(); - assertEquals(matProgressBarBuffer.max(), 100); - assertEquals(matProgressBarBuffer.max(), 100); - showIndeterminateProgressBarButton.click(); - assertEquals(matProgressBarIndeterminate.max(), 100); - assertEquals(matProgressBarQuery.max(), 100); - assertEquals(matProgressBarConfigurable.max(), 100); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/RadioButtonsUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/RadioButtonsUnitTests.java deleted file mode 100644 index 19c2ac14d0..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/RadioButtonsUnitTests.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.RadioButtonSection.seasonRadioGroup; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.AssertJUnit.assertTrue; - -// TODO Move to the new page -@Ignore -public class RadioButtonsUnitTests extends TestsInit { - - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void clickRadioButtonByValue() { - seasonRadioGroup.click("Spring"); - assertTrue(seasonRadioGroup.isChecked("Spring")); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/RippleUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/RippleUnitTests.java deleted file mode 100644 index abaf8b3d73..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/RippleUnitTests.java +++ /dev/null @@ -1,135 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.apache.commons.lang3.RandomUtils; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static com.epam.jdi.light.elements.composite.WebPage.refresh; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.AngularPage.rippleContainer; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.*; - -// TODO Move to the new page -@Ignore -public class RippleUnitTests extends TestsInit { - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - rippleContainer.show(); - } - - @Test - public void displayedTest() { - assertTrue(rippleContainer.isDisplayed()); - } - - @Test - public void disabledTest() { - rippleContainer.disable(); - assertTrue(rippleContainer.isDisabled()); - rippleContainer.enable(); - assertTrue(rippleContainer.isEnabled()); - } - - @Test - public void unboundedTest() { - rippleContainer.unbound(); - assertTrue(rippleContainer.isUnbounded()); - } - - @Test - public void centeredTest() { - rippleContainer.center(); - assertTrue(rippleContainer.isCentered()); - } - - @Test - public void rippleActionTest() { - rippleContainer.ripple(); - assertTrue(rippleContainer.isActive()); - } - - @Test - public void radiusTest() { - int expectedRadius = 200; - rippleContainer.setRadius(expectedRadius); - assertTrue(rippleContainer.isRadius(expectedRadius)); - } - - @Test - public void rippleRadiusTest() { - int expectedRadius = 195; - rippleContainer.setRadius(expectedRadius); - assertEquals(rippleContainer.radius(), expectedRadius, "The radius has an incorrect value"); - } - - @Test - public void rippleCorrectRadiusTest() { - rippleContainer.setRadius(0); - assertTrue(rippleContainer.isCorrectRadius()); - } - - @Test - public void rippleNotCorrectRadiusTest() { - rippleContainer.setRadius(-1); - assertFalse(rippleContainer.isCorrectRadius()); - } - - @Test - public void colorTest() { - String expectedColor = "Green"; - rippleContainer.setColor(expectedColor); - assertTrue(rippleContainer.isColor(expectedColor.toLowerCase())); - } - - @Test - public void rippleCorrectColorTest() { - rippleContainer.setColor("rgba(0, 0, 0)"); - assertTrue(rippleContainer.isCorrectColor()); - } - - @Test - public void rippleNotCorrectColorTest() { - rippleContainer.setColor("custom color"); - assertFalse(rippleContainer.isCorrectColor()); - } - - @Test - public void rippleColorTest() { - String expectedColor = "AqUaMaRiNe"; - rippleContainer.setColor(expectedColor); - assertEquals(rippleContainer.color(), expectedColor.toLowerCase(), "The color has an incorrect value"); - } - - @Test - public void rippleRgbaColorTest() { - String expectedColor = "rgba(200, 100, 50, 0.5)"; - rippleContainer.setColor(expectedColor); - assertEquals(rippleContainer.color(), expectedColor, "The color has an incorrect value"); - } - - @Test - public void mouseClickCenteredTest() { - refresh(); - rippleContainer.center(); - int x = 179; - int y = 243; - rippleContainer.ripple(x, y); - assertTrue(rippleContainer.isCentered()); - } - - @Test(enabled = false) - public void randomMouseClickTest() { - refresh(); - rippleContainer.show(); - rippleContainer.center(); - int x = RandomUtils.nextInt(0, 299); - int y = RandomUtils.nextInt(0, 299); - rippleContainer.ripple(x, y); - assertTrue(rippleContainer.isRippleCenter(x, y)); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SideNavUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SideNavUnitTests.java deleted file mode 100644 index ee114254bc..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SideNavUnitTests.java +++ /dev/null @@ -1,70 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.SideNavSection.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertEquals; - -// TODO Move to the new page -@Ignore -public class SideNavUnitTests extends TestsInit { - - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void getSideNavTest() { - assertEquals(implicitMainContent.getSideNav("End").getText(), "End content"); - } - - @Test - public void getContentTest() { - assertEquals(implicitMainContent.getContent().getText(), "Implicit main content"); - } - - // failed in CI - @Test(enabled = false) - public void getEventsTest() { - sideNavToggle.show(); - sideNavToggle.click(); - openCloseBehavior.base().timer().wait(() -> openCloseBehavior.isEnabled()); - assertEquals(openCloseBehavior.getEvents().getText(), "open!"); - } - - @Test - public void getSideNavLinksTest() { - responsiveContent.show(); - if (responsiveContent.getSideNav().isNotDisplayed()) { - toolbarToggle.click(); - } - assertEquals(responsiveContent.getSideNavLinks().get(1).getText(), "Nav Item 1"); - } - - @Test - public void getResponsiveResultsTest() { - responsiveContent.show(); - if (responsiveContent.getSideNav().isNotDisplayed()) { - toolbarToggle.click(); - } - responsiveContent.getSideNavLinks().get(1).click(); - assertEquals(responsiveContent.getResponsiveResults().get(1).getText(), "Selected Nav Item 1"); - } - - @Test - public void getMatDrawerTest() { - assertEquals(basicDrawer.getMatDrawer().getText(), "Drawer content"); - } - - @Test - public void getMatDrawerContentTest() { - assertEquals(basicDrawer.getMatDrawerContent().getText(), "Main content"); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SlideToggleUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SlideToggleUnitTests.java deleted file mode 100644 index d2a0c414b9..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SlideToggleUnitTests.java +++ /dev/null @@ -1,54 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.SlideToggleSection.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class SlideToggleUnitTests extends TestsInit { - - @BeforeMethod - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void checkTest() { - basicSlideToggle.check(); - assertTrue(basicSlideToggle.isSelected()); - } - - @Test - public void uncheckTest() { - basicSlideToggle.uncheck(); - assertFalse(basicSlideToggle.isSelected()); - } - - @Test - public void clickTest() { - assertTrue(basicSlideToggle.isSelected()); - basicSlideToggle.click(); - assertFalse(basicSlideToggle.isSelected()); - } - - @Test - public void testEnabledOption() { - disableCheckbox.uncheck(); - assertTrue(resultSlideToggle.isEnabled()); - } - - @Test - public void testDisabledOption() { - disableCheckbox.check(); - assertTrue(resultSlideToggle.isDisabled()); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SliderUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SliderUnitTests.java deleted file mode 100644 index c101eecf13..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SliderUnitTests.java +++ /dev/null @@ -1,113 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.SliderSection.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.*; - -// TODO Move to the new page -@Ignore -public class SliderUnitTests extends TestsInit { - @BeforeMethod - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - matSliderBasic.setupValue(0.0); - matSliderFormatting.setupValue(1.0); - sliderConfigurableMin.setValue("0"); - sliderConfigurableMax.setValue("100"); - sliderConfigurableStep.setValue("1"); - } - - @Test - public void isDisplayedTest() { - assertTrue(matSliderBasic.isDisplayed()); - assertTrue(matSliderFormatting.isDisplayed()); - assertTrue(matSliderConfigurable.isDisplayed()); - } - - @Test - public void isVisibleTest() { - matSliderBasic.show(); - assertTrue(matSliderBasic.isVisible()); - matSliderFormatting.show(); - assertTrue(matSliderFormatting.isVisible()); - matSliderConfigurable.show(); - assertTrue(matSliderConfigurable.isVisible()); - } - - @Test - public void getSlidersValueTest() { - assertEquals(matSliderBasic.value(), 0.0); - assertEquals(matSliderFormatting.value(), 1.0); - assertEquals(matSliderConfigurable.value(), 0.0); - } - - @Test - public void getSlidersExtremeValuesTest() { - assertEquals(matSliderBasic.min(), 0.0); - assertEquals(matSliderFormatting.min(), 1.0); - assertEquals(matSliderConfigurable.min(), 0.0); - - assertEquals(matSliderBasic.max(), 100.0); - assertEquals(matSliderFormatting.max(), 100000.0); - assertEquals(matSliderConfigurable.max(), 100.0); - } - - @Test - public void setDoubleValueToSliderTest() { - matSliderBasic.setupValue(45.0); - assertEquals(matSliderBasic.value(), 45.0); - - matSliderFormatting.setupValue(4353.8); - assertEquals(matSliderFormatting.value(), 4353.8); - - matSliderConfigurable.setupValue(34.5); - assertEquals(matSliderConfigurable.value(), 34.5); - } - - @Test - public void setIntValueToSliderTest() { - matSliderBasic.setupValue(45); - assertEquals(matSliderBasic.value(), 45.0); - - matSliderFormatting.setupValue(4353); - assertEquals(matSliderFormatting.value(), 4353.0); - - matSliderConfigurable.setupValue(34); - assertEquals(matSliderConfigurable.value(), 34.0); - } - - @Test - public void setOrientationTest() { - matSliderConfigurable.show(); - assertEquals(matSliderConfigurable.orientation(), "horizontal"); - - sliderConfigurableVertical.check(); - assertEquals(matSliderConfigurable.orientation(), "vertical"); - - sliderConfigurableVertical.uncheck(); - assertEquals(matSliderConfigurable.orientation(), "horizontal"); - } - - @Test - public void isEnabledTest() { - assertTrue(matSliderBasic.isEnabled()); - assertTrue(matSliderFormatting.isEnabled()); - assertTrue(matSliderConfigurable.isEnabled()); - } - - @Test - public void isDisabledTest() { - sliderConfigurableDisabled.check(); - assertFalse(matSliderBasic.isDisabled()); - assertFalse(matSliderFormatting.isDisabled()); - assertTrue(matSliderConfigurable.isDisabled()); - sliderConfigurableDisabled.uncheck(); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SnackbarUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SnackbarUnitTests.java deleted file mode 100644 index 38f42c5d36..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SnackbarUnitTests.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.AngularPage.snackbarSection; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.*; - -// TODO Move to the new page -@Ignore -public class SnackbarUnitTests extends TestsInit { - - @BeforeMethod - public void before() { - shouldBeLoggedIn(); - angularPage.open(); - } - - @Test - public void correctMessageBasicTest() { - snackbarSection.openButton.click(); - assertEquals(snackbarSection.basicSnackbar.getMessageText(),"Disco party!"); - } - - @Test - public void correctActionBasicTest() { - snackbarSection.openButton.click(); - assertEquals(snackbarSection.basicSnackbar.getActionText(),"Dance"); - } - - @Test - public void visibilityActionSnackbarBasicTest() { - snackbarSection.openButton.click(); - assertTrue(snackbarSection.basicSnackbar.isActionDisplayed()); - } - - @Test - public void emptyActionSnackbarBasicTest() { - snackbarSection.actionInput.setValue(""); - snackbarSection.openButton.click(); - assertFalse(snackbarSection.basicSnackbar.isActionDisplayed()); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SortingOverviewUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SortingOverviewUnitTests.java deleted file mode 100644 index 8ff1398f0b..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/SortingOverviewUnitTests.java +++ /dev/null @@ -1,69 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.com.pages.sections.SortingOverviewSection; -import io.github.epam.TestsInit; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import static io.github.com.StaticSite.angularPage; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; - -// TODO Move to the new page -@Ignore -public class SortingOverviewUnitTests extends TestsInit { - - private static final String DESSERT = "Dessert (100g)"; - private static final String CALORIES = "Calories"; - private static final String FAT = "Fat (g)"; - private static final String CARBS = "Carbs (g)"; - private static final String PROTEIN = "Protein (g)"; - - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void verifyTableIsVisible() { - Assert.assertTrue(SortingOverviewSection.sortingOverview.getTableHeaders().isDisplayed()); - } - - @Test - public void verifyHeaderButtonDessertIsClicked() { - SortingOverviewSection.sortingOverview.clickButtonByText(DESSERT); - SortingOverviewSection.sortingOverview.clickButtonByText(DESSERT); - Assert.assertTrue(SortingOverviewSection.sortingOverview.headerButtonIsClicked()); - } - - @Test - public void verifyHeaderButtonCaloriesIsClicked() { - SortingOverviewSection.sortingOverview.clickButtonByText(CALORIES); - SortingOverviewSection.sortingOverview.clickButtonByText(CALORIES); - Assert.assertTrue(SortingOverviewSection.sortingOverview.headerButtonIsClicked()); - } - - @Test - public void verifyHeaderButtonFatIsClicked() { - SortingOverviewSection.sortingOverview.clickButtonByText(FAT); - SortingOverviewSection.sortingOverview.clickButtonByText(FAT); - Assert.assertTrue(SortingOverviewSection.sortingOverview.headerButtonIsClicked()); - } - - @Test - public void verifyHeaderButtonCarbsIsClicked() { - SortingOverviewSection.sortingOverview.clickButtonByText(CARBS); - SortingOverviewSection.sortingOverview.clickButtonByText(CARBS); - Assert.assertTrue(SortingOverviewSection.sortingOverview.headerButtonIsClicked()); - } - - @Test - public void verifyHeaderButtonProteinIsClicked() { - SortingOverviewSection.sortingOverview.clickButtonByText(PROTEIN); - SortingOverviewSection.sortingOverview.clickButtonByText(PROTEIN); - Assert.assertTrue(SortingOverviewSection.sortingOverview.headerButtonIsClicked()); - } -} - diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/TabGroupUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/TabGroupUnitTests.java deleted file mode 100644 index 1b17fd5234..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/TabGroupUnitTests.java +++ /dev/null @@ -1,94 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import java.util.Arrays; -import java.util.List; - -import static com.jdiai.tools.StringUtils.format; -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.AngularPage.tabsSection; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertTrue; - -// TODO Move to the new page -@Ignore -public class TabGroupUnitTests extends TestsInit { - - public static final String CLASS_ATTR = "class"; - public static final String ACCENT = "accent"; - public static final String PRIMARY = "primary"; - private static final List TABS_TITLES_DEFAULT_LIST = Arrays.asList("First", "Second", "Third"); - private static final List TABS_LINKS_TITLES = Arrays.asList("First", "Second", "Third", "Disabled Link"); - - @BeforeMethod(alwaysRun = true) - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - } - - @Test - public void clickTest() { - int tabNumberForTest = 3; - tabsSection.basicTab.clickTab(tabNumberForTest); - assertTrue(tabsSection.basicTab.tabIsHighlighted(tabNumberForTest)); - } - - @Test - public void clickByNameTest() { - int tabNumberForTest = 3; - String tabNameForeTest = "Third"; - tabsSection.basicTab.clickTab(tabNameForeTest); - assertTrue(tabsSection.basicTab.tabIsHighlighted(tabNumberForTest)); - } - - @Test - public void tabsTitlesContainValuesTest() { - assertTrue(tabsSection.basicTab.tabsTitlesContainValues(TABS_TITLES_DEFAULT_LIST)); - } - - @Test - public void tabIsHighlightedTest() { - int tabNumberForTest = 3; - tabsSection.basicTab.clickTab(tabNumberForTest); - assertTrue(tabsSection.basicTab.tabIsHighlighted(tabNumberForTest)); - } - - @Test - public void tabPanelContainsValueTest() { - int tabNumberForTest = 2; - String stringForTest = format("Content %s", tabNumberForTest); - tabsSection.basicTab.clickTab(tabNumberForTest); - assertTrue(tabsSection.basicTab.tabPanelContainsValue(stringForTest)); - } - - @Test - public void clickTabLinkTest() { - String tabNameForeTest = "Third"; - tabsSection.tabsNavBar.clickTabLink(tabNameForeTest); - assertTrue(tabsSection.tabsNavBar.tabWithLinkIsHighlighted(tabNameForeTest)); - } - - @Test - public void tabsLinksTitlesContainValuesTest() { - assertTrue(tabsSection.tabsNavBar.tabsLinksTitlesContainValues(TABS_LINKS_TITLES)); - } - - @Test - public void tabWithLinkIsHighlightedTest() { - String tabNameForeTest = "Third"; - tabsSection.tabsNavBar.clickTabLink(tabNameForeTest); - assertTrue(tabsSection.tabsNavBar.tabWithLinkIsHighlighted(tabNameForeTest)); - } - - @Test - public void verifyCustomThemeHighlighterColor() { - tabsSection.matButtonToggleGroupColor.clickButtonToggleByValue(ACCENT); - tabsSection.tabGroupThemeExample.has().attr(CLASS_ATTR, "mat-tab-group mat-background-primary mat-accent"); - tabsSection.matButtonToggleGroupColor.clickButtonToggleByValue(PRIMARY); - tabsSection.tabGroupThemeExample.has().attr(CLASS_ATTR, "mat-tab-group mat-background-primary mat-primary"); - } -} diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/TooltipUnitTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/TooltipUnitTests.java deleted file mode 100644 index 3295174b37..0000000000 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/unit/TooltipUnitTests.java +++ /dev/null @@ -1,65 +0,0 @@ -package io.github.epam.angular.tests.unit; - -import com.epam.jdi.light.angular.elements.common.Tooltip; -import com.epam.jdi.light.angular.elements.composite.MaterialSelectorContainer; -import io.github.com.pages.AngularPage; -import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Ignore; -import org.testng.annotations.Test; - -import java.util.HashMap; -import java.util.Map; - -import static io.github.com.StaticSite.angularPage; -import static io.github.com.pages.sections.TooltipSection.*; -import static io.github.epam.site.steps.States.shouldBeLoggedIn; -import static org.testng.Assert.assertEquals; - -// TODO Move to the new page -@Ignore -public class TooltipUnitTests extends TestsInit { - - @BeforeMethod - public void before() { - shouldBeLoggedIn(); - angularPage.shouldBeOpened(); - if (tooltip.isDisplayed()) - AngularPage.refresh(); - } - - @Test - public void textTooltipTest() { - String message = "New Test Tooltip Message"; - changeMessageTooltipTextField.setValue(message); - changeMessageTooltipButton.hover(); - assertEquals(tooltip.text(), message); - } - - @Test - public void colorTooltipTest() { - String color = "rgba(183, 28, 28, 1)"; - colorTooltipButton.hover(); - assertEquals(tooltip.color(), color); - } - - @Test - public void positionTooltipTest() { - Map position = new HashMap<>(); - position.put("after", Tooltip.Position.RIGHT); - position.put("before", Tooltip.Position.LEFT); - position.put("above", Tooltip.Position.ABOVE); - position.put("below", Tooltip.Position.BELOW); - position.put("left", Tooltip.Position.LEFT); - position.put("right", Tooltip.Position.RIGHT); - - position.forEach( - (k,v) -> { - positionTooltipSelector.click(); - (new MaterialSelectorContainer()).select(k); - positionTooltipButton.hover(); - assertEquals(tooltip.position(positionTooltipButton), v); - } - ); - } -} diff --git a/jdi-light-angular-tests/src/test/resources/general.xml b/jdi-light-angular-tests/src/test/resources/general.xml index 12f8e083fb..87943d6101 100644 --- a/jdi-light-angular-tests/src/test/resources/general.xml +++ b/jdi-light-angular-tests/src/test/resources/general.xml @@ -4,7 +4,6 @@ - diff --git a/jdi-light-angular-tests/src/test/resources/unit.xml b/jdi-light-angular-tests/src/test/resources/unit.xml deleted file mode 100644 index f5cb0b98cc..0000000000 --- a/jdi-light-angular-tests/src/test/resources/unit.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java index 2a0cf91382..b178753336 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java @@ -15,65 +15,14 @@ public class BadgeAssert extends UIAssert { @JDIAction("Assert that '{name}' has '{0}' color") public BadgeAssert color(String value) { String actualColor = element().color(); - jdiAssert(actualColor, Matchers.equalTo(value), format("%s is not equal to %s", actualColor, value)); - return this; - } - - @JDIAction("Assert that '{name}' has '{0}' size") - public BadgeAssert size(BadgeSize size) { - final BadgeSize actualBadgeSize = element().size(); - jdiAssert(actualBadgeSize, Matchers.is(size), format("%s is not equal to %s", actualBadgeSize, size)); - return this; - - } - - @JDIAction("Assert that '{name}' has '{0}' position (vertical)") - public BadgeAssert positionVertical(BadgePosition value) { - final BadgePosition actualPosition = element().positionVertical(); - jdiAssert(actualPosition, Matchers.is(value), format("%s is not equal to %s", actualPosition, value)); - return this; - - } - - @JDIAction("Assert that '{name}' has '{0}' position (horizontal)") - public BadgeAssert positionHorizontal(BadgePosition value) { - final BadgePosition actualPosition = element().positionHorizontal(); - jdiAssert(actualPosition, Matchers.is(value), format("%s is not equal to %s", actualPosition, value)); - return this; - - } - - @JDIAction("Assert that '{name}' is overlap: {0}") - public BadgeAssert overlap(boolean value) { - jdiAssert(element().isOverlap(), Matchers.is(value), value ? "should be overlap" : "should NOT be overlap"); - return this; - } - - @Override - @JDIAction("Assert that '{name}' is displayed") - public BadgeAssert displayed() { - jdiAssert(element().isDisplayed(), Matchers.is(true), "should be displayed"); - return super.displayed(); - } - - @Override - @JDIAction("Assert that '{name}' is enabled") - public BadgeAssert enabled() { - jdiAssert(element().isEnabled(), Matchers.is(true), "should be enabled"); - return super.enabled(); - } - - @Override - @JDIAction("Assert that '{name}' is disabled") - public BadgeAssert disabled() { - jdiAssert(element().isDisabled(), Matchers.is(true), "should be disabled"); + jdiAssert(actualColor, Matchers.equalTo(value)); return this; } @JDIAction("Assert that '{name}' has text {0}") public BadgeAssert text(String value) { final String actualText = element().getText(); - jdiAssert(actualText, Matchers.is(value), format("%s is not equal to %s", actualText, value)); + jdiAssert(actualText, Matchers.is(value)); return this; } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java index 30cad80d51..fac640f29d 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java @@ -17,13 +17,7 @@ * To see an example of Badge web element please visit https://material.angular.io/components/badge/overview. */ -public class Badge extends UIBaseElement implements HasClick, IsText { - - @JDIAction("Get '{name}' badge") - private UIElement badge() { - return core().find(".mat-badge-content"); - } - +public class Badge extends UIBaseElement implements IsText { @Override public BadgeAssert is() { return new BadgeAssert().set(this); @@ -31,73 +25,11 @@ public BadgeAssert is() { @JDIAction("Get '{name}' color") public String color() { - return badge().css("background-color"); - } - - @JDIAction("Get '{name}' size") - public BadgeSize size() { - if (hasClass("mat-badge-medium")) { - return MEDIUM; - } - if (hasClass("mat-badge-large")) { - return LARGE; - } - if (hasClass("mat-badge-small")) { - return SMALL; - } - return BadgeSize.UNKNOWN; - } - - @JDIAction("Get '{name}' vertical position") - public BadgePosition positionVertical() { - if (hasClass("mat-badge-above")) { - return BadgePosition.ABOVE; - } - if (hasClass("mat-badge-below")) { - return BadgePosition.BELOW; - } - return BadgePosition.UNKNOWN; - } - - - @JDIAction("Get '{name}' horizontal position") - public BadgePosition positionHorizontal() { - if (hasClass("mat-badge-before")) { - return BadgePosition.BEFORE; - } - if (hasClass("mat-badge-after")) { - return BadgePosition.AFTER; - } - return BadgePosition.UNKNOWN; - } - - @JDIAction(value = "Check that '{name}' is overlap") - public boolean isOverlap() { - return hasClass("mat-badge-overlap"); - } - - @Override - public boolean isHidden() { - return hasClass("mat-badge-hidden"); - } - - @Override - public boolean isDisplayed() { - return !isHidden(); - } - - @Override - public boolean isDisabled() { - return hasClass("mat-badge-disabled"); - } - - @Override - public boolean isEnabled() { - return !isDisabled(); + return core().css("background-color"); } @Override public String getText() { - return badge().getText(); + return core().getText(); } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgePosition.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgePosition.java index 458da6f811..bbbd2731f4 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgePosition.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/BadgePosition.java @@ -6,5 +6,4 @@ public enum BadgePosition { AFTER, BEFORE, UNKNOWN - } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasBadge.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasBadge.java new file mode 100644 index 0000000000..e8ce23f8cb --- /dev/null +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasBadge.java @@ -0,0 +1,79 @@ +package com.epam.jdi.light.angular.elements.interfaces; + +import com.epam.jdi.light.angular.elements.common.Badge; +import com.epam.jdi.light.angular.elements.enums.AngularColors; +import com.epam.jdi.light.angular.elements.enums.BadgePosition; +import com.epam.jdi.light.angular.elements.enums.BadgeSize; +import com.epam.jdi.light.common.JDIAction; +import com.epam.jdi.light.elements.interfaces.base.ICoreElement; + +import static com.epam.jdi.light.angular.elements.enums.BadgeSize.*; + +/** + * In angular any element can be with Badge, so this interface can be used to work with it + */ +public interface HasBadge extends ICoreElement { + + default Badge badge(){ + return new Badge().setCore(Badge.class, this.find(".mat-badge-content")); + } + + @JDIAction("Get '{name}' size") + default BadgeSize badgeSize() { + if (hasClass("mat-badge-medium")) { + return MEDIUM; + } + if (hasClass("mat-badge-large")) { + return LARGE; + } + if (hasClass("mat-badge-small")) { + return SMALL; + } + return BadgeSize.UNKNOWN; + } + + @JDIAction("Get '{name}' vertical position") + default BadgePosition badgePositionVertical() { + if (hasClass("mat-badge-above")) { + return BadgePosition.ABOVE; + } + if (hasClass("mat-badge-below")) { + return BadgePosition.BELOW; + } + return BadgePosition.UNKNOWN; + } + + + @JDIAction("Get '{name}' horizontal position") + default BadgePosition badgePositionHorizontal() { + if (hasClass("mat-badge-before")) { + return BadgePosition.BEFORE; + } + return BadgePosition.AFTER; + } + + @JDIAction(value = "Check that '{name}' is overlap") + default boolean isBadgeOverlap() { + return hasClass("mat-badge-overlap"); + } + + default boolean isBadgeHidden() { + return hasClass("mat-badge-hidden"); + } + + default boolean isBadgeDisplayed() { + return !isHidden(); + } + + default boolean isBadgeDisabled() { + return hasClass("mat-badge-disabled"); + } + + default boolean isBadgeEnabled() { + return !isDisabled(); + } + + default AngularColors badgeColor() { + return AngularColors.fromColor(core().attr("matbadgecolor")); + } +} diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/asserts/HasBadgeAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/asserts/HasBadgeAssert.java new file mode 100644 index 0000000000..18994c3dcb --- /dev/null +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/asserts/HasBadgeAssert.java @@ -0,0 +1,59 @@ +package com.epam.jdi.light.angular.elements.interfaces.asserts; + +import com.epam.jdi.light.angular.elements.enums.BadgePosition; +import com.epam.jdi.light.angular.elements.enums.BadgeSize; +import com.epam.jdi.light.angular.elements.interfaces.HasBadge; +import com.epam.jdi.light.common.JDIAction; +import com.epam.jdi.light.elements.interfaces.base.IBaseElement; +import org.hamcrest.Matchers; + +import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; + +public interface HasBadgeAssert extends IBaseElement { + @JDIAction("Assert that '{name}' badge has '{0}' size") + default A badgeSize(BadgeSize size) { + final BadgeSize actualBadgeSize = element().badgeSize(); + jdiAssert(actualBadgeSize, Matchers.is(size)); + return (A) this; + + } + + @JDIAction("Assert that '{name}' badge has '{0}' vertical position") + default A badgePositionVertical(BadgePosition value) { + final BadgePosition actualPosition = element().badgePositionVertical(); + jdiAssert(actualPosition, Matchers.is(value)); + return (A) this; + + } + + @JDIAction("Assert that '{name}' badge has '{0}' horizontal position") + default A badgePositionHorizontal(BadgePosition value) { + jdiAssert(element().badgePositionHorizontal(), Matchers.is(value)); + return (A) this; + + } + + @JDIAction("Assert that '{name}' badge is overlap: {0}") + default A badgeOverlap(boolean value) { + jdiAssert(element().isBadgeOverlap(), Matchers.is(value), value ? "should be overlap" : "should NOT be overlap"); + return (A) this; + } + + @JDIAction("Assert that '{name}' badge is displayed") + default A badgeDisplayed() { + jdiAssert(element().isBadgeDisplayed(), Matchers.is(true), "Element's badge is not displayed"); + return (A) this; + } + + @JDIAction("Assert that '{name}' badge is enabled") + default A badgeEnabled() { + jdiAssert(element().isBadgeEnabled(), Matchers.is(true), "Element's badge is not enabled"); + return (A) this; + } + + @JDIAction("Assert that '{name}' badge is disabled") + default A badgeDisabled() { + jdiAssert(element().isBadgeDisabled(), Matchers.is(true), "Element's badge is not disabled"); + return (A) this; + } +} From f45cc026237baca69b23dd997e392b69897c43cf Mon Sep 17 00:00:00 2001 From: Natalia Pozhidaeva Date: Mon, 11 Sep 2023 09:34:43 -0500 Subject: [PATCH 4/9] Fix of interface --- .../angular/elements/interfaces/asserts/HasBadgeAssert.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/asserts/HasBadgeAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/asserts/HasBadgeAssert.java index 18994c3dcb..94407c8bc5 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/asserts/HasBadgeAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/asserts/HasBadgeAssert.java @@ -3,13 +3,13 @@ import com.epam.jdi.light.angular.elements.enums.BadgePosition; import com.epam.jdi.light.angular.elements.enums.BadgeSize; import com.epam.jdi.light.angular.elements.interfaces.HasBadge; +import com.epam.jdi.light.asserts.generic.IBaseAssert; import com.epam.jdi.light.common.JDIAction; -import com.epam.jdi.light.elements.interfaces.base.IBaseElement; import org.hamcrest.Matchers; import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; -public interface HasBadgeAssert extends IBaseElement { +public interface HasBadgeAssert extends IBaseAssert { @JDIAction("Assert that '{name}' badge has '{0}' size") default A badgeSize(BadgeSize size) { final BadgeSize actualBadgeSize = element().badgeSize(); From cd2ec337f310defce0b3b6a1e2d1b54301483673 Mon Sep 17 00:00:00 2001 From: Natalia Pozhidaeva Date: Mon, 11 Sep 2023 23:36:29 -0500 Subject: [PATCH 5/9] Remove unused imports --- .../com/epam/jdi/light/angular/elements/common/Badge.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java index fac640f29d..44ad1ffcec 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Badge.java @@ -1,18 +1,10 @@ package com.epam.jdi.light.angular.elements.common; import com.epam.jdi.light.angular.asserts.BadgeAssert; -import com.epam.jdi.light.angular.elements.enums.BadgePosition; -import com.epam.jdi.light.angular.elements.enums.BadgeSize; import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.base.UIBaseElement; -import com.epam.jdi.light.elements.common.UIElement; -import com.epam.jdi.light.elements.interfaces.base.HasClick; import com.epam.jdi.light.elements.interfaces.common.IsText; -import static com.epam.jdi.light.angular.elements.enums.BadgeSize.LARGE; -import static com.epam.jdi.light.angular.elements.enums.BadgeSize.MEDIUM; -import static com.epam.jdi.light.angular.elements.enums.BadgeSize.SMALL; - /** * To see an example of Badge web element please visit https://material.angular.io/components/badge/overview. */ From f8da2a3253e1eee8b9871233121f94d6b3bf3dba Mon Sep 17 00:00:00 2001 From: Natalia Pozhidaeva Date: Tue, 12 Sep 2023 00:42:56 -0500 Subject: [PATCH 6/9] Fix style --- .../java/com/epam/jdi/light/angular/asserts/BadgeAssert.java | 3 --- .../epam/jdi/light/angular/elements/interfaces/HasBadge.java | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java index b178753336..09f8a96ced 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/BadgeAssert.java @@ -1,14 +1,11 @@ package com.epam.jdi.light.angular.asserts; import com.epam.jdi.light.angular.elements.common.Badge; -import com.epam.jdi.light.angular.elements.enums.BadgePosition; -import com.epam.jdi.light.angular.elements.enums.BadgeSize; 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; -import static java.lang.String.format; public class BadgeAssert extends UIAssert { diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasBadge.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasBadge.java index e8ce23f8cb..e50bb60db8 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasBadge.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/HasBadge.java @@ -14,7 +14,7 @@ */ public interface HasBadge extends ICoreElement { - default Badge badge(){ + default Badge badge() { return new Badge().setCore(Badge.class, this.find(".mat-badge-content")); } From 2c339f61ad01ffa8c0501208894c964e549328a5 Mon Sep 17 00:00:00 2001 From: vklonin Date: Tue, 12 Sep 2023 16:23:39 +0300 Subject: [PATCH 7/9] Badge tests --- .../custom/asserts/ButtonWithBadgeAssert.java | 7 + .../asserts/UIElementWithBadgeAssert.java | 7 + .../com/custom/elements/ButtonWithBadge.java | 17 +++ .../custom/elements/UIElementWithBadge.java | 17 +++ .../java/io/github/com/pages/BadgePage.java | 32 +++-- .../tests/elements/common/BadgeTests.java | 130 +++++++++++------- .../interfaces/asserts/HasBadgeAssert.java | 6 + 7 files changed, 156 insertions(+), 60 deletions(-) create mode 100644 jdi-light-angular-tests/src/main/java/io/github/com/custom/asserts/ButtonWithBadgeAssert.java create mode 100644 jdi-light-angular-tests/src/main/java/io/github/com/custom/asserts/UIElementWithBadgeAssert.java create mode 100644 jdi-light-angular-tests/src/main/java/io/github/com/custom/elements/ButtonWithBadge.java create mode 100644 jdi-light-angular-tests/src/main/java/io/github/com/custom/elements/UIElementWithBadge.java diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/custom/asserts/ButtonWithBadgeAssert.java b/jdi-light-angular-tests/src/main/java/io/github/com/custom/asserts/ButtonWithBadgeAssert.java new file mode 100644 index 0000000000..9a4ca88f30 --- /dev/null +++ b/jdi-light-angular-tests/src/main/java/io/github/com/custom/asserts/ButtonWithBadgeAssert.java @@ -0,0 +1,7 @@ +package io.github.com.custom.asserts; + +import com.epam.jdi.light.angular.asserts.ButtonAssert; +import com.epam.jdi.light.angular.elements.interfaces.asserts.HasBadgeAssert; + +public class ButtonWithBadgeAssert extends ButtonAssert implements HasBadgeAssert { +} diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/custom/asserts/UIElementWithBadgeAssert.java b/jdi-light-angular-tests/src/main/java/io/github/com/custom/asserts/UIElementWithBadgeAssert.java new file mode 100644 index 0000000000..5e088c4852 --- /dev/null +++ b/jdi-light-angular-tests/src/main/java/io/github/com/custom/asserts/UIElementWithBadgeAssert.java @@ -0,0 +1,7 @@ +package io.github.com.custom.asserts; + +import com.epam.jdi.light.angular.elements.interfaces.asserts.HasBadgeAssert; +import com.epam.jdi.light.asserts.core.IsAssert; + +public class UIElementWithBadgeAssert extends IsAssert implements HasBadgeAssert { +} diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/custom/elements/ButtonWithBadge.java b/jdi-light-angular-tests/src/main/java/io/github/com/custom/elements/ButtonWithBadge.java new file mode 100644 index 0000000000..7f94a5997a --- /dev/null +++ b/jdi-light-angular-tests/src/main/java/io/github/com/custom/elements/ButtonWithBadge.java @@ -0,0 +1,17 @@ +package io.github.com.custom.elements; + +import com.epam.jdi.light.angular.elements.common.Button; +import com.epam.jdi.light.angular.elements.interfaces.HasBadge; +import io.github.com.custom.asserts.ButtonWithBadgeAssert; + +public class ButtonWithBadge extends Button implements HasBadge { + @Override + public ButtonWithBadgeAssert is() { + return (ButtonWithBadgeAssert) new ButtonWithBadgeAssert().set(this); + } + + @Override + public ButtonWithBadgeAssert has() { + return (ButtonWithBadgeAssert) new ButtonWithBadgeAssert().set(this); + } +} diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/custom/elements/UIElementWithBadge.java b/jdi-light-angular-tests/src/main/java/io/github/com/custom/elements/UIElementWithBadge.java new file mode 100644 index 0000000000..a69999ae36 --- /dev/null +++ b/jdi-light-angular-tests/src/main/java/io/github/com/custom/elements/UIElementWithBadge.java @@ -0,0 +1,17 @@ +package io.github.com.custom.elements; + +import com.epam.jdi.light.angular.elements.interfaces.HasBadge; +import com.epam.jdi.light.elements.common.UIElement; +import io.github.com.custom.asserts.UIElementWithBadgeAssert; + +public class UIElementWithBadge extends UIElement implements HasBadge { + @Override + public UIElementWithBadgeAssert is() { + return (UIElementWithBadgeAssert) new UIElementWithBadgeAssert().set(this); + } + + @Override + public UIElementWithBadgeAssert has() { + return (UIElementWithBadgeAssert) new UIElementWithBadgeAssert().set(this); + } +} diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/pages/BadgePage.java b/jdi-light-angular-tests/src/main/java/io/github/com/pages/BadgePage.java index 067b937742..b1332b8908 100644 --- a/jdi-light-angular-tests/src/main/java/io/github/com/pages/BadgePage.java +++ b/jdi-light-angular-tests/src/main/java/io/github/com/pages/BadgePage.java @@ -1,17 +1,29 @@ package io.github.com.pages; -import com.epam.jdi.light.angular.elements.common.Badge; +import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; +import io.github.com.custom.elements.ButtonWithBadge; +import io.github.com.custom.elements.UIElementWithBadge; public class BadgePage extends NewAngularPage { - public static Badge textWithBadge; - public static Badge buttonWithBadge; - public static Badge iconWithBadge; - public static Badge largeBadge; - public static Badge smallBadge; - public static Badge customSizeBadge; - public static Badge bellowPositionBadge; - public static Badge toggleVisibilityBadge; - public static Badge toggleDisabledBadge; +// public static Badge textWithBadge; + @UI("#text-with-badge") + public static UIElementWithBadge textWithBadge; + @UI("#large-badge") + public static UIElementWithBadge textWithLargeBadge; + @UI("#small-badge") + public static UIElementWithBadge textWithSmallBadge; + @UI("#custom-size-badge") + public static UIElementWithBadge elementWithCustomSizeBadge; + @UI("#bellow-position-badge") + public static UIElementWithBadge belowPositionBadge; + @UI("#button-with-badge") + public static ButtonWithBadge buttonWithBadge; + @UI("#icon-with-badge") + public static UIElementWithBadge iconWithBadge; + @UI("#toggle-visibility-badge") + public static ButtonWithBadge buttonToggleVisibilityBadge; + @UI("#toggle-disabled-badge") + public static ButtonWithBadge buttonToggleDisabledBadge; } diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java index 4ed2887d1a..a56eb49e23 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java @@ -1,5 +1,6 @@ package io.github.epam.angular.tests.elements.common; +import com.epam.jdi.light.angular.elements.enums.BadgeSize; import io.github.epam.TestsInit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -8,23 +9,20 @@ import static com.epam.jdi.light.angular.elements.enums.BadgePosition.AFTER; import static com.epam.jdi.light.angular.elements.enums.BadgePosition.BEFORE; import static com.epam.jdi.light.angular.elements.enums.BadgePosition.BELOW; -import static com.epam.jdi.light.angular.elements.enums.BadgeSize.LARGE; -import static com.epam.jdi.light.angular.elements.enums.BadgeSize.MEDIUM; -import static com.epam.jdi.light.angular.elements.enums.BadgeSize.SMALL; import static com.jdiai.tools.Timer.waitCondition; import static io.github.com.StaticSite.badgePage; import static io.github.com.enums.Colors.AMBER_ACCENT_2; import static io.github.com.enums.Colors.DEEP_PURPLE; import static io.github.com.enums.Colors.RED; -import static io.github.com.pages.BadgePage.bellowPositionBadge; +import static io.github.com.pages.BadgePage.belowPositionBadge; import static io.github.com.pages.BadgePage.buttonWithBadge; -import static io.github.com.pages.BadgePage.customSizeBadge; +import static io.github.com.pages.BadgePage.elementWithCustomSizeBadge; import static io.github.com.pages.BadgePage.iconWithBadge; -import static io.github.com.pages.BadgePage.largeBadge; -import static io.github.com.pages.BadgePage.smallBadge; import static io.github.com.pages.BadgePage.textWithBadge; -import static io.github.com.pages.BadgePage.toggleDisabledBadge; -import static io.github.com.pages.BadgePage.toggleVisibilityBadge; +import static io.github.com.pages.BadgePage.buttonToggleDisabledBadge; +import static io.github.com.pages.BadgePage.buttonToggleVisibilityBadge; +import static io.github.com.pages.BadgePage.textWithLargeBadge; +import static io.github.com.pages.BadgePage.textWithSmallBadge; public class BadgeTests extends TestsInit { @@ -36,67 +34,99 @@ public void before() { textWithBadge.show(); } - @Test(description = "The test checks color of the badge and content (string/number)") - public void colorAndContentBadgeTest() { - iconWithBadge.is().displayed() - .has().text("15") - .and().has().color(RED.value()); - buttonWithBadge.is().displayed() - .has().text("8") - .and().has().color(AMBER_ACCENT_2.value()); - customSizeBadge.is().displayed() - .has().text("Best") - .and().has().color(DEEP_PURPLE.value()); - } @Test(description = "Test checks if the badge is disabled/enabled") public void disabledBadgeTest() { - toggleDisabledBadge.is().disabled(); - - toggleDisabledBadge.click(); - toggleDisabledBadge.is().enabled(); - - toggleDisabledBadge.click(); - toggleDisabledBadge.is().disabled(); + buttonToggleDisabledBadge + .has().badgeDisabled(); + buttonToggleDisabledBadge.click(); + buttonToggleDisabledBadge + .has().badgeEnabled(); + buttonToggleDisabledBadge.click(); + buttonToggleDisabledBadge + .has().badgeDisabled(); } @Test(description = "Test checks the visibility of the badge") public void hiddenBadgeTest() { - toggleVisibilityBadge.is().displayed(); - toggleVisibilityBadge.click(); - toggleVisibilityBadge.is().hidden(); - toggleVisibilityBadge.click(); - toggleVisibilityBadge.is().displayed(); + buttonToggleVisibilityBadge + .has().badgeDisplayed(); + buttonToggleVisibilityBadge.click(); + buttonToggleVisibilityBadge + .has().badgeHidden(); + buttonToggleVisibilityBadge.click(); + buttonToggleVisibilityBadge + .has().badgeDisplayed(); } @Test(description = "Test checks if badge overlaps") public void overlapBadgeTest() { - textWithBadge.is().overlap(false); - - buttonWithBadge.is().overlap(true); + textWithLargeBadge + .has().badgeOverlap(true); + buttonWithBadge + .has().badgeOverlap(true); } @Test(description = "Test check position of the badge") public void positionOfTheBadgeTest() { - buttonWithBadge.has().positionVertical(ABOVE) - .and().has().positionHorizontal(BEFORE); - - textWithBadge.has().positionVertical(ABOVE) - .and().has().positionHorizontal(AFTER); - - bellowPositionBadge.has().positionVertical(BELOW) - .and().has().positionHorizontal(AFTER); + buttonWithBadge + .has().badgePositionVertical(ABOVE); + buttonWithBadge + .has().badgePositionHorizontal(BEFORE); + + textWithBadge + .has().badgePositionVertical(ABOVE); + textWithBadge + .has().badgePositionHorizontal(AFTER); + + belowPositionBadge + .has().badgePositionVertical(BELOW); + belowPositionBadge + .has().badgePositionHorizontal(AFTER); } @Test(description = "Test checks size of the badge") public void sizeOfTheBadgeTest() { - largeBadge.is().displayed() - .and().has().size(LARGE); + textWithLargeBadge + .has().badgeDisplayed(); + textWithLargeBadge + .has().badgeSize(BadgeSize.LARGE); + + textWithSmallBadge + .has().badgeDisplayed(); + textWithSmallBadge.has().badgeSize(BadgeSize.SMALL); + + textWithBadge + .has().badgeDisplayed(); + textWithBadge + .has().badgeSize(BadgeSize.MEDIUM); + } + + @Test(description = "simple checks for badge") + public void checkIfTextHasBadge() { + textWithBadge + .has().badgeDisabled(); + textWithBadge + .badge() + .has().text("4"); + } - smallBadge.is().displayed() - .and().has().size(SMALL); + @Test(description = "The test checks color of the badge and content (string/number) using badge()") + public void colorAndContentBadgeTest() { + iconWithBadge.badge() + .is().displayed() + .has().text("15") + .and() + .has().color(RED.value()); - textWithBadge.is().displayed() - .and().has().size(MEDIUM); + buttonWithBadge.badge() + .is().displayed() + .has().text("8") + .and().has().color(AMBER_ACCENT_2.value()); + + elementWithCustomSizeBadge.badge() + .is().displayed() + .has().text("Best") + .and().has().color(DEEP_PURPLE.value()); } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/asserts/HasBadgeAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/asserts/HasBadgeAssert.java index 94407c8bc5..c4667a2e43 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/asserts/HasBadgeAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/interfaces/asserts/HasBadgeAssert.java @@ -45,6 +45,12 @@ default A badgeDisplayed() { return (A) this; } + @JDIAction("Assert that '{name}' badge is hidden") + default A badgeHidden() { + jdiAssert(element().isBadgeHidden(), Matchers.is(true), "Element's badge is not hidden"); + return (A) this; + } + @JDIAction("Assert that '{name}' badge is enabled") default A badgeEnabled() { jdiAssert(element().isBadgeEnabled(), Matchers.is(true), "Element's badge is not enabled"); From e5197e5b4f07e20cc6ff30de45e94519a9979548 Mon Sep 17 00:00:00 2001 From: vklonin Date: Tue, 12 Sep 2023 19:00:30 +0300 Subject: [PATCH 8/9] fixed error --- .../github/epam/angular/tests/elements/common/BadgeTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java index a56eb49e23..c72579d735 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java @@ -105,7 +105,7 @@ public void sizeOfTheBadgeTest() { @Test(description = "simple checks for badge") public void checkIfTextHasBadge() { textWithBadge - .has().badgeDisabled(); + .has().badgeDisplayed(); textWithBadge .badge() .has().text("4"); From 7c61990e5fb8f61682c9191ae420e744ca8a82c5 Mon Sep 17 00:00:00 2001 From: vklonin Date: Wed, 13 Sep 2023 10:10:09 +0300 Subject: [PATCH 9/9] refactored icon and button --- .../custom/asserts/ButtonWithBadgeAssert.java | 7 ------- .../com/custom/elements/ButtonWithBadge.java | 17 ----------------- .../java/io/github/com/pages/BadgePage.java | 11 ++++++----- .../tests/elements/common/BadgeTests.java | 5 +++++ .../jdi/light/angular/asserts/ButtonAssert.java | 3 ++- .../jdi/light/angular/asserts/IconAssert.java | 3 ++- .../light/angular/elements/common/Button.java | 3 ++- .../jdi/light/angular/elements/common/Icon.java | 8 +++++++- 8 files changed, 24 insertions(+), 33 deletions(-) delete mode 100644 jdi-light-angular-tests/src/main/java/io/github/com/custom/asserts/ButtonWithBadgeAssert.java delete mode 100644 jdi-light-angular-tests/src/main/java/io/github/com/custom/elements/ButtonWithBadge.java diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/custom/asserts/ButtonWithBadgeAssert.java b/jdi-light-angular-tests/src/main/java/io/github/com/custom/asserts/ButtonWithBadgeAssert.java deleted file mode 100644 index 9a4ca88f30..0000000000 --- a/jdi-light-angular-tests/src/main/java/io/github/com/custom/asserts/ButtonWithBadgeAssert.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.github.com.custom.asserts; - -import com.epam.jdi.light.angular.asserts.ButtonAssert; -import com.epam.jdi.light.angular.elements.interfaces.asserts.HasBadgeAssert; - -public class ButtonWithBadgeAssert extends ButtonAssert implements HasBadgeAssert { -} diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/custom/elements/ButtonWithBadge.java b/jdi-light-angular-tests/src/main/java/io/github/com/custom/elements/ButtonWithBadge.java deleted file mode 100644 index 7f94a5997a..0000000000 --- a/jdi-light-angular-tests/src/main/java/io/github/com/custom/elements/ButtonWithBadge.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.github.com.custom.elements; - -import com.epam.jdi.light.angular.elements.common.Button; -import com.epam.jdi.light.angular.elements.interfaces.HasBadge; -import io.github.com.custom.asserts.ButtonWithBadgeAssert; - -public class ButtonWithBadge extends Button implements HasBadge { - @Override - public ButtonWithBadgeAssert is() { - return (ButtonWithBadgeAssert) new ButtonWithBadgeAssert().set(this); - } - - @Override - public ButtonWithBadgeAssert has() { - return (ButtonWithBadgeAssert) new ButtonWithBadgeAssert().set(this); - } -} diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/pages/BadgePage.java b/jdi-light-angular-tests/src/main/java/io/github/com/pages/BadgePage.java index b1332b8908..a16ab99e53 100644 --- a/jdi-light-angular-tests/src/main/java/io/github/com/pages/BadgePage.java +++ b/jdi-light-angular-tests/src/main/java/io/github/com/pages/BadgePage.java @@ -1,7 +1,8 @@ package io.github.com.pages; +import com.epam.jdi.light.angular.elements.common.Button; +import com.epam.jdi.light.angular.elements.common.Icon; import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; -import io.github.com.custom.elements.ButtonWithBadge; import io.github.com.custom.elements.UIElementWithBadge; public class BadgePage extends NewAngularPage { @@ -18,12 +19,12 @@ public class BadgePage extends NewAngularPage { @UI("#bellow-position-badge") public static UIElementWithBadge belowPositionBadge; @UI("#button-with-badge") - public static ButtonWithBadge buttonWithBadge; + public static Button buttonWithBadge; @UI("#icon-with-badge") - public static UIElementWithBadge iconWithBadge; + public static Icon iconWithBadge; @UI("#toggle-visibility-badge") - public static ButtonWithBadge buttonToggleVisibilityBadge; + public static Button buttonToggleVisibilityBadge; @UI("#toggle-disabled-badge") - public static ButtonWithBadge buttonToggleDisabledBadge; + public static Button buttonToggleDisabledBadge; } diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java index c72579d735..8f36b349f6 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java @@ -109,6 +109,11 @@ public void checkIfTextHasBadge() { textWithBadge .badge() .has().text("4"); + iconWithBadge + .has().badgeDisplayed(); + iconWithBadge + .badge() + .has().text("15"); } @Test(description = "The test checks color of the badge and content (string/number) using badge()") diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java index d9276b6273..8f4f197ce1 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/ButtonAssert.java @@ -3,13 +3,14 @@ import com.epam.jdi.light.angular.elements.common.Button; import com.epam.jdi.light.angular.elements.enums.AngularColors; import com.epam.jdi.light.angular.elements.enums.ButtonsTypes; +import com.epam.jdi.light.angular.elements.interfaces.asserts.HasBadgeAssert; 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; -public class ButtonAssert extends UIAssert { +public class ButtonAssert extends UIAssert implements HasBadgeAssert { @JDIAction("Assert that '{name}' has text '{0}'") public ButtonAssert text(String expectedText) { diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/IconAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/IconAssert.java index 07d701e2e9..32cd68bd04 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/IconAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/IconAssert.java @@ -1,13 +1,14 @@ package com.epam.jdi.light.angular.asserts; import com.epam.jdi.light.angular.elements.common.Icon; +import com.epam.jdi.light.angular.elements.interfaces.asserts.HasBadgeAssert; 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; -public class IconAssert extends UIAssert { +public class IconAssert extends UIAssert implements HasBadgeAssert { @JDIAction("Assert that '{name}' has type '{0}'") public IconAssert type(String expectedType) { diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java index bde01d4154..b0e1a4f65b 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Button.java @@ -3,13 +3,14 @@ import com.epam.jdi.light.angular.asserts.ButtonAssert; import com.epam.jdi.light.angular.elements.enums.AngularColors; import com.epam.jdi.light.angular.elements.enums.ButtonsTypes; +import com.epam.jdi.light.angular.elements.interfaces.HasBadge; import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.interfaces.base.HasClick; import com.epam.jdi.light.elements.interfaces.common.IsText; import com.jdiai.tools.map.MapArray; -public class Button extends UIBaseElement implements HasClick, IsText { +public class Button extends UIBaseElement implements HasBadge, HasClick, IsText { private static final String ICON_LOCATOR = ".//mat-icon"; diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Icon.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Icon.java index 172e5fd646..f2a997068b 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Icon.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/Icon.java @@ -1,12 +1,18 @@ package com.epam.jdi.light.angular.elements.common; import com.epam.jdi.light.angular.asserts.IconAssert; +import com.epam.jdi.light.angular.elements.interfaces.HasBadge; import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.interfaces.base.HasClick; -public class Icon extends UIBaseElement implements HasClick { +public class Icon extends UIBaseElement implements HasBadge, HasClick { // TODO implement. Done for button public String type() { return attr("data-mat-icon-type"); } + + @Override + public IconAssert is() { + return new IconAssert().set(this); + } }