mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Make all UI tests pass and add more tests (#2700)
This commit is contained in:
parent
239f74942f
commit
f7e6b20cab
8 changed files with 214 additions and 60 deletions
|
|
@ -1,36 +1,57 @@
|
|||
package fr.free.nrw.commons
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Instrumentation.ActivityResult
|
||||
import android.content.Intent
|
||||
import androidx.test.espresso.Espresso
|
||||
import androidx.test.espresso.action.ViewActions.click
|
||||
import androidx.test.espresso.assertion.ViewAssertions
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.intent.Intents
|
||||
import androidx.test.espresso.intent.Intents.intended
|
||||
import androidx.test.espresso.intent.Intents.intending
|
||||
import androidx.test.espresso.intent.matcher.IntentMatchers
|
||||
import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
|
||||
import androidx.test.espresso.intent.matcher.IntentMatchers.isInternal
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.filters.LargeTest
|
||||
import androidx.test.filters.MediumTest
|
||||
import androidx.test.rule.ActivityTestRule
|
||||
import androidx.test.runner.AndroidJUnit4
|
||||
import fr.free.nrw.commons.auth.LoginActivity
|
||||
import fr.free.nrw.commons.auth.SignupActivity
|
||||
import fr.free.nrw.commons.contributions.MainActivity
|
||||
import org.hamcrest.CoreMatchers
|
||||
import org.hamcrest.CoreMatchers.not
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@LargeTest
|
||||
|
||||
@MediumTest
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class LoginActivityTest {
|
||||
@get:Rule
|
||||
var activity: ActivityTestRule<*> = ActivityTestRule(LoginActivity::class.java)
|
||||
var activityRule = ActivityTestRule(LoginActivity::class.java)
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
try {
|
||||
Intents.init()
|
||||
} catch (ex: IllegalStateException) {
|
||||
|
||||
}
|
||||
UITestHelper.skipWelcome()
|
||||
intending(not(isInternal())).respondWith(ActivityResult(Activity.RESULT_OK, null))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isSignUpButtonWorks() {
|
||||
// Clicks the SignUp Button
|
||||
Intents.init()
|
||||
Espresso.onView(withId(R.id.signupButton))
|
||||
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
|
||||
.perform(click())
|
||||
intended(hasComponent(SignupActivity::class.java.name))
|
||||
Intents.release()
|
||||
fun testLogin() {
|
||||
UITestHelper.loginUser()
|
||||
UITestHelper.sleep(10000)
|
||||
Intents.intended(hasComponent(MainActivity::class.java.name))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testForgotPassword() {
|
||||
Espresso.onView(ViewMatchers.withId(R.id.forgotPassword))
|
||||
.perform(ViewActions.click())
|
||||
Intents.intended(CoreMatchers.allOf(IntentMatchers.hasAction(Intent.ACTION_VIEW), IntentMatchers.hasData(BuildConfig.FORGOT_PASSWORD_URL)));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue