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 25 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,69 @@
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_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");

@Test
public void basicGridListColorTest() {
gridListSection.basicGridList.get(1)
.has().css("background-color", "rgba(" + 173 + ", " + 216 + ", " + 230 + ", 1)");
}
dynamicGridList.getTiles().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(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_TRANSPARENT_038.value()))
.and().footerBackgroundColor(WHITE_TRANSPARENT_038.value())
.and().headerColor(AngularColors.fromColor(WHITE_TRANSPARENT_038.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,34 @@
package com.epam.jdi.light.angular.asserts.gridlist;

import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert;

import com.epam.jdi.light.angular.elements.complex.gridlist.GridList;
import com.epam.jdi.light.asserts.generic.UISelectAssert;
import com.epam.jdi.light.common.JDIAction;
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) {
int actualNumberOfColumns = element().cols();
jdiAssert(actualNumberOfColumns, 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'", actualNumberOfColumns, expectedCols));
return this;
}

@JDIAction("Assert that '{name}' has row's height '{0}'")
public GridListAssert rowHeight(String expectedRowHeight) {
String actualRowHeight = element().rowHeight();
jdiAssert(actualRowHeight, Matchers.is(expectedRowHeight));
return this;
}

@JDIAction("Assert that '{name}' has gutter size '{0}'")
public GridListAssert gutterSize(String expectedGutterSize) {
String actualGutterSize = element().gutterSize();
jdiAssert(actualGutterSize, Matchers.is(expectedGutterSize));
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.epam.jdi.light.angular.asserts.gridlist;

import com.epam.jdi.light.angular.elements.complex.gridlist.GridTile;
import com.epam.jdi.light.angular.elements.enums.AngularColors;
import com.epam.jdi.light.asserts.generic.ColorAssert;
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;

public class GridTileAssert extends UIAssert<GridTileAssert, GridTile> implements ColorAssert<GridTileAssert, GridTile> {

@JDIAction("Assert that '{name}' has number of columns '{0}'")
public GridTileAssert colspan(int expectedColspan) {
int actualNumberOfColumns = element().colspan();
jdiAssert(actualNumberOfColumns, Matchers.is(expectedColspan));
return this;
vklonin marked this conversation as resolved.
Show resolved Hide resolved
}

@JDIAction("Assert that '{name}' has number of rows '{0}'")
public GridTileAssert rowspan(int expectedRowspan) {
int actualNumberOfRows = element().rowspan();
jdiAssert(actualNumberOfRows, Matchers.is(expectedRowspan));
return this;
}

@JDIAction("Assert that '{name}' has text '{0}'")
public GridTileAssert text(String expectedText) {
String actualText = element().text();
jdiAssert(actualText, Matchers.is(expectedText));
return this;
}

@JDIAction("Assert that '{name}' color is '{0}'")
public GridTileAssert color(AngularColors expectedColor) {
jdiAssert(element().angularColor(), Matchers.is(expectedColor));
return this;
}

@JDIAction("Assert that '{name}' background color is '{0}'")
public GridTileAssert backgroundColor(AngularColors expectedColor) {
jdiAssert(element().angularBackgroundColor(), Matchers.is(expectedColor));
return this;
}

@JDIAction("Assert that '{name}' header color is '{0}'")
public GridTileAssert headerColor(AngularColors expectedColor) {
jdiAssert(element().headerAngularColor(), Matchers.is(expectedColor));
return this;
}

@JDIAction("Assert that '{name}' header color is '{0}'")
public GridTileAssert headerColor(String expectedColor) {
jdiAssert(element().headerColor(), Matchers.is(expectedColor));
return this;
}

@JDIAction("Assert that '{name}' header background color is '{0}'")
public GridTileAssert headerBackgroundColor(AngularColors expectedColor) {
jdiAssert(element().headerAngularBackgroundColor(), Matchers.is(expectedColor));
return this;
}

@JDIAction("Assert that '{name}' header background color is '{0}'")
public GridTileAssert headerBackgroundColor(String expectedColor) {
jdiAssert(element().headerBackgroundColor(), Matchers.is(expectedColor));
return this;
}

@JDIAction("Assert that '{name}' footer color is '{0}'")
public GridTileAssert footerColor(AngularColors expectedColor) {
jdiAssert(element().footerAngularColor(), Matchers.is(expectedColor));
return this;
}

@JDIAction("Assert that '{name}' footer color is '{0}'")
public GridTileAssert footerColor(String expectedColor) {
jdiAssert(element().footerColor(), Matchers.is(expectedColor));
return this;
}

@JDIAction("Assert that '{name}' footer background color is '{0}'")
public GridTileAssert footerBackgroundColor(AngularColors expectedColor) {
jdiAssert(element().footerAngularBackgroundColor(), Matchers.is(expectedColor));
return this;
}

@JDIAction("Assert that '{name}' footer background color is '{0}'")
public GridTileAssert footerBackgroundColor(String expectedColor) {
jdiAssert(element().footerBackgroundColor(), Matchers.is(expectedColor));
return this;
}

@JDIAction("Assert that '{name}' header text is '{0}'")
public GridTileAssert headerText(String expectedText) {
jdiAssert(element().headerText(), Matchers.is(expectedText));
return this;
}

@JDIAction("Assert that '{name}' footer text is '{0}'")
public GridTileAssert footerText(String expectedText) {
jdiAssert(element().footerText(), Matchers.is(expectedText));
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.epam.jdi.light.angular.elements.complex.gridlist;

import com.epam.jdi.light.angular.asserts.gridlist.GridListAssert;
import com.epam.jdi.light.common.JDIAction;
import com.epam.jdi.light.elements.base.UIListBase;

import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* To see an example of Grid web element please visit
* <a href="https://material.angular.io/components/grid-list/overview">Angular Grid list Web Page</a>
*/
public class GridList extends UIListBase<GridListAssert> {

@JDIAction(value = "Get '{name}' number of columns")
public int cols() {
return Integer.parseInt(core().getAttribute("cols"));
}

@JDIAction(value = "Get '{name}' row's height")
public String rowHeight() {
return core().getAttribute("rowheight");
}

@JDIAction(value = "Get '{name}' gutter size in pixels")
vklonin marked this conversation as resolved.
Show resolved Hide resolved
public String gutterSize() {
return core().getAttribute("guttersize");
}

@JDIAction(value = "Get '{name}' tile by index '{0}' (1 based index)")
public GridTile tileByIndex(int index) {
vklonin marked this conversation as resolved.
Show resolved Hide resolved
return getTiles().collect(Collectors.toList()).get(index - 1);
spbqaru marked this conversation as resolved.
Show resolved Hide resolved
vklonin marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
public GridListAssert is() {
return new GridListAssert().set(this);
}

public Stream<GridTile> getTiles() {
return core().finds(".mat-grid-tile").stream()
.map(e -> new GridTile().setCore(GridTile.class, e));
}
}
Loading