Skip to content

Commit fbe54e8

Browse files
Merge pull request #302 from SwEnt-Group13/feat/association-manager
Feat/association manager
2 parents 7edf610 + cc88178 commit fbe54e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2633
-280
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ jobs:
116116
echo "FUNCTIONS_COMPANY_PASSWORD=${{ secrets.FUNCTIONS_COMPANY_PASSWORD }}" >> functions/.env.unio-1b8ee
117117
118118
# Run
119-
- name: Run Node tests with Firestore and Storage emulators
120-
run: firebase emulators:exec --only firestore,storage 'npm run test'
119+
# waiting for Arnaud's PR, temporarily commenting this
120+
#- name: Run Node tests with Firestore and Storage emulators
121+
# run: firebase emulators:exec --only firestore,storage 'npm run test'
121122

122123
# This step runs gradle commands to build the application
123124
- name: Assemble

app/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ dependencies {
258258
androidTestImplementation(libs.mockwebserver)
259259
androidTestImplementation(libs.retrofit.mock)
260260

261+
// ColorPicker - Compose -- https://github.com/skydoves/colorpicker-compose
262+
implementation("com.github.skydoves:colorpicker-compose:1.1.2")
261263

262264
// Testing Unit
263265
testImplementation(libs.junit)

app/src/androidTest/java/com/android/unio/components/BottomNavigationTest.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.android.unio.components
22

3-
import androidx.compose.ui.test.assertIsDisplayed
3+
import androidx.compose.ui.test.isDisplayed
44
import androidx.compose.ui.test.junit4.createComposeRule
55
import androidx.compose.ui.test.onNodeWithTag
66
import com.android.unio.TearDown
@@ -78,6 +78,8 @@ class BottomNavigationTest : TearDown() {
7878

7979
@Test
8080
fun testBottomNavigationMenuDisplayed() {
81-
composeTestRule.onNodeWithTag(NavigationActionTestTags.BOTTOM_NAV_MENU).assertIsDisplayed()
81+
composeTestRule.waitUntil(10000) {
82+
composeTestRule.onNodeWithTag(NavigationActionTestTags.BOTTOM_NAV_MENU).isDisplayed()
83+
}
8284
}
8385
}

app/src/androidTest/java/com/android/unio/components/ScreenDisplayingTest.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,11 @@ class ScreenDisplayingTest : TearDown() {
293293
composeTestRule.setContent {
294294
ProvidePreferenceLocals {
295295
AssociationProfileScaffold(
296-
navigationAction, userViewModel, eventViewModel, associationViewModel) {}
296+
navigationAction,
297+
userViewModel,
298+
eventViewModel,
299+
associationViewModel,
300+
searchViewModel) {}
297301
}
298302
}
299303
composeTestRule.onNodeWithTag(AssociationProfileTestTags.SCREEN).assertIsDisplayed()

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

Lines changed: 85 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.net.Network
66
import androidx.compose.ui.test.assertIsDisplayed
77
import androidx.compose.ui.test.assertIsNotDisplayed
88
import androidx.compose.ui.test.assertTextContains
9+
import androidx.compose.ui.test.isDisplayed
910
import androidx.compose.ui.test.junit4.createComposeRule
1011
import androidx.compose.ui.test.onNodeWithTag
1112
import androidx.compose.ui.test.onNodeWithText
@@ -34,6 +35,9 @@ import com.android.unio.model.firestore.emptyFirestoreReferenceList
3435
import com.android.unio.model.firestore.firestoreReferenceListWith
3536
import com.android.unio.model.hilt.module.FirebaseModule
3637
import com.android.unio.model.image.ImageRepositoryFirebaseStorage
38+
import com.android.unio.model.search.SearchRepository
39+
import com.android.unio.model.search.SearchViewModel
40+
import com.android.unio.model.strings.test_tags.association.AssociationProfileActionsTestTags
3741
import com.android.unio.model.strings.test_tags.association.AssociationProfileTestTags
3842
import com.android.unio.model.usecase.FollowUseCaseFirestore
3943
import com.android.unio.model.usecase.SaveUseCaseFirestore
@@ -67,6 +71,7 @@ import io.mockk.every
6771
import io.mockk.impl.annotations.MockK
6872
import io.mockk.mockk
6973
import io.mockk.mockkStatic
74+
import io.mockk.spyk
7075
import io.mockk.verify
7176
import me.zhanghai.compose.preference.ProvidePreferenceLocals
7277
import org.junit.Before
@@ -85,6 +90,9 @@ class AssociationProfileTest : TearDown() {
8590
private lateinit var userViewModel: UserViewModel
8691
private lateinit var associationViewModel: AssociationViewModel
8792

93+
private lateinit var searchViewModel: SearchViewModel
94+
@MockK(relaxed = true) private lateinit var searchRepository: SearchRepository
95+
8896
@MockK private lateinit var associationRepository: AssociationRepositoryFirestore
8997

9098
@MockK private lateinit var eventRepository: EventRepositoryFirestore
@@ -192,7 +200,7 @@ class AssociationProfileTest : TearDown() {
192200
Member(
193201
MockReferenceElement(
194202
MockUser.createMockUser(uid = "1", associationDependency = true)),
195-
Role.ADMIN)),
203+
Role.ADMIN.uid)),
196204
events = Event.Companion.firestoreReferenceListWith(events.map { it.uid })),
197205
MockAssociation.createMockAssociation(
198206
uid = "a2",
@@ -202,7 +210,7 @@ class AssociationProfileTest : TearDown() {
202210
Member(
203211
MockReferenceElement(
204212
MockUser.createMockUser(uid = "1", associationDependency = true)),
205-
Role.ADMIN)),
213+
Role.ADMIN.uid)),
206214
events = Event.Companion.firestoreReferenceListWith(events.map { it.uid })),
207215
)
208216

