Skip to content

Commit

Permalink
Merge pull request #5419 from jdi-testing/5308
Browse files Browse the repository at this point in the history
#5308 add interfaces instead of validating styles in assertion
  • Loading branch information
pnatashap authored Apr 7, 2024
2 parents 3486e61 + a1b4fea commit 5e50faf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ public void styleAutocompleteTest() {
darkSoloAutocomplete.has().options(list);
darkSoloAutocomplete.close();

darkSoloInvertedAutocomplete.is()
.dark()
.soloInverted();
darkSoloInvertedAutocomplete.is().dark();
darkSoloInvertedAutocomplete.expand();
darkSoloInvertedAutocomplete.has().options(list);
darkSoloInvertedAutocomplete.close();
Expand Down Expand Up @@ -95,7 +93,7 @@ public void filterAutocompletesTest() {
filterStateAutocomplete.show();
filterStateAutocomplete.is().disabled();
filterEditButton.click();
filterStateAutocomplete.is().active();
filterStateAutocomplete.is().closed();
filterName.typeText(name);
filterStateAutocomplete.expand();
filterStateAutocomplete.is().expanded();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@
import com.epam.jdi.light.common.JDIAction;
import com.epam.jdi.light.elements.interfaces.common.IsText;
import com.epam.jdi.light.vuetify.elements.complex.Autocomplete;
import com.epam.jdi.light.vuetify.interfaces.asserts.DenseAssert;
import com.epam.jdi.light.vuetify.interfaces.asserts.FilledAssert;
import com.epam.jdi.light.vuetify.interfaces.asserts.OutlinedAssert;
import com.epam.jdi.light.vuetify.interfaces.asserts.ShapedAssert;
import org.hamcrest.Matchers;

import java.util.List;
import java.util.stream.Collectors;

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

public class AutocompleteAssert extends UIAssert<AutocompleteAssert, Autocomplete> {
public class AutocompleteAssert extends UIAssert<AutocompleteAssert, Autocomplete>
implements FilledAssert<AutocompleteAssert, Autocomplete>,
OutlinedAssert<AutocompleteAssert, Autocomplete>,
DenseAssert<AutocompleteAssert, Autocomplete>,
ShapedAssert<AutocompleteAssert, Autocomplete> {

@JDIAction(value = "Assert that '{name}' is expanded", isAssert = true)
public AutocompleteAssert expanded() {
Expand Down Expand Up @@ -61,14 +69,7 @@ public AutocompleteAssert notSelected(List<String> values) {
@JDIAction(value = "Assert that '{name}' is disabled", isAssert = true)
public AutocompleteAssert disabled() {
jdiAssert(element().isDisabled(), Matchers.is(true),
"Autocomplete is not disabled");
return this;
}

@JDIAction(value = "Assert that '{name}' is expanded", isAssert = true)
public AutocompleteAssert active() {
jdiAssert(element().isDisabled(), Matchers.is(false),
"Autocomplete is not active");
"Autocomplete is enabled");
return this;
}

Expand All @@ -78,61 +79,17 @@ public AutocompleteAssert empty() {
return this;
}

// @todo #5048 Create methods in Autocomplete class with all styles below
@JDIAction(value = "Assert that 'name' has solo style", isAssert = true)
@JDIAction(value = "Assert that 'name' only one element can be selected", isAssert = true)
public AutocompleteAssert solo() {
jdiAssert(
element().root().getAttribute("class"),
Matchers.containsString("v-text-field--solo")
);
return this;
}

@JDIAction(value = "Assert that 'name' has filled style", isAssert = true)
public AutocompleteAssert filled() {
jdiAssert(
element().root().attr("class"),
Matchers.containsString("v-text-field--filled")
);
return this;
}

@JDIAction(value = "Assert that 'name' has solo-inverted style", isAssert = true)
public AutocompleteAssert soloInverted() {
jdiAssert(
element().root().attr("class"),
Matchers.containsString("v-text-field--solo-inverted")
);
return this;
}

@JDIAction(value = "Assert that 'name' has outlined style", isAssert = true)
public AutocompleteAssert outlined() {
jdiAssert(
element().root().attr("class"),
Matchers.containsString("v-text-field--outlined")
);
return this;
}

@JDIAction(value = "Assert that 'name' has dense style", isAssert = true)
public AutocompleteAssert dense() {
jdiAssert(
element().root().attr("class"),
Matchers.containsString("v-input--dense")
);
return this;
}

@JDIAction(value = "Assert that 'name' has shaped style", isAssert = true)
public AutocompleteAssert shaped() {
jdiAssert(
element().root().attr("class"),
Matchers.containsString("v-text-field--shaped")
element().isSolo(),
Matchers.is(true),
"Autocomplete is can have many values"
);
return this;
}

// @todo #5308 Create interface for rounded
@JDIAction(value = "Assert that 'name' has rounded style", isAssert = true)
public AutocompleteAssert rounded() {
jdiAssert(
Expand All @@ -142,6 +99,7 @@ public AutocompleteAssert rounded() {
return this;
}

// @todo #5308 create interface for Themes
@JDIAction(value = "Assert that 'name' has dark style", isAssert = true)
public AutocompleteAssert dark() {
jdiAssert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
import com.epam.jdi.light.vuetify.annotations.JAutocomplete;
import com.epam.jdi.light.vuetify.asserts.AutocompleteAssert;
import com.epam.jdi.light.vuetify.elements.common.ListItem;
import com.epam.jdi.light.vuetify.interfaces.IsDense;
import com.epam.jdi.light.vuetify.interfaces.IsFilled;
import com.epam.jdi.light.vuetify.interfaces.IsOutlined;
import com.epam.jdi.light.vuetify.interfaces.IsShaped;
import com.jdiai.tools.Timer;
import org.openqa.selenium.Keys;

Expand All @@ -25,7 +29,8 @@
* To see an example of Autocompletes please visit https://v2.vuetifyjs.com/en/components/autocompletes/
*/

public class Autocomplete extends UIBaseElement<AutocompleteAssert> implements ISetup {
public class Autocomplete extends UIBaseElement<AutocompleteAssert>
implements ISetup, IsFilled, IsOutlined, IsDense, IsShaped {
private static final String VALUE_LOCATOR = "div input[type='hidden']";
private static final String INPUT_LOCATOR = "div input[type='text']";
private static final String EXPAND_LOCATOR = "div .v-input__append-inner";
Expand Down Expand Up @@ -113,6 +118,7 @@ public void expand() {
}
}

// @todo #5308 We need to send Esc, as expander can be hidden
@JDIAction("Close '{name}'")
public void close() {
if (isExpanded()) {
Expand All @@ -129,6 +135,7 @@ public void select(String value) {
}
}

// @todo #5308 another selected options are keeped, it is not correct
@JDIAction("Select '{0}' from '{name}'")
public void select(List<String> values) {
this.expand();
Expand All @@ -141,6 +148,7 @@ public void select(List<String> values) {
this.close();
}

// @todo #5308 in case option was not selected, if will be selected after
@JDIAction("Unselect '{0}' from '{name}'")
public void unselect(String value) {
if (isSelected(value)) {
Expand All @@ -162,12 +170,15 @@ public void unselect(List<String> values) {
this.close();
}

// @todo #5308 for example, we have thing and something in the list.
// something option is selected, but for option thing it will return true result.
@JDIAction("Get if '{0}' from '{name}' is selected")
public boolean isSelected(String value) {
String allValues = value().attr("value");
return allValues.contains(value + ",") || allValues.endsWith(value);
}

// @todo #5308 strange function, double check the meaning
@JDIAction("Get if '{0}' from '{name}' is selected")
public boolean isSelected(List<String> values) {
String allValues = value().attr("value");
Expand All @@ -179,6 +190,7 @@ public boolean isSelected(List<String> values) {
return true;
}

@JDIAction("Get {name}'s list of selected options")
public List<String> selected() {
return Arrays.asList(value().attr("value").split(","));
}
Expand Down Expand Up @@ -209,4 +221,9 @@ public void clearTextField() {
public void clickClear() {
clearButton().click();
}

@JDIAction("Get if one element can be selected in {name}")
public boolean isSolo() {
return root().attr("class").contains("v-text-field--solo");
}
}

0 comments on commit 5e50faf

Please sign in to comment.