Skip to content

Commit

Permalink
4938-rippleTestsRefactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Maiia_Afanaseva authored and Maiia_Afanaseva committed Jul 28, 2023
1 parent 8207979 commit ecb285a
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.github.com.pages.AngularPage;
import io.github.com.pages.ProgressBarPage;
import io.github.com.pages.ProgressSpinnerPage;
import io.github.com.pages.RipplePage;

@JSite("https://jdi-testing.github.io/jdi-light/angular-page/#/")
public class StaticSite {
Expand All @@ -17,4 +18,7 @@ public class StaticSite {

@Url("progress_spinner")
public static ProgressSpinnerPage progressSpinnerPage;

@Url("ripple")
public static RipplePage ripplePage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class AngularPage extends WebPage {
public static Icon basicIcon;
@UI("#svg_icon")
public static Icon svgIcon;
public static Ripple rippleContainer;
@UI("#bottom-sheet")
public static BottomSheet bottomSheet;
public static Dialog dialog;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.github.com.pages;

import com.epam.jdi.light.angular.elements.complex.Ripple;

public class RipplePage extends NewAngularPage {

public static Ripple rippleContainer;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@
import io.github.epam.TestsInit;
import org.apache.commons.lang3.RandomUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

import static com.epam.jdi.light.elements.composite.WebPage.refresh;
import static io.github.com.StaticSite.angularPage;
import static io.github.com.pages.AngularPage.rippleContainer;
import static io.github.epam.site.steps.States.shouldBeLoggedIn;
import static com.jdiai.tools.Timer.waitCondition;
import static io.github.com.StaticSite.ripplePage;
import static io.github.com.pages.RipplePage.*;
import static org.hamcrest.Matchers.is;

// TODO Move to the new page
@Ignore
public class RippleTests extends TestsInit {
@BeforeMethod(alwaysRun = true)
@BeforeMethod
public void before() {
shouldBeLoggedIn();
angularPage.shouldBeOpened();
rippleContainer.show();
ripplePage.open();
waitCondition(() -> ripplePage.isOpened());
ripplePage.checkOpened();
}

@Test(description = "Test checks that ripple container is displayed")
Expand Down Expand Up @@ -57,88 +54,78 @@ public void rippleActionTest() {
rippleContainer.is().active();
}

@Test(description = "Test checks ripple feature: radius(number)")
@Test(description = "Test checks ripple feature: radius")
public void radiusTest() {
int expectedRadius = 260;
rippleContainer.setRadius(expectedRadius);
rippleContainer.has().radius(expectedRadius);
}

@Test(description = "Test checks ripple feature: radius(number)")
@Test(description = "Test checks ripple feature: radius correct value")
public void rippleRadiusTest() {
int expectedRadius = 124;
rippleContainer.setRadius(expectedRadius);
rippleContainer.is().radius(is(124));
}

@Test
@Test(description = "Test checks ripple feature: radius attributes(correct number)")
public void rippleCorrectRadiusTest() {
rippleContainer.setRadius(100);
rippleContainer.has().correctRadius();
}

@Test
@Test(description = "Test checks ripple feature: radius attributes(incorrect number)")
public void rippleNotCorrectRadiusTest() {
refresh();
rippleContainer.setRadius(-5);
rippleContainer.has().incorrectRadius();
}

@Test
public void colorTest() {
String expectedColor = "BLUE";
rippleContainer.setColor(expectedColor);
rippleContainer.is().color(expectedColor.toLowerCase());
}

@Test
@Test(description = "Test checks ripple feature: color attributes(correct value)")
public void rippleCorrectColorTest() {
refresh();
rippleContainer.setColor("rgba(255, 0, 255, 0.7)");
rippleContainer.has().correctColor();
}

@Test
@Test(description = "Test checks ripple feature: color attributes(incorrect value)")
public void rippleNotCorrectColorTest() {
refresh();
rippleContainer.setColor("custom color");
rippleContainer.has().incorrectColor();
}

@Test
@Test(description = "Test checks ripple has correct radius and value")
public void rippleRadiusAndColorTest() {
refresh();
String expectedColor = "SALMON";
int expectedRadius = 219;
rippleContainer.setColor(expectedColor);
rippleContainer.setRadius(expectedRadius);
rippleContainer.is().radius(expectedRadius).and().color(is(expectedColor.toLowerCase()));
rippleContainer.is().radius(is(expectedRadius)).and().color(is(expectedColor.toLowerCase()));
}

@Test
@Test(description = "Test checks ripple is centered has correct radius and value")
public void rippleRadiusAndColorAndCenteredTest() {
refresh();
rippleContainer.center();
String expectedColor = "rgba(28, 140, 16, 0.1)";
int expectedRadius = 150;
rippleContainer.setColor(expectedColor);
rippleContainer.setRadius(expectedRadius);
rippleContainer.is().radius(expectedRadius).and().color(is(expectedColor.toLowerCase())).and().centered();
rippleContainer.is().radius(is(expectedRadius))
.and().color(is(expectedColor.toLowerCase()))
.and().centered();
}

@Test
@Test(description = "Test checks ripple center coordinates and radius value")
public void mouseClickByCoordinatesAndRadiusTest() {
refresh();
int x = 0;
int y = 299;
int expectedRadius = 300;
rippleContainer.setRadius(expectedRadius);

rippleContainer.ripple(x, y);
rippleContainer.is().rippleCenter(x, y).and().radius(expectedRadius);
rippleContainer.is().rippleCenter(x, y).and().radius((is(expectedRadius)));
}

@Test
@Test(description = "Test checks ripple is centered and unbounded")
public void randomMouseClickCenteredAndUnboundedTest() {
rippleContainer.unbound();
rippleContainer.center();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,120 +3,80 @@
import io.github.epam.TestsInit;
import org.apache.commons.lang3.RandomUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

import static com.epam.jdi.light.elements.composite.WebPage.refresh;
import static io.github.com.StaticSite.angularPage;
import static io.github.com.pages.AngularPage.rippleContainer;
import static io.github.epam.site.steps.States.shouldBeLoggedIn;
import static com.jdiai.tools.Timer.waitCondition;
import static io.github.com.StaticSite.ripplePage;
import static io.github.com.pages.RipplePage.*;
import static org.testng.Assert.*;

// TODO Move to the new page
@Ignore
public class RippleUnitTests extends TestsInit {
@BeforeMethod(alwaysRun = true)
@BeforeMethod
public void before() {
shouldBeLoggedIn();
angularPage.shouldBeOpened();
rippleContainer.show();
ripplePage.open();
waitCondition(() -> ripplePage.isOpened());
ripplePage.checkOpened();
}

@Test
public void displayedTest() {
assertTrue(rippleContainer.isDisplayed());
}

@Test
@Test(description = "Unit test checks that ripple does not appear if 'disabled' option chosen")
public void disabledTest() {
rippleContainer.disable();
assertTrue(rippleContainer.isDisabled());
rippleContainer.ripple();
assertTrue(rippleContainer.isNotActive());
rippleContainer.enable();
assertTrue(rippleContainer.isEnabled());
rippleContainer.ripple();
assertTrue(rippleContainer.isActive());
}

@Test
@Test(description = "Unit test checks element's feature 'unbounded'")
public void unboundedTest() {
rippleContainer.unbound();
rippleContainer.ripple();
assertTrue(rippleContainer.isUnbounded());
}

@Test
@Test(description = "Unit test checks element's feature 'centered'")
public void centeredTest() {
rippleContainer.center();
rippleContainer.ripple();
assertTrue(rippleContainer.isCentered());
}

@Test
@Test(description = "Unit test checks that 'ripple' activates if element is clicked")
public void rippleActionTest() {
rippleContainer.ripple();
assertTrue(rippleContainer.isActive());
}

@Test
public void radiusTest() {
int expectedRadius = 200;
rippleContainer.setRadius(expectedRadius);
assertTrue(rippleContainer.isRadius(expectedRadius));
}

@Test
@Test(description = "Unit test checks that 'ripple effect' has correct value of radius")
public void rippleRadiusTest() {
int expectedRadius = 195;
rippleContainer.setRadius(expectedRadius);
assertEquals(rippleContainer.radius(), expectedRadius, "The radius has an incorrect value");
}

@Test
public void rippleCorrectRadiusTest() {
refresh();
rippleContainer.setRadius(0);
assertTrue(rippleContainer.isCorrectRadius());
}

@Test
public void rippleNotCorrectRadiusTest() {
rippleContainer.setRadius(-1);
assertFalse(rippleContainer.isCorrectRadius());
}

@Test
public void colorTest() {
String expectedColor = "Green";
rippleContainer.setColor(expectedColor);
assertTrue(rippleContainer.isColor(expectedColor.toLowerCase()));
}

@Test
public void rippleCorrectColorTest() {
refresh();
rippleContainer.setColor("rgba(0, 0, 0)");
assertTrue(rippleContainer.isCorrectColor());
}

@Test
public void rippleNotCorrectColorTest() {
rippleContainer.setColor("custom color");
assertFalse(rippleContainer.isCorrectColor());
}

@Test
@Test(description = "Unit test checks that 'ripple' element has correct value of color")
public void rippleColorTest() {
refresh();
String expectedColor = "AqUaMaRiNe";
rippleContainer.setColor(expectedColor);
assertEquals(rippleContainer.color(), expectedColor.toLowerCase(), "The color has an incorrect value");
}

@Test
@Test(description = "Unit test checks that 'ripple' element has correct value of color rgba")
public void rippleRgbaColorTest() {
refresh();
String expectedColor = "rgba(200, 100, 50, 0.5)";
rippleContainer.setColor(expectedColor);
assertEquals(rippleContainer.color(), expectedColor, "The color has an incorrect value");
}

@Test
@Test(description = "Unit test checks that when 'centered' with any click in container 'ripple' is centered")
public void mouseClickCenteredTest() {
refresh();
rippleContainer.center();
Expand All @@ -126,7 +86,7 @@ public void mouseClickCenteredTest() {
assertTrue(rippleContainer.isCentered());
}

@Test
@Test(description = "Unit test checks that when 'not-centered' - 'ripple' center is click coordinates")
public void randomMouseClickTest() {
refresh();
rippleContainer.show();
Expand Down
Loading

0 comments on commit ecb285a

Please sign in to comment.