Skip to content

Commit 053a765

Browse files
committed
Fix tests
1 parent c198b3d commit 053a765

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

app/src/androidTest/java/fr/free/nrw/commons/UploadTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,25 +226,25 @@ class UploadTest {
226226
// Try to dismiss the error, if there is one (probably about duplicate files on Commons)
227227
dismissWarningDialog()
228228

229-
onView(allOf<View>(withId(R.id.description_item_edit_text), withParent(withParent(withId(R.id.image_title_container)))))
229+
onView(allOf<View>(isDisplayed(), withId(R.id.et_title)))
230230
.perform(replaceText(commonsFileName))
231231

232232
onView(withId(R.id.rv_descriptions)).perform(
233233
RecyclerViewActions
234-
.actionOnItemAtPosition<DescriptionsAdapter.ViewHolder>(1,
234+
.actionOnItemAtPosition<DescriptionsAdapter.ViewHolder>(0,
235235
MyViewAction.typeTextInChildViewWithId(R.id.description_item_edit_text, "Test description")))
236236

237237
onView(withId(R.id.btn_add_description))
238238
.perform(click())
239239

240240
onView(withId(R.id.rv_descriptions)).perform(
241241
RecyclerViewActions
242-
.actionOnItemAtPosition<DescriptionsAdapter.ViewHolder>(2,
242+
.actionOnItemAtPosition<DescriptionsAdapter.ViewHolder>(1,
243243
MyViewAction.selectSpinnerItemInChildViewWithId(R.id.spinner_description_languages, 2)))
244244

245245
onView(withId(R.id.rv_descriptions)).perform(
246246
RecyclerViewActions
247-
.actionOnItemAtPosition<DescriptionsAdapter.ViewHolder>(2,
247+
.actionOnItemAtPosition<DescriptionsAdapter.ViewHolder>(1,
248248
MyViewAction.typeTextInChildViewWithId(R.id.description_item_edit_text, "Description")))
249249

250250
onView(allOf(isDisplayed(), withId(R.id.btn_next)))
@@ -256,7 +256,7 @@ class UploadTest {
256256
UITestHelper.sleep(3000)
257257

258258
onView(allOf(isDisplayed(), withId(R.id.et_search)))
259-
.perform(replaceText("Uploaded with Mobile/Android Tests"))
259+
.perform(replaceText("Test"))
260260

261261
UITestHelper.sleep(3000)
262262

app/src/androidTest/java/fr/free/nrw/commons/util/MyViewAction.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,22 @@ class MyViewAction {
4343
}
4444
}
4545

46+
fun clickItemWithId(id: Int, position: Int): ViewAction {
47+
return object : ViewAction {
48+
override fun getConstraints(): Matcher<View>? {
49+
return null
50+
}
51+
52+
override fun getDescription(): String {
53+
return "Click on a child view with specified id."
54+
}
55+
56+
override fun perform(uiController: UiController, view: View) {
57+
val v = view.findViewById<View>(id) as View
58+
v.performClick()
59+
}
60+
}
61+
}
62+
4663
}
4764
}

0 commit comments

Comments
 (0)