Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for inviteuser and password module #18

Merged
merged 7 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ import androidx.test.rule.ActivityTestRule
import chat.rocket.android.R
import chat.rocket.android.analytics.event.ScreenViewEvent
import chat.rocket.android.authentication.ui.AuthenticationActivity
import chat.rocket.android.util.extensions.addFragmentBackStack
import chat.rocket.android.util.loginUserToTheApp
import chat.rocket.android.util.withTextInChild
import chat.rocket.android.util.extensions.addFragmentBackStack
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import testConfig.Config.Companion.EXISTING_CHANNEL
import testConfig.Config.Companion.EXISTING_USER
import testConfig.Config.Companion.FAVORITE_MESSAGES
import testConfig.Config.Companion.FILES
import testConfig.Config.Companion.MEMBERS
import testConfig.Config.Companion.MENTIONS
import testConfig.Config.Companion.PINNED_MESSAGES
import testConfig.Config.Companion.SERVER_URL
import testConfig.Config.Companion.TEST_CHANNEL
import testConfig.Config.Companion.TEST_USER

class ChatDetailsFragmentTest {

Expand Down Expand Up @@ -122,14 +122,14 @@ class ChatDetailsFragmentTest {

private fun navigateToExistingDMDetails() {
Thread.sleep(5000)
onView(withText(EXISTING_USER)).perform(click())
onView(withText(TEST_USER)).perform(click())
Thread.sleep(2000)
onView(withId(R.id.text_toolbar_title)).perform(click())
}

private fun navigateToExistingChannelDetails() {
Thread.sleep(5000)
onView(withText(EXISTING_CHANNEL)).perform(click())
onView(withText(TEST_CHANNEL)).perform(click())
Thread.sleep(2000)
onView(withId(R.id.text_toolbar_title)).perform(click())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import chat.rocket.android.util.loginUserToTheApp
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import testConfig.Config.Companion.EXISTING_CHANNEL2
import testConfig.Config.Companion.EXISTING_USER
import testConfig.Config.Companion.EXISTING_USER2
import testConfig.Config.Companion.SERVER_URL
import testConfig.Config.Companion.TEST_CHANNEL2
import testConfig.Config.Companion.TEST_MESSAGE
import testConfig.Config.Companion.TEST_USER
import testConfig.Config.Companion.TEST_USER2

@LargeTest
class ChatRoomFragmentTest {
Expand Down Expand Up @@ -136,17 +136,17 @@ class ChatRoomFragmentTest {
}

private fun navigateToExistingChannel() {
onView(withText(EXISTING_CHANNEL2)).perform(click())
onView(withText(TEST_CHANNEL2)).perform(click())
Thread.sleep(2000)
}

private fun navigateToExistingUser1() {
onView(withText(EXISTING_USER)).perform(click())
onView(withText(TEST_USER)).perform(click())
Thread.sleep(2000)
}

private fun navigateToExistingUser2() {
onView(withText(EXISTING_USER2)).perform(click())
onView(withText(TEST_USER2)).perform(click())
Thread.sleep(2000)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import androidx.test.rule.ActivityTestRule
import chat.rocket.android.R
import chat.rocket.android.analytics.event.ScreenViewEvent
import chat.rocket.android.authentication.ui.AuthenticationActivity
import chat.rocket.android.util.extensions.addFragmentBackStack
import chat.rocket.android.util.loginUserToTheApp
import chat.rocket.android.util.withIndex
import chat.rocket.android.util.extensions.addFragmentBackStack
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import testConfig.Config.Companion.EXISTING_CHANNEL
import testConfig.Config.Companion.SERVER_URL
import testConfig.Config.Companion.TEST_CHANNEL

class ChatRoomsFragmentTest {

Expand Down Expand Up @@ -50,9 +50,9 @@ class ChatRoomsFragmentTest {

@Test
fun clicking_channel_should_open_chatroom() {
onView(withText(EXISTING_CHANNEL)).perform(click())
onView(withText(TEST_CHANNEL)).perform(click())
Thread.sleep(2000)
onView(withId(R.id.text_toolbar_title)).check(matches(withText(EXISTING_CHANNEL)))
onView(withId(R.id.text_toolbar_title)).check(matches(withText(TEST_CHANNEL)))
onView(withId(R.id.message_list_container)).check(matches(isDisplayed()))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ import chat.rocket.android.R
import chat.rocket.android.analytics.event.ScreenViewEvent
import chat.rocket.android.authentication.ui.AuthenticationActivity
import chat.rocket.android.util.RecyclerViewItemCountAssertion.Companion.withItemCount
import chat.rocket.android.util.loginUserToTheApp
import chat.rocket.android.util.extensions.addFragmentBackStack
import chat.rocket.android.util.loginUserToTheApp
import org.hamcrest.Matchers.equalTo
import org.hamcrest.Matchers.greaterThan
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import testConfig.Config.Companion.CHANNELS
import testConfig.Config.Companion.DIRECTORY
import testConfig.Config.Companion.EXISTING_CHANNEL
import testConfig.Config.Companion.EXISTING_USER
import testConfig.Config.Companion.NON_EXISTING_CHANNEL
import testConfig.Config.Companion.NON_EXISTING_USER
import testConfig.Config.Companion.SERVER_URL
import testConfig.Config.Companion.TEST_CHANNEL
import testConfig.Config.Companion.TEST_USER
import testConfig.Config.Companion.USERS

class DirectoryFragmentTest {
Expand Down Expand Up @@ -80,7 +80,7 @@ class DirectoryFragmentTest {
onView(withId(R.id.action_search)).perform(click())
onView(isAssignableFrom(AutoCompleteTextView::class.java)).perform(
clearText(),
typeText(EXISTING_CHANNEL),
typeText(TEST_CHANNEL),
closeSoftKeyboard()
)
Thread.sleep(8000)
Expand All @@ -107,7 +107,7 @@ class DirectoryFragmentTest {
onView(withId(R.id.action_search)).perform(click())
onView(isAssignableFrom(AutoCompleteTextView::class.java)).perform(
clearText(),
typeText(EXISTING_USER),
typeText(TEST_USER),
closeSoftKeyboard()
)
Espresso.pressBack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ package chat.rocket.android.favoritemessages.ui

import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.NoMatchingViewException
import androidx.test.espresso.action.ViewActions.*
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.rule.ActivityTestRule
import chat.rocket.android.R
import chat.rocket.android.analytics.event.ScreenViewEvent
import chat.rocket.android.authentication.ui.AuthenticationActivity
import chat.rocket.android.util.RecyclerViewItemCountAssertion.Companion.withItemCount
import chat.rocket.android.util.loginUserToTheApp
import chat.rocket.android.util.extensions.addFragmentBackStack
import chat.rocket.android.util.loginUserToTheApp
import org.hamcrest.Matchers.equalTo
import org.hamcrest.Matchers.greaterThan
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import testConfig.Config.Companion.EXISTING_CHANNEL
import testConfig.Config.Companion.EXISTING_CHANNEL2
import testConfig.Config.Companion.FAVORITE_MESSAGES
import testConfig.Config.Companion.SERVER_URL
import testConfig.Config.Companion.TEST_CHANNEL
import testConfig.Config.Companion.TEST_CHANNEL2


class FavoriteMessagesFragmentTest {
Expand Down Expand Up @@ -60,14 +60,14 @@ class FavoriteMessagesFragmentTest {

private fun navigateToSandboxChannelDetails() {
Thread.sleep(5000)
onView(withText(EXISTING_CHANNEL2)).perform(click())
onView(withText(TEST_CHANNEL2)).perform(click())
Thread.sleep(2000)
onView(withId(R.id.text_toolbar_title)).perform(click())
}

private fun navigateToGeneralChannelDetails() {
Thread.sleep(5000)
onView(withText(EXISTING_CHANNEL)).perform(click())
onView(withText(TEST_CHANNEL)).perform(click())
Thread.sleep(2000)
onView(withId(R.id.text_toolbar_title)).perform(click())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import chat.rocket.android.R
import chat.rocket.android.analytics.event.ScreenViewEvent
import chat.rocket.android.authentication.ui.AuthenticationActivity
import chat.rocket.android.util.RecyclerViewItemCountAssertion.Companion.withItemCount
import chat.rocket.android.util.loginUserToTheApp
import chat.rocket.android.util.extensions.addFragmentBackStack
import chat.rocket.android.util.loginUserToTheApp
import org.hamcrest.Matchers.*
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import testConfig.Config.Companion.EXISTING_CHANNEL
import testConfig.Config.Companion.EXISTING_USER
import testConfig.Config.Companion.FILES
import testConfig.Config.Companion.SERVER_URL
import testConfig.Config.Companion.TEST_CHANNEL
import testConfig.Config.Companion.TEST_USER

class FilesFragmentTest {

Expand Down Expand Up @@ -72,14 +72,14 @@ class FilesFragmentTest {

private fun navigateToGeneralChannelDetails() {
Thread.sleep(5000)
onView(withText(EXISTING_CHANNEL)).perform(click())
onView(withText(TEST_CHANNEL)).perform(click())
Thread.sleep(2000)
onView(withId(R.id.text_toolbar_title)).perform(click())
}

private fun navigateToDummyUserChannelDetails() {
Thread.sleep(5000)
onView(withText(EXISTING_USER)).perform(click())
onView(withText(TEST_USER)).perform(click())
Thread.sleep(2000)
onView(withId(R.id.text_toolbar_title)).perform(click())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package chat.rocket.android.inviteusers.ui

import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.NoMatchingViewException
import androidx.test.espresso.action.ViewActions.*
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.rule.ActivityTestRule
import chat.rocket.android.R
import chat.rocket.android.analytics.event.ScreenViewEvent
import chat.rocket.android.authentication.ui.AuthenticationActivity
import chat.rocket.android.util.RecyclerViewItemCountAssertion
import chat.rocket.android.util.extensions.addFragmentBackStack
import chat.rocket.android.util.loginUserToTheApp
import org.hamcrest.Matchers.equalTo
import org.hamcrest.Matchers.greaterThan
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import testConfig.Config.Companion.MEMBERS
import testConfig.Config.Companion.NON_EXISTING_USER
import testConfig.Config.Companion.SERVER_URL
import testConfig.Config.Companion.TEST_CHANNEL3
import testConfig.Config.Companion.TEST_USER2


class InviteUsersFragmentTest {

@JvmField
var activityRule = ActivityTestRule(AuthenticationActivity::class.java, true, true)

@Rule
fun rule() = activityRule

@Before
fun setUp() {
try {
rule().activity.addFragmentBackStack(ScreenViewEvent.Login.screenName, R.id.fragment_container) {
chat.rocket.android.authentication.login.ui.newInstance(SERVER_URL)
}
loginUserToTheApp()
navigateToInviteUser()
} catch (e: NoMatchingViewException) {
Thread.sleep(3000)
navigateToInviteUser()
}
}

private fun navigateToInviteUser() {
onView(withText(TEST_CHANNEL3)).perform(click())
Thread.sleep(2000)
onView(withId(R.id.text_toolbar_title)).perform(click())
onView(withText(MEMBERS)).perform(click())
Thread.sleep(3000)
onView(withId(R.id.button_invite_user)).perform(click())
}

@Test
fun check_UI_element() {
onView(withId(R.id.text_invite_users)).check(matches(withHint(R.string.msg_invite_members)))
onView(withId(R.id.recycler_view)).check(matches(isDisplayed()))
onView(withId(R.id.button_invite_user)).check(matches(isDisplayed()))
}

@Test
fun search_an_existing_user() {
onView(withId(R.id.text_invite_users)).perform(
typeText(TEST_USER2), closeSoftKeyboard()
)
Thread.sleep(2000)
onView(withId(R.id.recycler_view)).check(
RecyclerViewItemCountAssertion.withItemCount(greaterThan(0))
)
onView(withId(R.id.text_member)).check(matches(withText(TEST_USER2)))
}

@Test
fun search_an_non_existing_user() {
onView(withId(R.id.text_invite_users)).perform(
typeText(NON_EXISTING_USER), closeSoftKeyboard()
)
Thread.sleep(2000)
onView(withId(R.id.recycler_view)).check(
RecyclerViewItemCountAssertion.withItemCount(equalTo(0))
)
onView(withId(R.id.text_member_not_found)).check(matches(isDisplayed()))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import chat.rocket.android.R
import chat.rocket.android.analytics.event.ScreenViewEvent
import chat.rocket.android.authentication.ui.AuthenticationActivity
import chat.rocket.android.util.RecyclerViewItemCountAssertion.Companion.withItemCount
import chat.rocket.android.util.loginUserToTheApp
import chat.rocket.android.util.extensions.addFragmentBackStack
import chat.rocket.android.util.loginUserToTheApp
import org.hamcrest.Matchers.greaterThan
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import testConfig.Config.Companion.EXISTING_CHANNEL
import testConfig.Config.Companion.MEMBERS
import testConfig.Config.Companion.SERVER_URL
import testConfig.Config.Companion.TEST_CHANNEL


class MembersFragmentTest {
Expand All @@ -38,7 +38,6 @@ class MembersFragmentTest {
loginUserToTheApp()
navigateToChannelDetails()
} catch (e: NoMatchingViewException) {
Thread.sleep(3000)
navigateToChannelDetails()
}
}
Expand All @@ -52,7 +51,7 @@ class MembersFragmentTest {

private fun navigateToChannelDetails() {
Thread.sleep(3000)
onView(withText(EXISTING_CHANNEL)).perform(click())
onView(withText(TEST_CHANNEL)).perform(click())
Thread.sleep(2000)
onView(withId(R.id.text_toolbar_title)).perform(click())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import chat.rocket.android.R
import chat.rocket.android.analytics.event.ScreenViewEvent
import chat.rocket.android.authentication.ui.AuthenticationActivity
import chat.rocket.android.util.RecyclerViewItemCountAssertion.Companion.withItemCount
import chat.rocket.android.util.loginUserToTheApp
import chat.rocket.android.util.extensions.addFragmentBackStack
import chat.rocket.android.util.loginUserToTheApp
import org.hamcrest.Matchers.equalTo
import org.hamcrest.Matchers.greaterThan
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import testConfig.Config.Companion.EXISTING_CHANNEL
import testConfig.Config.Companion.EXISTING_CHANNEL2
import testConfig.Config.Companion.MENTIONS
import testConfig.Config.Companion.SERVER_URL
import testConfig.Config.Companion.TEST_CHANNEL
import testConfig.Config.Companion.TEST_CHANNEL2


class MentionsFragmentTest {
Expand Down Expand Up @@ -60,14 +60,14 @@ class MentionsFragmentTest {

private fun navigateToSandboxChannelDetails() {
Thread.sleep(3000)
onView(withText(EXISTING_CHANNEL2)).perform(click())
onView(withText(TEST_CHANNEL2)).perform(click())
Thread.sleep(2000)
onView(withId(R.id.text_toolbar_title)).perform(click())
}

private fun navigateToGeneralChannelDetails() {
Thread.sleep(3000)
onView(withText(EXISTING_CHANNEL)).perform(click())
onView(withText(TEST_CHANNEL)).perform(click())
Thread.sleep(2000)
onView(withId(R.id.text_toolbar_title)).perform(click())
}
Expand Down
Loading