Skip to content

[SDK-115] Re-enable BCIT embedded message test#1064

Open
franco-zalamena-iterable wants to merge 1 commit into
SDK-115-bcit-cifrom
SDK-115-followup-embedded-test
Open

[SDK-115] Re-enable BCIT embedded message test#1064
franco-zalamena-iterable wants to merge 1 commit into
SDK-115-bcit-cifrom
SDK-115-followup-embedded-test

Conversation

@franco-zalamena-iterable
Copy link
Copy Markdown
Contributor

Summary

Re-enables EmbeddedMessageIntegrationTest#testEmbeddedMessageMVP which the parent SDK-115 PR @Ignore'd while the diagnosis was outstanding.

Three pieces, all of them pulling Android into shape with iOS:

  1. iOS-style dated test user (YYYY-MM-DD-integration-test-user@test.com). New TestUserEmailGenerator (with 4 unit tests) and the BaseIntegrationTest.testUserEmail companion property pick the dated email when the workflow passes ci=true, otherwise fall back to the BuildConfig.ITERABLE_TEST_USER_EMAIL secret. Avoids state accumulating on a long-lived shared user.
  2. Test user email override on MainActivity — text field + Save / Clear, persisted to SharedPreferences. Lets a developer point the SDK at any user without rebuilding. Also unit-tested. Resolution order: override → CI dated → BuildConfig.
  3. Two real bugs in the embedded test, surfaced by running with the dated user:
    • The BCIT campaign's audience predicate is on membershipLevel == \"premium\", not isPremium == true. Android was sending the wrong field, so the audience never matched and /api/embedded-messaging/messages returned placements: []. iOS sends membershipLevel: \"premium\" / \"standard\" (EmbeddedMessageTestViewModel.swift:90); we now do the same from both the test and the on-screen toggle.
    • The deeplink button on placement 2157 fires openUrl with tester://testview, but IterableConfig.allowedProtocols defaults to [], so the SDK silently dropped the URL. iOS configures [\"tester\", \"https\", \"http\"]. Now Android does too, in BaseIntegrationTest.

Local verification

CI mode, dated user 2026-06-02-integration-test-user@test.com, full non-push suite:

$ ./gradlew :integration-tests:connectedDebugAndroidTest \\
    -Pandroid.testInstrumentationRunnerArguments.package=com.iterable.integration.tests \\
    -Pandroid.testInstrumentationRunnerArguments.notClass=com.iterable.integration.tests.PushNotificationIntegrationTest \\
    -Pandroid.testInstrumentationRunnerArguments.ci=true
Tests 7/7 completed. (0 skipped) (0 failed)
BUILD SUCCESSFUL

Plus 8 unit tests (TestUserEmailGenerator ×4, TestUserEmailOverride ×4) all green via :integration-tests:testDebugUnitTest.

Push test is filtered out here because it lives on the stacked PR #1062.

Test plan

  • CI's Integration Tests (BCIT) job runs and is green for InApp + Deeplink + Embedded.
  • Manual sanity: launch the app, set override to today's dated email, open Embedded Message Test, toggle premium on, tap Sync — placement 2157 should appear.
  • Merge into SDK-115-bcit-ci after review; PR [SDK-115] BCIT push test on CI #1062 (push tests) rebases onto the result.

🤖 Generated with Claude Code

franco-zalamena-iterable added a commit that referenced this pull request Jun 2, 2026
CI run on PR #1064 surfaced four failures that all share the same root
cause: the Pixel Launcher ANRs on Ubuntu+KVM during heavy parallel work
and steals focus from the activity-under-test, so findObject().exists()
returns false even though the view is in the tree (logcat shows
`current package: android` instead of `com.iterable.integration.tests`).

Three fixes:

1. BaseIntegrationTest.setUp now pressBack/pressHome to dismiss any
   lingering system dialog before the test runs. Universal CI-emulator
   hardening; benefits every test class that extends BaseIntegrationTest.
2. EmbeddedMessageIntegrationTest + DeepLinkIntegrationTest now use
   findObject().waitForExists(5000) instead of bare .exists().
   ActivityScenario reports RESUMED before the view tree is fully
   rendered; waitForExists handles the race. Same pattern as
   PushNotificationIntegrationTest already uses.
3. activity_main.xml is now wrapped in a ScrollView so the Test Scenario
   buttons stay reachable even when the override card grows.

Local verification: `Tests 7/7 completed. (0 skipped) (0 failed)` for
the full non-push suite with `ci=true`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
franco-zalamena-iterable added a commit that referenced this pull request Jun 2, 2026
CI run on PR #1064 surfaced four failures that all share the same root
cause: the Pixel Launcher ANRs on Ubuntu+KVM during heavy parallel work
and steals focus from the activity-under-test, so findObject().exists()
returns false even though the view is in the tree (logcat shows
`current package: android` instead of `com.iterable.integration.tests`).

Three fixes:

1. BaseIntegrationTest.setUp now pressBack/pressHome to dismiss any
   lingering system dialog before the test runs. Universal CI-emulator
   hardening; benefits every test class that extends BaseIntegrationTest.
2. EmbeddedMessageIntegrationTest + DeepLinkIntegrationTest now use
   findObject().waitForExists(5000) instead of bare .exists().
   ActivityScenario reports RESUMED before the view tree is fully
   rendered; waitForExists handles the race. Same pattern as
   PushNotificationIntegrationTest already uses.
3. activity_main.xml is now wrapped in a ScrollView so the Test Scenario
   buttons stay reachable even when the override card grows.

Local verification: `Tests 7/7 completed. (0 skipped) (0 failed)` for
the full non-push suite with `ci=true`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…:// URLs

Two missing pieces vs the iOS BCIT embedded test:

1. The BCIT campaign's audience predicate is on `membershipLevel == "premium"`,
   not on `isPremium == true`. Android was sending the wrong field, so the
   audience never matched and /api/embedded-messaging/messages returned
   `placements: []`. iOS sends `membershipLevel: "premium" / "standard"`
   (see EmbeddedMessageTestViewModel.swift:90); this commit does the same
   from both the test and the on-screen toggle.
2. The deeplink button on placement 2157 fires `openUrl` with
   `tester://testview`. The Iterable SDK drops URLs whose scheme isn't in
   IterableConfig.allowedProtocols. iOS configures
   `["tester", "https", "http"]`; Android did not, so the SDK silently
   dropped the URL and the URL handler never fired. Add the same allowed
   protocols in BaseIntegrationTest.

Removed the @ignore on testEmbeddedMessageMVP. Renamed the
isPremium-themed toggle / labels in EmbeddedMessageTestActivity to
membership-level wording for parity.

Local verification (CI mode, dated user, full non-push suite):
  Tests 7/7 completed. (0 skipped) (0 failed)
  BUILD SUCCESSFUL

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@franco-zalamena-iterable franco-zalamena-iterable force-pushed the SDK-115-followup-embedded-test branch from 34a515e to e46e63a Compare June 2, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant