Skip to content

Commit

Permalink
Merge branch 'main' into feat/association-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelien9Code authored Dec 19, 2024
2 parents a21e863 + 701b1cc commit 18be3ae
Show file tree
Hide file tree
Showing 56 changed files with 1,394 additions and 245 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import com.android.unio.model.event.EventRepository
import com.android.unio.model.event.EventUserPictureRepositoryFirestore
import com.android.unio.model.event.EventViewModel
import com.android.unio.model.image.ImageRepositoryFirebaseStorage
import com.android.unio.model.save.ConcurrentEventUserRepositoryFirestore
import com.android.unio.model.search.SearchRepository
import com.android.unio.model.search.SearchViewModel
import com.android.unio.model.strings.test_tags.navigation.NavigationActionTestTags
import com.android.unio.model.usecase.SaveUseCaseFirestore
import com.android.unio.model.usecase.UserDeletionUseCaseFirestore
import com.android.unio.model.user.UserRepository
import com.android.unio.model.user.UserRepositoryFirestore
import com.android.unio.model.user.UserViewModel
Expand All @@ -35,11 +36,10 @@ class BottomNavigationTest : TearDown() {

@MockK private lateinit var imageRepository: ImageRepositoryFirebaseStorage
@MockK private lateinit var associationRepositoryFirestore: AssociationRepositoryFirestore
@MockK private lateinit var userDeletionRepository: UserDeletionUseCaseFirestore
@MockK
private lateinit var eventUserPictureRepositoryFirestore: EventUserPictureRepositoryFirestore
@MockK
private lateinit var concurrentEventUserRepositoryFirestore:
ConcurrentEventUserRepositoryFirestore
@MockK private lateinit var concurrentEventUserRepositoryFirestore: SaveUseCaseFirestore

private lateinit var userRepository: UserRepository
private lateinit var userViewModel: UserViewModel
Expand All @@ -62,7 +62,7 @@ class BottomNavigationTest : TearDown() {
concurrentEventUserRepositoryFirestore)

userRepository = mock { UserRepositoryFirestore::class.java }
userViewModel = UserViewModel(userRepository, imageRepository)
userViewModel = UserViewModel(userRepository, imageRepository, userDeletionRepository)

searchViewModel = spyk(SearchViewModel(searchRepository))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ import com.android.unio.model.event.Event
import com.android.unio.model.event.EventRepositoryFirestore
import com.android.unio.model.event.EventUserPictureRepositoryFirestore
import com.android.unio.model.event.EventViewModel
import com.android.unio.model.follow.ConcurrentAssociationUserRepositoryFirestore
import com.android.unio.model.image.ImageRepositoryFirebaseStorage
import com.android.unio.model.image.ImageViewModel
import com.android.unio.model.map.MapViewModel
import com.android.unio.model.map.nominatim.NominatimLocationRepository
import com.android.unio.model.map.nominatim.NominatimLocationSearchViewModel
import com.android.unio.model.save.ConcurrentEventUserRepositoryFirestore
import com.android.unio.model.search.SearchRepository
import com.android.unio.model.search.SearchViewModel
import com.android.unio.model.strings.test_tags.association.AssociationProfileTestTags
Expand All @@ -40,6 +38,9 @@ import com.android.unio.model.strings.test_tags.saved.SavedTestTags
import com.android.unio.model.strings.test_tags.settings.SettingsTestTags
import com.android.unio.model.strings.test_tags.user.SomeoneElseUserProfileTestTags
import com.android.unio.model.strings.test_tags.user.UserProfileTestTags
import com.android.unio.model.usecase.FollowUseCaseFirestore
import com.android.unio.model.usecase.SaveUseCaseFirestore
import com.android.unio.model.usecase.UserDeletionUseCaseFirestore
import com.android.unio.model.user.User
import com.android.unio.model.user.UserRepositoryFirestore
import com.android.unio.model.user.UserViewModel
Expand Down Expand Up @@ -111,12 +112,11 @@ class ScreenDisplayingTest : TearDown() {
}

@MockK private lateinit var associationRepositoryFirestore: AssociationRepositoryFirestore
@MockK private lateinit var userDeletionRepository: UserDeletionUseCaseFirestore
@MockK private lateinit var imageRepositoryFirestore: ImageRepositoryFirebaseStorage
@MockK
private lateinit var eventUserPictureRepositoryFirestore: EventUserPictureRepositoryFirestore
@MockK
private lateinit var concurrentEventUserRepositoryFirestore:
ConcurrentEventUserRepositoryFirestore
@MockK private lateinit var concurrentEventUserRepositoryFirestore: SaveUseCaseFirestore

private lateinit var imageViewModel: ImageViewModel

Expand Down Expand Up @@ -153,7 +153,7 @@ class ScreenDisplayingTest : TearDown() {
associationRepositoryFirestore,
mockk<EventRepositoryFirestore>(),
imageRepositoryFirestore,
mockk<ConcurrentAssociationUserRepositoryFirestore>()))
mockk<FollowUseCaseFirestore>()))

