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

4952 + 4964: Angular grid list class implementation and refactoring tests #5085

Open
wants to merge 37 commits into
base: angular_rework_development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a18ae08
add grid list implementation and refactor tests
b14ckster Jun 27, 2023
95a1554
add grid list implementation and add tests
b14ckster Jun 28, 2023
e32700e
refactor code
b14ckster Jul 10, 2023
eac88c8
refactor code and implement using new page
b14ckster Jul 12, 2023
854d3a2
implement grid list class and refactor tests
b14ckster Jul 13, 2023
4478d36
refactor imports and enum
b14ckster Jul 14, 2023
260fab6
refactor unit tests
b14ckster Jul 14, 2023
dc4d9c9
refactor tests and Element Object
b14ckster Sep 26, 2023
e407e9b
hot fix Colors
b14ckster Sep 26, 2023
dd6abf5
grid list tests refactoring
b14ckster Sep 26, 2023
f2f26c5
refactor asserts
b14ckster Oct 13, 2023
b2d62cd
4952-64-refactoringGridListAfterRebase
MayaElf Oct 18, 2023
b2f8717
4952-64-refactoringGridListAfterRebase
MayaElf Oct 18, 2023
5be7585
Merge branch 'angular_rework_development' into angular_grid_list_clas…
AlinaLysenko Nov 29, 2023
32ebfa6
Merge branch 'angular_rework_development' into angular_grid_list_clas…
AlinaLysenko Dec 5, 2023
d1f6926
gridTile implemented with header, footer and avatar
AlinaLysenko Dec 11, 2023
13595b0
changed cell to tile in naming
AlinaLysenko Dec 11, 2023
fe09856
Merge branch 'angular_rework_development' into angular_grid_list_clas…
AlinaLysenko Dec 21, 2023
c42148a
fixed comments
AlinaLysenko Dec 22, 2023
fa15251
removed unused imports
AlinaLysenko Dec 22, 2023
34b2f5e
Merge branch 'angular_rework_development' into angular_grid_list_clas…
AlinaLysenko Dec 22, 2023
c20c5d8
added background colors
AlinaLysenko Dec 26, 2023
763b7b9
text method updated
AlinaLysenko Jan 4, 2024
473ff98
Merge branch 'angular_rework_development' into angular_grid_list_clas…
AlinaLysenko Jan 4, 2024
7125245
option to implement extending UIListBase
AlinaLysenko Jan 4, 2024
1aa6a2d
removed creating variables for actual values for asserts
AlinaLysenko Jan 5, 2024
42db430
added getting footer and header as uiElement. No extra asserts added
AlinaLysenko Jan 5, 2024
f219d10
fixed text colors and added names for tiles
AlinaLysenko Jan 16, 2024
2aab439
Merge branch 'angular_rework_development' into angular_grid_list_clas…
AlinaLysenko Jan 18, 2024
7720301
added get content option, removed "in pixels" and changed tileByIngex…
AlinaLysenko Feb 2, 2024
bb6f030
removed content option, and separated getting tiles in stream and list
AlinaLysenko Feb 2, 2024
b67c3ba
added assertions for grid list and test examples for it
AlinaLysenko Feb 8, 2024
1f0dd27
removed methods itemsWithTexts and textsInItems
AlinaLysenko Feb 8, 2024
9eb0550
Update jdi-light-angular/src/main/java/com/epam/jdi/light/angular/ass…
vklonin Feb 9, 2024
eae91ea
Update jdi-light-angular-tests/src/test/java/io/github/epam/angular/t…
vklonin Feb 9, 2024
969e802
added custom tile, fixed empty matcher, removed mismatch message
AlinaLysenko Feb 13, 2024
50a42ae
Merge remote-tracking branch 'origin/angular_grid_list_class_implemen…
AlinaLysenko Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.github.com.pages.ProgressSpinnerPage;
import io.github.com.pages.RadioButtonPage;
import io.github.com.pages.SlideTogglePage;
import io.github.com.pages.GridListPage;

