From 0ad7ee699a7b92358166144534d2fae80649675b Mon Sep 17 00:00:00 2001 From: Natalia Pozhidaeva Date: Sat, 6 Apr 2024 18:51:28 -0500 Subject: [PATCH 1/2] #5308 add interfaces instead of validating styles in assertion --- .../tests/complex/AutocompletesTests.java | 6 +- .../vuetify/asserts/AutocompleteAssert.java | 74 ++++--------------- .../elements/complex/Autocomplete.java | 19 ++++- 3 files changed, 36 insertions(+), 63 deletions(-) diff --git a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/AutocompletesTests.java b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/AutocompletesTests.java index f63010fedc..9fc99fcc49 100644 --- a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/AutocompletesTests.java +++ b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/AutocompletesTests.java @@ -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(); @@ -95,7 +93,7 @@ public void filterAutocompletesTest() { filterStateAutocomplete.show(); filterStateAutocomplete.is().disabled(); filterEditButton.click(); - filterStateAutocomplete.is().active(); + filterStateAutocomplete.is().expanded(); filterName.typeText(name); filterStateAutocomplete.expand(); filterStateAutocomplete.is().expanded(); diff --git a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/AutocompleteAssert.java b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/AutocompleteAssert.java index d3b9d79f82..ebb09a3772 100644 --- a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/AutocompleteAssert.java +++ b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/asserts/AutocompleteAssert.java @@ -4,6 +4,10 @@ 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; @@ -11,7 +15,11 @@ import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; -public class AutocompleteAssert extends UIAssert { +public class AutocompleteAssert extends UIAssert + implements FilledAssert, + OutlinedAssert, + DenseAssert, + ShapedAssert { @JDIAction(value = "Assert that '{name}' is expanded", isAssert = true) public AutocompleteAssert expanded() { @@ -61,14 +69,7 @@ public AutocompleteAssert notSelected(List 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; } @@ -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( @@ -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( diff --git a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/Autocomplete.java b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/Autocomplete.java index 9e398bde58..418e8fc329 100644 --- a/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/Autocomplete.java +++ b/jdi-light-vuetify/src/main/java/com/epam/jdi/light/vuetify/elements/complex/Autocomplete.java @@ -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; @@ -25,7 +29,8 @@ * To see an example of Autocompletes please visit https://v2.vuetifyjs.com/en/components/autocompletes/ */ -public class Autocomplete extends UIBaseElement implements ISetup { +public class Autocomplete extends UIBaseElement + 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"; @@ -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()) { @@ -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 values) { this.expand(); @@ -141,6 +148,7 @@ public void select(List 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)) { @@ -162,12 +170,15 @@ public void unselect(List 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 values) { String allValues = value().attr("value"); @@ -179,6 +190,7 @@ public boolean isSelected(List values) { return true; } + @JDIAction("Get {name}'s list of selected options") public List selected() { return Arrays.asList(value().attr("value").split(",")); } @@ -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"); + } } From a1b4fea115e1c22e15e0c684362c7b67f71eaf04 Mon Sep 17 00:00:00 2001 From: Natalia Pozhidaeva Date: Sat, 6 Apr 2024 18:56:34 -0500 Subject: [PATCH 2/2] #5308 fix test --- .../github/epam/vuetify/tests/complex/AutocompletesTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/AutocompletesTests.java b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/AutocompletesTests.java index 9fc99fcc49..fb7caa91c9 100644 --- a/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/AutocompletesTests.java +++ b/jdi-light-vuetify-tests/src/test/java/io/github/epam/vuetify/tests/complex/AutocompletesTests.java @@ -93,7 +93,7 @@ public void filterAutocompletesTest() { filterStateAutocomplete.show(); filterStateAutocomplete.is().disabled(); filterEditButton.click(); - filterStateAutocomplete.is().expanded(); + filterStateAutocomplete.is().closed(); filterName.typeText(name); filterStateAutocomplete.expand(); filterStateAutocomplete.is().expanded();