Repository navigation
fix(home): 기록 카테고리 카드가 «모름» 을 0 으로 접지 않게 한다 (#700 일부) #1104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package com.afternote.feature.mindrecord.presentation.component | ||
|
|
||
| import androidx.activity.ComponentActivity | ||
| import androidx.compose.ui.test.assertIsDisplayed | ||
| import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
| import androidx.compose.ui.test.onNodeWithText | ||
| import com.afternote.core.ui.theme.AfternoteTheme | ||
| import com.afternote.feature.mindrecord.presentation.component.hometab.RecordCategoryCard | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
| import org.robolectric.RobolectricTestRunner | ||
| import org.robolectric.annotation.Config | ||
| import com.afternote.core.ui.R as CoreUiR | ||
|
|
||
| /** | ||
| * 기록 카테고리 카드가 «모름» 을 0 으로 접지 않는지 (#700). | ||
| * | ||
| * 홈 ViewModel 이 enum 전체를 돌며 데일리질문·주간 리포트에 0 을 박아 넣고 있었다. 화면이 | ||
| * 일기 카드만 그려 안 보였을 뿐, 카드가 늘면 그 0 이 그대로 «기록 0건» 으로 노출된다. | ||
| * 목업 숫자는 눈에 띄지만 0 은 그럴듯한 거짓이라 사용자가 그대로 믿는다 — 수신자 홈(#952)· | ||
| * 주간 요약(#562)에서 같은 이유로 대시 표기를 택했다. | ||
| */ | ||
| @RunWith(RobolectricTestRunner::class) | ||
| @Config(sdk = [35]) | ||
| class RecordCategoryCountTest { | ||
| @get:Rule | ||
| val composeRule = createAndroidComposeRule<ComponentActivity>() | ||
|
|
||
| @Test | ||
| fun `기록 수를 모르면 0 이 아니라 대시를 그린다`() { | ||
| composeRule.setContent { | ||
| AfternoteTheme { card(totalCount = null) } | ||
| } | ||
|
|
||
| composeRule.onNodeWithText("–").assertIsDisplayed() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [normal] 리소스 값을 리터럴로 다시 적어 두면 문자열을 바꿀 때 테스트가 소리 없이 갈린다 — en dash( 덧붙여 58번 줄의 |
||
| composeRule.onNodeWithText("0").assertDoesNotExist() | ||
| } | ||
|
|
||
| @Test | ||
| fun `0건은 확정값이라 그대로 그린다`() { | ||
| composeRule.setContent { | ||
| AfternoteTheme { card(totalCount = 0) } | ||
| } | ||
|
|
||
| composeRule.onNodeWithText("0").assertIsDisplayed() | ||
| } | ||
|
|
||
| @Test | ||
| fun `실제 기록 수는 천 단위로 끊어 그린다`() { | ||
| composeRule.setContent { | ||
| AfternoteTheme { card(totalCount = 1234) } | ||
| } | ||
|
|
||
| composeRule.onNodeWithText("1,234").assertIsDisplayed() | ||
| } | ||
|
|
||
| @androidx.compose.runtime.Composable | ||
| private fun card(totalCount: Int?) { | ||
| RecordCategoryCard( | ||
| iconResId = CoreUiR.drawable.core_ui_ic_diary, | ||
| title = "일기", | ||
| subtitle = "나의 매일을 기록하세요", | ||
| totalCount = totalCount, | ||
| onClick = {}, | ||
| ) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[normal] 주석이 «수신자 홈·주간 요약과 같은 표기» 라고 적은 그대로,
feature/receiver/presentation의receiver_home_section_count_unavailable이 이미 같은 값(–)을 들고 있다. 여기서 세 번째가 생기면(주간 요약 #562 는 #1055 로 열려 있다) 같은 규칙이 서로 다른 세 리소스로 흩어진다.두 모듈 다
core:ui에 의존하므로core_ui_count_unavailable같은 이름으로 한 벌만 두는 편이 «규칙» 이라는 성격에 맞는다. 지금 당장 옮기지 않더라도, 세 번째가 붙기 전이 정리하기 가장 싼 시점이라 남긴다.