Skip to content

Commit cdb4a61

Browse files
Merge pull request #29 from LookUpGroup27/feature/menu-screen
feat: add menu screen with navigation and welcome message
2 parents 0836ff6 + ccbeba5 commit cdb4a61

File tree

16 files changed

+465
-29
lines changed

16 files changed

+465
-29
lines changed

app/src/androidTest/java/com/github/lookupgroup27/lookup/screen/CalendarScreenTest.kt renamed to app/src/androidTest/java/com/github/lookupgroup27/lookup/ui/overview/CalendarScreenTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
package com.github.lookupgroup27.lookup.screen
1+
package com.github.lookupgroup27.lookup.ui.overview
22

33
import androidx.compose.ui.test.assertIsDisplayed
44
import androidx.compose.ui.test.junit4.createComposeRule
55
import androidx.compose.ui.test.onNodeWithText
66
import androidx.compose.ui.test.performClick
77
import com.github.lookupgroup27.lookup.model.calendar.CalendarViewModel
88
import com.github.lookupgroup27.lookup.ui.navigation.NavigationActions
9-
import com.github.lookupgroup27.lookup.ui.overview.CalendarScreen
109
import io.mockk.mockk
1110
import java.text.SimpleDateFormat
1211
import java.util.*

app/src/androidTest/java/com/github/lookupgroup27/lookup/overview/LandingScreenTest.kt renamed to app/src/androidTest/java/com/github/lookupgroup27/lookup/ui/overview/LandingScreenTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.lookupgroup27.lookup.overview
1+
package com.github.lookupgroup27.lookup.ui.overview
22

33
import androidx.compose.ui.test.assertHasClickAction
44
import androidx.compose.ui.test.assertIsDisplayed
@@ -56,7 +56,7 @@ class LandingScreenTest {
5656
composeTestRule.waitForIdle()
5757

5858
// Assert that the Map screen is displayed by checking for specific text or UI elements
59-
composeTestRule.onNodeWithText("This is the Map screen.").assertIsDisplayed()
59+
composeTestRule.onNodeWithTag("map_screen").assertIsDisplayed()
6060
}
6161

6262
@Test
@@ -68,7 +68,7 @@ class LandingScreenTest {
6868
composeTestRule.waitForIdle()
6969

7070
// Assert that the Menu screen is displayed by checking for specific text
71-
composeTestRule.onNodeWithText("This is the Menu screen.").assertIsDisplayed()
71+
composeTestRule.onNodeWithTag("menu_screen").assertIsDisplayed()
7272
}
7373

