fix(dm): FCM DM payload 보존을 보정한다

This commit is contained in:
2026-06-19 00:09:51 +09:00
parent f560adabfa
commit bbb84d4ffa
2 changed files with 44 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
package kr.co.vividnext.sodalive.fcm
import org.junit.Assert.assertTrue
import org.junit.Test
import java.io.File
class SodaFirebaseMessagingServiceSourceTest {
@Test
fun `FCM notification extras는 DM chat_type과 기존 deep link 값을 보존한다`() {
val source = projectFile(
"app/src/main/java/kr/co/vividnext/sodalive/fcm/SodaFirebaseMessagingService.kt"
).readText()
assertTrue(source.contains("messageData[\"chat_type\"]?.let { putString(\"chat_type\", it) }"))
assertTrue(source.contains("messageData[\"room_id\"]?.let { putString(\"room_id\", it) }"))
assertTrue(source.contains("messageData[\"message_id\"]?.let { putString(\"message_id\", it) }"))
assertTrue(source.contains("messageData[\"deep_link_value\"]?.let { putString(\"deep_link_value\", it) }"))
}
@Test
fun `FCM deepLink payload도 DM chat_type과 room_id를 extra bundle에 보존한다`() {
val source = projectFile(
"app/src/main/java/kr/co/vividnext/sodalive/fcm/SodaFirebaseMessagingService.kt"
).readText()
val deepLinkBundleStart = source.indexOf("if (!deepLinkUrl.isNullOrBlank())")
val fallbackBundleStart = source.indexOf("} else {", deepLinkBundleStart)
val deepLinkBundleSource = source.substring(deepLinkBundleStart, fallbackBundleStart)
assertTrue(deepLinkBundleSource.contains("putString(\"deep_link\", deepLinkUrl)"))
assertTrue(deepLinkBundleSource.contains("messageData[\"chat_type\"]?.let { putString(\"chat_type\", it) }"))
assertTrue(deepLinkBundleSource.contains("messageData[\"room_id\"]?.let { putString(\"room_id\", it) }"))
}
private fun projectFile(relativePath: String): File {
val candidates = listOf(File(relativePath), File("../$relativePath"))
return candidates.firstOrNull { it.exists() }
?: error("Project file not found: $relativePath")
}
}