feat(gift): 받은 선물 상세 표시를 추가한다
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package kr.co.vividnext.sodalive.v2.gift
|
||||
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.v2.gift.GiftDetailText.Key
|
||||
import kr.co.vividnext.sodalive.v2.gift.GiftDetailText.Raw
|
||||
import kr.co.vividnext.sodalive.v2.gift.data.GiftAddressResponse
|
||||
@@ -111,6 +112,206 @@ class GiftDetailPresenterTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `받은 선물 배송지 입력 모드는 보류 선물 정보만 노출한다`() {
|
||||
val model = GiftDetailPresenter.present(
|
||||
receivedDetail(recipientAddressRequired = true).copy(
|
||||
giftInfo = detail().giftInfo.copy(applicationNo = "중첩번호", paidCan = 999, tracking = "비밀운송장"),
|
||||
senderInfo = GiftAddressResponse("발송자", "01000000001", "발송지"),
|
||||
mailbox = GiftAddressResponse("사서함", "01000000002", "사서함주소")
|
||||
)
|
||||
)
|
||||
|
||||
val mode = model.received as GiftDetailReceived.AddressForm
|
||||
assertEquals(
|
||||
listOf(
|
||||
GiftDetailInfoRow(R.string.gift_inbox_sender, Raw("보낸팬")),
|
||||
GiftDetailInfoRow(R.string.gift_send_size, Raw("소형")),
|
||||
GiftDetailInfoRow(R.string.gift_send_category, Raw("잡화"))
|
||||
),
|
||||
mode.pendingGiftRows
|
||||
)
|
||||
assertEquals(GiftDetailAddressForm, mode.addressForm)
|
||||
assertNull(model.senderInfo)
|
||||
assertNull(model.mailbox)
|
||||
assertNull(model.giftInfo.paidCan)
|
||||
assertNull(model.giftInfo.tracking)
|
||||
assertFalse(model.toString().contains("중첩번호"))
|
||||
assertFalse(model.toString().contains("비밀운송장"))
|
||||
assertTrue(model.actions.none { it == GiftDetailAction.TRACKING || it == GiftDetailAction.CANCEL })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `배송지 입력 form descriptor는 고정 필드 약관과 수령 CTA를 제공한다`() {
|
||||
val form = (
|
||||
GiftDetailPresenter.present(receivedDetail(recipientAddressRequired = true)).received
|
||||
as GiftDetailReceived.AddressForm
|
||||
).addressForm
|
||||
|
||||
assertTrue(form.showsPrivacyNotice)
|
||||
assertEquals(
|
||||
listOf(
|
||||
GiftDetailAddressFormField.NAME,
|
||||
GiftDetailAddressFormField.PHONE_NUMBER,
|
||||
GiftDetailAddressFormField.ZIP_CODE,
|
||||
GiftDetailAddressFormField.ADDRESS,
|
||||
GiftDetailAddressFormField.DETAIL_ADDRESS
|
||||
),
|
||||
form.fields
|
||||
)
|
||||
assertEquals(listOf(true, true, true, true, false), form.fields.map { it.required })
|
||||
assertEquals(
|
||||
listOf(GiftDetailAddressAgreement.TERMS, GiftDetailAddressAgreement.PRIVACY),
|
||||
form.agreements
|
||||
)
|
||||
assertEquals(GiftDetailAddressFormCta.RECEIVE_GIFT, form.cta)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `받은 선물 취소 상태는 발송 전용 개인정보를 보존하지 않는다`() {
|
||||
val model = GiftDetailPresenter.present(
|
||||
receivedDetail(
|
||||
status = "CANCELED",
|
||||
recipientAddress = GiftAddressResponse("수신자", "01000000003", "수신주소")
|
||||
).copy(
|
||||
giftInfo = detail().giftInfo.copy(paidCan = 700, tracking = "비밀운송장"),
|
||||
senderInfo = GiftAddressResponse("발송자", "01000000001", "발송지"),
|
||||
mailbox = GiftAddressResponse("사서함", "01000000002", "사서함주소"),
|
||||
delivery = GiftDeliveryResponse(date, null, null)
|
||||
)
|
||||
)
|
||||
|
||||
assertNull(model.received)
|
||||
assertNull(model.senderInfo)
|
||||
assertNull(model.mailbox)
|
||||
assertNull(model.recipientAddress)
|
||||
assertNull(model.giftInfo.paidCan)
|
||||
assertNull(model.giftInfo.tracking)
|
||||
assertNull(model.cancellation)
|
||||
assertTrue(model.cancellationRows.isEmpty())
|
||||
assertTrue(
|
||||
model.actions.none {
|
||||
it == GiftDetailAction.TRACKING || it == GiftDetailAction.CANCEL || it == GiftDetailAction.POLICY
|
||||
}
|
||||
)
|
||||
assertFalse(model.toString().contains("비밀"))
|
||||
assertFalse(model.toString().contains("사서함"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `받은 선물 미지원 상태는 배송지 입력 완료로 분류하지 않는다`() {
|
||||
listOf("RECEIVED", "FUTURE").forEach { status ->
|
||||
val model = GiftDetailPresenter.present(
|
||||
receivedDetail(status = status).copy(
|
||||
giftInfo = detail().giftInfo.copy(paidCan = 700, tracking = "비밀운송장"),
|
||||
senderInfo = GiftAddressResponse("발송자", "01000000001", "발송지"),
|
||||
mailbox = GiftAddressResponse("사서함", "01000000002", "사서함주소")
|
||||
)
|
||||
)
|
||||
|
||||
assertNull(model.received)
|
||||
assertNull(model.senderInfo)
|
||||
assertNull(model.mailbox)
|
||||
assertNull(model.giftInfo.paidCan)
|
||||
assertNull(model.giftInfo.tracking)
|
||||
assertTrue(
|
||||
model.actions.none {
|
||||
it == GiftDetailAction.TRACKING || it == GiftDetailAction.CANCEL || it == GiftDetailAction.POLICY
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `받은 선물 배송지 입력 완료 모드는 진행 상태별 네 행과 선택 주소를 만든다`() {
|
||||
listOf("TRACKING_REGISTERED", "ARRIVED_AT_MAILBOX", "INSPECTION_COMPLETED").forEach { status ->
|
||||
val model = GiftDetailPresenter.present(
|
||||
receivedDetail(status = status, recipientAddress = GiftAddressResponse("수신자", "01000000003", "수신주소"))
|
||||
)
|
||||
|
||||
val mode = model.received as GiftDetailReceived.AddressCompleted
|
||||
assertEquals(Key.RECIPIENT_ADDRESS_COMPLETED_TITLE, mode.hero.title)
|
||||
assertEquals(
|
||||
listOf(
|
||||
R.string.gift_inbox_sender,
|
||||
R.string.gift_send_size,
|
||||
R.string.gift_send_category,
|
||||
R.string.gift_detail_shipping_date
|
||||
),
|
||||
mode.giftInfoRows.map { it.label }
|
||||
)
|
||||
assertEquals(GiftDetailAddress("수신자", "01000000003", "수신주소"), mode.recipientAddress)
|
||||
assertEquals(setOf(GiftDetailAction.INQUIRY), model.actions)
|
||||
assertTrue(model.actions.none { it == GiftDetailAction.TRACKING || it == GiftDetailAction.CANCEL })
|
||||
}
|
||||
listOf<String?>(null, "bad").forEach { shippingRequestedAt ->
|
||||
val missingDate = GiftDetailPresenter.present(
|
||||
receivedDetail(status = "TRACKING_REGISTERED").copy(
|
||||
giftInfo = detail().giftInfo.copy(shippingRequestedAt = shippingRequestedAt)
|
||||
)
|
||||
).received as GiftDetailReceived.AddressCompleted
|
||||
assertEquals(3, missingDate.giftInfoRows.size)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `받은 선물 배송지 입력 완료 모드는 주소가 없으면 주소 section을 만들지 않는다`() {
|
||||
val model = GiftDetailPresenter.present(receivedDetail(status = "TRACKING_REGISTERED"))
|
||||
|
||||
val mode = model.received as GiftDetailReceived.AddressCompleted
|
||||
assertNull(mode.recipientAddress)
|
||||
assertNull(model.recipientAddress)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `받은 선물 전달 완료 모드는 이력 배송 완료일과 주소 삭제 안내를 사용한다`() {
|
||||
val model = GiftDetailPresenter.present(
|
||||
receivedDetail(
|
||||
status = "DELIVERED",
|
||||
recipientAddressRequired = true,
|
||||
recipientAddress = GiftAddressResponse("수신자", "01000000003", "수신주소")
|
||||
).copy(
|
||||
statusTimeline = listOf(GiftStatusTimelineResponse("DELIVERED", "전달", "2026-10-02T18:30:00Z"))
|
||||
)
|
||||
)
|
||||
|
||||
val mode = model.received as GiftDetailReceived.Delivered
|
||||
assertEquals(Key.RECIPIENT_ADDRESS_REMOVAL_GUIDANCE, mode.recipientAddressGuidance)
|
||||
assertEquals(Key.RECIPIENT_DELIVERED_TITLE, mode.hero.title)
|
||||
assertEquals(5, mode.giftInfoRows.size)
|
||||
assertEquals(
|
||||
GiftDetailInfoRow(R.string.gift_detail_delivered_date, Raw("2026.10.03")),
|
||||
mode.giftInfoRows.last()
|
||||
)
|
||||
assertEquals(GiftDetailAddress("수신자", "01000000003", "수신주소"), mode.recipientAddress)
|
||||
assertEquals(setOf(GiftDetailAction.INQUIRY), model.actions)
|
||||
|
||||
val withoutAddress = GiftDetailPresenter.present(
|
||||
receivedDetail(status = "DELIVERED", recipientAddressRequired = true)
|
||||
).received as GiftDetailReceived.Delivered
|
||||
assertNull(withoutAddress.recipientAddress)
|
||||
assertNull(withoutAddress.recipientAddressGuidance)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `받은 선물 전달 불가 모드는 주소를 숨기고 사유와 정책 액션을 제공한다`() {
|
||||
val model = GiftDetailPresenter.present(
|
||||
receivedDetail(
|
||||
status = "UNDELIVERABLE",
|
||||
recipientAddressRequired = true,
|
||||
recipientAddress = GiftAddressResponse("수신자", "01000000003", "수신주소")
|
||||
)
|
||||
)
|
||||
|
||||
val mode = model.received as GiftDetailReceived.Undeliverable
|
||||
assertEquals(GiftDetailHero(Key.UNDELIVERABLE_LABEL, Key.UNDELIVERABLE_TITLE, Key.UNDELIVERABLE_BODY), mode.hero)
|
||||
assertEquals(GiftDetailUndeliverable(Key.UNDELIVERABLE_LABEL, Key.DISPOSAL_NON_RETURN_GUIDANCE), mode.reason)
|
||||
assertEquals(setOf(GiftDetailAction.INQUIRY, GiftDetailAction.POLICY), model.actions)
|
||||
assertNull(model.recipientAddress)
|
||||
assertFalse(model.toString().contains("수신주소"))
|
||||
assertTrue(model.actions.none { it == GiftDetailAction.TRACKING || it == GiftDetailAction.CANCEL })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `받은 선물의 본인 주소와 보낸 사람 사서함은 대체 없이 구분한다`() {
|
||||
val source = detail().copy(
|
||||
@@ -122,10 +323,14 @@ class GiftDetailPresenterTest {
|
||||
assertEquals("발송지", sent.senderInfo?.address)
|
||||
assertEquals("사서함주소", sent.mailbox?.address)
|
||||
assertEquals("크리에이터", sent.giftInfo.counterpartNickname)
|
||||
val received = GiftDetailPresenter.present(source.copy(direction = "RECEIVED"))
|
||||
val received = GiftDetailPresenter.present(source.copy(direction = "RECEIVED", status = "TRACKING_REGISTERED"))
|
||||
assertEquals(GiftDetailAddress("수신자", "01000000003", "수신주소"), received.recipientAddress)
|
||||
assertEquals("보낸팬", received.giftInfo.counterpartNickname)
|
||||
assertNull(GiftDetailPresenter.present(source.copy(direction = "RECEIVED", recipientAddress = null)).recipientAddress)
|
||||
assertNull(
|
||||
GiftDetailPresenter.present(
|
||||
source.copy(direction = "RECEIVED", status = "TRACKING_REGISTERED", recipientAddress = null)
|
||||
).recipientAddress
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -212,7 +417,7 @@ class GiftDetailPresenterTest {
|
||||
)
|
||||
assertEquals(
|
||||
"$status $direction trackingRequired=$required",
|
||||
status in knownStates && required,
|
||||
direction == "SENT" && status in knownStates && required,
|
||||
GiftDetailAction.TRACKING in model.actions
|
||||
)
|
||||
assertEquals(direction == "SENT" && status == "RECEIVED", GiftDetailAction.CANCEL in model.actions)
|
||||
@@ -221,7 +426,7 @@ class GiftDetailPresenterTest {
|
||||
}
|
||||
}
|
||||
assertEquals(GiftDetailHero(null, Raw("서버 상태"), null), present("FUTURE").hero)
|
||||
assertEquals(setOf("TRACKING", "CANCEL", "INQUIRY"), GiftDetailAction.entries.map { it.name }.toSet())
|
||||
assertEquals(setOf("TRACKING", "CANCEL", "INQUIRY", "POLICY"), GiftDetailAction.entries.map { it.name }.toSet())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -244,6 +449,11 @@ class GiftDetailPresenterTest {
|
||||
assertEquals("10.02", GiftDetailPresenter.formatProgressDate(it))
|
||||
assertEquals("2026.10.02", GiftDetailPresenter.formatCardDate(it))
|
||||
}
|
||||
val boundary = "2026-10-11T23:30:00Z"
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul"))
|
||||
assertEquals("2026.10.12", GiftDetailPresenter.formatCardDate(boundary))
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("UTC"))
|
||||
assertEquals("2026.10.11", GiftDetailPresenter.formatCardDate(boundary))
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"))
|
||||
assertEquals("10.01", GiftDetailPresenter.formatProgressDate(date))
|
||||
assertEquals("2026.10.01", GiftDetailPresenter.formatCardDate(date))
|
||||
@@ -290,7 +500,7 @@ class GiftDetailPresenterTest {
|
||||
@Test
|
||||
fun `취소 본문은 수신 크리에이터와 최상위 번호를 쓰고 일곱 행에 영 환불을 보존한다`() {
|
||||
val source = detail("CANCELED").copy(
|
||||
direction = "RECEIVED",
|
||||
direction = "SENT",
|
||||
giftInfo = detail().giftInfo.copy(applicationNo = "중첩번호", paidCan = 0),
|
||||
delivery = GiftDeliveryResponse(date, null, null),
|
||||
statusTimeline = listOf(GiftStatusTimelineResponse("RECEIVED", "접수", date))
|
||||
@@ -336,6 +546,17 @@ class GiftDetailPresenterTest {
|
||||
|
||||
private fun present(status: String) = GiftDetailPresenter.present(detail(status))
|
||||
|
||||
private fun receivedDetail(
|
||||
status: String = "RECEIVED",
|
||||
recipientAddressRequired: Boolean = false,
|
||||
recipientAddress: GiftAddressResponse? = null
|
||||
) = detail(status).copy(
|
||||
direction = "RECEIVED",
|
||||
recipientAddressRequired = recipientAddressRequired,
|
||||
recipientAddress = recipientAddress,
|
||||
giftInfo = detail().giftInfo.copy(shippingRequestedAt = date)
|
||||
)
|
||||
|
||||
private fun detail(status: String = "RECEIVED") = GiftDetailResponse(
|
||||
"GIFT-1", "SENT", status, "서버 상태",
|
||||
GiftDetailInfoResponse("크리에이터", "보낸팬", "소형", "잡화", null, null, null, null),
|
||||
|
||||
Reference in New Issue
Block a user