Skip to content

Commit

Permalink
fix: update documentation for SettingsComponents
Browse files Browse the repository at this point in the history
  • Loading branch information
Harrish92 committed Nov 21, 2024
1 parent 21ae754 commit 00fd9ce
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
Empty file removed app/.attach_pid32102
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.android.periodpals.ui.theme.dimens
/**
* A composable function that displays a section in the settings screen.
*
* @param testTag the test tag for the section.
* @param content the content to be displayed in the settings section.
*/
@Composable
Expand All @@ -51,6 +52,7 @@ fun SettingsContainer(testTag: String, content: @Composable () -> Unit) {
* A composable function that displays a description in the settings screen.
*
* @param text the text to be displayed in the description.
* @param testTag the test tag for the description.
*/
@Composable
fun SettingsDescription(text: String, testTag: String) {
Expand All @@ -71,6 +73,8 @@ fun SettingsDescription(text: String, testTag: String) {
* @param text The text to be displayed in the row.
* @param isChecked The state of the switch.
* @param onCheckedChange The function to be called when the switch is toggled.
* @param textTestTag The test tag for the text.
* @param switchTestTag The test tag for the switch.
*/
@Composable
fun SettingsSwitchRow(
Expand Down Expand Up @@ -104,6 +108,8 @@ fun SettingsSwitchRow(
* @param text The text to be displayed in the row.
* @param onClick The function to be called when the icon is clicked.
* @param icon The icon to be displayed in the row.
* @param textTestTag The test tag for the text.
* @param iconTestTag The test tag for the icon.
*/
@Composable
fun SettingsIconRow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import com.android.periodpals.model.user.UserViewModel
import com.android.periodpals.resources.C.Tag.SettingsScreen
import com.android.periodpals.resources.ComponentColor.getMenuItemColors
import com.android.periodpals.resources.ComponentColor.getMenuTextFieldColors
Expand Down Expand Up @@ -94,7 +95,7 @@ private val THEME_DROPDOWN_CHOICES =

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingsScreen(navigationActions: NavigationActions) {
fun SettingsScreen(userViewModel: UserViewModel, navigationActions: NavigationActions) {

// notifications states
var receiveNotifications by remember { mutableStateOf(true) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo
import com.android.periodpals.model.user.UserViewModel
import com.android.periodpals.resources.C.Tag.BottomNavigationMenu
import com.android.periodpals.resources.C.Tag.SettingsScreen
import com.android.periodpals.resources.C.Tag.TopAppBar
Expand All @@ -26,18 +27,20 @@ import org.robolectric.RobolectricTestRunner
class SettingsScreenTest {

private lateinit var navigationActions: NavigationActions
private lateinit var userViewModel: UserViewModel
@get:Rule val composeTestRule = createComposeRule()

@Before
fun setUp() {
navigationActions = mock(NavigationActions::class.java)
userViewModel = mock(UserViewModel::class.java)

`when`(navigationActions.currentRoute()).thenReturn(Route.SETTINGS)
}

@Test
fun allComponentsAreDisplayed() {
composeTestRule.setContent { SettingsScreen(navigationActions) }
composeTestRule.setContent { SettingsScreen(userViewModel, navigationActions) }

composeTestRule.onNodeWithTag(SettingsScreen.SCREEN).assertIsDisplayed()
composeTestRule.onNodeWithTag(TopAppBar.TOP_BAR).assertIsDisplayed()
Expand Down Expand Up @@ -122,7 +125,7 @@ class SettingsScreenTest {

@Test
fun allCardsComponentsAreDisplayed() {
composeTestRule.setContent { SettingsScreen(navigationActions) }
composeTestRule.setContent { SettingsScreen(userViewModel, navigationActions) }

composeTestRule
.onNodeWithTag(SettingsScreen.DELETE_ACCOUNT_ICON)
Expand All @@ -138,7 +141,7 @@ class SettingsScreenTest {

@Test
fun goBackButtonNavigatesToProfileScreen() {
composeTestRule.setContent { SettingsScreen(navigationActions) }
composeTestRule.setContent { SettingsScreen(userViewModel, navigationActions) }

composeTestRule.onNodeWithTag(TopAppBar.GO_BACK_BUTTON).performClick()

Expand All @@ -147,7 +150,7 @@ class SettingsScreenTest {

@Test
fun performClickOnDropDownMenu() {
composeTestRule.setContent { SettingsScreen(navigationActions) }
composeTestRule.setContent { SettingsScreen(userViewModel, navigationActions) }

composeTestRule
.onNodeWithTag(SettingsScreen.THEME_DROP_DOWN_MENU_BOX)
Expand All @@ -159,7 +162,7 @@ class SettingsScreenTest {

@Test
fun signOutButtonNavigatesToSignInScreen() {
composeTestRule.setContent { SettingsScreen(navigationActions) }
composeTestRule.setContent { SettingsScreen(userViewModel, navigationActions) }

composeTestRule.onNodeWithTag(SettingsScreen.SIGN_OUT_ICON).performScrollTo().performClick()

Expand All @@ -168,7 +171,7 @@ class SettingsScreenTest {

@Test
fun deleteAccountButtonNavigatesToSignInScreen() {
composeTestRule.setContent { SettingsScreen(navigationActions) }
composeTestRule.setContent { SettingsScreen(userViewModel, navigationActions) }

composeTestRule
.onNodeWithTag(SettingsScreen.DELETE_ACCOUNT_ICON)
Expand All @@ -181,7 +184,7 @@ class SettingsScreenTest {

@Test
fun notDeleteAccountButtonDismissDialog() {
composeTestRule.setContent { SettingsScreen(navigationActions) }
composeTestRule.setContent { SettingsScreen(userViewModel, navigationActions) }

composeTestRule
.onNodeWithTag(SettingsScreen.DELETE_ACCOUNT_ICON)
Expand Down

0 comments on commit 00fd9ce

Please sign in to comment.