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

[WIP] 4941 test refactoring divider element #5241

Merged
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,65 @@
package io.github.com.pages;

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

public class DividerPage extends NewAngularPage {

@UI("/descendant::h3[1]")
public static UIElement textWithDefaultDividers;
igor-vlasiuk marked this conversation as resolved.
Show resolved Hide resolved

@UI("#divider-list:first-of-type > mat-list-item")
public static JList<Divider> defaultDividersList;
igor-vlasiuk marked this conversation as resolved.
Show resolved Hide resolved

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

@UI("#divider-list:first-of-type > mat-list-item:nth-of-type(1)")
public static UIElement elementDefaultItemOneDivider;

@UI("#divider-list:first-of-type > mat-list-item:nth-of-type(2)")
public static UIElement elementDefaultItemTwoDivider;

@UI("#divider-list:first-of-type > mat-list-item:nth-of-type(3)")
public static UIElement elementDefaultItemThreeDivider;

@UI("/descendant::h3[2]")
public static UIElement textInsetDividers;

@UI("#divider-list:nth-of-type(2) > mat-list-item")
public static JList<Divider> insetDividersList;

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

@UI("#divider-list:nth-of-type(2) > mat-list-item:nth-of-type(1)")
public static UIElement elementInsetItemOneDivider;

@UI("#divider-list:nth-of-type(2) > mat-list-item:nth-of-type(2)")
public static UIElement elementInsetItemTwoDivider;

@UI("#divider-list:nth-of-type(2) > mat-list-item:nth-of-type(3)")
public static UIElement elementInsetItemThreeDivider;

@UI("/descendant::h3[3]")
public static UIElement textVerticalDividers;

@UI(".vertical-dividers > mat-list-item")
public static JList<Divider> verticalDividersList;

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

@UI(".vertical-dividers > mat-list-item:nth-of-type(1)")
public static UIElement elementVerticalItemOneDivider;

@UI(".vertical-dividers > mat-list-item:nth-of-type(2)")
public static UIElement elementVerticalItemTwoDivider;

@UI(".vertical-dividers > mat-list-item:nth-of-type(3)")
public static UIElement elementVerticalItemThreeDivider;

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,44 @@

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.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.defaultDividersSeparators;
import static io.github.com.pages.DividerPage.insetDividerSeparators;
import static io.github.com.pages.DividerPage.textWithDefaultDividers;
import static io.github.com.pages.DividerPage.verticalDividerSeparators;
import static org.hamcrest.Matchers.equalTo;

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

@BeforeMethod(alwaysRun = true)
igor-vlasiuk marked this conversation as resolved.
Show resolved Hide resolved
public void before() {
shouldBeLoggedIn();
angularPage.shouldBeOpened();
dividerPage.open();
waitCondition(() -> dividerPage.isOpened());
dividerPage.checkOpened();
textWithDefaultDividers.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 separators have horizontal property")
public void defaultDividersSeparatorsTest() {
defaultDividersSeparators.has().size(equalTo(2));
defaultDividersSeparators.get(1).is().horizontal();
defaultDividersSeparators.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 separators have inset property")
public void insetDividersSeparatorsTest() {
insetDividerSeparators.has().size(equalTo(2));
insetDividerSeparators.get(1).has().inset();
insetDividerSeparators.get(2).has().inset();
}

@Test(description = "Test checks that vertical divider separators have vertical property")
public void verticalDividerSeparatorsTest() {
verticalDividerSeparators.has().size(equalTo(2));
verticalDividerSeparators.get(1).is().vertical();
verticalDividerSeparators.get(2).is().vertical();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.epam.jdi.light.angular.asserts;

import com.epam.jdi.light.angular.elements.common.DividerSeparator;
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;

/**
* Assertions for {@link DividerSeparator}
*/
public class DividerSeparatorAssert extends UIAssert<DividerSeparatorAssert, DividerSeparator> {

/**
* Check that {@link DividerSeparator} is horizontal orientation
*
* @return this {@link DividerSeparatorAssert} instance
*/
@JDIAction("Assert that '{name}' is horizontal orientation")
public DividerSeparatorAssert horizontal() {
jdiAssert(element().isHorizontal(), Matchers.is(true), "Default divider separator is not horizontal");
igor-vlasiuk marked this conversation as resolved.
Show resolved Hide resolved
return this;
}

/**
* Check that {@link DividerSeparator} is vertical orientation
*
* @return this {@link DividerSeparatorAssert} instance
*/
@JDIAction("Assert that '{name}' is vertical orientation")
public DividerSeparatorAssert vertical() {
jdiAssert(element().isVertical(), Matchers.is(true), "Vertical divider separator is not vertical");
igor-vlasiuk marked this conversation as resolved.
Show resolved Hide resolved
return this;
}

/**
* Check that {@link DividerSeparator} has inset
*
* @return this {@link DividerSeparatorAssert} instance
*/
@JDIAction("Assert that '{name}' has inset")
public DividerSeparatorAssert inset() {
jdiAssert(element().hasInset(), Matchers.is(true), "Inset divider separator doesn't have inset");
igor-vlasiuk marked this conversation as resolved.
Show resolved Hide resolved
return this;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.epam.jdi.light.angular.elements.common;

import com.epam.jdi.light.angular.asserts.DividerAssert;
import com.epam.jdi.light.common.JDIAction;
import com.epam.jdi.light.angular.asserts.DividerSeparatorAssert;
import com.epam.jdi.light.elements.base.UIBaseElement;

/**
Expand All @@ -11,23 +10,6 @@
*
* @see <a href="https://material.angular.io/components/divider/overview">Divider Overview</a>
*/
public class Divider extends UIBaseElement<DividerAssert> {
public class Divider extends UIBaseElement<DividerSeparatorAssert> {

private static final String ORIENTATION_ATTRIBUTE = "aria-orientation";
private static final String HORIZONTAL_VALUE = "horizontal";

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

@Override
public DividerAssert is() {
return new DividerAssert().set(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.epam.jdi.light.angular.elements.common;

import com.epam.jdi.light.angular.asserts.DividerSeparatorAssert;
import com.epam.jdi.light.common.JDIAction;
import com.epam.jdi.light.elements.base.UIBaseElement;

public class DividerSeparator extends UIBaseElement<DividerSeparatorAssert> {
igor-vlasiuk marked this conversation as resolved.
Show resolved Hide resolved

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 separator is horizontal orientation or not
*
* @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 DividerSeparatorAssert is() {
return new DividerSeparatorAssert().set(this);
}

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