fix(dm): MainActivity chat path 라우팅을 보정한다
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package kr.co.vividnext.sodalive.main
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class MainActivitySourceTest {
|
||||
|
||||
@Test
|
||||
fun `MainActivity는 deep_link를 원본 bundle에 merge하고 chat_type을 사용하지 않는다`() {
|
||||
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/main/MainActivity.kt").readText()
|
||||
|
||||
assertTrue(source.contains("Bundle(bundle).apply"))
|
||||
assertTrue(source.contains("buildBundleFromDeepLinkUrl(deepLinkUrl)?.let { putAll(it) }"))
|
||||
assertFalse(source.contains("chat_type"))
|
||||
assertFalse(source.contains("isUserCreatorChat"))
|
||||
assertTrue(source.contains("return bundle.getString(\"deep_link_value\") == \"chat\""))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MainActivity는 chat path deep_link 단독 payload를 DM 채팅방으로 라우팅한다`() {
|
||||
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/main/MainActivity.kt").readText()
|
||||
|
||||
val chatPathIndex = source.indexOf("\"chat\" ->")
|
||||
val dmRouteIndex = source.indexOf("isDmChatDeepLink(bundle) && roomId != null && roomId > 0")
|
||||
val liveRouteIndex = source.indexOf("roomId != null && roomId > 0 ->")
|
||||
|
||||
assertTrue(source.contains("import kr.co.vividnext.sodalive.v2.main.chat.dm.DmChatRoomActivity"))
|
||||
assertTrue(chatPathIndex >= 0)
|
||||
assertTrue(source.contains("putIfAbsent(\"room_id\", pathId)"))
|
||||
assertTrue(source.contains("putIfAbsent(\"deep_link_value\", \"chat\")"))
|
||||
assertTrue(source.contains("private fun isDmChatDeepLink(bundle: Bundle): Boolean"))
|
||||
assertTrue(source.contains("DmChatRoomActivity.newIntentByRoomId(applicationContext, roomId)"))
|
||||
assertTrue(dmRouteIndex >= 0)
|
||||
assertTrue(liveRouteIndex >= 0)
|
||||
assertTrue(dmRouteIndex < liveRouteIndex)
|
||||
}
|
||||
|
||||
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