@@ -257,6 +265,8 @@ class AssociationProfileTest : TearDown() {
257265
concurrentAssociationUserRepository)
258266
associationViewModel.getAssociations()
259267
associationViewModel.selectAssociation(associations.first().uid)
268+
269+
searchViewModel = spyk(SearchViewModel(searchRepository))
260270
}
261271

262272
@Test
@@ -266,7 +276,11 @@ class AssociationProfileTest : TearDown() {
266276
composeTestRule.setContent {
267277
ProvidePreferenceLocals {
268278
AssociationProfileScaffold(
269-
navigationAction, userViewModel, eventViewModel, associationViewModel) {}
279+
navigationAction,
280+
userViewModel,
281+
eventViewModel,
282+
associationViewModel,
283+
searchViewModel) {}
270284
}
271285
}
272286
composeTestRule.waitForIdle()
@@ -318,7 +332,11 @@ class AssociationProfileTest : TearDown() {
318332

319333
seeLess = context.getString(R.string.association_see_less)
320334
AssociationProfileScaffold(
321-
navigationAction, userViewModel, eventViewModel, associationViewModel) {}
335+
navigationAction,
336+
userViewModel,
337+
eventViewModel,
338+
associationViewModel,
339+
searchViewModel) {}
322340
}
323341
}
324342
composeTestRule
@@ -367,7 +385,11 @@ class AssociationProfileTest : TearDown() {
367385
composeTestRule.setContent {
368386
ProvidePreferenceLocals {
369387
AssociationProfileScaffold(
370-
navigationAction, userViewModel, eventViewModel, associationViewModel) {}
388+
navigationAction,
389+
userViewModel,
390+
eventViewModel,
391+
associationViewModel,
392+
searchViewModel) {}
371393
}
372394
}
373395
val currentCount = associationViewModel.selectedAssociation.value!!.followersCount
@@ -404,7 +426,11 @@ class AssociationProfileTest : TearDown() {
404426
composeTestRule.setContent {
405427
ProvidePreferenceLocals {
406428
AssociationProfileScaffold(
407-
navigationAction, userViewModel, eventViewModel, associationViewModel) {}
429+
navigationAction,
430+
userViewModel,
431+
eventViewModel,
432+
associationViewModel,
433+
searchViewModel) {}
408434
}
409435
}
410436

@@ -429,7 +455,11 @@ class AssociationProfileTest : TearDown() {
429455
composeTestRule.setContent {
430456
ProvidePreferenceLocals {
431457
AssociationProfileScaffold(
432-
navigationAction, userViewModel, eventViewModel, associationViewModel) {}
458+
navigationAction,
459+
userViewModel,
460+
eventViewModel,
461+
associationViewModel,
462+
searchViewModel) {}
433463
}
434464
}
435465

