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

4916 refactor chips element #5111

Open
wants to merge 13 commits into
base: angular_rework_development
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.github.com.pages.ButtonTogglePage;
import io.github.com.pages.ButtonsPage;
import io.github.com.pages.CheckBoxPage;
import io.github.com.pages.ChipsPage;
import io.github.com.pages.ProgressBarPage;
import io.github.com.pages.ProgressSpinnerPage;
import io.github.com.pages.RadioButtonPage;
Expand Down Expand Up @@ -41,4 +42,7 @@ public class StaticSite {

@Url("checkbox")
public static CheckBoxPage checkBoxPage;

@Url("chips")
public static ChipsPage chipsPage;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.github.com.custom.elements;

import com.epam.jdi.light.angular.elements.complex.AutoComplete;
import com.epam.jdi.light.angular.elements.complex.ChipGroup;
import com.epam.jdi.light.common.JDIAction;

public class ChipGroupWithAutocomlete extends ChipGroup {

@JDIAction("Get '{name}' input field")
public AutoComplete inputField() {
return new AutoComplete().setCore(AutoComplete.class, find("input"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class AngularPage extends WebPage {
public static SideNavSection sidenavSection;
public static ExpansionPanelSection expansionPanelSection;
public static SortingOverviewSection sortingOverviewSection;
public static ChipsSection chipsSection;
public static TableSection tableSection;
public static DividerSection dividerSection;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package io.github.com.pages;

import com.epam.jdi.light.angular.elements.complex.ChipGroup;
import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI;
import com.epam.jdi.light.ui.html.elements.common.Text;
import io.github.com.custom.elements.ChipGroupWithAutocomlete;

public class ChipsPage extends NewAngularPage {

@UI("#basic-chips-row")
public static ChipGroup basicChips;

@UI("#stacked-chips-list")
public static ChipGroup stackedChips;

@UI("#chips-autocomplete-field")
public static ChipGroupWithAutocomlete autocompleteChips;

@UI("#chips-with-input-field")
public static ChipGroupWithAutocomlete inputChips;

@UI("#chips-with-form-control")
public static ChipGroup formControlChips;

@UI("#chips-drag-and-drop")
public static ChipGroup dragAndDropChips;

@UI("#chips-avatar")
public static ChipGroup avatarChips;

@UI("#chips-disabled-ripple")
public static ChipGroup disabledRippleChips;

@UI("#chips-enabled-ripple")
public static ChipGroup enabledRippleChips;

@UI("#chips-disabled")
public static ChipGroup disabledChips;

@UI("#chips-highlighted")
public static ChipGroup highlightedChips;
NewerNaigil marked this conversation as resolved.
Show resolved Hide resolved

@UI("#multiple-chips")
public static ChipGroup multipleChips;

@UI("#chips-with-error-state")
public static ChipGroupWithAutocomlete errorChips;

@UI("#basic-chips-label")
public static Text basicSelectedValue;

@UI("#stacked-chips-label")
public static Text stackedSelectedValue;

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,98 +1,187 @@
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;
import org.testng.annotations.Ignore;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.util.Arrays;
import java.util.List;

import static com.jdiai.tools.StringUtils.format;
import static io.github.com.StaticSite.angularPage;
import static io.github.com.pages.sections.ChipsSection.*;
import static io.github.epam.site.steps.States.shouldBeLoggedIn;
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.highlightedChips;
import static io.github.com.pages.ChipsPage.inputChips;
import static io.github.com.pages.ChipsPage.multipleChips;
import static io.github.com.pages.ChipsPage.stackedChips;

// TODO Move to the new page
@Ignore
public class ChipsTests extends TestsInit {

private static final String ONEFISH = "One fish";
private static final String TWOFISH = "Two fish";
private static final String PRIMARYFISH = "Primary fish";
private static final String ACCENTFISH = "Accent fish";
private static final String WARNFISH = "Warn fish";

private static final String NONE = "none";
private static final String PRIMARY = "Primary";
private static final String ACCENT = "Accent";
private static final String WARN = "Warn";

private static final String PLACEHOLDER = "New fruit...";
private static final String APPLE = "Apple";
private static final String LEMON = "Lemon";
private static final String LIME = "Lime";
private static final String KIWI = "Kiwi";
private static final String ROCKMELON = "Rockmelon";
private static final String MELON = "Melon";


@BeforeMethod(alwaysRun = true)
@BeforeClass
public void before() {
NewerNaigil marked this conversation as resolved.
Show resolved Hide resolved
shouldBeLoggedIn();
angularPage.shouldBeOpened();
chipsPage.open();
waitCondition(() -> chipsPage.isOpened());
chipsPage.checkOpened();
}

@Test
@Test(description = "Test verifies that chip group is selectable")
public void basicChipsTest() {
basicChipsRow.show();
basicChipsRow.is().displayed();
basicChipsRow.is().assertChipsIsEnabled();
basicChipsRow.clickChipsByTextValue(ONEFISH);
basicChipsRow.clickChipsByTextValue(TWOFISH);
basicChipsRow.clickChipsByTextValue(PRIMARYFISH);
basicChipsRow.clickChipsByTextValue(ACCENTFISH);

basicSelectedValue.has().text(format("You clicked: %s", ACCENTFISH));
basicChips.show();
basicChips.is().displayed().and().enabled();
basicChips.selectByText(TWOFISH);
basicChips.getElement(TWOFISH).is().selected();
basicChips.selectByText(WARNFISH);
basicChips.getElement(WARNFISH).is().selected();

ChipsPage.basicSelectedValue.has().text(format("You clicked: %s", WARNFISH));
}

@Test
@Test(description = "Test verifies that chip group is vertical")
public void stackedChipsTest() {
stackedChipsList.show();
stackedChipsList.is().displayed();
stackedChipsList.is().assertChipsIsEnabled();
stackedChipsList.clickChipsByTextValue(NONE);
stackedChipsList.clickChipsByTextValue(PRIMARY);
stackedChipsList.clickChipsByTextValue(ACCENT);
stackedChipsList.clickChipsByTextValue(WARN);
stackedChips.show();
stackedChips.is().displayed().and().vertical();
}

@Test(description = "Test verifies that chip group is not vertical")
public void horizontalChipsTest() {
basicChips.show();
basicChips.is().displayed().and().notVertical();
}

@Test(description = "Test check chips colors")
public void chipsColorTest() {
highlightedChips.show();
highlightedChips.is().displayed();
highlightedChips.getElement("Highlighted color Primary").is().color(AngularColors.PRIMARY)
.and().highlighted();
highlightedChips.getElement("Highlighted color Accent").is().color(AngularColors.ACCENT)
.and().highlighted();
highlightedChips.getElement("Highlighted color Warn").is().color(AngularColors.WARN)
.and().highlighted();
}

stackedSelectedValue.has().text(format("You clicked: %s", WARN));
@Test(description = "Test verifies that chips isn't highlighted")
public void chipsNotHighlightedTest() {
basicChips.show();
basicChips.is().displayed().and().enabled();
basicChips.getElement(TWOFISH).is().notHighlighted();
basicChips.getElement(WARNFISH).is().notHighlighted();
}

@Test
@Test(description = "Test checks the operation of the autocomplete in chips group")
public void chipsAutocompleteTest() {
String[] expectedValuesArray = {
"Apple", "Lemon", "Lime", "Orange", "Strawberry"};
APPLE, LEMON, LIME, "Orange", "Strawberry"};
List<String> expectedValues = Arrays.asList(expectedValuesArray);
chipsAutocompleteField.show();
chipsAutocompleteField.is().displayed();
chipsAutocompleteInput.is().assertChipsIsEnabled();
chipsAutocompleteInput.has().assertChipsHasPlaceholder(PLACEHOLDER);
chipsAutocompleteInput.has().assertChipsHasOptions(expectedValues);

chipsAutocompleteInput.setValue(LEMON);
chipsAutocompleteField.collapseField();
chipsAutocompleteInput.setValue(APPLE);
chipsAutocompleteField.collapseField();
chipsAutocompleteInput.setValue(LIME);
chipsAutocompleteField.collapseField();
autocompleteChips.show();
autocompleteChips.is().displayed();
autocompleteChips.inputField().has().placeholder("New Fruit...");
autocompleteChips.inputField().has().options(expectedValues);

autocompleteChips.inputField().select(LEMON);
autocompleteChips.is().hasElement(LEMON);
autocompleteChips.inputField().select(APPLE);
autocompleteChips.is().hasElement(APPLE);
}

@Test
@Test(description = "Test checks the input field in chips group")
public void chipsWithInputTest() {
chipsWithInputField.show();
chipsWithInputField.is().displayed();
chipsWithInputInput.is().assertChipsIsEnabled();
chipsWithInputInput.has().assertChipsHasPlaceholder(PLACEHOLDER);
chipsWithInputInput.input("Kiwi" + "\n");
chipsWithInputInput.input("Melon");
chipsWithInputInput.clearInputField();
chipsWithInputInput.input("Rockmelon" + "\n");
}
}
inputChips.show();
inputChips.is().displayed();
inputChips.inputField().has().placeholder("New fruit...");
inputChips.inputField().input(KIWI + "\n");
inputChips.inputField().input(MELON);
inputChips.inputField().clear();
inputChips.inputField().input(ROCKMELON + "\n");
inputChips.is().hasElement(KIWI);
inputChips.is().hasElement(ROCKMELON);
}

@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();
}

@Test(description = "Test checks that chips can't be removed")
public void chipsNotRemovableTest() {
basicChips.show();
basicChips.is().displayed();
basicChips.getElement(WARNFISH).is().notRemovable();
}

@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();
inputChips.getElement(APPLE).is().notFocused();
}

@Test(description = "Test checks that chips has avatar image")
public void chipAvatarTest() {
avatarChips.show();
avatarChips.getElement("Dog one").has().image();
}

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

@Test(description = "Test checks chips multiply selection")
public void chipsMultipleSelectionTest() {
multipleChips.show();
multipleChips.is().displayed();
multipleChips.is().multiselectable();
NewerNaigil marked this conversation as resolved.
Show resolved Hide resolved
multipleChips.selectByText("multiple color none");
multipleChips.selectByText("multiple color Primary");
multipleChips.getElement("multiple color none").is().selected();
multipleChips.getElement("multiple color Primary").is().selected();
}

@Test(description = "Test checks chips isn't multiply selection")
public void chipsNotMultipleSelectionTest() {
basicChips.show();
basicChips.is().displayed();
basicChips.is().notMultiselectable();
basicChips.selectByText(TWOFISH);
basicChips.selectByText(WARNFISH);
basicChips.getElement(TWOFISH).is().deselected();
basicChips.getElement(WARNFISH).is().selected();

}

@Test(description = "Test checks that chips has error state")
public void chipsErrorState() {
errorChips.show();
errorChips.is().displayed();
errorChips.inputField().input(KIWI + "\n");
errorChips.has().errorState();
}
}
Loading