mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Fix existing Espresso tests (#3450)
* Fix existing Espresso tests * Convert class to kotlin
This commit is contained in:
parent
36cafd7c39
commit
65ec071493
5 changed files with 48 additions and 13 deletions
|
|
@ -135,11 +135,7 @@ class UploadTest {
|
|||
val commonsFileName = "MobileTest " + dateFormat.format(Date())
|
||||
|
||||
// Try to dismiss the error, if there is one (probably about duplicate files on Commons)
|
||||
try {
|
||||
onView(withText("Yes"))
|
||||
.check(matches(isDisplayed()))
|
||||
.perform(click())
|
||||
} catch (ignored: NoMatchingViewException) {}
|
||||
dismissWarning("Yes")
|
||||
|
||||
onView(allOf<View>(isDisplayed(), withId(R.id.et_title)))
|
||||
.perform(replaceText(commonsFileName))
|
||||
|
|
@ -151,25 +147,27 @@ class UploadTest {
|
|||
onView(allOf(isDisplayed(), withId(R.id.btn_next)))
|
||||
.perform(click())
|
||||
|
||||
try {
|
||||
onView(withText("Yes"))
|
||||
.check(matches(isDisplayed()))
|
||||
.perform(click())
|
||||
} catch (ignored: NoMatchingViewException) {}
|
||||
UITestHelper.sleep(5000)
|
||||
dismissWarning("Yes")
|
||||
|
||||
UITestHelper.sleep(1000)
|
||||
UITestHelper.sleep(3000)
|
||||
|
||||
onView(allOf(isDisplayed(), withId(R.id.et_search)))
|
||||
.perform(replaceText("Uploaded with Mobile/Android Tests"))
|
||||
|
||||
UITestHelper.sleep(3000)
|
||||
|
||||
onView(allOf(isDisplayed(), withParent(withId(R.id.rv_categories))))
|
||||
.perform(click())
|
||||
try {
|
||||
onView(allOf(isDisplayed(), withParent(withId(R.id.rv_categories))))
|
||||
.perform(click())
|
||||
} catch (ignored: NoMatchingViewException) {
|
||||
}
|
||||
|
||||
onView(allOf(isDisplayed(), withId(R.id.btn_next)))
|
||||
.perform(click())
|
||||
|
||||
dismissWarning("Yes, Submit")
|
||||
|
||||
UITestHelper.sleep(500)
|
||||
|
||||
onView(allOf(isDisplayed(), withId(R.id.btn_submit)))
|
||||
|
|
@ -181,4 +179,13 @@ class UploadTest {
|
|||
commonsFileName.replace(' ', '_') + ".jpg"
|
||||
Timber.i("File should be uploaded to $fileUrl")
|
||||
}
|
||||
|
||||
private fun dismissWarning(warningText: String) {
|
||||
try {
|
||||
onView(withText(warningText))
|
||||
.check(matches(isDisplayed()))
|
||||
.perform(click())
|
||||
} catch (ignored: NoMatchingViewException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue