From 9a45f72adf9d4d7160520c1de1e34e7f8288e373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jc=20Mi=C3=B1arro?= Date: Tue, 20 Dec 2022 10:28:38 +0100 Subject: [PATCH 1/2] core: Add Huawei and Xiaomi PushProviders --- .../lib/src/core/api/device_api.dart | 6 +++ .../test/src/core/api/device_api_test.dart | 39 ++++++++++++------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/packages/stream_chat/lib/src/core/api/device_api.dart b/packages/stream_chat/lib/src/core/api/device_api.dart index cc0a1952..25a678dd 100644 --- a/packages/stream_chat/lib/src/core/api/device_api.dart +++ b/packages/stream_chat/lib/src/core/api/device_api.dart @@ -6,6 +6,12 @@ enum PushProvider { /// Send notifications using Google's Firebase Cloud Messaging firebase, + /// Send notifications using Huawei's Push Kit + huawei, + + /// Send notifications using Xiaomi's Mi Push Service + xiaomi, + /// Send notifications using Apple's Push Notification service apn, } diff --git a/packages/stream_chat/test/src/core/api/device_api_test.dart b/packages/stream_chat/test/src/core/api/device_api_test.dart index 13cfe4dc..4e04da6b 100644 --- a/packages/stream_chat/test/src/core/api/device_api_test.dart +++ b/packages/stream_chat/test/src/core/api/device_api_test.dart @@ -22,26 +22,37 @@ void main() { test('addDevice should work', () async { const deviceId = 'test-device-id'; - const pushProvider = PushProvider.firebase; - + const pushProvidersMap = { + 'apn': PushProvider.apn, + 'firebase': PushProvider.firebase, + 'huawei': PushProvider.huawei, + 'xiaomi': PushProvider.xiaomi, + }; const path = '/devices'; - when(() => client.post( - path, - data: { - 'id': deviceId, - 'push_provider': pushProvider.name, - }, - )) - .thenAnswer( - (_) async => successResponse(path, data: {})); + for (final pushProviderMapEntry in pushProvidersMap.entries) { + final data = { + 'id': deviceId, + 'push_provider': pushProviderMapEntry.key, + }; + when(() { + return client.post( + path, + data: data, + ); + }).thenAnswer( + (_) async => successResponse(path, data: {})); - final res = await deviceApi.addDevice(deviceId, pushProvider); + final res = + await deviceApi.addDevice(deviceId, pushProviderMapEntry.value); - expect(res, isNotNull); + expect(res, isNotNull); - verify(() => client.post(path, data: any(named: 'data'))).called(1); + verify(() => client.post(path, data: data)).called(1); + } verifyNoMoreInteractions(client); + expect(pushProvidersMap.length, PushProvider.values.length, + reason: 'All PushProvider should be tested'); }); test('addDevice should work with pushProviderName', () async { From 38cea12d3f831c85fa974a912aa5ec8bcc1415b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jc=20Mi=C3=B1arro?= Date: Tue, 20 Dec 2022 16:17:52 +0100 Subject: [PATCH 2/2] Update CHANGELOG --- packages/stream_chat/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 2937a2c9..e6d011f1 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -1,3 +1,9 @@ +## Upcomming + +✅ Added + +- Added `Huawei` and `Xiaomi` PushProviders. + ## 5.1.0 ✅ Added