Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sign in screen #23

Merged
merged 10 commits into from
Oct 14, 2024
21 changes: 18 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
submodules: recursive
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of Sonar analysis (if we use Sonar Later)

# This step removes the current gradle cache to avoid any caching issues
- name: Remove current gradle cache
run: rm -rf ~/.gradle

# Kernel-based Virtual Machine (KVM) is an open source virtualization technology built into Linux. Enabling it allows the Android emulator to run faster.
- name: Enable KVM group perms
Expand All @@ -44,8 +47,13 @@ jobs:
# this means that one would need to re-download and re-process gradle files for every run. Which is very time consuming.
#
# To avoid that, we cache the the gradle folder to reuse it later.
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: Retrieve gradle cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}

# Cache the Emulator, if the cache does not hit, create the emulator
- name: AVD cache
Expand All @@ -65,10 +73,17 @@ jobs:
target: google_apis
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
emulator-options: -no-window -gpu off -noaudio -no-boot-anim
disable-animations: false
script: echo "Generated AVD snapshot for caching."

# Load google-services.json and local.properties from the secrets
- name: Decode secrets
env:
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
run: |
echo "$GOOGLE_SERVICES" | base64 --decode > ./app/google-services.json

- name: Grant execute permission for gradlew
run: |
chmod +x ./gradlew
Expand Down
146 changes: 77 additions & 69 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
alias(libs.plugins.jetbrainsKotlinAndroid)
alias(libs.plugins.ktfmt)
alias(libs.plugins.sonar)
alias(libs.plugins.gms)
id("jacoco")
}

Expand Down Expand Up @@ -122,74 +123,81 @@ fun DependencyHandlerScope.globalTestImplementation(dep: Any) {

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.lifecycle.runtime.ktx)

// Jetpack Compose BOM
val composeBom = platform(libs.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

// Jetpack Compose
implementation(libs.compose.ui)
implementation(libs.compose.ui.graphics)
implementation(libs.compose.material3)
implementation(libs.compose.activity)
implementation(libs.compose.viewmodel)
implementation(libs.compose.preview)
debugImplementation(libs.compose.tooling)
androidTestImplementation(libs.compose.test.junit)
debugImplementation(libs.compose.test.manifest)

// Kaspresso test framework
androidTestImplementation(libs.kaspresso)
androidTestImplementation(libs.kaspresso.compose)

// Robolectric
testImplementation(libs.robolectric)

// Firebase
implementation(libs.firebase.database.ktx)
implementation(libs.firebase.firestore)
implementation(libs.firebase.ui.auth)
implementation(libs.firebase.auth.ktx)

// Navigation
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx)

// Unit Testing
testImplementation(libs.junit)
androidTestImplementation(libs.mockk)
androidTestImplementation(libs.mockk.android)
androidTestImplementation(libs.mockk.agent)
testImplementation(libs.json)

// UI Testing
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(libs.androidx.espresso.intents)
androidTestImplementation(libs.androidx.ui.test.junit4)
androidTestImplementation(platform(libs.androidx.compose.bom))
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.inline)
testImplementation(libs.mockito.kotlin)
androidTestImplementation(libs.mockito.android)
androidTestImplementation(libs.mockito.kotlin)
testImplementation(libs.robolectric)

// Kaspresso Allure
androidTestImplementation(libs.kaspresso.allure.support)
androidTestImplementation(libs.kaspresso.compose.support)

// Coroutines Testing
testImplementation(libs.kotlinx.coroutines.test)

// Networking with OkHttp
implementation(libs.okhttp)

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.navigation.runtime.ktx)

