fix(gift): 수령인 이름 검증을 보정한다

This commit is contained in:
2026-10-08 11:55:58 +09:00
parent 61f4ffc209
commit 33078f83c2
2 changed files with 15 additions and 4 deletions
@@ -21,7 +21,7 @@ data class GiftRecipientAddressFormState(
val recipientPrivacyAgreed: Boolean = false val recipientPrivacyAgreed: Boolean = false
) { ) {
val isSubmitEnabled: Boolean val isSubmitEnabled: Boolean
get() = recipientName.isNotBlank() && get() = GiftSendInputFilters.isValidName(recipientName) &&
recipientPhoneNumber.isNotBlank() && recipientPhoneNumber.isNotBlank() &&
recipientZipCode.isNotBlank() && recipientZipCode.isNotBlank() &&
recipientAddress.isNotBlank() && recipientAddress.isNotBlank() &&
@@ -70,6 +70,17 @@ class GiftRecipientAddressViewModelTest {
} }
} }
@Test
fun `완성되지 않은 한글이나 숫자 또는 13자 이름은 제출하지 않는다`() {
listOf("ㄱ", "이름1", "가".repeat(13)).forEach { name ->
viewModel.updateForm(validForm().copy(recipientName = name))
assertFalse(viewModel.formState.value!!.isSubmitEnabled)
viewModel.submit("test-gift")
assertTrue(api.requests.isEmpty())
}
}
@Test @Test
fun `공백 신청번호는 유효한 form이어도 POST하지 않는다`() { fun `공백 신청번호는 유효한 form이어도 POST하지 않는다`() {
viewModel.updateForm(validForm()) viewModel.updateForm(validForm())
@@ -121,11 +132,11 @@ class GiftRecipientAddressViewModelTest {
fun `제출 중 재탭은 첫 번째 현재 form으로 한 번만 POST한다`() { fun `제출 중 재탭은 첫 번째 현재 form으로 한 번만 POST한다`() {
val pending = SingleSubject.create<ApiResponse<GiftRecipientAddressResponse>>() val pending = SingleSubject.create<ApiResponse<GiftRecipientAddressResponse>>()
api.responses.add(pending) api.responses.add(pending)
val first = validForm().copy(recipientName = "첫 이름") val first = validForm().copy(recipientName = "첫이름")
viewModel.updateForm(first) viewModel.updateForm(first)
viewModel.submit("test-gift") viewModel.submit("test-gift")
viewModel.updateForm(validForm().copy(recipientName = "다른 이름")) viewModel.updateForm(validForm().copy(recipientName = "다른이름"))
viewModel.submit("other-gift") viewModel.submit("other-gift")
assertEquals(true, viewModel.isSubmitting.value) assertEquals(true, viewModel.isSubmitting.value)
@@ -134,7 +145,7 @@ class GiftRecipientAddressViewModelTest {
Triple( Triple(
"test-gift", "test-gift",
GiftRecipientAddressRequest( GiftRecipientAddressRequest(
"첫 이름", "첫이름",
"01000000000", "01000000000",
"01234", "01234",
"서울시 주소", "서울시 주소",