Fix existing Espresso tests (#3450)

* Fix existing Espresso tests

* Convert class to kotlin
This commit is contained in:
Vivek Maskara 2020-03-02 15:17:24 -07:00 committed by GitHub
parent 36cafd7c39
commit 65ec071493
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 13 deletions

View file

@ -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) {
}
}
}