@@ -12,7 +12,6 @@ import androidx.test.espresso.matcher.ViewMatchers.withParent
12
12
import androidx.test.espresso.matcher.ViewMatchers.withText
13
13
import androidx.test.ext.junit.runners.AndroidJUnit4
14
14
import com.example.util.simpletimetracker.core.mapper.ColorMapper
15
- import com.example.util.simpletimetracker.feature_change_record_type.R
16
15
import com.example.util.simpletimetracker.utils.BaseUiTest
17
16
import com.example.util.simpletimetracker.utils.NavUtils
18
17
import com.example.util.simpletimetracker.utils.checkViewDoesNotExist
@@ -23,6 +22,7 @@ import com.example.util.simpletimetracker.utils.clickOnView
23
22
import com.example.util.simpletimetracker.utils.clickOnViewWithId
24
23
import com.example.util.simpletimetracker.utils.clickOnViewWithText
25
24
import com.example.util.simpletimetracker.utils.longClickOnView
25
+ import com.example.util.simpletimetracker.utils.nestedScrollTo
26
26
import com.example.util.simpletimetracker.utils.scrollRecyclerToPosition
27
27
import com.example.util.simpletimetracker.utils.tryAction
28
28
import com.example.util.simpletimetracker.utils.typeTextIntoView
@@ -46,6 +46,7 @@ class AddCategoryTest : BaseUiTest() {
46
46
val name = " Test"
47
47
val typeName1 = " Type1"
48
48
val typeName2 = " Type2"
49
+ val note = " note"
49
50
val lastColorPosition = ColorMapper .getAvailableColors().size - 1
50
51
51
52
// Add activities
@@ -142,6 +143,10 @@ class AddCategoryTest : BaseUiTest() {
142
143
checkViewIsDisplayed(withText(" 10$minuteString " ))
143
144
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
144
145
146
+ // Adding note
147
+ onView(withId(changeCategoryR.id.etChangeRecordCategoryNote)).perform(nestedScrollTo())
148
+ typeTextIntoView(changeCategoryR.id.etChangeRecordCategoryNote, note)
149
+
145
150
// Category added
146
151
clickOnViewWithText(coreR.string.change_record_type_save)
147
152
checkViewIsDisplayed(withText(name))
@@ -155,12 +160,17 @@ class AddCategoryTest : BaseUiTest() {
155
160
checkViewIsDisplayed(withId(baseR.id.viewDividerItem))
156
161
onView(withText(typeName1)).check(isCompletelyAbove(withId(baseR.id.viewDividerItem)))
157
162
onView(withText(typeName2)).check(isCompletelyBelow(withId(baseR.id.viewDividerItem)))
163
+ clickOnViewWithText(coreR.string.change_category_types_hint)
158
164
159
165
// Check goals saved
160
- clickOnViewWithText(coreR.string.change_category_types_hint)
161
166
Thread .sleep(1000 )
162
167
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
163
168
checkViewIsDisplayed(withText(" 10$minuteString " ))
169
+ clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
170
+
171
+ // Check note saved
172
+ onView(withId(changeCategoryR.id.etChangeRecordCategoryNote)).perform(nestedScrollTo())
173
+ checkViewIsDisplayed(allOf(withId(changeCategoryR.id.etChangeRecordCategoryNote), withText(note)))
164
174
}
165
175
166
176
@Test
@@ -227,6 +237,31 @@ class AddCategoryTest : BaseUiTest() {
227
237
checkViewIsDisplayed(withText(categoryName2))
228
238
}
229
239
240
+ @Test
241
+ fun addCategorySameName () {
242
+ val name = " Test"
243
+
244
+ // Add activity
245
+ testUtils.addCategory(name)
246
+
247
+ // Add another
248
+ NavUtils .openSettingsScreen()
249
+ NavUtils .openCategoriesScreen()
250
+ clickOnViewWithText(coreR.string.categories_add_category)
251
+ closeSoftKeyboard()
252
+
253
+ // No error
254
+ checkViewDoesNotExist(withText(coreR.string.change_record_message_name_exist))
255
+
256
+ // Check same name
257
+ typeTextIntoView(R .id.etChangeCategoryName, name)
258
+ checkViewIsDisplayed(withText(coreR.string.change_record_message_name_exist))
259
+
260
+ // Check other name
261
+ typeTextIntoView(R .id.etChangeCategoryName, " $name +" )
262
+ checkViewDoesNotExist(withText(coreR.string.change_record_message_name_exist))
263
+ }
264
+
230
265
private fun checkPreviewUpdated (matcher : Matcher <View >) =
231
266
checkViewIsDisplayed(allOf(withId(changeCategoryR.id.previewChangeCategory), matcher))
232
267
}
0 commit comments