every { eventRepository.getEvents(any(), any()) } answers
{
Expand Down Expand Up @@ -191,7 +191,7 @@ class ScreenDisplayingTest : TearDown() {
val onSuccess = args[1] as (User) -> Unit
onSuccess(user)
}
userViewModel = UserViewModel(userRepository, imageRepositoryFirestore)
userViewModel = UserViewModel(userRepository, imageRepositoryFirestore, userDeletionRepository)
userViewModel.getUserByUid("1", false)

searchViewModel = spyk(SearchViewModel(searchRepository))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ import com.android.unio.model.event.EventUserPictureRepositoryFirestore
import com.android.unio.model.event.EventViewModel
import com.android.unio.model.firestore.emptyFirestoreReferenceList
import com.android.unio.model.firestore.firestoreReferenceListWith
import com.android.unio.model.follow.ConcurrentAssociationUserRepositoryFirestore
import com.android.unio.model.hilt.module.FirebaseModule
import com.android.unio.model.image.ImageRepositoryFirebaseStorage
import com.android.unio.model.save.ConcurrentEventUserRepositoryFirestore
import com.android.unio.model.strings.test_tags.association.AssociationProfileTestTags
import com.android.unio.model.usecase.FollowUseCaseFirestore
import com.android.unio.model.usecase.SaveUseCaseFirestore
import com.android.unio.model.usecase.UserDeletionUseCaseFirestore
import com.android.unio.model.user.User
import com.android.unio.model.user.UserRepositoryFirestore
import com.android.unio.model.user.UserViewModel
Expand Down Expand Up @@ -88,18 +89,15 @@ class AssociationProfileTest : TearDown() {

@MockK private lateinit var eventRepository: EventRepositoryFirestore

@MockK
private lateinit var concurrentAssociationUserRepository:
ConcurrentAssociationUserRepositoryFirestore
@MockK private lateinit var concurrentAssociationUserRepository: FollowUseCaseFirestore

@MockK private lateinit var userRepository: UserRepositoryFirestore
@MockK private lateinit var userDeletionRepository: UserDeletionUseCaseFirestore

@MockK private lateinit var imageRepository: ImageRepositoryFirebaseStorage
@MockK
private lateinit var eventUserPictureRepositoryFirestore: EventUserPictureRepositoryFirestore
@MockK
private lateinit var concurrentEventUserRepositoryFirestore:
ConcurrentEventUserRepositoryFirestore
@MockK private lateinit var concurrentEventUserRepositoryFirestore: SaveUseCaseFirestore

@MockK private lateinit var connectivityManager: ConnectivityManager

Expand Down Expand Up @@ -248,7 +246,7 @@ class AssociationProfileTest : TearDown() {
onSuccess()
}

userViewModel = UserViewModel(userRepository, imageRepository)
userViewModel = UserViewModel(userRepository, imageRepository, userDeletionRepository)
userViewModel.addUser(user, {})

associationViewModel =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.android.unio.components.authentication

import androidx.compose.ui.test.assert
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.assertTextContains
import androidx.compose.ui.test.assertTextEquals
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
Expand Down Expand Up @@ -125,6 +128,27 @@ class AccountDetailsTest : TearDown() {
.assertTextContains("I am a student")
}

@Test
fun testClearButtonFunctionality() {
composeTestRule
.onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_TEXT_FIELD)
.performTextInput("John")
composeTestRule
.onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_TEXT_FIELD, useUnmergedTree = true)
.assertTextEquals("John", includeEditableText = true)
composeTestRule.onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_CLEAR_BUTTON).performClick()
composeTestRule.onNodeWithTag(AccountDetailsTestTags.FIRST_NAME_TEXT_FIELD).assert(hasText(""))

composeTestRule
.onNodeWithTag(AccountDetailsTestTags.LAST_NAME_TEXT_FIELD)
.performTextInput("Doe")
composeTestRule
.onNodeWithTag(AccountDetailsTestTags.LAST_NAME_TEXT_FIELD, useUnmergedTree = true)
.assertTextEquals("Doe", includeEditableText = true)
composeTestRule.onNodeWithTag(AccountDetailsTestTags.LAST_NAME_CLEAR_BUTTON).performClick()
composeTestRule.onNodeWithTag(AccountDetailsTestTags.LAST_NAME_TEXT_FIELD).assert(hasText(""))
}

