Skip to content

Commit

Permalink
feat: merge main into assoc settings perms
Browse files Browse the repository at this point in the history
  • Loading branch information
SidonieBouthors committed Jun 2, 2024
2 parents 1fbc949 + a06b6d5 commit ad6de77
Show file tree
Hide file tree
Showing 62 changed files with 1,565 additions and 955 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ dependencies {
implementation("androidx.compose.material3:material3-android:1.2.1")
implementation("androidx.compose.material:material-icons-extended") // extra icons

// For pull to refresh
implementation("androidx.compose.material:material:1.6.7")

// Navigation
val navVersion = "2.7.7"
implementation("androidx.navigation:navigation-fragment-ktx:$navVersion")
Expand Down
4 changes: 0 additions & 4 deletions app/src/androidTest/java/com/github/se/assocify/Epic1Test.kt
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,6 @@ class Epic1Test : TestCase(kaspressoBuilder = Kaspresso.Builder.withComposeSuppo
onNodeWithTag("create").performClick()
verify { associationAPI.addAssociation(any(), any(), any()) }

val toHome = navController.currentBackStackEntry?.destination?.route
assert(toHome == Destination.Home.route)

onNodeWithTag("homeScreen").assertIsDisplayed()
onNodeWithTag("mainNavBarItem/profile").assertIsDisplayed().performClick()

// go to my profile
Expand Down
6 changes: 3 additions & 3 deletions app/src/androidTest/java/com/github/se/assocify/Epic4Test.kt
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ class Epic4Test : TestCase(kaspressoBuilder = Kaspresso.Builder.withComposeSuppo
verify { associationAPI.addAssociation(any(), any(), any()) }
assert(listAsso.contains(placeholderAssociations[0]))

// Arrives at home screen with association1 as the current association
// Arrives at treasury screen with association1 as the current association
val toHome = navController.currentBackStackEntry?.destination?.route
assert(toHome == Destination.Home.route)
onNodeWithTag("homeScreen").assertIsDisplayed()
assert(toHome == Destination.Treasury.route)
onNodeWithTag("treasuryScreen").assertIsDisplayed()

// Goes to the profile screen to check that and go to add their other association
onNodeWithTag("mainNavBarItem/profile").assertIsDisplayed().performClick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ class MainNavigationBarTest : TestCase(kaspressoBuilder = Kaspresso.Builder.with
MainNavigationBar(
onTabSelect = { tabPressed = it },
tabList = MAIN_TABS_LIST,
selectedTab = Destination.Home)
selectedTab = Destination.Treasury)
}
}

@Test
fun tabsDisplayed() {
with(composeTestRule) {
onNodeWithTag("mainNavBar").assertIsDisplayed()
onNodeWithTag("mainNavBar").onChild().onChildren().assertCountEquals(5)
onNodeWithTag("mainNavBar").onChild().onChildren().assertCountEquals(3)
}
}

Expand All @@ -50,9 +50,7 @@ class MainNavigationBarTest : TestCase(kaspressoBuilder = Kaspresso.Builder.with
with(composeTestRule) {
onNodeWithTag("mainNavBarItem/event").assertTextContains("Event")
onNodeWithTag("mainNavBarItem/profile").assertTextContains("Profile")
onNodeWithTag("mainNavBarItem/chat").assertTextContains("Chat")
onNodeWithTag("mainNavBarItem/treasury").assertTextContains("Treasury")
onNodeWithTag("mainNavBarItem/home").assertTextContains("Home")
}
}

Expand All @@ -61,9 +59,7 @@ class MainNavigationBarTest : TestCase(kaspressoBuilder = Kaspresso.Builder.with
with(composeTestRule) {
onNodeWithTag("eventIcon", useUnmergedTree = true).assertIsDisplayed()
onNodeWithTag("profileIcon", useUnmergedTree = true).assertIsDisplayed()
onNodeWithTag("chatIcon", useUnmergedTree = true).assertIsDisplayed()
onNodeWithTag("treasuryIcon", useUnmergedTree = true).assertIsDisplayed()
onNodeWithTag("homeIcon", useUnmergedTree = true).assertIsDisplayed()
}
}

Expand All @@ -74,12 +70,8 @@ class MainNavigationBarTest : TestCase(kaspressoBuilder = Kaspresso.Builder.with
assert(tabPressed == Destination.Event)
onNodeWithTag("mainNavBarItem/profile").performClick()
assert(tabPressed == Destination.Profile)
onNodeWithTag("mainNavBarItem/chat").performClick()
assert(tabPressed == Destination.Chat)
onNodeWithTag("mainNavBarItem/treasury").performClick()
assert(tabPressed == Destination.Treasury)
onNodeWithTag("mainNavBarItem/home").performClick()
assert(tabPressed == Destination.Home)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.se.assocify.screens

import androidx.compose.material3.SnackbarHostState
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
Expand All @@ -25,6 +26,7 @@ import com.github.se.assocify.ui.screens.treasury.accounting.AccountingFilterBar
import com.github.se.assocify.ui.screens.treasury.accounting.AccountingPage
import com.github.se.assocify.ui.screens.treasury.accounting.AccountingScreen
import com.github.se.assocify.ui.screens.treasury.accounting.AccountingViewModel
import com.github.se.assocify.ui.util.SnackbarSystem
import com.kaspersky.components.composesupport.config.withComposeSupport
import com.kaspersky.kaspresso.kaspresso.Kaspresso
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase
Expand Down Expand Up @@ -151,7 +153,11 @@ class AccountingScreenTest : TestCase(kaspressoBuilder = Kaspresso.Builder.withC
CurrentUser.associationUid = "associationId"
accountingViewModel =
AccountingViewModel(
mockAccountingCategoryAPI, mockAccountingSubCategoryAPI, mockBalanceAPI, mockBudgetAPI)
mockAccountingCategoryAPI,
mockAccountingSubCategoryAPI,
mockBalanceAPI,
mockBudgetAPI,
SnackbarSystem(SnackbarHostState()))
composeTestRule.setContent {
AccountingScreen(AccountingPage.BUDGET, mockNavActions, accountingViewModel)
AccountingFilterBar(accountingViewModel = accountingViewModel)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.se.assocify.screens

import androidx.compose.material3.SnackbarHostState
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
Expand All @@ -18,6 +19,7 @@ import com.github.se.assocify.model.entities.BalanceItem
import com.github.se.assocify.model.entities.BudgetItem
import com.github.se.assocify.ui.screens.treasury.accounting.AccountingViewModel
import com.github.se.assocify.ui.screens.treasury.accounting.accountingComposables.AddSubcategoryDialog
import com.github.se.assocify.ui.util.SnackbarSystem
import com.kaspersky.components.composesupport.config.withComposeSupport
import com.kaspersky.kaspresso.kaspresso.Kaspresso
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase
Expand Down Expand Up @@ -83,7 +85,8 @@ class AddSubcategoryDialogTest :
accountingCategoryAPI = accountingCategoryAPI,
accountingSubCategoryAPI = accountingSubCategoryAPI,
balanceAPI = balanceAPI,
budgetAPI = budgetAPI)
budgetAPI = budgetAPI,
SnackbarSystem(SnackbarHostState()))
composeTestRule.setContent { AddSubcategoryDialog(viewModel) }
viewModel.showNewSubcategoryDialog()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ class BalanceDetailedScreenTest :
}
with(composeTestRule) {
balanceDetailedViewModel.loadBalanceDetails()
onNodeWithTag("errorMessage").assertIsDisplayed().assertTextContains("Error loading category")
onNodeWithTag("errorMessage")
.assertIsDisplayed()
.assertTextContains("Error loading balance category")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,21 @@ class BudgetDetailedScreenTest :
}
}

