-
Notifications
You must be signed in to change notification settings - Fork 35
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
Step4 - 페이먼츠(카드 수정) #61
Open
eshc123
wants to merge
9
commits into
next-step:eshc123
Choose a base branch
from
eshc123:step4
base: eshc123
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+607
−262
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fc0c8f9
docs: README - step3 피드백 추가 및 step4 내용 추가
3ffda72
feat: NewCardRouteScreen '카드사 선택' 테스트 추가
92e486f
feat: PaymentCard Preview 카드사 타입이 없는 케이스
68532ed
feat: NewCard -> ManageCard 수정
3d45fa1
feat: 카드 수정 진입 로직 구현
c44c606
feat: 변경사항이 발생하지 않으면 수정이 불가능하게 구현
2e960e5
feat: 카드 수정 기능 구현
50c2837
feat: 카드사 수정 추가
b411353
feat: 카드 수정 테스트 추가
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
189 changes: 189 additions & 0 deletions
189
app/src/androidTest/java/nextstep/payments/ui/ManageCardRouteScreenTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
package nextstep.payments.ui | ||
|
||
import androidx.activity.ComponentActivity | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.testTag | ||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.assertIsEnabled | ||
import androidx.compose.ui.test.assertIsNotDisplayed | ||
import androidx.compose.ui.test.assertIsNotEnabled | ||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.performClick | ||
import androidx.lifecycle.SavedStateHandle | ||
import nextstep.payments.data.model.BankType | ||
import nextstep.payments.data.model.CreditCard | ||
import nextstep.payments.screen.model.BankTypeUiModel | ||
import nextstep.payments.screen.cardmanage.ManageCardRouteScreen | ||
import nextstep.payments.screen.cardmanage.ManageCardViewModel | ||
import nextstep.payments.screen.model.arg.CardArgType | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
internal class ManageCardRouteScreenTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createAndroidComposeRule<ComponentActivity>() | ||
private lateinit var viewModel: ManageCardViewModel | ||
|
||
@Before | ||
fun setUp() { | ||
viewModel = ManageCardViewModel( | ||
savedStateHandle = SavedStateHandle() | ||
) | ||
} | ||
|
||
@Test | ||
fun 카드가_추가되면_화면_이동_로직이_실행된다() { | ||
var isNavigated = false | ||
|
||
//GIVEN | ||
composeTestRule.setContent { | ||
ManageCardRouteScreen( | ||
navigateToCardList = { | ||
isNavigated = true | ||
}, | ||
viewModel = viewModel | ||
) | ||
} | ||
viewModel.setBankType(BankTypeUiModel.BC) | ||
viewModel.setCardNumber("1234123412341234") | ||
viewModel.setExpiredDate("1228") | ||
viewModel.setPassword("1234") | ||
|
||
//WHEN | ||
composeTestRule.onNodeWithTag("saveButton").performClick() | ||
|
||
composeTestRule.waitForIdle() | ||
|
||
//THEN | ||
assert(isNavigated) | ||
} | ||
|
||
@Test | ||
fun 새_카드_추가_화면_진입_시_카드사_선택_바텀_시트가_나타난다() { | ||
//GIVEN | ||
composeTestRule.setContent { | ||
ManageCardRouteScreen( | ||
navigateToCardList = { }, | ||
viewModel = viewModel | ||
) | ||
} | ||
|
||
//THEN | ||
composeTestRule.onNodeWithTag("BankSelectBottomSheet") | ||
.assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun 카드사_선택을_하지_않고_뒤로_가기_시_카드_추가_화면에서_빠져나온다() { | ||
//GIVEN | ||
composeTestRule.setContent { | ||
ManageCardRouteScreen( | ||
modifier = Modifier.testTag("ManageCardRouteScreen"), | ||
navigateToCardList = { }, | ||
viewModel = viewModel | ||
) | ||
} | ||
|
||
//WHEN | ||
composeTestRule.runOnUiThread { | ||
composeTestRule.activity.onBackPressedDispatcher.onBackPressed() | ||
} | ||
|
||
composeTestRule.waitForIdle() | ||
|
||
//THEN | ||
composeTestRule.onNodeWithTag("ManageCardRouteScreen") | ||
.assertDoesNotExist() | ||
} | ||
|
||
@Test | ||
fun 카드사를_선택하면_바텀시트가_내려가고_카드사가_선택되어있다() { | ||
//GIVEN | ||
composeTestRule.setContent { | ||
ManageCardRouteScreen( | ||
modifier = Modifier.testTag("ManageCardRouteScreen"), | ||
navigateToCardList = { }, | ||
viewModel = viewModel | ||
) | ||
} | ||
|
||
//WHEN | ||
composeTestRule.onNodeWithTag(BankTypeUiModel.BC.name).performClick() | ||
|
||
composeTestRule.waitForIdle() | ||
|
||
//THEN | ||
composeTestRule.onNodeWithTag("BankSelectBottomSheet") | ||
.assertIsNotDisplayed() | ||
assert(viewModel.bankType.value == BankTypeUiModel.BC) | ||
} | ||
|
||
@Test | ||
fun 카드_수정_화면에서_변경사항이_발생하지_않으면_저장_버튼을_클릭할_수_없다() { | ||
//GIVEN | ||
viewModel = ManageCardViewModel( | ||
savedStateHandle = SavedStateHandle().apply { | ||
set(CardArgType.MANAGE_CARD_TYPE_ARG, | ||
CardArgType.EditCardArg( | ||
CreditCard( | ||
cardNumber = "1234123412341234", | ||
expiredDate = "1122", | ||
ownerName = "김컴포즈", | ||
password = "1234", | ||
bankType = BankType.BC | ||
) | ||
) | ||
) | ||
} | ||
) | ||
composeTestRule.setContent { | ||
ManageCardRouteScreen( | ||
modifier = Modifier.testTag("ManageCardRouteScreen"), | ||
navigateToCardList = { }, | ||
viewModel = viewModel | ||
) | ||
} | ||
|
||
//THEN | ||
composeTestRule.onNodeWithTag("saveButton").assertIsNotEnabled() | ||
} | ||
|
||
@Test | ||
fun 카드_수정_화면에서_변경사항이_발생하면_저장_버튼을_클릭할_수_있다() { | ||
//GIVEN | ||
viewModel = ManageCardViewModel( | ||
savedStateHandle = SavedStateHandle().apply { | ||
set(CardArgType.MANAGE_CARD_TYPE_ARG, | ||
CardArgType.EditCardArg( | ||
CreditCard( | ||
cardNumber = "1234123412341234", | ||
expiredDate = "1122", | ||
ownerName = "김컴포즈", | ||
password = "1234", | ||
bankType = BankType.BC | ||
) | ||
) | ||
) | ||
} | ||
) | ||
composeTestRule.setContent { | ||
ManageCardRouteScreen( | ||
modifier = Modifier.testTag("ManageCardRouteScreen"), | ||
navigateToCardList = { }, | ||
viewModel = viewModel | ||
) | ||
} | ||
|
||
//WHEN | ||
viewModel.setBankType(BankTypeUiModel.HYUNDAI) | ||
|
||
composeTestRule.waitForIdle() | ||
|
||
//THEN | ||
composeTestRule.onNodeWithTag("saveButton").assertIsEnabled() | ||
} | ||
} | ||
|
93 changes: 0 additions & 93 deletions
93
app/src/androidTest/java/nextstep/payments/ui/NewCardRouteScreenTest.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
해당 테스트들이 ManageCardViewModel의 의존적이라고도 볼수 있을거같아요
Screen과 ViewModel을 분리해서 테스트하면 조금더 독립적인 테스트코드를 작성할수 있을거같아요 :)
( 이부분은 고민 만해주셔도 좋을거같아요!)