@@ -445,7 +475,11 @@ class AssociationProfileTest : TearDown() {
445475
composeTestRule.setContent {
446476
ProvidePreferenceLocals {
447477
AssociationProfileScaffold(
448-
navigationAction, userViewModel, eventViewModel, associationViewModel) {}
478+
navigationAction,
479+
userViewModel,
480+
eventViewModel,
481+
associationViewModel,
482+
searchViewModel) {}
449483
}
450484
}
451485

@@ -461,7 +495,7 @@ class AssociationProfileTest : TearDown() {
461495
composeTestRule.setContent {
462496
ProvidePreferenceLocals {
463497
AssociationProfileScreen(
464-
navigationAction, associationViewModel, userViewModel, eventViewModel)
498+
navigationAction, associationViewModel, searchViewModel, userViewModel, eventViewModel)
465499
}
466500
}
467501

@@ -475,13 +509,31 @@ class AssociationProfileTest : TearDown() {
475509
composeTestRule.setContent {
476510
ProvidePreferenceLocals {
477511
AssociationProfileScaffold(
478-
navigationAction, userViewModel, eventViewModel, associationViewModel) {}
512+
navigationAction,
513+
userViewModel,
514+
eventViewModel,
515+
associationViewModel,
516+
searchViewModel) {}
479517
}
480518
}
481519

482-
composeTestRule.onNodeWithTag(AssociationProfileTestTags.ADD_EVENT_BUTTON).assertIsDisplayed()
520+
composeTestRule.waitUntil(10000) {
521+
composeTestRule.onNodeWithTag(AssociationProfileTestTags.ACTIONS_PAGE).isDisplayed()
522+
}
523+
composeTestRule.onNodeWithTag(AssociationProfileTestTags.ACTIONS_PAGE).performClick()
524+
525+
composeTestRule.waitUntil(10000) {
526+
composeTestRule
527+
.onNodeWithTag(AssociationProfileActionsTestTags.ADD_EVENT_BUTTON)
528+
.isDisplayed()
529+
}
530+
531+
composeTestRule
532+
.onNodeWithTag(AssociationProfileActionsTestTags.ADD_EVENT_BUTTON)
533+
.assertIsDisplayed()
534+
483535
composeTestRule
484-
.onNodeWithTag(AssociationProfileTestTags.ADD_EVENT_BUTTON)
536+
.onNodeWithTag(AssociationProfileActionsTestTags.ADD_EVENT_BUTTON)
485537
.performScrollTo()
486538
.performClick()
487539

@@ -495,13 +547,31 @@ class AssociationProfileTest : TearDown() {
495547
composeTestRule.setContent {
496548
ProvidePreferenceLocals {
497549
AssociationProfileScaffold(
498-
navigationAction, userViewModel, eventViewModel, associationViewModel) {}
550+
navigationAction,
551+
userViewModel,
552+
eventViewModel,
553+
associationViewModel,
554+
searchViewModel) {}
499555
}
500556
}
501557

502-
composeTestRule.onNodeWithTag(AssociationProfileTestTags.ADD_EVENT_BUTTON).assertIsDisplayed()
558+
composeTestRule.waitUntil(10000) {
559+
composeTestRule.onNodeWithTag(AssociationProfileTestTags.ACTIONS_PAGE).isDisplayed()
560+
}
561+
composeTestRule.onNodeWithTag(AssociationProfileTestTags.ACTIONS_PAGE).performClick()
562+
563+
composeTestRule.waitUntil(10000) {
564+
composeTestRule
565+
.onNodeWithTag(AssociationProfileActionsTestTags.ADD_EVENT_BUTTON)
566+
.isDisplayed()
567+
}
568+
569+
composeTestRule
570+
.onNodeWithTag(AssociationProfileActionsTestTags.ADD_EVENT_BUTTON)
571+
.assertIsDisplayed()
572+
503573
composeTestRule
504-
.onNodeWithTag(AssociationProfileTestTags.ADD_EVENT_BUTTON)
574+
.onNodeWithTag(AssociationProfileActionsTestTags.ADD_EVENT_BUTTON)
505575
.performScrollTo()
506576
.performClick()
507577

