fix(dm): FCM deep_link payload 알림 생성을 보정한다
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package kr.co.vividnext.sodalive.fcm
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
@@ -7,19 +8,19 @@ import java.io.File
|
||||
class SodaFirebaseMessagingServiceSourceTest {
|
||||
|
||||
@Test
|
||||
fun `FCM notification extras는 DM chat_type과 기존 deep link 값을 보존한다`() {
|
||||
fun `FCM notification extras는 기존 deep link 값을 보존하고 chat_type을 사용하지 않는다`() {
|
||||
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) }"))
|
||||
assertFalse(source.contains("chat_type"))
|
||||
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에 보존한다`() {
|
||||
fun `FCM deepLink payload는 deep_link와 room_id를 extra bundle에 보존한다`() {
|
||||
val source = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/fcm/SodaFirebaseMessagingService.kt"
|
||||
).readText()
|
||||
@@ -29,10 +30,25 @@ class SodaFirebaseMessagingServiceSourceTest {
|
||||
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) }"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `FCM deep_link 단독 payload는 deep_link extra와 ACTION_VIEW data로 보존한다`() {
|
||||
val source = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/fcm/SodaFirebaseMessagingService.kt"
|
||||
).readText()
|
||||
|
||||
assertTrue(source.contains("} else if (hasDeepLink(remoteMessage.data)) {"))
|
||||
assertTrue(source.contains("private fun hasDeepLink(messageData: Map<String, String>): Boolean"))
|
||||
assertTrue(source.contains("messageData[\"deepLink\"]?.isNotBlank() == true"))
|
||||
assertTrue(source.contains("messageData[\"deep_link\"]?.isNotBlank() == true"))
|
||||
assertTrue(source.contains("val deepLinkUrl = messageData[\"deepLink\"] ?: messageData[\"deep_link\"]"))
|
||||
assertTrue(source.contains("intent.action = Intent.ACTION_VIEW"))
|
||||
assertTrue(source.contains("intent.data = Uri.parse(deepLinkUrl)"))
|
||||
assertTrue(source.contains("putString(\"deep_link\", deepLinkUrl)"))
|
||||
}
|
||||
|
||||
private fun projectFile(relativePath: String): File {
|
||||
val candidates = listOf(File(relativePath), File("../$relativePath"))
|
||||
return candidates.firstOrNull { it.exists() }
|
||||
|
||||
Reference in New Issue
Block a user