7474
@Test
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.github.lookupgroup27.lookup.ui.overview
2+
3+
import androidx.compose.ui.test.*
4+
import androidx.compose.ui.test.junit4.createComposeRule
5+
import com.github.lookupgroup27.lookup.ui.map.MapScreen
6+
import com.github.lookupgroup27.lookup.ui.navigation.NavigationActions
7+
import org.junit.*
8+
import org.mockito.kotlin.*
9+
10+
class MapScreenTest {
11+
12+
@get:Rule val composeTestRule = createComposeRule()
13+
14+
private val mockNavigationActions: NavigationActions = mock()
15+
16+
@Test
17+
fun mapScreen_displaysBackgroundImage() {
18+
composeTestRule.setContent { MapScreen(navigationActions = mockNavigationActions) }
19+
20+
// Verify the background image is displayed
21+
composeTestRule.onNodeWithTag("map_background").assertIsDisplayed()
22+
}
23+
24+
@Test
25+
fun mapScreen_clickBackButton_navigatesBack() {
26+
composeTestRule.setContent { MapScreen(navigationActions = mockNavigationActions) }
27+
28+
// Perform click on the back button
29+
composeTestRule.onNodeWithTag("go_back_button").performClick()
30+
31+
// Verify navigation back action is triggered
32+
verify(mockNavigationActions).goBack()
33+
}
34+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package com.github.lookupgroup27.lookup.ui.overview
2+
3+
import androidx.compose.ui.test.*
4+
import androidx.compose.ui.test.junit4.createComposeRule
5+
import com.github.lookupgroup27.lookup.ui.navigation.*
6+
import org.junit.*
7+
import org.mockito.kotlin.*
8+
9+
class MenuScreenTest {
10+
11+
@get:Rule val composeTestRule = createComposeRule()
12+
13+
private val mockNavigationActions: NavigationActions = mock()
14+
15+
@Test
16+
fun menuScreen_displaysBottomNavigationMenu() {
17+
composeTestRule.setContent { MenuScreen(navigationActions = mockNavigationActions) }
18+
19+
// Check that the bottom navigation menu is displayed
20+
composeTestRule.onNodeWithTag("bottomNavigationMenu").assertIsDisplayed()
21+
}
22+
23+
@Test
24+
fun menuScreen_bottomNavigation_clickMenuTab_navigatesToMenu() {
25+
composeTestRule.setContent { MenuScreen(navigationActions = mockNavigationActions) }
26+
27+
// Click on the Menu tab
28+
composeTestRule.onNodeWithTag("Menu").performClick()
29+
// Find the correct TopLevelDestination for "Map"
30+
val menuDestination = LIST_TOP_LEVEL_DESTINATION.first { it.textId == "Menu" }
31+
32+
// Verify that navigation to the Map screen is triggered with the correct object
33+
verify(mockNavigationActions).navigateTo(menuDestination)
34+
}
35+
36+
@Test
37+
fun menuScreen_bottomNavigation_clickMapTab_navigatesToMap() {
38+
composeTestRule.setContent { MenuScreen(navigationActions = mockNavigationActions) }
39+
40+
// Click on the Map tab
41+
composeTestRule.onNodeWithTag("Map").performClick()
42+
43+
val mapDestination = LIST_TOP_LEVEL_DESTINATION.first { it.textId == "Map" }
44+
45+
// Verify that navigation to the Map screen is triggered with the correct object
46+
verify(mockNavigationActions).navigateTo(mapDestination)
47+
}
48+
49+
@Test
50+
fun menuScreen_displaysWelcomeText() {
51+
composeTestRule.setContent { MenuScreen(navigationActions = mockNavigationActions) }
52+
53+
// Check that the "Welcome !" text is displayed
54+
composeTestRule.onNodeWithText("Welcome !").assertIsDisplayed()
55+
}
56+
57+
@Test
58+
fun menuScreen_backButton_navigatesBack() {
59+
composeTestRule.setContent { MenuScreen(navigationActions = mockNavigationActions) }
60+
61+
// Perform click on the back button
62+
composeTestRule.onNodeWithTag("back_button").performClick()
63+
64+
// Verify navigation back action is triggered
65+
verify(mockNavigationActions).goBack()
66+
}
67+
68+
@Test
69+
fun menuScreen_displaysAllButtons() {
70+
composeTestRule.setContent { MenuScreen(navigationActions = mockNavigationActions) }
71+
72+
// Check that the background is displayed
73+
composeTestRule.onNodeWithTag("background_image").assertIsDisplayed()
74+
// Check that all buttons are displayed
75+
composeTestRule.onNodeWithText("Quizzes").assertIsDisplayed()
76+
composeTestRule.onNodeWithText("Calendar").assertIsDisplayed()
77+
composeTestRule.onNodeWithText("Sky Tracker").assertIsDisplayed()
78+
composeTestRule.onNodeWithTag("profile_button").assertIsDisplayed()
79+
}
80+
81+
@Test
82+
fun menuScreen_clickProfileButton_navigatesToProfile() {
83+
composeTestRule.setContent { MenuScreen(navigationActions = mockNavigationActions) }
84+
85+
// Click on profile button
86+
composeTestRule.onNodeWithTag("profile_button").performClick()
87+
88+
// Verify navigation to Profile screen is triggered
89+
verify(mockNavigationActions).navigateTo(Screen.PROFILE)
90+
}
91+
92+
@Test
93+
fun menuScreen_clickQuizzes_navigatesToQuizScreen() {
94+
composeTestRule.setContent { MenuScreen(navigationActions = mockNavigationActions) }
95+
96+
// Perform click on "Quizzes" button
97+
composeTestRule.onNodeWithText("Quizzes").performClick()
98+
99+
// Verify navigation to Quiz screen is triggered
100+
verify(mockNavigationActions).navigateTo(Screen.QUIZ)
101+
}
102+
103+
@Test
104+
fun menuScreen_clickCalendar_navigatesToCalendarScreen() {
105+
composeTestRule.setContent { MenuScreen(navigationActions = mockNavigationActions) }
106+
107+
// Perform click on "Calendar" button
108+
composeTestRule.onNodeWithText("Calendar").performClick()
109+
110+
// Verify navigation to Calendar screen is triggered
111+
verify(mockNavigationActions).navigateTo(Screen.CALENDAR)
112+
}
113+
114+
@Test
115+
fun menuScreen_clickSkyTracker_navigatesToSkyTrackerScreen() {
116+
composeTestRule.setContent { MenuScreen(navigationActions = mockNavigationActions) }
117+
118+
// Perform click on "Sky Tracker" button
119+
composeTestRule.onNodeWithText("Sky Tracker").performClick()
120+
121+
// Verify navigation to Sky Tracker screen is triggered
122+
verify(mockNavigationActions).navigateTo(Screen.SKY_TRACKER)
123+
}
124+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.github.lookupgroup27.lookup.ui.overview
2+
3+
import androidx.compose.ui.test.assertIsDisplayed
4+
import androidx.compose.ui.test.junit4.createComposeRule
5+
import androidx.compose.ui.test.onNodeWithTag
6+
import androidx.compose.ui.test.onNodeWithText
7+
import androidx.compose.ui.test.performClick
8+
import com.github.lookupgroup27.lookup.ui.navigation.NavigationActions
9+
import org.junit.Rule
10+
import org.junit.Test
11+
import org.mockito.kotlin.mock
12+
import org.mockito.kotlin.verify
13+
14+
class QuizScreenTest {
15+
16+
@get:Rule val composeTestRule = createComposeRule()
17+
18+
private val mockNavigationActions: NavigationActions = mock()
19+
20+
@Test
21+
fun quizScreen_displaysQuizText() {
22+
composeTestRule.setContent { QuizScreen(navigationActions = mockNavigationActions) }
23+
24+
// Verify that the "Quiz Screen" text is displayed
25+
composeTestRule.onNodeWithText("Quiz Screen").assertIsDisplayed()
26+
}
27+
28+
@Test
29+
fun quizScreen_clickBackButton_navigatesBack() {
30+
composeTestRule.setContent { QuizScreen(navigationActions = mockNavigationActions) }
31+
32+
// Perform click on the back button
33+
composeTestRule.onNodeWithTag("go_back_button_quiz").performClick()
34+
35+
// Verify navigation back action is triggered
36+
verify(mockNavigationActions).goBack()
37+
}
38+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.github.lookupgroup27.lookup.ui.profile
2+
3+
import androidx.compose.ui.test.assertIsDisplayed
4+
import androidx.compose.ui.test.junit4.createComposeRule
5+
import androidx.compose.ui.test.onNodeWithTag
6+
import androidx.compose.ui.test.onNodeWithText
7+
import androidx.compose.ui.test.performClick
8+
import com.github.lookupgroup27.lookup.ui.navigation.NavigationActions
9+
import org.junit.Rule
10+
import org.junit.Test
11+
import org.mockito.kotlin.mock
12+
import org.mockito.kotlin.verify
13+
14+
class ProfileScreenTest {
15+
16+
@get:Rule val composeTestRule = createComposeRule()
17+
18+
private val mockNavigationActions: NavigationActions = mock()
19+
20+
@Test
21+
fun profileScreen_displaysProfileTextAndBackButton() {
22+
composeTestRule.setContent { ProfileScreen(navigationActions = mockNavigationActions) }
23+
24+
// Verify that the profile screen text is displayed
25+
composeTestRule.onNodeWithText("Profile Screen").assertIsDisplayed()
26+
27+
// Verify that the back button is displayed
28+
composeTestRule.onNodeWithTag("go_back_button_profile").assertIsDisplayed()
29+
}
30+
31+
@Test
32+
fun profileScreen_clickBackButton_navigatesBack() {
33+
composeTestRule.setContent { ProfileScreen(navigationActions = mockNavigationActions) }
34+
35+
// Click on back button
36+
composeTestRule.onNodeWithTag("go_back_button_profile").performClick()
37+
38+
// Verify that the navigation back action is triggered
39+
verify(mockNavigationActions).goBack()
40+
}
41+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.github.lookupgroup27.lookup.ui.skytracker
2+
3+
import androidx.compose.ui.test.assertIsDisplayed
4+
import androidx.compose.ui.test.junit4.createComposeRule
5+
import androidx.compose.ui.test.onNodeWithTag
6+
import androidx.compose.ui.test.onNodeWithText
7+
import androidx.compose.ui.test.performClick
8+
import com.github.lookupgroup27.lookup.ui.navigation.NavigationActions
9+
import org.junit.Rule
10+
import org.junit.Test
11+
import org.mockito.kotlin.mock
12+
import org.mockito.kotlin.verify
13+
14+
class SkyTrackerScreenTest {
15+
16+
@get:Rule val composeTestRule = createComposeRule()
17+
18+
private val mockNavigationActions: NavigationActions = mock()
19+
20+
@Test
21+
fun skyTrackerScreen_displaysSkyTrackerText() {
22+
composeTestRule.setContent { SkyTrackerScreen(navigationActions = mockNavigationActions) }
23+
24+
// Verify that the "Sky Tracker Screen" text is displayed
25+
composeTestRule.onNodeWithText("Sky Tracker Screen").assertIsDisplayed()
26+
}
27+
28+
@Test
29+
fun skyTrackerScreen_clickBackButton_navigatesBack() {
30+
composeTestRule.setContent { SkyTrackerScreen(navigationActions = mockNavigationActions) }
31+
32+
// Perform click on the back button
33+
composeTestRule.onNodeWithTag("go_back_button_skyTracker").performClick()
34+
35+
// Verify navigation back action is triggered
36+
verify(mockNavigationActions).goBack()
37+
}
38+
}

app/src/main/java/com/github/lookupgroup27/lookup/MainActivity.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,15 @@ fun LookUpApp() {
5454
) {
5555
composable(Screen.AUTH) { SignInScreen(navigationActions) }
5656
}
57-
57+
navigation(startDestination = Screen.MAP, route = Route.MAP) {
58+
composable(Screen.MAP) { MapScreen(navigationActions) }
59+
}
5860
navigation(
5961
startDestination = Screen.LANDING,
6062
route = Route.LANDING,
6163
) {
6264
composable(Screen.LANDING) { LandingScreen(navigationActions) }
6365
composable(Screen.MENU) { MenuScreen(navigationActions) }
64-
composable(Screen.MAP) { MapScreen(navigationActions) }
6566
}
6667

6768
navigation(
@@ -70,9 +71,7 @@ fun LookUpApp() {
7071
) {
7172
composable(Screen.MENU) { MenuScreen(navigationActions) }
7273
composable(Screen.PROFILE) { ProfileScreen(navigationActions) }
73-
7474
composable(Screen.CALENDAR) { CalendarScreen(calendarViewModel, navigationActions) }
75-
7675
composable(Screen.SKY_TRACKER) { SkyTrackerScreen(navigationActions) }
7776
composable(Screen.QUIZ) { QuizScreen(navigationActions) }
7877
}

app/src/main/java/com/github/lookupgroup27/lookup/ui/authentication/SignIn.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ import androidx.compose.material3.ButtonDefaults
1616
import androidx.compose.material3.MaterialTheme
1717
import androidx.compose.material3.Scaffold
1818
import androidx.compose.material3.Text
19-
import androidx.compose.runtime.Composable
20-
import androidx.compose.runtime.rememberCoroutineScope
19+
import androidx.compose.runtime.*
2120
import androidx.compose.ui.Alignment
2221
import androidx.compose.ui.Modifier
2322
import androidx.compose.ui.graphics.Color
Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
11
package com.github.lookupgroup27.lookup.ui.map
22

3-
import androidx.compose.material3.Text
3+
import androidx.compose.foundation.Image
4+
import androidx.compose.foundation.layout.*
5+
import androidx.compose.material.icons.Icons
6+
import androidx.compose.material.icons.filled.ArrowBack
7+
import androidx.compose.material3.*
48
import androidx.compose.runtime.Composable
9+
import androidx.compose.ui.*
10+
import androidx.compose.ui.graphics.Color
11+
import androidx.compose.ui.layout.ContentScale
12+
import androidx.compose.ui.platform.testTag
13+
import androidx.compose.ui.res.painterResource
14+
import androidx.compose.ui.unit.dp
15+
import com.github.lookupgroup27.lookup.R
516
import com.github.lookupgroup27.lookup.ui.navigation.NavigationActions
617

718
@Composable
819
fun MapScreen(navigationActions: NavigationActions) {
9-
Text(text = "This is the Map screen.")
20+
Box(modifier = Modifier.fillMaxSize().testTag("map_screen")) {
21+
Image(
22+
painter = painterResource(id = R.drawable.landing_screen_bckgrnd), // Import your image
23+
contentDescription = null,
24+
modifier = Modifier.fillMaxSize().testTag("map_background"),
25+
contentScale = ContentScale.Crop)
26+
27+
// Back button
28+
IconButton(
29+
onClick = { navigationActions.goBack() },
30+
modifier = Modifier.padding(16.dp).align(Alignment.TopStart).testTag("go_back_button")) {
31+
Icon(
32+
imageVector = Icons.Default.ArrowBack,
33+
contentDescription = "Back",
34+
tint = Color.White)
35+
}
36+
}
1037
}

0 commit comments

Comments
 (0)