@Test
fun testNegativeAmount() {
with(composeTestRule) {
onNodeWithTag("createNewItem").performClick()
onNodeWithTag("editDialogBox").assertIsDisplayed()
onNodeWithTag("editNameBox").performTextClearance()
onNodeWithTag("editNameBox").performTextInput("fees")
onNodeWithTag("editAmountBox").performTextClearance()
onNodeWithTag("editAmountBox").performTextInput("-5")
onNodeWithTag("editConfirmButton").performClick()
assert(!budgetDetailedViewModel.uiState.value.amountError)
onNodeWithTag("editDialogBox").assertIsNotDisplayed()
}
}

@Test
fun deleteTest() {
with(composeTestRule) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class CreateAssoScreenTest : TestCase(kaspressoBuilder = Kaspresso.Builder.withC
with(composeTestRule) {
onNodeWithTag("create").performClick()
verify { bigView.saveAsso() }
verify { mockNavActions.navigateToMainTab(Destination.Home) }
verify { mockNavActions.navigateToMainTab(Destination.Treasury) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,7 @@ class EventScreenTest : TestCase(kaspressoBuilder = Kaspresso.Builder.withCompos
fun testSetup() {
every { mockEventAPI.getEvents(any(), any()) } answers
{
val e1 =
Event(
"eventUID",
"testEvent1",
"a",
OffsetDateTime.now(),
OffsetDateTime.now(),
"me",
"46.518726,6.566613")
val e1 = Event("eventUID", "testEvent1", "a")
val onSuccessCallback = arg<(List<Event>) -> Unit>(0)
onSuccessCallback(listOf(e1))
}
Expand Down Expand Up @@ -134,16 +126,7 @@ class EventScreenTest : TestCase(kaspressoBuilder = Kaspresso.Builder.withCompos
fun testFilterChipShowAssoc() {
every { mockEventAPI.getEvents(any(), any()) } answers
{
val events =
listOf(
Event(
"1",
"filterChipTestEvent1",
"a",
OffsetDateTime.now(),
OffsetDateTime.now(),
"me",
"home"))
val events = listOf(Event("1", "filterChipTestEvent1", "a"))
val onSuccessCallback = firstArg<(List<Event>) -> Unit>()
onSuccessCallback(events)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.se.assocify.screens

import androidx.compose.material3.SnackbarHostState
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand All @@ -9,6 +10,7 @@ import com.github.se.assocify.model.entities.Task
import com.github.se.assocify.navigation.NavigationActions
import com.github.se.assocify.ui.screens.event.scheduletab.EventScheduleScreen
import com.github.se.assocify.ui.screens.event.scheduletab.EventScheduleViewModel
import com.github.se.assocify.ui.util.SnackbarSystem
import com.kaspersky.components.composesupport.config.withComposeSupport
import com.kaspersky.kaspresso.kaspresso.Kaspresso
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase
Expand Down Expand Up @@ -40,23 +42,15 @@ class ScheduleScreenTest : TestCase(kaspressoBuilder = Kaspresso.Builder.withCom
"Location",
"eventUid"))

private val events: List<Event> =
listOf(
Event(
"eventUid",
"Event 1",
"Event 1",
OffsetDateTime.now(),
OffsetDateTime.now(),
"Guests?",
"BC"))
private val events: List<Event> = listOf(Event("eventUid", "Event 1", "Event 1"))

private val taskAPI: TaskAPI =
mockk<TaskAPI>() {
every { getTasks(any(), any()) } answers { firstArg<(List<Task>) -> Unit>().invoke(tasks) }
}
private val navActions = mockk<NavigationActions>(relaxUnitFun = true)
private val viewModel = EventScheduleViewModel(navActions, taskAPI)
private val viewModel =
EventScheduleViewModel(navActions, taskAPI, SnackbarSystem(SnackbarHostState()))

@Before
fun testSetup() {
Expand Down
Loading

0 comments on commit ad6de77

Please sign in to comment.