-
Notifications
You must be signed in to change notification settings - Fork 48
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
4952 + 4964: Angular grid list class implementation and refactoring tests #5085
base: angular_rework_development
Are you sure you want to change the base?
Changes from all commits
a18ae08
95a1554
e32700e
eac88c8
854d3a2
4478d36
260fab6
dc4d9c9
e407e9b
dd6abf5
f2f26c5
b2d62cd
b2f8717
5be7585
32ebfa6
d1f6926
13595b0
fe09856
c42148a
fa15251
34b2f5e
c20c5d8
763b7b9
473ff98
7125245
1aa6a2d
42db430
f219d10
2aab439
7720301
bb6f030
b67c3ba
1f0dd27
9eb0550
eae91ea
969e802
50a42ae
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,11 @@ | ||
package io.github.com.custom.elements; | ||
|
||
import com.epam.jdi.light.angular.elements.complex.gridlist.GridTile; | ||
import com.epam.jdi.light.elements.common.UIElement; | ||
import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; | ||
|
||
public class CustomGridTileWithImage extends GridTile { | ||
|
||
@UI("#dynamic-grid-item-avatar") | ||
public UIElement image; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.github.com.pages; | ||
|
||
import com.epam.jdi.light.angular.elements.complex.gridlist.GridList; | ||
import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; | ||
import io.github.com.custom.elements.CustomGridTileWithImage; | ||
|
||
public class GridListPage extends NewAngularPage { | ||
|
||
@UI("#dynamic-grid-list") | ||
public static GridList dynamicGridList; | ||
|
||
@UI("#dynamic-grid-list-two") | ||
public static CustomGridTileWithImage tileWithImage; | ||
} |
This file was deleted.
vklonin marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,80 @@ | ||
package io.github.epam.angular.tests.elements.complex; | ||
|
||
import com.epam.jdi.light.angular.elements.enums.AngularColors; | ||
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.gridListSection; | ||
import static io.github.epam.site.steps.States.shouldBeLoggedIn; | ||
import static io.github.com.enums.Colors.BLACK_TRANSPARENT_087; | ||
import static io.github.com.enums.Colors.LIGHT_GREEN_2; | ||
import static io.github.com.enums.Colors.LIGHT_LILAC; | ||
import static com.jdiai.tools.Timer.waitCondition; | ||
import static io.github.com.StaticSite.gridListPage; | ||
|
||
import static io.github.com.enums.Colors.LIGHT_PINK; | ||
import static io.github.com.enums.Colors.WHITE; | ||
import static io.github.com.enums.Colors.WHITE_TRANSPARENT_038; | ||
import static io.github.com.pages.GridListPage.dynamicGridList; | ||
import static io.github.com.pages.GridListPage.tileWithImage; | ||
|
||
// TODO Move to the new page | ||
@Ignore | ||
public class GridListTests extends TestsInit { | ||
|
||
@BeforeMethod | ||
@BeforeClass | ||
public void before() { | ||
shouldBeLoggedIn(); | ||
angularPage.shouldBeOpened(); | ||
gridListPage.open(); | ||
waitCondition(() -> gridListPage.isOpened()); | ||
gridListPage.checkOpened(); | ||
} | ||
|
||
@Test | ||
public void basicGridListBasicTest() { | ||
gridListSection.basicGridList.is().displayed(); | ||
} | ||
@Test(description = "Test checks dynamic grid list attributes") | ||
public void dynamicGridListTest() { | ||
dynamicGridList.shouldBe().displayed(); | ||
dynamicGridList.show(); | ||
dynamicGridList.shouldBe().visible(); | ||
|
||
@Test | ||
public void basicGridListTextTest() { | ||
gridListSection.basicGridList.get(1).is().text("1"); | ||
} | ||
dynamicGridList.has().cols(4) | ||
.and().rowHeight("100px") | ||
.and().gutterSize("10px") | ||
.and().notEmpty() | ||
.and().size(4) | ||
.and().each(e -> e.isVisible()) | ||
.and().noOne(e -> e.text().equals("Zero")) | ||
.and().onlyOne(e -> e.text().equals("One")) | ||
.and().any(e -> e.rowspan() == 1); | ||
|
||
@Test | ||
public void basicGridListColorTest() { | ||
gridListSection.basicGridList.get(1) | ||
.has().css("background-color", "rgba(" + 173 + ", " + 216 + ", " + 230 + ", 1)"); | ||
} | ||
dynamicGridList.tiles().forEach(e -> e.is().visible()); | ||
|
||
@Test | ||
public void dynamicGridListBasicTest() { | ||
gridListSection.dynamicGridList.is().displayed(); | ||
} | ||
dynamicGridList.tileByIndex(1) | ||
.has().text("One") | ||
.and().colspan(3) | ||
.and().rowspan(1); | ||
|
||
@Test | ||
public void dynamicGridListTextTest() { | ||
gridListSection.dynamicGridList.get(1).is().text("One"); | ||
} | ||
dynamicGridList.tileByIndex(2) | ||
.is().color(AngularColors.fromColor(LIGHT_GREEN_2.value())) | ||
.and().colspan(1) | ||
.and().rowspan(2); | ||
|
||
tileWithImage.image.is() | ||
.attr("src","https://material.angular.io/assets/img/examples/shiba2.jpg"); | ||
|
||
dynamicGridList.tileByIndex(3) | ||
.is().colspan(1) | ||
.and().rowspan(1) | ||
.and().backgroundColor(LIGHT_PINK.value()) | ||
.and().backgroundColor(AngularColors.fromColor(LIGHT_PINK.value())) | ||
.and().color(BLACK_TRANSPARENT_087.value()) | ||
.and().color(AngularColors.fromColor(BLACK_TRANSPARENT_087.value())) | ||
.and().footerColor(AngularColors.fromColor(WHITE.value())) | ||
.and().footerBackgroundColor(WHITE_TRANSPARENT_038.value()) | ||
.and().headerColor(WHITE.value()) | ||
.and().headerBackgroundColor(AngularColors.fromColor(WHITE_TRANSPARENT_038.value())) | ||
.and().text("Mat Grid Header\nThree\nMat Grid Footer") | ||
.and().footerText("Mat Grid Footer") | ||
.and().headerText("Mat Grid Header"); | ||
|
||
@Test | ||
public void dynamicGridListColorTest() { | ||
gridListSection.dynamicGridList.get(1) | ||
.has().css("background-color", "rgba(" + 173 + ", " + 216 + ", " + 230 + ", 1)"); | ||
gridListSection.dynamicGridList.get(2) | ||
.has().css("background-color", "rgba(" + 144 + ", " + 238 + ", " + 144 + ", 1)"); | ||
gridListSection.dynamicGridList.get(3) | ||
.has().css("background-color", "rgba(" + 255 + ", " + 182 + ", " + 193 + ", 1)"); | ||
gridListSection.dynamicGridList.get(4) | ||
.has().css("background-color", "rgba(" + 221 + ", " + 189 + ", " + 241 + ", 1)"); | ||
dynamicGridList.tileByIndex(4) | ||
.is().text("Four") | ||
.and().color(AngularColors.fromColor(LIGHT_LILAC.value())) | ||
.and().colspan(2); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package com.epam.jdi.light.angular.asserts.gridlist; | ||
|
||
import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; | ||
import static com.jdiai.tools.LinqUtils.first; | ||
import static com.jdiai.tools.LinqUtils.single; | ||
import static org.hamcrest.Matchers.not; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
import static org.hamcrest.Matchers.nullValue; | ||
|
||
import com.epam.jdi.light.angular.elements.complex.gridlist.GridList; | ||
import com.epam.jdi.light.angular.elements.complex.gridlist.GridTile; | ||
import com.epam.jdi.light.asserts.generic.UISelectAssert; | ||
import com.epam.jdi.light.common.JDIAction; | ||
import com.jdiai.tools.LinqUtils; | ||
import com.jdiai.tools.func.JFunc1; | ||
import org.hamcrest.Matchers; | ||
|
||
public class GridListAssert extends UISelectAssert<GridListAssert, GridList> { | ||
vklonin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@JDIAction(value = "Assert that '{name}' has number of columns '{0}'", isAssert = true) | ||
public GridListAssert cols(int expectedCols) { | ||
jdiAssert(element().cols(), Matchers.is(expectedCols)); | ||
return this; | ||
} | ||
|
||
@JDIAction("Assert that '{name}' has row's height '{0}'") | ||
public GridListAssert rowHeight(String expectedRowHeight) { | ||
jdiAssert(element().rowHeight(), Matchers.is(expectedRowHeight)); | ||
return this; | ||
} | ||
|
||
@JDIAction("Assert that '{name}' has gutter size '{0}'") | ||
public GridListAssert gutterSize(String expectedGutterSize) { | ||
jdiAssert(element().gutterSize(), Matchers.is(expectedGutterSize)); | ||
return this; | ||
} | ||
|
||
/** | ||
* Checks that Grid List has given size. | ||
* | ||
* @param size expected size | ||
* @return the same assert for chaining | ||
*/ | ||
@JDIAction(value = "Assert that '{name}' has size {0}", isAssert = true) | ||
public GridListAssert size(int size) { | ||
jdiAssert(element().tiles().size(), Matchers.is(size)); | ||
return this; | ||
} | ||
|
||
/** | ||
* Checks that Grid List is empty. | ||
* @return the same assert for chaining | ||
*/ | ||
@JDIAction(value = "Assert that '{name}' is empty", isAssert = true) | ||
public GridListAssert empty() { | ||
jdiAssert(element().tiles(), Matchers.empty()); | ||
return this; | ||
} | ||
|
||
/** | ||
* Checks that Grid List is not empty. | ||
* @return the same assert for chaining | ||
*/ | ||
@JDIAction(value = "Assert that '{name}' is not empty", isAssert = true) | ||
public GridListAssert notEmpty() { | ||
jdiAssert(element().tiles(), not(Matchers.empty())); | ||
return this; | ||
} | ||
|
||
/** | ||
* Check that all elements meet condition | ||
* @param condition to compare | ||
* @return DataListAssert | ||
*/ | ||
@JDIAction("Assert that each of '{name}' elements meet condition") | ||
public GridListAssert each(JFunc1<GridTile, Boolean> condition) { | ||
jdiAssert(LinqUtils.all(element().tiles(), condition::execute), Matchers.is(true), "Not all elements meet condition"); | ||
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. я может что-то не поняла, а почему мы не используем Matcher.allOf и с матчером внутри? |
||
return this; | ||
} | ||
|
||
/** | ||
* Check that at least one element meets condition | ||
* @param condition to compare | ||
* @return DataListAssert | ||
*/ | ||
@JDIAction("Assert that any of '{name}' elements meet condition") | ||
public GridListAssert any(JFunc1<GridTile, Boolean> condition) { | ||
jdiAssert(LinqUtils.any(element().tiles(), condition::execute), Matchers.is(true), "None of elements meets condition"); | ||
return this; | ||
} | ||
|
||
/** | ||
* Check that only one of elements meets condition | ||
* @param condition to compare | ||
* @return DataListAssert | ||
*/ | ||
@JDIAction("Assert that only one of '{name}' elements meet condition") | ||
public GridListAssert onlyOne(JFunc1<GridTile, Boolean> condition) { | ||
jdiAssert(single(element().tiles(), condition::execute), Matchers.is(notNullValue())); | ||
return this; | ||
} | ||
|
||
/** | ||
* Check that none of elements meets condition | ||
* @param condition to compare | ||
* @return DataListAssert | ||
*/ | ||
@JDIAction("Assert that none of '{name}' meet condition") | ||
public GridListAssert noOne(JFunc1<GridTile, Boolean> condition) { | ||
jdiAssert(first(element().tiles(), condition::execute), Matchers.is(nullValue())); | ||
return this; | ||
} | ||
} |
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.
я скоро добавлю в checkstyle условие, чтобы никто не писал, что image имеет тип UIElement