feat(health-sdk): Add smoke UI test case for Health SDK and Bank app …#893
feat(health-sdk): Add smoke UI test case for Health SDK and Bank app …#893saranyanataraja wants to merge 1 commit intomainfrom
Conversation
…integration - from invoices list HEAL-143
|
|
|
|
|
|
|
|
There was a problem hiding this comment.
Pull request overview
This PR introduces an end-to-end UI smoke test flow for the Health SDK example app, including cross-app verification against the Bank SDK example app using a hybrid Espresso + UiAutomator approach.
Changes:
- Added a new
SmokeTestHealthinstrumented test that drives the “invoice list → payment review → launch bank app → return” flow. - Introduced Page Object Model (POM) page classes (
MainScreen,InvoicesScreen,PaymentReviewScreen,BankScreen) plus centralizedTestData. - Updated build configuration to include needed Android test dependencies and to install the Bank SDK example app before connected UI tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/uitest/SmokeTestHealth.kt | New smoke test orchestrating the full cross-app payment flow |
| health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/testdata/TestData.kt | Centralized constants for invoice/bank/app package test data |
| health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/pages/PaymentReviewScreen.kt | POM interactions/assertions for payment review and pay actions |
| health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/pages/MainScreen.kt | POM interaction to enter invoices list flow |
| health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/pages/InvoicesScreen.kt | POM interactions for loading invoices and selecting an invoice to pay |
| health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/pages/BankScreen.kt | UiAutomator-based verification and return flow inside the bank app |
| health-sdk/example-app/build.gradle.kts | Adds test deps + installs bank app prior to connectedAndroidTest |
| gradle/libs.versions.toml | Adds Espresso contrib dependency entry |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Tap "Continue to overview" button | ||
| onView(withText("Continue to overview")) |
| /** | ||
| * Taps the "Pay" button on the payment overview screen to launch the bank app. | ||
| * The button is identified by [net.gini.android.internal.payment.R.id.gps_pay_button]. | ||
| */ | ||
| fun tapPayButton(): PaymentReviewScreen { | ||
| onView( | ||
| allOf( | ||
| withId(net.gini.android.internal.payment.R.id.payment), |
| override fun perform(uiController: UiController, view: View) { | ||
| val recyclerView = view as RecyclerView | ||
| val adapter = recyclerView.adapter | ||
| ?: throw PerformException.Builder() | ||
| .withActionDescription(description) | ||
| .withViewDescription("RecyclerView has no adapter") | ||
| .build() | ||
|
|
||
| // Find the adapter position of the item matching recipientName | ||
| var targetPosition = -1 | ||
| for (pos in 0 until adapter.itemCount) { | ||
| recyclerView.post { | ||
| (recyclerView.layoutManager as? LinearLayoutManager) | ||
| ?.scrollToPositionWithOffset(pos, 0) | ||
| } | ||
| uiController.loopMainThreadUntilIdle() | ||
| Thread.sleep(100) | ||
| uiController.loopMainThreadUntilIdle() |
| device.wait( | ||
| Until.hasObject(By.pkg(TestData.AppPackages.BANK_SDK_EXAMPLE_APP).depth(0)), | ||
| LAUNCH_TIMEOUT_MS | ||
| ) |
| device.findObject( | ||
| By.res(TestData.AppPackages.BANK_SDK_EXAMPLE_APP, "resolve_payment") | ||
| )?.click() | ||
|
|
||
| // Wait for "Return to Business" button — confirms payment was processed | ||
| device.wait( | ||
| Until.findObject( | ||
| By.res(TestData.AppPackages.BANK_SDK_EXAMPLE_APP, "return_to_payment_initiator_app") | ||
| ), | ||
| FIELD_TIMEOUT_MS | ||
| ) | ||
|
|
||
| // Tap it — triggers deep-link back to Health app | ||
| device.findObject( | ||
| By.res(TestData.AppPackages.BANK_SDK_EXAMPLE_APP, "return_to_payment_initiator_app") | ||
| )?.click() | ||
|
|
||
| // Wait for the Health app to return to the foreground — Espresso takes over from here | ||
| device.wait( | ||
| Until.hasObject(By.pkg(TestData.AppPackages.HEALTH_SDK_EXAMPLE_APP).depth(0)), | ||
| LAUNCH_TIMEOUT_MS | ||
| ) |
| val actualIban = device | ||
| .findObject(By.res(TestData.AppPackages.BANK_SDK_EXAMPLE_APP, "iban")) | ||
| ?.text ?: "" | ||
| println("✅ Bank App IBAN: $actualIban") | ||
| assertEquals("IBAN mismatch in bank app", expectedIban, actualIban) | ||
|
|
||
| // Verify Amount | ||
| val actualAmount = device | ||
| .findObject(By.res(TestData.AppPackages.BANK_SDK_EXAMPLE_APP, "amount")) | ||
| ?.text ?: "" | ||
| println("✅ Bank App Amount: $actualAmount") | ||
| assertEquals("Amount mismatch in bank app", expectedAmount, actualAmount) | ||
|
|
||
| // Verify Purpose | ||
| val actualPurpose = device | ||
| .findObject(By.res(TestData.AppPackages.BANK_SDK_EXAMPLE_APP, "purpose")) | ||
| ?.text ?: "" |
| /** Expected extracted amount on the payment review screen. */ | ||
| const val AMOUNT = "18,23" | ||
| const val AMOUNT1 = "18.23" |
MozhganPeivandianSharbaf
left a comment
There was a problem hiding this comment.
Thank you @saranyanataraja 💯 , Please resolve copilet comments and remove emojis from code.







This pull request introduces a comprehensive suite for UI test automation in the Health SDK example app, focusing on end-to-end payment flows involving both the Health and Bank example apps. The changes enable robust cross-app testing by integrating UiAutomator and Espresso, establishing Page Object Models for key screens, and automating the installation of the Bank app before tests run.
UI test infrastructure and automation:
MainScreen,InvoicesScreen,PaymentReviewScreen, andBankScreento encapsulate UI interactions and assertions for each screen, supporting hybrid Espresso + UiAutomator flows. (health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/pages/MainScreen.kt,InvoicesScreen.kt,PaymentReviewScreen.kt,BankScreen.kt) [1] [2] [3] [4]TestDataobject for all test constants and expected values, improving maintainability and clarity across test cases. (health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/testdata/TestData.kt)Cross-app test support and dependencies:
health-sdk/example-app/build.gradle.kts)androidx.test.espresso.contribandandroidx.test.uiautomatordependencies to support advanced UI interactions and cross-app automation. (gradle/libs.versions.toml,health-sdk/example-app/build.gradle.kts) [1] [2]…integration - from invoices listHEAL-143