-
Notifications
You must be signed in to change notification settings - Fork 47
4935 test refactoring element sidenav #5375
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
base: angular_rework_development
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package io.github.com.enums; | ||
|
|
||
| public enum ConfigurableMode { | ||
|
|
||
| OVER("over"), | ||
| SIDE("side"), | ||
| PUSH("push"); | ||
|
|
||
| private final String mode; | ||
|
|
||
| ConfigurableMode(String mode) { | ||
| this.mode = mode; | ||
| } | ||
|
|
||
| public String getMode() { | ||
| return mode; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,16 @@ | ||
| package io.github.epam.angular.tests.elements.complex; | ||
|
|
||
| import com.epam.jdi.light.elements.common.UIElement; | ||
| import com.epam.jdi.light.angular.elements.complex.SideNav; | ||
| import io.github.epam.TestsInit; | ||
| import org.testng.annotations.BeforeClass; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import static com.epam.jdi.light.elements.composite.WebPage.refresh; | ||
| import static com.jdiai.tools.StringUtils.format; | ||
| import static com.jdiai.tools.Timer.waitCondition; | ||
| import static io.github.com.StaticSite.sideNavPage; | ||
| import static io.github.com.enums.ConfigurableMode.OVER; | ||
| import static io.github.com.enums.ConfigurableMode.PUSH; | ||
| import static io.github.com.enums.ConfigurableMode.SIDE; | ||
| import static io.github.com.pages.SideNavPage.autoSizeSideNav; | ||
| import static io.github.com.pages.SideNavPage.backDropToggle; | ||
| import static io.github.com.pages.SideNavPage.basicDrawer; | ||
|
|
@@ -39,6 +41,7 @@ | |
| import static io.github.com.pages.SideNavPage.toggleSideNav; | ||
| import static io.github.com.pages.SideNavPage.toolbarToggle; | ||
| import static io.github.com.pages.SideNavPage.topGap; | ||
| import static java.lang.String.format; | ||
| import static org.hamcrest.Matchers.containsString; | ||
|
|
||
|
|
||
|
|
@@ -51,7 +54,6 @@ public class SideNavTests extends TestsInit { | |
| public static final String STYLE_VISIBLE = "transform: none; visibility: visible;"; | ||
| public static final String STYLE_HIDDEN = "box-shadow: none; visibility: hidden;"; | ||
| public static final String MODE = "mode"; | ||
| public static final String SIDE = "side"; | ||
|
|
||
| @BeforeClass(alwaysRun = true) | ||
| public void before() { | ||
|
|
@@ -103,24 +105,24 @@ public void verifyFocusSelectionDrawerWithExplicitBackdropSettingSideNavTest() { | |
|
|
||
| backDropToggle.click(); | ||
|
|
||
| firstElementFocused.base().timer().wait(() -> firstElementFocused.has().cssClass("cdk-program-focused")); | ||
| firstElementFocused.has().text("First Element"); | ||
| firstElementFocused.is().displayed(); | ||
| firstElementFocused.is().focused(); | ||
| } | ||
|
|
||
| @Test(description = "Verify main content is properly displayed alongside two side navigation panels") | ||
| public void verifyImplicitMainContentWithTwoSideNavTest() { | ||
| implicitMainContent.show(); | ||
| UIElement startSideNav = implicitMainContent.getSideNav("start"); | ||
| UIElement endSideNav = implicitMainContent.getSideNav("end"); | ||
| SideNav start = implicitMainContent.getSideNav("start"); | ||
| SideNav end = implicitMainContent.getSideNav("end"); | ||
|
|
||
| startSideNav.has().attr(MODE, SIDE); | ||
| startSideNav.has().attr(STYLE, STYLE_VISIBLE); | ||
| startSideNav.has().text("Start content"); | ||
| start.has().attr(MODE, SIDE.getMode()); | ||
| start.has().attr(STYLE, STYLE_VISIBLE); | ||
| start.has().text("Start content"); | ||
|
|
||
| endSideNav.has().attr(MODE, SIDE); | ||
| endSideNav.has().attr(STYLE, STYLE_VISIBLE); | ||
| endSideNav.has().text("End content"); | ||
| end.has().attr(MODE, SIDE.getMode()); | ||
| end.has().attr(STYLE, STYLE_VISIBLE); | ||
| end.has().text("End content"); | ||
|
|
||
| implicitMainContent.getContent().has().text("Implicit main content"); | ||
| implicitMainContent.getContent().is().displayed(); | ||
|
|
@@ -138,8 +140,8 @@ public void verifyOpenCloseBehaviorTest() { | |
| openCloseBehavior.getSideNav().has().text(SIDE_NAV_CONTENT); | ||
|
|
||
| sideNavOpened.click(); | ||
| openCloseBehavior.base().timer().wait(() -> openCloseBehavior.isEnabled()); | ||
| openCloseBehavior.base().timer().wait(() -> openCloseBehavior.getEvents().has().text("open!\nclose!")); | ||
| openCloseBehavior.isEnabled(); | ||
| openCloseBehavior.getEvents().has().text("open!\nclose!"); | ||
| } | ||
|
|
||
| @Test(description = "Verify SideNav with with configurable mode") | ||
|
|
@@ -159,26 +161,31 @@ public void toggleConfigurableSideNavTest() { | |
| public void sideRadioGroupTest() { | ||
| refresh(); | ||
| contentToggle.click(); | ||
| configurableMode.getContent().has().attr(STYLE, ""); | ||
|
|
||
| sideNavRadioGroup.base().timer().wait(() -> fixedPosition.visualValidation(".mat-sidenav-content")); | ||
| sideNavRadioGroup.click("Side"); | ||
| configurableMode.getContent().has().attr(STYLE, "margin-left: 299px;"); | ||
| sideNavRadioGroup.show(); | ||
| configurableMode.getContent().is().displayed(); | ||
| configurableMode.getMatDrawer().has().configurableMode(OVER.getMode()); | ||
|
|
||
| sideNavRadioGroup.click("Push"); | ||
| configurableMode.getContent().has().attr(STYLE, "margin-left: 300px; margin-right: -300px;"); | ||
| sideNavRadioGroup.click(SIDE.getMode()); | ||
| configurableMode.getContent().is().displayed(); | ||
| configurableMode.getMatDrawer().has().configurableMode(SIDE.getMode()); | ||
|
|
||
| sideNavRadioGroup.click(PUSH.getMode()); | ||
| configurableMode.getContent().is().displayed(); | ||
| configurableMode.getMatDrawer().has().configurableMode(PUSH.getMode()); | ||
| } | ||
|
|
||
| @Test(description = "Verify content radio group buttons") | ||
| public void contentRadioButtonsTest() { | ||
| refresh(); | ||
| contentToggle.click(); | ||
| sideNavRadioGroup.base().timer().wait(() -> fixedPosition.visualValidation(".mat-sidenav-content")); | ||
| sideNavRadioGroup.click("Side"); | ||
| configurableMode.getContent().has().attr(STYLE, "margin-left: 299px;"); | ||
| sideNavRadioGroup.show(); | ||
|
|
||
| sideNavRadioGroup.click(SIDE.getMode()); | ||
| configurableMode.getMatDrawer().has().configurableMode(SIDE.getMode()); | ||
|
|
||
| contentRadioGroup.click("Push"); | ||
| configurableMode.getContent().has().attr(STYLE, "margin-left: 300px; margin-right: -300px;"); | ||
| contentRadioGroup.click(PUSH.getMode()); | ||
| configurableMode.getMatDrawer().has().configurableMode(PUSH.getMode()); | ||
| } | ||
|
|
||
| @Test(description = "Verify toggle button") | ||
|
|
@@ -203,7 +210,6 @@ public void verifyAutoSizeSideNav() { | |
| toggleAutoNav.click(); | ||
| toggleExtraText.click(); | ||
| autoSizeSideNav.getMatDrawer().has().text(containsString("Toggle extra text")); | ||
| autoSizeSideNav.getMatDrawerContent().has().attr(STYLE, "margin-left: 303px;"); | ||
| } | ||
|
|
||
| @Test(description = "Verify fixed sideNav") | ||
|
|
@@ -219,7 +225,8 @@ public void fixedSideNavTest() { | |
| "100px;"); | ||
|
|
||
| toggleFixedSideNav.click(); | ||
| fixedPosition.base().timer().wait(() -> fixedPosition.visualValidation(".mat-sidenav-content")); | ||
|
|
||
| fixedPosition.base().timer().wait(() -> fixedPosition.getSideNav().is().hidden()); | ||
| fixedPosition.getSideNav().has().attr(STYLE, "top: 100px; bottom: 100px; box-shadow: none; visibility: " + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. не надо проверять style, это не стабильно и базовый функционал, который проверяется в html пакете
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. убрал
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. все еще на месте |
||
| "hidden;"); | ||
| } | ||
|
|
@@ -230,7 +237,7 @@ public void toggleResponsiveSideNavTest() { | |
| responsiveContent.show(); | ||
| toolbarToggle.click(); | ||
| for (int value : testValues) { | ||
| responsiveContent.getSideNavLinks().get(value).click(); | ||
| responsiveContent.getSideNav().getSideNavLinks().get(value).click(); | ||
| responsiveContent.getResponsiveResults().get(value).has().text(format("Selected Nav Item %d", value)); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.epam.jdi.light.angular.asserts; | ||
|
|
||
| import com.epam.jdi.light.angular.elements.composite.SideNavContainer; | ||
| import com.epam.jdi.light.asserts.generic.UIAssert; | ||
| import com.epam.jdi.light.common.JDIAction; | ||
| import org.hamcrest.Matchers; | ||
| import org.openqa.selenium.Point; | ||
|
|
||
| import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; | ||
|
|
||
| public class SideNavContainerAssert extends UIAssert<SideNavContainerAssert, SideNavContainer> { | ||
|
|
||
| private static final String LOCATION_ERROR_MESSAGE = "SideNavSection with location %s isn't on the right side"; | ||
|
|
||
| @JDIAction(value = "Assert that '{name}' has section with location '{0}' on the right side", isAssert = true) | ||
| public SideNavContainerAssert sideNavSectionOnTheRight(Point locationOfSection) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. зачем нам проверять, что-то по координатам? |
||
| jdiAssert(element().isSectionInRightPart(locationOfSection), Matchers.is(true), | ||
| String.format(LOCATION_ERROR_MESSAGE, locationOfSection)); | ||
| return this; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,21 +1,33 @@ | ||||||
| package com.epam.jdi.light.angular.asserts; | ||||||
|
|
||||||
| import com.epam.jdi.light.angular.elements.complex.SideNav; | ||||||
| import com.epam.jdi.light.asserts.generic.ITextAssert; | ||||||
| import com.epam.jdi.light.asserts.generic.UIAssert; | ||||||
| import com.epam.jdi.light.common.JDIAction; | ||||||
| import org.hamcrest.Matcher; | ||||||
| import org.hamcrest.Matchers; | ||||||
| import org.openqa.selenium.Point; | ||||||
|
|
||||||
| import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; | ||||||
| import static java.lang.String.format; | ||||||
|
|
||||||
| public class SideNaveAssert extends UIAssert<SideNaveAssert, SideNav> { | ||||||
| public class SideNaveAssert extends UIAssert<SideNaveAssert, SideNav> implements ITextAssert<SideNaveAssert> { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| private static final String MAT_DRAWER_TEMPLATE = "mat-drawer-%s"; | ||||||
|
|
||||||
| private static final String LOCATION_ERROR_MESSAGE = "SideNavSection with location %s isn't on the right side"; | ||||||
|
|
||||||
| @JDIAction(value = "Assert that '{name}' has section with location '{0}' on the right side", isAssert = true) | ||||||
| public SideNaveAssert sideNavSectionOnTheRight(Point locationOfSection) { | ||||||
| jdiAssert(element().isSectionInRightPart(locationOfSection), Matchers.is(true), | ||||||
| String.format(LOCATION_ERROR_MESSAGE, locationOfSection)); | ||||||
| @JDIAction(value = "Assert that '{name}' text {0}", isAssert = true) | ||||||
| @Override | ||||||
| public SideNaveAssert text(Matcher<String> condition) { | ||||||
| jdiAssert(element().getSideNaveText(), condition); | ||||||
| return this; | ||||||
| } | ||||||
|
|
||||||
| @JDIAction(value = "Assert that '{name}' text is '{0}'", isAssert = true) | ||||||
| @Override | ||||||
| public SideNaveAssert text(String text) { | ||||||
| return text(Matchers.is(text)); | ||||||
| } | ||||||
|
|
||||||
| @JDIAction(value = "Assert that '{name}' has class '{0}'", isAssert = true) | ||||||
| public void configurableMode(String mode) { | ||||||
| this.cssClass(format(MAT_DRAWER_TEMPLATE, mode.toLowerCase())); | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,16 +24,6 @@ public SideNaveAssert has() { | |
| return is(); | ||
| } | ||
|
|
||
| @JDIAction("Get '{name}' side nav") | ||
| public UIElement getSideNav() { | ||
| return this.find(".mat-sidenav"); | ||
| } | ||
|
|
||
| @JDIAction("Get '{name}' side nav content") | ||
| public UIElement getContent() { | ||
| return this.find(".mat-sidenav-content"); | ||
| } | ||
|
|
||
| /*for several side navs*/ | ||
| @JDIAction("Get '{name}' side nav by '{0}' position value") | ||
| public UIElement getSideNav(String position) { | ||
|
|
@@ -46,40 +36,23 @@ public UIElement getSideNav(String position) { | |
| return element; | ||
| } | ||
|
|
||
| @JDIAction("Get '{name}' side nav content") | ||
| public UIElement getEvents() { | ||
| return getContent().find(".example-events"); | ||
| } | ||
|
|
||
| @JDIAction("Get '{name}' side nav content") | ||
| public WebList getSideNavLinks() { | ||
| return getSideNav().finds("a"); | ||
| } | ||
|
|
||
| @JDIAction("Get '{name}' side nav content") | ||
| public WebList getResponsiveResults() { | ||
| return getContent().finds("p"); | ||
| return this.finds("a"); | ||
| } | ||
|
|
||
| @JDIAction("Get '{name}' side nav items") | ||
| private WebList getSideNavItems() { | ||
| return this.finds(".mat-sidenav"); | ||
|
||
| } | ||
|
|
||
| /*mat-drawer*/ | ||
| @JDIAction("Get '{name}' mat drawer") | ||
| public UIElement getMatDrawer() { | ||
| return this.find(".mat-drawer"); | ||
| } | ||
|
|
||
| @JDIAction("Get '{name}' mat drawer content content") | ||
| public UIElement getMatDrawerContent() { | ||
| return this.find(".mat-drawer-content"); | ||
| } | ||
|
|
||
| @JDIAction("Is '{name}' side nav has section with location '{0}' on right side") | ||
| public boolean isSectionInRightPart(Point locationOfSection) { | ||
| int containerCenterX = this.getLocation().getX() + this.getSize().getWidth() / 2; | ||
| return locationOfSection.getX() >= containerCenterX; | ||
| } | ||
|
|
||
| public String getSideNaveText() { | ||
| return core().text(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
обычно еще делают метод получения Enum по строковому значению