Skip to content

Commit

Permalink
tests of Divider page, task # 4941
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Vlasiuk committed Nov 30, 2023
1 parent 05f1218 commit c058117
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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;
Expand All @@ -14,7 +15,7 @@ public class DividerPage extends NewAngularPage {
public static JList<Divider> defaultDividersList;

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

@UI("#divider-list:first-of-type > mat-list-item:nth-of-type(1)")
public static UIElement elementDefaultItemOneDivider;
Expand All @@ -32,7 +33,7 @@ public class DividerPage extends NewAngularPage {
public static JList<Divider> insetDividersList;

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

@UI("#divider-list:nth-of-type(2) > mat-list-item:nth-of-type(1)")
public static UIElement elementInsetItemOneDivider;
Expand All @@ -50,7 +51,7 @@ public class DividerPage extends NewAngularPage {
public static JList<Divider> verticalDividersList;

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

@UI(".vertical-dividers > mat-list-item:nth-of-type(1)")
public static UIElement elementVerticalItemOneDivider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ public void before() {
@Test(description = "Test checks presence of mat-divider-horizontal class for default divider separators")
public void defaultDividersSeparatorsTest() {
defaultDividersSeparators.has().size(equalTo(2));
defaultDividersSeparators.get(1).hasClass("mat-divider-horizontal");
defaultDividersSeparators.get(2).hasClass("mat-divider-horizontal");
defaultDividersSeparators.get(1).is().horizontal();
defaultDividersSeparators.get(2).is().horizontal();
}

@Test(description = "Test checks presence of mat-divider-inset class for inset divider separators")
public void insetDividersSeparatorsTest() {
insetDividerSeparators.has().size(equalTo(2));
insetDividerSeparators.get(1).hasClass("mat-divider-inset");
insetDividerSeparators.get(2).hasClass("mat-divider-inset");
insetDividerSeparators.get(1).has().inset();
insetDividerSeparators.get(2).has().inset();
}

@Test(description = "Test checks presence of mat-divider-vertical class for vertical divider separators")
public void verticalDividerSeparatorsTest() {
verticalDividerSeparators.has().size(equalTo(2));
verticalDividerSeparators.get(1).hasClass("mat-divider-vertical");
verticalDividerSeparators.get(2).hasClass("mat-divider-vertical");
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,48 @@
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() ? "is horizontal" : "is not horizontal", Matchers.is("is horizontal"));
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() ? "is vertical" : "is not vertical", Matchers.is("is vertical"));
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() ? "has inset" : "has no inset", Matchers.is("has inset"));
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,54 @@
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> {

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

0 comments on commit c058117

Please sign in to comment.