feat(gift): 선물 신청 프로필과 정책 링크를 연결한다

This commit is contained in:
2026-10-08 15:04:56 +09:00
parent 8161c2afc7
commit e5e41af4c4
4 changed files with 180 additions and 5 deletions
@@ -16,6 +16,10 @@ import android.widget.TextView
import androidx.core.view.children
import androidx.lifecycle.ViewModelProvider
import androidx.test.core.app.ApplicationProvider
import coil.EventListener
import coil.ImageLoader
import coil.request.ImageRequest
import coil.transform.CircleCropTransformation
import io.reactivex.rxjava3.android.plugins.RxAndroidPlugins
import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.plugins.RxJavaPlugins
@@ -23,6 +27,7 @@ import io.reactivex.rxjava3.schedulers.Schedulers
import io.reactivex.rxjava3.subjects.SingleSubject
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.common.ImageLoaderProvider
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.v2.gift.data.GiftApi
import kr.co.vividnext.sodalive.v2.gift.data.GiftCancelResponse
@@ -956,6 +961,138 @@ class GiftNavigationTest {
assertRecipientAgreementLink(GiftDetailAddressAgreement.PRIVACY)
}
@Test
fun `선물 신청 Intent는 크리에이터 id 닉네임 프로필 URL을 원본 그대로 전달한다`() {
val profileImageUrl = "https://example.com/creator-profile.jpg"
val intent = GiftSendRequestActivity.newIntent(
ApplicationProvider.getApplicationContext(),
creatorMemberId = 71L,
creatorNickname = "크리에이터",
profileImageUrl = profileImageUrl
)
assertEquals(71L, intent.getLongExtra(GiftSendRequestActivity.EXTRA_CREATOR_MEMBER_ID, 0L))
assertEquals("크리에이터", intent.getStringExtra(GiftSendRequestActivity.EXTRA_CREATOR_NICKNAME))
assertEquals(profileImageUrl, intent.getStringExtra(GiftSendRequestActivity.EXTRA_CREATOR_PROFILE_IMAGE_URL))
}
@Test
@Config(qualifiers = "ko")
@GraphicsMode(GraphicsMode.Mode.NATIVE)
fun `선물 신청 화면은 프로필 ImageView를 바인딩하고 URL이 없으면 placeholder를 유지한다`() {
val profileImageUrl = "https://example.com/creator-profile.jpg"
if (!ImageLoaderProvider.isInitialized) {
ImageLoaderProvider.init(ApplicationProvider.getApplicationContext())
}
val requests = mutableListOf<ImageRequest>()
val originalImageLoader = ImageLoaderProvider.imageLoader
replaceImageLoader(
ImageLoader.Builder(ApplicationProvider.getApplicationContext())
.eventListenerFactory(
EventListener.Factory {
object : EventListener {
override fun onStart(request: ImageRequest) {
requests += request
}
}
}
)
.build()
)
try {
val withProfileController = Robolectric.buildActivity(
GiftSendRequestActivity::class.java,
GiftSendRequestActivity.newIntent(
ApplicationProvider.getApplicationContext(),
creatorMemberId = 71L,
creatorNickname = "크리에이터",
profileImageUrl = profileImageUrl
)
).setup().visible()
val withoutProfileController = Robolectric.buildActivity(
GiftSendRequestActivity::class.java,
GiftSendRequestActivity.newIntent(
ApplicationProvider.getApplicationContext(),
creatorMemberId = 71L,
creatorNickname = "크리에이터",
profileImageUrl = null
)
).setup().visible()
val withProfileImage = withProfileController.get().binding.ivCreatorProfile
val withoutProfileImage = withoutProfileController.get().binding.ivCreatorProfile
assertEquals(listOf(profileImageUrl), requests.map { it.data })
assertEquals(listOf(CircleCropTransformation()), requests.single().transformations)
assertNotNull(withoutProfileImage.drawable)
withProfileController.pause().stop().destroy()
withoutProfileController.pause().stop().destroy()
} finally {
replaceImageLoader(originalImageLoader)
}
}
@Test
@Config(qualifiers = "ko")
@GraphicsMode(GraphicsMode.Mode.NATIVE)
fun `파손 면책 필수만 정책을 열고 폼 동의 CTA를 유지한다`() {
val controller = Robolectric.buildActivity(
GiftSendRequestActivity::class.java,
GiftSendRequestActivity.newIntent(
ApplicationProvider.getApplicationContext(),
creatorMemberId = 71L,
creatorNickname = "크리에이터",
profileImageUrl = null
)
).setup().visible()
val activity = controller.get()
completeGiftSendForm(activity)
val checkBox = activity.binding.cbDamageLoss
val span = checkBox.requiredLink()
val spanned = checkBox.text as Spanned
val senderName = activity.binding.etSenderName.text.toString()
val phoneNumber = activity.binding.etPhoneNumber.text.toString()
val postcode = activity.binding.tvPostcode.text.toString()
val address = activity.binding.tvAddress.text.toString()
val detailAddress = activity.binding.etDetailAddress.text.toString()
val termsAgreed = activity.binding.cbTerms.isChecked
val privacyAgreed = activity.binding.cbPrivacy.isChecked
val damageLossAgreed = checkBox.isChecked
val ctaEnabled = activity.binding.btnSend.isEnabled
assertEquals(
activity.getString(R.string.gift_send_required),
spanned.subSequence(spanned.getSpanStart(span), spanned.getSpanEnd(span)).toString()
)
assertFalse(checkBox.text.contains("(자세히보기)"))
checkBox.measure(
View.MeasureSpec.makeMeasureSpec(360, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
)
checkBox.layout(0, 0, checkBox.measuredWidth, checkBox.measuredHeight)
checkBox.dispatchTap(checkBox.glyphRightInteriorPoint(spanned.getSpanStart(span) - 1))
assertNull(shadowOf(activity).nextStartedActivity)
checkBox.isChecked = damageLossAgreed
checkBox.dispatchTap(checkBox.requiredLinkCenter())
val launched = shadowOf(activity).nextStartedActivity
assertNotNull(launched)
assertEquals(Intent.ACTION_VIEW, launched.action)
assertEquals("https://app.notion.com/p/3f227b3596738018ba5dea2e5205293b", launched.data.toString())
assertEquals(senderName, activity.binding.etSenderName.text.toString())
assertEquals(phoneNumber, activity.binding.etPhoneNumber.text.toString())
assertEquals(postcode, activity.binding.tvPostcode.text.toString())
assertEquals(address, activity.binding.tvAddress.text.toString())
assertEquals(detailAddress, activity.binding.etDetailAddress.text.toString())
assertEquals(termsAgreed, activity.binding.cbTerms.isChecked)
assertEquals(privacyAgreed, activity.binding.cbPrivacy.isChecked)
assertEquals(damageLossAgreed, checkBox.isChecked)
assertEquals(ctaEnabled, activity.binding.btnSend.isEnabled)
assertNull(shadowOf(activity).nextStartedActivity)
controller.pause().stop().destroy()
}
private fun assertRecipientAgreementLink(agreement: GiftDetailAddressAgreement) {
api.direction = "RECEIVED"
val controller = Robolectric.buildActivity(
@@ -1095,6 +1232,13 @@ class GiftNavigationTest {
)
}
private fun replaceImageLoader(imageLoader: ImageLoader) {
ImageLoaderProvider::class.java.getDeclaredField("imageLoader").apply {
isAccessible = true
set(ImageLoaderProvider, imageLoader)
}
}
private fun CheckBox.describeRequiredLinkPoint(point: Pair<Float, Float>): String {
val textLayout = checkNotNull(layout)
val vertical = point.second - totalPaddingTop + scrollY