Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Bulavin committed Nov 20, 2023
1 parent c8fdb1e commit 9a846af
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 263 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.epam.angular.tests.elements.complex;

import com.epam.jdi.light.angular.elements.enums.AngularColors;
import io.github.com.pages.ChipsPage;
import io.github.epam.TestsInit;
import org.testng.annotations.BeforeMethod;
Expand All @@ -12,8 +13,10 @@
import static com.jdiai.tools.Timer.waitCondition;
import static io.github.com.StaticSite.chipsPage;
import static io.github.com.pages.ChipsPage.autocompleteChips;
import static io.github.com.pages.ChipsPage.avatarChips;
import static io.github.com.pages.ChipsPage.basicChips;
import static io.github.com.pages.ChipsPage.disabledChips;
import static io.github.com.pages.ChipsPage.errorChips;
import static io.github.com.pages.ChipsPage.inputChips;
import static io.github.com.pages.ChipsPage.multipleChips;
import static io.github.com.pages.ChipsPage.stackedChips;
Expand Down Expand Up @@ -43,7 +46,7 @@ public void before() {
chipsPage.checkOpened();
}

@Test
@Test(description = "Test verifies that chip group is selectable")
public void basicChipsTest() {
basicChips.show();
basicChips.is().displayed();
Expand All @@ -54,7 +57,7 @@ public void basicChipsTest() {
ChipsPage.basicSelectedValue.has().text(format("You clicked: %s", WARNFISH));
}

@Test
@Test(description = "Test verifies that chip group is vertical")
public void stackedChipsTest() {
stackedChips.show();
stackedChips.is().displayed();
Expand All @@ -67,32 +70,39 @@ public void stackedChipsTest() {
stackedSelectedValue.has().text(format("You clicked: %s", WARN));
}

@Test
@Test(description = "Test check chips colors")
public void chipsColorTest() {
stackedChips.show();
stackedChips.is().displayed();
stackedChips.getElement(PRIMARY).is().color(AngularColors.MAT_PRIMARY);
stackedChips.getElement(ACCENT).is().color(AngularColors.MAT_ACCENT);
stackedChips.getElement(WARN).is().color(AngularColors.MAT_WARN);
}

@Test(description = "Test checks the operation of the autocomplete in chips group")
public void chipsAutocompleteTest() {
String[] expectedValuesArray = {
"Apple", "Lemon", "Lime", "Orange", "Strawberry"};
List<String> expectedValues = Arrays.asList(expectedValuesArray);

autocompleteChips.show();
autocompleteChips.is().displayed();
autocompleteChips.has().assertChipsHasPlaceholder("New Fruit...");
autocompleteChips.has().assertChipsHasOptions(expectedValues);
autocompleteChips.has().placeholder("New Fruit...");
autocompleteChips.has().options(expectedValues);

autocompleteChips.setValue(LEMON);
autocompleteChips.select(LEMON);
autocompleteChips.collapseField();
autocompleteChips.is().hasElement(LEMON);
autocompleteChips.setValue(APPLE);
autocompleteChips.select(APPLE);
autocompleteChips.collapseField();
autocompleteChips.is().hasElement(APPLE);
autocompleteChips.setValue(LIME);
autocompleteChips.collapseField();
autocompleteChips.is().hasElement(LIME);
}

@Test
@Test(description = "Test checks the input field in chips group")
public void chipsWithInputTest() {
inputChips.show();
inputChips.is().displayed();
inputChips.has().assertChipsHasPlaceholder(PLACEHOLDER);
inputChips.has().placeholder(PLACEHOLDER);
inputChips.input("Kiwi" + "\n");
inputChips.input("Melon");
inputChips.clearInputField();
Expand All @@ -101,24 +111,39 @@ public void chipsWithInputTest() {
inputChips.is().hasElement("Rockmelon");
}

@Test
@Test(description = "Test checks that chips can be removed")
public void chipsRemovableTest() {
inputChips.show();
inputChips.is().displayed();
inputChips.getElement("Lemon").is().removable();
inputChips.getElement("Lemon").close();
inputChips.getElement("Lemon");
}

@Test
public void chipDisabledTest() {
disabledChips.groupElements().get(0).is().disabled();
disabledChips.groupElements().get(1).is().disabled();
disabledChips.groupElements().get(2).is().disabled();
@Test(description = "Test checks that chips can be focused")
public void chipFocusedTest() {
inputChips.show();
inputChips.is().displayed();
inputChips.getElement("Apple").click();
inputChips.getElement("Apple").is().focused();
inputChips.getElement("Lime").click();
inputChips.getElement("Lime").is().focused();
}

@Test(description = "Test checks that chips has avatar image")
public void chipAvatarTest() {
String expectedSrc = "https://material.angular.io/assets/img/examples/shiba1.jpg";
avatarChips.show();
avatarChips.getElement("Dog one").leadingIcon().is().src(expectedSrc);
}

@Test
@Test(description = "Test checks that chips can be disabled")
public void chipDisabledTest() {
disabledChips.show();
disabledChips.is().displayed();
disabledChips.is().disabled();
}

@Test(description = "Test checks chips multiply selection")
public void chipsMultipleSelectionTest() {
multipleChips.show();
multipleChips.is().displayed();
Expand All @@ -128,4 +153,12 @@ public void chipsMultipleSelectionTest() {
multipleChips.getElement("multiple color none").is().selected();
multipleChips.getElement("multiple color Primary").is().selected();
}

@Test(description = "Test checks that chips has error state")
public void chipsErrorState() {
errorChips.show();
errorChips.is().displayed();
errorChips.input("Kiwi" + "\n");
errorChips.has().errorState();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.epam.jdi.light.angular.asserts;

import com.epam.jdi.light.angular.elements.common.Chip;
import com.epam.jdi.light.angular.elements.enums.AngularColors;
import com.epam.jdi.light.asserts.generic.UIAssert;
import com.epam.jdi.light.common.JDIAction;
import org.hamcrest.Matchers;
Expand All @@ -9,16 +10,26 @@

public class ChipAssert extends UIAssert<ChipAssert, Chip> {

@JDIAction("Assert that '{name}' enabled")
@JDIAction("Assert that '{name}' is enabled")
public ChipAssert selected() {
jdiAssert(element().selected(), Matchers.is(true));
return this;
}

@JDIAction("Assert that '{name}' ")
@JDIAction("Assert that '{name}' is removable ")
public ChipAssert removable() {
jdiAssert(element().removable(), Matchers.is(true));
return this;
}

@JDIAction("Assert that '{name}' has '{0}' color")
public ChipAssert color(AngularColors color) {
return cssClass(color.getColor());
}

@JDIAction("Assert that '{name}' is focused ")
public ChipAssert focused() {
jdiAssert(element().focused(), Matchers.is(true));
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,53 @@

public class ChipGroupAssert extends UIAssert<ChipGroupAssert, ChipGroup> {

@JDIAction("")
public ChipGroupAssert vertical(){
jdiAssert(element().getOrientation(), Matchers.is("vertical"));
@Override
@JDIAction("Assert that '{name}' is displayed")
public ChipGroupAssert displayed() {
jdiAssert(element().isDisplayed() ? "displayed" : "hidden", Matchers.is("displayed"));
return this;
}

@Override
@JDIAction("Assert that '{name}' is enabled")
public ChipGroupAssert enabled() {
jdiAssert(element().isEnabled() ? "enabled" : "disabled", Matchers.is("enabled"));
return this;
}

@JDIAction("Assert that '{name}' aria-orientation is vertical")
public ChipGroupAssert vertical() {
jdiAssert(element().isVertical(), Matchers.is(true));
return this;
}

@JDIAction("Assert that '{name}' has placeholder '{0}'")
public ChipGroupAssert assertChipsHasPlaceholder(String expected) {
public ChipGroupAssert placeholder(String expected) {
jdiAssert(element().getPlaceholderForChips(), Matchers.is(expected));
return this;
}

@JDIAction("Assert that '{name}' has options")
public ChipGroupAssert assertChipsHasOptions(List<String> options) {
public ChipGroupAssert options(List<String> options) {
jdiAssert(element().options(), Matchers.is(options));
return this;
}

@JDIAction("Assert that '{name}' has multiple select options")
public ChipGroupAssert multiselectable() {
jdiAssert(element().isMultiselectable(), Matchers.is("true"));
jdiAssert(element().multiselectable(), Matchers.is("true"));
return this;
}

@JDIAction("Assert that '{name}' has '{0}' element")
public ChipGroupAssert hasElement(String expected) {
jdiAssert(element().hasElement(expected), Matchers.is(true));
return this;
}

@JDIAction("Assert that '{name}' is displayed")
public ChipGroupAssert displayed() {
jdiAssert(element().isDisplayed() ? "displayed" : "hidden", Matchers.is("displayed"));
@JDIAction("Assert that '{name}' has error state")
public ChipGroupAssert errorState() {
jdiAssert(element().errorState(), Matchers.is(true));
return this;
}


}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,49 @@
import com.epam.jdi.light.common.JDIAction;
import com.epam.jdi.light.elements.base.UIBaseElement;
import com.epam.jdi.light.elements.interfaces.base.HasClick;
import com.epam.jdi.light.ui.html.elements.common.Image;

public class Chip extends UIBaseElement<ChipAssert> implements HasClick, HasColor, HasIcon, HasImage {


@JDIAction("Get if '{name} is selected'")
public boolean selected() {
return hasClass("mat-mdc-chip-selected");
}

@JDIAction("Close '{name}'")
public void close() {
find("matChipRemove").click();
find("[matChipRemove]").click();
}

@JDIAction("Get if '{name}' is removable")
public boolean removable() {
return hasAttribute("matchipremove");
return find("[matChipRemove]").isDisplayed();
}

@JDIAction("Get if '{name}' background-color")
public String getBackgroundColor() {
return css("background-color");
}

@JDIAction("Get if '{name} is focused'")
public boolean focused() {
return hasClass("cdk-focused");
}

@JDIAction("Get if '{name} is selected'")
public boolean selected() {
return hasClass("mat-mdc-chip-selected");
}

@JDIAction("Get if '{name} checkmark is visible'")
public boolean showCheckMark() {
return find("mdc-evolution-chip__checkmark").isVisible();
}

@JDIAction("Get '{name} label text")
public String getText() {
return find(".mdc-evolution-chip__text-label").getText();
}

public void click() {
core().click();
@JDIAction("Get '{name} avatar image")
public Image leadingIcon() {
return new Image().setCore(Image.class, find("[matchipavatar]"));
}

@Override
Expand Down
Loading

0 comments on commit 9a846af

Please sign in to comment.