Skip to content

Commit 3e73b45

Browse files
Merge pull request #294 from SwEnt-Group13/feat/create-association
Feat/create association
2 parents 282c88c + 4506481 commit 3e73b45

28 files changed

+765
-518
lines changed

app/src/androidTest/java/com/android/unio/components/association/EditAssociationTest.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import com.android.unio.assertDisplayComponentInScroll
88
import com.android.unio.mocks.association.MockAssociation
99
import com.android.unio.model.association.Association
1010
import com.android.unio.model.association.AssociationRepository
11-
import com.android.unio.model.strings.test_tags.association.EditAssociationTestTags
12-
import com.android.unio.ui.association.EditAssociationScaffold
11+
import com.android.unio.model.strings.test_tags.association.SaveAssociationTestTags
12+
import com.android.unio.ui.association.SaveAssociationScaffold
1313
import com.android.unio.ui.navigation.NavigationAction
1414
import com.google.firebase.firestore.CollectionReference
1515
import com.google.firebase.firestore.FirebaseFirestore
@@ -57,26 +57,29 @@ class EditAssociationTest : TearDown() {
5757
@Test
5858
fun testEditAssociationScreenDisplaysCorrectly() {
5959
composeTestRule.setContent {
60-
EditAssociationScaffold(
61-
MockAssociation.createMockAssociation(uid = "1"), onCancel = {}, onSave = {})
60+
SaveAssociationScaffold(
61+
association = MockAssociation.createMockAssociation(uid = "1"),
62+
onCancel = {},
63+
onSave = { _, _ -> },
64+
isNewAssociation = false)
6265
}
6366

6467
composeTestRule.waitForIdle()
6568

6669
composeTestRule
67-
.onNodeWithTag(EditAssociationTestTags.NAME_TEXT_FIELD)
70+
.onNodeWithTag(SaveAssociationTestTags.NAME_TEXT_FIELD)
6871
.assertDisplayComponentInScroll()
6972
composeTestRule
70-
.onNodeWithTag(EditAssociationTestTags.FULL_NAME_TEXT_FIELD)
73+
.onNodeWithTag(SaveAssociationTestTags.FULL_NAME_TEXT_FIELD)
7174
.assertDisplayComponentInScroll()
7275
composeTestRule
73-
.onNodeWithTag(EditAssociationTestTags.CATEGORY_BUTTON)
76+
.onNodeWithTag(SaveAssociationTestTags.CATEGORY_BUTTON)
7477
.assertDisplayComponentInScroll()
7578
composeTestRule
76-
.onNodeWithTag(EditAssociationTestTags.DESCRIPTION_TEXT_FIELD)
79+
.onNodeWithTag(SaveAssociationTestTags.DESCRIPTION_TEXT_FIELD)
7780
.assertDisplayComponentInScroll()
7881
composeTestRule
79-
.onNodeWithTag(EditAssociationTestTags.URL_TEXT_FIELD)
82+
.onNodeWithTag(SaveAssociationTestTags.URL_TEXT_FIELD)
8083
.assertDisplayComponentInScroll()
8184
}
8285
}

app/src/androidTest/java/com/android/unio/components/user/UserClaimAssociationPresidentialRightsTest.kt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
package com.android.unio.components.user
44

