11package io .github .epam .angular .tests .elements .complex ;
22
3+ import com .epam .jdi .light .angular .elements .enums .AngularColors ;
34import io .github .com .pages .ChipsPage ;
45import io .github .epam .TestsInit ;
56import org .testng .annotations .BeforeMethod ;
1213import static com .jdiai .tools .Timer .waitCondition ;
1314import static io .github .com .StaticSite .chipsPage ;
1415import static io .github .com .pages .ChipsPage .autocompleteChips ;
16+ import static io .github .com .pages .ChipsPage .avatarChips ;
1517import static io .github .com .pages .ChipsPage .basicChips ;
1618import static io .github .com .pages .ChipsPage .disabledChips ;
19+ import static io .github .com .pages .ChipsPage .errorChips ;
1720import static io .github .com .pages .ChipsPage .inputChips ;
1821import static io .github .com .pages .ChipsPage .multipleChips ;
1922import static io .github .com .pages .ChipsPage .stackedChips ;
@@ -43,7 +46,7 @@ public void before() {
4346 chipsPage .checkOpened ();
4447 }
4548
46- @ Test
49+ @ Test ( description = "Test verifies that chip group is selectable" )
4750 public void basicChipsTest () {
4851 basicChips .show ();
4952 basicChips .is ().displayed ();
@@ -54,7 +57,7 @@ public void basicChipsTest() {
5457 ChipsPage .basicSelectedValue .has ().text (format ("You clicked: %s" , WARNFISH ));
5558 }
5659
57- @ Test
60+ @ Test ( description = "Test verifies that chip group is vertical" )
5861 public void stackedChipsTest () {
5962 stackedChips .show ();
6063 stackedChips .is ().displayed ();
@@ -67,32 +70,39 @@ public void stackedChipsTest() {
6770 stackedSelectedValue .has ().text (format ("You clicked: %s" , WARN ));
6871 }
6972
70- @ Test
73+ @ Test (description = "Test check chips colors" )
74+ public void chipsColorTest () {
75+ stackedChips .show ();
76+ stackedChips .is ().displayed ();
77+ stackedChips .getElement (PRIMARY ).is ().color (AngularColors .MAT_PRIMARY );
78+ stackedChips .getElement (ACCENT ).is ().color (AngularColors .MAT_ACCENT );
79+ stackedChips .getElement (WARN ).is ().color (AngularColors .MAT_WARN );
80+ }
81+
82+ @ Test (description = "Test checks the operation of the autocomplete in chips group" )
7183 public void chipsAutocompleteTest () {
7284 String [] expectedValuesArray = {
7385 "Apple" , "Lemon" , "Lime" , "Orange" , "Strawberry" };
7486 List <String > expectedValues = Arrays .asList (expectedValuesArray );
87+
7588 autocompleteChips .show ();
7689 autocompleteChips .is ().displayed ();
77- autocompleteChips .has ().assertChipsHasPlaceholder ("New Fruit..." );
78- autocompleteChips .has ().assertChipsHasOptions (expectedValues );
90+ autocompleteChips .has ().placeholder ("New Fruit..." );
91+ autocompleteChips .has ().options (expectedValues );
7992
80- autocompleteChips .setValue (LEMON );
93+ autocompleteChips .select (LEMON );
8194 autocompleteChips .collapseField ();
8295 autocompleteChips .is ().hasElement (LEMON );
83- autocompleteChips .setValue (APPLE );
96+ autocompleteChips .select (APPLE );
8497 autocompleteChips .collapseField ();
8598 autocompleteChips .is ().hasElement (APPLE );
86- autocompleteChips .setValue (LIME );
87- autocompleteChips .collapseField ();
88- autocompleteChips .is ().hasElement (LIME );
8999 }
90100
91- @ Test
101+ @ Test ( description = "Test checks the input field in chips group" )
92102 public void chipsWithInputTest () {
93103 inputChips .show ();
94104 inputChips .is ().displayed ();
95- inputChips .has ().assertChipsHasPlaceholder (PLACEHOLDER );
105+ inputChips .has ().placeholder (PLACEHOLDER );
96106 inputChips .input ("Kiwi" + "\n " );
97107 inputChips .input ("Melon" );
98108 inputChips .clearInputField ();
@@ -101,24 +111,39 @@ public void chipsWithInputTest() {
101111 inputChips .is ().hasElement ("Rockmelon" );
102112 }
103113
104- @ Test
114+ @ Test ( description = "Test checks that chips can be removed" )
105115 public void chipsRemovableTest () {
106116 inputChips .show ();
107117 inputChips .is ().displayed ();
108118 inputChips .getElement ("Lemon" ).is ().removable ();
109119 inputChips .getElement ("Lemon" ).close ();
110- inputChips .getElement ("Lemon" );
111120 }
112121
113- @ Test
114- public void chipDisabledTest () {
115- disabledChips .groupElements ().get (0 ).is ().disabled ();
116- disabledChips .groupElements ().get (1 ).is ().disabled ();
117- disabledChips .groupElements ().get (2 ).is ().disabled ();
122+ @ Test (description = "Test checks that chips can be focused" )
123+ public void chipFocusedTest () {
124+ inputChips .show ();
125+ inputChips .is ().displayed ();
126+ inputChips .getElement ("Apple" ).click ();
127+ inputChips .getElement ("Apple" ).is ().focused ();
128+ inputChips .getElement ("Lime" ).click ();
129+ inputChips .getElement ("Lime" ).is ().focused ();
130+ }
118131
132+ @ Test (description = "Test checks that chips has avatar image" )
133+ public void chipAvatarTest () {
134+ String expectedSrc = "https://material.angular.io/assets/img/examples/shiba1.jpg" ;
135+ avatarChips .show ();
136+ avatarChips .getElement ("Dog one" ).leadingIcon ().is ().src (expectedSrc );
119137 }
120138
121- @ Test
139+ @ Test (description = "Test checks that chips can be disabled" )
140+ public void chipDisabledTest () {
141+ disabledChips .show ();
142+ disabledChips .is ().displayed ();
143+ disabledChips .is ().disabled ();
144+ }
145+
146+ @ Test (description = "Test checks chips multiply selection" )
122147 public void chipsMultipleSelectionTest () {
123148 multipleChips .show ();
124149 multipleChips .is ().displayed ();
@@ -128,4 +153,12 @@ public void chipsMultipleSelectionTest() {
128153 multipleChips .getElement ("multiple color none" ).is ().selected ();
129154 multipleChips .getElement ("multiple color Primary" ).is ().selected ();
130155 }
156+
157+ @ Test (description = "Test checks that chips has error state" )
158+ public void chipsErrorState () {
159+ errorChips .show ();
160+ errorChips .is ().displayed ();
161+ errorChips .input ("Kiwi" + "\n " );
162+ errorChips .has ().errorState ();
163+ }
131164}
0 commit comments