Skip to content

Commit

Permalink
Merge pull request #5241 from jdi-testing/4941-Test-refactoring-Divid…
Browse files Browse the repository at this point in the history
…er-element

[WIP] 4941 test refactoring divider element
  • Loading branch information
igor-vlasiuk authored Dec 18, 2023
2 parents 64e0b6c + 781d8e6 commit fe86675
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.github.com.pages.ButtonTogglePage;
import io.github.com.pages.ButtonsPage;
import io.github.com.pages.CheckBoxPage;
import io.github.com.pages.DividerPage;
import io.github.com.pages.ProgressBarPage;
import io.github.com.pages.ProgressSpinnerPage;
import io.github.com.pages.RadioButtonPage;
Expand All @@ -33,6 +34,9 @@ public class StaticSite {
@Url("buttons_toggle")
public static ButtonTogglePage buttonTogglePage;

@Url("divider")
public static DividerPage dividerPage;

@Url("autocompletes")
public static AutocompletePage autocompletePage;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,26 @@
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.CardSection;
import io.github.com.pages.sections.ChipsSection;
import io.github.com.pages.sections.DatepickerSection;
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.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 {

Expand Down Expand Up @@ -36,5 +55,4 @@ public class AngularPage extends WebPage {
public static SortingOverviewSection sortingOverviewSection;
public static ChipsSection chipsSection;
public static TableSection tableSection;
public static DividerSection dividerSection;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.github.com.pages;

import com.epam.jdi.light.angular.elements.common.Divider;
import com.epam.jdi.light.elements.common.Label;
import com.epam.jdi.light.elements.complex.JList;
import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI;

public class DividerPage extends NewAngularPage {

@UI("h2.example-h2")
public static Label textWithBasicDivider;

@UI("#divider-list:first-of-type > mat-divider[role=\"separator\"]")
public static JList<Divider> defaultDividers;

@UI("#divider-list:nth-of-type(2) > mat-divider[role=\"separator\"]")
public static JList<Divider> insetDivider;

@UI(".vertical-dividers > mat-divider[role=\"separator\"]")
public static JList<Divider> verticalDivider;

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,35 +1,46 @@
package io.github.epam.angular.tests.elements.common;

import io.github.epam.TestsInit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Ignore;
import org.testng.annotations.BeforeClass;
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 com.jdiai.tools.Timer.waitCondition;
import static io.github.com.StaticSite.dividerPage;
import static io.github.com.pages.DividerPage.defaultDividers;
import static io.github.com.pages.DividerPage.insetDivider;
import static io.github.com.pages.DividerPage.textWithBasicDivider;
import static io.github.com.pages.DividerPage.verticalDivider;
import static org.hamcrest.Matchers.equalTo;

// TODO Move to the new page
@Ignore
public class DividerTests extends TestsInit {

@BeforeMethod(alwaysRun = true)
@BeforeClass(alwaysRun = true)
public void before() {
shouldBeLoggedIn();
angularPage.shouldBeOpened();
dividerPage.open();
waitCondition(() -> dividerPage.isOpened());
dividerPage.checkOpened();
textWithBasicDivider.show();
}

@Test
public void dividerDisplayTest() {
dividerSection.dividers.has().size(equalTo(2));
dividerSection.dividers.get(1).is().displayed();
dividerSection.dividers.get(2).is().displayed();
@Test(description = "Test checks that default divider has horizontal property")
public void defaultDividersTest() {
defaultDividers.waitFor().displayed();
defaultDividers.has().size(equalTo(2));
defaultDividers.get(1).is().horizontal();
defaultDividers.get(2).is().horizontal();
}

@Test
public void dividerHorizontalOrientationTest() {
dividerSection.dividers.get(1).is().horizontal();
dividerSection.dividers.get(2).is().horizontal();
@Test(description = "Test checks that inset divider has inset property")
public void insetDividersTest() {
insetDivider.has().size(equalTo(2));
insetDivider.get(1).has().inset();
insetDivider.get(2).has().inset();
}

@Test(description = "Test checks that vertical divider has vertical property")
public void verticalDividerTest() {
verticalDivider.has().size(equalTo(2));
verticalDivider.get(1).is().vertical();
verticalDivider.get(2).is().vertical();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,29 @@ public class DividerAssert extends UIAssert<DividerAssert, Divider> {
*/
@JDIAction("Assert that '{name}' is horizontal orientation")
public DividerAssert horizontal() {
jdiAssert(element().isHorizontal() ? "is horizontal" : "is not horizontal", Matchers.is("is horizontal"));
jdiAssert(element().isHorizontal(), Matchers.is(true), "Divider is not horizontal");
return this;
}

/**
* Check that {@link Divider} is vertical orientation
*
* @return this {@link DividerAssert} instance
*/
@JDIAction("Assert that '{name}' is vertical orientation")
public DividerAssert vertical() {
jdiAssert(element().isVertical(), Matchers.is(true), "Divider is not vertical");
return this;
}

/**
* Check that {@link Divider} has inset
*
* @return this {@link DividerAssert} instance
*/
@JDIAction("Assert that '{name}' has inset")
public DividerAssert inset() {
jdiAssert(element().hasInset(), Matchers.is(true), "Divider doesn't have inset");
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,48 @@ public class Divider extends UIBaseElement<DividerAssert> {

private static final String ORIENTATION_ATTRIBUTE = "aria-orientation";
private static final String HORIZONTAL_VALUE = "horizontal";
private static final String VERTICAL_VALUE = "vertical";
private static final String INSET_CLASS = "mat-divider-inset";

/**
* Check whether Divider is horizontal orientation or not
* Check whether Divider separator is horizontal orientation or not
*
* @return {@code true} if Divider is horizontal orientation
* @return {@code true} if Divider separator is horizontal orientation
*/
@JDIAction("Check if '{name}' is horizontal orientation")
public boolean isHorizontal() {
return core().attr(ORIENTATION_ATTRIBUTE).equals(HORIZONTAL_VALUE);
}

/**
* Check whether Divider separator is vertical orientation or not
*
* @return {@code true} if Divider separator is vertical orientation
*/

@JDIAction("Check if '{name}' is vertical orientation")
public boolean isVertical() {
return core().attr(ORIENTATION_ATTRIBUTE).equals(VERTICAL_VALUE);
}

/**
* Check whether Divider separator has inset or not
*
* @return {@code true} if Divider separator has inset
*/
@JDIAction("Check if '{name}' has inset")
public boolean hasInset() {
return core().hasClass(INSET_CLASS);
}

@Override
public DividerAssert is() {
return new DividerAssert().set(this);
}

@Override
public DividerAssert has() {
return new DividerAssert().set(this);
}

}

0 comments on commit fe86675

Please sign in to comment.