Skip to content

Commit

Permalink
testfix: testcase에서 access token 선행 발급
Browse files Browse the repository at this point in the history
앱을 처음시작할때 disable auto login 으로 수정됨에 따라
test code를 진행할 때 access tocken을 mechanicjo 계정의 access token을 발급하여 진행하도록 수정하였습니다.
  • Loading branch information
mechanicjo committed Nov 29, 2023
1 parent 3b076f2 commit 6e5ab5d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.GrantPermissionRule
import com.team13.fooriend.ui.component.BottomBar
import com.team13.fooriend.ui.navigation.BottomNavItem
import com.team13.fooriend.ui.util.saveAccessToken
import org.junit.Assert
import org.junit.Before
import org.junit.Rule
Expand All @@ -30,9 +31,9 @@ class BottomBarTest {

@Before
fun setUpNavHost(){
// 위치 정보 공유 허가 코드 작성 필요 -> 아래에 작성함
composeTestRule.setContent {
context = LocalContext.current
saveAccessToken(context, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwidXNlcm5hbWUiOiJtZWNoYW5pY2pvIiwiaWF0IjoxNzAxMjY3NTc5LCJleHAiOjE3MDkwNDM1Nzl9.QcaBr1w8RKQ_FkQ_Yce_J7fOn6TuvVhjl3H0jjMANmY")
navController = TestNavHostController(context)
navController.navigatorProvider.addNavigator(ComposeNavigator())
BottomBar(navController = navController, context = context, showBottomBar = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.team13.fooriend

import android.content.Context
import android.util.Log
import androidx.annotation.UiThread
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.test.assertIsDisplayed
Expand Down Expand Up @@ -93,5 +94,6 @@ class LogInScreenTest {
}
val route = navController.currentBackStackEntry?.destination?.route
Assert.assertEquals(route, Graph.HOME)
Log.d("testLog", context.getSharedPreferences("MyAppPrefs", Context.MODE_PRIVATE).getString("AccessToken", null).toString())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.navigation.compose.ComposeNavigator
import androidx.navigation.testing.TestNavHostController
import com.team13.fooriend.core.graph.HomeNavGraph
import com.team13.fooriend.ui.navigation.BottomNavItem
import com.team13.fooriend.ui.util.saveAccessToken
import org.junit.Assert
import org.junit.Before
import org.junit.Rule
Expand All @@ -28,6 +29,7 @@ class MyInformationScreenTest {
fun setUpNavHost(){
composeTestRule.setContent {
context = LocalContext.current
saveAccessToken(context, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwidXNlcm5hbWUiOiJtZWNoYW5pY2pvIiwiaWF0IjoxNzAxMjY3NTc5LCJleHAiOjE3MDkwNDM1Nzl9.QcaBr1w8RKQ_FkQ_Yce_J7fOn6TuvVhjl3H0jjMANmY")
navController = TestNavHostController(context)
navController.navigatorProvider.addNavigator(ComposeNavigator())
HomeNavGraph(navController = navController, context = context, startDestination = BottomNavItem.MyPage.route)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.team13.fooriend.core.graph.AuthScreen
import com.team13.fooriend.core.graph.HomeNavGraph
import com.team13.fooriend.core.graph.RootNavigationGraph
import com.team13.fooriend.ui.navigation.BottomNavItem
import com.team13.fooriend.ui.util.saveAccessToken
import okhttp3.internal.wait
import org.junit.Assert
import org.junit.Before
Expand All @@ -44,6 +45,7 @@ class MyPageScreenTest {
fun setUpNavHost(){
composeTestRule.setContent {
context = LocalContext.current
saveAccessToken(context, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwidXNlcm5hbWUiOiJtZWNoYW5pY2pvIiwiaWF0IjoxNzAxMjY3NTc5LCJleHAiOjE3MDkwNDM1Nzl9.QcaBr1w8RKQ_FkQ_Yce_J7fOn6TuvVhjl3H0jjMANmY")
navController = TestNavHostController(context)
navController.navigatorProvider.addNavigator(ComposeNavigator())
HomeNavGraph(navController = navController, context = context, startDestination = BottomNavItem.MyPage.route)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.navigation.compose.ComposeNavigator
import androidx.navigation.testing.TestNavHostController
import com.team13.fooriend.core.graph.HomeNavGraph
import com.team13.fooriend.ui.navigation.BottomNavItem
import com.team13.fooriend.ui.util.saveAccessToken
import org.junit.Assert
import org.junit.Before
import org.junit.Rule
Expand All @@ -27,6 +28,7 @@ class RestaurantDetailScreenTest {
fun setUpNavHost_fromReviewDetailScreen(){
composeTestRule.setContent {
context = LocalContext.current
saveAccessToken(context, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwidXNlcm5hbWUiOiJtZWNoYW5pY2pvIiwiaWF0IjoxNzAxMjY3NTc5LCJleHAiOjE3MDkwNDM1Nzl9.QcaBr1w8RKQ_FkQ_Yce_J7fOn6TuvVhjl3H0jjMANmY")
navController = TestNavHostController(context)
navController.navigatorProvider.addNavigator(ComposeNavigator())
HomeNavGraph(navController = navController, context = context, startDestination = BottomNavItem.Social.route)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.navigation.compose.ComposeNavigator
import androidx.navigation.testing.TestNavHostController
import com.team13.fooriend.core.graph.HomeNavGraph
import com.team13.fooriend.ui.navigation.BottomNavItem
import com.team13.fooriend.ui.util.saveAccessToken
import org.junit.Assert
import org.junit.Before
import org.junit.Rule
Expand All @@ -27,6 +28,7 @@ class ReviewDetailScreenTest {
fun setUpNavHost_fromSocialScreen(){
composeTestRule.setContent {
context = LocalContext.current
saveAccessToken(context, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwidXNlcm5hbWUiOiJtZWNoYW5pY2pvIiwiaWF0IjoxNzAxMjY3NTc5LCJleHAiOjE3MDkwNDM1Nzl9.QcaBr1w8RKQ_FkQ_Yce_J7fOn6TuvVhjl3H0jjMANmY")
navController = TestNavHostController(context)
navController.navigatorProvider.addNavigator(ComposeNavigator())
HomeNavGraph(navController = navController, context = context, startDestination = BottomNavItem.Social.route)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.navigation.compose.ComposeNavigator
import androidx.navigation.testing.TestNavHostController
import com.team13.fooriend.core.graph.HomeNavGraph
import com.team13.fooriend.ui.navigation.BottomNavItem
import com.team13.fooriend.ui.util.saveAccessToken
import okhttp3.internal.wait
import org.junit.Assert
import org.junit.Before
Expand All @@ -31,6 +32,7 @@ class SocialScreenTest {
fun setUpNavHost(){
composeTestRule.setContent {
context = LocalContext.current
saveAccessToken(context, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwidXNlcm5hbWUiOiJtZWNoYW5pY2pvIiwiaWF0IjoxNzAxMjY3NTc5LCJleHAiOjE3MDkwNDM1Nzl9.QcaBr1w8RKQ_FkQ_Yce_J7fOn6TuvVhjl3H0jjMANmY")
navController = TestNavHostController(context)
navController.navigatorProvider.addNavigator(ComposeNavigator())
HomeNavGraph(navController = navController, context = context, startDestination = BottomNavItem.Social.route)
Expand Down

0 comments on commit 6e5ab5d

Please sign in to comment.