V5 (#1222)
* chore(flutter): change BoxFit of VLC player * chore(flutter): remove unused imports * chore(flutter sample): tweak breakpoints, ignore some lints * chore(flutter): minor code readability improvements * chore(flutter): extract out platform_widget_builder to its own "package" * fix(flutter): fix a theme bug with PlatformDialog * chore(persistence): test plugin on macOS * Generated the macos runner for the example * Re-generated the android runner because it was using the v1 embedding * chore(persistence): test plugin on web * chore(persistence): add Windows runner to example * chore(persistence): add linux runner to example * feat(flutter): branded context menus * chore(flutter): fix bug where lines would be shown in between menu items * chore(flutter): import/export fixes * chore(flutter): move file * chore(flutter): /src/channel Also refactors several /channel widgets to use class widgets instead of methods. Some methods, however, have been left as those cases do actually produce cleaner code. chore(flutter): fix bad directory placement chore(flutter): fix bad directory placement * chore(flutter): more directory organization * chore(flutter): navigator improvements * chore(flutter): void async improvements * chore(flutter): fix imports/exports * docs(flutter): documentation updates for /attachment * docs(flutter): doc updates For: * /avatars * /bottom_sheets * /channel * feat(flutter): selectable message text on web & desktop * Squashed commit of the following: commit 50b249edb6b2ee2d744e4e00e97f81979026aab4 Author: GroovinChip <[email protected]> Date: Wed Mar 16 14:55:05 2022 -0400 chore(flutter): wrapping up docs commit 7d289ae45e20c0109bcdb4496f7b693e2adc4ef9 Author: GroovinChip <[email protected]> Date: Wed Mar 16 14:42:09 2022 -0400 chore(flutter): more docs & typedefs commit 6b36f6f3864f15b52e441d58ee7e62577ff8f843 Author: GroovinChip <[email protected]> Date: Wed Mar 16 14:22:34 2022 -0400 chore(flutter): more doc fixes commit 1a9a6de3c836e9ee5d6373033f1d9a7da830bddc Merge: 59188f5d 88abf99f Author: GroovinChip <[email protected]> Date: Wed Mar 16 13:17:52 2022 -0400 Merge branch 'desk_web_dev' into utils commit 59188f5d9c1dd68edd531086cdfd9d42faf93fc8 Author: GroovinChip <[email protected]> Date: Wed Mar 16 12:48:16 2022 -0400 chore(flutter): add todo commit 9b4a986ca5757f284677eb5335637d11ccb1d642 Author: GroovinChip <[email protected]> Date: Wed Mar 16 12:43:12 2022 -0400 chore(flutter): more docs and typedefs updates commit 8786d2dd82b94f673b36371fb2b33a1ebcc9840a Author: GroovinChip <[email protected]> Date: Wed Mar 16 12:14:14 2022 -0400 chore(flutter): more typedef and doc template updates commit 9e906beb0e7a054c13a32c8c8c5b0e2a9e27bb21 Author: GroovinChip <[email protected]> Date: Wed Mar 16 10:46:04 2022 -0400 chore(flutter): create /uitils and move files Fixes subsequent imports/exports * chore(flutter): update file_selector plugin * chore(flutter): include utils/typedefs.dart in library export * Squashed commit of the following: commit 501228afa614b0d740858dec1ebedd3f671e2c96 Author: GroovinChip <[email protected]> Date: Thu Mar 17 16:18:12 2022 -0400 feat(flutter): ensure fullscreen media feature works on ALL platforms commit cd0aab92bc7d90af03258829a5aae66125578af5 Author: GroovinChip <[email protected]> Date: Thu Mar 17 14:26:48 2022 -0400 feat(flutter): working conditional import for initializing VLC * fix(flutter): remove stray import causing web to break * chore(flutter): ensure context menus can show on web in sample * feat(flutter) FullScreenMedia context menus for Web * feat(flutter): branded context menus * chore(flutter): no success dialog on file download (web) * chore(flutter): remove platform UI packages * chore(flutter): properly show/hide delete message menu item Also deletes deprecated PlatformDialog * feat(flutter): 'view info' channel preview context menu * feat(flutter): more menu actions for ChannelPreview Also new ConfirmationDialog and add missing docs * feat(flutter/localizations): translations related to channel mutes * chore(flutter): remove prints and fix super.didChangeDependencies order * chore(flutter): rename some things in ChannelBottomSheet * chore(flutter): more sensible name in TypingIndicator * chore(flutter): remove unused code in MessageWidget * feat(flutter): ChannelInfoDialog * chore(flutter): organize files more Also refactors out some internal MessageListView widgets * fix(flutter): fix render overflow issue * chore(flutter): move MediaListView * chore(flutter): remove unused imports * fix(flutter): fix weird share menu placement on macos * chore(flutter): clean up fullscreenmedia conditional imports * chore(flutter): adjust package exports * chore(flutter): update dart_vlc * chore(flutter): clean up platform checks * chore(flutter): run flutter format on lib * chore(flutter): minor sample cleanup * chore(flutter): ensure vlc doesn't get initialized in non-desktop testing environments * test(flutter): reformat existing tests * fix(flutter): pass onThreadReplyTap down to ThreadReplyButton * First round of new tests commit a90bed427521123fdaa4c5e276744a224fac2b68 Author: GroovinChip <[email protected]> Date: Thu Apr 7 12:34:19 2022 -0400 test(flutter): Username test commit d7bc179c20eae2713c9248191518bf1d955104a9 Author: GroovinChip <[email protected]> Date: Thu Apr 7 12:30:47 2022 -0400 chore(flutter): remove unused imports commit 09c9517de2917dc5ccd7de019b50a7875386991c Author: GroovinChip <[email protected]> Date: Thu Apr 7 12:29:58 2022 -0400 test(flutter): ThreadSeparator test commit 9422d1129211aaaac9a51ca4d29fe94bde06593c Author: GroovinChip <[email protected]> Date: Thu Apr 7 12:19:43 2022 -0400 chore(flutter): rename LoadingIndicator parameter commit 63af943a1a16e78a1e0377d76176420bd7e1fbc7 Author: GroovinChip <[email protected]> Date: Thu Apr 7 11:47:46 2022 -0400 test(flutter): FloatingDateDivider test commit d8e67cf6fca2b76ac091a9047104c0910d5fdfef Author: GroovinChip <[email protected]> Date: Tue Mar 29 15:19:39 2022 -0400 test(flutter): InputAttachment tests commit d2b7d5dd3304c8be6f74bf5b0281d7a95dd027ec Author: GroovinChip <[email protected]> Date: Tue Mar 29 14:41:40 2022 -0400 test(flutter): DmCheckbox tests commit 01567f235a2f00880bb530b232489e3790159b25 Author: GroovinChip <[email protected]> Date: Tue Mar 29 14:16:08 2022 -0400 chore(flutter): remove unused imports commit c9625858e840df6082506ae9374f1d2710053cbd Author: GroovinChip <[email protected]> Date: Tue Mar 29 14:15:44 2022 -0400 test(flutter): CountdownButton tests commit d770474bb11ee8b36a3b0e18db31695fd812a6b3 Author: GroovinChip <[email protected]> Date: Tue Mar 29 14:11:37 2022 -0400 test(flutter): CommandButton tests commit 95e63706d1dd971373d39d471894a38bb2a634f2 Author: GroovinChip <[email protected]> Date: Tue Mar 29 14:07:43 2022 -0400 test(flutter): ClearInputItem tests commit 4156586945c91408cb7943b6c57c2ae560a2857c Author: GroovinChip <[email protected]> Date: Tue Mar 29 14:03:59 2022 -0400 test(flutter): AttachmentButton tests commit bba042806326999aabf338636c6e33900de86160 Author: GroovinChip <[email protected]> Date: Tue Mar 29 13:00:42 2022 -0400 test(flutter): golden test for SendButton commit e2cd0f00b9eeb8d81399f6316edb298234de12dc Author: GroovinChip <[email protected]> Date: Tue Mar 29 12:56:52 2022 -0400 chore(flutter): deal with lints commit b4e045f9cbd54c4d42c3f30acfe72d5f8ccf9d82 Author: GroovinChip <[email protected]> Date: Tue Mar 29 12:56:00 2022 -0400 test(flutter): SendButton test commit 4e3d5db0bddb97e508fcdda2e7272fe31e70808f Author: GroovinChip <[email protected]> Date: Tue Mar 29 12:38:21 2022 -0400 test(flutter): KeyboardShortcutRunner tests commit 0dfd7a0bd6fd6bc76902e87f62ac29da0b01bac6 Author: GroovinChip <[email protected]> Date: Tue Mar 29 12:17:30 2022 -0400 test(flutter): UploadProgressIndicator commit ec50c8aea716bdc19e4308e367c8331211c61ea3 Author: GroovinChip <[email protected]> Date: Tue Mar 29 11:47:53 2022 -0400 test(flutter): SendingIndicator tests commit e87bd1450fb5bfb713a867c7e831968f76428848 Author: GroovinChip <[email protected]> Date: Tue Mar 29 11:32:35 2022 -0400 test(flutter): more gallery tests commit 93d46ca649277fe6d289a70f0bdd23584fd0ab94 Author: GroovinChip <[email protected]> Date: Tue Mar 29 11:17:29 2022 -0400 test(flutter): remove bad mock commit c7b03a39f0f3ca7a334dfb908f3473b5e4deab38 Author: GroovinChip <[email protected]> Date: Tue Mar 29 10:45:45 2022 -0400 chore(flutter): minor refactor commit 33aeb7b5ed398287cb930f3b4702f47a82fce2c6 Author: GroovinChip <[email protected]> Date: Tue Mar 29 09:49:07 2022 -0400 test(flutter): MessageDialog tests commit 220b3ae591e135d9606254666e04d4771945d0ae Author: GroovinChip <[email protected]> Date: Tue Mar 29 09:42:51 2022 -0400 test(flutter): DeleteMessageDialog tests commit db508478bb96749971f563de87b6c2a49e1e4e57 Author: GroovinChip <[email protected]> Date: Mon Mar 28 14:46:41 2022 -0400 test(flutter): ConfirmationDialog tests commit e8172dad6bfe18f40b65554ef2c6c16d7437cb56 Author: GroovinChip <[email protected]> Date: Mon Mar 28 14:35:50 2022 -0400 test(flutter): ChannelInfoDialog test commit 04c21458a601af3c3f4a5fc5ce9e8b61493c208c Author: GroovinChip <[email protected]> Date: Mon Mar 28 13:57:02 2022 -0400 test(flutter): DownloadMenuItem tests commit afee1dace543e2fef8543f9b035f684b2ee00f3b Author: GroovinChip <[email protected]> Date: Mon Mar 28 13:53:21 2022 -0400 test(flutter): StreamChatContextMenuItem tests commit 4616b1a973d0cf5224b5a71914c9908339c8462a Author: GroovinChip <[email protected]> Date: Mon Mar 28 13:02:07 2022 -0400 test(flutter): golden test for ErrorAlertSheet commit 22fb8241ae333f57ade8e8550f87695929836b2b Author: GroovinChip <[email protected]> Date: Mon Mar 28 12:59:01 2022 -0400 test(flutter): golden test for EditMessageSheet commit 0be79964827f344ba66e99cb9e5bd3d627aed01d Author: GroovinChip <[email protected]> Date: Mon Mar 28 12:56:08 2022 -0400 test(flutter): golden test for AttachmentModalSheet commit 0ae842a98143478885bc211c788353c8bca57b40 Author: GroovinChip <[email protected]> Date: Mon Mar 28 12:53:26 2022 -0400 test(flutter): GroupAvatar tests commit 697d294c6c7e1bba1d9089a53d5c60d8609ea64e Author: GroovinChip <[email protected]> Date: Mon Mar 28 12:30:25 2022 -0400 test(flutter): UserAvatar tests commit c03ba4124068c83d3a49c4db00ca18a659801c23 Author: GroovinChip <[email protected]> Date: Mon Mar 28 11:04:55 2022 -0400 test(flutter): ErrorAlertSheet test commit 3414f28530b0e22614b83af20361f21dd4967fae Author: GroovinChip <[email protected]> Date: Mon Mar 28 10:45:37 2022 -0400 test(flutter): EditMessageSheet test commit b2962b641dfbf14c11d3da7f80a4be27f9980d90 Author: GroovinChip <[email protected]> Date: Mon Mar 28 10:37:18 2022 -0400 test(flutter): AttachmentModalSheet test test(flutter): AttachmentModalSheet test chore(flutter): update exports commit 7d7e278692c65dea84e7ef3b2d3c1311ebb28408 Author: GroovinChip <[email protected]> Date: Mon Mar 28 09:52:29 2022 -0400 test(flutter): more organization commit 4479b649835acc62d8a0553f9505a0af8077abfc Author: GroovinChip <[email protected]> Date: Mon Mar 28 09:33:06 2022 -0400 test(flutter): tweak AttachmentHandler tests commit b4a41106567e3c08105ce8dc272b1ebf40b3b0bb Author: GroovinChip <[email protected]> Date: Mon Mar 28 09:24:00 2022 -0400 chore(flutter): streamline attachment handling * MobileAttachmentHandler for streamlining related code for mobile * Break out DesktopAttachmentHandler into its own file * Update minSdk version in Android runner commit bfb06d31b79cd941d8b611c7e89e2d7728a394cb Merge: a44b3b39 15c83d03 Author: GroovinChip <[email protected]> Date: Fri Mar 25 13:00:27 2022 -0400 Merge branch 'desk_web_dev' into tests commit a44b3b390adc25a00d1597bb1460973e8555fa9e Author: GroovinChip <[email protected]> Date: Fri Mar 25 12:59:14 2022 -0400 chore(flutter): start cleaning up test dir commit de104a3491d942d12f72dd66152b62c6e8b10a5b Author: GroovinChip <[email protected]> Date: Fri Mar 25 12:56:48 2022 -0400 test(flutter): VideoAttachment test commit 4748a1c081a3272f7fdbdeb69c501344e221e01e Author: GroovinChip <[email protected]> Date: Fri Mar 25 12:52:30 2022 -0400 test(flutter): UrlAttachment test commit 54408ef70f07c60adf8350553fdf3173e5edd7c7 Author: GroovinChip <[email protected]> Date: Fri Mar 25 12:48:24 2022 -0400 test(flutter): ImageGroup test commit 811cff069e490c6bd03be0c0ac2f5ec86fb990e9 Author: GroovinChip <[email protected]> Date: Fri Mar 25 12:46:04 2022 -0400 test(flutter): ImageAttachment test commit a72677976c6524e76793432b0520e99cac4e7a62 Author: GroovinChip <[email protected]> Date: Fri Mar 25 12:34:06 2022 -0400 test(flutter): GiphyAttachment test commit 32ddac022e2c149726b4b6607f41850d556055b8 Author: GroovinChip <[email protected]> Date: Fri Mar 25 12:28:01 2022 -0400 test(flutter): FileAttachment test commit 6534958cab775be1fb9bda56e67caa4746aa1502 Author: GroovinChip <[email protected]> Date: Fri Mar 25 12:14:25 2022 -0400 test(flutter): AttachmentError test commit 718a83c10c4e883ce01c9c002ced24de671d30b9 Author: GroovinChip <[email protected]> Date: Fri Mar 25 12:06:43 2022 -0400 test(flutter): AttachmentUploadStateBuilder test commit a05108c460e36b2e425e4ec06f8bf408b0c20e97 Author: GroovinChip <[email protected]> Date: Fri Mar 25 11:44:34 2022 -0400 chore(flutter): minor cleanup commit 6e73038ac3714a2bd96f8c587af7f743bf2b2023 Author: GroovinChip <[email protected]> Date: Fri Mar 25 11:43:23 2022 -0400 test(flutter): AttachmentTitle test commit c6ee52ec951877feef31dc1427eec3bfc2bd8fcb Author: GroovinChip <[email protected]> Date: Fri Mar 25 11:43:11 2022 -0400 test(flutter): minor cleanup commit 09845cd845aa8c546043f4ae04805a8e6f53f61c Author: GroovinChip <[email protected]> Date: Fri Mar 25 11:42:52 2022 -0400 chore(flutter): improve device segmentation & vlc init check commit 172e6b25a064b5147b7641f29ebff3c920156f70 Author: GroovinChip <[email protected]> Date: Fri Mar 25 10:37:43 2022 -0400 test(flutter): attachment_handler tests commit 5f5a91c70cd7c069f39518f1f50bb74ab484c7e9 Author: GroovinChip <[email protected]> Date: Wed Mar 23 13:55:27 2022 -0400 test(flutter): test PlatformWidgetBuilder & DesktopWidgetBuilder commit 5a457b7557cb4127b74ee022389a24e5e9150601 Author: GroovinChip <[email protected]> Date: Wed Mar 23 13:55:05 2022 -0400 chore(flutter): make base platform widgets testable Also fix environment check in stream_chat.dart commit 88fb16018103c581236aeebd978e705b223b2243 Author: GroovinChip <[email protected]> Date: Wed Mar 23 11:59:19 2022 -0400 chore(flutter): add readme to conditional_parent_widget library commit e9307f8a6a5639d59358c245f033f9d9b209fe20 Author: GroovinChip <[email protected]> Date: Wed Mar 23 11:54:54 2022 -0400 test(flutter): ConditionalParentBuilder tests * chore(flutter): add thumblr dependency * chore(flutter): fix typos * chore(flutter): properly order super calls * feat(flutter) video thumbnails on desktop * chore(flutter): fix incorrect file name * chore(flutter): fix docs for generateVideoThumbnail * chore(flutter): remove incorrect comment * chore(flutter): run flutter format * chore(flutter): ignore lint * chore(flutter): flutter format * chore(flutter): fix tests * fix(flutter): fix MessageListView bug caused by rebase * chore(flutter): migrate desktop stuff to v4/stream_message_input.dart * chore(flutter): migrate over desktop changes for message replies * chore(flutter): fix message replies on desktop * chore(flutter): address lints * chore(flutter): update dart_vlc * chore(flutter): melos clean & update photo_view * fix(ui): port #1118 * fix(ui): use attachmentButtonBuilder * fix(ui): fix file attachment * format * fix(ui): fix message bottom row * chore(flutter sample): use modern window look * chore(flutter): pass userAvatarBuilder through to MessageWidgetContent Also pass onUserAvatarTap & userAvatarBuilder through to UserAvatarTransform * chore: fix MessageWidget menu actions * fix(flutter): fix "enter" sending empty messages in StreamMessageInput * fix(flutter): fix Giphys not loading in quoted messages * chore(flutter): update thumblr * feat(flutter): keyboard navigation for gallery items * fix(ui): fix double date divider * fix(ui): add scroll to bottom back * fix(ui): use mouse region * fix(ui): remove backbutton in desktop example * fix(ui): rename full screen media widget * feat(flutter): elevation prop for gallery header * chore(flutter): update dart_vlc * fix(flutter): fix "show in chat" showing when it shouldn't * fix(flutter): fix "show in chat" for mobile * docs(flutter): minor doc update * chore(flutter): add onMessageSwiped in example app * chore(flutter): pass usernameBuilder through to BottomRow * fix(flutter): hacky fix for chonky link previews * fix(flutter): fix chonky text messages * feat(flutter): press "esc" to close gallery Also refactors KeyboardShortcutRunner API * chore(flutter): fix innaccurate name * fix(ui): fix attachment + long text sizing * add key to channelpage * fix(ui): better example * fix format * fix example * chore(flutter): revert modern window look * improvement(flutter): improve `GalleryNavigationItem` * Make buttons more visible * Spacing from the sides of the screen * fix video thumbnail * fix split view * fix(ui): fix giphy in thread * feat(flutter): desktop message reactions commit 4b880ecb6d4dcbf315a7d41d863174817a9c530a Author: Reuben Turner <[email protected]> Date: Thu Jun 9 12:25:21 2022 -0400 fix(flutter): fixes for desktop reactions * Fix reactions for reverse messages * Ensure reactions near the edges of MessageListView show properly commit f511513f8dbb272397e81d08bad33ee60108d738 Author: Salvatore Giordano <[email protected]> Date: Thu Jun 9 16:43:03 2022 +0200 fix(ui): fix DesktopReactionBuilder and Portal commit c4885648330552f5212c5ba6b771c0f07023f6ae Merge: 2b710a2b 72b34c21 Author: Reuben Turner <[email protected]> Date: Wed Jun 8 14:12:44 2022 -0400 Merge branch 'desk_web_dev' into desktop_reactions commit 2b710a2bb610326123d5b7f75c26caa705114c9b Author: Reuben Turner <[email protected]> Date: Mon Jun 6 12:19:12 2022 -0400 chore(flutter): add debug props commit e24dabc1de12da8dce697b6d4e1a3617e9835549 Author: Reuben Turner <[email protected]> Date: Mon Jun 6 12:00:03 2022 -0400 feat(flutter): first pass at desktop reactions popup on mouse hover * fix(flutter): potential fix for #1199 * fix(flutter): fix non-reversed reactions placement * refactor(flutter): extract bottom reaction, stacked reaction with debug props * fix(flutter): fixes for desktop reactions * Fix bottom row being rendered above reaction buttons * Fix padding issues related to avatars * chore(flutter): add back lost changes from 2b1fb6a Also removed commented code * chore(flutter): stacked reactions update * Show "You" if userId matches the reaction username (per design) * Ensure long names don't throw off alignment * chore(flutter): format * fix(ui): fix mime type generation * chore(flutter): tweak desktop video * chore(flutter): add some missing things from develop * merge develop * fix merge * fix merge * format * fix tests * increate test action timeout * remove test * refactor(ui,core): remove deprecated code and cleanup * run builder * update coverage threasholds * refactor(ui): remove arrow function from countdown button * Update packages/stream_chat_flutter/lib/src/message_input/countdown_button.dart * Update packages/stream_chat_flutter/lib/src/message_input/countdown_button.dart * update comment * fix(ui): fix attachment + link solution * fix(ui): fix attachment + link solution * chore(flutter) update changelog and version * chore(localizations): update changelog and versions * chore(llc,core,ui,persistence,localizations): update changelog and pubspec * chore(llc,core,ui,persistence,localizations): update changelog and pubspec * fix example * fix deps * fix(ui): fix enter sending the message while in slowmode * fix(ui): fix reaction list * fix web * fix(ui): fix image download when using assetUrl * fix(ui): fix typo in changelog * fix(ui): fix gallery navigation * fix(ui): fix giphy sending size * fix(ui): add keyboard shorcuts to gallery view * fix(ui): fix gallery footer * fix(core): allow scroll notification bubbling in lazy load scroll view * fix(ui): fix lazy load scroll view * fix(ui): fix loading to unread position * fix(ui): fix last message preview * chore(ui): update changelog * fix tests * fix(llc): fix connecting while connecting and disconneting (#1237) * fix(llc): fix connecting while connecting and disconneting * chore(llc): update changelog * chore(llc): add test * chore(llc): improve test * fix(llc): _resetRequestFlags regardless of the connection status * feat(llc): add support for AttachmentFileUploaderProvider. (#1246) * feat(llc): add support for `AttachmentFileUploaderProvider`. Signed-off-by: xsahil03x <[email protected]> * chore(llc): update CHANGELOG.md Signed-off-by: xsahil03x <[email protected]> * refactor(llc): Remove deprecated attachmentFileUploader field. Signed-off-by: xsahil03x <[email protected]> * port no localization * fix(ui): fix jiffy locale initialization (#1255) * fix(ui): fix jiffy locale initialization * chore(ui): update changelog * fix(ui): cleanup * chore(llc,core,ui,persistence,localizations): align changelog * chore(llc,core,ui,persistence,localizations): add links to 4.x changelogs * fix(ui): fix date divider not showing (#1259) * fix(ui): fix date divider not showing * chore(ui): update changelog * chore(ui): minor changes Signed-off-by: xsahil03x <[email protected]> * fix(ui): fix separator Signed-off-by: xsahil03x <[email protected]> Co-authored-by: Sahil Kumar <[email protected]> * chore(ui): add contextmenu requirements for web (#1261) * fix unread separator * feat(ui): `StreamChatConfiguration` class (#1128) * feat: StreamChatConfiguration class See #1125 for more details * chore(flutter): update changelog * fix analysis * cleanup * feat(ui): add enforceUniqueReactions to `StreamChatConfiguration` widget * add tests * refactor(ui): rename StreamChatConfigurationProvider and StreamChatConfiguration * refactor(ui): rename StreamChat.config to streamChatConfigData * refactor(ui): make enforceUniqueReactions non nullable * chore(ui): fix analysis errors * refactor(ui): make config fields non nullable * chore(ui): format Co-authored-by: Salvatore Giordano <[email protected]> * feat(ui, core): add StreamAutocomplete (#1263) * feat(ui, core): add stream_autocomplete.dart Signed-off-by: xsahil03x <[email protected]> * refactor(core, ui): refactor message input controller Signed-off-by: xsahil03x <[email protected]> * fix(ui): minor fixes Signed-off-by: xsahil03x <[email protected]> * feat(ui): add StreamAutocompleteOptions widget Signed-off-by: xsahil03x <[email protected]> * Update packages/stream_chat_flutter/lib/src/autocomplete/stream_autocomplete.dart * fix(ui): cleanup * chore(core, ui): cleanup Signed-off-by: xsahil03x <[email protected]> * chore(ui): ignore no empty block * chore(ui): more cleanup Signed-off-by: xsahil03x <[email protected]> * fix(ui): fix command button for bigger screens, other fixes. Signed-off-by: xsahil03x <[email protected]> Co-authored-by: Salvatore Giordano <[email protected]> * fix(ui): increase default file limit to 100MB (#1279) * fix(ui): increase default file limit to 100MB * Update packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart * fix(ui): export kDefaultMaxAttachmentSize and use it in `StreamAttachmentPicker` default * feat(ui): show dialog after clicking on the camera button and permission is denied (#1262) * feat(ui): show dialog after clicking on the camera button and permission is denied * chore(ui): update changelog * Remove permission_handler plugin and refactor * cleanup * cleanup * add tests * fix(ui): reset the permission state on resume * cleanup * fix concurrent calls * fix(ui): cleanup * fix(ui): add try catch * fix(llc, ui): copy file to tempdir before uploading a file and do not serialize bytes (#1285) * fix(llc, ui): copy file to tempdir before uploading a file and do not serialize bytes * fix(llc): do not save failed messages with attachments on web * fix(llc): replace every with any * chore(llc): add test * fix analysis * fix analysis * chore(llc,core,ui,persistence): align changelog with v4 * fix(ui): do not linkify system message mentions * chore(llc,core,ui,persistence,localizations): update changelog and pubspec (#1289) * chore(ui): update deps * chore(llc,core,ui,persistence,localizations): update changelog and pubspec * chore(ui): publish beta.2 * feat(core,ui): add StreamMemberListView, StreamMemberGridView, and StreamMemberListController (#1291) * feat(core,ui): add StreamMemberListView, StreamMemberGridView, and StreamMemberListController * chore(core,ui): update changelog * fix(ui): fix exports * chore(ui): add tests * chore(ui): add StreamMemberGridTile typedef * chore(ui): minor changes Signed-off-by: xsahil03x <[email protected]> Co-authored-by: Sahil Kumar <[email protected]> * fix(ui): do not send empty message * refactor(ui,localization): removed emoji picker and connected (#1292) * refactor(ui,localization): removed emoji picker and connected * chore(ui,localizations): update changelog * chore(repo): update ui coverage threashold * doc(ui): add autocomplete_triggers guide * chore(ui): add tests for isOnlyEmoji * chore(ui): add tests for isOnlyEmoji * feat(ui): add `StreamAutocompleteTrigger.triggerOnlyAfterSpace` * fix(llc): Fix `Channel.removeMessage` not able to remove thread message. (#1294) Signed-off-by: xsahil03x <[email protected]> * chore(ui): flutter format Signed-off-by: xsahil03x <[email protected]> * fix(ui): fix `stopTyping` unhandled exceptions when network is off or spotty. (#1296) * feat(llc, ui): Introduce `keyStrokeHandler` to properly handle keyStrokes. Signed-off-by: xsahil03x <[email protected]> * chore(ui): update CHANGELOG.md Signed-off-by: xsahil03x <[email protected]> * test(llc): add key_stroke_handler_test.dart Signed-off-by: xsahil03x <[email protected]> * chore(ui): update CHANGELOG.md Signed-off-by: xsahil03x <[email protected]> * fix(core): only handle the channel list event if the state is success. Signed-off-by: xsahil03x <[email protected]> * feat(llc): add `hide_history` flag in `channel.addMembers`. Signed-off-by: xsahil03x <[email protected]> * refactor(llc): Convert positional argument to optional arguments Signed-off-by: xsahil03x <[email protected]> * test(llc): update tests Signed-off-by: xsahil03x <[email protected]> * perf: improve image resizing * fix(core): use copyWith while setting controller items. Signed-off-by: xsahil03x <[email protected]> * feat(ui): Added `thumbnailSize`, `thumbnailResizeType`, and `thumbnailCropType` params to `StreamMessageWidget` and `StreamAttachmentPicker` to customize the appearance of image thumbnails. Signed-off-by: xsahil03x <[email protected]> * fix analysis * Release v4.5.0 (#1308) * chore(llc, ui, core): bump version to v4.5.0 Signed-off-by: xsahil03x <[email protected]> * chore(ui, core): update CHANGELOG.md Signed-off-by: xsahil03x <[email protected]> Signed-off-by: xsahil03x <[email protected]> * third party video integration * fix llc * refactor: clean up and add docs * chore(llc): update changelog * chore(llc): add tests * chore(llc): add more tests * fix analysis * chore(llc): add more tests * chore(llc): add more tests * fix(llc): only start listening to event once connected. Signed-off-by: xsahil03x <[email protected]> * chore(llc): update CHANGELOG.md Signed-off-by: xsahil03x <[email protected]> * chore(llc): move files to correct folders. Signed-off-by: xsahil03x <[email protected]> * fix(ui): Fix message text hiding because of a flutter bug (#1327) * fix(ui): remove clip * chore(ui): update changelog * cleanup * fix(ui): hitting "enter" on the android keyboard sends the message instead of going to a new line. Signed-off-by: xsahil03x <[email protected]> * feat(ui): add support for additional text field params in message input. Signed-off-by: xsahil03x <[email protected]> * fix analysis * remove print * chore(llc,core,ui): update pubspec and changelogs (#1333) * fix(ui): show placeholder for web video thumbs * fix file download on web * fix reply and show buttons * remove tests * treat svg as files * fix(ui): change default image resize to clip * solve some todos * polish v5 fixing analysis issues * feat(ui): stream attachment picker bottom sheet (#1336) * refactor(ui): improve stream_attachment_handler.dart, add stream_attachment_picker_bottom_sheet.dart Signed-off-by: xsahil03x <[email protected]> * feat(ui): add copyWith in command_button.dart Signed-off-by: xsahil03x <[email protected]> * chore(ui): remove permission_manager.dart Signed-off-by: xsahil03x <[email protected]> * fix(ui): some fixes Signed-off-by: xsahil03x <[email protected]> * fix(ui): more fixes Signed-off-by: xsahil03x <[email protected]> * chore(ui): fix lints, add doc comments Signed-off-by: xsahil03x <[email protected]> * chore(ci): update flutter version Signed-off-by: xsahil03x <[email protected]> * chore(ui): more fixes Signed-off-by: xsahil03x <[email protected]> * chore(ui): more fixes Signed-off-by: xsahil03x <[email protected]> * chore(ui): more fixes Signed-off-by: xsahil03x <[email protected]> * chore(ci): update melos and flutter version Signed-off-by: xsahil03x <[email protected]> Signed-off-by: xsahil03x <[email protected]> Co-authored-by: Salvatore Giordano <[email protected]> * remove todo * update changelog * update changelogs * revert * update coverage threasholds Signed-off-by: xsahil03x <[email protected]> Co-authored-by: GroovinChip <[email protected]> Co-authored-by: Sahil Kumar <[email protected]> Co-authored-by: Gordon Hayes <[email protected]> Co-authored-by: Sacha Arbonel <[email protected]>
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('AttachmentError test', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
child: child,
|
||||
),
|
||||
home: const Scaffold(
|
||||
body: Center(
|
||||
child: AttachmentError(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(Icon), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
group('AttachmentHandler Downloads', () {
|
||||
test('AttachmentHandler downloads image', () async {
|
||||
final attachment = Attachment(
|
||||
title: 'test image attachment',
|
||||
type: 'image',
|
||||
extraData: const {
|
||||
'mime_type': 'png',
|
||||
},
|
||||
);
|
||||
|
||||
final attachmentHandler = MockAttachmentHandler();
|
||||
|
||||
when(() => attachmentHandler.downloadAttachment(attachment))
|
||||
.thenAnswer((invocation) async => 'filePath');
|
||||
|
||||
expect(
|
||||
await attachmentHandler.downloadAttachment(attachment),
|
||||
'filePath',
|
||||
);
|
||||
});
|
||||
|
||||
test('AttachmentHandler downloads giphy', () async {
|
||||
final attachment = Attachment(
|
||||
title: 'test giphy attachment',
|
||||
type: 'giphy',
|
||||
extraData: const {
|
||||
'original':
|
||||
'https://giphy.com/gifs/nrkp3-dance-happy-3o7TKnCdBx5cMg0qti',
|
||||
},
|
||||
);
|
||||
|
||||
final attachmentHandler = MockAttachmentHandler();
|
||||
|
||||
when(() => attachmentHandler.downloadAttachment(attachment))
|
||||
.thenAnswer((invocation) async => 'filePath');
|
||||
|
||||
expect(
|
||||
await attachmentHandler.downloadAttachment(attachment),
|
||||
'filePath',
|
||||
);
|
||||
});
|
||||
|
||||
test('AttachmentHandler downloads video', () async {
|
||||
final attachment = Attachment(
|
||||
title: 'test video attachment',
|
||||
type: 'video',
|
||||
assetUrl: 'https://www.youtube.com/watch?v=lytQi-slT5Y',
|
||||
);
|
||||
|
||||
final attachmentHandler = MockAttachmentHandler();
|
||||
|
||||
when(() => attachmentHandler.downloadAttachment(attachment))
|
||||
.thenAnswer((invocation) async => 'filePath');
|
||||
|
||||
expect(
|
||||
await attachmentHandler.downloadAttachment(attachment),
|
||||
'filePath',
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('AttachmentTitle renders properly', (tester) async {
|
||||
final mockClient = MockClient();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: mockClient,
|
||||
streamChatThemeData: StreamChatThemeData.light(),
|
||||
child: child,
|
||||
),
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) {
|
||||
return Center(
|
||||
child: StreamAttachmentTitle(
|
||||
attachment: Attachment(
|
||||
title: 'Test Attachment',
|
||||
type: 'video',
|
||||
titleLink: 'https://www.youtube.com/watch?v=lytQi-slT5Y',
|
||||
ogScrapeUrl: 'https://www.youtube.com/watch?v=lytQi-slT5Y',
|
||||
),
|
||||
messageTheme: StreamChatTheme.of(context).ownMessageTheme,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(StreamAttachmentTitle), findsOneWidget);
|
||||
expect(find.text('Test Attachment'), findsOneWidget);
|
||||
expect(find.text('https://www.youtube.com/watch?v=lytQi-slT5Y'),
|
||||
findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'AttachmentUploadStateBuilder returns Offstage when message is sent',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: StreamChannel(
|
||||
channel: MockChannel(),
|
||||
child: StreamAttachmentUploadStateBuilder(
|
||||
attachment: Attachment(
|
||||
id: 'test',
|
||||
),
|
||||
message: Message(
|
||||
id: 'test',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(Offstage), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -3,11 +3,11 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'it should show file details',
|
||||
'Shows the file name',
|
||||
(WidgetTester tester) async {
|
||||
final channel = MockChannel();
|
||||
final channelState = MockChannelState();
|
||||
@@ -25,10 +25,10 @@ void main() {
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamFileAttachment(
|
||||
size: const Size(
|
||||
constraints: BoxConstraints.tight(const Size(
|
||||
300,
|
||||
300,
|
||||
),
|
||||
)),
|
||||
message: Message(),
|
||||
attachment: Attachment(
|
||||
type: 'file',
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'Shows GIPHY text',
|
||||
(WidgetTester tester) async {
|
||||
final channel = MockChannel();
|
||||
final channelState = MockChannelState();
|
||||
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
|
||||
final themeData = ThemeData();
|
||||
final streamTheme = StreamChatThemeData.fromTheme(themeData);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: streamTheme,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamGiphyAttachment(
|
||||
constraints: BoxConstraints.tight(const Size(
|
||||
300,
|
||||
300,
|
||||
)),
|
||||
message: Message(),
|
||||
attachment: Attachment(
|
||||
type: 'giphy',
|
||||
title: 'example.gif',
|
||||
imageUrl:
|
||||
'https://media.giphy.com/media/35H0pwQNaO2iLTnnBf/giphy.gif',
|
||||
extraData: const {
|
||||
'mime_type': 'gif',
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('GIPHY'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'Shows the image',
|
||||
(WidgetTester tester) async {
|
||||
final channel = MockChannel();
|
||||
final channelState = MockChannelState();
|
||||
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
|
||||
final themeData = ThemeData();
|
||||
final streamTheme = StreamChatThemeData.fromTheme(themeData);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: streamTheme,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamImageAttachment(
|
||||
messageTheme: streamTheme.ownMessageTheme,
|
||||
constraints: BoxConstraints.tight(const Size(
|
||||
300,
|
||||
300,
|
||||
)),
|
||||
message: Message(),
|
||||
attachment: Attachment(
|
||||
type: 'image',
|
||||
title: 'example.png',
|
||||
imageUrl:
|
||||
'https://logowik.com/content/uploads/images/flutter5786.jpg',
|
||||
extraData: const {
|
||||
'mime_type': 'png',
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(CachedNetworkImage), findsOneWidget);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'Shows 2 images',
|
||||
(WidgetTester tester) async {
|
||||
final channel = MockChannel();
|
||||
final channelState = MockChannelState();
|
||||
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
|
||||
final themeData = ThemeData();
|
||||
final streamTheme = StreamChatThemeData.fromTheme(themeData);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: streamTheme,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamImageGroup(
|
||||
messageTheme: streamTheme.ownMessageTheme,
|
||||
constraints: BoxConstraints.tight(const Size(
|
||||
300,
|
||||
300,
|
||||
)),
|
||||
message: Message(),
|
||||
images: [
|
||||
Attachment(
|
||||
type: 'image',
|
||||
title: 'example.png',
|
||||
imageUrl:
|
||||
'https://logowik.com/content/uploads/images/flutter5786.jpg',
|
||||
extraData: const {
|
||||
'mime_type': 'png',
|
||||
},
|
||||
),
|
||||
Attachment(
|
||||
type: 'image',
|
||||
title: 'example.png',
|
||||
imageUrl:
|
||||
'https://logowik.com/content/uploads/images/flutter5786.jpg',
|
||||
extraData: const {
|
||||
'mime_type': 'png',
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(CachedNetworkImage), findsNWidgets(2));
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'Shows the attachment title',
|
||||
(WidgetTester tester) async {
|
||||
final channel = MockChannel();
|
||||
final channelState = MockChannelState();
|
||||
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
|
||||
final themeData = ThemeData();
|
||||
final streamTheme = StreamChatThemeData.fromTheme(themeData);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: streamTheme,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamUrlAttachment(
|
||||
messageTheme: streamTheme.ownMessageTheme,
|
||||
hostDisplayName: 'Test',
|
||||
urlAttachment: Attachment(
|
||||
title: 'Flutter',
|
||||
titleLink: 'https://flutter.dev',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('Flutter'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -5,20 +5,21 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
class MockAttachmentDownloader extends Mock {
|
||||
ProgressCallback? progressCallback;
|
||||
DownloadedPathCallback? downloadedPathCallback;
|
||||
ProgressCallback? onReceiveProgress;
|
||||
Completer<String> completer = Completer();
|
||||
|
||||
Future<String> call(
|
||||
Attachment attachment, {
|
||||
ProgressCallback? progressCallback,
|
||||
DownloadedPathCallback? downloadedPathCallback,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
CancelToken? cancelToken,
|
||||
bool deleteOnError = true,
|
||||
Options? options,
|
||||
}) {
|
||||
this.progressCallback = progressCallback;
|
||||
this.downloadedPathCallback = downloadedPathCallback;
|
||||
this.onReceiveProgress = onReceiveProgress;
|
||||
return completer.future;
|
||||
}
|
||||
}
|
||||
@@ -408,123 +409,4 @@ void main() {
|
||||
verify(() => mockChannel.deleteMessage(message)).called(1);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'tapping on save in chat should call image downloader',
|
||||
(WidgetTester tester) async {
|
||||
final client = MockClient();
|
||||
final clientState = MockClientState();
|
||||
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
|
||||
|
||||
final imageDownloader = MockAttachmentDownloader();
|
||||
|
||||
final attachment = Attachment(
|
||||
type: 'image',
|
||||
title: 'image.jpg',
|
||||
);
|
||||
final message = Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
attachment,
|
||||
],
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: client,
|
||||
child: child,
|
||||
),
|
||||
home: SizedBox(
|
||||
child: AttachmentActionsModal(
|
||||
imageDownloader: imageDownloader,
|
||||
message: message,
|
||||
attachment: attachment,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Save Image'));
|
||||
|
||||
imageDownloader.progressCallback!(0, 100000);
|
||||
await tester.pump();
|
||||
expect(find.text('0.00 MB'), findsOneWidget);
|
||||
|
||||
imageDownloader.progressCallback!(50000, 100000);
|
||||
await tester.pump();
|
||||
expect(find.text('0.05 MB'), findsOneWidget);
|
||||
|
||||
imageDownloader.progressCallback!(100000, 100000);
|
||||
imageDownloader.downloadedPathCallback!('path');
|
||||
imageDownloader.completer.complete('path');
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('completedIcon')), findsOneWidget);
|
||||
await tester.pumpAndSettle(const Duration(milliseconds: 500));
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'tapping on save in chat should call file downloader',
|
||||
(WidgetTester tester) async {
|
||||
final client = MockClient();
|
||||
final clientState = MockClientState();
|
||||
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
|
||||
|
||||
final fileDownloader = MockAttachmentDownloader();
|
||||
|
||||
final attachment = Attachment(
|
||||
type: 'video',
|
||||
title: 'video.mp4',
|
||||
);
|
||||
final message = Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
id: 'user-id',
|
||||
),
|
||||
attachments: [
|
||||
attachment,
|
||||
]);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: client,
|
||||
child: child,
|
||||
),
|
||||
home: SizedBox(
|
||||
child: AttachmentActionsModal(
|
||||
fileDownloader: fileDownloader,
|
||||
message: message,
|
||||
attachment: attachment,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Save Video'));
|
||||
|
||||
fileDownloader.progressCallback!(0, 100000);
|
||||
await tester.pump();
|
||||
expect(find.text('0.00 MB'), findsOneWidget);
|
||||
|
||||
fileDownloader.progressCallback!(50000, 100000);
|
||||
await tester.pump();
|
||||
expect(find.text('0.05 MB'), findsOneWidget);
|
||||
|
||||
fileDownloader.progressCallback!(100000, 100000);
|
||||
fileDownloader.downloadedPathCallback!('path');
|
||||
fileDownloader.completer.complete('path');
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('completedIcon')), findsOneWidget);
|
||||
await tester.pumpAndSettle(const Duration(milliseconds: 500));
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -0,0 +1,227 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
late MockClient client;
|
||||
late MockChannel channel;
|
||||
late MockChannelState channelState;
|
||||
late MockMember member;
|
||||
late MockUser user;
|
||||
late MockMember member2;
|
||||
late MockUser user2;
|
||||
const methodChannel =
|
||||
MethodChannel('dev.fluttercommunity.plus/connectivity_status');
|
||||
|
||||
setUpAll(() {
|
||||
client = MockClient();
|
||||
channel = MockChannel();
|
||||
channelState = MockChannelState();
|
||||
member = MockMember();
|
||||
user = MockUser();
|
||||
member2 = MockMember();
|
||||
user2 = MockUser();
|
||||
|
||||
when(() => channel.state!).thenReturn(channelState);
|
||||
when(() => channelState.membersStream)
|
||||
.thenAnswer((_) => Stream<List<Member>>.value([member, member2]));
|
||||
when(() => member.user).thenReturn(user);
|
||||
when(() => user.name).thenReturn('user123');
|
||||
when(() => user.id).thenReturn('123');
|
||||
when(() => member2.user).thenReturn(user2);
|
||||
when(() => user2.name).thenReturn('user456');
|
||||
when(() => user2.id).thenReturn('456');
|
||||
});
|
||||
|
||||
setUp(() {
|
||||
methodChannel.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
if (methodCall.method == 'listen') {
|
||||
try {
|
||||
await ServicesBinding.instance.defaultBinaryMessenger
|
||||
.handlePlatformMessage(
|
||||
methodChannel.name,
|
||||
methodChannel.codec.encodeSuccessEnvelope('wifi'),
|
||||
(_) {},
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'control test',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
streamChatThemeData: StreamChatThemeData.light(),
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: StreamGroupAvatar(
|
||||
members: [
|
||||
member,
|
||||
member2,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(StreamUserAvatar), findsNWidgets(2));
|
||||
},
|
||||
);
|
||||
|
||||
testGoldens(
|
||||
'golden test for the group with "user123" and "user456"',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
streamChatThemeData: StreamChatThemeData.light(),
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 100,
|
||||
height: 100,
|
||||
child: StreamGroupAvatar(
|
||||
members: [
|
||||
member,
|
||||
member2,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'group_avatar_0');
|
||||
},
|
||||
);
|
||||
|
||||
tearDown(() {
|
||||
methodChannel.setMockMethodCallHandler(null);
|
||||
});
|
||||
|
||||
/*testGoldens(
|
||||
'golden test for the name "demo user"',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 100,
|
||||
height: 100,
|
||||
child: GroupAvatar(
|
||||
members: [
|
||||
Member(userId: 'user123'),
|
||||
Member(userId: 'user456'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'group_avatar_0');
|
||||
},
|
||||
);
|
||||
|
||||
testGoldens(
|
||||
'golden test for the name "demo"',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 100,
|
||||
height: 100,
|
||||
child: GroupAvatar(
|
||||
members: [
|
||||
Member(userId: 'user123'),
|
||||
Member(userId: 'user456'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'group_avatar_1');
|
||||
},
|
||||
);
|
||||
|
||||
testGoldens(
|
||||
'control special character test',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 100,
|
||||
height: 100,
|
||||
child: GroupAvatar(
|
||||
members: [
|
||||
Member(userId: 'user123'),
|
||||
Member(userId: 'user456'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'group_avatar_3');
|
||||
},
|
||||
);
|
||||
|
||||
testGoldens(
|
||||
'control special character test 2',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 100,
|
||||
height: 100,
|
||||
child: GroupAvatar(
|
||||
members: [
|
||||
Member(userId: 'user123'),
|
||||
Member(userId: 'user456'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'group_avatar_3');
|
||||
},
|
||||
);*/
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
late MockClient client;
|
||||
late MockUser user;
|
||||
|
||||
setUpAll(() {
|
||||
client = MockClient();
|
||||
user = MockUser();
|
||||
|
||||
when(() => user.name).thenReturn('user123');
|
||||
when(() => user.id).thenReturn('123');
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'control test',
|
||||
(WidgetTester tester) async {
|
||||
when(() => user.online).thenReturn(true);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
streamChatThemeData: StreamChatThemeData.light(),
|
||||
child: Builder(builder: (context) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: StreamUserAvatar(
|
||||
user: user,
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(StreamUserAvatar), findsOneWidget);
|
||||
},
|
||||
);
|
||||
|
||||
testGoldens(
|
||||
'golden test for online user "user123"',
|
||||
(WidgetTester tester) async {
|
||||
when(() => user.online).thenReturn(true);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) {
|
||||
return StreamChatConfiguration(
|
||||
data: StreamChatConfigurationData(),
|
||||
child: child!,
|
||||
);
|
||||
},
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: StreamUserAvatar(
|
||||
user: user,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'user_avatar_0');
|
||||
},
|
||||
);
|
||||
|
||||
testGoldens(
|
||||
'golden test for offline user "user123"',
|
||||
(WidgetTester tester) async {
|
||||
when(() => user.online).thenReturn(false);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) {
|
||||
return StreamChatConfiguration(
|
||||
data: StreamChatConfigurationData(),
|
||||
child: child!,
|
||||
);
|
||||
},
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: StreamUserAvatar(
|
||||
user: user,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'user_avatar_1');
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
group('AttachmentModalSheet tests', () {
|
||||
testWidgets('Appears on tap', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(builder: (context) {
|
||||
return Center(
|
||||
child: ElevatedButton(
|
||||
child: const Text('Show Modal'),
|
||||
onPressed: () => showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (_) => AttachmentModalSheet(
|
||||
onFileTap: () {},
|
||||
onPhotoTap: () {},
|
||||
onVideoTap: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final button = find.byType(ElevatedButton);
|
||||
await tester.tap(button);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(AttachmentModalSheet), findsOneWidget);
|
||||
expect(find.byType(ListTile), findsNWidgets(4));
|
||||
});
|
||||
|
||||
testWidgets('onPhotoTap works', (tester) async {
|
||||
var called = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(builder: (context) {
|
||||
return Center(
|
||||
child: AttachmentModalSheet(
|
||||
onPhotoTap: () => called = 1,
|
||||
onFileTap: () {},
|
||||
onVideoTap: () {},
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(AttachmentModalSheet), findsOneWidget);
|
||||
final photoTile = find.widgetWithIcon(ListTile, Icons.image);
|
||||
expect(photoTile, findsOneWidget);
|
||||
await tester.tap(photoTile);
|
||||
await tester.pumpAndSettle();
|
||||
expect(called, 1);
|
||||
});
|
||||
|
||||
testWidgets('onVideoTap works', (tester) async {
|
||||
var called = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(builder: (context) {
|
||||
return Center(
|
||||
child: AttachmentModalSheet(
|
||||
onPhotoTap: () {},
|
||||
onVideoTap: () => called = 1,
|
||||
onFileTap: () {},
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(AttachmentModalSheet), findsOneWidget);
|
||||
final videoTile = find.widgetWithIcon(ListTile, Icons.video_library);
|
||||
expect(videoTile, findsOneWidget);
|
||||
await tester.tap(videoTile);
|
||||
await tester.pumpAndSettle();
|
||||
expect(called, 1);
|
||||
});
|
||||
|
||||
testWidgets('onFileTap works', (tester) async {
|
||||
var called = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(builder: (context) {
|
||||
return Center(
|
||||
child: AttachmentModalSheet(
|
||||
onPhotoTap: () {},
|
||||
onVideoTap: () {},
|
||||
onFileTap: () => called = 1,
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(AttachmentModalSheet), findsOneWidget);
|
||||
final fileTile = find.widgetWithIcon(ListTile, Icons.insert_drive_file);
|
||||
expect(fileTile, findsOneWidget);
|
||||
await tester.tap(fileTile);
|
||||
await tester.pumpAndSettle();
|
||||
expect(called, 1);
|
||||
});
|
||||
|
||||
testGoldens(
|
||||
'golden test for AttachmentModalSheet',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(builder: (context) {
|
||||
return Center(
|
||||
child: AttachmentModalSheet(
|
||||
onPhotoTap: () {},
|
||||
onVideoTap: () {},
|
||||
onFileTap: () {},
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'attachment_modal_sheet_0');
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
group('EditMessageSheet tests', () {
|
||||
const methodChannel =
|
||||
MethodChannel('dev.fluttercommunity.plus/connectivity_status');
|
||||
setUp(() {
|
||||
methodChannel.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
if (methodCall.method == 'listen') {
|
||||
try {
|
||||
await ServicesBinding.instance.defaultBinaryMessenger
|
||||
.handlePlatformMessage(
|
||||
methodChannel.name,
|
||||
methodChannel.codec.encodeSuccessEnvelope('wifi'),
|
||||
(_) {},
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('appears on tap', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
child: child,
|
||||
),
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) {
|
||||
return Center(
|
||||
child: ElevatedButton(
|
||||
child: const Text('Show Modal'),
|
||||
onPressed: () => showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (_) => EditMessageSheet(
|
||||
channel: MockChannel(),
|
||||
message: Message(id: 'msg123', text: 'Hello World!'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final button = find.byType(ElevatedButton);
|
||||
await tester.tap(button);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(EditMessageSheet), findsOneWidget);
|
||||
expect(find.text('Edit Message'), findsOneWidget);
|
||||
expect(find.byType(StreamMessageInput), findsOneWidget);
|
||||
});
|
||||
|
||||
testGoldens(
|
||||
'golden test for EditMessageSheet',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
child: child,
|
||||
),
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: EditMessageSheet(
|
||||
channel: MockChannel(),
|
||||
message: Message(id: 'msg123', text: 'Hello World!'),
|
||||
),
|
||||
)),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'edit_message_sheet_0');
|
||||
},
|
||||
);
|
||||
|
||||
tearDown(() {
|
||||
methodChannel.setMockMethodCallHandler(null);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
group('ErrorAlertSheet tests', () {
|
||||
const methodChannel =
|
||||
MethodChannel('dev.fluttercommunity.plus/connectivity_status');
|
||||
setUp(() {
|
||||
methodChannel.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
if (methodCall.method == 'listen') {
|
||||
try {
|
||||
await ServicesBinding.instance.defaultBinaryMessenger
|
||||
.handlePlatformMessage(
|
||||
methodChannel.name,
|
||||
methodChannel.codec.encodeSuccessEnvelope('wifi'),
|
||||
(_) {},
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('appears on error', (tester) async {
|
||||
void failFunction() => throw Exception('Something went wrong');
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
child: child,
|
||||
),
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) {
|
||||
return Center(
|
||||
child: ElevatedButton(
|
||||
child: const Text('Show Modal'),
|
||||
onPressed: () {
|
||||
try {
|
||||
failFunction();
|
||||
} catch (e) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (_) => ErrorAlertSheet(
|
||||
errorDescription: e.toString(),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final button = find.byType(ElevatedButton);
|
||||
await tester.tap(button);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(ErrorAlertSheet), findsOneWidget);
|
||||
expect(find.text('Something went wrong'), findsOneWidget);
|
||||
});
|
||||
|
||||
testGoldens(
|
||||
'golden test for ErrorAlertSheet',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
child: child,
|
||||
),
|
||||
home: const Scaffold(
|
||||
body: Center(
|
||||
child: ErrorAlertSheet(
|
||||
errorDescription: 'Something went wrong.',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'error_alert_sheet_0');
|
||||
},
|
||||
);
|
||||
|
||||
tearDown(() {
|
||||
methodChannel.setMockMethodCallHandler(null);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/src/channel_info.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -39,12 +38,14 @@ void main() {
|
||||
when(() => clientState.totalUnreadCount).thenAnswer((i) => 1);
|
||||
when(() => clientState.totalUnreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -52,17 +53,19 @@ void main() {
|
||||
),
|
||||
]);
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: const Scaffold(
|
||||
body: StreamChannelHeader(),
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: const Scaffold(
|
||||
body: StreamChannelHeader(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
expect(find.text('test'), findsOneWidget);
|
||||
expect(find.byType(StreamChannelAvatar), findsOneWidget);
|
||||
@@ -98,12 +101,14 @@ void main() {
|
||||
when(() => channelState.unreadCount).thenReturn(1);
|
||||
when(() => channelState.unreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -118,19 +123,21 @@ void main() {
|
||||
when(() => clientState.totalUnreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: const Scaffold(
|
||||
body: StreamChannelHeader(
|
||||
showConnectionStateTile: true,
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: const Scaffold(
|
||||
body: StreamChannelHeader(
|
||||
showConnectionStateTile: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
expect(
|
||||
tester
|
||||
@@ -169,12 +176,14 @@ void main() {
|
||||
when(() => channelState.unreadCount).thenReturn(1);
|
||||
when(() => channelState.unreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -187,20 +196,22 @@ void main() {
|
||||
when(() => clientState.totalUnreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
showLoading: false,
|
||||
child: const Scaffold(
|
||||
body: StreamChannelHeader(
|
||||
showConnectionStateTile: true,
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
showLoading: false,
|
||||
child: const Scaffold(
|
||||
body: StreamChannelHeader(
|
||||
showConnectionStateTile: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
await tester.pump();
|
||||
|
||||
@@ -242,12 +253,14 @@ void main() {
|
||||
when(() => channelState.unreadCount).thenReturn(1);
|
||||
when(() => channelState.unreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -259,24 +272,26 @@ void main() {
|
||||
when(() => clientState.totalUnreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: const Scaffold(
|
||||
body: StreamChannelHeader(
|
||||
leading: Text('leading'),
|
||||
subtitle: Text('subtitle'),
|
||||
actions: [
|
||||
Text('action'),
|
||||
],
|
||||
title: Text('title'),
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: const Scaffold(
|
||||
body: StreamChannelHeader(
|
||||
leading: Text('leading'),
|
||||
subtitle: Text('subtitle'),
|
||||
actions: [
|
||||
Text('action'),
|
||||
],
|
||||
title: Text('title'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
expect(find.text('test'), findsNothing);
|
||||
expect(find.byType(StreamBackButton), findsNothing);
|
||||
@@ -318,12 +333,14 @@ void main() {
|
||||
when(() => channelState.unreadCount).thenReturn(1);
|
||||
when(() => channelState.unreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -333,27 +350,30 @@ void main() {
|
||||
when(() => client.wsConnectionStatusStream)
|
||||
.thenAnswer((_) => Stream.value(ConnectionStatus.disconnected));
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: const Scaffold(
|
||||
body: StreamChannelHeader(
|
||||
showTypingIndicator: false,
|
||||
showBackButton: false,
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: const Scaffold(
|
||||
body: StreamChannelHeader(
|
||||
showTypingIndicator: false,
|
||||
showBackButton: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
expect(find.byType(StreamBackButton), findsNothing);
|
||||
expect(
|
||||
tester
|
||||
.widget<StreamChannelInfo>(find.byType(StreamChannelInfo))
|
||||
.showTypingIndicator,
|
||||
false);
|
||||
tester
|
||||
.widget<StreamChannelInfo>(find.byType(StreamChannelInfo))
|
||||
.showTypingIndicator,
|
||||
false,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<StreamInfoTile>(find.byType(StreamInfoTile))
|
||||
@@ -389,12 +409,14 @@ void main() {
|
||||
when(() => channelState.unreadCount).thenReturn(1);
|
||||
when(() => channelState.unreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -411,21 +433,23 @@ void main() {
|
||||
var imageTapped = false;
|
||||
var titleTapped = false;
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: StreamChannelHeader(
|
||||
onBackPressed: () => backPressed = true,
|
||||
onImageTap: () => imageTapped = true,
|
||||
onTitleTap: () => titleTapped = true,
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: StreamChannelHeader(
|
||||
onBackPressed: () => backPressed = true,
|
||||
onImageTap: () => imageTapped = true,
|
||||
onTitleTap: () => titleTapped = true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
await tester.tap(find.byType(StreamBackButton));
|
||||
await tester.tap(find.byType(StreamChannelAvatar));
|
||||
@@ -2,10 +2,9 @@ import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/src/group_avatar.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -26,19 +25,19 @@ void main() {
|
||||
.thenAnswer((i) => Stream.value('https://bit.ly/321RmWb'));
|
||||
when(() => channel.image).thenReturn('https://bit.ly/321RmWb');
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: StreamChannelAvatar(
|
||||
channel: channel,
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: StreamChannelAvatar(channel: channel),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
final image =
|
||||
tester.widget<CachedNetworkImage>(find.byType(CachedNetworkImage));
|
||||
@@ -62,19 +61,21 @@ void main() {
|
||||
when(() => channel.name).thenReturn('test');
|
||||
when(() => channel.imageStream).thenAnswer((i) => Stream.value(null));
|
||||
when(() => channel.image).thenReturn(null);
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
),
|
||||
Member(
|
||||
userId: 'user-id2',
|
||||
user: User(
|
||||
id: 'user-id2',
|
||||
image: 'testimage',
|
||||
),
|
||||
Member(
|
||||
userId: 'user-id2',
|
||||
user: User(
|
||||
id: 'user-id2',
|
||||
image: 'testimage',
|
||||
),
|
||||
)
|
||||
]));
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id2',
|
||||
@@ -88,29 +89,31 @@ void main() {
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]);
|
||||
when(() => clientState.usersStream).thenAnswer((i) => Stream.value({
|
||||
'user-id2': User(
|
||||
id: 'user-id2',
|
||||
image: 'testimage',
|
||||
),
|
||||
}));
|
||||
when(() => clientState.usersStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'user-id2': User(
|
||||
id: 'user-id2',
|
||||
image: 'testimage',
|
||||
),
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: StreamChannelAvatar(
|
||||
channel: channel,
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: StreamChannelAvatar(channel: channel),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
final image =
|
||||
tester.widget<CachedNetworkImage>(find.byType(CachedNetworkImage));
|
||||
@@ -161,19 +164,19 @@ void main() {
|
||||
when(() => channelState.membersStream)
|
||||
.thenAnswer((_) => Stream.value(members));
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: StreamChannelAvatar(
|
||||
channel: channel,
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: StreamChannelAvatar(channel: channel),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
final image =
|
||||
tester.widget<StreamGroupAvatar>(find.byType(StreamGroupAvatar));
|
||||
@@ -203,20 +206,22 @@ void main() {
|
||||
.thenAnswer((i) => Stream.value('https://bit.ly/321RmWb'));
|
||||
when(() => channel.image).thenReturn('https://bit.ly/321RmWb');
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: StreamChannelAvatar(
|
||||
selected: true,
|
||||
channel: channel,
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: StreamChannelAvatar(
|
||||
channel: channel,
|
||||
selected: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
expect(find.byKey(const Key('selectedImage')), findsOneWidget);
|
||||
},
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -27,12 +27,14 @@ void main() {
|
||||
when(() => channelState.unreadCount).thenReturn(1);
|
||||
when(() => channelState.unreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
when(() => channelState.membersStream).thenAnswer((_) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(_) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -45,26 +47,30 @@ void main() {
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]);
|
||||
when(() => channelState.messagesStream).thenAnswer((i) => Stream.value([
|
||||
Message(
|
||||
text: 'hello',
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.messagesStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Message(
|
||||
text: 'hello',
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: StreamChannelName(
|
||||
channel: channel,
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: StreamChannelName(
|
||||
channel: channel,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
expect(find.text('test'), findsOneWidget);
|
||||
},
|
||||
@@ -5,7 +5,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -42,12 +42,14 @@ void main() {
|
||||
when(() => channelState.unreadCount).thenReturn(1);
|
||||
when(() => channelState.unreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -60,26 +62,30 @@ void main() {
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]);
|
||||
when(() => channelState.messagesStream).thenAnswer((i) => Stream.value([
|
||||
Message(
|
||||
text: 'hello',
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.messagesStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Message(
|
||||
text: 'hello',
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: ChannelPreview(
|
||||
channel: channel,
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: ChannelPreview(
|
||||
channel: channel,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
expect(find.text('6/22/2020'), findsOneWidget);
|
||||
expect(find.text('test name'), findsOneWidget);
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/src/context_menu_items/download_menu_item.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('DownloadMenuItem test', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
child: child,
|
||||
),
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: DownloadMenuItem(
|
||||
attachment: MockAttachment(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(ListTile), findsOneWidget);
|
||||
});
|
||||
|
||||
testGoldens(
|
||||
'golden test for DownloadMenuItem',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: child!,
|
||||
),
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: DownloadMenuItem(
|
||||
attachment: MockAttachment(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'download_menu_item_0');
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/src/context_menu_items/stream_chat_context_menu_item.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('StreamChatContextMenuItem test', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
child: child,
|
||||
),
|
||||
home: const Scaffold(
|
||||
body: Center(
|
||||
child: StreamChatContextMenuItem(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(ListTile), findsOneWidget);
|
||||
});
|
||||
|
||||
testGoldens(
|
||||
'golden test for StreamChatContextMenuItem',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: child!,
|
||||
),
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: StreamChatContextMenuItem(
|
||||
leading: const Icon(Icons.download),
|
||||
title: const Text('Download'),
|
||||
onClick: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'stream_chat_context_menu_item_0');
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/src/dialogs/channel_info_dialog.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
late MockClient client;
|
||||
late MockClientState clientState;
|
||||
late MockOwnUser user;
|
||||
late MockChannel channel;
|
||||
late MockChannelState channelState;
|
||||
|
||||
setUpAll(() {
|
||||
client = MockClient();
|
||||
clientState = MockClientState();
|
||||
user = MockOwnUser();
|
||||
channel = MockChannel();
|
||||
channelState = MockChannelState();
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.currentUser).thenReturn(user);
|
||||
when(() => user.id).thenReturn('1');
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
user: User(
|
||||
id: '1',
|
||||
),
|
||||
),
|
||||
Member(
|
||||
user: User(
|
||||
id: '2',
|
||||
),
|
||||
),
|
||||
]);
|
||||
when(() => channel.name).thenReturn('test-channel');
|
||||
when(() => channel.id).thenReturn('123456789');
|
||||
when(() => channel.isDistinct).thenReturn(true);
|
||||
when(() => channel.memberCount).thenReturn(2);
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(_) => Stream.value([
|
||||
Member(
|
||||
user: User(
|
||||
id: '1',
|
||||
),
|
||||
),
|
||||
Member(
|
||||
user: User(
|
||||
id: '2',
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('ChannelInfoDialog shows info and members', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
streamChatThemeData: StreamChatThemeData.light(),
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: ChannelInfoDialog(
|
||||
channel: channel,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(SimpleDialog), findsOneWidget);
|
||||
expect(find.byType(StreamChannelInfo), findsOneWidget);
|
||||
expect(find.byType(StreamUserAvatar), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/src/dialogs/confirmation_dialog.dart';
|
||||
import 'package:stream_chat_flutter/src/utils/extensions.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('ChannelInfoDialog shows info and members', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(builder: (context) {
|
||||
return Center(
|
||||
child: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: ConfirmationDialog(
|
||||
titleText: context.translations
|
||||
.toggleMuteUnmuteUserText(isMuted: false),
|
||||
promptText: context.translations
|
||||
.toggleMuteUnmuteUserQuestion(isMuted: false),
|
||||
affirmativeText: context.translations
|
||||
.toggleMuteUnmuteAction(isMuted: false),
|
||||
onConfirmation: () {},
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
expect(find.text('Mute User'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Are you sure you want to mute this user?'), findsOneWidget);
|
||||
expect(find.text('MUTE'), findsOneWidget);
|
||||
});
|
||||
|
||||
testGoldens('golden test for ConfirmationDialog', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) {
|
||||
return Center(
|
||||
child: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: ConfirmationDialog(
|
||||
titleText: context.translations
|
||||
.toggleMuteUnmuteUserText(isMuted: false),
|
||||
promptText: context.translations
|
||||
.toggleMuteUnmuteUserQuestion(isMuted: false),
|
||||
affirmativeText: context.translations
|
||||
.toggleMuteUnmuteAction(isMuted: false),
|
||||
onConfirmation: () {},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'confirmation_dialog_0');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/src/dialogs/delete_message_dialog.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('DeleteMessageDialog', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) {
|
||||
return Center(
|
||||
child: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const DeleteMessageDialog(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
expect(find.text('Delete Message'), findsOneWidget);
|
||||
expect(find.text('DELETE'), findsOneWidget);
|
||||
});
|
||||
|
||||
testGoldens('golden test for DeleteMessageDialog', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) {
|
||||
return Center(
|
||||
child: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const DeleteMessageDialog(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'delete_message_dialog_0');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/src/dialogs/message_dialog.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('MessageDialog shows default info', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) {
|
||||
return Center(
|
||||
child: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const MessageDialog(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
expect(find.text('Something went wrong'), findsOneWidget);
|
||||
expect(find.text('OK'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('MessageDialog shows custom info', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) {
|
||||
return Center(
|
||||
child: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const MessageDialog(
|
||||
titleText: 'Message',
|
||||
messageText: 'Message body',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(AlertDialog), findsOneWidget);
|
||||
expect(find.text('Message'), findsOneWidget);
|
||||
expect(find.text('Message body'), findsOneWidget);
|
||||
expect(find.text('OK'), findsOneWidget);
|
||||
});
|
||||
|
||||
testGoldens('golden test for default MessageDialog', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) {
|
||||
return Center(
|
||||
child: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const MessageDialog(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'message_dialog_0');
|
||||
});
|
||||
|
||||
testGoldens('golden test for custom MessageDialog', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) {
|
||||
return Center(
|
||||
child: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const MessageDialog(
|
||||
titleText: 'Message',
|
||||
messageText: 'Message body',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'message_dialog_1');
|
||||
});
|
||||
|
||||
testGoldens('golden test for custom MessageDialog with no body',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) {
|
||||
return Center(
|
||||
child: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const MessageDialog(
|
||||
titleText: 'Message',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'message_dialog_2');
|
||||
});
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/src/emoji/emoji.dart';
|
||||
|
||||
void main() {
|
||||
group('src/emoji', () {
|
||||
test('${Emoji.byShortName} should bring the correct emoji', () {
|
||||
final resultEmoji = Emoji.byShortName('smiley');
|
||||
expect(resultEmoji, _mockEmoji);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
final _mockEmoji = Emoji(
|
||||
name: 'grinning face with big eyes',
|
||||
char: '\u{1F603}',
|
||||
shortName: 'smiley',
|
||||
emojiGroup: EmojiGroup.smileysEmotion,
|
||||
emojiSubgroup: EmojiSubgroup.faceSmiling,
|
||||
keywords: [
|
||||
'face',
|
||||
'mouth',
|
||||
'open',
|
||||
'smile',
|
||||
'uc6',
|
||||
'smiley',
|
||||
'happy',
|
||||
'silly',
|
||||
'laugh',
|
||||
'good',
|
||||
'smile',
|
||||
'teeth',
|
||||
'fun',
|
||||
'smileys',
|
||||
'mood',
|
||||
'emotion',
|
||||
'emotions',
|
||||
'emotional',
|
||||
'hooray',
|
||||
'cheek',
|
||||
'cheeky',
|
||||
'excited',
|
||||
'feliz',
|
||||
'heureux',
|
||||
'cheerful',
|
||||
'delighted',
|
||||
'ecstatic',
|
||||
'elated',
|
||||
'glad',
|
||||
'joy',
|
||||
'merry',
|
||||
'funny',
|
||||
'laughing',
|
||||
'lol',
|
||||
'rofl',
|
||||
'lmao',
|
||||
'lmfao',
|
||||
'hilarious',
|
||||
'ha',
|
||||
'haha',
|
||||
'chuckle',
|
||||
'comedy',
|
||||
'giggle',
|
||||
'hehe',
|
||||
'joyful',
|
||||
'laugh out loud',
|
||||
'rire',
|
||||
'tee hee',
|
||||
'jaja',
|
||||
'good job',
|
||||
'nice',
|
||||
'well done',
|
||||
'bravo',
|
||||
'congratulations',
|
||||
'congrats',
|
||||
'smiles',
|
||||
'dentist',
|
||||
':-D',
|
||||
'=D'
|
||||
]);
|
||||
@@ -4,7 +4,7 @@ import 'package:mocktail/mocktail.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -23,18 +23,22 @@ void main() {
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.isMuted).thenReturn(false);
|
||||
when(() => channel.isMutedStream).thenAnswer((i) => Stream.value(false));
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -47,21 +51,24 @@ void main() {
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]);
|
||||
when(() => channelState.messagesStream).thenAnswer((i) => Stream.value([
|
||||
Message(
|
||||
text: 'hello',
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.messagesStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Message(
|
||||
text: 'hello',
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.typingEvents).thenAnswer((i) => {
|
||||
User(id: 'other-user', extraData: const {'name': 'demo'}):
|
||||
Event(type: EventType.typingStart),
|
||||
});
|
||||
when(() => channelState.typingEventsStream)
|
||||
.thenAnswer((i) => Stream.value({
|
||||
User(id: 'other-user', extraData: const {'name': 'demo'}):
|
||||
Event(type: EventType.typingStart),
|
||||
}));
|
||||
when(() => channelState.typingEventsStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
User(id: 'other-user', extraData: const {'name': 'demo'}):
|
||||
Event(type: EventType.typingStart),
|
||||
}),
|
||||
);
|
||||
|
||||
final attachment = Attachment(
|
||||
type: 'image',
|
||||
@@ -0,0 +1,111 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
late MockClient client;
|
||||
late MockClientState clientState;
|
||||
late MockChannel channel;
|
||||
late MockChannelState channelState;
|
||||
const methodChannel =
|
||||
MethodChannel('dev.fluttercommunity.plus/connectivity_status');
|
||||
|
||||
setUpAll(() {
|
||||
client = MockClient();
|
||||
clientState = MockClientState();
|
||||
channel = MockChannel();
|
||||
channelState = MockChannelState();
|
||||
final lastMessageAt = DateTime.parse('2020-06-22 12:00:00');
|
||||
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
|
||||
when(() => channel.lastMessageAt).thenReturn(lastMessageAt);
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.isMuted).thenReturn(false);
|
||||
when(() => channel.isMutedStream).thenAnswer((i) => Stream.value(false));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
});
|
||||
|
||||
setUp(() {
|
||||
methodChannel.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
if (methodCall.method == 'listen') {
|
||||
try {
|
||||
await ServicesBinding.instance.defaultBinaryMessenger
|
||||
.handlePlatformMessage(
|
||||
methodChannel.name,
|
||||
methodChannel.codec.encodeSuccessEnvelope('wifi'),
|
||||
(_) {},
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'it should show channel typing',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: const Scaffold(
|
||||
body: StreamGalleryFooter(
|
||||
mediaAttachmentPackages: [],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(StreamSvgIcon), findsNWidgets(2));
|
||||
},
|
||||
);
|
||||
|
||||
testGoldens('golden test for GalleryFooter', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: const Scaffold(
|
||||
body: StreamGalleryFooter(
|
||||
mediaAttachmentPackages: [],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'gallery_footer_0');
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
methodChannel.setMockMethodCallHandler(null);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
late MockClient client;
|
||||
late MockClientState clientState;
|
||||
late MockChannel channel;
|
||||
late MockChannelState channelState;
|
||||
const methodChannel =
|
||||
MethodChannel('dev.fluttercommunity.plus/connectivity_status');
|
||||
|
||||
setUpAll(() {
|
||||
client = MockClient();
|
||||
clientState = MockClientState();
|
||||
channel = MockChannel();
|
||||
channelState = MockChannelState();
|
||||
final lastMessageAt = DateTime.parse('2020-06-22 12:00:00');
|
||||
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
|
||||
when(() => channel.lastMessageAt).thenReturn(lastMessageAt);
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.isMuted).thenReturn(false);
|
||||
when(() => channel.isMutedStream).thenAnswer((i) => Stream.value(false));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
});
|
||||
|
||||
setUp(() {
|
||||
methodChannel.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
if (methodCall.method == 'listen') {
|
||||
try {
|
||||
await ServicesBinding.instance.defaultBinaryMessenger
|
||||
.handlePlatformMessage(
|
||||
methodChannel.name,
|
||||
methodChannel.codec.encodeSuccessEnvelope('wifi'),
|
||||
(_) {},
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'it should show channel typing',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: Scaffold(
|
||||
appBar: StreamGalleryHeader(
|
||||
attachment: MockAttachment(),
|
||||
message: Message(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(StreamSvgIcon), findsNWidgets(2));
|
||||
},
|
||||
);
|
||||
|
||||
testGoldens('golden test for GalleryHeader', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: Scaffold(
|
||||
appBar: StreamGalleryHeader(
|
||||
userName: 'User',
|
||||
sentAt: DateTime.now().toIso8601String(),
|
||||
message: Message(),
|
||||
attachment: MockAttachment(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'gallery_header_0');
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
methodChannel.setMockMethodCallHandler(null);
|
||||
});
|
||||
}
|
||||
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 32 KiB |
@@ -1,52 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'it should show channel typing',
|
||||
(WidgetTester tester) async {
|
||||
final client = MockClient();
|
||||
final clientState = MockClientState();
|
||||
final channel = MockChannel();
|
||||
final channelState = MockChannelState();
|
||||
final lastMessageAt = DateTime.parse('2020-06-22 12:00:00');
|
||||
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
|
||||
when(() => channel.lastMessageAt).thenReturn(lastMessageAt);
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.isMuted).thenReturn(false);
|
||||
when(() => channel.isMutedStream).thenAnswer((i) => Stream.value(false));
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: Scaffold(
|
||||
body: StreamGalleryFooter(
|
||||
mediaAttachmentPackages: Message().getAttachmentPackageList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
expect(find.byType(StreamSvgIcon), findsNWidgets(2));
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('StreamSendingIndicator shows an Icon', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: StreamSendingIndicator(
|
||||
message: Message(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(Icon), findsOneWidget);
|
||||
});
|
||||
|
||||
testGoldens(
|
||||
'golden test for StreamSendingIndicator with StreamSvgIcon.checkAll',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: StreamSendingIndicator(
|
||||
isMessageRead: true,
|
||||
message: Message(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'sending_indicator_0');
|
||||
});
|
||||
|
||||
testGoldens('golden test for StreamSendingIndicator with StreamSvgIcon.check',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: StreamSendingIndicator(
|
||||
message: Message(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'sending_indicator_1');
|
||||
});
|
||||
|
||||
testGoldens(
|
||||
'golden test for StreamSendingIndicator with Icon(Icons.access_time)',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: StreamSendingIndicator(
|
||||
message: Message(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'sending_indicator_2');
|
||||
});
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -22,18 +22,22 @@ void main() {
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.isMuted).thenReturn(false);
|
||||
when(() => channel.isMutedStream).thenAnswer((i) => Stream.value(false));
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -46,22 +50,25 @@ void main() {
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]);
|
||||
when(() => channelState.messagesStream).thenAnswer((i) => Stream.value([
|
||||
Message(
|
||||
text: 'hello',
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.messagesStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Message(
|
||||
text: 'hello',
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
|
||||
when(() => channelState.typingEvents).thenAnswer((i) => {
|
||||
User(id: 'other-user', extraData: const {'name': 'demo'}):
|
||||
Event(type: EventType.typingStart),
|
||||
});
|
||||
when(() => channelState.typingEventsStream)
|
||||
.thenAnswer((i) => Stream.value({
|
||||
User(id: 'other-user', extraData: const {'name': 'demo'}):
|
||||
Event(type: EventType.typingStart),
|
||||
}));
|
||||
when(() => channelState.typingEventsStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
User(id: 'other-user', extraData: const {'name': 'demo'}):
|
||||
Event(type: EventType.typingStart),
|
||||
}),
|
||||
);
|
||||
|
||||
const typingKey = Key('typing');
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -20,9 +20,11 @@ void main() {
|
||||
when(() => channel.lastMessageAt).thenReturn(lastMessageAt);
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
@@ -0,0 +1,167 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('StreamUploadProgressIndicator at 0% with no background',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const Scaffold(
|
||||
body: Center(
|
||||
child: StreamUploadProgressIndicator(
|
||||
total: 100,
|
||||
uploaded: 0,
|
||||
showBackground: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('0%'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('StreamUploadProgressIndicator at 50% with no background',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const Scaffold(
|
||||
body: Center(
|
||||
child: StreamUploadProgressIndicator(
|
||||
total: 100,
|
||||
uploaded: 50,
|
||||
showBackground: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('50%'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('StreamUploadProgressIndicator at 100% with no background',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const Scaffold(
|
||||
body: Center(
|
||||
child: StreamUploadProgressIndicator(
|
||||
total: 100,
|
||||
uploaded: 100,
|
||||
showBackground: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('100%'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('StreamUploadProgressIndicator at 50% with background',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const Scaffold(
|
||||
body: Center(
|
||||
child: StreamUploadProgressIndicator(
|
||||
total: 100,
|
||||
uploaded: 50,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final backgroundColor =
|
||||
((find.byType(DecoratedBox).evaluate().first.widget as DecoratedBox)
|
||||
.decoration as BoxDecoration)
|
||||
.color;
|
||||
|
||||
expect(const Color(0x99000000), backgroundColor);
|
||||
});
|
||||
|
||||
testGoldens(
|
||||
'golden test for StreamUploadProgressIndicator at 0% with background',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const Scaffold(
|
||||
body: Center(
|
||||
child: StreamUploadProgressIndicator(
|
||||
total: 100,
|
||||
uploaded: 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'upload_progress_indicator_0',
|
||||
customPump: (widget) => widget.pump(const Duration(seconds: 3)));
|
||||
});
|
||||
|
||||
testGoldens(
|
||||
'golden test for StreamUploadProgressIndicator at 50% with background',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const Scaffold(
|
||||
body: Center(
|
||||
child: StreamUploadProgressIndicator(
|
||||
total: 100,
|
||||
uploaded: 50,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'upload_progress_indicator_1',
|
||||
customPump: (widget) => widget.pump(const Duration(seconds: 3)));
|
||||
});
|
||||
|
||||
testGoldens(
|
||||
'golden test for StreamUploadProgressIndicator at 100% with background',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const Scaffold(
|
||||
body: Center(
|
||||
child: StreamUploadProgressIndicator(
|
||||
total: 100,
|
||||
uploaded: 100,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'upload_progress_indicator_2',
|
||||
customPump: (widget) => widget.pump(const Duration(seconds: 3)));
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('KeyboardShortcutRunner onEnterKeypress works', (tester) async {
|
||||
var count = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: KeyboardShortcutRunner(
|
||||
onEnterKeypress: () {
|
||||
count++;
|
||||
},
|
||||
onEscapeKeypress: () {},
|
||||
child: const TextField(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final textField = find.byType(TextField);
|
||||
await tester.tap(textField);
|
||||
await tester.enterText(textField, 'Test');
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.enter);
|
||||
await tester.pumpAndSettle();
|
||||
expect(count, 1);
|
||||
});
|
||||
|
||||
testWidgets('KeyboardShortcutRunner onEscapeKeypress works', (tester) async {
|
||||
final controller = TextEditingController();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: KeyboardShortcutRunner(
|
||||
onEnterKeypress: () {},
|
||||
onEscapeKeypress: controller.clear,
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final textField = find.byType(TextField);
|
||||
await tester.tap(textField);
|
||||
await tester.enterText(textField, 'Test');
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.text, '');
|
||||
});
|
||||
}
|
||||
@@ -56,7 +56,6 @@ void main() {
|
||||
expect(translations.instantCommandsLabel, isNotNull);
|
||||
expect(translations.fileTooLargeAfterCompressionError(33), isNotNull);
|
||||
expect(translations.fileTooLargeError(33), isNotNull);
|
||||
expect(translations.emojiMatchingQueryText('sahil'), isNotNull);
|
||||
expect(translations.addAFileLabel, isNotNull);
|
||||
expect(translations.photoFromCameraLabel, isNotNull);
|
||||
expect(translations.uploadAFileLabel, isNotNull);
|
||||
@@ -1,37 +0,0 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/src/media_list_view_controller.dart';
|
||||
|
||||
void main() {
|
||||
test('should update media', () {
|
||||
final controller = MediaListViewController();
|
||||
|
||||
expect(controller.shouldUpdateMedia, false);
|
||||
|
||||
controller.updateMedia(newValue: true);
|
||||
expect(controller.shouldUpdateMedia, true);
|
||||
|
||||
controller.dispose();
|
||||
});
|
||||
|
||||
test('should notify listeners on update media', () {
|
||||
final controller = MediaListViewController();
|
||||
|
||||
var callCount = 0;
|
||||
void updateCallsSpy() => callCount++;
|
||||
|
||||
controller.addListener(updateCallsSpy);
|
||||
|
||||
expect(callCount, 0);
|
||||
controller.updateMedia(newValue: false);
|
||||
expect(controller.shouldUpdateMedia, false);
|
||||
expect(callCount, 1);
|
||||
|
||||
controller.updateMedia(newValue: true);
|
||||
expect(controller.shouldUpdateMedia, true);
|
||||
expect(callCount, 2);
|
||||
|
||||
controller
|
||||
..removeListener(updateCallsSpy)
|
||||
..dispose();
|
||||
});
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/src/message_actions_modal.dart';
|
||||
import 'package:stream_chat_flutter/src/message_actions_modal/message_actions_modal.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
setUpAll(() {
|
||||
@@ -34,7 +34,7 @@ void main() {
|
||||
child: SizedBox(
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
message: Message(
|
||||
text: 'test',
|
||||
user: User(
|
||||
@@ -47,9 +47,6 @@ void main() {
|
||||
key: Key('MessageWidget'),
|
||||
),
|
||||
messageTheme: streamTheme.ownMessageTheme,
|
||||
showThreadReplyMessage: true,
|
||||
showEditMessage: true,
|
||||
showDeleteMessage: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -88,7 +85,7 @@ void main() {
|
||||
child: SizedBox(
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
showCopyMessage: false,
|
||||
showReplyMessage: false,
|
||||
showThreadReplyMessage: false,
|
||||
@@ -134,16 +131,17 @@ void main() {
|
||||
final streamTheme = StreamChatThemeData.fromTheme(themeData);
|
||||
|
||||
var tapped = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: themeData,
|
||||
home: StreamChat(
|
||||
streamChatThemeData: streamTheme,
|
||||
client: client,
|
||||
child: SizedBox(
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
theme: themeData,
|
||||
home: StreamChat(
|
||||
streamChatThemeData: streamTheme,
|
||||
client: client,
|
||||
child: SizedBox(
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
messageWidget: const Text('test'),
|
||||
message: Message(
|
||||
text: 'test',
|
||||
@@ -166,7 +164,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
));
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -203,7 +201,7 @@ void main() {
|
||||
child: SizedBox(
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
messageWidget: const Text('test'),
|
||||
onReplyTap: (m) {
|
||||
tapped = true;
|
||||
@@ -254,7 +252,7 @@ void main() {
|
||||
child: SizedBox(
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
messageWidget: const Text('test'),
|
||||
onThreadReplyTap: (m) {
|
||||
tapped = true;
|
||||
@@ -267,7 +265,6 @@ void main() {
|
||||
status: MessageSendingStatus.sent,
|
||||
),
|
||||
messageTheme: streamTheme.ownMessageTheme,
|
||||
showThreadReplyMessage: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -309,7 +306,7 @@ void main() {
|
||||
showLoading: false,
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
messageWidget: const Text('test'),
|
||||
message: Message(
|
||||
text: 'test',
|
||||
@@ -318,7 +315,6 @@ void main() {
|
||||
),
|
||||
),
|
||||
messageTheme: streamTheme.ownMessageTheme,
|
||||
showEditMessage: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -359,7 +355,7 @@ void main() {
|
||||
showLoading: false,
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
messageWidget: const Text('test'),
|
||||
editMessageInputBuilder: (context, m) => const Text('test'),
|
||||
message: Message(
|
||||
@@ -369,7 +365,6 @@ void main() {
|
||||
),
|
||||
),
|
||||
messageTheme: streamTheme.ownMessageTheme,
|
||||
showEditMessage: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -412,7 +407,7 @@ void main() {
|
||||
showLoading: false,
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
messageWidget: const Text('test'),
|
||||
onCopyTap: (m) => tapped = true,
|
||||
message: Message(
|
||||
@@ -462,7 +457,7 @@ void main() {
|
||||
showLoading: false,
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
messageWidget: const Text('test'),
|
||||
message: Message(
|
||||
status: MessageSendingStatus.failed,
|
||||
@@ -512,7 +507,7 @@ void main() {
|
||||
showLoading: false,
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
messageWidget: const Text('test'),
|
||||
message: Message(
|
||||
status: MessageSendingStatus.failed_update,
|
||||
@@ -560,7 +555,7 @@ void main() {
|
||||
showLoading: false,
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
messageWidget: const Text('test'),
|
||||
message: Message(
|
||||
id: 'testid',
|
||||
@@ -570,7 +565,6 @@ void main() {
|
||||
),
|
||||
),
|
||||
messageTheme: streamTheme.ownMessageTheme,
|
||||
showFlagButton: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -617,7 +611,7 @@ void main() {
|
||||
showLoading: false,
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
messageWidget: const Text('test'),
|
||||
message: Message(
|
||||
id: 'testid',
|
||||
@@ -627,7 +621,6 @@ void main() {
|
||||
),
|
||||
),
|
||||
messageTheme: streamTheme.ownMessageTheme,
|
||||
showFlagButton: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -674,7 +667,7 @@ void main() {
|
||||
showLoading: false,
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
messageWidget: const Text('test'),
|
||||
message: Message(
|
||||
id: 'testid',
|
||||
@@ -684,7 +677,6 @@ void main() {
|
||||
),
|
||||
),
|
||||
messageTheme: streamTheme.ownMessageTheme,
|
||||
showFlagButton: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -729,7 +721,7 @@ void main() {
|
||||
showLoading: false,
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
messageWidget: const Text('test'),
|
||||
message: Message(
|
||||
id: 'testid',
|
||||
@@ -739,7 +731,6 @@ void main() {
|
||||
),
|
||||
),
|
||||
messageTheme: streamTheme.ownMessageTheme,
|
||||
showDeleteMessage: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -786,7 +777,7 @@ void main() {
|
||||
showLoading: false,
|
||||
channel: channel,
|
||||
child: SizedBox(
|
||||
child: StreamMessageActionsModal(
|
||||
child: MessageActionsModal(
|
||||
messageWidget: const Text('test'),
|
||||
message: Message(
|
||||
id: 'testid',
|
||||
@@ -796,7 +787,6 @@ void main() {
|
||||
),
|
||||
),
|
||||
messageTheme: streamTheme.ownMessageTheme,
|
||||
showDeleteMessage: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/src/message_input/attachment_button.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('SendButton onPressed works', (tester) async {
|
||||
var count = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: AttachmentButton(
|
||||
color: StreamChatThemeData.light()
|
||||
.messageInputTheme
|
||||
.actionButtonIdleColor!,
|
||||
onPressed: () {
|
||||
count++;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final button = find.byType(IconButton);
|
||||
expect(button, findsOneWidget);
|
||||
expect(find.byType(StreamSvgIcon), findsOneWidget);
|
||||
await tester.tap(button);
|
||||
expect(count, 1);
|
||||
});
|
||||
|
||||
testGoldens('golden test for AttachmentButton', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: AttachmentButton(
|
||||
color: StreamChatThemeData.light()
|
||||
.messageInputTheme
|
||||
.actionButtonIdleColor!,
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'attachment_button_0');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/src/message_input/clear_input_item_button.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('ClearInputItemButton onPressed works', (tester) async {
|
||||
var count = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: ClearInputItemButton(
|
||||
onTap: () {
|
||||
count++;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final button = find.byType(RawMaterialButton);
|
||||
expect(button, findsOneWidget);
|
||||
expect(find.byType(StreamSvgIcon), findsOneWidget);
|
||||
await tester.tap(button);
|
||||
expect(count, 1);
|
||||
});
|
||||
|
||||
testGoldens('golden test for ClearInputItemButton', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: ClearInputItemButton(
|
||||
onTap: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'clear_input_item_0');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/src/message_input/command_button.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('CommandButton onPressed works', (tester) async {
|
||||
var count = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: CommandButton(
|
||||
color: Colors.red,
|
||||
onPressed: () {
|
||||
count++;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final button = find.byType(IconButton);
|
||||
expect(button, findsOneWidget);
|
||||
await tester.tap(button);
|
||||
expect(count, 1);
|
||||
});
|
||||
|
||||
testGoldens('golden test for CommandButton', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: CommandButton(
|
||||
color: Colors.red,
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'command_button_0');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('CountdownButton works', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const Scaffold(
|
||||
body: Center(
|
||||
child: StreamCountdownButton(count: 5),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('5'), findsOneWidget);
|
||||
});
|
||||
|
||||
testGoldens('golden test for CountdownButton', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: const Scaffold(
|
||||
body: Center(
|
||||
child: StreamCountdownButton(count: 5),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'countdown_button_0');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:stream_chat_flutter/src/message_input/dm_checkbox.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('DmCheckbox onTap works', (tester) async {
|
||||
var count = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: DmCheckbox(
|
||||
foregroundDecoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: StreamChatThemeData.light()
|
||||
.colorTheme
|
||||
.textHighEmphasis
|
||||
.withOpacity(0.5),
|
||||
width: 2,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
color: StreamChatThemeData.light().colorTheme.accentPrimary,
|
||||
onTap: () {
|
||||
count++;
|
||||
},
|
||||
crossFadeState: CrossFadeState.showFirst,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(AnimatedCrossFade), findsOneWidget);
|
||||
final checkbox = find.byType(InkWell);
|
||||
await tester.tap(checkbox);
|
||||
await tester.pumpAndSettle();
|
||||
expect(count, 1);
|
||||
});
|
||||
|
||||
testGoldens('golden test for checked DmCheckbox with border', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: DmCheckbox(
|
||||
foregroundDecoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: StreamChatThemeData.light()
|
||||
.colorTheme
|
||||
.textHighEmphasis
|
||||
.withOpacity(0.5),
|
||||
width: 2,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
color: StreamChatThemeData.light().colorTheme.accentPrimary,
|
||||
onTap: () {},
|
||||
crossFadeState: CrossFadeState.showFirst,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'dm_checkbox_0');
|
||||
});
|
||||
|
||||
testGoldens('golden test for checked DmCheckbox without border',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: DmCheckbox(
|
||||
foregroundDecoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
color: StreamChatThemeData.light().colorTheme.accentPrimary,
|
||||
onTap: () {},
|
||||
crossFadeState: CrossFadeState.showFirst,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'dm_checkbox_1');
|
||||
});
|
||||
|
||||
testGoldens('golden test for unchecked DmCheckbox with border',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: DmCheckbox(
|
||||
foregroundDecoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: StreamChatThemeData.light()
|
||||
.colorTheme
|
||||
.textHighEmphasis
|
||||
.withOpacity(0.5),
|
||||
width: 2,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
color: StreamChatThemeData.light().colorTheme.barsBg,
|
||||
onTap: () {},
|
||||
crossFadeState: CrossFadeState.showSecond,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await screenMatchesGolden(tester, 'dm_checkbox_2');
|
||||
});
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -22,18 +22,22 @@ void main() {
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.isMuted).thenReturn(false);
|
||||
when(() => channel.isMutedStream).thenAnswer((i) => Stream.value(false));
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -46,12 +50,14 @@ void main() {
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]);
|
||||
when(() => channelState.messagesStream).thenAnswer((i) => Stream.value([
|
||||
Message(
|
||||
text: 'hello',
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.messagesStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Message(
|
||||
text: 'hello',
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
@@ -88,18 +94,22 @@ void main() {
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.isMuted).thenReturn(false);
|
||||
when(() => channel.isMutedStream).thenAnswer((i) => Stream.value(false));
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -112,12 +122,14 @@ void main() {
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]);
|
||||
when(() => channelState.messagesStream).thenAnswer((i) => Stream.value([
|
||||
Message(
|
||||
text: 'hello',
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.messagesStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Message(
|
||||
text: 'hello',
|
||||
user: User(id: 'other-user'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||
import 'package:stream_chat_flutter/src/message_list_view/floating_date_divider.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('FloatingDateDivider', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
FloatingDateDivider(
|
||||
reverse: false,
|
||||
itemCount: 3,
|
||||
itemPositionListener: ItemPositionsListener.create(),
|
||||
messages: [
|
||||
Message(),
|
||||
Message(),
|
||||
Message(),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(Positioned), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
late StreamChatClient client;
|
||||
@@ -121,10 +121,11 @@ void main() {
|
||||
expect(find.byType(StreamMessageListView), findsOneWidget);
|
||||
expect(find.byKey(nonEmptyWidgetKey), findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
findBackground,
|
||||
description: 'findBackground',
|
||||
),
|
||||
findsOneWidget);
|
||||
find.byWidgetPredicate(
|
||||
findBackground,
|
||||
description: 'findBackground',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/src/message_list_view/thread_separator.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('ThreadSeparator', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChatTheme(
|
||||
data: StreamChatThemeData.light(),
|
||||
child: Scaffold(
|
||||
body: Center(
|
||||
child: ThreadSeparator(
|
||||
parentMessage: Message(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(DecoratedBox), findsOneWidget);
|
||||
expect(find.byType(Text), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/src/message_reactions_modal.dart';
|
||||
import 'package:stream_chat_flutter/src/reaction_bubble.dart';
|
||||
import 'package:stream_chat_flutter/src/message_widget/reactions/message_reactions_modal.dart';
|
||||
import 'package:stream_chat_flutter/src/message_widget/reactions/reaction_bubble.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -4,7 +4,7 @@ import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -16,21 +16,23 @@ void main() {
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: const Scaffold(
|
||||
body: StreamDeletedMessage(
|
||||
messageTheme: StreamMessageThemeData(
|
||||
createdAtStyle: TextStyle(
|
||||
color: Colors.black,
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: const Scaffold(
|
||||
body: StreamDeletedMessage(
|
||||
messageTheme: StreamMessageThemeData(
|
||||
createdAtStyle: TextStyle(
|
||||
color: Colors.black,
|
||||
),
|
||||
messageTextStyle: TextStyle(),
|
||||
),
|
||||
messageTextStyle: TextStyle(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
expect(find.text('Message deleted'), findsOneWidget);
|
||||
},
|
||||
@@ -50,9 +52,11 @@ void main() {
|
||||
when(() => channel.lastMessageAt).thenReturn(lastMessageAt);
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
@@ -103,9 +107,11 @@ void main() {
|
||||
when(() => channel.lastMessageAt).thenReturn(lastMessageAt);
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
@@ -156,9 +162,11 @@ void main() {
|
||||
when(() => channel.lastMessageAt).thenReturn(lastMessageAt);
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
@@ -5,8 +5,8 @@ import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import 'simple_frame.dart';
|
||||
import '../mocks.dart';
|
||||
import '../simple_frame.dart';
|
||||
|
||||
void expectTextStrings(Iterable<Widget> widgets, List<String> strings) {
|
||||
var currentString = 0;
|
||||
@@ -197,9 +197,11 @@ void main() {
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.isMuted).thenReturn(false);
|
||||
when(() => channel.isMutedStream).thenAnswer((i) => Stream.value(false));
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/src/message_widget/username.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Username', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: Username(
|
||||
message: Message(),
|
||||
messageTheme: StreamChatThemeData.light().ownMessageTheme,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(Text), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -14,14 +14,16 @@ void main() {
|
||||
MaterialApp(
|
||||
home: const Material(child: Text('Home')),
|
||||
routes: <String, WidgetBuilder>{
|
||||
'/next': (BuildContext context) => Material(
|
||||
child: Center(
|
||||
child: StreamChatTheme(
|
||||
data: StreamChatThemeData.fromTheme(theme),
|
||||
child: const StreamBackButton(),
|
||||
),
|
||||
'/next': (BuildContext context) {
|
||||
return Material(
|
||||
child: Center(
|
||||
child: StreamChatTheme(
|
||||
data: StreamChatThemeData.fromTheme(theme),
|
||||
child: const StreamBackButton(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -75,16 +77,18 @@ void main() {
|
||||
MaterialApp(
|
||||
home: const Material(child: Text('Home')),
|
||||
routes: <String, WidgetBuilder>{
|
||||
'/next': (BuildContext context) => Material(
|
||||
child: Center(
|
||||
child: StreamChatTheme(
|
||||
data: StreamChatThemeData.fromTheme(theme),
|
||||
child: StreamBackButton(
|
||||
onPressed: () => customCallbackWasCalled = true,
|
||||
),
|
||||
'/next': (BuildContext context) {
|
||||
return Material(
|
||||
child: Center(
|
||||
child: StreamChatTheme(
|
||||
data: StreamChatThemeData.fromTheme(theme),
|
||||
child: StreamBackButton(
|
||||
onPressed: () => customCallbackWasCalled = true,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -128,7 +132,7 @@ void main() {
|
||||
child: StreamChat(
|
||||
client: client,
|
||||
child: const StreamBackButton(
|
||||
showUnreads: true,
|
||||
showUnreadCount: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -15,16 +15,18 @@ void main() {
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: Scaffold(
|
||||
body: StreamDateDivider(
|
||||
dateTime: DateTime.now(),
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: Scaffold(
|
||||
body: StreamDateDivider(
|
||||
dateTime: DateTime.now(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
expect(find.text('Today'), findsOneWidget);
|
||||
},
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -16,22 +16,24 @@ void main() {
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: const Scaffold(
|
||||
body: Portal(
|
||||
child: SizedBox(
|
||||
child: StreamInfoTile(
|
||||
showMessage: true,
|
||||
message: 'message',
|
||||
child: Text('test'),
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: const Scaffold(
|
||||
body: Portal(
|
||||
child: SizedBox(
|
||||
child: StreamInfoTile(
|
||||
showMessage: true,
|
||||
message: 'message',
|
||||
child: Text('test'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
expect(find.text('message'), findsOneWidget);
|
||||
},
|
||||
@@ -46,22 +48,24 @@ void main() {
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'user-id'));
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: const Scaffold(
|
||||
body: Portal(
|
||||
child: SizedBox(
|
||||
child: StreamInfoTile(
|
||||
showMessage: false,
|
||||
message: 'message',
|
||||
child: Text('test'),
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: const Scaffold(
|
||||
body: Portal(
|
||||
child: SizedBox(
|
||||
child: StreamInfoTile(
|
||||
showMessage: false,
|
||||
message: 'message',
|
||||
child: Text('test'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
expect(find.text('message'), findsNothing);
|
||||
},
|
||||
@@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/src/reaction_bubble.dart';
|
||||
import 'package:stream_chat_flutter/src/message_widget/reactions/reaction_bubble.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testGoldens(
|
||||
@@ -4,7 +4,7 @@ import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -21,9 +21,11 @@ void main() {
|
||||
when(() => channel.lastMessageAt).thenReturn(lastMessageAt);
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
@@ -72,9 +74,11 @@ void main() {
|
||||
when(() => channel.lastMessageAt).thenReturn(lastMessageAt);
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
@@ -124,9 +128,11 @@ void main() {
|
||||
when(() => channel.lastMessageAt).thenReturn(lastMessageAt);
|
||||
when(() => channel.state).thenReturn(channelState);
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
@@ -5,7 +5,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import 'mocks.dart';
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
@@ -29,12 +29,14 @@ void main() {
|
||||
when(() => channelState.unreadCount).thenReturn(1);
|
||||
when(() => channelState.unreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -85,21 +87,25 @@ void main() {
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.isMuted).thenReturn(false);
|
||||
when(() => channel.isMutedStream).thenAnswer((i) => Stream.value(false));
|
||||
when(() => channel.extraDataStream).thenAnswer((i) => Stream.value({
|
||||
'name': 'test',
|
||||
}));
|
||||
when(() => channel.extraDataStream).thenAnswer(
|
||||
(i) => Stream.value({
|
||||
'name': 'test',
|
||||
}),
|
||||
);
|
||||
when(() => channel.extraData).thenReturn({
|
||||
'name': 'test',
|
||||
});
|
||||
when(() => channelState.unreadCount).thenReturn(1);
|
||||
when(() => channelState.unreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]));
|
||||
when(() => channelState.membersStream).thenAnswer(
|
||||
(i) => Stream.value([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
user: User(id: 'user-id'),
|
||||
)
|
||||
]),
|
||||
);
|
||||
when(() => channelState.members).thenReturn([
|
||||
Member(
|
||||
userId: 'user-id',
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
import 'package:stream_chat_flutter/src/video/vlc/vlc_manager_desktop.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
class MockClient extends Mock implements StreamChatClient {
|
||||
MockClient() {
|
||||
@@ -30,6 +31,8 @@ class MockChannelState extends Mock implements ChannelClientState {
|
||||
MockChannelState() {
|
||||
when(() => typingEvents).thenReturn({});
|
||||
when(() => typingEventsStream).thenAnswer((_) => Stream.value({}));
|
||||
when(() => unreadCount).thenReturn(0);
|
||||
when(() => read).thenReturn([]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,3 +41,21 @@ class MockNavigatorObserver extends Mock implements NavigatorObserver {}
|
||||
class MockVoidCallback extends Mock {
|
||||
void call();
|
||||
}
|
||||
|
||||
class MockAttachmentHandler extends Mock implements StreamAttachmentHandler {}
|
||||
|
||||
class MockMember extends Mock implements Member {}
|
||||
|
||||
class MockUser extends Mock implements User {}
|
||||
|
||||
class MockOwnUser extends Mock implements OwnUser {}
|
||||
|
||||
class MockAttachment extends Mock implements Attachment {}
|
||||
|
||||
class MockVlcManagerDesktop extends Mock implements VlcManagerDesktop {}
|
||||
|
||||
class MockStreamMemberListController extends Mock
|
||||
implements StreamMemberListController {
|
||||
@override
|
||||
PagedValue<int, Member> value = const PagedValue.loading();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../../mocks.dart';
|
||||
|
||||
void main() {
|
||||
late StreamChatClient client;
|
||||
late Channel channel;
|
||||
late ChannelClientState channelClientState;
|
||||
late ClientState clientState;
|
||||
|
||||
setUp(() {
|
||||
client = MockClient();
|
||||
clientState = MockClientState();
|
||||
when(() => client.state).thenAnswer((_) => clientState);
|
||||
when(() => clientState.currentUser).thenReturn(OwnUser(id: 'testid'));
|
||||
when(() => clientState.currentUserStream)
|
||||
.thenAnswer((_) => Stream.value(OwnUser(id: 'testid')));
|
||||
channel = MockChannel();
|
||||
when(() => channel.on(any(), any(), any(), any()))
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
channelClientState = MockChannelState();
|
||||
when(() => channel.client).thenReturn(client);
|
||||
when(() => channel.state).thenReturn(channelClientState);
|
||||
|
||||
when(() => channelClientState.membersStream)
|
||||
.thenAnswer((_) => const Stream.empty());
|
||||
when(() => channelClientState.members).thenReturn([]);
|
||||
});
|
||||
|
||||
testWidgets('renders empty member list view', (tester) async {
|
||||
const emptyWidgetKey = Key('empty_widget');
|
||||
final controller = MockStreamMemberListController();
|
||||
|
||||
when(controller.doInitialLoad).thenAnswer((_) async {
|
||||
controller.value = const PagedValue(items: []);
|
||||
});
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: StreamChat(
|
||||
client: client,
|
||||
child: StreamChannel(
|
||||
channel: channel,
|
||||
child: Scaffold(
|
||||
body: StreamMemberListView(
|
||||
emptyBuilder: (_) => Container(key: emptyWidgetKey),
|
||||
controller: controller,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(StreamMemberListView), findsOneWidget);
|
||||
expect(find.byKey(emptyWidgetKey), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -6,12 +6,14 @@ class SimpleFrame extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFFFFFF),
|
||||
border: Border.all(color: const Color(0xFF9E9E9E)),
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFFFFFF),
|
||||
border: Border.all(color: const Color(0xFF9E9E9E)),
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/src/stream_chat_configuration.dart';
|
||||
|
||||
void main() {
|
||||
group('StreamChatConfigurationProvider', () {
|
||||
testWidgets(
|
||||
'should provide the StreamChatConfiguration class with default data',
|
||||
(t) async {
|
||||
final configuration = StreamChatConfigurationData();
|
||||
late final StreamChatConfigurationData configurationFromProvider;
|
||||
await t.pumpWidget(StreamChatConfiguration(
|
||||
data: configuration,
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
configurationFromProvider = StreamChatConfiguration.of(context);
|
||||
return const SizedBox();
|
||||
},
|
||||
),
|
||||
));
|
||||
|
||||
expect(configuration, configurationFromProvider);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'should provide the StreamChatConfiguration class with custom data',
|
||||
(t) async {
|
||||
final configuration = StreamChatConfigurationData().copyWith(
|
||||
enforceUniqueReactions: false,
|
||||
);
|
||||
late final StreamChatConfigurationData configurationFromProvider;
|
||||
await t.pumpWidget(StreamChatConfiguration(
|
||||
data: configuration,
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
configurationFromProvider = StreamChatConfiguration.of(context);
|
||||
return const SizedBox();
|
||||
},
|
||||
),
|
||||
));
|
||||
|
||||
expect(configuration, configurationFromProvider);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
// ignore_for_file: deprecated_member_use_from_same_package
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
test('ChannelListViewThemeData copyWith, ==, hashCode basics', () {
|
||||
expect(const StreamChannelListViewThemeData(),
|
||||
const StreamChannelListViewThemeData().copyWith());
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light ChannelListViewThemeData lerps completely to dark ChannelListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const StreamChannelListViewThemeData().lerp(
|
||||
_channelListViewThemeDataControl,
|
||||
_channelListViewThemeDataControlDark,
|
||||
1),
|
||||
_channelListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light ChannelListViewThemeData lerps halfway to dark ChannelListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const StreamChannelListViewThemeData().lerp(
|
||||
_channelListViewThemeDataControl,
|
||||
_channelListViewThemeDataControlDark,
|
||||
0.5),
|
||||
_channelListViewThemeDataControlHalfLerp);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Dark ChannelListViewThemeData lerps completely to light ChannelListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const StreamChannelListViewThemeData().lerp(
|
||||
_channelListViewThemeDataControlDark,
|
||||
_channelListViewThemeDataControl,
|
||||
1),
|
||||
_channelListViewThemeDataControl);
|
||||
});
|
||||
|
||||
test('Merging dark and light themes results in a dark theme', () {
|
||||
expect(
|
||||
_channelListViewThemeDataControl
|
||||
.merge(_channelListViewThemeDataControlDark),
|
||||
_channelListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no ChannelListViewThemeData returns default light theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
body: StreamChannel(
|
||||
channel: MockChannel(),
|
||||
child: ChannelListView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final channelListViewTheme = StreamChannelListViewTheme.of(_context);
|
||||
expect(channelListViewTheme.backgroundColor,
|
||||
_channelListViewThemeDataControl.backgroundColor);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no ChannelListViewThemeData returns default dark theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
streamChatThemeData: StreamChatThemeData.dark(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
body: StreamChannel(
|
||||
channel: MockChannel(),
|
||||
child: const StreamMessageListView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final channelListViewTheme = StreamChannelListViewTheme.of(_context);
|
||||
expect(channelListViewTheme.backgroundColor,
|
||||
_channelListViewThemeDataControlDark.backgroundColor);
|
||||
});
|
||||
}
|
||||
|
||||
final _channelListViewThemeDataControl = StreamChannelListViewThemeData(
|
||||
backgroundColor: StreamColorTheme.light().appBg,
|
||||
);
|
||||
|
||||
const _channelListViewThemeDataControlHalfLerp = StreamChannelListViewThemeData(
|
||||
backgroundColor: Color(0xff818384),
|
||||
);
|
||||
|
||||
final _channelListViewThemeDataControlDark = StreamChannelListViewThemeData(
|
||||
backgroundColor: StreamColorTheme.dark().appBg,
|
||||
);
|
||||
@@ -1,137 +0,0 @@
|
||||
// ignore: lines_longer_than_80_chars
|
||||
// ignore_for_file: deprecated_member_use, deprecated_member_use_from_same_package
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
test('MessageSearchListViewThemeData copyWith, ==, hashCode basics', () {
|
||||
expect(const StreamMessageSearchListViewThemeData(),
|
||||
const StreamMessageSearchListViewThemeData().copyWith());
|
||||
expect(const StreamMessageSearchListViewThemeData().hashCode,
|
||||
const StreamMessageSearchListViewThemeData().copyWith().hashCode);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light MessageSearchListViewThemeData lerps completely to dark MessageSearchListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const StreamMessageSearchListViewThemeData().lerp(
|
||||
_messageSearchListViewThemeDataControl,
|
||||
_messageSearchListViewThemeDataControlDark,
|
||||
1),
|
||||
_messageSearchListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light MessageSearchListViewThemeData lerps halfway to dark MessageSearchListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const StreamMessageSearchListViewThemeData().lerp(
|
||||
_messageSearchListViewThemeDataControl,
|
||||
_messageSearchListViewThemeDataControlDark,
|
||||
0.5),
|
||||
_messageSearchListViewThemeDataControlHalfLerp);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Dark MessageSearchListViewThemeData lerps completely to light MessageSearchListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const StreamMessageSearchListViewThemeData().lerp(
|
||||
_messageSearchListViewThemeDataControlDark,
|
||||
_messageSearchListViewThemeDataControl,
|
||||
1),
|
||||
_messageSearchListViewThemeDataControl);
|
||||
});
|
||||
|
||||
test('Merging dark and light themes results in a dark theme', () {
|
||||
expect(
|
||||
_messageSearchListViewThemeDataControl
|
||||
.merge(_messageSearchListViewThemeDataControlDark),
|
||||
_messageSearchListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'''Passing no MessageSearchListViewThemeData returns default light theme values''',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
body: MessageSearchBloc(
|
||||
child: MessageSearchListView(
|
||||
filters: Filter.in_('members', const ['test_id']),
|
||||
messageQuery: 'test query',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final messageSearchListViewTheme =
|
||||
StreamMessageSearchListViewTheme.of(_context);
|
||||
expect(messageSearchListViewTheme.backgroundColor,
|
||||
_messageSearchListViewThemeDataControl.backgroundColor);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'''Passing no MessageSearchListViewThemeData returns default dark theme values''',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
streamChatThemeData: StreamChatThemeData.dark(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
body: MessageSearchBloc(
|
||||
child: MessageSearchListView(
|
||||
filters: Filter.in_('members', const ['test_id']),
|
||||
messageQuery: 'test query',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final messageSearchListViewTheme =
|
||||
StreamMessageSearchListViewTheme.of(_context);
|
||||
expect(messageSearchListViewTheme.backgroundColor,
|
||||
_messageSearchListViewThemeDataControlDark.backgroundColor);
|
||||
});
|
||||
}
|
||||
|
||||
final _messageSearchListViewThemeDataControl =
|
||||
StreamMessageSearchListViewThemeData(
|
||||
backgroundColor: StreamColorTheme.light().appBg,
|
||||
);
|
||||
|
||||
const _messageSearchListViewThemeDataControlHalfLerp =
|
||||
StreamMessageSearchListViewThemeData(
|
||||
backgroundColor: Color(0xff818384),
|
||||
);
|
||||
|
||||
final _messageSearchListViewThemeDataControlDark =
|
||||
StreamMessageSearchListViewThemeData(
|
||||
backgroundColor: StreamColorTheme.dark().appBg,
|
||||
);
|
||||
@@ -1,119 +0,0 @@
|
||||
// ignore: lines_longer_than_80_chars
|
||||
// ignore_for_file: deprecated_member_use_from_same_package, deprecated_member_use
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
import '../mocks.dart';
|
||||
|
||||
void main() {
|
||||
test('UserListViewThemeData copyWith, ==, hashCode basics', () {
|
||||
expect(const StreamUserListViewThemeData(),
|
||||
const StreamUserListViewThemeData().copyWith());
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light UserListViewThemeData lerps completely to dark UserListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const StreamUserListViewThemeData().lerp(_userListViewThemeDataControl,
|
||||
_userListViewThemeDataControlDark, 1),
|
||||
_userListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Light UserListViewThemeData lerps halfway to dark UserListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const StreamUserListViewThemeData().lerp(_userListViewThemeDataControl,
|
||||
_userListViewThemeDataControlDark, 0.5),
|
||||
_userListViewThemeDataControlHalfLerp);
|
||||
});
|
||||
|
||||
test(
|
||||
'''Dark UserListViewThemeData lerps completely to light UserListViewThemeData''',
|
||||
() {
|
||||
expect(
|
||||
const StreamUserListViewThemeData().lerp(
|
||||
_userListViewThemeDataControlDark,
|
||||
_userListViewThemeDataControl,
|
||||
1),
|
||||
_userListViewThemeDataControl);
|
||||
});
|
||||
|
||||
test('Merging dark and light themes results in a dark theme', () {
|
||||
expect(
|
||||
_userListViewThemeDataControl.merge(_userListViewThemeDataControlDark),
|
||||
_userListViewThemeDataControlDark);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no ChannelListViewThemeData returns default light theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
body: UsersBloc(
|
||||
child: UserListView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final userListViewTheme = StreamUserListViewTheme.of(_context);
|
||||
expect(userListViewTheme.backgroundColor,
|
||||
_userListViewThemeDataControl.backgroundColor);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Passing no ChannelListViewThemeData returns default dark theme values',
|
||||
(WidgetTester tester) async {
|
||||
late BuildContext _context;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: (context, child) => StreamChat(
|
||||
client: MockClient(),
|
||||
streamChatThemeData: StreamChatThemeData.dark(),
|
||||
child: child,
|
||||
),
|
||||
home: Builder(
|
||||
builder: (BuildContext context) {
|
||||
_context = context;
|
||||
return Scaffold(
|
||||
body: UsersBloc(
|
||||
child: UserListView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final userListViewTheme = StreamUserListViewTheme.of(_context);
|
||||
expect(userListViewTheme.backgroundColor,
|
||||
_userListViewThemeDataControlDark.backgroundColor);
|
||||
});
|
||||
}
|
||||
|
||||
final _userListViewThemeDataControl = StreamUserListViewThemeData(
|
||||
backgroundColor: StreamColorTheme.light().appBg,
|
||||
);
|
||||
|
||||
const _userListViewThemeDataControlHalfLerp = StreamUserListViewThemeData(
|
||||
backgroundColor: Color(0xff818384),
|
||||
);
|
||||
|
||||
final _userListViewThemeDataControlDark = StreamUserListViewThemeData(
|
||||
backgroundColor: StreamColorTheme.dark().appBg,
|
||||
);
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_flutter/src/extension.dart';
|
||||
import 'package:stream_chat_flutter/src/utils/extensions.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
|
||||
void main() {
|
||||
@@ -67,4 +67,21 @@ void main() {
|
||||
expect([user].search('franc'), [user]);
|
||||
});
|
||||
});
|
||||
|
||||
group('String.isOnlyEmoji', () {
|
||||
test('should return false for empty or > 3 strings', () {
|
||||
expect(''.isOnlyEmoji, false);
|
||||
expect('aaa📝💜'.isOnlyEmoji, false);
|
||||
expect('📝💜📝💜'.isOnlyEmoji, false);
|
||||
});
|
||||
|
||||
test('should detect strings made only by emojis', () {
|
||||
expect('a📝💜'.isOnlyEmoji, false);
|
||||
expect('📝💜📝'.isOnlyEmoji, true);
|
||||
expect('🌶'.isOnlyEmoji, true);
|
||||
expect('🌶1'.isOnlyEmoji, false);
|
||||
expect('👨👨👨👨'.isOnlyEmoji, true);
|
||||
expect('👨👨👨👨 '.isOnlyEmoji, true);
|
||||
});
|
||||
});
|
||||
}
|
||||