-
Notifications
You must be signed in to change notification settings - Fork 318
e2e: Port the iOS push notification tests #6574
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
Merged
andremion
merged 4 commits into
develop
from
andrerego/and-1311-port-the-ios-push-notification-e2e-tests
Jul 17, 2026
+337
−4
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4b4a722
e2e: Port the iOS push notification tests
andremion d21ff14
e2e: Wait the full window for absent push and recover the shade betwe…
andremion 7fef832
e2e: Send the push platform param to the mock server
andremion 716f71c
Document the degraded-payload push test helper
andremion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...droidTestE2eDebug/kotlin/io/getstream/chat/android/compose/robots/UserRobotPushAsserts.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Copyright (c) 2014-2026 Stream.io Inc. All rights reserved. | ||
| * | ||
| * Licensed under the Stream License; | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.getstream.chat.android.compose.robots | ||
|
|
||
| import androidx.test.uiautomator.By | ||
| import io.getstream.chat.android.e2e.test.uiautomator.device | ||
| import io.getstream.chat.android.e2e.test.uiautomator.waitDisplayed | ||
| import org.junit.Assert.assertFalse | ||
| import org.junit.Assert.assertTrue | ||
|
|
||
| /** | ||
| * Opens the notification shade and asserts a notification with [text] is shown. | ||
| * The shade stays open so the notification can be tapped next. | ||
| */ | ||
| fun UserRobot.assertPushNotification(text: String): UserRobot { | ||
| openNotificationShade() | ||
| assertTrue(By.text(text).waitDisplayed()) | ||
| return this | ||
| } | ||
|
|
||
| /** | ||
| * Opens the notification shade, asserts no notification with [text] appears within the | ||
| * delivery window, and closes it. Polls for the full timeout so the assertion cannot pass | ||
| * before the push has had time to be delivered and rendered. | ||
| */ | ||
| fun UserRobot.assertPushNotificationDoesNotAppear(text: String): UserRobot { | ||
| openNotificationShade() | ||
| assertFalse(By.text(text).waitDisplayed()) | ||
| device.pressBack() | ||
| return this | ||
| } | ||
182 changes: 182 additions & 0 deletions
182
...droidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/PushNotificationTests.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| /* | ||
| * Copyright (c) 2014-2026 Stream.io Inc. All rights reserved. | ||
| * | ||
| * Licensed under the Stream License; | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.getstream.chat.android.compose.tests | ||
|
|
||
| import io.getstream.chat.android.compose.robots.assertMessage | ||
| import io.getstream.chat.android.compose.robots.assertPushNotification | ||
| import io.getstream.chat.android.compose.robots.assertPushNotificationDoesNotAppear | ||
| import io.getstream.chat.android.compose.sample.ui.InitTestActivity | ||
| import io.getstream.chat.android.e2e.test.uiautomator.device | ||
| import io.getstream.chat.android.e2e.test.uiautomator.goToBackground | ||
| import io.getstream.chat.android.e2e.test.uiautomator.goToForeground | ||
| import io.getstream.chat.android.e2e.test.uiautomator.packageName | ||
| import io.qameta.allure.kotlin.Allure.step | ||
| import io.qameta.allure.kotlin.AllureId | ||
| import org.junit.Test | ||
|
|
||
| class PushNotificationTests : StreamTestCase() { | ||
|
|
||
| override fun initTestActivity() = InitTestActivity.UserLogin | ||
|
|
||
| private val pushMessage = "Push test message" | ||
| private val pushReceiverComponent get() = "$packageName/$PUSH_RECEIVER_CLASS" | ||
|
|
||
| @AllureId("5715") | ||
| @Test | ||
| fun test_pushNotificationFromMessageList() { | ||
| step("GIVEN user opens the channel") { | ||
| userRobot.login().openChannel() | ||
| } | ||
| step("AND user goes to background") { | ||
| device.goToBackground() | ||
| } | ||
| step("WHEN participant sends a message and its push notification") { | ||
| participantRobot | ||
| .sendMessage(pushMessage) | ||
| .sendPushNotification(pushReceiverComponent) | ||
| } | ||
| step("THEN user receives the push notification") { | ||
| userRobot.assertPushNotification(pushMessage) | ||
| } | ||
| step("WHEN user taps on the push notification") { | ||
| userRobot.tapOnPushNotification(pushMessage) | ||
| } | ||
| step("THEN the message list shows the message") { | ||
| userRobot.assertMessage(pushMessage) | ||
| } | ||
| } | ||
|
|
||
| @AllureId("5832") | ||
| @Test | ||
| fun test_pushNotificationFromChannelList() { | ||
| step("GIVEN user opens the channel and goes back to the channel list") { | ||
| userRobot.login().openChannel().tapOnBackButton() | ||
| } | ||
| step("AND user goes to background") { | ||
| device.goToBackground() | ||
| } | ||
| step("WHEN participant sends a message and its push notification") { | ||
| participantRobot | ||
| .sendMessage(pushMessage) | ||
| .sendPushNotification(pushReceiverComponent) | ||
| } | ||
| step("THEN user receives the push notification") { | ||
| userRobot.assertPushNotification(pushMessage) | ||
| } | ||
| step("WHEN user taps on the push notification") { | ||
| userRobot.tapOnPushNotification(pushMessage) | ||
| } | ||
| step("THEN the message list shows the message") { | ||
| userRobot.assertMessage(pushMessage) | ||
| } | ||
| } | ||
|
|
||
| @AllureId("5662") | ||
| @Test | ||
| fun test_pushNotification_optionalValuesEqualToNil() { | ||
| assertPushNotificationWithDegradedPayload(rest = "null") | ||
| } | ||
|
|
||
| @AllureId("5834") | ||
| @Test | ||
| fun test_pushNotification_optionalValuesAreEmpty() { | ||
| assertPushNotificationWithDegradedPayload(rest = "empty") | ||
| } | ||
|
|
||
| @AllureId("5835") | ||
| @Test | ||
| fun test_pushNotification_optionalValuesContainIncorrectType() { | ||
| assertPushNotificationWithDegradedPayload(rest = "incorrect_type") | ||
| } | ||
|
|
||
| @AllureId("5836") | ||
| @Test | ||
| fun test_pushNotification_optionalValuesContainIncorrectData() { | ||
| assertPushNotificationWithDegradedPayload(rest = "incorrect_data") | ||
| } | ||
|
|
||
| @AllureId("5837") | ||
| @Test | ||
| fun test_pushNotification_requiredValuesAreInvalid() { | ||
| step("GIVEN user opens the channel") { | ||
| userRobot.login().openChannel() | ||
| } | ||
| step("AND user goes to background") { | ||
| device.goToBackground() | ||
| } | ||
| listOf("invalid_version", "invalid_sender", "invalid_type").forEach { rest -> | ||
| step("WHEN participant sends a push notification with $rest in the payload") { | ||
| participantRobot | ||
| .sendMessage(rest) | ||
| .sendPushNotification(pushReceiverComponent, rest = rest) | ||
| } | ||
| step("THEN user does not receive a push notification") { | ||
| userRobot.assertPushNotificationDoesNotAppear(rest) | ||
| } | ||
| } | ||
| step("WHEN user comes back to foreground") { | ||
| device.goToForeground() | ||
| } | ||
| step("THEN the message list shows all messages") { | ||
| userRobot | ||
| .assertMessage("invalid_version") | ||
| .assertMessage("invalid_sender") | ||
| .assertMessage("invalid_type") | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Verifies a push notification is still delivered and opens the message when the payload's | ||
| * optional values are degraded but its required keys stay valid. | ||
| * | ||
| * [rest] selects how the mock server degrades the payload: | ||
| * - `null`: omits the optional title and body | ||
| * - `empty`: sends an empty title and body | ||
| * - `incorrect_type`: sends a wrong-type title and junk badge fields | ||
| * - `incorrect_data`: sends out-of-range badge fields | ||
| * | ||
| * In all of these the required keys (`version`, `sender`, `type`, `message_id`, `cid`) stay | ||
| * valid, so the client accepts the push, shows it, and opens the message on tap. Payloads that | ||
| * break a required key are covered by [test_pushNotification_requiredValuesAreInvalid]. | ||
| * | ||
| * @param rest The mock server's payload-degradation mode. | ||
| */ | ||
| private fun assertPushNotificationWithDegradedPayload(rest: String) { | ||
|
VelikovPetar marked this conversation as resolved.
|
||
| step("GIVEN user opens the channel") { | ||
| userRobot.login().openChannel() | ||
| } | ||
| step("AND user goes to background") { | ||
| device.goToBackground() | ||
| } | ||
| step("WHEN participant sends a message and a push notification with $rest optional values") { | ||
| participantRobot | ||
| .sendMessage(pushMessage) | ||
| .sendPushNotification(pushReceiverComponent, rest = rest) | ||
| } | ||
| step("THEN user receives the push notification") { | ||
| userRobot.assertPushNotification(pushMessage) | ||
| } | ||
| step("WHEN user taps on the push notification") { | ||
| userRobot.tapOnPushNotification(pushMessage) | ||
| } | ||
| step("THEN the message list shows the message") { | ||
| userRobot.assertMessage(pushMessage) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private const val PUSH_RECEIVER_CLASS = "io.getstream.chat.android.compose.sample.push.PushTestReceiver" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ose-sample/src/e2e/java/io/getstream/chat/android/compose/sample/push/PushTestReceiver.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * Copyright (c) 2014-2026 Stream.io Inc. All rights reserved. | ||
| * | ||
| * Licensed under the Stream License; | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.getstream.chat.android.compose.sample.push | ||
|
|
||
| import android.content.BroadcastReceiver | ||
| import android.content.Context | ||
| import android.content.Intent | ||
| import com.google.firebase.messaging.RemoteMessage | ||
| import io.getstream.android.push.firebase.FirebaseMessagingDelegate | ||
|
|
||
| /** | ||
| * Feeds a push payload into the production push pipeline during E2E tests. The mock server | ||
| * delivers the payload as an adb broadcast; every string extra becomes an entry of the | ||
| * [RemoteMessage] data map, which then goes through the same validation and rendering path | ||
| * as a real FCM message. | ||
| */ | ||
| internal class PushTestReceiver : BroadcastReceiver() { | ||
|
|
||
| override fun onReceive(context: Context, intent: Intent) { | ||
| val extras = intent.extras ?: return | ||
| val data = extras.keySet() | ||
| .mapNotNull { key -> extras.getString(key)?.let { value -> key to value } } | ||
| .toMap() | ||
| FirebaseMessagingDelegate.handleRemoteMessage(RemoteMessage.Builder(SENDER).setData(data).build()) | ||
| } | ||
|
|
||
| private companion object { | ||
| private const val SENDER = "test@fcm.googleapis.com" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.