diff --git a/app/src/androidTest/java/com/juandgaines/testground/presentation/ProfileScreenTest.kt b/app/src/androidTest/java/com/juandgaines/testground/presentation/ProfileScreenTest.kt deleted file mode 100644 index adb7733..0000000 --- a/app/src/androidTest/java/com/juandgaines/testground/presentation/ProfileScreenTest.kt +++ /dev/null @@ -1,98 +0,0 @@ -package com.juandgaines.testground.presentation - -import androidx.compose.material3.MaterialTheme -import androidx.compose.ui.test.assertIsDisplayed -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.compose.ui.test.onNodeWithContentDescription -import androidx.compose.ui.test.onNodeWithText -import com.juandgaines.testground.domain.Coordinates -import com.juandgaines.testground.domain.Place -import com.juandgaines.testground.domain.Profile -import com.juandgaines.testground.domain.User -import org.junit.Rule -import org.junit.Test - -class ProfileScreenTest { - - @get:Rule - val composeRule = createComposeRule() - - @get:Rule - val mainDispatcherRule = MainDispatcherRule() - - @Test - fun profileScreen_whenProfileLoaded_showsUserAndPlaces() { - // Arrange - val state = previewProfileState() - - // Act - composeRule.setContent { - MaterialTheme { - ProfileScreen( - state = state, - onPlaceClick = {} - ) - } - } - - // Assert - composeRule.onNodeWithText("Welcome Test User!").assertIsDisplayed() - composeRule.onNodeWithText("Place 1").assertIsDisplayed() - composeRule.onNodeWithText("Lat: 1.0").assertIsDisplayed() - composeRule.onNodeWithText("Long: 1.0").assertIsDisplayed() - } - - @Test - fun profileScreen_whenLoading_showsLoadingIndicator() { - composeRule.setContent { - MaterialTheme { - ProfileScreen( - state = ProfileState( - isLoading = true - ), - onPlaceClick = {} - ) - } - } - - // Assert loading state using semantics - composeRule.onNodeWithContentDescription("Loading Profile").assertIsDisplayed() - } - - @Test - fun profileScreen_whenError_showsErrorMessage() { - val errorMessage = "Error loading profile" - - composeRule.setContent { - MaterialTheme { - ProfileScreen( - state = ProfileState( - errorMessage = errorMessage - ), onPlaceClick = {} - ) - } - } - - composeRule.onNodeWithText(errorMessage).assertIsDisplayed() - } -} - -fun previewProfileState() = ProfileState( - profile = Profile( - user = User( - id = "test-user", - username = "Test User" - ), - places = (1..3).map { - Place( - id = it.toString(), - name = "Place $it", - coordinates = Coordinates( - latitude = it.toDouble(), - longitude = it.toDouble() - ) - ) - } - ), - isLoading = false -) \ No newline at end of file diff --git a/app/src/main/java/com/juandgaines/testground/presentation/DetailPlaceScreen.kt b/app/src/main/java/com/juandgaines/testground/presentation/DetailPlaceScreen.kt index 769d75c..7db185b 100644 --- a/app/src/main/java/com/juandgaines/testground/presentation/DetailPlaceScreen.kt +++ b/app/src/main/java/com/juandgaines/testground/presentation/DetailPlaceScreen.kt @@ -24,7 +24,9 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp +import com.juandgaines.testground.domain.Coordinates import com.juandgaines.testground.domain.Place @OptIn(ExperimentalMaterial3Api::class) @@ -108,4 +110,20 @@ fun DetailPlaceScreen( } } } -} \ No newline at end of file +} + +@PreviewLightDark +@Composable +fun DetailPlaceScreenPreview() { + DetailPlaceScreen( + place = Place( + id = "1", + name = "Test Place", + coordinates = Coordinates( + latitude = 37.7749, + longitude = -122.4194 + ) + ), + onNavigateBack = {} + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/juandgaines/testground/presentation/ProfileScreen.kt b/app/src/main/java/com/juandgaines/testground/presentation/ProfileScreen.kt index f1a738c..762451c 100644 --- a/app/src/main/java/com/juandgaines/testground/presentation/ProfileScreen.kt +++ b/app/src/main/java/com/juandgaines/testground/presentation/ProfileScreen.kt @@ -20,8 +20,13 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp +import com.juandgaines.testground.domain.Coordinates import com.juandgaines.testground.domain.Place +import com.juandgaines.testground.domain.Profile +import com.juandgaines.testground.domain.User @Composable fun ProfileScreen( @@ -118,4 +123,29 @@ fun PlaceCard( } } } -} \ No newline at end of file +} + +@PreviewLightDark +@Composable +fun ProfileScreenPreview() { + val sampleProfile = Profile( + user = User( + id = "1", + username = "JohnDoe"), + places = listOf( + Place(id = "1",name = "Place 1", coordinates = Coordinates(1.0, 2.0)), + Place(id = "2",name = "Place 2", coordinates = Coordinates(3.0, 4.0)) + ) + ) + + val sampleState = ProfileState( + isLoading = false, + errorMessage = null, + profile = sampleProfile + ) + + ProfileScreen( + state = sampleState, + onPlaceClick = {} + ) +} \ No newline at end of file