-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5023 from jdi-testing/4903_Tests_refactoring_BADG…
…E_element 4903: tests refactoring BADGE
- Loading branch information
Showing
47 changed files
with
371 additions
and
3,065 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...ht-angular-tests/src/main/java/io/github/com/custom/asserts/UIElementWithBadgeAssert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
} |
17 changes: 17 additions & 0 deletions
17
jdi-light-angular-tests/src/main/java/io/github/com/custom/elements/UIElementWithBadge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
jdi-light-angular-tests/src/main/java/io/github/com/pages/BadgePage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
10 changes: 0 additions & 10 deletions
10
jdi-light-angular-tests/src/main/java/io/github/com/pages/sections/BadgeSection.java
This file was deleted.
Oops, something went wrong.
148 changes: 119 additions & 29 deletions
148
...-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/BadgeTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
Oops, something went wrong.