Skip to content

Add an option to make a direct call in E2E testing flavor - #1471

Merged
aleksandar-apostolov merged 5 commits into
developfrom
feature/rahullohra/e2e_calling
Jul 2, 2025
Merged

Add an option to make a direct call in E2E testing flavor#1471
aleksandar-apostolov merged 5 commits into
developfrom
feature/rahullohra/e2e_calling

Conversation

@rahul-lohra

@rahul-lohra rahul-lohra commented Jul 2, 2025

Copy link
Copy Markdown
Contributor

🎯 Goal

Add an option to make a direct call in E2E testing flavor

[AND-568]

🛠 Implementation details

This PR introduces an InMemoryStore interface used to temporarily store user-related data only in the E2eTesting build flavor.

✨ Purpose
The main goal is to make relevant user data (such as the one set during test setup or joining a call) accessible globally during end-to-end (E2E) test flows — without modifying the SDK’s core state.

In non-E2E flavors, the implementation is safely no-op to avoid unnecessary memory usage or behavior differences.

🏗️ Implementation Details

interface InMemoryStore {
    fun saveUser(user: User)
    fun getUser(): User?
}

InMemoryStoreImpl: Used only in E2eTesting builds; holds the user in memory for temporary access.

🚫 NoopMemoryStoreImpl: Used in all other flavors; safely ignores calls and always returns null.

🧩 Hilt Integration

@Provides
@Singleton
fun provideInMemoryStore(): InMemoryStore {
    return when (StreamBuildFlavorUtil.current) {
        StreamBuildFlavor.E2eTesting -> InMemoryStoreImpl()
        else -> NoopMemoryStoreImpl()
    }
}

This ensures the correct implementation is injected at runtime based on the current build flavor, with zero overhead for production builds.

🔧 Build Flavor Refactor

Replaced the old StreamFlavors object:

internal object StreamFlavors {
    const val development = "development"
    const val production = "production"
}

with a more structured and extensible approach using StreamBuildFlavor and StreamBuildFlavorUtil:

object StreamBuildFlavorUtil {
    val current: StreamBuildFlavor
        get() = StreamBuildFlavor.from(BuildConfig.FLAVOR)

    val isDevelopment: Boolean get() = current == Development
    val isProduction: Boolean get() = current == Production
    val isE2eTesting: Boolean get() = current == E2eTesting
}

enum class StreamBuildFlavor(val type: String) {
    Development("development"),
    Production("production"),
    E2eTesting("e2etesting"),
    ;

    companion object {
        fun from(type: String?): StreamBuildFlavor {
            return entries.find { it.type == type } ?: Development
        }
    }
}

This change:

  • Adds type safety via enum class StreamBuildFlavor
  • Makes it easier to add or compare flavors going forward
  • Centralizes flavor-related logic (e.g., isE2eTesting) in a utility object
  • Provides a fallback to Development for unknown or missing values

🎨 UI Changes

Add relevant videos

Screen_Recording_20250702_163547_Stream.Video.Calls.E2E.Testing.mp4

🧪 Testing

  1. Launch the app and wait until the main screen is visible — the User ID should appear in the top-left corner.
  2. Sign out and wait for the app to navigate to the login screen.
  3. Confirm that the login screen is rendered successfully.
  4. Sign in again with a random user.
  5. The app should now render the main screen again.
  6. Navigate to the Direct Call screen and initiate a call to the user listed — this should be the same user created in Step 1.

@rahul-lohra
rahul-lohra requested a review from a team as a code owner July 2, 2025 10:48
@rahul-lohra rahul-lohra self-assigned this Jul 2, 2025
@rahul-lohra rahul-lohra added pr:improvement Enhances an existing feature or code pr:demo-app Changes specific to demo app labels Jul 2, 2025
@github-actions

github-actions Bot commented Jul 2, 2025

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-video-android-core 11.40 MB 11.40 MB 0.00 MB 🟢
stream-video-android-ui-xml 5.70 MB 5.70 MB 0.00 MB 🟢
stream-video-android-ui-compose 5.86 MB 5.86 MB 0.00 MB 🟢

@rahul-lohra rahul-lohra changed the title [AND-568] Add an option to make a direct call in E2E testing flavor Add an option to make a direct call in E2E testing flavor Jul 2, 2025
@rahul-lohra rahul-lohra removed the pr:improvement Enhances an existing feature or code label Jul 2, 2025

@testableapple testableapple left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great for me! ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:demo-app Changes specific to demo app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants