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
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,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;

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,101 @@

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

@Test
public void basicBadgeTest() {
textWithBadge.show();
textWithBadge.badge().is().displayed();
textWithBadge.badge().has().text("4");
textWithBadge.has().color("Violet");
@Test(description = "The test checks color of the badge and content (string/number)")
public void colorAndContentBadgeTest() {
iconWithBadge.is().displayed()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is icon badge, we should have a validation for icon, if not, there is no difference with buttonWithBadge and should be removed

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

@Test
public void buttonBadgeTest() {
buttonWithBadge.show();
buttonWithBadge.badge().is().displayed();
buttonWithBadge.badge().has().text("8");
buttonWithBadge.has().color("Yellow");
@Test(description = "Test checks the visibility of the badge")
public void hiddenBadgeTest() {
toggleVisibilityBadge.is().displayed();
toggleVisibilityBadge.click();
toggleVisibilityBadge.is().hidden();
toggleVisibilityBadge.click();
Kate-Semenova marked this conversation as resolved.
Show resolved Hide resolved
toggleVisibilityBadge.is().displayed();
}

@Test
public void iconBadgeTest() {
iconWithBadge.show();
iconWithBadge.badge().is().displayed();
iconWithBadge.badge().has().text("15");
iconWithBadge.has().color("Red");
@Test(description = "Test checks if badge overlaps")
public void overlapBadgeTest() {
textWithBadge.is().overlap(false);

buttonWithBadge.is().overlap(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);
}

@Test(description = "Test checks size of the badge")
public void sizeOfTheBadgeTest() {
largeBadge.is().displayed()
.and().has().size(LARGE);

smallBadge.is().displayed()
.and().has().size(SMALL);

textWithBadge.is().displayed()
.and().has().size(MEDIUM);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
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 org.testng.Assert.assertTrue;

Expand All @@ -20,13 +19,4 @@ public void before() {
angularPage.shouldBeOpened();
}

@Test
public void badgeTest() {
assertTrue(textWithBadge.badge().isDisplayed());
}

@Test
public void colorTest() {
assertTrue(textWithBadge.color("Violet"));
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +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<BadgeAssert, Badge> {
public class BadgeAssert extends UIAssert<BadgeAssert, Badge> {

@JDIAction("'{name}' has '{0}' color")
@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(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");
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;
}
}
Loading