fix(dm): USER_CREATOR DM push 라우팅을 보정한다
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package kr.co.vividnext.sodalive.main
|
||||
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class DeepLinkActivitySourceTest {
|
||||
|
||||
@Test
|
||||
fun `DeepLinkActivity는 USER_CREATOR push room_id를 DM 채팅방으로 라우팅한다`() {
|
||||
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/main/DeepLinkActivity.kt").readText()
|
||||
|
||||
assertTrue(source.contains("import kr.co.vividnext.sodalive.v2.main.chat.dm.DmChatRoomActivity"))
|
||||
assertTrue(source.contains("copyString(\"chat_type\")"))
|
||||
assertTrue(source.contains("private fun isUserCreatorChat(bundle: Bundle): Boolean"))
|
||||
assertTrue(source.contains("bundle.getString(\"chat_type\") == \"USER_CREATOR\""))
|
||||
assertTrue(source.contains("DmChatRoomActivity.newIntentByRoomId(applicationContext, roomId)"))
|
||||
assertTrue(source.contains("if (isUserCreatorChat(bundle) && roomId != null && roomId > 0)"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `DeepLinkActivity는 URL query chat_type도 deepLinkExtras에 보존한다`() {
|
||||
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/main/DeepLinkActivity.kt").readText()
|
||||
val queryCopyStart = source.indexOf("if (data != null)")
|
||||
val extrasNormalizeStart = source.indexOf("extras.getString(\"postId\")", queryCopyStart)
|
||||
val queryCopySource = source.substring(queryCopyStart, extrasNormalizeStart)
|
||||
|
||||
assertTrue(queryCopySource.contains("putQuery(\"chat_type\")"))
|
||||
assertTrue(queryCopySource.contains("putQuery(\"room_id\")"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `USER_CREATOR push는 LiveRoom foreground confirm broadcast보다 먼저 foreground route를 시도한다`() {
|
||||
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/main/DeepLinkActivity.kt").readText()
|
||||
|
||||
val dmRouteIndex = source.indexOf("routeForegroundDeepLink(deepLinkExtras)")
|
||||
val liveRoomBroadcastIndex = source.indexOf("Constants.ACTION_LIVE_ROOM_DEEPLINK_CONFIRM")
|
||||
|
||||
assertTrue(dmRouteIndex >= 0)
|
||||
assertTrue(liveRoomBroadcastIndex >= 0)
|
||||
assertTrue(dmRouteIndex < liveRoomBroadcastIndex)
|
||||
}
|
||||
|
||||
private fun projectFile(relativePath: String): File {
|
||||
val candidates = listOf(File(relativePath), File("../$relativePath"))
|
||||
return candidates.firstOrNull { it.exists() }
|
||||
?: error("Project file not found: $relativePath")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package kr.co.vividnext.sodalive.v2.main
|
||||
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class MainV2ActivitySourceTest {
|
||||
|
||||
@Test
|
||||
fun `MainV2Activity는 USER_CREATOR push room_id를 DM 채팅방으로 라우팅한다`() {
|
||||
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/v2/main/MainV2Activity.kt").readText()
|
||||
|
||||
assertTrue(source.contains("import kr.co.vividnext.sodalive.v2.main.chat.dm.DmChatRoomActivity"))
|
||||
assertTrue(source.contains("private fun isUserCreatorChat(bundle: Bundle): Boolean"))
|
||||
assertTrue(source.contains("bundle.getString(\"chat_type\") == \"USER_CREATOR\""))
|
||||
assertTrue(source.contains("val roomId = bundle.getString(\"room_id\")?.toLongOrNull()"))
|
||||
assertTrue(source.contains("DmChatRoomActivity.newIntentByRoomId(applicationContext, roomId)"))
|
||||
assertTrue(source.contains("if (isUserCreatorChat(bundle) && roomId != null && roomId > 0)"))
|
||||
}
|
||||
|
||||
private fun projectFile(relativePath: String): File {
|
||||
val candidates = listOf(File(relativePath), File("../$relativePath"))
|
||||
return candidates.firstOrNull { it.exists() }
|
||||
?: error("Project file not found: $relativePath")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user