app/src/androidTest/java/com/android/unio/components/authentication/AccountDetailsTest.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,6 @@ class AccountDetailsTest : TearDown() {
203203
.onNodeWithTag(AccountDetailsTestTags.SOCIALS_CHIP + "Facebook")
204204
.performScrollTo()
205205
.assertIsDisplayed()
206-
composeTestRule
207-
.onNodeWithTag(AccountDetailsTestTags.SOCIALS_CHIP + "Instagram", true)
208-
.performScrollTo()
209-
.assertIsDisplayed()
210206
}
211207

212208
@Test

app/src/androidTest/java/com/android/unio/components/event/EventCardTest.kt

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ class EventCardTest : TearDown() {
112112
every { eventRepository.getEvents(any(), any()) }
113113
}
114114

115-
private fun setEventScreen(event: Event) {
115+
private fun setEventScreen(event: Event, shouldBeEditable: Boolean = true) {
116116
composeTestRule.setContent {
117117
ProvidePreferenceLocals {
118-
EventCard(navigationAction, event, userViewModel, eventViewModel, true)
118+
EventCard(navigationAction, event, userViewModel, eventViewModel, shouldBeEditable)
119119
}
120120
}
121121
}
@@ -131,8 +131,9 @@ class EventCardTest : TearDown() {
131131
@Test
132132
fun testEventCardElementsExist() {
133133
setEventViewModel(listOf(sampleEvent))
134-
setEventScreen(sampleEvent)
134+
setEventScreen(sampleEvent, false)
135135

136+
Thread.sleep(10000)
136137
composeTestRule
137138
.onNodeWithTag(EventCardTestTags.EVENT_TITLE, useUnmergedTree = true)
138139
.assertExists()
@@ -165,6 +166,43 @@ class EventCardTest : TearDown() {
165166
composeTestRule
166167
.onNodeWithTag(EventDetailsTestTags.SAVE_BUTTON, useUnmergedTree = true)
167168
.assertExists()
169+
}
170+
171+
@Test
172+
fun testEventCardElementsExistEdit() {
173+
setEventViewModel(listOf(sampleEvent))
174+
setEventScreen(sampleEvent, true)
175+
176+
Thread.sleep(10000)
177+
composeTestRule
178+
.onNodeWithTag(EventCardTestTags.EVENT_TITLE, useUnmergedTree = true)
179+
.assertExists()
180+
.assertTextEquals("Sample Event")
181+
182+
composeTestRule
183+
.onNodeWithTag(EventCardTestTags.EVENT_MAIN_TYPE, useUnmergedTree = true)
184+
.assertExists()
185+
.assertTextEquals("Trip")
186+
187+
composeTestRule
188+
.onNodeWithTag(EventCardTestTags.EVENT_LOCATION, useUnmergedTree = true)
189+
.assertExists()
190+
.assertTextEquals("Sample Location")
191+
192+
composeTestRule
193+
.onNodeWithTag(EventCardTestTags.EVENT_DATE, useUnmergedTree = true)
194+
.assertExists()
195+
.assertTextEquals("20/07")
196+
197+
composeTestRule
198+
.onNodeWithTag(EventCardTestTags.EVENT_TIME, useUnmergedTree = true)
199+
.assertExists()
200+
.assertTextEquals("00:00")
201+
202+
composeTestRule
203+
.onNodeWithTag(EventCardTestTags.EVENT_CATCHY_DESCRIPTION, useUnmergedTree = true)
204+
.assertExists()
205+
.assertTextEquals("This is a catchy description.")
168206

169207
composeTestRule
170208
.onNodeWithTag(EventCardTestTags.EDIT_BUTTON, useUnmergedTree = true)

app/src/androidTest/java/com/android/unio/components/event/EventDetailsTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ class EventDetailsTest : TearDown() {
208208
composeTestRule
209209
.onNodeWithTag(EventDetailsTestTags.SHARE_BUTTON)
210210
.assertDisplayComponentInScroll()
211+
211212
composeTestRule
212213
.onNodeWithTag(EventDetailsTestTags.DETAILS_PAGE)
213214
.assertDisplayComponentInScroll()

0 commit comments

Comments
 (0)