From c652265ac44d57e5733c9029664e9fc5038fd46a Mon Sep 17 00:00:00 2001 From: francelu Date: Thu, 21 Nov 2024 18:23:18 +0100 Subject: [PATCH 01/10] feat: add settings button to `TopAppBar` --- .../periodpals/ui/navigation/TopAppBar.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/src/main/java/com/android/periodpals/ui/navigation/TopAppBar.kt b/app/src/main/java/com/android/periodpals/ui/navigation/TopAppBar.kt index c0d323252..7ef44ad4e 100644 --- a/app/src/main/java/com/android/periodpals/ui/navigation/TopAppBar.kt +++ b/app/src/main/java/com/android/periodpals/ui/navigation/TopAppBar.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.ArrowBack import androidx.compose.material.icons.outlined.Edit +import androidx.compose.material.icons.outlined.Settings import androidx.compose.material3.CenterAlignedTopAppBar import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon @@ -59,12 +60,20 @@ fun TopAppBar( title: String, backButton: Boolean = false, onBackButtonClick: (() -> Unit)? = null, + settingsButton: Boolean = false, + onSettingsButtonClick: (() -> Unit)? = null, editButton: Boolean = false, onEditButtonClick: (() -> Unit)? = null, ) { + require(!(backButton && settingsButton)) { + "Either backButton or settingsButton must be true, but not both" + } require(!(backButton && onBackButtonClick == null)) { "onBackButtonClick must be provided when backButton is true" } + require(!(settingsButton && onSettingsButtonClick == null)) { + "onSettingsButtonClick must be provided when settingsButton is true" + } require(!(editButton && onEditButtonClick == null)) { "onEditButtonClick must be provided when editButton is true" } @@ -91,6 +100,18 @@ fun TopAppBar( contentDescription = "Back", ) } + } else if (settingsButton) { + IconButton( + modifier = Modifier.wrapContentSize().testTag(TopAppBar.SETTINGS_BUTTON), + onClick = onSettingsButtonClick!!, + colors = getTopAppBarIconButtonColors(), + ) { + Icon( + modifier = Modifier.size(MaterialTheme.dimens.iconSize), + imageVector = Icons.Outlined.Settings, + contentDescription = "Settings", + ) + } } }, actions = { From 2c273817b193d5091f5fbcc74af9ead574369397 Mon Sep 17 00:00:00 2001 From: francelu Date: Thu, 21 Nov 2024 18:25:41 +0100 Subject: [PATCH 02/10] feat: add tests for settings button to `TopAppBarTest` - Add test tag in `C.kt` for settings button --- .../com/android/periodpals/resources/C.kt | 1 + .../periodpals/ui/navigation/TopAppBarTest.kt | 72 +++++++++++++++++-- 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/android/periodpals/resources/C.kt b/app/src/main/java/com/android/periodpals/resources/C.kt index ee7b728cc..c64e2cc9d 100644 --- a/app/src/main/java/com/android/periodpals/resources/C.kt +++ b/app/src/main/java/com/android/periodpals/resources/C.kt @@ -110,6 +110,7 @@ object C { object TopAppBar { const val TOP_BAR = "topBar" const val GO_BACK_BUTTON = "goBackButton" + const val SETTINGS_BUTTON = "settingsButton" const val EDIT_BUTTON = "editButton" const val TITLE_TEXT = "titleText" } diff --git a/app/src/test/java/com/android/periodpals/ui/navigation/TopAppBarTest.kt b/app/src/test/java/com/android/periodpals/ui/navigation/TopAppBarTest.kt index 0e2a428f1..269366ac1 100644 --- a/app/src/test/java/com/android/periodpals/ui/navigation/TopAppBarTest.kt +++ b/app/src/test/java/com/android/periodpals/ui/navigation/TopAppBarTest.kt @@ -29,7 +29,7 @@ class TopAppBarTest { @Test fun backButtonIsDisplayed() { composeTestRule.setContent { - TopAppBar(title = "Tampon Timer", backButton = true, onBackButtonClick = { /* Do nothing */}) + TopAppBar(title = "Tampon Timer", backButton = true, onBackButtonClick = { /* Do nothing */ }) } composeTestRule.onNodeWithTag(TopAppBar.TOP_BAR).assertIsDisplayed() @@ -41,7 +41,7 @@ class TopAppBarTest { @Test fun editButtonIsDisplayed() { composeTestRule.setContent { - TopAppBar(title = "Tampon Timer", editButton = true, onEditButtonClick = { /* Do nothing */}) + TopAppBar(title = "Tampon Timer", editButton = true, onEditButtonClick = { /* Do nothing */ }) } composeTestRule.onNodeWithTag(TopAppBar.TOP_BAR).assertIsDisplayed() @@ -51,14 +51,31 @@ class TopAppBarTest { } @Test - fun backAndEditButtonsAreDisplayed() { + fun settingsButtonIsDisplayed() { + composeTestRule.setContent { + TopAppBar( + title = "Tampon Timer", + settingsButton = true, + onSettingsButtonClick = { /* Do nothing */ }, + ) + } + + composeTestRule.onNodeWithTag(TopAppBar.TOP_BAR).assertIsDisplayed() + composeTestRule.onNodeWithTag(TopAppBar.TITLE_TEXT).assertIsDisplayed() + composeTestRule.onNodeWithTag(TopAppBar.SETTINGS_BUTTON).assertIsDisplayed() + composeTestRule.onNodeWithTag(TopAppBar.GO_BACK_BUTTON).assertDoesNotExist() + composeTestRule.onNodeWithTag(TopAppBar.EDIT_BUTTON).assertDoesNotExist() + } + + @Test + fun allButtonsAreDisplayed() { composeTestRule.setContent { TopAppBar( title = "Tampon Timer", backButton = true, - onBackButtonClick = { /* Do nothing */}, + onBackButtonClick = { /* Do nothing */ }, editButton = true, - onEditButtonClick = { /* Do nothing */}, + onEditButtonClick = { /* Do nothing */ }, ) } @@ -100,6 +117,22 @@ class TopAppBarTest { assert(editButtonClicked) } + @Test + fun settingsButtonClickWorks() { + var settingsButtonClicked = false + + composeTestRule.setContent { + TopAppBar( + title = "Tampon Timer", + settingsButton = true, + onSettingsButtonClick = { settingsButtonClicked = true }, + ) + } + + composeTestRule.onNodeWithTag(TopAppBar.SETTINGS_BUTTON).performClick() + assert(settingsButtonClicked) + } + @Test fun backButtonInvalidFunction() { val exception = @@ -119,4 +152,33 @@ class TopAppBarTest { } assert(exception.message == "onEditButtonClick must be provided when editButton is true") } + + @Test + fun settingsButtonInvalidFunction() { + val exception = + assertThrows(IllegalArgumentException::class.java) { + composeTestRule.setContent { + TopAppBar(title = "Test Title", settingsButton = true, onSettingsButtonClick = null) + } + } + assert( + exception.message == "onSettingsButtonClick must be provided when settingsButton is true") + } + + @Test + fun cannotHaveBothBackAndSettingsButtons() { + val exception = + assertThrows(IllegalArgumentException::class.java) { + composeTestRule.setContent { + TopAppBar( + title = "Test Title", + backButton = true, + onBackButtonClick = { /* Do nothing */ }, + settingsButton = true, + onSettingsButtonClick = { /* Do nothing */ }, + ) + } + } + assert(exception.message == "Either backButton or settingsButton must be true, but not both") + } } From 19e17cd77a43aaa3d30f45e87cb771ba2015ab87 Mon Sep 17 00:00:00 2001 From: francelu Date: Thu, 21 Nov 2024 18:39:46 +0100 Subject: [PATCH 03/10] feat: add settings button to `ProfileScreen` and tests --- .../com/android/periodpals/MainActivity.kt | 2 + .../ui/navigation/NavigationActions.kt | 1 + .../periodpals/ui/profile/ProfileScreen.kt | 2 + .../periodpals/ui/settings/SettingsScreen.kt | 43 +++++++++++++++++++ .../ui/profile/ProfileScreenTest.kt | 11 +++++ 5 files changed, 59 insertions(+) create mode 100644 app/src/main/java/com/android/periodpals/ui/settings/SettingsScreen.kt diff --git a/app/src/main/java/com/android/periodpals/MainActivity.kt b/app/src/main/java/com/android/periodpals/MainActivity.kt index 3d32988d5..f2cb858ac 100644 --- a/app/src/main/java/com/android/periodpals/MainActivity.kt +++ b/app/src/main/java/com/android/periodpals/MainActivity.kt @@ -31,6 +31,7 @@ import com.android.periodpals.ui.navigation.Screen import com.android.periodpals.ui.profile.CreateProfileScreen import com.android.periodpals.ui.profile.EditProfileScreen import com.android.periodpals.ui.profile.ProfileScreen +import com.android.periodpals.ui.settings.SettingsScreen import com.android.periodpals.ui.theme.PeriodPalsAppTheme import com.android.periodpals.ui.timer.TimerScreen import io.github.jan.supabase.auth.Auth @@ -134,6 +135,7 @@ fun PeriodPalsApp( navigation(startDestination = Screen.PROFILE, route = Route.PROFILE) { composable(Screen.PROFILE) { ProfileScreen(userViewModel, navigationActions) } composable(Screen.EDIT_PROFILE) { EditProfileScreen(userViewModel, navigationActions) } + composable(Screen.SETTINGS) { SettingsScreen(navigationActions) } } } } diff --git a/app/src/main/java/com/android/periodpals/ui/navigation/NavigationActions.kt b/app/src/main/java/com/android/periodpals/ui/navigation/NavigationActions.kt index 638810329..90ff5f374 100644 --- a/app/src/main/java/com/android/periodpals/ui/navigation/NavigationActions.kt +++ b/app/src/main/java/com/android/periodpals/ui/navigation/NavigationActions.kt @@ -29,6 +29,7 @@ object Screen { const val SIGN_UP = "Register Screen" const val CREATE_PROFILE = "CreateProfile Screen" const val EDIT_PROFILE = "EditProfile Screen" + const val SETTINGS = "Settings Screen" // TODO: Add as app is being built } diff --git a/app/src/main/java/com/android/periodpals/ui/profile/ProfileScreen.kt b/app/src/main/java/com/android/periodpals/ui/profile/ProfileScreen.kt index 0e87a411a..413c29939 100644 --- a/app/src/main/java/com/android/periodpals/ui/profile/ProfileScreen.kt +++ b/app/src/main/java/com/android/periodpals/ui/profile/ProfileScreen.kt @@ -88,6 +88,8 @@ fun ProfileScreen(userViewModel: UserViewModel, navigationActions: NavigationAct topBar = { TopAppBar( title = SCREEN_TITLE, + settingsButton = true, + onSettingsButtonClick = { navigationActions.navigateTo(Screen.SETTINGS) }, editButton = true, onEditButtonClick = { navigationActions.navigateTo(Screen.EDIT_PROFILE) }, ) diff --git a/app/src/main/java/com/android/periodpals/ui/settings/SettingsScreen.kt b/app/src/main/java/com/android/periodpals/ui/settings/SettingsScreen.kt new file mode 100644 index 000000000..7bce7d3e6 --- /dev/null +++ b/app/src/main/java/com/android/periodpals/ui/settings/SettingsScreen.kt @@ -0,0 +1,43 @@ +package com.android.periodpals.ui.settings + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag +import com.android.periodpals.resources.C.Tag +import com.android.periodpals.ui.navigation.NavigationActions +import com.android.periodpals.ui.theme.dimens + +/** TODO: Placeholder Screen, waiting for implementation */ +@Composable +fun SettingsScreen(navigationActions: NavigationActions) { + Scaffold( + modifier = Modifier.fillMaxSize().testTag(Tag.TimerScreen.SCREEN), + ) { paddingValues -> + Column( + modifier = + Modifier.fillMaxSize() + .padding(paddingValues) + .padding( + horizontal = MaterialTheme.dimens.medium3, + vertical = MaterialTheme.dimens.small3, + ) + .verticalScroll(rememberScrollState()), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = + Arrangement.spacedBy(MaterialTheme.dimens.small2, Alignment.CenterVertically), + ) { + // TODO: delete when implementing the screen + Text("Settings Screen", modifier = Modifier.fillMaxSize().testTag(Tag.TimerScreen.TIMER_TEXT)) + } + } +} diff --git a/app/src/test/java/com/android/periodpals/ui/profile/ProfileScreenTest.kt b/app/src/test/java/com/android/periodpals/ui/profile/ProfileScreenTest.kt index 0608c60db..179878955 100644 --- a/app/src/test/java/com/android/periodpals/ui/profile/ProfileScreenTest.kt +++ b/app/src/test/java/com/android/periodpals/ui/profile/ProfileScreenTest.kt @@ -62,6 +62,7 @@ class ProfileScreenTest { .assertIsDisplayed() .assertTextEquals("Your Profile") composeTestRule.onNodeWithTag(TopAppBar.GO_BACK_BUTTON).assertIsNotDisplayed() + composeTestRule.onNodeWithTag(TopAppBar.SETTINGS_BUTTON).assertIsDisplayed() composeTestRule.onNodeWithTag(TopAppBar.EDIT_BUTTON).assertIsDisplayed() composeTestRule.onNodeWithTag(BottomNavigationMenu.BOTTOM_NAVIGATION_MENU).assertIsDisplayed() @@ -97,6 +98,16 @@ class ProfileScreenTest { .assertIsDisplayed() } + @Test + fun settingsButtonNavigatesToSettingsScreen() { + `when`(userViewModel.user).thenReturn(userState) + composeTestRule.setContent { ProfileScreen(userViewModel, navigationActions) } + + composeTestRule.onNodeWithTag(TopAppBar.SETTINGS_BUTTON).performClick() + + verify(navigationActions).navigateTo(Screen.SETTINGS) + } + @Test fun editButtonNavigatesToEditProfileScreen() { `when`(userViewModel.user).thenReturn(userState) From 92acf7597b19fe3cfc49ffc4ca9c635b44f4248b Mon Sep 17 00:00:00 2001 From: francelu Date: Thu, 21 Nov 2024 18:40:28 +0100 Subject: [PATCH 04/10] style: ktfmt format --- .../periodpals/ui/navigation/TopAppBarTest.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/test/java/com/android/periodpals/ui/navigation/TopAppBarTest.kt b/app/src/test/java/com/android/periodpals/ui/navigation/TopAppBarTest.kt index 269366ac1..59ced52a0 100644 --- a/app/src/test/java/com/android/periodpals/ui/navigation/TopAppBarTest.kt +++ b/app/src/test/java/com/android/periodpals/ui/navigation/TopAppBarTest.kt @@ -29,7 +29,7 @@ class TopAppBarTest { @Test fun backButtonIsDisplayed() { composeTestRule.setContent { - TopAppBar(title = "Tampon Timer", backButton = true, onBackButtonClick = { /* Do nothing */ }) + TopAppBar(title = "Tampon Timer", backButton = true, onBackButtonClick = { /* Do nothing */}) } composeTestRule.onNodeWithTag(TopAppBar.TOP_BAR).assertIsDisplayed() @@ -41,7 +41,7 @@ class TopAppBarTest { @Test fun editButtonIsDisplayed() { composeTestRule.setContent { - TopAppBar(title = "Tampon Timer", editButton = true, onEditButtonClick = { /* Do nothing */ }) + TopAppBar(title = "Tampon Timer", editButton = true, onEditButtonClick = { /* Do nothing */}) } composeTestRule.onNodeWithTag(TopAppBar.TOP_BAR).assertIsDisplayed() @@ -56,7 +56,7 @@ class TopAppBarTest { TopAppBar( title = "Tampon Timer", settingsButton = true, - onSettingsButtonClick = { /* Do nothing */ }, + onSettingsButtonClick = { /* Do nothing */}, ) } @@ -73,9 +73,9 @@ class TopAppBarTest { TopAppBar( title = "Tampon Timer", backButton = true, - onBackButtonClick = { /* Do nothing */ }, + onBackButtonClick = { /* Do nothing */}, editButton = true, - onEditButtonClick = { /* Do nothing */ }, + onEditButtonClick = { /* Do nothing */}, ) } @@ -173,9 +173,9 @@ class TopAppBarTest { TopAppBar( title = "Test Title", backButton = true, - onBackButtonClick = { /* Do nothing */ }, + onBackButtonClick = { /* Do nothing */}, settingsButton = true, - onSettingsButtonClick = { /* Do nothing */ }, + onSettingsButtonClick = { /* Do nothing */}, ) } } From 5b6b73fd00d82b8bb0d4ccfe4d94a535e0aa6ea9 Mon Sep 17 00:00:00 2001 From: francelu Date: Thu, 21 Nov 2024 19:01:34 +0100 Subject: [PATCH 05/10] fix: remove test tags on placeholder settings screen --- .../com/android/periodpals/ui/settings/SettingsScreen.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/android/periodpals/ui/settings/SettingsScreen.kt b/app/src/main/java/com/android/periodpals/ui/settings/SettingsScreen.kt index 7bce7d3e6..89aee1686 100644 --- a/app/src/main/java/com/android/periodpals/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/com/android/periodpals/ui/settings/SettingsScreen.kt @@ -12,8 +12,6 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.testTag -import com.android.periodpals.resources.C.Tag import com.android.periodpals.ui.navigation.NavigationActions import com.android.periodpals.ui.theme.dimens @@ -21,7 +19,7 @@ import com.android.periodpals.ui.theme.dimens @Composable fun SettingsScreen(navigationActions: NavigationActions) { Scaffold( - modifier = Modifier.fillMaxSize().testTag(Tag.TimerScreen.SCREEN), + modifier = Modifier.fillMaxSize(), ) { paddingValues -> Column( modifier = @@ -37,7 +35,7 @@ fun SettingsScreen(navigationActions: NavigationActions) { Arrangement.spacedBy(MaterialTheme.dimens.small2, Alignment.CenterVertically), ) { // TODO: delete when implementing the screen - Text("Settings Screen", modifier = Modifier.fillMaxSize().testTag(Tag.TimerScreen.TIMER_TEXT)) + Text("Settings Screen", modifier = Modifier.fillMaxSize()) } } } From 0b86511354f69e0047a06337697d66bc878c8950 Mon Sep 17 00:00:00 2001 From: francelu Date: Thu, 21 Nov 2024 21:28:58 +0100 Subject: [PATCH 06/10] fix: add go back button as requested by @taghizadlaura --- .../com/android/periodpals/ui/settings/SettingsScreen.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/com/android/periodpals/ui/settings/SettingsScreen.kt b/app/src/main/java/com/android/periodpals/ui/settings/SettingsScreen.kt index 89aee1686..0da72cecb 100644 --- a/app/src/main/java/com/android/periodpals/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/com/android/periodpals/ui/settings/SettingsScreen.kt @@ -13,13 +13,22 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import com.android.periodpals.ui.navigation.NavigationActions +import com.android.periodpals.ui.navigation.TopAppBar import com.android.periodpals.ui.theme.dimens +private const val SCREEN_TITLE = "My Settings" + /** TODO: Placeholder Screen, waiting for implementation */ @Composable fun SettingsScreen(navigationActions: NavigationActions) { Scaffold( modifier = Modifier.fillMaxSize(), + topBar = { + TopAppBar( + title = SCREEN_TITLE, + backButton = true, + onBackButtonClick = { navigationActions.goBack() }) + }, ) { paddingValues -> Column( modifier = From 8d8a6d55779a12269c1c1b901b134b4dcc94b9df Mon Sep 17 00:00:00 2001 From: francelu Date: Thu, 21 Nov 2024 21:44:36 +0100 Subject: [PATCH 07/10] docs: update documentation for `TopAppBar` --- .../java/com/android/periodpals/ui/navigation/TopAppBar.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/android/periodpals/ui/navigation/TopAppBar.kt b/app/src/main/java/com/android/periodpals/ui/navigation/TopAppBar.kt index 7ef44ad4e..20add1ada 100644 --- a/app/src/main/java/com/android/periodpals/ui/navigation/TopAppBar.kt +++ b/app/src/main/java/com/android/periodpals/ui/navigation/TopAppBar.kt @@ -27,8 +27,10 @@ import com.android.periodpals.ui.theme.dimens * * @param title The title text to be displayed in the app bar. * @param backButton Whether to show a back button. Default is false. - * @param editButton Whether to show an edit button. Default is false. * @param onBackButtonClick Called when the back button is clicked. Default is null. + * @param settingsButton Whether to show a settings button. Default is false. + * @param onSettingsButtonClick Called when the settings button is clicked. Default is null. + * @param editButton Whether to show an edit button. Default is false. * @param onEditButtonClick Called when the edit button is clicked. Default is null. * * ### Usage: @@ -49,7 +51,7 @@ import com.android.periodpals.ui.theme.dimens * ### Testing: * - Use the testTag "topBar" to verify the app bar is displayed. * - If the back button is shown, check for the "goBackButton" tag to confirm its presence and - * functionality. + * functionality. - * - If the edit button is shown, check for the "editButton" tag to confirm its presence and * functionality. * - The title can be checked using the "screenTitle" testTag. From 7d515e6a50ff58d7424d6a872ca0e230503169ba Mon Sep 17 00:00:00 2001 From: francelu Date: Thu, 21 Nov 2024 21:45:01 +0100 Subject: [PATCH 08/10] test: update `TopAppBar` tests for alert UIs --- .../java/com/android/periodpals/ui/alert/AlertListsScreenTest.kt | 1 + .../com/android/periodpals/ui/alert/CreateAlertScreenTest.kt | 1 + .../java/com/android/periodpals/ui/alert/EditAlertScreenTest.kt | 1 + 3 files changed, 3 insertions(+) diff --git a/app/src/test/java/com/android/periodpals/ui/alert/AlertListsScreenTest.kt b/app/src/test/java/com/android/periodpals/ui/alert/AlertListsScreenTest.kt index c7231229c..0e37a3bd2 100644 --- a/app/src/test/java/com/android/periodpals/ui/alert/AlertListsScreenTest.kt +++ b/app/src/test/java/com/android/periodpals/ui/alert/AlertListsScreenTest.kt @@ -113,6 +113,7 @@ class AlertListsScreenTest { .assertIsDisplayed() .assertTextEquals("Alert Lists") composeTestRule.onNodeWithTag(TopAppBar.GO_BACK_BUTTON).assertIsNotDisplayed() + composeTestRule.onNodeWithTag(TopAppBar.SETTINGS_BUTTON).assertIsNotDisplayed() composeTestRule.onNodeWithTag(TopAppBar.EDIT_BUTTON).assertIsNotDisplayed() composeTestRule.onNodeWithTag(BottomNavigationMenu.BOTTOM_NAVIGATION_MENU).assertIsDisplayed() } diff --git a/app/src/test/java/com/android/periodpals/ui/alert/CreateAlertScreenTest.kt b/app/src/test/java/com/android/periodpals/ui/alert/CreateAlertScreenTest.kt index 747e626ad..473a46538 100644 --- a/app/src/test/java/com/android/periodpals/ui/alert/CreateAlertScreenTest.kt +++ b/app/src/test/java/com/android/periodpals/ui/alert/CreateAlertScreenTest.kt @@ -77,6 +77,7 @@ class CreateAlertScreenTest { .assertIsDisplayed() .assertTextEquals("Create Alert") composeTestRule.onNodeWithTag(TopAppBar.GO_BACK_BUTTON).assertIsNotDisplayed() + composeTestRule.onNodeWithTag(TopAppBar.SETTINGS_BUTTON).assertIsNotDisplayed() composeTestRule.onNodeWithTag(TopAppBar.EDIT_BUTTON).assertIsNotDisplayed() composeTestRule.onNodeWithTag(BottomNavigationMenu.BOTTOM_NAVIGATION_MENU).assertIsDisplayed() diff --git a/app/src/test/java/com/android/periodpals/ui/alert/EditAlertScreenTest.kt b/app/src/test/java/com/android/periodpals/ui/alert/EditAlertScreenTest.kt index 3900f2312..e83a045ff 100644 --- a/app/src/test/java/com/android/periodpals/ui/alert/EditAlertScreenTest.kt +++ b/app/src/test/java/com/android/periodpals/ui/alert/EditAlertScreenTest.kt @@ -87,6 +87,7 @@ class EditAlertScreenTest { .assertIsDisplayed() .assertTextEquals("Edit Your Alert") composeTestRule.onNodeWithTag(TopAppBar.GO_BACK_BUTTON).assertIsDisplayed() + composeTestRule.onNodeWithTag(TopAppBar.SETTINGS_BUTTON).assertIsNotDisplayed() composeTestRule.onNodeWithTag(TopAppBar.EDIT_BUTTON).assertIsNotDisplayed() composeTestRule .onNodeWithTag(BottomNavigationMenu.BOTTOM_NAVIGATION_MENU) From af3d2731922f6feb93a60a1f4f1f6d3c72a493a6 Mon Sep 17 00:00:00 2001 From: francelu Date: Thu, 21 Nov 2024 21:45:56 +0100 Subject: [PATCH 09/10] test: update `TopAppBar` tests for map and timer UIs --- app/src/test/java/com/android/periodpals/ui/map/MapScreenTest.kt | 1 + .../test/java/com/android/periodpals/ui/timer/TimerScreenTest.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/app/src/test/java/com/android/periodpals/ui/map/MapScreenTest.kt b/app/src/test/java/com/android/periodpals/ui/map/MapScreenTest.kt index 0d6911313..e500f896a 100644 --- a/app/src/test/java/com/android/periodpals/ui/map/MapScreenTest.kt +++ b/app/src/test/java/com/android/periodpals/ui/map/MapScreenTest.kt @@ -48,6 +48,7 @@ class MapScreenTest { composeTestRule.onNodeWithTag(TopAppBar.TOP_BAR).assertIsDisplayed() composeTestRule.onNodeWithTag(TopAppBar.TITLE_TEXT).assertIsDisplayed().assertTextEquals("Map") composeTestRule.onNodeWithTag(TopAppBar.GO_BACK_BUTTON).assertIsNotDisplayed() + composeTestRule.onNodeWithTag(TopAppBar.SETTINGS_BUTTON).assertIsNotDisplayed() composeTestRule.onNodeWithTag(TopAppBar.EDIT_BUTTON).assertIsNotDisplayed() composeTestRule.onNodeWithTag(MapScreen.MAP_VIEW_CONTAINER).assertIsDisplayed() diff --git a/app/src/test/java/com/android/periodpals/ui/timer/TimerScreenTest.kt b/app/src/test/java/com/android/periodpals/ui/timer/TimerScreenTest.kt index a8ceb2a90..9427bcd51 100644 --- a/app/src/test/java/com/android/periodpals/ui/timer/TimerScreenTest.kt +++ b/app/src/test/java/com/android/periodpals/ui/timer/TimerScreenTest.kt @@ -40,6 +40,7 @@ class TimerScreenTest { .assertIsDisplayed() .assertTextEquals("Tampon Timer") composeTestRule.onNodeWithTag(TopAppBar.GO_BACK_BUTTON).assertIsNotDisplayed() + composeTestRule.onNodeWithTag(TopAppBar.SETTINGS_BUTTON).assertIsNotDisplayed() composeTestRule.onNodeWithTag(TopAppBar.EDIT_BUTTON).assertIsNotDisplayed() composeTestRule.onNodeWithTag(TimerScreen.TIMER_TEXT).performScrollTo().assertIsDisplayed() From a419a27398ee5bf9a21d7ab5add7d2e48faf7d49 Mon Sep 17 00:00:00 2001 From: francelu Date: Thu, 21 Nov 2024 21:46:36 +0100 Subject: [PATCH 10/10] test: update `TopAppBar` tests for create and edit profile UIs --- .../java/com/android/periodpals/ui/profile/CreateProfileTest.kt | 1 + .../java/com/android/periodpals/ui/profile/EditProfileTest.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/app/src/test/java/com/android/periodpals/ui/profile/CreateProfileTest.kt b/app/src/test/java/com/android/periodpals/ui/profile/CreateProfileTest.kt index a2e96be42..232fb5457 100644 --- a/app/src/test/java/com/android/periodpals/ui/profile/CreateProfileTest.kt +++ b/app/src/test/java/com/android/periodpals/ui/profile/CreateProfileTest.kt @@ -69,6 +69,7 @@ class CreateProfileTest { .assertIsDisplayed() .assertTextEquals("Create Your Account") composeTestRule.onNodeWithTag(TopAppBar.GO_BACK_BUTTON).assertIsNotDisplayed() + composeTestRule.onNodeWithTag(TopAppBar.SETTINGS_BUTTON).assertIsNotDisplayed() composeTestRule.onNodeWithTag(TopAppBar.EDIT_BUTTON).assertIsNotDisplayed() composeTestRule.onNodeWithTag(BottomNavigationMenu.BOTTOM_NAVIGATION_MENU).assertDoesNotExist() diff --git a/app/src/test/java/com/android/periodpals/ui/profile/EditProfileTest.kt b/app/src/test/java/com/android/periodpals/ui/profile/EditProfileTest.kt index b4b1277cc..c921b0a71 100644 --- a/app/src/test/java/com/android/periodpals/ui/profile/EditProfileTest.kt +++ b/app/src/test/java/com/android/periodpals/ui/profile/EditProfileTest.kt @@ -68,6 +68,7 @@ class EditProfileTest { .assertIsDisplayed() .assertTextEquals("Edit Your Profile") composeTestRule.onNodeWithTag(TopAppBar.GO_BACK_BUTTON).assertIsDisplayed() + composeTestRule.onNodeWithTag(TopAppBar.SETTINGS_BUTTON).assertIsNotDisplayed() composeTestRule.onNodeWithTag(TopAppBar.EDIT_BUTTON).assertIsNotDisplayed() composeTestRule.onNodeWithTag(BottomNavigationMenu.BOTTOM_NAVIGATION_MENU).assertDoesNotExist()