From 2b80611cd3f6fe70ad06fed4b4916445b90413aa Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 17 Jun 2021 12:52:48 +0530 Subject: [PATCH 01/11] fix tests Signed-off-by: Sahil Kumar --- .../test/src/back_button_test.dart | 3 +- .../test/src/channel_header_test.dart | 4 ++ .../src/goldens/deleted_message_custom.png | Bin 2936 -> 2334 bytes .../test/src/goldens/deleted_message_dark.png | Bin 2785 -> 2262 bytes .../src/goldens/deleted_message_light.png | Bin 2750 -> 2161 bytes .../test/src/goldens/reaction_bubble_2.png | Bin 2920 -> 2937 bytes .../test/src/goldens/system_message_dark.png | Bin 1812 -> 1679 bytes .../test/src/goldens/system_message_light.png | Bin 1866 -> 1746 bytes .../test/src/message_action_modal_test.dart | 18 +++----- .../test/src/thread_header_test.dart | 1 + .../test/message_list_core_test.dart | 4 +- .../test/stream_channel_test.dart | 40 +++++++++++++----- .../test/stream_chat_core_test.dart | 26 ++++++------ 13 files changed, 59 insertions(+), 37 deletions(-) diff --git a/packages/stream_chat_flutter/test/src/back_button_test.dart b/packages/stream_chat_flutter/test/src/back_button_test.dart index 3fae1ace..efb889ac 100644 --- a/packages/stream_chat_flutter/test/src/back_button_test.dart +++ b/packages/stream_chat_flutter/test/src/back_button_test.dart @@ -118,8 +118,9 @@ void main() { final clientState = MockClientState(); when(() => client.state).thenReturn(clientState); + when(() => clientState.totalUnreadCount).thenAnswer((_) => 0); when(() => clientState.totalUnreadCountStream) - .thenAnswer((i) => Stream.value(0)); + .thenAnswer((_) => Stream.value(0)); await tester.pumpWidget( MaterialApp( diff --git a/packages/stream_chat_flutter/test/src/channel_header_test.dart b/packages/stream_chat_flutter/test/src/channel_header_test.dart index 9f6e981d..87f3d028 100644 --- a/packages/stream_chat_flutter/test/src/channel_header_test.dart +++ b/packages/stream_chat_flutter/test/src/channel_header_test.dart @@ -34,6 +34,7 @@ void main() { .thenAnswer((_) => Stream.value(ConnectionStatus.connected)); when(() => channelState.unreadCountStream) .thenAnswer((i) => Stream.value(1)); + when(() => clientState.totalUnreadCount).thenAnswer((i) => 1); when(() => clientState.totalUnreadCountStream) .thenAnswer((i) => Stream.value(1)); when(() => channelState.membersStream).thenAnswer((i) => Stream.value([ @@ -109,6 +110,7 @@ void main() { .thenAnswer((_) => Stream.value(ConnectionStatus.disconnected)); when(() => client.wsConnectionStatus) .thenReturn(ConnectionStatus.disconnected); + when(() => clientState.totalUnreadCount).thenAnswer((i) => 1); when(() => clientState.totalUnreadCountStream) .thenAnswer((i) => Stream.value(1)); @@ -171,6 +173,7 @@ void main() { ]); when(() => client.wsConnectionStatusStream) .thenAnswer((_) => Stream.value(ConnectionStatus.connecting)); + when(() => clientState.totalUnreadCount).thenAnswer((i) => 1); when(() => clientState.totalUnreadCountStream) .thenAnswer((i) => Stream.value(1)); @@ -375,6 +378,7 @@ void main() { ]); when(() => client.wsConnectionStatusStream) .thenAnswer((_) => Stream.value(ConnectionStatus.connecting)); + when(() => clientState.totalUnreadCount).thenAnswer((i) => 1); when(() => clientState.totalUnreadCountStream) .thenAnswer((i) => Stream.value(1)); diff --git a/packages/stream_chat_flutter/test/src/goldens/deleted_message_custom.png b/packages/stream_chat_flutter/test/src/goldens/deleted_message_custom.png index c464bc01de48fcef06c538bd284ed284370f55aa..693db3c78ee724f41d6376bd5c7ba1eb1385750d 100644 GIT binary patch delta 1816 zcmV+z2j}?s7M>E2Kz|6xNkl`t918 zW=r}^wyN@nb8~`9;(r3==Ah7?x7$?0|NsZ9Uax+;9%TC zktE#9kTCG-`LqHE}wSQVVIy#DV46z2%Xf)zHJo>=y?ryBdk1ddslM`;p(behc zsZLH#Vmp3pfdoMi*P+p8;+!i4f}VFL0|EL0fdB>qxkZ+jmsPD+yY3eRffg1P)ND3y zU{u#1S1-CXfh;U6XmN4z%56aqXmN4zx7%-vot+)!a=EVi`MxjboPW~k^bL&a`s3$&(ntwA8uq^z3A2i629OU zmkqw}YinyunM|f{U!?2!lS%LU{v#D~qEa_~C)NZ#mJw4s^+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il*yn<>r( zK1j&(Ex*6$PQ#NC@|?Z+d-e1?V4buxoU$(&K)oUntG3qR^y$;v`R8yrAm`1d?Nc`^ zVD;}4NvB}M8o=BX0sGD=i0ORBH;gpHCdL?Nt zFE4qupE|fUzup*N2_Tv4saN^mD_lnli=Q8W7!bE(u%K6xuyQ>%76s`gFK2<7$38Q4 zL1VEjfdJv*<;8ja+!=*J0q%>QyEC>?B9VkEHc}847Gc1IARhKlZ h$U5GC0pAKv z4-*p;<;L15EYl^oH9Thj_h-*O6$Oz!wmIeJ=S?D&!PzAxK481cqK19J`T+_?jn;C# z93aJH%bvSZsq__yPgd4f#JISyxHvR8jjS_EO6SJb3wkQo=0-_*=8X1M@zNjv`fMya z_baXO-Y$tuhH`iR?b(KGe$O0Kt(a!2-)mG#Sov@y@bi{9mjp*{rv!c=M$UXyS}Fw+ zw~16y^x}m}!;juH8V%ZpCKk(pTeA-8=;#2#1Ox^3EiS%{m6Y=N?-EBqfB`-tl9F&> z^KYqU%k&iCmHbelR6bm_&BpidADXjH%J28B>Lg)I1W`ZykX9YUOW9O}_V)Dr#o@H$ z>UzrC=n;Aq!vh01e(ZTjm;3knE&8fxlAsX8|Mr4_V(WT=sTgb1zI$R z2bGre6_XanE6IHo39#v{l2gnMskE0Potg0t4Q1uzWa2~5=4|; zfu{IF&0O+OYW;R8V@uXJ*TC?P(K%6l{cT@%Hh|jlSi`OwmAtCc?lVJX1j}zBVQ58o ztia9!fzVOqFbz8dSS=ZPw^d6=a+BcP&}Qw4Y)#8G7*?!LBod<>?AvY+s_t`A!RxsL z!qBmN&@CE;qH#i^FCeri%>_VMbLC~qRu1hYp?q_=x_i@d2GFV2M1%TiQ5w=T5d)5n zO;y^~lW{278;_q=R!=?3GD!%aJ Goqqs9Ee-zw diff --git a/packages/stream_chat_flutter/test/src/goldens/deleted_message_dark.png b/packages/stream_chat_flutter/test/src/goldens/deleted_message_dark.png index 7db0a6ef17a3f5586f9a0f7d67b1f49dd6fd5b60..d9bb3138bf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st9b^Unw-?_J9m_JUAeBS<%bU?Nu^RrDaX;&jnj%YBQ zRyLcJB>nT+HC3xs6^ca-rqdc48q#n!t6Ht5>vMA|7K`TCcBLXGnbcr9t<2G*+ANjS z+uN&^Tu!U2tJ>Pyl9Nm-nMi0TlWEVO_d(N%eiVQ9j@91^smns9-RtN~QA35Adx0d)>KSuUCGbPutI3 z#jI_&Ti4IkXf))JexLtoLnl4|P2X?tU6|iuED#9j&*#o*C709Vl@+-I14=oLzP)<& znK-1^3uDjTJ58?~H}>y!=ho}>X_t;!+ith6Zu3_BsL4TAsZ{jC+?>LpkftUl<@fvb zkMF;4JqO@m``una-lV1F<<{pV=q_AA00V&l1_A*L1OgZc1TYW?VCd-Ey!CoRQg{BY zGTxjXZ|DA_jgAG<lY3<4pEcg2j7wZA{WE|0l%51RqPmgaR2}S07*qoM6N<$ Ef*kF!`v3p{ diff --git a/packages/stream_chat_flutter/test/src/goldens/deleted_message_light.png b/packages/stream_chat_flutter/test/src/goldens/deleted_message_light.png index d5a453ffc0cf157efe7d6a8e84648ab9a4a90530..1f6330eb9bd92be6130bae15872bfe6d51878d88 100644 GIT binary patch delta 1615 zcmV-V2C(_Q74Z;|Kz|4uNklLx2g!BEI-42W6ODdH5(ESyy6gwnH+%rXA?#h&NE7<+wo zGSkdGleuQ@iLnpjIQ}I7SNhMm2LRk<1OgZc1TYW?U?32{K$E@+>61_a2Rx?6wc(SK z6ZLw%acv$GB$Y~Oetv!|+a6mWQ55O;_*l-laSZ_zAdX}G`t|G23q+EfbDEu<9p?}L z6VH=j0UCez$j6T#)oeCLt{2C#Ha0dChT$!Y>gMCRi|$Pz8yg$i+}yl!SscgO+}yl& z`F(MCc&L0nKXSbw2;`hoCX=~^QQdr8chS8FBnSdYXCcIKd}+Dod5Ys$3kwUkJ+xah zI0m^~?ndk0^jLVFrw<=K+{(D_qI(m_;0?bxZ3usYKzn<8%4V|@`zGDQ@0|2O5Zw4! z{LZ@n>$vWsv3^UO&$k3|@Us@Ln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R!N* client.state).thenReturn(clientState); when(() => clientState.user).thenReturn(OwnUser(id: 'user-id')); - when(() => client.flagMessage(any())).thenThrow(ApiError( - '{}', - 500, - )); + when(() => client.flagMessage(any())) + .thenThrow(StreamChatNetworkError(ChatErrorCode.internalSystemError)); final themeData = ThemeData(); final streamTheme = StreamChatThemeData.fromTheme(themeData); @@ -609,10 +607,8 @@ void main() { when(() => client.state).thenReturn(clientState); when(() => clientState.user).thenReturn(OwnUser(id: 'user-id')); - when(() => client.flagMessage(any())).thenThrow(ApiError( - '{"code":4}', - 400, - )); + when(() => client.flagMessage(any())) + .thenThrow(StreamChatNetworkError(ChatErrorCode.inputError)); final themeData = ThemeData(); final streamTheme = StreamChatThemeData.fromTheme(themeData); @@ -719,10 +715,8 @@ void main() { when(() => client.state).thenReturn(clientState); when(() => clientState.user).thenReturn(OwnUser(id: 'user-id')); - when(() => channel.deleteMessage(any())).thenThrow(ApiError( - '{}', - 500, - )); + when(() => channel.deleteMessage(any())) + .thenThrow(StreamChatNetworkError(ChatErrorCode.internalSystemError)); final themeData = ThemeData(); final streamTheme = StreamChatThemeData.fromTheme(themeData); diff --git a/packages/stream_chat_flutter/test/src/thread_header_test.dart b/packages/stream_chat_flutter/test/src/thread_header_test.dart index 578b2ad6..2b649be3 100644 --- a/packages/stream_chat_flutter/test/src/thread_header_test.dart +++ b/packages/stream_chat_flutter/test/src/thread_header_test.dart @@ -45,6 +45,7 @@ void main() { ]); when(() => client.wsConnectionStatusStream) .thenAnswer((_) => Stream.value(ConnectionStatus.connecting)); + when(() => clientState.totalUnreadCount).thenAnswer((i) => 1); when(() => clientState.totalUnreadCountStream) .thenAnswer((i) => Stream.value(1)); diff --git a/packages/stream_chat_flutter_core/test/message_list_core_test.dart b/packages/stream_chat_flutter_core/test/message_list_core_test.dart index 4e34f8f2..98e83f9f 100644 --- a/packages/stream_chat_flutter_core/test/message_list_core_test.dart +++ b/packages/stream_chat_flutter_core/test/message_list_core_test.dart @@ -300,7 +300,9 @@ void main() { when(() => mockChannel.state.isUpToDate).thenReturn(false); when(() => mockChannel.initialized).thenAnswer((_) async => true); when(() => mockChannel.query( - options: any(named: 'options'), + state: any(named: 'state'), + watch: any(named: 'watch'), + presence: any(named: 'presence'), membersPagination: any(named: 'membersPagination'), messagesPagination: any(named: 'messagesPagination'), preferOffline: any(named: 'preferOffline'), diff --git a/packages/stream_chat_flutter_core/test/stream_channel_test.dart b/packages/stream_chat_flutter_core/test/stream_channel_test.dart index b48c02b1..2b32cf2d 100644 --- a/packages/stream_chat_flutter_core/test/stream_channel_test.dart +++ b/packages/stream_chat_flutter_core/test/stream_channel_test.dart @@ -165,7 +165,9 @@ void main() { when(() => mockChannel.initialized).thenAnswer((_) async => true); final messages = _generateMessages(); when(() => mockChannel.query( - options: any(named: 'options'), + state: any(named: 'state'), + watch: any(named: 'watch'), + presence: any(named: 'presence'), messagesPagination: any(named: 'messagesPagination'), membersPagination: any(named: 'membersPagination'), watchersPagination: any(named: 'watchersPagination'), @@ -183,7 +185,9 @@ void main() { verify(() => mockChannel.initialized).called(1); verify(() => mockChannel.query( - options: any(named: 'options'), + state: any(named: 'state'), + watch: any(named: 'watch'), + presence: any(named: 'presence'), messagesPagination: any(named: 'messagesPagination'), membersPagination: any(named: 'membersPagination'), watchersPagination: any(named: 'watchersPagination'), @@ -228,7 +232,9 @@ void main() { final messages = _generateMessages(); when(() => mockChannel.query( - options: any(named: 'options'), + state: any(named: 'state'), + watch: any(named: 'watch'), + presence: any(named: 'presence'), messagesPagination: beforePagination, membersPagination: any(named: 'membersPagination'), watchersPagination: any(named: 'watchersPagination'), @@ -236,7 +242,9 @@ void main() { )).thenAnswer((_) async => ChannelState(messages: messages)); when(() => mockChannel.query( - options: any(named: 'options'), + state: any(named: 'state'), + watch: any(named: 'watch'), + presence: any(named: 'presence'), messagesPagination: afterPagination, membersPagination: any(named: 'membersPagination'), watchersPagination: any(named: 'watchersPagination'), @@ -259,7 +267,9 @@ void main() { await tester.pumpAndSettle(); verify(() => mockChannel.query( - options: any(named: 'options'), + state: any(named: 'state'), + watch: any(named: 'watch'), + presence: any(named: 'presence'), messagesPagination: beforePagination, membersPagination: any(named: 'membersPagination'), watchersPagination: any(named: 'watchersPagination'), @@ -267,7 +277,9 @@ void main() { )).called(1); verify(() => mockChannel.query( - options: any(named: 'options'), + state: any(named: 'state'), + watch: any(named: 'watch'), + presence: any(named: 'presence'), messagesPagination: afterPagination, membersPagination: any(named: 'membersPagination'), watchersPagination: any(named: 'watchersPagination'), @@ -285,7 +297,9 @@ void main() { ); when(() => mockChannel.query( - options: any(named: 'options'), + state: any(named: 'state'), + watch: any(named: 'watch'), + presence: any(named: 'presence'), messagesPagination: updatedBeforePagination, membersPagination: any(named: 'membersPagination'), watchersPagination: any(named: 'watchersPagination'), @@ -293,7 +307,9 @@ void main() { )).thenAnswer((_) async => ChannelState(messages: messages)); when(() => mockChannel.query( - options: any(named: 'options'), + state: any(named: 'state'), + watch: any(named: 'watch'), + presence: any(named: 'presence'), messagesPagination: updatedAfterPagination, membersPagination: any(named: 'membersPagination'), watchersPagination: any(named: 'watchersPagination'), @@ -303,7 +319,9 @@ void main() { await tester.pumpAndSettle(); verify(() => mockChannel.query( - options: any(named: 'options'), + state: any(named: 'state'), + watch: any(named: 'watch'), + presence: any(named: 'presence'), messagesPagination: updatedBeforePagination, membersPagination: any(named: 'membersPagination'), watchersPagination: any(named: 'watchersPagination'), @@ -311,7 +329,9 @@ void main() { )).called(1); verify(() => mockChannel.query( - options: any(named: 'options'), + state: any(named: 'state'), + watch: any(named: 'watch'), + presence: any(named: 'presence'), messagesPagination: updatedAfterPagination, membersPagination: any(named: 'membersPagination'), watchersPagination: any(named: 'watchersPagination'), diff --git a/packages/stream_chat_flutter_core/test/stream_chat_core_test.dart b/packages/stream_chat_flutter_core/test/stream_chat_core_test.dart index 168454c8..f2b1b514 100644 --- a/packages/stream_chat_flutter_core/test/stream_chat_core_test.dart +++ b/packages/stream_chat_flutter_core/test/stream_chat_core_test.dart @@ -227,7 +227,7 @@ void main() { ); testWidgets( - 'didChangeAppLifecycleState should not call client.connect() ' + 'didChangeAppLifecycleState should not call client.openConnection() ' 'if connection is not available in case the ' 'widget lifestyle changes to AppLifecycleState.resume', (tester) async { @@ -238,8 +238,8 @@ void main() { final event = Event(); when(() => mockClient.on()).thenAnswer((_) => Stream.value(event)); - when(() => mockClient.connect()).thenAnswer((_) async => event); - when(() => mockClient.disconnect()).thenAnswer((_) async => null); + when(() => mockClient.openConnection()).thenAnswer((_) async => event); + when(() => mockClient.closeConnection()).thenAnswer((_) async => null); when(() => mockClient.wsConnectionStatus) .thenReturn(ConnectionStatus.disconnected); @@ -267,7 +267,7 @@ void main() { streamChatCoreState .didChangeAppLifecycleState(AppLifecycleState.resumed); - verifyNever(() => mockClient.connect()); + verifyNever(() => mockClient.openConnection()); }); }, ); @@ -327,8 +327,8 @@ void main() { final event = Event(); when(() => mockClient.on()).thenAnswer((_) => Stream.value(event)); - when(() => mockClient.connect()).thenAnswer((_) async => event); - when(() => mockClient.disconnect()).thenAnswer((_) async => null); + when(() => mockClient.openConnection()).thenAnswer((_) async => event); + when(() => mockClient.closeConnection()).thenAnswer((_) async => null); when(() => mockClient.wsConnectionStatus) .thenReturn(ConnectionStatus.disconnected); @@ -348,7 +348,7 @@ void main() { await Future.delayed(const Duration(seconds: 1)); - verify(() => mockClient.connect()).called(1); + verify(() => mockClient.openConnection()).called(1); }); }, ); @@ -376,8 +376,8 @@ void main() { final event = Event(); when(() => mockClient.on()).thenAnswer((_) => Stream.value(event)); - when(() => mockClient.connect()).thenAnswer((_) async => event); - when(mockClient.disconnect).thenAnswer((_) async => null); + when(() => mockClient.openConnection()).thenAnswer((_) async => event); + when(() => mockClient.closeConnection()).thenAnswer((_) async => null); when(() => mockClient.wsConnectionStatus) .thenReturn(ConnectionStatus.connected); @@ -385,7 +385,7 @@ void main() { await Future.delayed(const Duration(seconds: 1)); - verify(() => mockClient.disconnect()).called(1); + verify(() => mockClient.closeConnection()).called(1); }); }, ); @@ -402,8 +402,8 @@ void main() { final event = Event(); when(() => mockClient.on()).thenAnswer((_) => Stream.value(event)); - when(() => mockClient.connect()).thenAnswer((_) async => event); - when(() => mockClient.disconnect()).thenAnswer((_) async => null); + when(() => mockClient.openConnection()).thenAnswer((_) async => event); + when(() => mockClient.closeConnection()).thenAnswer((_) async => null); when(() => mockClient.wsConnectionStatus) .thenReturn(ConnectionStatus.disconnected); @@ -432,7 +432,7 @@ void main() { await Future.delayed(const Duration(seconds: 1)); - verifyNever(() => mockClient.disconnect()); + verifyNever(() => mockClient.closeConnection()); }); }, ); From 2d6cc796e86e0b6ee2b19ce05ff03edf8a6ecc53 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 16 Jun 2021 12:27:21 +0200 Subject: [PATCH 02/11] move jsons to fixtures --- .../stream_chat/lib/src/core/error/error.dart | 2 +- .../lib/src/core/models/channel_model.dart | 3 +- .../lib/src/core/models/own_user.dart | 11 +- .../stream_chat/lib/src/core/models/user.dart | 4 +- .../stream_chat/test/fixtures/action.json | 7 + .../stream_chat/test/fixtures/attachment.json | 29 + .../stream_chat/test/fixtures/channel.json | 7 + .../test/fixtures/channel_state.json | 832 +++++++++++ .../test/fixtures/channel_state_to_json.json | 418 ++++++ .../stream_chat/test/fixtures/command.json | 5 + .../stream_chat/test/fixtures/device.json | 4 + packages/stream_chat/test/fixtures/event.json | 29 + .../stream_chat/test/fixtures/member.json | 15 + .../stream_chat/test/fixtures/message.json | 65 + .../test/fixtures/message_to_json.json | 29 + .../stream_chat/test/fixtures/reaction.json | 18 + packages/stream_chat/test/fixtures/read.json | 7 + packages/stream_chat/test/fixtures/user.json | 4 + .../test/src/core/models/action_test.dart | 17 +- .../test/src/core/models/attachment_test.dart | 37 +- .../src/core/models/channel_state_test.dart | 1263 +---------------- .../test/src/core/models/channel_test.dart | 16 +- .../test/src/core/models/command_test.dart | 14 +- .../test/src/core/models/device_test.dart | 14 +- .../test/src/core/models/event_test.dart | 38 +- .../test/src/core/models/member_test.dart | 26 +- .../test/src/core/models/message_test.dart | 105 +- .../test/src/core/models/reaction_test.dart | 27 +- .../test/src/core/models/read_test.dart | 18 +- .../test/src/core/models/user_test.dart | 13 +- packages/stream_chat/test/src/utils.dart | 8 + .../lib/src/db/moor_chat_database.g.dart | 4 +- 32 files changed, 1530 insertions(+), 1559 deletions(-) create mode 100644 packages/stream_chat/test/fixtures/action.json create mode 100644 packages/stream_chat/test/fixtures/attachment.json create mode 100644 packages/stream_chat/test/fixtures/channel.json create mode 100644 packages/stream_chat/test/fixtures/channel_state.json create mode 100644 packages/stream_chat/test/fixtures/channel_state_to_json.json create mode 100644 packages/stream_chat/test/fixtures/command.json create mode 100644 packages/stream_chat/test/fixtures/device.json create mode 100644 packages/stream_chat/test/fixtures/event.json create mode 100644 packages/stream_chat/test/fixtures/member.json create mode 100644 packages/stream_chat/test/fixtures/message.json create mode 100644 packages/stream_chat/test/fixtures/message_to_json.json create mode 100644 packages/stream_chat/test/fixtures/reaction.json create mode 100644 packages/stream_chat/test/fixtures/read.json create mode 100644 packages/stream_chat/test/fixtures/user.json diff --git a/packages/stream_chat/lib/src/core/error/error.dart b/packages/stream_chat/lib/src/core/error/error.dart index 6f2c39a3..ac4a1e0d 100644 --- a/packages/stream_chat/lib/src/core/error/error.dart +++ b/packages/stream_chat/lib/src/core/error/error.dart @@ -1,2 +1,2 @@ export 'chat_error_code.dart'; -export 'stream_chat_error.dart'; \ No newline at end of file +export 'stream_chat_error.dart'; diff --git a/packages/stream_chat/lib/src/core/models/channel_model.dart b/packages/stream_chat/lib/src/core/models/channel_model.dart index 74195c71..37e587ff 100644 --- a/packages/stream_chat/lib/src/core/models/channel_model.dart +++ b/packages/stream_chat/lib/src/core/models/channel_model.dart @@ -78,8 +78,7 @@ class ChannelModel { final DateTime? deletedAt; /// The count of this channel members - @JsonKey( - includeIfNull: false, toJson: Serializer.readOnly, defaultValue: 0) + @JsonKey(includeIfNull: false, toJson: Serializer.readOnly, defaultValue: 0) final int memberCount; /// Map of custom channel extraData diff --git a/packages/stream_chat/lib/src/core/models/own_user.dart b/packages/stream_chat/lib/src/core/models/own_user.dart index 70529687..22705b05 100644 --- a/packages/stream_chat/lib/src/core/models/own_user.dart +++ b/packages/stream_chat/lib/src/core/models/own_user.dart @@ -61,21 +61,16 @@ class OwnUser extends User { /// List of users muted by the user @JsonKey( - includeIfNull: false, - toJson: Serializer.readOnly, - defaultValue: []) + includeIfNull: false, toJson: Serializer.readOnly, defaultValue: []) final List mutes; /// List of users muted by the user @JsonKey( - includeIfNull: false, - toJson: Serializer.readOnly, - defaultValue: []) + includeIfNull: false, toJson: Serializer.readOnly, defaultValue: []) final List channelMutes; /// Total unread messages by the user - @JsonKey( - includeIfNull: false, toJson: Serializer.readOnly, defaultValue: 0) + @JsonKey(includeIfNull: false, toJson: Serializer.readOnly, defaultValue: 0) final int totalUnreadCount; /// Total unread channels by the user diff --git a/packages/stream_chat/lib/src/core/models/user.dart b/packages/stream_chat/lib/src/core/models/user.dart index de58055d..c2960af9 100644 --- a/packages/stream_chat/lib/src/core/models/user.dart +++ b/packages/stream_chat/lib/src/core/models/user.dart @@ -22,8 +22,8 @@ class User extends Equatable { updatedAt = updatedAt ?? DateTime.now(); /// Create a new instance from a json - factory User.fromJson(Map json) => _$UserFromJson( - Serializer.moveToExtraDataFromRoot(json, topLevelFields)); + factory User.fromJson(Map json) => + _$UserFromJson(Serializer.moveToExtraDataFromRoot(json, topLevelFields)); /// Known top level fields. /// Useful for [Serializer] methods. diff --git a/packages/stream_chat/test/fixtures/action.json b/packages/stream_chat/test/fixtures/action.json new file mode 100644 index 00000000..59da5684 --- /dev/null +++ b/packages/stream_chat/test/fixtures/action.json @@ -0,0 +1,7 @@ +{ + "name": "name", + "style": "style", + "text": "text", + "type": "type", + "value": "value" +} \ No newline at end of file diff --git a/packages/stream_chat/test/fixtures/attachment.json b/packages/stream_chat/test/fixtures/attachment.json new file mode 100644 index 00000000..faf38b90 --- /dev/null +++ b/packages/stream_chat/test/fixtures/attachment.json @@ -0,0 +1,29 @@ +{ + "type": "giphy", + "title": "awesome", + "title_link": "https://giphy.com/gifs/nrkp3-dance-happy-3o7TKnCdBx5cMg0qti", + "thumb_url": "https://media0.giphy.com/media/3o7TKnCdBx5cMg0qti/giphy.gif", + "actions": [ + { + "name": "image_action", + "text": "Send", + "style": "primary", + "type": "button", + "value": "send" + }, + { + "name": "image_action", + "text": "Shuffle", + "style": "default", + "type": "button", + "value": "shuffle" + }, + { + "name": "image_action", + "text": "Cancel", + "style": "default", + "type": "button", + "value": "cancel" + } + ] +} \ No newline at end of file diff --git a/packages/stream_chat/test/fixtures/channel.json b/packages/stream_chat/test/fixtures/channel.json new file mode 100644 index 00000000..2184cd6e --- /dev/null +++ b/packages/stream_chat/test/fixtures/channel.json @@ -0,0 +1,7 @@ +{ + "id": "test", + "type": "livestream", + "cid": "livestream:test", + "cats": true, + "fruit": ["bananas", "apples"] +} \ No newline at end of file diff --git a/packages/stream_chat/test/fixtures/channel_state.json b/packages/stream_chat/test/fixtures/channel_state.json new file mode 100644 index 00000000..1e6af605 --- /dev/null +++ b/packages/stream_chat/test/fixtures/channel_state.json @@ -0,0 +1,832 @@ + +{ + "channel": { + "id": "dev", + "type": "team", + "cid": "team:dev", + "last_message_at": "2020-01-30T13:43:41.062362Z", + "created_at": "2019-04-03T18:43:33.213373Z", + "updated_at": "2019-04-03T18:43:33.213374Z", + "team": "test", + "created_by": { + "id": "guido", + "role": "user", + "created_at": "2019-04-03T18:43:33.201036Z", + "updated_at": "2019-04-03T18:43:33.204713Z", + "banned": false, + "online": false, + "name": "Guido" + }, + "frozen": true, + "config": { + "created_at": "2019-11-07T22:29:26.776526Z", + "updated_at": "2019-11-07T22:29:48.286746Z", + "name": "team", + "typing_events": true, + "read_events": true, + "connect_events": true, + "search": true, + "reactions": true, + "replies": true, + "mutes": true, + "uploads": true, + "url_enrichment": true, + "message_retention": "infinite", + "max_message_length": 5000, + "automod": "disabled", + "automod_behavior": "flag", + "commands": [ + { + "name": "giphy", + "description": "Post a random gif to the channel", + "args": "[text]", + "set": "fun_set" + } + ] + }, + "name": "#dev", + "image": "https://cdn.chrisshort.net/testing-certificate-chains-in-go/GOPHER_MIC_DROP.png", + "example": 1 + }, + "messages": [ + { + "id": "dry-meadow-0-2b73cc8b-cd86-4a01-8d40-bd82ad07a030", + "text": "fasdfa", + "type": "regular", + "status": "SENT", + "silent": false, + "user": { + "id": "dry-meadow-0", + "role": "user", + "created_at": "2019-03-27T17:40:17.155892Z", + "updated_at": "2020-01-29T03:22:47.641589Z", + "last_active": "2020-01-29T03:22:47.63613Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Dry+meadow", + "name": "Dry meadow" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T03:23:02.843948Z", + "updated_at": "2020-01-29T03:23:02.843949Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-e8e74482-b4cd-48db-9d1e-30e6c191786f", + "text": "test message", + "type": "regular", + "user": { + "id": "dry-meadow-0", + "role": "user", + "created_at": "2019-03-27T17:40:17.155892Z", + "updated_at": "2020-01-29T03:22:47.641589Z", + "last_active": "2020-01-29T03:22:47.63613Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Dry+meadow", + "name": "Dry meadow" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T03:23:07.981091Z", + "updated_at": "2020-01-29T03:23:07.981091Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-53e6299f-9b97-4a9c-a27e-7e2dde49b7e0", + "text": "test message", + "type": "regular", + "user": { + "id": "dry-meadow-0", + "role": "user", + "created_at": "2019-03-27T17:40:17.155892Z", + "updated_at": "2020-01-29T03:22:47.641589Z", + "last_active": "2020-01-29T03:22:47.63613Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Dry+meadow", + "name": "Dry meadow" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T03:23:11.568022Z", + "updated_at": "2020-01-29T03:23:11.568022Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-80925be0-786e-40a5-b225-486518dafd35", + "text": "asdfadf", + "type": "regular", + "user": { + "id": "dry-meadow-0", + "role": "user", + "created_at": "2019-03-27T17:40:17.155892Z", + "updated_at": "2020-01-29T03:22:47.641589Z", + "last_active": "2020-01-29T03:22:47.63613Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Dry+meadow", + "name": "Dry meadow" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T03:32:57.403566Z", + "updated_at": "2020-01-29T03:32:57.403566Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-64d7970f-ede8-4b31-9738-1bc1756d2bfe", + "text": "test", + "type": "regular", + "user": { + "id": "dry-meadow-0", + "role": "user", + "created_at": "2019-03-27T17:40:17.155892Z", + "updated_at": "2020-01-29T03:22:47.641589Z", + "last_active": "2020-01-29T03:22:47.63613Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Dry+meadow", + "name": "Dry meadow" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T03:33:35.294802Z", + "updated_at": "2020-01-29T03:33:35.294802Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "withered-cell-0-84cbd760-cf55-4f7e-9207-c5f66cccc6dc", + "text": "hi", + "type": "regular", + "user": { + "id": "withered-cell-0", + "role": "user", + "created_at": "2020-01-29T03:34:01.698106Z", + "updated_at": "2020-01-29T03:34:01.708808Z", + "last_active": "2020-01-29T03:34:01.70353Z", + "banned": false, + "online": false, + "name": "Withered cell", + "image": "https://getstream.io/random_svg/?name=Withered+cell" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T03:34:27.393296Z", + "updated_at": "2020-01-29T03:34:27.393296Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-e9203588-43c3-40b1-91f7-f217fc42aa53", + "text": "fantastic", + "type": "regular", + "user": { + "id": "dry-meadow-0", + "role": "user", + "created_at": "2019-03-27T17:40:17.155892Z", + "updated_at": "2020-01-29T03:22:47.641589Z", + "last_active": "2020-01-29T03:22:47.63613Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Dry+meadow", + "name": "Dry meadow" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T03:34:37.638376Z", + "updated_at": "2020-01-29T03:34:37.638376Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "withered-cell-0-7e3552d7-7a0d-45f2-a856-e91b23a7e240", + "text": "nice to meet you", + "type": "regular", + "user": { + "id": "withered-cell-0", + "role": "user", + "created_at": "2020-01-29T03:34:01.698106Z", + "updated_at": "2020-01-29T03:34:01.708808Z", + "last_active": "2020-01-29T03:34:01.70353Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Withered+cell", + "name": "Withered cell" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T03:35:04.301566Z", + "updated_at": "2020-01-29T03:35:04.301566Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-1ffeafd4-e4fc-4c84-9394-9d7cb10fff42", + "text": "hey", + "type": "regular", + "user": { + "id": "dry-meadow-0", + "role": "user", + "created_at": "2019-03-27T17:40:17.155892Z", + "updated_at": "2020-01-29T03:22:47.641589Z", + "last_active": "2020-01-29T03:22:47.63613Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Dry+meadow", + "name": "Dry meadow" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T03:35:24.939084Z", + "updated_at": "2020-01-29T03:35:24.939085Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-3f147324-12c8-4b41-9fb5-2db88d065efa", + "text": "hello, everyone", + "type": "regular", + "user": { + "id": "dry-meadow-0", + "role": "user", + "created_at": "2019-03-27T17:40:17.155892Z", + "updated_at": "2020-01-29T03:22:47.641589Z", + "last_active": "2020-01-29T03:22:47.63613Z", + "banned": false, + "online": false, + "name": "Dry meadow", + "image": "https://getstream.io/random_svg/?name=Dry+meadow" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T03:35:33.101566Z", + "updated_at": "2020-01-29T03:35:33.101566Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-51a348ae-0c0a-44de-a556-eac7891c0cf0", + "text": "who is there?", + "type": "regular", + "user": { + "id": "dry-meadow-0", + "role": "user", + "created_at": "2019-03-27T17:40:17.155892Z", + "updated_at": "2020-01-29T03:22:47.641589Z", + "last_active": "2020-01-29T03:22:47.63613Z", + "banned": false, + "online": false, + "name": "Dry meadow", + "image": "https://getstream.io/random_svg/?name=Dry+meadow" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T03:35:45.458685Z", + "updated_at": "2020-01-29T03:35:45.458685Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "icy-recipe-7-a29e237b-8d81-4a97-9bc8-d42bca3f1356", + "text": "하이", + "type": "regular", + "user": { + "id": "icy-recipe-7", + "role": "user", + "created_at": "2020-01-21T11:36:22.284503Z", + "updated_at": "2020-01-29T07:01:59.69882Z", + "last_active": "2020-01-29T07:01:59.693378Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Icy+recipe", + "name": "Icy recipe" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T07:02:11.535395Z", + "updated_at": "2020-01-29T07:02:11.535395Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "icy-recipe-7-935c396e-ddf8-4a9a-951c-0a12fa5bf055", + "text": "what are you doing?", + "type": "regular", + "user": { + "id": "icy-recipe-7", + "role": "user", + "created_at": "2020-01-21T11:36:22.284503Z", + "updated_at": "2020-01-29T07:01:59.69882Z", + "last_active": "2020-01-29T07:01:59.693378Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Icy+recipe", + "name": "Icy recipe" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T07:02:22.485136Z", + "updated_at": "2020-01-29T07:02:22.485136Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "throbbing-boat-5-1e4d5730-5ff0-4d25-9948-9f34ffda43e4", + "text": "👍", + "type": "regular", + "user": { + "id": "throbbing-boat-5", + "role": "user", + "created_at": "2019-07-30T06:29:53.060413Z", + "updated_at": "2020-01-29T14:11:27.80176Z", + "last_active": "2020-01-29T14:11:27.7963Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Throbbing+boat", + "name": "Throbbing boat" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T14:12:04.688552Z", + "updated_at": "2020-01-29T14:12:04.688552Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "snowy-credit-3-3e0c1a0d-d22f-42ee-b2a1-f9f49477bf21", + "text": "sdasas", + "type": "regular", + "user": { + "id": "snowy-credit-3", + "role": "user", + "created_at": "2020-01-29T15:29:03.693312Z", + "updated_at": "2020-01-29T15:29:03.702648Z", + "last_active": "2020-01-29T15:29:03.696144Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Snowy+credit", + "name": "Snowy credit" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T15:29:36.011315Z", + "updated_at": "2020-01-29T15:29:36.011316Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "snowy-credit-3-3319537e-2d0e-4876-8170-a54f046e4b7d", + "text": "cjshsa", + "type": "regular", + "user": { + "id": "snowy-credit-3", + "role": "user", + "created_at": "2020-01-29T15:29:03.693312Z", + "updated_at": "2020-01-29T15:29:03.702648Z", + "last_active": "2020-01-29T15:29:03.696144Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Snowy+credit", + "name": "Snowy credit" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T15:29:41.677819Z", + "updated_at": "2020-01-29T15:29:41.677819Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "snowy-credit-3-cfaf0b46-1daa-49c5-947c-b16d6697487d", + "text": "nhisagdhsadz", + "type": "regular", + "user": { + "id": "snowy-credit-3", + "role": "user", + "created_at": "2020-01-29T15:29:03.693312Z", + "updated_at": "2020-01-29T15:29:03.702648Z", + "last_active": "2020-01-29T15:29:03.696144Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Snowy+credit", + "name": "Snowy credit" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T15:29:43.354177Z", + "updated_at": "2020-01-29T15:29:43.354177Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "snowy-credit-3-cebe25a7-a3a3-49fc-9919-91c6725e81f3", + "text": "hvadhsahzd", + "type": "regular", + "user": { + "id": "snowy-credit-3", + "role": "user", + "created_at": "2020-01-29T15:29:03.693312Z", + "updated_at": "2020-01-29T15:29:03.702648Z", + "last_active": "2020-01-29T15:29:03.696144Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Snowy+credit", + "name": "Snowy credit" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T15:29:44.754713Z", + "updated_at": "2020-01-29T15:29:44.754713Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "divine-glade-9-0cea9262-5766-48e9-8b22-311870aed3bf", + "text": "hello", + "type": "regular", + "user": { + "id": "divine-glade-9", + "role": "user", + "created_at": "2020-01-29T17:02:18.312524Z", + "updated_at": "2020-01-29T17:02:18.320187Z", + "last_active": "2020-01-29T17:02:18.315074Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Divine+glade", + "name": "Divine glade" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T17:02:36.933852Z", + "updated_at": "2020-01-29T17:02:36.933852Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "red-firefly-9-c4e9007b-bb7d-4238-ae08-5f8e3cd03d73", + "text": "hello", + "type": "regular", + "user": { + "id": "red-firefly-9", + "role": "user", + "created_at": "2019-08-02T18:56:39.366516Z", + "updated_at": "2020-01-29T22:13:50.491769Z", + "last_active": "2020-01-29T22:13:50.450215Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Red+firefly", + "name": "Red firefly" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-29T22:14:08.54062Z", + "updated_at": "2020-01-29T22:14:08.54062Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "bitter-glade-2-02aee4eb-4093-4736-808b-2de75820e854", + "text": "hello", + "type": "regular", + "user": { + "id": "bitter-glade-2", + "role": "user", + "created_at": "2020-01-30T13:08:56.190678Z", + "updated_at": "2020-01-30T13:08:56.200333Z", + "last_active": "2020-01-30T13:08:56.193882Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Bitter+glade", + "name": "Bitter glade" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-30T13:11:37.191293Z", + "updated_at": "2020-01-30T13:11:37.191293Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "morning-sea-1-0c700bcb-46dd-4224-b590-e77bdbccc480", + "text": "http://jaeger.ui.gtstrm.com/", + "type": "regular", + "user": { + "id": "morning-sea-1", + "role": "user", + "created_at": "2019-07-22T09:19:07.505207Z", + "updated_at": "2020-01-30T13:33:05.831856Z", + "last_active": "2020-01-30T13:33:05.825369Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Morning+sea", + "name": "Morning sea" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-30T13:33:16.853116Z", + "updated_at": "2020-01-30T13:33:16.853116Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "ancient-salad-0-53e8b4e6-5b7b-43ad-aeee-8bfb6a9ed0be", + "text": "hi", + "type": "regular", + "user": { + "id": "ancient-salad-0", + "role": "user", + "created_at": "2020-01-30T13:34:29.286813Z", + "updated_at": "2020-01-30T13:34:29.296196Z", + "last_active": "2020-01-30T13:34:29.289964Z", + "banned": false, + "online": true, + "image": "https://getstream.io/random_svg/?name=Ancient+salad", + "name": "Ancient salad" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-30T13:36:52.749731Z", + "updated_at": "2020-01-30T13:36:52.749732Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "ancient-salad-0-8c225075-bd4c-42e2-8024-530aae13cd40", + "text": "hi", + "type": "regular", + "user": { + "id": "ancient-salad-0", + "role": "user", + "created_at": "2020-01-30T13:34:29.286813Z", + "updated_at": "2020-01-30T13:34:29.296196Z", + "last_active": "2020-01-30T13:34:29.289964Z", + "banned": false, + "online": true, + "image": "https://getstream.io/random_svg/?name=Ancient+salad", + "name": "Ancient salad" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-30T13:37:41.631056Z", + "updated_at": "2020-01-30T13:37:41.631056Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "proud-sea-7-17802096-cbf8-4e3c-addd-4ee31f4c8b5c", + "text": "😃", + "type": "regular", + "user": { + "id": "proud-sea-7", + "role": "user", + "created_at": "2020-01-30T13:43:03.903006Z", + "updated_at": "2020-01-30T13:43:03.912307Z", + "last_active": "2020-01-30T13:43:03.906236Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Proud+sea", + "name": "Proud sea" + }, + "attachments": [], + "latest_reactions": [], + "own_reactions": [], + "reaction_counts": {}, + "reaction_scores": {}, + "reply_count": 0, + "created_at": "2020-01-30T13:43:41.062362Z", + "updated_at": "2020-01-30T13:43:41.062362Z", + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + } + ], + "watcher_count": 5, + "members": [] +} \ No newline at end of file diff --git a/packages/stream_chat/test/fixtures/channel_state_to_json.json b/packages/stream_chat/test/fixtures/channel_state_to_json.json new file mode 100644 index 00000000..4b8a0369 --- /dev/null +++ b/packages/stream_chat/test/fixtures/channel_state_to_json.json @@ -0,0 +1,418 @@ + +{ + "channel": { + "id": "dev", + "type": "team", + "frozen": true, + "name": "#dev", + "image": "https://cdn.chrisshort.net/testing-certificate-chains-in-go/GOPHER_MIC_DROP.png", + "example": 1 + }, + "watchers": [], + "read": [], + "messages": [ + { + "id": "dry-meadow-0-2b73cc8b-cd86-4a01-8d40-bd82ad07a030", + "text": "fasdfa", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-e8e74482-b4cd-48db-9d1e-30e6c191786f", + "text": "test message", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-53e6299f-9b97-4a9c-a27e-7e2dde49b7e0", + "text": "test message", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-80925be0-786e-40a5-b225-486518dafd35", + "text": "asdfadf", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-64d7970f-ede8-4b31-9738-1bc1756d2bfe", + "text": "test", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "withered-cell-0-84cbd760-cf55-4f7e-9207-c5f66cccc6dc", + "text": "hi", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-e9203588-43c3-40b1-91f7-f217fc42aa53", + "text": "fantastic", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "withered-cell-0-7e3552d7-7a0d-45f2-a856-e91b23a7e240", + "text": "nice to meet you", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-1ffeafd4-e4fc-4c84-9394-9d7cb10fff42", + "text": "hey", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-3f147324-12c8-4b41-9fb5-2db88d065efa", + "text": "hello, everyone", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "dry-meadow-0-51a348ae-0c0a-44de-a556-eac7891c0cf0", + "text": "who is there?", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "icy-recipe-7-a29e237b-8d81-4a97-9bc8-d42bca3f1356", + "text": "하이", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "icy-recipe-7-935c396e-ddf8-4a9a-951c-0a12fa5bf055", + "text": "what are you doing?", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "throbbing-boat-5-1e4d5730-5ff0-4d25-9948-9f34ffda43e4", + "text": "👍", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "snowy-credit-3-3e0c1a0d-d22f-42ee-b2a1-f9f49477bf21", + "text": "sdasas", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "snowy-credit-3-3319537e-2d0e-4876-8170-a54f046e4b7d", + "text": "cjshsa", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "snowy-credit-3-cfaf0b46-1daa-49c5-947c-b16d6697487d", + "text": "nhisagdhsadz", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "snowy-credit-3-cebe25a7-a3a3-49fc-9919-91c6725e81f3", + "text": "hvadhsahzd", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "divine-glade-9-0cea9262-5766-48e9-8b22-311870aed3bf", + "text": "hello", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "red-firefly-9-c4e9007b-bb7d-4238-ae08-5f8e3cd03d73", + "text": "hello", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "bitter-glade-2-02aee4eb-4093-4736-808b-2de75820e854", + "text": "hello", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "morning-sea-1-0c700bcb-46dd-4224-b590-e77bdbccc480", + "text": "http://jaeger.ui.gtstrm.com/", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "ancient-salad-0-53e8b4e6-5b7b-43ad-aeee-8bfb6a9ed0be", + "text": "hi", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "ancient-salad-0-8c225075-bd4c-42e2-8024-530aae13cd40", + "text": "hi", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + }, + { + "id": "proud-sea-7-17802096-cbf8-4e3c-addd-4ee31f4c8b5c", + "text": "😃", + "attachments": [], + "parent_id": null, + "quoted_message": null, + "quoted_message_id": null, + "show_in_channel": null, + "mentioned_users": [], + "status": "SENT", + "silent": false, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null + } + ], + "pinned_messages": [], + "members": [], + "watcher_count": 5 +} diff --git a/packages/stream_chat/test/fixtures/command.json b/packages/stream_chat/test/fixtures/command.json new file mode 100644 index 00000000..38a169a5 --- /dev/null +++ b/packages/stream_chat/test/fixtures/command.json @@ -0,0 +1,5 @@ +{ + "name": "giphy", + "description": "Post a random gif to the channel", + "args": "[text]" +} \ No newline at end of file diff --git a/packages/stream_chat/test/fixtures/device.json b/packages/stream_chat/test/fixtures/device.json new file mode 100644 index 00000000..4555dc1e --- /dev/null +++ b/packages/stream_chat/test/fixtures/device.json @@ -0,0 +1,4 @@ +{ + "id": "device-id", + "push_provider": "push-provider" +} \ No newline at end of file diff --git a/packages/stream_chat/test/fixtures/event.json b/packages/stream_chat/test/fixtures/event.json new file mode 100644 index 00000000..2568af02 --- /dev/null +++ b/packages/stream_chat/test/fixtures/event.json @@ -0,0 +1,29 @@ +{ + "type": "type", + "cid": "cid", + "connection_id": "connectionId", + "created_at": "2019-04-03T18:43:33.213374Z", + "me": { + "id": "dry-meadow-0", + "role": "user", + "created_at": "2019-03-27T17:40:17.155892Z", + "updated_at": "2020-01-29T03:22:47.641589Z", + "last_active": "2020-01-29T03:22:47.63613Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Dry+meadow", + "name": "Dry meadow" + }, + "parent_id": null, + "user": { + "id": "dry-meadow-0", + "role": "user", + "created_at": "2019-03-27T17:40:17.155892Z", + "updated_at": "2020-01-29T03:22:47.641589Z", + "last_active": "2020-01-29T03:22:47.63613Z", + "banned": false, + "online": false, + "image": "https://getstream.io/random_svg/?name=Dry+meadow", + "name": "Dry meadow" + } +} \ No newline at end of file diff --git a/packages/stream_chat/test/fixtures/member.json b/packages/stream_chat/test/fixtures/member.json new file mode 100644 index 00000000..a33acf13 --- /dev/null +++ b/packages/stream_chat/test/fixtures/member.json @@ -0,0 +1,15 @@ +{ + "user": { + "id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e", + "role": "user", + "created_at": "2020-01-28T22:17:30.826259Z", + "updated_at": "2020-01-28T22:17:31.101222Z", + "banned": false, + "online": false, + "name": "Robin Papa", + "image": "https://pbs.twimg.com/profile_images/669512187778498560/L7wQctBt.jpg" + }, + "role": "member", + "created_at": "2020-01-28T22:17:30.95443Z", + "updated_at": "2020-01-28T22:17:30.95443Z" +} \ No newline at end of file diff --git a/packages/stream_chat/test/fixtures/message.json b/packages/stream_chat/test/fixtures/message.json new file mode 100644 index 00000000..d469639b --- /dev/null +++ b/packages/stream_chat/test/fixtures/message.json @@ -0,0 +1,65 @@ +{ + "id": "4637f7e4-a06b-42db-ba5a-8d8270dd926f", + "text": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA", + "type": "regular", + "silent": false, + "status": "SENT", + "user": { + "id": "c1c9b454-2bcc-402d-8bb0-2f3706ce1680", + "role": "user", + "created_at": "2020-01-28T22:17:30.83015Z", + "updated_at": "2020-01-28T22:17:31.19435Z", + "banned": false, + "online": false, + "image": "https://randomuser.me/api/portraits/women/2.jpg", + "name": "Mia Denys" + }, + "attachments": [ + { + "type": "video", + "author_name": "GIPHY", + "title": "The Lion King Disney GIF - Find \u0026 Share on GIPHY", + "title_link": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif", + "text": "Discover \u0026 share this Lion King Live Action GIF with everyone you know. GIPHY is how you search, share, discover, and create GIFs.", + "image_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif", + "thumb_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif", + "asset_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.mp4", + "og_scrape_url": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA" + } + ], + "latest_reactions": [ + { + "message_id": "4637f7e4-a06b-42db-ba5a-8d8270dd926f", + "user_id": "c1c9b454-2bcc-402d-8bb0-2f3706ce1680", + "user": { + "id": "c1c9b454-2bcc-402d-8bb0-2f3706ce1680", + "role": "user", + "created_at": "2020-01-28T22:17:30.83015Z", + "updated_at": "2020-01-28T22:17:31.19435Z", + "banned": false, + "online": false, + "image": "https://randomuser.me/api/portraits/women/2.jpg", + "name": "Mia Denys" + }, + "type": "love", + "score": 1, + "created_at": "2020-01-28T22:17:31.128376Z", + "updated_at": "2020-01-28T22:17:31.128376Z" + } + ], + "own_reactions": [], + "reaction_counts": { + "love": 1 + }, + "reaction_scores": { + "love": 1 + }, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null, + "reply_count": 0, + "created_at": "2020-01-28T22:17:31.107978Z", + "updated_at": "2020-01-28T22:17:31.130506Z", + "mentioned_users": [] +} \ No newline at end of file diff --git a/packages/stream_chat/test/fixtures/message_to_json.json b/packages/stream_chat/test/fixtures/message_to_json.json new file mode 100644 index 00000000..b3b1dd6b --- /dev/null +++ b/packages/stream_chat/test/fixtures/message_to_json.json @@ -0,0 +1,29 @@ +{ + "id": "4637f7e4-a06b-42db-ba5a-8d8270dd926f", + "text": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA", + "silent": false, + "attachments": [ + { + "type": "video", + "title_link": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif", + "title": "The Lion King Disney GIF - Find & Share on GIPHY", + "thumb_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif", + "text": "Discover & share this Lion King Live Action GIF with everyone you know. GIPHY is how you search, share, discover, and create GIFs.", + "og_scrape_url": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA", + "image_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif", + "author_name": "GIPHY", + "asset_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.mp4", + "actions": [] + } + ], + "mentioned_users": [], + "parent_id": "parentId", + "quoted_message": null, + "quoted_message_id": null, + "pinned": false, + "pinned_at": null, + "pin_expires": null, + "pinned_by": null, + "show_in_channel": true, + "hey": "test" +} \ No newline at end of file diff --git a/packages/stream_chat/test/fixtures/reaction.json b/packages/stream_chat/test/fixtures/reaction.json new file mode 100644 index 00000000..ce87ca1d --- /dev/null +++ b/packages/stream_chat/test/fixtures/reaction.json @@ -0,0 +1,18 @@ +{ + "message_id": "76cd8c82-b557-4e48-9d12-87995d3a0e04", + "user_id": "2de0297c-f3f2-489d-b930-ef77342edccf", + "user": { + "id": "2de0297c-f3f2-489d-b930-ef77342edccf", + "role": "user", + "created_at": "2020-01-28T22:17:30.810011Z", + "updated_at": "2020-01-28T22:17:31.077195Z", + "banned": false, + "online": false, + "image": "https://randomuser.me/api/portraits/women/45.jpg", + "name": "Daisy Morgan" + }, + "type": "wow", + "score": 1, + "created_at": "2020-01-28T22:17:31.108742Z", + "updated_at": "2020-01-28T22:17:31.108742Z" +} \ No newline at end of file diff --git a/packages/stream_chat/test/fixtures/read.json b/packages/stream_chat/test/fixtures/read.json new file mode 100644 index 00000000..7dc596d3 --- /dev/null +++ b/packages/stream_chat/test/fixtures/read.json @@ -0,0 +1,7 @@ +{ + "user": { + "id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e" + }, + "last_read": "2020-01-28T22:17:30.966485504Z", + "unread_messages": 10 +} \ No newline at end of file diff --git a/packages/stream_chat/test/fixtures/user.json b/packages/stream_chat/test/fixtures/user.json new file mode 100644 index 00000000..1fad8ea0 --- /dev/null +++ b/packages/stream_chat/test/fixtures/user.json @@ -0,0 +1,4 @@ +{ + "id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e", + "role": "test-role" +} \ No newline at end of file diff --git a/packages/stream_chat/test/src/core/models/action_test.dart b/packages/stream_chat/test/src/core/models/action_test.dart index d0108948..0cf1c996 100644 --- a/packages/stream_chat/test/src/core/models/action_test.dart +++ b/packages/stream_chat/test/src/core/models/action_test.dart @@ -1,21 +1,12 @@ -import 'dart:convert'; - -import 'package:test/test.dart'; import 'package:stream_chat/src/core/models/action.dart'; +import 'package:test/test.dart'; + +import '../../utils.dart'; void main() { group('src/models/action', () { - const jsonExample = ''' - { - "name": "name", - "style": "style", - "text": "text", - "type": "type", - "value": "value" - }'''; - test('should parse json correctly', () { - final action = Action.fromJson(json.decode(jsonExample)); + final action = Action.fromJson(jsonFixture('action.json')); expect(action.name, 'name'); expect(action.style, 'style'); expect(action.text, 'text'); diff --git a/packages/stream_chat/test/src/core/models/attachment_test.dart b/packages/stream_chat/test/src/core/models/attachment_test.dart index a433bedd..37716656 100644 --- a/packages/stream_chat/test/src/core/models/attachment_test.dart +++ b/packages/stream_chat/test/src/core/models/attachment_test.dart @@ -1,44 +1,13 @@ -import 'dart:convert'; - import 'package:stream_chat/src/core/models/action.dart'; import 'package:stream_chat/src/core/models/attachment.dart'; import 'package:test/test.dart'; +import '../../utils.dart'; + void main() { group('src/models/attachment', () { - const jsonExample = ''' - { - "type": "giphy", - "title": "awesome", - "title_link": "https://giphy.com/gifs/nrkp3-dance-happy-3o7TKnCdBx5cMg0qti", - "thumb_url": "https://media0.giphy.com/media/3o7TKnCdBx5cMg0qti/giphy.gif", - "actions": [ - { - "name": "image_action", - "text": "Send", - "style": "primary", - "type": "button", - "value": "send" - }, - { - "name": "image_action", - "text": "Shuffle", - "style": "default", - "type": "button", - "value": "shuffle" - }, - { - "name": "image_action", - "text": "Cancel", - "style": "default", - "type": "button", - "value": "cancel" - } - ] -}'''; - test('should parse json correctly', () { - final attachment = Attachment.fromJson(json.decode(jsonExample)); + final attachment = Attachment.fromJson(jsonFixture('attachment.json')); expect(attachment.type, 'giphy'); expect(attachment.title, 'awesome'); expect( diff --git a/packages/stream_chat/test/src/core/models/channel_state_test.dart b/packages/stream_chat/test/src/core/models/channel_state_test.dart index ad5245a2..8bd17d46 100644 --- a/packages/stream_chat/test/src/core/models/channel_state_test.dart +++ b/packages/stream_chat/test/src/core/models/channel_state_test.dart @@ -1,5 +1,3 @@ -import 'dart:convert'; - import 'package:stream_chat/src/core/models/channel_config.dart'; import 'package:stream_chat/src/core/models/channel_state.dart'; import 'package:stream_chat/src/core/models/command.dart'; @@ -8,843 +6,13 @@ import 'package:stream_chat/src/core/models/user.dart'; import 'package:stream_chat/stream_chat.dart'; import 'package:test/test.dart'; +import '../../utils.dart'; + void main() { group('src/models/channel_state', () { - const jsonExample = ''' - { - "channel": { - "id": "dev", - "type": "team", - "cid": "team:dev", - "last_message_at": "2020-01-30T13:43:41.062362Z", - "created_at": "2019-04-03T18:43:33.213373Z", - "updated_at": "2019-04-03T18:43:33.213374Z", - "team": "test", - "created_by": { - "id": "guido", - "role": "user", - "created_at": "2019-04-03T18:43:33.201036Z", - "updated_at": "2019-04-03T18:43:33.204713Z", - "banned": false, - "online": false, - "name": "Guido" - }, - "frozen": true, - "config": { - "created_at": "2019-11-07T22:29:26.776526Z", - "updated_at": "2019-11-07T22:29:48.286746Z", - "name": "team", - "typing_events": true, - "read_events": true, - "connect_events": true, - "search": true, - "reactions": true, - "replies": true, - "mutes": true, - "uploads": true, - "url_enrichment": true, - "message_retention": "infinite", - "max_message_length": 5000, - "automod": "disabled", - "automod_behavior": "flag", - "commands": [ - { - "name": "giphy", - "description": "Post a random gif to the channel", - "args": "[text]", - "set": "fun_set" - } - ] - }, - "name": "#dev", - "image": "https://cdn.chrisshort.net/testing-certificate-chains-in-go/GOPHER_MIC_DROP.png", - "example": 1 - }, - "messages": [ - { - "id": "dry-meadow-0-2b73cc8b-cd86-4a01-8d40-bd82ad07a030", - "text": "fasdfa", - "type": "regular", - "status": "SENT", - "silent": false, - "user": { - "id": "dry-meadow-0", - "role": "user", - "created_at": "2019-03-27T17:40:17.155892Z", - "updated_at": "2020-01-29T03:22:47.641589Z", - "last_active": "2020-01-29T03:22:47.63613Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Dry+meadow", - "name": "Dry meadow" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T03:23:02.843948Z", - "updated_at": "2020-01-29T03:23:02.843949Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-e8e74482-b4cd-48db-9d1e-30e6c191786f", - "text": "test message", - "type": "regular", - "user": { - "id": "dry-meadow-0", - "role": "user", - "created_at": "2019-03-27T17:40:17.155892Z", - "updated_at": "2020-01-29T03:22:47.641589Z", - "last_active": "2020-01-29T03:22:47.63613Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Dry+meadow", - "name": "Dry meadow" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T03:23:07.981091Z", - "updated_at": "2020-01-29T03:23:07.981091Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-53e6299f-9b97-4a9c-a27e-7e2dde49b7e0", - "text": "test message", - "type": "regular", - "user": { - "id": "dry-meadow-0", - "role": "user", - "created_at": "2019-03-27T17:40:17.155892Z", - "updated_at": "2020-01-29T03:22:47.641589Z", - "last_active": "2020-01-29T03:22:47.63613Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Dry+meadow", - "name": "Dry meadow" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T03:23:11.568022Z", - "updated_at": "2020-01-29T03:23:11.568022Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-80925be0-786e-40a5-b225-486518dafd35", - "text": "asdfadf", - "type": "regular", - "user": { - "id": "dry-meadow-0", - "role": "user", - "created_at": "2019-03-27T17:40:17.155892Z", - "updated_at": "2020-01-29T03:22:47.641589Z", - "last_active": "2020-01-29T03:22:47.63613Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Dry+meadow", - "name": "Dry meadow" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T03:32:57.403566Z", - "updated_at": "2020-01-29T03:32:57.403566Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-64d7970f-ede8-4b31-9738-1bc1756d2bfe", - "text": "test", - "type": "regular", - "user": { - "id": "dry-meadow-0", - "role": "user", - "created_at": "2019-03-27T17:40:17.155892Z", - "updated_at": "2020-01-29T03:22:47.641589Z", - "last_active": "2020-01-29T03:22:47.63613Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Dry+meadow", - "name": "Dry meadow" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T03:33:35.294802Z", - "updated_at": "2020-01-29T03:33:35.294802Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "withered-cell-0-84cbd760-cf55-4f7e-9207-c5f66cccc6dc", - "text": "hi", - "type": "regular", - "user": { - "id": "withered-cell-0", - "role": "user", - "created_at": "2020-01-29T03:34:01.698106Z", - "updated_at": "2020-01-29T03:34:01.708808Z", - "last_active": "2020-01-29T03:34:01.70353Z", - "banned": false, - "online": false, - "name": "Withered cell", - "image": "https://getstream.io/random_svg/?name=Withered+cell" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T03:34:27.393296Z", - "updated_at": "2020-01-29T03:34:27.393296Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-e9203588-43c3-40b1-91f7-f217fc42aa53", - "text": "fantastic", - "type": "regular", - "user": { - "id": "dry-meadow-0", - "role": "user", - "created_at": "2019-03-27T17:40:17.155892Z", - "updated_at": "2020-01-29T03:22:47.641589Z", - "last_active": "2020-01-29T03:22:47.63613Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Dry+meadow", - "name": "Dry meadow" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T03:34:37.638376Z", - "updated_at": "2020-01-29T03:34:37.638376Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "withered-cell-0-7e3552d7-7a0d-45f2-a856-e91b23a7e240", - "text": "nice to meet you", - "type": "regular", - "user": { - "id": "withered-cell-0", - "role": "user", - "created_at": "2020-01-29T03:34:01.698106Z", - "updated_at": "2020-01-29T03:34:01.708808Z", - "last_active": "2020-01-29T03:34:01.70353Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Withered+cell", - "name": "Withered cell" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T03:35:04.301566Z", - "updated_at": "2020-01-29T03:35:04.301566Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-1ffeafd4-e4fc-4c84-9394-9d7cb10fff42", - "text": "hey", - "type": "regular", - "user": { - "id": "dry-meadow-0", - "role": "user", - "created_at": "2019-03-27T17:40:17.155892Z", - "updated_at": "2020-01-29T03:22:47.641589Z", - "last_active": "2020-01-29T03:22:47.63613Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Dry+meadow", - "name": "Dry meadow" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T03:35:24.939084Z", - "updated_at": "2020-01-29T03:35:24.939085Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-3f147324-12c8-4b41-9fb5-2db88d065efa", - "text": "hello, everyone", - "type": "regular", - "user": { - "id": "dry-meadow-0", - "role": "user", - "created_at": "2019-03-27T17:40:17.155892Z", - "updated_at": "2020-01-29T03:22:47.641589Z", - "last_active": "2020-01-29T03:22:47.63613Z", - "banned": false, - "online": false, - "name": "Dry meadow", - "image": "https://getstream.io/random_svg/?name=Dry+meadow" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T03:35:33.101566Z", - "updated_at": "2020-01-29T03:35:33.101566Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-51a348ae-0c0a-44de-a556-eac7891c0cf0", - "text": "who is there?", - "type": "regular", - "user": { - "id": "dry-meadow-0", - "role": "user", - "created_at": "2019-03-27T17:40:17.155892Z", - "updated_at": "2020-01-29T03:22:47.641589Z", - "last_active": "2020-01-29T03:22:47.63613Z", - "banned": false, - "online": false, - "name": "Dry meadow", - "image": "https://getstream.io/random_svg/?name=Dry+meadow" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T03:35:45.458685Z", - "updated_at": "2020-01-29T03:35:45.458685Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "icy-recipe-7-a29e237b-8d81-4a97-9bc8-d42bca3f1356", - "text": "하이", - "type": "regular", - "user": { - "id": "icy-recipe-7", - "role": "user", - "created_at": "2020-01-21T11:36:22.284503Z", - "updated_at": "2020-01-29T07:01:59.69882Z", - "last_active": "2020-01-29T07:01:59.693378Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Icy+recipe", - "name": "Icy recipe" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T07:02:11.535395Z", - "updated_at": "2020-01-29T07:02:11.535395Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "icy-recipe-7-935c396e-ddf8-4a9a-951c-0a12fa5bf055", - "text": "what are you doing?", - "type": "regular", - "user": { - "id": "icy-recipe-7", - "role": "user", - "created_at": "2020-01-21T11:36:22.284503Z", - "updated_at": "2020-01-29T07:01:59.69882Z", - "last_active": "2020-01-29T07:01:59.693378Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Icy+recipe", - "name": "Icy recipe" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T07:02:22.485136Z", - "updated_at": "2020-01-29T07:02:22.485136Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "throbbing-boat-5-1e4d5730-5ff0-4d25-9948-9f34ffda43e4", - "text": "👍", - "type": "regular", - "user": { - "id": "throbbing-boat-5", - "role": "user", - "created_at": "2019-07-30T06:29:53.060413Z", - "updated_at": "2020-01-29T14:11:27.80176Z", - "last_active": "2020-01-29T14:11:27.7963Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Throbbing+boat", - "name": "Throbbing boat" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T14:12:04.688552Z", - "updated_at": "2020-01-29T14:12:04.688552Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "snowy-credit-3-3e0c1a0d-d22f-42ee-b2a1-f9f49477bf21", - "text": "sdasas", - "type": "regular", - "user": { - "id": "snowy-credit-3", - "role": "user", - "created_at": "2020-01-29T15:29:03.693312Z", - "updated_at": "2020-01-29T15:29:03.702648Z", - "last_active": "2020-01-29T15:29:03.696144Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Snowy+credit", - "name": "Snowy credit" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T15:29:36.011315Z", - "updated_at": "2020-01-29T15:29:36.011316Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "snowy-credit-3-3319537e-2d0e-4876-8170-a54f046e4b7d", - "text": "cjshsa", - "type": "regular", - "user": { - "id": "snowy-credit-3", - "role": "user", - "created_at": "2020-01-29T15:29:03.693312Z", - "updated_at": "2020-01-29T15:29:03.702648Z", - "last_active": "2020-01-29T15:29:03.696144Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Snowy+credit", - "name": "Snowy credit" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T15:29:41.677819Z", - "updated_at": "2020-01-29T15:29:41.677819Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "snowy-credit-3-cfaf0b46-1daa-49c5-947c-b16d6697487d", - "text": "nhisagdhsadz", - "type": "regular", - "user": { - "id": "snowy-credit-3", - "role": "user", - "created_at": "2020-01-29T15:29:03.693312Z", - "updated_at": "2020-01-29T15:29:03.702648Z", - "last_active": "2020-01-29T15:29:03.696144Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Snowy+credit", - "name": "Snowy credit" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T15:29:43.354177Z", - "updated_at": "2020-01-29T15:29:43.354177Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "snowy-credit-3-cebe25a7-a3a3-49fc-9919-91c6725e81f3", - "text": "hvadhsahzd", - "type": "regular", - "user": { - "id": "snowy-credit-3", - "role": "user", - "created_at": "2020-01-29T15:29:03.693312Z", - "updated_at": "2020-01-29T15:29:03.702648Z", - "last_active": "2020-01-29T15:29:03.696144Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Snowy+credit", - "name": "Snowy credit" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T15:29:44.754713Z", - "updated_at": "2020-01-29T15:29:44.754713Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "divine-glade-9-0cea9262-5766-48e9-8b22-311870aed3bf", - "text": "hello", - "type": "regular", - "user": { - "id": "divine-glade-9", - "role": "user", - "created_at": "2020-01-29T17:02:18.312524Z", - "updated_at": "2020-01-29T17:02:18.320187Z", - "last_active": "2020-01-29T17:02:18.315074Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Divine+glade", - "name": "Divine glade" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T17:02:36.933852Z", - "updated_at": "2020-01-29T17:02:36.933852Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "red-firefly-9-c4e9007b-bb7d-4238-ae08-5f8e3cd03d73", - "text": "hello", - "type": "regular", - "user": { - "id": "red-firefly-9", - "role": "user", - "created_at": "2019-08-02T18:56:39.366516Z", - "updated_at": "2020-01-29T22:13:50.491769Z", - "last_active": "2020-01-29T22:13:50.450215Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Red+firefly", - "name": "Red firefly" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-29T22:14:08.54062Z", - "updated_at": "2020-01-29T22:14:08.54062Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "bitter-glade-2-02aee4eb-4093-4736-808b-2de75820e854", - "text": "hello", - "type": "regular", - "user": { - "id": "bitter-glade-2", - "role": "user", - "created_at": "2020-01-30T13:08:56.190678Z", - "updated_at": "2020-01-30T13:08:56.200333Z", - "last_active": "2020-01-30T13:08:56.193882Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Bitter+glade", - "name": "Bitter glade" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-30T13:11:37.191293Z", - "updated_at": "2020-01-30T13:11:37.191293Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "morning-sea-1-0c700bcb-46dd-4224-b590-e77bdbccc480", - "text": "http://jaeger.ui.gtstrm.com/", - "type": "regular", - "user": { - "id": "morning-sea-1", - "role": "user", - "created_at": "2019-07-22T09:19:07.505207Z", - "updated_at": "2020-01-30T13:33:05.831856Z", - "last_active": "2020-01-30T13:33:05.825369Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Morning+sea", - "name": "Morning sea" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-30T13:33:16.853116Z", - "updated_at": "2020-01-30T13:33:16.853116Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "ancient-salad-0-53e8b4e6-5b7b-43ad-aeee-8bfb6a9ed0be", - "text": "hi", - "type": "regular", - "user": { - "id": "ancient-salad-0", - "role": "user", - "created_at": "2020-01-30T13:34:29.286813Z", - "updated_at": "2020-01-30T13:34:29.296196Z", - "last_active": "2020-01-30T13:34:29.289964Z", - "banned": false, - "online": true, - "image": "https://getstream.io/random_svg/?name=Ancient+salad", - "name": "Ancient salad" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-30T13:36:52.749731Z", - "updated_at": "2020-01-30T13:36:52.749732Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "ancient-salad-0-8c225075-bd4c-42e2-8024-530aae13cd40", - "text": "hi", - "type": "regular", - "user": { - "id": "ancient-salad-0", - "role": "user", - "created_at": "2020-01-30T13:34:29.286813Z", - "updated_at": "2020-01-30T13:34:29.296196Z", - "last_active": "2020-01-30T13:34:29.289964Z", - "banned": false, - "online": true, - "image": "https://getstream.io/random_svg/?name=Ancient+salad", - "name": "Ancient salad" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-30T13:37:41.631056Z", - "updated_at": "2020-01-30T13:37:41.631056Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "proud-sea-7-17802096-cbf8-4e3c-addd-4ee31f4c8b5c", - "text": "😃", - "type": "regular", - "user": { - "id": "proud-sea-7", - "role": "user", - "created_at": "2020-01-30T13:43:03.903006Z", - "updated_at": "2020-01-30T13:43:03.912307Z", - "last_active": "2020-01-30T13:43:03.906236Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Proud+sea", - "name": "Proud sea" - }, - "attachments": [], - "latest_reactions": [], - "own_reactions": [], - "reaction_counts": {}, - "reaction_scores": {}, - "reply_count": 0, - "created_at": "2020-01-30T13:43:41.062362Z", - "updated_at": "2020-01-30T13:43:41.062362Z", - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - } - ], - "watcher_count": 5, - "members": [] - }'''; - test('should parse json correctly', () { - final channelState = ChannelState.fromJson(json.decode(jsonExample)); + final channelState = + ChannelState.fromJson(jsonFixture('channel_state.json')); expect(channelState.channel?.cid, 'team:dev'); expect(channelState.channel?.id, 'dev'); expect(channelState.channel?.team, 'test'); @@ -879,426 +47,7 @@ void main() { }); test('should serialize to json correctly', () { - const toJsonExample = ''' - { - "channel": { - "id": "dev", - "type": "team", - "frozen": true, - "name": "#dev", - "image": "https://cdn.chrisshort.net/testing-certificate-chains-in-go/GOPHER_MIC_DROP.png", - "example": 1 - }, - "watchers": [], - "read": [], - "messages": [ - { - "id": "dry-meadow-0-2b73cc8b-cd86-4a01-8d40-bd82ad07a030", - "text": "fasdfa", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-e8e74482-b4cd-48db-9d1e-30e6c191786f", - "text": "test message", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-53e6299f-9b97-4a9c-a27e-7e2dde49b7e0", - "text": "test message", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-80925be0-786e-40a5-b225-486518dafd35", - "text": "asdfadf", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-64d7970f-ede8-4b31-9738-1bc1756d2bfe", - "text": "test", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "withered-cell-0-84cbd760-cf55-4f7e-9207-c5f66cccc6dc", - "text": "hi", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-e9203588-43c3-40b1-91f7-f217fc42aa53", - "text": "fantastic", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "withered-cell-0-7e3552d7-7a0d-45f2-a856-e91b23a7e240", - "text": "nice to meet you", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-1ffeafd4-e4fc-4c84-9394-9d7cb10fff42", - "text": "hey", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-3f147324-12c8-4b41-9fb5-2db88d065efa", - "text": "hello, everyone", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "dry-meadow-0-51a348ae-0c0a-44de-a556-eac7891c0cf0", - "text": "who is there?", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "icy-recipe-7-a29e237b-8d81-4a97-9bc8-d42bca3f1356", - "text": "하이", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "icy-recipe-7-935c396e-ddf8-4a9a-951c-0a12fa5bf055", - "text": "what are you doing?", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "throbbing-boat-5-1e4d5730-5ff0-4d25-9948-9f34ffda43e4", - "text": "👍", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "snowy-credit-3-3e0c1a0d-d22f-42ee-b2a1-f9f49477bf21", - "text": "sdasas", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "snowy-credit-3-3319537e-2d0e-4876-8170-a54f046e4b7d", - "text": "cjshsa", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "snowy-credit-3-cfaf0b46-1daa-49c5-947c-b16d6697487d", - "text": "nhisagdhsadz", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "snowy-credit-3-cebe25a7-a3a3-49fc-9919-91c6725e81f3", - "text": "hvadhsahzd", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "divine-glade-9-0cea9262-5766-48e9-8b22-311870aed3bf", - "text": "hello", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "red-firefly-9-c4e9007b-bb7d-4238-ae08-5f8e3cd03d73", - "text": "hello", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "bitter-glade-2-02aee4eb-4093-4736-808b-2de75820e854", - "text": "hello", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "morning-sea-1-0c700bcb-46dd-4224-b590-e77bdbccc480", - "text": "http://jaeger.ui.gtstrm.com/", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "ancient-salad-0-53e8b4e6-5b7b-43ad-aeee-8bfb6a9ed0be", - "text": "hi", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "ancient-salad-0-8c225075-bd4c-42e2-8024-530aae13cd40", - "text": "hi", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - }, - { - "id": "proud-sea-7-17802096-cbf8-4e3c-addd-4ee31f4c8b5c", - "text": "😃", - "attachments": [], - "parent_id": null, - "quoted_message": null, - "quoted_message_id": null, - "show_in_channel": null, - "mentioned_users": [], - "status": "SENT", - "silent": false, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null - } - ], - "pinned_messages": [], - "members": [], - "watcher_count": 5 - } - '''; - final j = jsonDecode(jsonExample); + final j = jsonFixture('channel_state.json'); final channelState = ChannelState( channel: ChannelModel.fromJson(j['channel']), members: [], @@ -1312,7 +61,7 @@ void main() { expect( channelState.toJson(), - jsonDecode(toJsonExample), + jsonFixture('channel_state_to_json.json'), ); }); }); diff --git a/packages/stream_chat/test/src/core/models/channel_test.dart b/packages/stream_chat/test/src/core/models/channel_test.dart index 1bb400a6..ca734c44 100644 --- a/packages/stream_chat/test/src/core/models/channel_test.dart +++ b/packages/stream_chat/test/src/core/models/channel_test.dart @@ -1,22 +1,12 @@ -import 'dart:convert'; - import 'package:stream_chat/src/core/models/channel_model.dart'; import 'package:test/test.dart'; +import '../../utils.dart'; + void main() { group('src/models/channel', () { - const jsonExample = ''' - { - "id": "test", - "type": "livestream", - "cid": "livestream:test", - "cats": true, - "fruit": ["bananas", "apples"] - } - '''; - test('should parse json correctly', () { - final channel = ChannelModel.fromJson(json.decode(jsonExample)); + final channel = ChannelModel.fromJson(jsonFixture('channel.json')); expect(channel.id, equals('test')); expect(channel.type, equals('livestream')); expect(channel.cid, equals('livestream:test')); diff --git a/packages/stream_chat/test/src/core/models/command_test.dart b/packages/stream_chat/test/src/core/models/command_test.dart index 3306fd0f..e8ffb81e 100644 --- a/packages/stream_chat/test/src/core/models/command_test.dart +++ b/packages/stream_chat/test/src/core/models/command_test.dart @@ -1,20 +1,12 @@ -import 'dart:convert'; - import 'package:stream_chat/src/core/models/command.dart'; import 'package:test/test.dart'; +import '../../utils.dart'; + void main() { group('src/models/command', () { - const jsonExample = ''' - { - "name": "giphy", - "description": "Post a random gif to the channel", - "args": "[text]" - } - '''; - test('should parse json correctly', () { - final command = Command.fromJson(json.decode(jsonExample)); + final command = Command.fromJson(jsonFixture('command.json')); expect(command.name, 'giphy'); expect(command.description, 'Post a random gif to the channel'); expect(command.args, '[text]'); diff --git a/packages/stream_chat/test/src/core/models/device_test.dart b/packages/stream_chat/test/src/core/models/device_test.dart index f4700b7e..b3ac707b 100644 --- a/packages/stream_chat/test/src/core/models/device_test.dart +++ b/packages/stream_chat/test/src/core/models/device_test.dart @@ -1,18 +1,12 @@ -import 'dart:convert'; - -import 'package:test/test.dart'; import 'package:stream_chat/src/core/models/device.dart'; +import 'package:test/test.dart'; + +import '../../utils.dart'; void main() { group('src/models/device', () { - const jsonExample = ''' - { - "id": "device-id", - "push_provider": "push-provider" - }'''; - test('should parse json correctly', () { - final device = Device.fromJson(json.decode(jsonExample)); + final device = Device.fromJson(jsonFixture('device.json')); expect(device.id, 'device-id'); expect(device.pushProvider, 'push-provider'); }); diff --git a/packages/stream_chat/test/src/core/models/event_test.dart b/packages/stream_chat/test/src/core/models/event_test.dart index b05da962..7ebd82fa 100644 --- a/packages/stream_chat/test/src/core/models/event_test.dart +++ b/packages/stream_chat/test/src/core/models/event_test.dart @@ -1,46 +1,14 @@ -import 'dart:convert'; - import 'package:stream_chat/src/core/models/event.dart'; import 'package:stream_chat/src/core/models/own_user.dart'; import 'package:stream_chat/stream_chat.dart'; import 'package:test/test.dart'; +import '../../utils.dart'; + void main() { group('src/models/event', () { - const jsonExample = ''' - { - "type": "type", - "cid": "cid", - "connection_id": "connectionId", - "created_at": "2019-04-03T18:43:33.213374Z", - "me": { - "id": "dry-meadow-0", - "role": "user", - "created_at": "2019-03-27T17:40:17.155892Z", - "updated_at": "2020-01-29T03:22:47.641589Z", - "last_active": "2020-01-29T03:22:47.63613Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Dry+meadow", - "name": "Dry meadow" - }, - "parent_id": null, - "user": { - "id": "dry-meadow-0", - "role": "user", - "created_at": "2019-03-27T17:40:17.155892Z", - "updated_at": "2020-01-29T03:22:47.641589Z", - "last_active": "2020-01-29T03:22:47.63613Z", - "banned": false, - "online": false, - "image": "https://getstream.io/random_svg/?name=Dry+meadow", - "name": "Dry meadow" - } - } - '''; - test('should parse json correctly', () { - final event = Event.fromJson(json.decode(jsonExample)); + final event = Event.fromJson(jsonFixture('event.json')); expect(event.type, 'type'); expect(event.cid, 'cid'); expect(event.connectionId, 'connectionId'); diff --git a/packages/stream_chat/test/src/core/models/member_test.dart b/packages/stream_chat/test/src/core/models/member_test.dart index 54c258e1..4cd8efda 100644 --- a/packages/stream_chat/test/src/core/models/member_test.dart +++ b/packages/stream_chat/test/src/core/models/member_test.dart @@ -1,31 +1,13 @@ -import 'dart:convert'; - -import 'package:test/test.dart'; import 'package:stream_chat/src/core/models/member.dart'; import 'package:stream_chat/src/core/models/user.dart'; +import 'package:test/test.dart'; + +import '../../utils.dart'; void main() { group('src/models/member', () { - const jsonExample = ''' - { - "user": { - "id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e", - "role": "user", - "created_at": "2020-01-28T22:17:30.826259Z", - "updated_at": "2020-01-28T22:17:31.101222Z", - "banned": false, - "online": false, - "name": "Robin Papa", - "image": "https://pbs.twimg.com/profile_images/669512187778498560/L7wQctBt.jpg" - }, - "role": "member", - "created_at": "2020-01-28T22:17:30.95443Z", - "updated_at": "2020-01-28T22:17:30.95443Z" - } - '''; - test('should parse json correctly', () { - final member = Member.fromJson(json.decode(jsonExample)); + final member = Member.fromJson(jsonFixture('member.json')); expect(member.user, isA()); expect(member.role, 'member'); expect(member.createdAt, DateTime.parse('2020-01-28T22:17:30.95443Z')); diff --git a/packages/stream_chat/test/src/core/models/message_test.dart b/packages/stream_chat/test/src/core/models/message_test.dart index f7b8f003..a5571430 100644 --- a/packages/stream_chat/test/src/core/models/message_test.dart +++ b/packages/stream_chat/test/src/core/models/message_test.dart @@ -1,82 +1,15 @@ -import 'dart:convert'; - import 'package:stream_chat/src/core/models/attachment.dart'; import 'package:stream_chat/src/core/models/message.dart'; import 'package:stream_chat/src/core/models/reaction.dart'; import 'package:stream_chat/src/core/models/user.dart'; import 'package:test/test.dart'; +import '../../utils.dart'; + void main() { group('src/models/message', () { - const jsonExample = r''' - { - "id": "4637f7e4-a06b-42db-ba5a-8d8270dd926f", - "text": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA", - "type": "regular", - "silent": false, - "status": "SENT", - "user": { - "id": "c1c9b454-2bcc-402d-8bb0-2f3706ce1680", - "role": "user", - "created_at": "2020-01-28T22:17:30.83015Z", - "updated_at": "2020-01-28T22:17:31.19435Z", - "banned": false, - "online": false, - "image": "https://randomuser.me/api/portraits/women/2.jpg", - "name": "Mia Denys" - }, - "attachments": [ - { - "type": "video", - "author_name": "GIPHY", - "title": "The Lion King Disney GIF - Find \u0026 Share on GIPHY", - "title_link": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif", - "text": "Discover \u0026 share this Lion King Live Action GIF with everyone you know. GIPHY is how you search, share, discover, and create GIFs.", - "image_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif", - "thumb_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif", - "asset_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.mp4", - "og_scrape_url": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA" - } - ], - "latest_reactions": [ - { - "message_id": "4637f7e4-a06b-42db-ba5a-8d8270dd926f", - "user_id": "c1c9b454-2bcc-402d-8bb0-2f3706ce1680", - "user": { - "id": "c1c9b454-2bcc-402d-8bb0-2f3706ce1680", - "role": "user", - "created_at": "2020-01-28T22:17:30.83015Z", - "updated_at": "2020-01-28T22:17:31.19435Z", - "banned": false, - "online": false, - "image": "https://randomuser.me/api/portraits/women/2.jpg", - "name": "Mia Denys" - }, - "type": "love", - "score": 1, - "created_at": "2020-01-28T22:17:31.128376Z", - "updated_at": "2020-01-28T22:17:31.128376Z" - } - ], - "own_reactions": [], - "reaction_counts": { - "love": 1 - }, - "reaction_scores": { - "love": 1 - }, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null, - "reply_count": 0, - "created_at": "2020-01-28T22:17:31.107978Z", - "updated_at": "2020-01-28T22:17:31.130506Z", - "mentioned_users": [] - }'''; - test('should parse json correctly', () { - final message = Message.fromJson(json.decode(jsonExample)); + final message = Message.fromJson(jsonFixture('message.json')); expect(message.id, '4637f7e4-a06b-42db-ba5a-8d8270dd926f'); expect(message.text, 'https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA'); @@ -128,37 +61,7 @@ void main() { expect( message.toJson(), - json.decode(''' - { - "id": "4637f7e4-a06b-42db-ba5a-8d8270dd926f", - "text": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA", - "silent": false, - "attachments": [ - { - "type": "video", - "title_link": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif", - "title": "The Lion King Disney GIF - Find & Share on GIPHY", - "thumb_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif", - "text": "Discover & share this Lion King Live Action GIF with everyone you know. GIPHY is how you search, share, discover, and create GIFs.", - "og_scrape_url": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA", - "image_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif", - "author_name": "GIPHY", - "asset_url": "https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.mp4", - "actions": [] - } - ], - "mentioned_users": [], - "parent_id": "parentId", - "quoted_message": null, - "quoted_message_id": null, - "pinned": false, - "pinned_at": null, - "pin_expires": null, - "pinned_by": null, - "show_in_channel": true, - "hey": "test" - } - '''), + jsonFixture('message_to_json.json'), ); }); }); diff --git a/packages/stream_chat/test/src/core/models/reaction_test.dart b/packages/stream_chat/test/src/core/models/reaction_test.dart index b69bd986..facb8d07 100644 --- a/packages/stream_chat/test/src/core/models/reaction_test.dart +++ b/packages/stream_chat/test/src/core/models/reaction_test.dart @@ -1,34 +1,13 @@ -import 'dart:convert'; - import 'package:stream_chat/src/core/models/reaction.dart'; import 'package:stream_chat/src/core/models/user.dart'; import 'package:test/test.dart'; +import '../../utils.dart'; + void main() { group('src/models/reaction', () { - const jsonExample = ''' - { - "message_id": "76cd8c82-b557-4e48-9d12-87995d3a0e04", - "user_id": "2de0297c-f3f2-489d-b930-ef77342edccf", - "user": { - "id": "2de0297c-f3f2-489d-b930-ef77342edccf", - "role": "user", - "created_at": "2020-01-28T22:17:30.810011Z", - "updated_at": "2020-01-28T22:17:31.077195Z", - "banned": false, - "online": false, - "image": "https://randomuser.me/api/portraits/women/45.jpg", - "name": "Daisy Morgan" - }, - "type": "wow", - "score": 1, - "created_at": "2020-01-28T22:17:31.108742Z", - "updated_at": "2020-01-28T22:17:31.108742Z" - } - '''; - test('should parse json correctly', () { - final reaction = Reaction.fromJson(json.decode(jsonExample)); + final reaction = Reaction.fromJson(jsonFixture('reaction.json')); expect(reaction.messageId, '76cd8c82-b557-4e48-9d12-87995d3a0e04'); expect(reaction.createdAt, DateTime.parse('2020-01-28T22:17:31.108742Z')); expect(reaction.type, 'wow'); diff --git a/packages/stream_chat/test/src/core/models/read_test.dart b/packages/stream_chat/test/src/core/models/read_test.dart index 47c252ac..eabfc18c 100644 --- a/packages/stream_chat/test/src/core/models/read_test.dart +++ b/packages/stream_chat/test/src/core/models/read_test.dart @@ -1,23 +1,13 @@ -import 'dart:convert'; - -import 'package:test/test.dart'; import 'package:stream_chat/src/core/models/read.dart'; import 'package:stream_chat/src/core/models/user.dart'; +import 'package:test/test.dart'; + +import '../../utils.dart'; void main() { group('src/models/read', () { - const jsonExample = ''' - { - "user": { - "id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e" - }, - "last_read": "2020-01-28T22:17:30.966485504Z", - "unread_messages": 10 - } - '''; - test('should parse json correctly', () { - final read = Read.fromJson(json.decode(jsonExample)); + final read = Read.fromJson(jsonFixture('read.json')); expect(read.lastRead, DateTime.parse('2020-01-28T22:17:30.966485504Z')); expect(read.user.id, 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e'); expect(read.unreadMessages, 10); diff --git a/packages/stream_chat/test/src/core/models/user_test.dart b/packages/stream_chat/test/src/core/models/user_test.dart index f4ff5ee0..89d22b30 100644 --- a/packages/stream_chat/test/src/core/models/user_test.dart +++ b/packages/stream_chat/test/src/core/models/user_test.dart @@ -1,19 +1,12 @@ -import 'dart:convert'; - import 'package:stream_chat/src/core/models/user.dart'; import 'package:test/test.dart'; +import '../../utils.dart'; + void main() { group('src/models/user', () { - const jsonExample = ''' - { - "id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e", - "role": "test-role" - } - '''; - test('should parse json correctly', () { - final user = User.fromJson(json.decode(jsonExample)); + final user = User.fromJson(jsonFixture('user.json')); expect(user.id, 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e'); }); diff --git a/packages/stream_chat/test/src/utils.dart b/packages/stream_chat/test/src/utils.dart index 91a61204..768d2fe2 100644 --- a/packages/stream_chat/test/src/utils.dart +++ b/packages/stream_chat/test/src/utils.dart @@ -1,10 +1,18 @@ +import 'dart:convert'; import 'dart:io'; +String fixture(String name) { + final dir = currentDirectory.path; + return File('$dir/test/fixtures/$name').readAsStringSync(); +} + File assetFile(String name) { final dir = currentDirectory.path; return File('$dir/test/assets/$name'); } +Map jsonFixture(String name) => json.decode(fixture(name)); + // https://github.com/flutter/flutter/issues/20907 Directory get currentDirectory { var directory = Directory.current; diff --git a/packages/stream_chat_persistence/lib/src/db/moor_chat_database.g.dart b/packages/stream_chat_persistence/lib/src/db/moor_chat_database.g.dart index 09156642..fe921e70 100644 --- a/packages/stream_chat_persistence/lib/src/db/moor_chat_database.g.dart +++ b/packages/stream_chat_persistence/lib/src/db/moor_chat_database.g.dart @@ -3550,7 +3550,7 @@ class UsersCompanion extends UpdateCompanion { this.online = const Value.absent(), this.banned = const Value.absent(), required Map extraData, - }) : id = Value(id), + }) : id = Value(id), extraData = Value(extraData); static Insertable custom({ Expression? id, @@ -4723,7 +4723,7 @@ class ChannelQueriesCompanion extends UpdateCompanion { ChannelQueriesCompanion.insert({ required String queryHash, required String channelCid, - }) : queryHash = Value(queryHash), + }) : queryHash = Value(queryHash), channelCid = Value(channelCid); static Insertable custom({ Expression? queryHash, From 51f8e030f51dc2bf3d5a9d20c9b3e6d2b777f477 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 16 Jun 2021 13:58:24 +0200 Subject: [PATCH 03/11] add mute test --- .../stream_chat/lib/src/core/models/mute.dart | 9 +-- .../lib/src/core/models/mute.g.dart | 16 ---- packages/stream_chat/test/fixtures/mute.json | 74 +++++++++++++++++++ .../test/src/core/models/mute_test.dart | 17 +++++ 4 files changed, 95 insertions(+), 21 deletions(-) create mode 100644 packages/stream_chat/test/fixtures/mute.json create mode 100644 packages/stream_chat/test/src/core/models/mute_test.dart diff --git a/packages/stream_chat/lib/src/core/models/mute.dart b/packages/stream_chat/lib/src/core/models/mute.dart index 9166d3e4..4b14ad01 100644 --- a/packages/stream_chat/lib/src/core/models/mute.dart +++ b/packages/stream_chat/lib/src/core/models/mute.dart @@ -1,12 +1,14 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:stream_chat/src/core/models/channel_model.dart'; -import 'package:stream_chat/src/core/util/serializer.dart'; import 'package:stream_chat/src/core/models/user.dart'; +import 'package:stream_chat/src/core/util/serializer.dart'; part 'mute.g.dart'; /// The class that contains the information about a muted user -@JsonSerializable() +@JsonSerializable( + createToJson: false, +) class Mute { /// Constructor used for json serialization Mute({ @@ -34,7 +36,4 @@ class Mute { /// The date of the last update @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) final DateTime updatedAt; - - /// Serialize to json - Map toJson() => _$MuteToJson(this); } diff --git a/packages/stream_chat/lib/src/core/models/mute.g.dart b/packages/stream_chat/lib/src/core/models/mute.g.dart index e77b8707..b847a109 100644 --- a/packages/stream_chat/lib/src/core/models/mute.g.dart +++ b/packages/stream_chat/lib/src/core/models/mute.g.dart @@ -14,19 +14,3 @@ Mute _$MuteFromJson(Map json) { updatedAt: DateTime.parse(json['updated_at'] as String), ); } - -Map _$MuteToJson(Mute instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('user', readonly(instance.user)); - writeNotNull('channel', readonly(instance.channel)); - writeNotNull('created_at', readonly(instance.createdAt)); - writeNotNull('updated_at', readonly(instance.updatedAt)); - return val; -} diff --git a/packages/stream_chat/test/fixtures/mute.json b/packages/stream_chat/test/fixtures/mute.json new file mode 100644 index 00000000..cc6c3a8c --- /dev/null +++ b/packages/stream_chat/test/fixtures/mute.json @@ -0,0 +1,74 @@ +{ + "user": { + "id": "super-band-9", + "role": "user", + "created_at": "2020-03-03T16:48:28.853674Z", + "updated_at": "2021-05-26T03:22:20.296181Z", + "last_active": "2021-06-16T11:42:29.466165498Z", + "banned": false, + "online": true, + "username": "Rioland", + "image": "https://placehold.jp/150x150.png", + "invisible": false, + "name": "Proud darkness", + "unread_count": 0 + }, + "channel": { + "id": "!members-Qsp7PpigdPkW0rJk0603y5GnTiF1iRfoDc4SAngMMmw", + "type": "messaging", + "cid": "messaging:!members-Qsp7PpigdPkW0rJk0603y5GnTiF1iRfoDc4SAngMMmw", + "last_message_at": "2020-12-02T06:56:18.003432Z", + "created_at": "2020-11-30T10:25:32.494601Z", + "updated_at": "2020-11-30T10:25:32.494601Z", + "created_by": { + "id": "super-band-9", + "role": "user", + "created_at": "2020-03-03T16:48:28.853674Z", + "updated_at": "2021-05-26T03:22:20.296181Z", + "last_active": "2021-06-16T11:42:29.466165498Z", + "banned": false, + "online": true, + "image": "https://placehold.jp/150x150.png", + "invisible": false, + "name": "Proud darkness", + "unread_count": 0, + "username": "Rioland" + }, + "frozen": false, + "disabled": false, + "member_count": 2, + "config": { + "created_at": "2020-04-15T14:57:17.00966Z", + "updated_at": "2021-05-25T14:25:30.405621Z", + "name": "messaging", + "typing_events": true, + "read_events": true, + "connect_events": true, + "search": true, + "reactions": true, + "replies": true, + "mutes": true, + "uploads": true, + "url_enrichment": true, + "custom_events": false, + "push_notifications": true, + "message_retention": "infinite", + "max_message_length": 5000, + "automod": "disabled", + "automod_behavior": "flag", + "blocklist": "profanity_en_2020_v1", + "blocklist_behavior": "block", + "automod_thresholds": {}, + "commands": [ + { + "name": "giphy", + "description": "Post a random gif to the channel", + "args": "[text]", + "set": "fun_set" + } + ] + } + }, + "created_at": "2020-12-04T10:39:06.512021Z", + "updated_at": "2020-12-04T10:39:06.512021Z" +} \ No newline at end of file diff --git a/packages/stream_chat/test/src/core/models/mute_test.dart b/packages/stream_chat/test/src/core/models/mute_test.dart new file mode 100644 index 00000000..f1f7b606 --- /dev/null +++ b/packages/stream_chat/test/src/core/models/mute_test.dart @@ -0,0 +1,17 @@ +import 'package:stream_chat/src/core/models/channel_model.dart'; +import 'package:stream_chat/src/core/models/mute.dart'; +import 'package:stream_chat/src/core/models/user.dart'; +import 'package:test/test.dart'; + +import '../../utils.dart'; + +void main() { + group('src/models/mute', () { + test('should parse json correctly', () { + final mute = Mute.fromJson(jsonFixture('mute.json')); + expect(mute.channel, isA()); + expect(mute.user, isA()); + expect(mute.createdAt, DateTime.parse('2020-12-04T10:39:06.512021Z')); + }); + }); +} From 4e9699dbf49816104f9d4975671f5604cefa60f1 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 16 Jun 2021 16:06:55 +0200 Subject: [PATCH 04/11] add OwnUser test --- .../lib/src/core/models/own_user.dart | 25 ++--- .../lib/src/core/models/own_user.g.dart | 26 ----- .../stream_chat/test/fixtures/own_user.json | 100 ++++++++++++++++++ .../test/src/core/models/own_user_test.dart | 45 ++++++++ 4 files changed, 152 insertions(+), 44 deletions(-) create mode 100644 packages/stream_chat/test/fixtures/own_user.json create mode 100644 packages/stream_chat/test/src/core/models/own_user_test.dart diff --git a/packages/stream_chat/lib/src/core/models/own_user.dart b/packages/stream_chat/lib/src/core/models/own_user.dart index 22705b05..7ceffbfa 100644 --- a/packages/stream_chat/lib/src/core/models/own_user.dart +++ b/packages/stream_chat/lib/src/core/models/own_user.dart @@ -1,14 +1,14 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:stream_chat/src/core/models/device.dart'; import 'package:stream_chat/src/core/models/mute.dart'; -import 'package:stream_chat/src/core/util/serializer.dart'; import 'package:stream_chat/src/core/models/user.dart'; +import 'package:stream_chat/src/core/util/serializer.dart'; part 'own_user.g.dart'; /// The class that defines the own user model /// This object can be found in [Event] -@JsonSerializable() +@JsonSerializable(createToJson: false) class OwnUser extends User { /// Constructor used for json serialization OwnUser({ @@ -53,28 +53,23 @@ class OwnUser extends User { ); /// List of user devices - @JsonKey( - includeIfNull: false, - toJson: Serializer.readOnly, - defaultValue: []) + @JsonKey(includeIfNull: false, defaultValue: []) final List devices; /// List of users muted by the user - @JsonKey( - includeIfNull: false, toJson: Serializer.readOnly, defaultValue: []) + @JsonKey(includeIfNull: false, defaultValue: []) final List mutes; /// List of users muted by the user - @JsonKey( - includeIfNull: false, toJson: Serializer.readOnly, defaultValue: []) + @JsonKey(includeIfNull: false, defaultValue: []) final List channelMutes; /// Total unread messages by the user - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly, defaultValue: 0) + @JsonKey(includeIfNull: false, defaultValue: 0) final int totalUnreadCount; /// Total unread channels by the user - @JsonKey(includeIfNull: false, toJson: Serializer.readOnly) + @JsonKey(includeIfNull: false) final int? unreadChannels; /// Known top level fields. @@ -87,10 +82,4 @@ class OwnUser extends User { 'channel_mutes', ...User.topLevelFields, ]; - - /// Serialize to json - @override - Map toJson() => Serializer.moveFromExtraDataToRoot( - _$OwnUserToJson(this), - ); } diff --git a/packages/stream_chat/lib/src/core/models/own_user.g.dart b/packages/stream_chat/lib/src/core/models/own_user.g.dart index 760edc01..26e4786e 100644 --- a/packages/stream_chat/lib/src/core/models/own_user.g.dart +++ b/packages/stream_chat/lib/src/core/models/own_user.g.dart @@ -38,29 +38,3 @@ OwnUser _$OwnUserFromJson(Map json) { banned: json['banned'] as bool? ?? false, ); } - -Map _$OwnUserToJson(OwnUser instance) { - final val = { - 'id': instance.id, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('role', readonly(instance.role)); - writeNotNull('created_at', readonly(instance.createdAt)); - writeNotNull('updated_at', readonly(instance.updatedAt)); - writeNotNull('last_active', readonly(instance.lastActive)); - writeNotNull('online', readonly(instance.online)); - writeNotNull('banned', readonly(instance.banned)); - val['extra_data'] = instance.extraData; - writeNotNull('devices', readonly(instance.devices)); - writeNotNull('mutes', readonly(instance.mutes)); - writeNotNull('channel_mutes', readonly(instance.channelMutes)); - writeNotNull('total_unread_count', readonly(instance.totalUnreadCount)); - writeNotNull('unread_channels', readonly(instance.unreadChannels)); - return val; -} diff --git a/packages/stream_chat/test/fixtures/own_user.json b/packages/stream_chat/test/fixtures/own_user.json new file mode 100644 index 00000000..dc6aabd1 --- /dev/null +++ b/packages/stream_chat/test/fixtures/own_user.json @@ -0,0 +1,100 @@ +{ + "id": "super-band-9", + "role": "user", + "created_at": "2020-03-03T16:48:28.853674Z", + "updated_at": "2021-05-26T03:22:20.296181Z", + "last_active": "2021-06-16T11:59:59.003453014Z", + "banned": false, + "online": true, + "devices": [ + { + "push_provider": "firebase", + "id": "cRS8elU4Q-qqdCAvHR2kSa:APA91bFy7MEgPyXbnFWi3uoanr_x8Vbi42JcWOXlg8p3vyIL5FuW4bjpVfamqQjYCgwDGxPA0C4qavOadE-uiKeGQJp6Sp5D2KDW9Od_BlDqzwEPJnVG9gC1zbj7NKCfXRqbOA2Wh2mW", + "created_at": "2020-04-23T14:36:21.838196Z", + "user_id": "super-band-9" + } + ], + "mutes": [], + "channel_mutes": [ + { + "user": { + "id": "super-band-9", + "role": "user", + "created_at": "2020-03-03T16:48:28.853674Z", + "updated_at": "2021-05-26T03:22:20.296181Z", + "last_active": "2021-06-16T11:59:59.003453014Z", + "banned": false, + "online": true, + "image": "https://placehold.jp/150x150.png", + "invisible": false, + "name": "Proud darkness", + "unread_count": 0, + "username": "Rioland" + }, + "channel": { + "id": "!members-Qsp7PpigdPkW0rJk0603y5GnTiF1iRfoDc4SAngMMmw", + "type": "messaging", + "cid": "messaging:!members-Qsp7PpigdPkW0rJk0603y5GnTiF1iRfoDc4SAngMMmw", + "last_message_at": "2020-12-02T06:56:18.003432Z", + "created_at": "2020-11-30T10:25:32.494601Z", + "updated_at": "2020-11-30T10:25:32.494601Z", + "created_by": { + "id": "super-band-9", + "role": "user", + "created_at": "2020-03-03T16:48:28.853674Z", + "updated_at": "2021-05-26T03:22:20.296181Z", + "last_active": "2021-06-16T11:59:59.003453014Z", + "banned": false, + "online": true, + "unread_count": 0, + "username": "Rioland", + "image": "https://placehold.jp/150x150.png", + "invisible": false, + "name": "Proud darkness" + }, + "frozen": false, + "disabled": false, + "member_count": 2, + "config": { + "created_at": "2020-04-15T14:57:17.00966Z", + "updated_at": "2021-05-25T14:25:30.405621Z", + "name": "messaging", + "typing_events": true, + "read_events": true, + "connect_events": true, + "search": true, + "reactions": true, + "replies": true, + "mutes": true, + "uploads": true, + "url_enrichment": true, + "custom_events": false, + "push_notifications": true, + "message_retention": "infinite", + "max_message_length": 5000, + "automod": "disabled", + "automod_behavior": "flag", + "blocklist": "profanity_en_2020_v1", + "blocklist_behavior": "block", + "automod_thresholds": {}, + "commands": [ + { + "name": "giphy", + "description": "Post a random gif to the channel", + "args": "[text]", + "set": "fun_set" + } + ] + } + }, + "created_at": "2020-12-04T10:39:06.512021Z", + "updated_at": "2020-12-04T10:39:06.512021Z" + } + ], + "total_unread_count": 0, + "unread_channels": 0, + "language": "", + "image": "https://placehold.jp/150x150.png", + "name": "Proud darkness", + "username": "Rioland" +} diff --git a/packages/stream_chat/test/src/core/models/own_user_test.dart b/packages/stream_chat/test/src/core/models/own_user_test.dart new file mode 100644 index 00000000..edaf022e --- /dev/null +++ b/packages/stream_chat/test/src/core/models/own_user_test.dart @@ -0,0 +1,45 @@ +import 'package:stream_chat/src/core/models/own_user.dart'; +import 'package:stream_chat/src/core/models/user.dart'; +import 'package:test/test.dart'; + +import '../../utils.dart'; + +void main() { + group('src/models/own_user', () { + test('should parse json correctly', () { + final ownUser = OwnUser.fromJson(jsonFixture('own_user.json')); + expect(ownUser.id, 'super-band-9'); + expect(ownUser.role, 'user'); + + expect(ownUser.createdAt, DateTime.parse('2020-03-03T16:48:28.853674Z')); + expect(ownUser.updatedAt, DateTime.parse('2021-05-26T03:22:20.296181Z')); + expect( + ownUser.lastActive, DateTime.parse('2021-06-16T11:59:59.003453014Z')); + expect(ownUser.banned, false); + expect(ownUser.online, true); + expect(ownUser.devices.length, 1); + expect(ownUser.mutes.length, 0); + expect(ownUser.channelMutes.length, 1); + expect(ownUser.totalUnreadCount, 0); + expect(ownUser.unreadChannels, 0); + expect(ownUser.extraData['image'], 'https://placehold.jp/150x150.png'); + expect(ownUser.extraData['name'], 'Proud darkness'); + expect(ownUser.extraData['username'], 'Rioland'); + }); + + test('should initialize a OwnUser from a User correctly', () { + final user = User.fromJson(jsonFixture('user.json')); + final ownUser = OwnUser.fromUser(user); + + expect(ownUser.id, user.id); + expect(ownUser.id, user.id); + expect(ownUser.role, user.role); + expect(ownUser.createdAt, user.createdAt); + expect(ownUser.updatedAt, user.updatedAt); + expect(ownUser.lastActive, user.lastActive); + expect(ownUser.online, user.online); + expect(ownUser.banned, user.banned); + expect(ownUser.extraData, user.extraData); + }); + }); +} From d4b5154cbad0ce4888fa19617590000d5a6c95f4 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 16 Jun 2021 16:27:21 +0200 Subject: [PATCH 05/11] add reaction test --- .../test/src/core/models/reaction_test.dart | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/packages/stream_chat/test/src/core/models/reaction_test.dart b/packages/stream_chat/test/src/core/models/reaction_test.dart index facb8d07..cfe9f69e 100644 --- a/packages/stream_chat/test/src/core/models/reaction_test.dart +++ b/packages/stream_chat/test/src/core/models/reaction_test.dart @@ -47,5 +47,108 @@ void main() { }, ); }); + + test('copyWith', () { + final reaction = Reaction.fromJson(jsonFixture('reaction.json')); + var newReaction = reaction.copyWith(); + expect(newReaction.messageId, '76cd8c82-b557-4e48-9d12-87995d3a0e04'); + expect( + newReaction.createdAt, DateTime.parse('2020-01-28T22:17:31.108742Z')); + expect(newReaction.type, 'wow'); + expect( + newReaction.user?.toJson(), + User(id: '2de0297c-f3f2-489d-b930-ef77342edccf', extraData: const { + 'image': 'https://randomuser.me/api/portraits/women/45.jpg', + 'name': 'Daisy Morgan', + }).toJson(), + ); + expect(newReaction.score, 1); + expect(newReaction.userId, '2de0297c-f3f2-489d-b930-ef77342edccf'); + expect( + newReaction.extraData, {'updated_at': '2020-01-28T22:17:31.108742Z'}); + + newReaction = reaction.copyWith( + type: 'lol', + createdAt: DateTime.parse('2021-01-28T22:17:31.108742Z'), + extraData: {}, + messageId: 'test', + score: 2, + user: User(id: 'test'), + userId: 'test', + ); + + expect( + newReaction.type, + 'lol', + ); + expect( + newReaction.createdAt, + DateTime.parse('2021-01-28T22:17:31.108742Z'), + ); + expect( + newReaction.extraData, + {}, + ); + expect( + newReaction.messageId, + 'test', + ); + expect( + newReaction.score, + 2, + ); + expect( + newReaction.user, + User(id: 'test'), + ); + expect( + newReaction.userId, + 'test', + ); + }); + + test('merge', () { + final reaction = Reaction.fromJson(jsonFixture('reaction.json')); + final newReaction = reaction.merge( + Reaction( + type: 'lol', + createdAt: DateTime.parse('2021-01-28T22:17:31.108742Z'), + extraData: {}, + messageId: 'test', + score: 2, + user: User(id: 'test'), + userId: 'test', + ), + ); + + expect( + newReaction.type, + 'lol', + ); + expect( + newReaction.createdAt, + DateTime.parse('2021-01-28T22:17:31.108742Z'), + ); + expect( + newReaction.extraData, + {}, + ); + expect( + newReaction.messageId, + 'test', + ); + expect( + newReaction.score, + 2, + ); + expect( + newReaction.user, + User(id: 'test'), + ); + expect( + newReaction.userId, + 'test', + ); + }); }); } From aef63f3722e51752a9182f90a32e32f6906cf238 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 17 Jun 2021 09:40:01 +0200 Subject: [PATCH 06/11] add more read test --- .../test/src/core/models/read_test.dart | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/stream_chat/test/src/core/models/read_test.dart b/packages/stream_chat/test/src/core/models/read_test.dart index eabfc18c..94a28f08 100644 --- a/packages/stream_chat/test/src/core/models/read_test.dart +++ b/packages/stream_chat/test/src/core/models/read_test.dart @@ -26,5 +26,29 @@ void main() { 'unread_messages': 10, }); }); + + test('copyWith', () { + final read = Read.fromJson(jsonFixture('read.json')); + var newRead = read.copyWith(); + expect( + newRead.lastRead, + DateTime.parse('2020-01-28T22:17:30.966485504Z'), + ); + expect(newRead.user.id, 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e'); + expect(newRead.unreadMessages, 10); + + newRead = read.copyWith( + user: User(id: 'test'), + lastRead: DateTime.parse('2021-01-28T22:17:30.966485504Z'), + unreadMessages: 2, + ); + + expect( + newRead.lastRead, + DateTime.parse('2021-01-28T22:17:30.966485504Z'), + ); + expect(newRead.user.id, 'test'); + expect(newRead.unreadMessages, 2); + }); }); } From 91907639adef5627dc9f4f4fefd7f604978b4f5e Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 17 Jun 2021 10:01:46 +0200 Subject: [PATCH 07/11] add more user and channel config test --- .../lib/src/core/models/channel_config.dart | 5 +---- .../lib/src/core/models/channel_config.g.dart | 19 ---------------- packages/stream_chat/test/fixtures/user.json | 3 ++- .../test/src/core/models/user_test.dart | 22 +++++++++++++++++++ 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/packages/stream_chat/lib/src/core/models/channel_config.dart b/packages/stream_chat/lib/src/core/models/channel_config.dart index 2d5182b3..b7cafac6 100644 --- a/packages/stream_chat/lib/src/core/models/channel_config.dart +++ b/packages/stream_chat/lib/src/core/models/channel_config.dart @@ -4,7 +4,7 @@ import 'package:stream_chat/src/core/models/command.dart'; part 'channel_config.g.dart'; /// The class that contains the information about the configuration of a channel -@JsonSerializable() +@JsonSerializable(createToJson: false) class ChannelConfig { /// Constructor used for json serialization ChannelConfig({ @@ -87,7 +87,4 @@ class ChannelConfig { /// True if urls appears as attachments @JsonKey(defaultValue: false) final bool urlEnrichment; - - /// Serialize to json - Map toJson() => _$ChannelConfigToJson(this); } diff --git a/packages/stream_chat/lib/src/core/models/channel_config.g.dart b/packages/stream_chat/lib/src/core/models/channel_config.g.dart index 723281c0..b01049f3 100644 --- a/packages/stream_chat/lib/src/core/models/channel_config.g.dart +++ b/packages/stream_chat/lib/src/core/models/channel_config.g.dart @@ -32,22 +32,3 @@ ChannelConfig _$ChannelConfigFromJson(Map json) { urlEnrichment: json['url_enrichment'] as bool? ?? false, ); } - -Map _$ChannelConfigToJson(ChannelConfig instance) => - { - 'automod': instance.automod, - 'commands': instance.commands.map((e) => e.toJson()).toList(), - 'connect_events': instance.connectEvents, - 'created_at': instance.createdAt.toIso8601String(), - 'updated_at': instance.updatedAt.toIso8601String(), - 'max_message_length': instance.maxMessageLength, - 'message_retention': instance.messageRetention, - 'mutes': instance.mutes, - 'reactions': instance.reactions, - 'read_events': instance.readEvents, - 'replies': instance.replies, - 'search': instance.search, - 'typing_events': instance.typingEvents, - 'uploads': instance.uploads, - 'url_enrichment': instance.urlEnrichment, - }; diff --git a/packages/stream_chat/test/fixtures/user.json b/packages/stream_chat/test/fixtures/user.json index 1fad8ea0..49b972a3 100644 --- a/packages/stream_chat/test/fixtures/user.json +++ b/packages/stream_chat/test/fixtures/user.json @@ -1,4 +1,5 @@ { "id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e", - "role": "test-role" + "role": "test-role", + "name": "John" } \ No newline at end of file diff --git a/packages/stream_chat/test/src/core/models/user_test.dart b/packages/stream_chat/test/src/core/models/user_test.dart index 89d22b30..ce488cab 100644 --- a/packages/stream_chat/test/src/core/models/user_test.dart +++ b/packages/stream_chat/test/src/core/models/user_test.dart @@ -8,6 +8,7 @@ void main() { test('should parse json correctly', () { final user = User.fromJson(jsonFixture('user.json')); expect(user.id, 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e'); + expect(user.name, 'John'); }); test('should serialize to json correctly', () { @@ -20,5 +21,26 @@ void main() { 'id': 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e', }); }); + + test('copyWith', () { + final user = User.fromJson(jsonFixture('user.json')); + var newUser = user.copyWith(); + + expect(newUser.id, user.id); + expect(newUser.role, user.role); + expect(newUser.name, user.name); + + newUser = user.copyWith( + id: 'test', + role: 'test', + extraData: { + 'name': 'test', + }, + ); + + expect(newUser.id, 'test'); + expect(newUser.role, 'test'); + expect(newUser.name, 'test'); + }); }); } From 907573dab1532cb76bb843c68b0ec8b19e13c62a Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 17 Jun 2021 10:34:53 +0200 Subject: [PATCH 08/11] add event tests --- .../lib/src/core/models/channel_config.dart | 5 +- .../lib/src/core/models/channel_config.g.dart | 19 ++++ .../lib/src/core/models/event.dart | 13 ++- .../lib/src/core/models/event.g.dart | 26 ----- .../test/fixtures/event_channel.json | 99 +++++++++++++++++++ .../test/src/core/models/event_test.dart | 48 +++++++++ 6 files changed, 176 insertions(+), 34 deletions(-) create mode 100644 packages/stream_chat/test/fixtures/event_channel.json diff --git a/packages/stream_chat/lib/src/core/models/channel_config.dart b/packages/stream_chat/lib/src/core/models/channel_config.dart index b7cafac6..2d5182b3 100644 --- a/packages/stream_chat/lib/src/core/models/channel_config.dart +++ b/packages/stream_chat/lib/src/core/models/channel_config.dart @@ -4,7 +4,7 @@ import 'package:stream_chat/src/core/models/command.dart'; part 'channel_config.g.dart'; /// The class that contains the information about the configuration of a channel -@JsonSerializable(createToJson: false) +@JsonSerializable() class ChannelConfig { /// Constructor used for json serialization ChannelConfig({ @@ -87,4 +87,7 @@ class ChannelConfig { /// True if urls appears as attachments @JsonKey(defaultValue: false) final bool urlEnrichment; + + /// Serialize to json + Map toJson() => _$ChannelConfigToJson(this); } diff --git a/packages/stream_chat/lib/src/core/models/channel_config.g.dart b/packages/stream_chat/lib/src/core/models/channel_config.g.dart index b01049f3..723281c0 100644 --- a/packages/stream_chat/lib/src/core/models/channel_config.g.dart +++ b/packages/stream_chat/lib/src/core/models/channel_config.g.dart @@ -32,3 +32,22 @@ ChannelConfig _$ChannelConfigFromJson(Map json) { urlEnrichment: json['url_enrichment'] as bool? ?? false, ); } + +Map _$ChannelConfigToJson(ChannelConfig instance) => + { + 'automod': instance.automod, + 'commands': instance.commands.map((e) => e.toJson()).toList(), + 'connect_events': instance.connectEvents, + 'created_at': instance.createdAt.toIso8601String(), + 'updated_at': instance.updatedAt.toIso8601String(), + 'max_message_length': instance.maxMessageLength, + 'message_retention': instance.messageRetention, + 'mutes': instance.mutes, + 'reactions': instance.reactions, + 'read_events': instance.readEvents, + 'replies': instance.replies, + 'search': instance.search, + 'typing_events': instance.typingEvents, + 'uploads': instance.uploads, + 'url_enrichment': instance.urlEnrichment, + }; diff --git a/packages/stream_chat/lib/src/core/models/event.dart b/packages/stream_chat/lib/src/core/models/event.dart index 33e696c4..21dd069c 100644 --- a/packages/stream_chat/lib/src/core/models/event.dart +++ b/packages/stream_chat/lib/src/core/models/event.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:json_annotation/json_annotation.dart'; import 'package:stream_chat/src/core/models/channel_model.dart'; import 'package:stream_chat/src/core/models/message.dart'; @@ -160,11 +162,14 @@ class Event { channelType: channelType ?? this.channelType, parentId: parentId ?? this.parentId, extraData: extraData ?? this.extraData, + isLocal: isLocal, ); } /// The channel embedded in the event object -@JsonSerializable() +@JsonSerializable( + createToJson: false, +) class EventChannel extends ChannelModel { /// Constructor used for json serialization EventChannel({ @@ -212,10 +217,4 @@ class EventChannel extends ChannelModel { 'members', ...ChannelModel.topLevelFields, ]; - - /// Serialize to json - @override - Map toJson() => Serializer.moveFromExtraDataToRoot( - _$EventChannelToJson(this), - ); } diff --git a/packages/stream_chat/lib/src/core/models/event.g.dart b/packages/stream_chat/lib/src/core/models/event.g.dart index 90abeb71..5247af17 100644 --- a/packages/stream_chat/lib/src/core/models/event.g.dart +++ b/packages/stream_chat/lib/src/core/models/event.g.dart @@ -89,29 +89,3 @@ EventChannel _$EventChannelFromJson(Map json) { extraData: json['extra_data'] as Map? ?? {}, ); } - -Map _$EventChannelToJson(EventChannel instance) { - final val = { - 'id': instance.id, - 'type': instance.type, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('cid', readonly(instance.cid)); - writeNotNull('config', readonly(instance.config)); - writeNotNull('created_by', readonly(instance.createdBy)); - val['frozen'] = instance.frozen; - writeNotNull('last_message_at', readonly(instance.lastMessageAt)); - writeNotNull('created_at', readonly(instance.createdAt)); - writeNotNull('updated_at', readonly(instance.updatedAt)); - writeNotNull('deleted_at', readonly(instance.deletedAt)); - writeNotNull('member_count', readonly(instance.memberCount)); - val['extra_data'] = instance.extraData; - val['members'] = instance.members?.map((e) => e.toJson()).toList(); - return val; -} diff --git a/packages/stream_chat/test/fixtures/event_channel.json b/packages/stream_chat/test/fixtures/event_channel.json new file mode 100644 index 00000000..6078c545 --- /dev/null +++ b/packages/stream_chat/test/fixtures/event_channel.json @@ -0,0 +1,99 @@ +{ + "id": "!members-v9ktpgmYysZA-MjgC-GMoeEawFHSelkOdTu6JGxFZWU", + "type": "messaging", + "cid": "messaging:!members-v9ktpgmYysZA-MjgC-GMoeEawFHSelkOdTu6JGxFZWU", + "last_message_at": "2020-12-02T04:22:16.755334Z", + "created_at": "2020-10-01T08:49:32.90162Z", + "updated_at": "2021-06-17T08:18:48.188996Z", + "created_by": { + "id": "super-band-9", + "role": "user", + "created_at": "2020-03-03T16:48:28.853674Z", + "updated_at": "2021-05-26T03:22:20.296181Z", + "last_active": "2021-06-17T08:12:05.062115Z", + "banned": false, + "online": true, + "image": "https://placehold.jp/150x150.png", + "invisible": false, + "name": "Proud darkness", + "unread_count": 0, + "username": "Rioland" + }, + "frozen": false, + "disabled": false, + "members": [ + { + "user_id": "super-band-9", + "user": { + "id": "super-band-9", + "role": "user", + "created_at": "2020-03-03T16:48:28.853674Z", + "updated_at": "2021-05-26T03:22:20.296181Z", + "last_active": "2021-06-17T08:12:05.062115Z", + "banned": false, + "online": true, + "image": "https://placehold.jp/150x150.png", + "invisible": false, + "name": "Proud darkness", + "unread_count": 0, + "username": "Rioland" + }, + "role": "owner", + "created_at": "2020-10-01T08:49:32.905052Z", + "updated_at": "2020-10-01T08:49:32.905052Z", + "banned": false, + "shadow_banned": false + }, + { + "user_id": "cc48de8e-b2db-48e7-bba5-c03cefd61430", + "user": { + "id": "cc48de8e-b2db-48e7-bba5-c03cefd61430", + "role": "user", + "created_at": "2020-07-22T14:59:38.026809Z", + "updated_at": "2020-07-22T14:59:38.31338Z", + "banned": false, + "online": false, + "image": "https://images-na.ssl-images-amazon.com/images/M/MV5BMjA3NjYzMzE1MV5BMl5BanBnXkFtZTgwNTA4NDY4OTE@._V1_UX172_CR0,0,172,256_AL_.jpg", + "name": "Ana De Armas" + }, + "role": "member", + "created_at": "2020-10-01T08:49:32.905053Z", + "updated_at": "2020-10-01T08:49:32.905053Z", + "banned": false, + "shadow_banned": false + } + ], + "member_count": 2, + "config": { + "created_at": "2020-04-15T14:57:17.00966Z", + "updated_at": "2021-05-25T14:25:30.405621Z", + "name": "messaging", + "typing_events": true, + "read_events": true, + "connect_events": true, + "search": true, + "reactions": true, + "replies": true, + "mutes": true, + "uploads": true, + "url_enrichment": true, + "custom_events": false, + "push_notifications": true, + "message_retention": "infinite", + "max_message_length": 5000, + "automod": "disabled", + "automod_behavior": "flag", + "blocklist": "profanity_en_2020_v1", + "blocklist_behavior": "block", + "automod_thresholds": {}, + "commands": [ + { + "name": "giphy", + "description": "Post a random gif to the channel", + "args": "[text]", + "set": "fun_set" + } + ] + }, + "name": "test" +} \ No newline at end of file diff --git a/packages/stream_chat/test/src/core/models/event_test.dart b/packages/stream_chat/test/src/core/models/event_test.dart index 7ebd82fa..0cd9a0ad 100644 --- a/packages/stream_chat/test/src/core/models/event_test.dart +++ b/packages/stream_chat/test/src/core/models/event_test.dart @@ -54,5 +54,53 @@ void main() { }, ); }); + + test('copyWith', () { + final event = Event.fromJson(jsonFixture('event.json')); + var newEvent = event.copyWith(); + expect(newEvent.type, 'type'); + expect(newEvent.cid, 'cid'); + expect(newEvent.connectionId, 'connectionId'); + expect(newEvent.createdAt, isA()); + expect(newEvent.me, isA()); + expect(newEvent.user, isA()); + expect(newEvent.isLocal, false); + + newEvent = event.copyWith( + type: 'test', + cid: 'test', + connectionId: 'test', + extraData: {}, + user: User(id: 'test'), + channelId: 'test', + totalUnreadCount: 2, + channelType: 'testtype', + ); + + expect(newEvent.channelType, 'testtype'); + expect(newEvent.totalUnreadCount, 2); + expect(newEvent.type, 'test'); + expect(newEvent.channelId, 'test'); + expect(newEvent.cid, 'test'); + expect(newEvent.connectionId, 'test'); + expect(newEvent.extraData, {}); + expect(newEvent.user!.id, 'test'); + }); + + group('eventChannel', () { + test('should parse json correctly', () { + final eventChannel = + EventChannel.fromJson(jsonFixture('event_channel.json')); + expect(eventChannel.type, 'messaging'); + expect(eventChannel.cid, + 'messaging:!members-v9ktpgmYysZA-MjgC-GMoeEawFHSelkOdTu6JGxFZWU'); + expect(eventChannel.createdBy!.id, 'super-band-9'); + expect(eventChannel.frozen, false); + expect(eventChannel.members!.length, 2); + expect(eventChannel.memberCount, 2); + expect(eventChannel.config, isA()); + expect(eventChannel.name, 'test'); + }); + }); }); } From 875eda8cb5566337bc9bd6fa0e2c88a08171e5eb Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 17 Jun 2021 11:27:31 +0200 Subject: [PATCH 09/11] Update packages/stream_chat/lib/src/core/models/mute.dart Co-authored-by: Sahil Kumar --- packages/stream_chat/lib/src/core/models/mute.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/stream_chat/lib/src/core/models/mute.dart b/packages/stream_chat/lib/src/core/models/mute.dart index 4b14ad01..857b34a1 100644 --- a/packages/stream_chat/lib/src/core/models/mute.dart +++ b/packages/stream_chat/lib/src/core/models/mute.dart @@ -6,9 +6,7 @@ import 'package:stream_chat/src/core/util/serializer.dart'; part 'mute.g.dart'; /// The class that contains the information about a muted user -@JsonSerializable( - createToJson: false, -) +@JsonSerializable(createToJson: false) class Mute { /// Constructor used for json serialization Mute({ From 6a2efb18e44f9447e4781178fa8ada09ca2fe148 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 17 Jun 2021 15:01:45 +0530 Subject: [PATCH 10/11] Update packages/stream_chat/test/src/core/models/reaction_test.dart --- .../test/src/core/models/reaction_test.dart | 30 ++++--------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/packages/stream_chat/test/src/core/models/reaction_test.dart b/packages/stream_chat/test/src/core/models/reaction_test.dart index cfe9f69e..b603477c 100644 --- a/packages/stream_chat/test/src/core/models/reaction_test.dart +++ b/packages/stream_chat/test/src/core/models/reaction_test.dart @@ -77,34 +77,16 @@ void main() { userId: 'test', ); - expect( - newReaction.type, - 'lol', - ); + expect(newReaction.type, 'lol'); expect( newReaction.createdAt, DateTime.parse('2021-01-28T22:17:31.108742Z'), ); - expect( - newReaction.extraData, - {}, - ); - expect( - newReaction.messageId, - 'test', - ); - expect( - newReaction.score, - 2, - ); - expect( - newReaction.user, - User(id: 'test'), - ); - expect( - newReaction.userId, - 'test', - ); + expect(newReaction.extraData, {}); + expect(newReaction.messageId, 'test'); + expect(newReaction.score, 2); + expect(newReaction.user, User(id: 'test')); + expect(newReaction.userId, 'test'); }); test('merge', () { From a98148e0db4a2f603e2bc36818b879d2e1c8efdd Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 17 Jun 2021 15:01:53 +0530 Subject: [PATCH 11/11] Update packages/stream_chat/test/src/core/models/reaction_test.dart --- .../test/src/core/models/reaction_test.dart | 30 ++++--------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/packages/stream_chat/test/src/core/models/reaction_test.dart b/packages/stream_chat/test/src/core/models/reaction_test.dart index b603477c..518a223e 100644 --- a/packages/stream_chat/test/src/core/models/reaction_test.dart +++ b/packages/stream_chat/test/src/core/models/reaction_test.dart @@ -103,34 +103,16 @@ void main() { ), ); - expect( - newReaction.type, - 'lol', - ); + expect(newReaction.type, 'lol'); expect( newReaction.createdAt, DateTime.parse('2021-01-28T22:17:31.108742Z'), ); - expect( - newReaction.extraData, - {}, - ); - expect( - newReaction.messageId, - 'test', - ); - expect( - newReaction.score, - 2, - ); - expect( - newReaction.user, - User(id: 'test'), - ); - expect( - newReaction.userId, - 'test', - ); + expect(newReaction.extraData, {}); + expect(newReaction.messageId, 'test'); + expect(newReaction.score, 2); + expect(newReaction.user, User(id: 'test')); + expect(newReaction.userId, 'test'); }); }); }