Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4903: tests refactoring BADGE #5023

Merged
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,4 +22,7 @@ public class StaticSite {

@Url("buttons")
public static ButtonsPage buttonsPage;

@Url("badges")
public static BadgePage badgePage;
}
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class AngularPage extends WebPage {
public static SelectSection selectSection;
public static ListSection listSection;
public static GridListSection gridListSection;
public static BadgeSection badgeSection;
public static AutocompleteSection autocompleteSection;
public static SnackbarSection snackbarSection;
public static ButtonToggleSection buttonToggleSection;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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.UIElementWithBadge;

public class BadgePage extends NewAngularPage {

// 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 Button buttonWithBadge;
@UI("#icon-with-badge")
public static Icon iconWithBadge;
@UI("#toggle-visibility-badge")
public static Button buttonToggleVisibilityBadge;
@UI("#toggle-disabled-badge")
public static Button buttonToggleDisabledBadge;

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,47 +1,137 @@
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.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.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.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.belowPositionBadge;
import static io.github.com.pages.BadgePage.buttonWithBadge;
import static io.github.com.pages.BadgePage.elementWithCustomSizeBadge;
import static io.github.com.pages.BadgePage.iconWithBadge;
import static io.github.com.pages.BadgePage.textWithBadge;
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;

// 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();
textWithBadge.show();
}

@Test
public void basicBadgeTest() {
textWithBadge.show();
textWithBadge.badge().is().displayed();
textWithBadge.badge().has().text("4");
textWithBadge.has().color("Violet");

@Test(description = "Test checks if the badge is disabled/enabled")
public void disabledBadgeTest() {
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() {
buttonToggleVisibilityBadge
.has().badgeDisplayed();
buttonToggleVisibilityBadge.click();
buttonToggleVisibilityBadge
.has().badgeHidden();
buttonToggleVisibilityBadge.click();
buttonToggleVisibilityBadge
.has().badgeDisplayed();
}

@Test
public void buttonBadgeTest() {
buttonWithBadge.show();
buttonWithBadge.badge().is().displayed();
buttonWithBadge.badge().has().text("8");
buttonWithBadge.has().color("Yellow");
@Test(description = "Test checks if badge overlaps")
public void overlapBadgeTest() {
textWithLargeBadge
.has().badgeOverlap(true);
buttonWithBadge
.has().badgeOverlap(true);
}

@Test(description = "Test check position of the badge")
public void positionOfTheBadgeTest() {
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
public void iconBadgeTest() {
iconWithBadge.show();
iconWithBadge.badge().is().displayed();
iconWithBadge.badge().has().text("15");
iconWithBadge.has().color("Red");
@Test(description = "Test checks size of the badge")
public void sizeOfTheBadgeTest() {
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().badgeDisplayed();
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()")
public void colorAndContentBadgeTest() {
iconWithBadge.badge()
.is().displayed()
.has().text("15")
.and()
.has().color(RED.value());

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());
}
}
Loading