diff --git a/feature/setting/presentation/src/main/kotlin/com/afternote/feature/setting/presentation/home/SettingScreen.kt b/feature/setting/presentation/src/main/kotlin/com/afternote/feature/setting/presentation/home/SettingScreen.kt index c959821ef..45cd0bc46 100644 --- a/feature/setting/presentation/src/main/kotlin/com/afternote/feature/setting/presentation/home/SettingScreen.kt +++ b/feature/setting/presentation/src/main/kotlin/com/afternote/feature/setting/presentation/home/SettingScreen.kt @@ -163,6 +163,7 @@ private fun SettingScreenContent( SettingProfile( name = state.name, email = state.email, + onInquiryClick = onUnavailableClick, onNoticeClick = onNoticeClick, onRecipientListClick = onRecipientListClick, ) diff --git a/feature/setting/presentation/src/main/kotlin/com/afternote/feature/setting/presentation/home/component/SettingProfile.kt b/feature/setting/presentation/src/main/kotlin/com/afternote/feature/setting/presentation/home/component/SettingProfile.kt index 029a9694f..1dc7c1428 100644 --- a/feature/setting/presentation/src/main/kotlin/com/afternote/feature/setting/presentation/home/component/SettingProfile.kt +++ b/feature/setting/presentation/src/main/kotlin/com/afternote/feature/setting/presentation/home/component/SettingProfile.kt @@ -21,9 +21,10 @@ import com.afternote.core.ui.theme.AfternoteDesign import com.afternote.feature.setting.presentation.R @Composable -fun SettingProfile( +internal fun SettingProfile( name: String, email: String, + onInquiryClick: () -> Unit, onNoticeClick: () -> Unit, onRecipientListClick: () -> Unit, modifier: Modifier = Modifier, @@ -76,7 +77,7 @@ fun SettingProfile( ) { val items = listOf( - stringResource(R.string.setting_support_inquiry) to null, + stringResource(R.string.setting_support_inquiry) to onInquiryClick, stringResource(R.string.setting_support_notice) to onNoticeClick, stringResource(R.string.setting_recipient_list) to onRecipientListClick, ) @@ -86,13 +87,7 @@ fun SettingProfile( modifier = Modifier .weight(1f) - .then( - if (onClick != null) { - Modifier.clickable(onClick = onClick) - } else { - Modifier - }, - ), + .clickable(onClick = onClick), horizontalAlignment = Alignment.CenterHorizontally, ) { Image( diff --git a/feature/setting/presentation/src/test/kotlin/com/afternote/feature/setting/presentation/SettingFlowTest.kt b/feature/setting/presentation/src/test/kotlin/com/afternote/feature/setting/presentation/SettingFlowTest.kt index 5182a206e..e52191860 100644 --- a/feature/setting/presentation/src/test/kotlin/com/afternote/feature/setting/presentation/SettingFlowTest.kt +++ b/feature/setting/presentation/src/test/kotlin/com/afternote/feature/setting/presentation/SettingFlowTest.kt @@ -2,6 +2,7 @@ package com.afternote.feature.setting.presentation import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.hasClickAction +import androidx.compose.ui.test.hasContentDescription import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.v2.createComposeRule import androidx.compose.ui.test.onNodeWithText @@ -114,6 +115,37 @@ class SettingFlowTest { assertEquals(listOf(Triple(false, null, null)), user.pushSettingUpdates) } + @Test + fun profileShortcuts_showSupportFeedbackAndKeepExistingNavigation() { + val viewModel = SettingViewModel(settingFlowAuthRepository(loggedIn = true), settingFlowUserRepository()) + val destinations = mutableListOf() + setSettingContent( + viewModel = viewModel, + onNotice = { destinations += "notice" }, + onRecipientList = { destinations += "recipient-list" }, + ) + val resources = ApplicationProvider.getApplicationContext().resources + + composeRule + .onNode( + hasContentDescription(resources.getString(R.string.setting_support_inquiry)) and hasClickAction(), + ).performClick() + composeRule.onNodeWithText("현재 이 메뉴는 이용할 수 없습니다.").assertIsDisplayed() + assertEquals(emptyList(), destinations) + composeRule.onNodeWithText("확인").performClick() + composeRule.onNodeWithText("현재 이 메뉴는 이용할 수 없습니다.").assertDoesNotExist() + + composeRule + .onNode( + hasContentDescription(resources.getString(R.string.setting_support_notice)) and hasClickAction(), + ).performClick() + composeRule + .onNode( + hasContentDescription(resources.getString(R.string.setting_recipient_list)) and hasClickAction(), + ).performClick() + assertEquals(listOf("notice", "recipient-list"), destinations) + } + @Test fun unavailableMenus_showFeedbackAndKeepSettingsUsable() { val viewModel = SettingViewModel(settingFlowAuthRepository(loggedIn = true), settingFlowUserRepository()) @@ -130,7 +162,12 @@ class SettingFlowTest { R.string.setting_support_service_info, ) menuIds.forEach { menuId -> - composeRule.onNode(hasText(resources.getString(menuId)) and hasClickAction()).performScrollTo().performClick() + val label = resources.getString(menuId) + composeRule + .onNode( + hasText(label) and hasClickAction() and !hasContentDescription(label), + ).performScrollTo() + .performClick() composeRule.onNodeWithText("현재 이 메뉴는 이용할 수 없습니다.").assertIsDisplayed() composeRule.onNodeWithText("확인").performClick() } @@ -143,6 +180,8 @@ class SettingFlowTest { onLogoutSuccess: () -> Unit = {}, onProfileEdit: () -> Unit = {}, onAppLock: () -> Unit = {}, + onNotice: () -> Unit = {}, + onRecipientList: () -> Unit = {}, ) { composeRule.setContent { AfternoteTheme { @@ -152,12 +191,12 @@ class SettingFlowTest { onProfileEditClick = onProfileEdit, onLinkedAccountClick = {}, onNotificationClick = {}, - onRecipientListClick = {}, + onRecipientListClick = onRecipientList, onRecipientRegisterClick = {}, onDeliveryConditionsClick = {}, onPasskeyClick = {}, onAppLockClick = onAppLock, - onNoticeClick = {}, + onNoticeClick = onNotice, onWithdrawGuideClick = {}, viewModel = viewModel, )