Skip to content

Commit e98d79d

Browse files
committed
refactor: move e2e tests to separate module
1 parent 01d79e7 commit e98d79d

File tree

14 files changed

+170
-24
lines changed

14 files changed

+170
-24
lines changed

.github/workflows/android.yml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,13 @@ jobs:
1919
~/.gradle/wrapper
2020
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
2121

22-
- name: Firebase Emulator Cache
23-
uses: actions/cache@v4
24-
with:
25-
path: ~/.cache/firebase/emulators
26-
key: firebase-emulators-v3-${{ runner.os }}
27-
28-
- name: Install Node.js 20
29-
uses: actions/setup-node@v4
30-
with:
31-
node-version: '20'
32-
3322
- name: Set up JDK 21
3423
uses: actions/setup-java@v4
3524
with:
3625
java-version: '21'
3726
distribution: 'temurin'
3827

39-
- name: Install Tools
40-
run: |
41-
npm i -g firebase-tools
42-
43-
- name: Start Firebase Auth Emulator
44-
run: ./scripts/start-firebase-emulator.sh
45-
46-
- name: Build with Gradle
28+
- name: Build and Test
4729
run: ./scripts/build.sh
4830

4931
- name: Print Logs

.github/workflows/e2e_test.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: E2E Tests (Firebase Emulator)
2+
3+
on:
4+
- pull_request
5+
- push
6+
7+
jobs:
8+
e2e-tests:
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 45
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Cache Gradle packages
15+
uses: actions/cache@v3
16+
with:
17+
path: |
18+
~/.gradle/caches
19+
~/.gradle/wrapper
20+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
21+
22+
- name: Firebase Emulator Cache
23+
uses: actions/cache@v4
24+
with:
25+
path: ~/.cache/firebase/emulators
26+
key: firebase-emulators-v3-${{ runner.os }}
27+
28+
- name: Install Node.js 20
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '20'
32+
33+
- name: Set up JDK 21
34+
uses: actions/setup-java@v4
35+
with:
36+
java-version: '21'
37+
distribution: 'temurin'
38+
39+
- name: Install Firebase Tools
40+
run: |
41+
npm i -g firebase-tools
42+
43+
- name: Start Firebase Auth Emulator
44+
run: ./scripts/start-firebase-emulator.sh
45+
46+
- name: Run E2E Tests
47+
run: |
48+
./gradlew e2eTest
49+
50+
- name: Print Logs
51+
if: failure()
52+
run: ./scripts/print_build_logs.sh

auth/src/main/java/com/firebase/ui/auth/compose/FirebaseAuthUI.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ class FirebaseAuthUI private constructor(
452452
*/
453453
@JvmStatic
454454
@RestrictTo(RestrictTo.Scope.TESTS)
455-
internal fun clearInstanceCache() {
455+
fun clearInstanceCache() {
456456
instanceCache.clear()
457457
}
458458

File renamed without changes.

e2eTest/build.gradle.kts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
plugins {
2+
id("com.android.library")
3+
id("org.jetbrains.kotlin.android")
4+
id("org.jetbrains.kotlin.plugin.compose") version Config.kotlinVersion
5+
}
6+
7+
android {
8+
compileSdk = Config.SdkVersions.compile
9+
namespace = "com.firebase.ui.auth.e2etest"
10+
11+
defaultConfig {
12+
minSdk = Config.SdkVersions.min
13+
targetSdk = Config.SdkVersions.target
14+
}
15+
16+
compileOptions {
17+
sourceCompatibility = JavaVersion.VERSION_17
18+
targetCompatibility = JavaVersion.VERSION_17
19+
}
20+
21+
kotlinOptions {
22+
jvmTarget = "17"
23+
}
24+
25+
buildFeatures {
26+
compose = true
27+
}
28+
29+
testOptions {
30+
unitTests {
31+
isIncludeAndroidResources = true
32+
}
33+
}
34+
}
35+
36+
dependencies {
37+
// Depend on the auth module to test it
38+
implementation(project(":auth"))
39+
40+
// Compose dependencies
41+
implementation(platform(Config.Libs.Androidx.Compose.bom))
42+
implementation(Config.Libs.Androidx.Compose.ui)
43+
implementation(Config.Libs.Androidx.Compose.material3)
44+
45+
// Firebase dependencies
46+
implementation(platform(Config.Libs.Firebase.bom))
47+
implementation(Config.Libs.Firebase.auth)
48+
49+
// Test dependencies
50+
testImplementation(Config.Libs.Test.junit)
51+
testImplementation(Config.Libs.Test.truth)
52+
testImplementation(Config.Libs.Test.core)
53+
testImplementation(Config.Libs.Test.robolectric)
54+
testImplementation(Config.Libs.Test.kotlinReflect)
55+
testImplementation(Config.Libs.Test.mockitoCore)
56+
testImplementation(Config.Libs.Test.mockitoInline)
57+
testImplementation(Config.Libs.Test.mockitoKotlin)
58+
testImplementation(Config.Libs.Androidx.credentials)
59+
testImplementation(Config.Libs.Test.composeUiTestJunit4)
60+
}
61+
62+
val mockitoAgent by configurations.creating
63+
64+
dependencies {
65+
mockitoAgent(Config.Libs.Test.mockitoCore) {
66+
isTransitive = false
67+
}
68+
}
69+
70+
tasks.withType<Test>().configureEach {
71+
jvmArgs("-javaagent:${mockitoAgent.asPath}")
72+
}
73+
74+
tasks.register<Test>("e2eTest") {
75+
description = "Runs e2e emulator tests"
76+
group = "verification"
77+
78+
val debug = tasks.named<Test>("testDebugUnitTest").get()
79+
testClassesDirs = debug.testClassesDirs
80+
classpath = debug.classpath
81+
82+
doNotTrackState("Always run e2e emulator tests to mirror Android Studio")
83+
}
File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
</manifest>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.firebase.ui.auth.e2etest.test">
4+
5+
<application>
6+
<!--
7+
Declare ComponentActivity as a launcher activity for Robolectric.
8+
ActivityScenario (used by Compose's test rule) launches with ACTION_MAIN
9+
and CATEGORY_LAUNCHER, which requires a resolvable activity in the manifest.
10+
-->
11+
<activity
12+
android:name="androidx.activity.ComponentActivity"
13+
android:exported="false">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
<!-- No runtime permissions needed for unit tests -->
22+
23+
</manifest>
24+

0 commit comments

Comments
 (0)