From c0c7f4ba555125559e19eaf8062247c10ab15ff0 Mon Sep 17 00:00:00 2001 From: Maya Afanaseva Date: Tue, 28 Nov 2023 15:12:18 +0200 Subject: [PATCH] 4914_cardTestsRefImageSizeAdded --- .../java/io/github/com/pages/CardPage.java | 11 ++++++ .../tests/elements/complex/CardTests.java | 14 ++++++++ .../jdi/light/angular/asserts/CardAssert.java | 8 +++++ .../light/angular/elements/complex/Card.java | 34 +++++++++++++++++-- .../angular/elements/enums/CardImageSize.java | 10 ++++++ 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CardImageSize.java diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/pages/CardPage.java b/jdi-light-angular-tests/src/main/java/io/github/com/pages/CardPage.java index 8c80f4e7a4d..c7fb4178bd2 100644 --- a/jdi-light-angular-tests/src/main/java/io/github/com/pages/CardPage.java +++ b/jdi-light-angular-tests/src/main/java/io/github/com/pages/CardPage.java @@ -19,4 +19,15 @@ public class CardPage extends NewAngularPage { @UI("#card-with-alignment-align-end") public static Card cardAlignEndActions; + @UI("#card-with-media-size-sm-image") + public static Card cardWithSmallImageSize; + + @UI("#card-with-media-size-md-image") + public static Card cardWithMediumImageSize; + + @UI("#card-with-media-size-lg-image") + public static Card cardWithLargeImageSize; + + @UI("#card-with-media-size-xl-image") + public static Card cardWithExtraLargeImageSize; } diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/CardTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/CardTests.java index e569e5b91c3..ac6a892f19c 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/CardTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/CardTests.java @@ -1,5 +1,6 @@ package io.github.epam.angular.tests.elements.complex; +import com.epam.jdi.light.angular.elements.enums.CardImageSize; import io.github.epam.TestsInit; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -9,7 +10,11 @@ import static io.github.com.pages.CardPage.card; import static io.github.com.pages.CardPage.cardAlignEndActions; import static io.github.com.pages.CardPage.cardAlignStartActions; +import static io.github.com.pages.CardPage.cardWithExtraLargeImageSize; import static io.github.com.pages.CardPage.cardWithFooter; +import static io.github.com.pages.CardPage.cardWithLargeImageSize; +import static io.github.com.pages.CardPage.cardWithMediumImageSize; +import static io.github.com.pages.CardPage.cardWithSmallImageSize; import static io.github.com.pages.CardPage.simpleCard; @@ -71,4 +76,13 @@ public void alignPositionTest() { cardAlignStartActions.show(); cardAlignStartActions.is().aligStartActions(); } + + @Test(description = "Test verifies image size of the card") + public void sizeOfCardImageTest() { + cardWithSmallImageSize.has().cardImageSize(CardImageSize.SMALL); + cardWithMediumImageSize.has().cardImageSize(CardImageSize.MEDIUM); + cardWithLargeImageSize.has().cardImageSize(CardImageSize.LARGE); + cardWithExtraLargeImageSize.has().cardImageSize(CardImageSize.EXTRALARGE); + } + } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CardAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CardAssert.java index f2ded43e3d9..7ef39cea60d 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CardAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CardAssert.java @@ -1,6 +1,7 @@ package com.epam.jdi.light.angular.asserts; import com.epam.jdi.light.angular.elements.complex.Card; +import com.epam.jdi.light.angular.elements.enums.CardImageSize; import com.epam.jdi.light.asserts.generic.UIAssert; import com.epam.jdi.light.common.JDIAction; import org.hamcrest.Matchers; @@ -45,4 +46,11 @@ public CardAssert aligStartActions() { "Card actions are in end align position"); return this; } + + @JDIAction("Assert that {name} has image '{0}' size") + public CardAssert cardImageSize( CardImageSize size) { + final CardImageSize actualCardImageSize = element().cardImageSize(); + jdiAssert(actualCardImageSize, Matchers.is(size)); + return this; + } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Card.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Card.java index afdb05576a8..1d247b27a41 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Card.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Card.java @@ -1,6 +1,12 @@ package com.epam.jdi.light.angular.elements.complex; +import static com.epam.jdi.light.angular.elements.enums.CardImageSize.EXTRALARGE; +import static com.epam.jdi.light.angular.elements.enums.CardImageSize.LARGE; +import static com.epam.jdi.light.angular.elements.enums.CardImageSize.MEDIUM; +import static com.epam.jdi.light.angular.elements.enums.CardImageSize.SMALL; + import com.epam.jdi.light.angular.asserts.CardAssert; +import com.epam.jdi.light.angular.elements.enums.CardImageSize; import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.common.UIElement; @@ -71,13 +77,37 @@ public UIElement getButtonByNumber(int number) { return this.getButtons().get(number); } - @JDIAction("Get if {nave} has align end actions") + @JDIAction("Get if {name} has align end actions") public boolean actionsEndAlign() { - return finds("mat-card-actions").hasClass("mat-mdc-card-actions-align-end"); + return finds("mat-card-actions") + .hasClass("mat-mdc-card-actions-align-end"); + } + + @JDIAction("Get '{name}' size") + public CardImageSize cardImageSize() { + UIElement e = core().find("//img"); + if (e.hasClass("mat-mdc-card-xl-image")) { + return EXTRALARGE; + } + if (e.hasClass("mat-mdc-card-lg-image")) { + return LARGE; + } + if (e.hasClass("mat-mdc-card-md-image")) { + return MEDIUM; + } + if (e.hasClass("mat-mdc-card-sm-image")) { + return SMALL; + } + return CardImageSize.UNKNOWN; } @Override public CardAssert is() { return new CardAssert().set(this); } + + @Override + public CardAssert has() { + return is(); + } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CardImageSize.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CardImageSize.java new file mode 100644 index 00000000000..485016f3ba8 --- /dev/null +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CardImageSize.java @@ -0,0 +1,10 @@ +package com.epam.jdi.light.angular.elements.enums; + +public enum CardImageSize { + + EXTRALARGE, + LARGE, + MEDIUM, + SMALL, + UNKNOWN; +}