@JSite("https://jdi-testing.github.io/jdi-light/angular-page/#/")
public class StaticSite {
Expand All @@ -36,6 +37,9 @@ public class StaticSite {
@Url("badges")
public static BadgePage badgePage;

@Url("grid_list")
public static GridListPage gridListPage;

@Url("buttons_toggle")
public static ButtonTogglePage buttonTogglePage;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public enum Colors {
RED_ACCENT_3("rgba(255, 23, 68, 1)"),
RED_ACCENT_4("rgba(213, 0, 0, 1)"),
PINK("rgba(233, 30, 99, 1)"),
LIGHT_PINK("rgba(255, 182, 193, 1)"),
PINK_LIGHTEN_5("rgba(252, 228, 236, 1)"),
PINK_LIGHTEN_4("rgba(248, 187, 208, 1)"),
PINK_LIGHTEN_3("rgba(244, 143, 177, 1)"),
Expand Down Expand Up @@ -90,6 +91,7 @@ public enum Colors {
BLUE_ACCENT_5("rgba(138, 197, 255, 1)"),
BLUE_ACCENT_6("rgb(25, 118, 210)"),
LIGHT_BLUE("rgba(3, 169, 244, 1)"),
LIGHT_BLUE_2("rgba(173, 216, 230, 1)"),
LIGHT_BLUE_LIGHTEN_5("rgba(225, 245, 254, 1)"),
LIGHT_BLUE_LIGHTEN_4("rgba(179, 229, 252, 1)"),
LIGHT_BLUE_LIGHTEN_3("rgba(129, 212, 250, 1)"),
Expand Down Expand Up @@ -148,6 +150,7 @@ public enum Colors {
GREEN_ACCENT_4("rgba(0, 200, 83, 1)"),
GREEN_ACCENT_5("rgb(76, 175, 80)"),
LIGHT_GREEN("rgba(139, 195, 74, 1)"),
LIGHT_GREEN_2("rgba(144, 238, 144, 1)"),
LIGHT_GREEN_LIGHTEN_5("rgba(241, 248, 233, 1)"),
LIGHT_GREEN_LIGHTEN_4("rgba(220, 237, 200, 1)"),
LIGHT_GREEN_LIGHTEN_3("rgba(197, 225, 165, 1)"),
Expand Down Expand Up @@ -274,6 +277,7 @@ public enum Colors {
WHITE_TRANSPARENT_087("rgba(255, 255, 255, 0.87)"),
WHITE_TRANSPARENT_038("rgba(0, 0, 0, 0.38)"),
RED_TRANSPARENT_055("rgba(244, 67, 54, 0.55)"),
LIGHT_LILAC("rgba(221, 189, 241, 1)"),
TRANSPARENT("rgba(0, 0, 0, 0)");

private final String rgba;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
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.GridListSection;
import io.github.com.pages.sections.ListSection;
import io.github.com.pages.sections.SnackbarSection;
import io.github.com.pages.sections.TabGroupSection;
Expand All @@ -21,7 +20,6 @@ public class AngularPage extends WebPage {
public static BottomSheet bottomSheet;
public static Dialog dialog;
public static ListSection listSection;
public static GridListSection gridListSection;
public static SnackbarSection snackbarSection;
public static TabGroupSection tabsSection;
public static TableSection tableSection;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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;

public class GridListPage extends NewAngularPage {

@UI("#dynamic-grid-list")
public static GridList dynamicGridList;
}

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 com.epam.jdi.light.elements.interfaces.base.ICoreElement;
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;

// 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)
.each(ICoreElement::isVisible)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

стиль кода поехал, давайте единообразно писать

.noOne(e -> e.text().equals("Zero"))
.onlyOne(e -> e.text().equals("One"))
.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)
.is().text("One")
vklonin marked this conversation as resolved.
Show resolved Hide resolved
.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);

dynamicGridList.tileByIndex(2).find(".avatar-img").is()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не надо вот такое писать, кастомный локатор в тесте - плохая практика, мы тут пытаемся показать, как это используется правильно.
правильный метод - сделать кастомный tile с валидатором

.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,114 @@
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.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("Assert that '{name}' has number of columns '{0}'")
vklonin marked this conversation as resolved.
Show resolved Hide resolved
public GridListAssert cols(int expectedCols) {
jdiAssert(element().cols(), Matchers.is(expectedCols),
String.format("\nActual number of columns in Grid List: '%s'\n" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

стандартное сообщение матчера нормальное, к нему все привыкли

"is not equal to expected: '%s'", element().cols(), 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().isEmpty(), Matchers.is(true), "List is not empty");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • есть матчер для пустой коллекции
  • сообщение List is not empty не понятно, какой такой лист? мы tile проверяем, вот и написать, что tile есть или нет

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().isEmpty(), Matchers.is(false), "List is 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");
Copy link
Contributor

Choose a reason for hiding this comment

The 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;
}
}
Loading