5-
import androidx.compose.ui.test.assertIsDisplayed
65
import androidx.compose.ui.test.junit4.createComposeRule
76
import androidx.compose.ui.test.onNodeWithTag
8-
import androidx.compose.ui.test.onNodeWithText
97
import androidx.compose.ui.test.performClick
108
import androidx.navigation.NavHostController
119
import com.android.unio.TearDown
@@ -16,6 +14,10 @@ import com.android.unio.model.association.AssociationViewModel
1614
import com.android.unio.model.event.EventRepositoryFirestore
1715
import com.android.unio.model.follow.ConcurrentAssociationUserRepositoryFirestore
1816
import com.android.unio.model.image.ImageRepositoryFirebaseStorage
17+
import com.android.unio.model.search.SearchRepository
18+
import com.android.unio.model.search.SearchViewModel
19+
import com.android.unio.model.user.UserRepositoryFirestore
20+
import com.android.unio.model.user.UserViewModel
1921
import com.android.unio.ui.navigation.NavigationAction
2022
import com.android.unio.ui.user.UserClaimAssociationPresidentialRightsScreenScaffold
2123
import dagger.hilt.android.testing.HiltAndroidRule
@@ -36,6 +38,8 @@ class UserClaimAssociationPresidentialRightsTest : TearDown() {
3638
@MockK private lateinit var associationRepository: AssociationRepositoryFirestore
3739
@MockK private lateinit var eventRepository: EventRepositoryFirestore
3840
@MockK private lateinit var imageRepository: ImageRepositoryFirebaseStorage
41+
@MockK private lateinit var userRepository: UserRepositoryFirestore
42+
@MockK private lateinit var searchRepository: SearchRepository
3943
@MockK
4044
private lateinit var concurrentAssociationUserRepositoryFirestore:
4145
ConcurrentAssociationUserRepositoryFirestore
@@ -44,6 +48,10 @@ class UserClaimAssociationPresidentialRightsTest : TearDown() {
4448
private lateinit var associationViewModel: AssociationViewModel
4549
@MockK private lateinit var navigationAction: NavigationAction
4650

51+
private lateinit var searchViewModel: SearchViewModel
52+
53+
private lateinit var userViewModel: UserViewModel
54+
4755
// test data
4856
private val testAssociation =
4957
MockAssociation.createMockAssociation(
@@ -65,25 +73,20 @@ class UserClaimAssociationPresidentialRightsTest : TearDown() {
6573
imageRepository,
6674
concurrentAssociationUserRepositoryFirestore)
6775
navigationAction = NavigationAction(navHostController)
68-
}
69-
70-
@Test
71-
fun testEmailVerificationInputAndErrorHandling() {
72-
composeTestRule.setContent {
73-
UserClaimAssociationPresidentialRightsScreenScaffold(
74-
association = testAssociation, user = testUser, navigationAction = navigationAction)
75-
}
7676

77-
composeTestRule.onNodeWithText("Enter the presidential email address:").assertIsDisplayed()
77+
userViewModel = UserViewModel(userRepository = userRepository, imageRepository)
7878

79-
composeTestRule.onNodeWithText("Verify Email").performClick()
79+
searchViewModel = SearchViewModel(searchRepository)
8080
}
8181

8282
@Test
8383
fun testBackButtonNavigatesBack() {
8484
composeTestRule.setContent {
8585
UserClaimAssociationPresidentialRightsScreenScaffold(
86-
association = testAssociation, user = testUser, navigationAction = navigationAction)
86+
navigationAction = navigationAction,
87+
associationViewModel = associationViewModel,
88+
user = MockUser.createMockUser(uid = "1"),
89+
searchViewModel = searchViewModel)
8790
}
8891

8992
// click the back button

app/src/androidTest/java/com/android/unio/components/user/UserClaimAssociationTest.kt

Lines changed: 0 additions & 103 deletions
This file was deleted.

app/src/androidTest/java/com/android/unio/end2end/ClaimAdminRightsTest.kt

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,39 @@ class ClaimAdminRightsTest : EndToEndTest() {
2929
signInWithUser(composeTestRule, Admin.EMAIL, Admin.PASSWORD)
3030

3131
// Wait until "HomeScreen" is displayed
32-
composeTestRule.waitUntil(10001) {
32+
composeTestRule.waitUntil(10000) {
3333
composeTestRule.onNodeWithTag(HomeTestTags.SCREEN).isDisplayed()
3434
}
3535

3636
// Wait until the bottom nav bar is displayed
37-
composeTestRule.waitUntil(10002) {
37+
composeTestRule.waitUntil(10000) {
3838
composeTestRule.onNodeWithTag(BottomNavBarTestTags.MY_PROFILE).isDisplayed()
3939
}
4040

4141
/** Navigate to the profile screen */
4242
composeTestRule.onNodeWithTag(BottomNavBarTestTags.MY_PROFILE).performClick()
4343

44-
composeTestRule.waitUntil(10003) {
44+
composeTestRule.waitUntil(10000) {
4545
composeTestRule.onNodeWithTag(UserProfileTestTags.SCREEN).isDisplayed()
4646
}
4747

48+
composeTestRule.waitUntil(10000) {
49+
composeTestRule.onNodeWithTag(UserProfileTestTags.SETTINGS).isDisplayed()
50+
}
51+
composeTestRule.onNodeWithTag(UserProfileTestTags.SETTINGS).performClick()
4852
/** Navigate to the claiming button screen */
49-
composeTestRule.onNodeWithTag(UserProfileTestTags.CLAIMING_BUTTON).performClick()
53+
composeTestRule.waitUntil(10000) {
54+
composeTestRule.onNodeWithTag(UserProfileTestTags.CLAIM_ASSOCIATION).isDisplayed()
55+
}
56+
composeTestRule.onNodeWithTag(UserProfileTestTags.CLAIM_ASSOCIATION).performClick()
5057

5158
composeTestRule.onNodeWithTag(ExploreContentTestTags.SEARCH_BAR).assertIsDisplayed()
5259
composeTestRule
5360
.onNodeWithTag(ExploreContentTestTags.SEARCH_BAR_INPUT)
5461
.performTextInput(ASSOCIATION_SEARCH_INPUT)
5562

5663
// Wait for the server's response to get the association
57-
composeTestRule.waitUntil(10004) {
64+
composeTestRule.waitUntil(10000) {
5865
composeTestRule
5966
.onNodeWithTag(
6067
ExploreContentTestTags.ASSOCIATION_EXPLORE_RESULT + EXPECTED_ASSOCIATION_NAME)
@@ -66,7 +73,7 @@ class ClaimAdminRightsTest : EndToEndTest() {
6673
ExploreContentTestTags.ASSOCIATION_EXPLORE_RESULT + EXPECTED_ASSOCIATION_NAME)
6774
.performClick()
6875

69-
composeTestRule.waitUntil(5005) {
76+
composeTestRule.waitUntil(10000) {
7077
composeTestRule
7178
.onNodeWithTag(UserClaimAssociationPresidentialRightsTestTags.SCREEN)
7279
.isDisplayed()
@@ -83,13 +90,13 @@ class ClaimAdminRightsTest : EndToEndTest() {
8390
.onNodeWithTag(UserClaimAssociationPresidentialRightsTestTags.VERIFY_EMAIL_BUTTON)
8491
.performClick()
8592

86-
composeTestRule.waitUntil(5006) {
93+
composeTestRule.waitUntil(10000) {
8794
composeTestRule
8895
.onNodeWithTag(UserClaimAssociationPresidentialRightsTestTags.CODE)
8996
.isDisplayed()
9097
}
9198

92-
Thread.sleep(8007) // wait a few seconds according to
99+
Thread.sleep(10000) // wait a few seconds according to
93100
// https://firebase.google.com/docs/emulator-suite/connect_firestore#how_the_emulator_differs_from_production
94101

95102
var finalCode = ""
@@ -116,7 +123,7 @@ class ClaimAdminRightsTest : EndToEndTest() {
116123
throw IllegalStateException("Failed to fetch verification code: ${exception.message}")
117124
}
118125

119-
composeTestRule.waitUntil(30008) {
126+
composeTestRule.waitUntil(10000) {
120127
finalCode.isNotEmpty()
121128
} // otherwise it directly goes to the rest of the code
122129

@@ -128,7 +135,7 @@ class ClaimAdminRightsTest : EndToEndTest() {
128135
.onNodeWithTag(UserClaimAssociationPresidentialRightsTestTags.SUBMIT_CODE_BUTTON)
129136
.performClick()
130137

131-
composeTestRule.waitUntil(10009) {
138+
composeTestRule.waitUntil(10000) {
132139
composeTestRule.onNodeWithTag(UserProfileTestTags.SCREEN).isDisplayed()
133140
}
134141

0 commit comments

Comments
 (0)