@Test
fun testInterestsButtonWorksCorrectly() {
composeTestRule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.android.unio.mocks.user.MockUser
import com.android.unio.model.authentication.AuthViewModel
import com.android.unio.model.image.ImageRepositoryFirebaseStorage
import com.android.unio.model.strings.test_tags.authentication.WelcomeTestTags
import com.android.unio.model.usecase.UserDeletionUseCaseFirestore
import com.android.unio.model.user.User
import com.android.unio.model.user.UserRepositoryFirestore
import com.android.unio.model.user.UserViewModel
Expand Down Expand Up @@ -44,6 +45,7 @@ class WelcomeTest : TearDown() {
private lateinit var authViewModel: AuthViewModel
@MockK private lateinit var navigationAction: NavigationAction
@MockK private lateinit var userRepository: UserRepositoryFirestore
@MockK private lateinit var userDeletionRepository: UserDeletionUseCaseFirestore
@MockK private lateinit var imageRepository: ImageRepositoryFirebaseStorage
@MockK private lateinit var firebaseAuth: FirebaseAuth

Expand All @@ -65,7 +67,7 @@ class WelcomeTest : TearDown() {
}

navigationAction = mock(NavigationAction::class.java)
userViewModel = UserViewModel(userRepository, imageRepository)
userViewModel = UserViewModel(userRepository, imageRepository, userDeletionRepository)
authViewModel = AuthViewModel(firebaseAuth, userRepository)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import com.android.unio.mocks.user.MockUser
import com.android.unio.model.association.AssociationRepositoryFirestore
import com.android.unio.model.event.Event
import com.android.unio.model.event.EventRepositoryFirestore
import com.android.unio.model.event.EventType
import com.android.unio.model.event.EventUserPictureRepositoryFirestore
import com.android.unio.model.event.EventViewModel
import com.android.unio.model.image.ImageRepositoryFirebaseStorage
import com.android.unio.model.notification.NotificationWorker
import com.android.unio.model.save.ConcurrentEventUserRepositoryFirestore
import com.android.unio.model.strings.test_tags.event.EventCardTestTags
import com.android.unio.model.strings.test_tags.event.EventDetailsTestTags
import com.android.unio.model.usecase.SaveUseCaseFirestore
import com.android.unio.model.usecase.UserDeletionUseCaseFirestore
import com.android.unio.model.user.UserRepositoryFirestore
import com.android.unio.model.user.UserViewModel
import com.android.unio.ui.event.EventCard
Expand Down Expand Up @@ -76,11 +76,10 @@ class EventCardTest : TearDown() {
@MockK private lateinit var eventRepository: EventRepositoryFirestore
@MockK private lateinit var imageRepository: ImageRepositoryFirebaseStorage
@MockK private lateinit var associationRepository: AssociationRepositoryFirestore
@MockK private lateinit var userDeletionRepository: UserDeletionUseCaseFirestore
@MockK
private lateinit var eventUserPictureRepositoryFirestore: EventUserPictureRepositoryFirestore
@MockK
private lateinit var concurrentEventUserRepositoryFirestore:
ConcurrentEventUserRepositoryFirestore
@MockK private lateinit var concurrentEventUserRepositoryFirestore: SaveUseCaseFirestore
private lateinit var context: Context

@Before
Expand All @@ -101,7 +100,7 @@ class EventCardTest : TearDown() {
associationRepository,
eventUserPictureRepositoryFirestore,
concurrentEventUserRepositoryFirestore))
userViewModel = UserViewModel(userRepository, imageRepository)
userViewModel = UserViewModel(userRepository, imageRepository, userDeletionRepository)
every { userRepository.updateUser(user, any(), any()) } answers
{
val onSuccess = args[1] as () -> Unit
Expand Down Expand Up @@ -142,7 +141,7 @@ class EventCardTest : TearDown() {
composeTestRule
.onNodeWithTag(EventCardTestTags.EVENT_MAIN_TYPE, useUnmergedTree = true)
.assertExists()
.assertTextEquals(EventType.TRIP.text)
.assertTextEquals("Trip")

composeTestRule
.onNodeWithTag(EventCardTestTags.EVENT_LOCATION, useUnmergedTree = true)
Expand Down
Loading

0 comments on commit 18be3ae

Please sign in to comment.