// Jetpack Compose BOM
val composeBom = platform(libs.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

// Jetpack Compose
implementation(libs.compose.ui)
implementation(libs.compose.ui.graphics)
implementation(libs.compose.material3)
implementation(libs.compose.activity)
implementation(libs.compose.viewmodel)
implementation(libs.compose.preview)
debugImplementation(libs.compose.tooling)
androidTestImplementation(libs.compose.test.junit)
debugImplementation(libs.compose.test.manifest)

// Kaspresso test framework
androidTestImplementation(libs.kaspresso)
androidTestImplementation(libs.kaspresso.compose)

// Robolectric
testImplementation(libs.robolectric)

// Firebase
implementation(libs.firebase.database.ktx)
implementation(libs.firebase.firestore)
implementation(libs.firebase.ui.auth)
implementation(libs.firebase.auth.ktx)

// Navigation
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx)

// Unit Testing
testImplementation(libs.junit)
androidTestImplementation(libs.mockk)
androidTestImplementation(libs.mockk.android)
androidTestImplementation(libs.mockk.agent)
testImplementation(libs.json)

// UI Testing
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(libs.androidx.espresso.intents)
androidTestImplementation(libs.androidx.ui.test.junit4)
androidTestImplementation(platform(libs.androidx.compose.bom))
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.inline)
testImplementation(libs.mockito.kotlin)
androidTestImplementation(libs.mockito.android)
androidTestImplementation(libs.mockito.kotlin)
testImplementation(libs.robolectric)

// Kaspresso Allure
androidTestImplementation(libs.kaspresso.allure.support)
androidTestImplementation(libs.kaspresso.compose.support)

// Coroutines Testing
testImplementation(libs.kotlinx.coroutines.test)

// Networking with OkHttp
implementation(libs.okhttp)

// Calendar
implementation(libs.ical4j)
implementation(libs.compose)
implementation("com.prolificinteractive:material-calendarview:1.4.3") {
exclude(group = "com.android.support", module = "support-v4")
}
}

tasks.withType<Test> {
Expand Down Expand Up @@ -228,4 +236,4 @@ tasks.register("jacocoTestReport", JacocoReport::class) {
include("outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec")
include("outputs/code_coverage/debugAndroidTest/connected/*/coverage.ec")
})
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.github.lookupgroup27.lookup.overview

import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.espresso.intent.Intents
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.lookupgroup27.lookup.MainActivity
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class LandingScreenTest {

@get:Rule val composeTestRule = createAndroidComposeRule<MainActivity>()

@Before
fun setUp() {
// Initialize Espresso Intents to capture and validate outgoing intents
Intents.init()
}

@After
fun tearDown() {
// Release Espresso Intents after tests
Intents.release()
}

@Test
fun logoAndButtonAreDisplayed() {
// Verify that the Look Up logo is displayed
composeTestRule.onNodeWithContentDescription("Look Up Logo").assertIsDisplayed()

// Verify that the Home button is displayed and clickable
composeTestRule.onNodeWithContentDescription("Home Icon").assertIsDisplayed()
composeTestRule.onNodeWithContentDescription("Home Icon").assertHasClickAction()
}

@Test
fun backgroundIsClickableAndNavigatesToMap() {
// Verify that the background image is displayed and clickable
composeTestRule.onNodeWithContentDescription("Background").assertIsDisplayed()
composeTestRule.onNodeWithContentDescription("Background").assertHasClickAction()

// Perform click action on the background image
composeTestRule.onNodeWithContentDescription("Background").performClick()

// Wait for the UI to settle after the click
composeTestRule.waitForIdle()

// Assert that the Map screen is displayed by checking for specific text or UI elements
composeTestRule.onNodeWithText("This is the Map screen.").assertIsDisplayed()
}

@Test
fun homeButtonIsClickable() {
// Perform click action on the home button using its testTag
composeTestRule.onNodeWithTag("Home Icon").performClick()

// Wait for the UI to settle after the click
composeTestRule.waitForIdle()

// Assert that the Menu screen is displayed by checking for specific text
composeTestRule.onNodeWithText("This is the Menu screen.").assertIsDisplayed()
}

@Test
fun testMapViewPromptIsDisplayed() {
// Assert that it is displayed
composeTestRule.onNodeWithText("Click for full map view").assertIsDisplayed()
}
}
Loading
Loading