stream-chat-react-native-core 4.3.1-beta.1 → 4.4.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/components/Attachment/Giphy.js +31 -25
  3. package/lib/commonjs/components/Attachment/Giphy.js.map +1 -1
  4. package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js +11 -7
  5. package/lib/commonjs/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
  6. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  7. package/lib/commonjs/components/Chat/Chat.js.map +1 -1
  8. package/lib/commonjs/components/Message/Message.js.map +1 -1
  9. package/lib/commonjs/components/Message/MessageSimple/MessageContent.js +4 -4
  10. package/lib/commonjs/components/Message/MessageSimple/MessageContent.js.map +1 -1
  11. package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js +4 -4
  12. package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js.map +1 -1
  13. package/lib/commonjs/components/Message/MessageSimple/utils/renderText.md +1 -1
  14. package/lib/commonjs/components/MessageList/ScrollToBottomButton.js +8 -6
  15. package/lib/commonjs/components/MessageList/ScrollToBottomButton.js.map +1 -1
  16. package/lib/commonjs/contexts/attachmentPickerContext/AttachmentPickerContext.js.map +1 -1
  17. package/lib/commonjs/contexts/channelContext/ChannelContext.js.map +1 -1
  18. package/lib/commonjs/contexts/channelContext/ChannelContext.md +2 -2
  19. package/lib/commonjs/contexts/channelsContext/ChannelsContext.js.map +1 -1
  20. package/lib/commonjs/contexts/channelsContext/ChannelsContext.md +2 -2
  21. package/lib/commonjs/contexts/chatContext/ChatContext.md +2 -2
  22. package/lib/commonjs/contexts/imageGalleryContext/ImageGalleryContext.md +2 -2
  23. package/lib/commonjs/contexts/keyboardContext/KeyboardContext.md +1 -1
  24. package/lib/commonjs/contexts/messageContext/MessageContext.js.map +1 -1
  25. package/lib/commonjs/contexts/messageContext/MessageContext.md +1 -1
  26. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  27. package/lib/commonjs/contexts/messageInputContext/MessageInputContext.md +1 -1
  28. package/lib/commonjs/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
  29. package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
  30. package/lib/commonjs/contexts/messagesContext/MessagesContext.md +1 -1
  31. package/lib/commonjs/contexts/overlayContext/OverlayContext.md +2 -2
  32. package/lib/commonjs/contexts/paginatedMessageListContext/PaginatedMessageListContext.md +2 -2
  33. package/lib/commonjs/contexts/suggestionsContext/SuggestionsContext.md +1 -1
  34. package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
  35. package/lib/commonjs/contexts/typingContext/TypingContext.md +2 -2
  36. package/lib/commonjs/version.json +1 -1
  37. package/lib/module/components/Attachment/Giphy.js +31 -25
  38. package/lib/module/components/Attachment/Giphy.js.map +1 -1
  39. package/lib/module/components/AttachmentPicker/AttachmentPicker.js +11 -7
  40. package/lib/module/components/AttachmentPicker/AttachmentPicker.js.map +1 -1
  41. package/lib/module/components/Channel/Channel.js.map +1 -1
  42. package/lib/module/components/Chat/Chat.js.map +1 -1
  43. package/lib/module/components/Message/Message.js.map +1 -1
  44. package/lib/module/components/Message/MessageSimple/MessageContent.js +4 -4
  45. package/lib/module/components/Message/MessageSimple/MessageContent.js.map +1 -1
  46. package/lib/module/components/Message/MessageSimple/MessageSimple.js +4 -4
  47. package/lib/module/components/Message/MessageSimple/MessageSimple.js.map +1 -1
  48. package/lib/module/components/Message/MessageSimple/utils/renderText.md +1 -1
  49. package/lib/module/components/MessageList/ScrollToBottomButton.js +8 -6
  50. package/lib/module/components/MessageList/ScrollToBottomButton.js.map +1 -1
  51. package/lib/module/contexts/attachmentPickerContext/AttachmentPickerContext.js.map +1 -1
  52. package/lib/module/contexts/channelContext/ChannelContext.js.map +1 -1
  53. package/lib/module/contexts/channelContext/ChannelContext.md +2 -2
  54. package/lib/module/contexts/channelsContext/ChannelsContext.js.map +1 -1
  55. package/lib/module/contexts/channelsContext/ChannelsContext.md +2 -2
  56. package/lib/module/contexts/chatContext/ChatContext.md +2 -2
  57. package/lib/module/contexts/imageGalleryContext/ImageGalleryContext.md +2 -2
  58. package/lib/module/contexts/keyboardContext/KeyboardContext.md +1 -1
  59. package/lib/module/contexts/messageContext/MessageContext.js.map +1 -1
  60. package/lib/module/contexts/messageContext/MessageContext.md +1 -1
  61. package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
  62. package/lib/module/contexts/messageInputContext/MessageInputContext.md +1 -1
  63. package/lib/module/contexts/messageOverlayContext/MessageOverlayContext.js.map +1 -1
  64. package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
  65. package/lib/module/contexts/messagesContext/MessagesContext.md +1 -1
  66. package/lib/module/contexts/overlayContext/OverlayContext.md +2 -2
  67. package/lib/module/contexts/paginatedMessageListContext/PaginatedMessageListContext.md +2 -2
  68. package/lib/module/contexts/suggestionsContext/SuggestionsContext.md +1 -1
  69. package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
  70. package/lib/module/contexts/typingContext/TypingContext.md +2 -2
  71. package/lib/module/version.json +1 -1
  72. package/lib/typescript/components/AttachmentPicker/AttachmentPicker.d.ts +4 -4
  73. package/lib/typescript/components/Channel/Channel.d.ts +2 -2
  74. package/lib/typescript/components/Chat/Chat.d.ts +1 -1
  75. package/lib/typescript/components/Message/Message.d.ts +2 -2
  76. package/lib/typescript/contexts/attachmentPickerContext/AttachmentPickerContext.d.ts +3 -3
  77. package/lib/typescript/contexts/channelContext/ChannelContext.d.ts +2 -2
  78. package/lib/typescript/contexts/channelsContext/ChannelsContext.d.ts +6 -6
  79. package/lib/typescript/contexts/messageContext/MessageContext.d.ts +2 -2
  80. package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +6 -6
  81. package/lib/typescript/contexts/messageOverlayContext/MessageOverlayContext.d.ts +3 -3
  82. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +20 -20
  83. package/lib/typescript/contexts/themeContext/utils/theme.d.ts +1 -0
  84. package/package.json +2 -2
  85. package/src/components/Attachment/Giphy.tsx +7 -1
  86. package/src/components/Attachment/__tests__/Attachment.test.js +0 -61
  87. package/src/components/Attachment/__tests__/Giphy.test.js +290 -0
  88. package/src/components/AttachmentPicker/AttachmentPicker.tsx +27 -17
  89. package/src/components/Channel/Channel.tsx +2 -2
  90. package/src/components/Channel/__tests__/isAttachmentEqualHandler.test.js +1 -1
  91. package/src/components/Chat/Chat.tsx +1 -1
  92. package/src/components/Message/Message.tsx +2 -2
  93. package/src/components/Message/MessageSimple/MessageContent.tsx +16 -17
  94. package/src/components/Message/MessageSimple/MessageSimple.tsx +11 -12
  95. package/src/components/Message/MessageSimple/utils/renderText.md +1 -1
  96. package/src/components/MessageInput/__tests__/__snapshots__/FileUploadPreview.test.js.snap +8 -8
  97. package/src/components/MessageInput/__tests__/__snapshots__/MessageInput.test.js.snap +2 -2
  98. package/src/components/MessageList/ScrollToBottomButton.tsx +2 -1
  99. package/src/components/MessageList/__tests__/__snapshots__/ScrollToBottomButton.test.js.snap +1 -0
  100. package/src/contexts/attachmentPickerContext/AttachmentPickerContext.tsx +3 -3
  101. package/src/contexts/channelContext/ChannelContext.md +2 -2
  102. package/src/contexts/channelContext/ChannelContext.tsx +2 -2
  103. package/src/contexts/channelsContext/ChannelsContext.md +2 -2
  104. package/src/contexts/channelsContext/ChannelsContext.tsx +6 -6
  105. package/src/contexts/chatContext/ChatContext.md +2 -2
  106. package/src/contexts/imageGalleryContext/ImageGalleryContext.md +2 -2
  107. package/src/contexts/keyboardContext/KeyboardContext.md +1 -1
  108. package/src/contexts/messageContext/MessageContext.md +1 -1
  109. package/src/contexts/messageContext/MessageContext.tsx +2 -2
  110. package/src/contexts/messageInputContext/MessageInputContext.md +1 -1
  111. package/src/contexts/messageInputContext/MessageInputContext.tsx +6 -6
  112. package/src/contexts/messageOverlayContext/MessageOverlayContext.tsx +3 -3
  113. package/src/contexts/messagesContext/MessagesContext.md +1 -1
  114. package/src/contexts/messagesContext/MessagesContext.tsx +20 -20
  115. package/src/contexts/overlayContext/OverlayContext.md +2 -2
  116. package/src/contexts/paginatedMessageListContext/PaginatedMessageListContext.md +2 -2
  117. package/src/contexts/suggestionsContext/SuggestionsContext.md +1 -1
  118. package/src/contexts/themeContext/utils/theme.ts +1 -0
  119. package/src/contexts/typingContext/TypingContext.md +2 -2
  120. package/src/version.json +1 -1
@@ -44,22 +44,22 @@ export declare type MessageContentType = 'attachments' | 'files' | 'gallery' | '
44
44
  export declare type MessagesContextValue<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
45
45
  /**
46
46
  * UI component for Attachment.
47
- * Defaults to: [Attachment](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Attachment.tsx)
47
+ * Defaults to: [Attachment](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Attachment/Attachment.tsx)
48
48
  */
49
49
  Attachment: React.ComponentType<AttachmentProps<StreamChatGenerics>>;
50
50
  /**
51
51
  * UI component to display AttachmentActions. e.g., send, shuffle, cancel in case of giphy
52
- * Defaults to: [AttachmentActions](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/AttachmentActions.tsx)
52
+ * Defaults to: [AttachmentActions](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Attachment/AttachmentActions.tsx)
53
53
  */
54
54
  AttachmentActions: React.ComponentType<AttachmentActionsProps<StreamChatGenerics>>;
55
55
  /**
56
56
  * UI component to display generic media type e.g. giphy, url preview etc
57
- * Defaults to: [Card](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Card.tsx)
57
+ * Defaults to: [Card](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Attachment/Card.tsx)
58
58
  */
59
59
  Card: React.ComponentType<CardProps<StreamChatGenerics>>;
60
60
  /**
61
61
  * UI component for DateHeader
62
- * Defaults to: [DateHeader](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageList/DateHeader.tsx)
62
+ * Defaults to: [DateHeader](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/MessageList/DateHeader.tsx)
63
63
  **/
64
64
  DateHeader: React.ComponentType<DateHeaderProps>;
65
65
  /** Should keyboard be dismissed when messaged is touched */
@@ -67,28 +67,28 @@ export declare type MessagesContextValue<StreamChatGenerics extends DefaultStrea
67
67
  enableMessageGroupingByUser: boolean;
68
68
  /**
69
69
  * UI component to display File type attachment.
70
- * Defaults to: [FileAttachment](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/FileAttachment.tsx)
70
+ * Defaults to: [FileAttachment](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Attachment/FileAttachment.tsx)
71
71
  */
72
72
  FileAttachment: React.ComponentType<FileAttachmentProps<StreamChatGenerics>>;
73
73
  /**
74
74
  * UI component to display group of File type attachments or multiple file attachments (in single message).
75
- * Defaults to: [FileAttachmentGroup](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/FileAttachmentGroup.tsx)
75
+ * Defaults to: [FileAttachmentGroup](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Attachment/FileAttachmentGroup.tsx)
76
76
  */
77
77
  FileAttachmentGroup: React.ComponentType<FileAttachmentGroupProps<StreamChatGenerics>>;
78
78
  /**
79
79
  * UI component for attachment icon for type 'file' attachment.
80
- * Defaults to: https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/FileIcon.tsx
80
+ * Defaults to: https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Attachment/FileIcon.tsx
81
81
  */
82
82
  FileAttachmentIcon: React.ComponentType<FileIconProps>;
83
83
  FlatList: typeof FlatList;
84
84
  /**
85
85
  * UI component to display image attachments
86
- * Defaults to: [Gallery](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Gallery.tsx)
86
+ * Defaults to: [Gallery](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Attachment/Gallery.tsx)
87
87
  */
88
88
  Gallery: React.ComponentType<GalleryProps<StreamChatGenerics>>;
89
89
  /**
90
90
  * UI component for Giphy
91
- * Defaults to: [Giphy](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Giphy.tsx)
91
+ * Defaults to: [Giphy](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Attachment/Giphy.tsx)
92
92
  */
93
93
  Giphy: React.ComponentType<GiphyProps<StreamChatGenerics>>;
94
94
  /**
@@ -101,30 +101,30 @@ export declare type MessagesContextValue<StreamChatGenerics extends DefaultStrea
101
101
  initialScrollToFirstUnreadMessage: boolean;
102
102
  /**
103
103
  * UI component for Message Date Separator Component
104
- * Defaults to: [InlineDateSeparator](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageList/InlineDateSeparator.tsx)
104
+ * Defaults to: [InlineDateSeparator](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/MessageList/InlineDateSeparator.tsx)
105
105
  */
106
106
  InlineDateSeparator: React.ComponentType<InlineDateSeparatorProps>;
107
107
  /**
108
108
  * UI component for InlineUnreadIndicator
109
- * Defaults to: [InlineUnreadIndicator](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/InlineUnreadIndicator.tsx)
109
+ * Defaults to: [InlineUnreadIndicator](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Message/MessageSimple/InlineUnreadIndicator.tsx)
110
110
  **/
111
111
  InlineUnreadIndicator: React.ComponentType;
112
112
  Message: React.ComponentType<MessageProps<StreamChatGenerics>>;
113
113
  /**
114
114
  * UI component for MessageAvatar
115
- * Defaults to: [MessageAvatar](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/MessageAvatar.tsx)
115
+ * Defaults to: [MessageAvatar](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Message/MessageSimple/MessageAvatar.tsx)
116
116
  **/
117
117
  MessageAvatar: React.ComponentType<MessageAvatarProps<StreamChatGenerics>>;
118
118
  /**
119
119
  * UI component for MessageContent
120
- * Defaults to: [MessageContent](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/MessageContent.tsx)
120
+ * Defaults to: [MessageContent](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Message/MessageSimple/MessageContent.tsx)
121
121
  */
122
122
  MessageContent: React.ComponentType<MessageContentProps<StreamChatGenerics>>;
123
123
  /** Order to render the message content */
124
124
  messageContentOrder: MessageContentType[];
125
125
  /**
126
126
  * UI component for MessageDeleted
127
- * Defaults to: [MessageDeleted](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageSimple/MessageDeleted.tsx)
127
+ * Defaults to: [MessageDeleted](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/MessageSimple/MessageDeleted.tsx)
128
128
  */
129
129
  MessageDeleted: React.ComponentType<MessageDeletedProps<StreamChatGenerics>>;
130
130
  /**
@@ -138,22 +138,22 @@ export declare type MessagesContextValue<StreamChatGenerics extends DefaultStrea
138
138
  MessagePinnedHeader: React.ComponentType<MessagePinnedHeaderProps<StreamChatGenerics>>;
139
139
  /**
140
140
  * UI component for MessageReplies
141
- * Defaults to: [MessageReplies](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageSimple/MessageReplies.tsx)
141
+ * Defaults to: [MessageReplies](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/MessageSimple/MessageReplies.tsx)
142
142
  */
143
143
  MessageReplies: React.ComponentType<MessageRepliesProps<StreamChatGenerics>>;
144
144
  /**
145
145
  * UI Component for MessageRepliesAvatars
146
- * Defaults to: [MessageRepliesAvatars](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/MessageSimple/MessageRepliesAvatars.tsx)
146
+ * Defaults to: [MessageRepliesAvatars](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/MessageSimple/MessageRepliesAvatars.tsx)
147
147
  */
148
148
  MessageRepliesAvatars: React.ComponentType<MessageRepliesAvatarsProps<StreamChatGenerics>>;
149
149
  /**
150
150
  * UI component for MessageSimple
151
- * Defaults to: [MessageSimple](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/MessageSimple.tsx)
151
+ * Defaults to: [MessageSimple](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Message/MessageSimple/MessageSimple.tsx)
152
152
  */
153
153
  MessageSimple: React.ComponentType<MessageSimpleProps<StreamChatGenerics>>;
154
154
  /**
155
155
  * UI component for MessageStatus (delivered/read)
156
- * Defaults to: [MessageStatus](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Message/MessageSimple/MessageStatus.tsx)
156
+ * Defaults to: [MessageStatus](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Message/MessageSimple/MessageStatus.tsx)
157
157
  */
158
158
  MessageStatus: React.ComponentType<MessageStatusProps<StreamChatGenerics>>;
159
159
  /**
@@ -167,7 +167,7 @@ export declare type MessagesContextValue<StreamChatGenerics extends DefaultStrea
167
167
  OverlayReactionList: React.ComponentType<OverlayReactionListProps<StreamChatGenerics>>;
168
168
  /**
169
169
  * UI component for ReactionList
170
- * Defaults to: [ReactionList](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Reaction/ReactionList.tsx)
170
+ * Defaults to: [ReactionList](https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Reaction/ReactionList.tsx)
171
171
  */
172
172
  ReactionList: React.ComponentType<ReactionListProps<StreamChatGenerics>>;
173
173
  removeMessage: (message: {
@@ -208,7 +208,7 @@ export declare type MessagesContextValue<StreamChatGenerics extends DefaultStrea
208
208
  }) => void;
209
209
  /**
210
210
  * Custom UI component to display enriched url preview.
211
- * Defaults to https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Card.tsx
211
+ * Defaults to https://github.com/GetStream/stream-chat-react-native/blob/master/package/src/components/Attachment/Card.tsx
212
212
  */
213
213
  UrlPreview: React.ComponentType<CardProps<StreamChatGenerics>>;
214
214
  /**
@@ -330,6 +330,7 @@ export declare type Theme = {
330
330
  unreadCountNotificationContainer: ViewStyle;
331
331
  unreadCountNotificationText: TextStyle;
332
332
  wrapper: ViewStyle;
333
+ chevronColor?: Color;
333
334
  };
334
335
  typingIndicatorContainer: ViewStyle;
335
336
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stream-chat-react-native-core",
3
3
  "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
4
- "version": "4.3.1-beta.1",
4
+ "version": "4.4.0-beta.1",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -126,7 +126,7 @@
126
126
  "eslint-plugin-sort-destructure-keys": "1.3.5",
127
127
  "eslint-plugin-typescript-sort-keys": "1.6.0",
128
128
  "jest": "26.6.3",
129
- "moment": "2.29.1",
129
+ "moment": "2.29.2",
130
130
  "prettier": "2.3.0",
131
131
  "react": "17.0.2",
132
132
  "react-docgen-typescript": "1.22.0",
@@ -65,6 +65,7 @@ const styles = StyleSheet.create({
65
65
  },
66
66
  giphyHeaderTitle: {
67
67
  fontSize: 14,
68
+ marginLeft: 8,
68
69
  },
69
70
  giphyMask: {
70
71
  bottom: 8,
@@ -84,7 +85,8 @@ const styles = StyleSheet.create({
84
85
  width: '60%',
85
86
  },
86
87
  selectionContainer: {
87
- borderBottomLeftRadius: 8,
88
+ borderBottomRightRadius: 0,
89
+ borderRadius: 16,
88
90
  borderWidth: 1,
89
91
  overflow: 'hidden',
90
92
  width: 272,
@@ -201,6 +203,7 @@ const GiphyWithContext = <
201
203
  { backgroundColor: white, borderColor: `${black}0D` },
202
204
  selectionContainer,
203
205
  ]}
206
+ testID='giphy-action-attachment'
204
207
  >
205
208
  <View style={[styles.header, header]}>
206
209
  <GiphyIcon />
@@ -229,6 +232,7 @@ const GiphyWithContext = <
229
232
  { borderColor: grey_gainsboro, borderRightWidth: 1 },
230
233
  buttonContainer,
231
234
  ]}
235
+ testID={`${actions?.[2].value}-action-button`}
232
236
  >
233
237
  <Text style={[styles.cancel, { color: grey }, cancel]}>{actions?.[2].text}</Text>
234
238
  </TouchableOpacity>
@@ -243,6 +247,7 @@ const GiphyWithContext = <
243
247
  { borderColor: grey_gainsboro, borderRightWidth: 1 },
244
248
  buttonContainer,
245
249
  ]}
250
+ testID={`${actions?.[1].value}-action-button`}
246
251
  >
247
252
  <Text style={[styles.shuffle, { color: grey }, shuffle]}>{actions?.[1].text}</Text>
248
253
  </TouchableOpacity>
@@ -253,6 +258,7 @@ const GiphyWithContext = <
253
258
  }
254
259
  }}
255
260
  style={[styles.buttonContainer, { borderColor: grey_gainsboro }, buttonContainer]}
261
+ testID={`${actions?.[0].value}-action-button`}
256
262
  >
257
263
  <Text style={[styles.send, { color: accent_blue }, send]}>{actions?.[0].text}</Text>
258
264
  </TouchableOpacity>
@@ -10,9 +10,7 @@ import {
10
10
  generateAudioAttachment,
11
11
  generateCardAttachment,
12
12
  generateFileAttachment,
13
- generateGiphyAttachment,
14
13
  generateImageAttachment,
15
- generateImgurAttachment,
16
14
  } from '../../../mock-builders/generator/attachment';
17
15
  import { generateMessage } from '../../../mock-builders/generator/message';
18
16
  import { Attachment } from '../Attachment';
@@ -53,65 +51,6 @@ describe('Attachment', () => {
53
51
  });
54
52
  });
55
53
 
56
- it('should render Card component for "imgur" type attachment', async () => {
57
- const attachment = generateImgurAttachment();
58
- const { getByTestId } = render(getAttachmentComponent({ attachment }));
59
-
60
- await waitFor(() => {
61
- expect(getByTestId('giphy-attachment')).toBeTruthy();
62
- });
63
- });
64
-
65
- it('should render Card component for "giphy" type attachment', async () => {
66
- const attachment = generateGiphyAttachment();
67
- const { getByTestId } = render(getAttachmentComponent({ attachment }));
68
-
69
- await waitFor(() => {
70
- expect(getByTestId('giphy-attachment')).toBeTruthy();
71
- });
72
- });
73
-
74
- it('"giphy" attachment size should be customisable', async () => {
75
- const attachment = generateGiphyAttachment();
76
- attachment.giphy = {
77
- fixed_height: {
78
- height: '200',
79
- url: 'https://media1.giphy.com/media/test/fixed_height.gif',
80
- width: '375',
81
- },
82
- original: {
83
- height: '256',
84
- url: 'https://media1.giphy.com/media/test/original.gif',
85
- width: '480',
86
- },
87
- };
88
- const { getByTestId: getByTestIdFixedHeight } = render(
89
- getAttachmentComponent({ attachment, giphyVersion: 'fixed_height' }),
90
- );
91
- const { getByTestId: getByTestIdOriginal } = render(
92
- getAttachmentComponent({ attachment, giphyVersion: 'original' }),
93
- );
94
- await waitFor(() => {
95
- const checkImageProps = (imageProps, specificSizedGiphyData) => {
96
- let imageStyle = imageProps.style;
97
- if (Array.isArray(imageStyle)) {
98
- imageStyle = Object.assign({}, ...imageStyle);
99
- }
100
- expect(imageStyle.height).toBe(parseFloat(specificSizedGiphyData.height));
101
- expect(imageStyle.width).toBe(parseFloat(specificSizedGiphyData.width));
102
- expect(imageProps.source.uri).toBe(specificSizedGiphyData.url);
103
- };
104
- checkImageProps(
105
- getByTestIdFixedHeight('giphy-attachment-image').props,
106
- attachment.giphy.fixed_height,
107
- );
108
- checkImageProps(
109
- getByTestIdOriginal('giphy-attachment-image').props,
110
- attachment.giphy.original,
111
- );
112
- });
113
- });
114
-
115
54
  it('should render UrlPreview component if attachment has title_link or og_scrape_url', async () => {
116
55
  const attachment = generateImageAttachment({
117
56
  og_scrape_url: uuidv4(),
@@ -0,0 +1,290 @@
1
+ import React from 'react';
2
+
3
+ import { fireEvent, render, waitFor } from '@testing-library/react-native';
4
+
5
+ import { MessageProvider } from '../../../contexts/messageContext/MessageContext';
6
+ import { OverlayProvider } from '../../../contexts/overlayContext/OverlayProvider';
7
+
8
+ import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
9
+ import { getOrCreateChannelApi } from '../../../mock-builders/api/getOrCreateChannel';
10
+ import { useMockedApis } from '../../../mock-builders/api/useMockedApis';
11
+ import {
12
+ generateGiphyAttachment,
13
+ generateImgurAttachment,
14
+ } from '../../../mock-builders/generator/attachment';
15
+ import { generateChannelResponse } from '../../../mock-builders/generator/channel';
16
+ import { generateMember } from '../../../mock-builders/generator/member';
17
+ import { generateMessage } from '../../../mock-builders/generator/message';
18
+ import { generateUser } from '../../../mock-builders/generator/user';
19
+ import { getTestClientWithUser } from '../../../mock-builders/mock';
20
+ import { Channel } from '../../Channel/Channel';
21
+ import { Chat } from '../../Chat/Chat';
22
+ import { MessageList } from '../../MessageList/MessageList';
23
+ import { Giphy } from '../Giphy';
24
+
25
+ describe('Giphy', () => {
26
+ const getAttachmentComponent = (props) => {
27
+ const message = generateMessage();
28
+ return (
29
+ <ThemeProvider>
30
+ <MessageProvider value={{ message }}>
31
+ <Giphy {...props} />
32
+ </MessageProvider>
33
+ </ThemeProvider>
34
+ );
35
+ };
36
+
37
+ it('should render Card component for "imgur" type attachment', async () => {
38
+ const attachment = generateImgurAttachment();
39
+ const { getByTestId } = render(getAttachmentComponent({ attachment }));
40
+
41
+ await waitFor(() => {
42
+ expect(getByTestId('giphy-attachment')).toBeTruthy();
43
+ });
44
+ });
45
+
46
+ it('should render Card component for "giphy" type attachment', async () => {
47
+ const attachment = generateGiphyAttachment();
48
+ const { getByTestId } = render(getAttachmentComponent({ attachment }));
49
+
50
+ await waitFor(() => {
51
+ expect(getByTestId('giphy-attachment')).toBeTruthy();
52
+ });
53
+ });
54
+
55
+ it('"giphy" attachment size should be customisable', async () => {
56
+ const attachment = generateGiphyAttachment();
57
+ attachment.giphy = {
58
+ fixed_height: {
59
+ height: '200',
60
+ url: 'https://media1.giphy.com/media/test/fixed_height.gif',
61
+ width: '375',
62
+ },
63
+ original: {
64
+ height: '256',
65
+ url: 'https://media1.giphy.com/media/test/original.gif',
66
+ width: '480',
67
+ },
68
+ };
69
+ const { getByTestId: getByTestIdFixedHeight } = render(
70
+ getAttachmentComponent({ attachment, giphyVersion: 'fixed_height' }),
71
+ );
72
+ const { getByTestId: getByTestIdOriginal } = render(
73
+ getAttachmentComponent({ attachment, giphyVersion: 'original' }),
74
+ );
75
+ await waitFor(() => {
76
+ const checkImageProps = (imageProps, specificSizedGiphyData) => {
77
+ let imageStyle = imageProps.style;
78
+ if (Array.isArray(imageStyle)) {
79
+ imageStyle = Object.assign({}, ...imageStyle);
80
+ }
81
+ expect(imageStyle.height).toBe(parseFloat(specificSizedGiphyData.height));
82
+ expect(imageStyle.width).toBe(parseFloat(specificSizedGiphyData.width));
83
+ expect(imageProps.source.uri).toBe(specificSizedGiphyData.url);
84
+ };
85
+ checkImageProps(
86
+ getByTestIdFixedHeight('giphy-attachment-image').props,
87
+ attachment.giphy.fixed_height,
88
+ );
89
+ checkImageProps(
90
+ getByTestIdOriginal('giphy-attachment-image').props,
91
+ attachment.giphy.original,
92
+ );
93
+ });
94
+ });
95
+
96
+ it('show render giphy action UI and all the 3 action buttons', async () => {
97
+ const attachment = generateGiphyAttachment();
98
+ attachment.actions = [
99
+ { name: 'image_action', text: 'Send', value: 'send' },
100
+ { name: 'image_action', text: 'Shuffle', value: 'shuffle' },
101
+ {
102
+ name: 'image_action',
103
+ text: 'Cancel',
104
+ value: 'cancel',
105
+ },
106
+ ];
107
+ const { getByTestId } = render(
108
+ getAttachmentComponent({ attachment, giphyVersion: 'fixed_height' }),
109
+ );
110
+
111
+ await waitFor(() => {
112
+ expect(getByTestId('giphy-action-attachment')).toBeTruthy();
113
+ expect(getByTestId('cancel-action-button')).toBeTruthy();
114
+ expect(getByTestId('shuffle-action-button')).toBeTruthy();
115
+ expect(getByTestId('send-action-button')).toBeTruthy();
116
+ });
117
+ });
118
+
119
+ it('should trigger the cancel giphy action', async () => {
120
+ const attachment = generateGiphyAttachment();
121
+ const handleAction = jest.fn();
122
+ attachment.actions = [
123
+ { name: 'image_action', text: 'Send', value: 'send' },
124
+ { name: 'image_action', text: 'Shuffle', value: 'shuffle' },
125
+ {
126
+ name: 'image_action',
127
+ text: 'Cancel',
128
+ value: 'cancel',
129
+ },
130
+ ];
131
+ const { getByTestId } = render(
132
+ getAttachmentComponent({
133
+ attachment,
134
+ giphyVersion: 'fixed_height',
135
+ handleAction,
136
+ }),
137
+ );
138
+
139
+ await waitFor(() => getByTestId(`${attachment.actions[2].value}-action-button`));
140
+
141
+ expect(getByTestId('giphy-action-attachment')).toContainElement(
142
+ getByTestId(`${attachment.actions[2].value}-action-button`),
143
+ );
144
+
145
+ fireEvent.press(getByTestId(`${attachment.actions[2].value}-action-button`));
146
+
147
+ await waitFor(() => {
148
+ expect(handleAction).toHaveBeenCalledTimes(1);
149
+ });
150
+ });
151
+
152
+ it('should trigger the shuffle giphy action', async () => {
153
+ const attachment = generateGiphyAttachment();
154
+ const handleAction = jest.fn();
155
+ attachment.actions = [
156
+ { name: 'image_action', text: 'Send', value: 'send' },
157
+ { name: 'image_action', text: 'Shuffle', value: 'shuffle' },
158
+ {
159
+ name: 'image_action',
160
+ text: 'Cancel',
161
+ value: 'cancel',
162
+ },
163
+ ];
164
+ const { getByTestId } = render(
165
+ getAttachmentComponent({
166
+ attachment,
167
+ giphyVersion: 'fixed_height',
168
+ handleAction,
169
+ }),
170
+ );
171
+
172
+ await waitFor(() => getByTestId(`${attachment.actions[1].value}-action-button`));
173
+
174
+ expect(getByTestId('giphy-action-attachment')).toContainElement(
175
+ getByTestId(`${attachment.actions[1].value}-action-button`),
176
+ );
177
+
178
+ fireEvent.press(getByTestId(`${attachment.actions[1].value}-action-button`));
179
+
180
+ await waitFor(() => {
181
+ expect(handleAction).toHaveBeenCalledTimes(1);
182
+ });
183
+ });
184
+
185
+ it('should trigger the send giphy action', async () => {
186
+ const attachment = generateGiphyAttachment();
187
+ const handleAction = jest.fn();
188
+ attachment.actions = [
189
+ { name: 'image_action', text: 'Send', value: 'send' },
190
+ { name: 'image_action', text: 'Shuffle', value: 'shuffle' },
191
+ {
192
+ name: 'image_action',
193
+ text: 'Cancel',
194
+ value: 'cancel',
195
+ },
196
+ ];
197
+ const { getByTestId } = render(
198
+ getAttachmentComponent({
199
+ attachment,
200
+ giphyVersion: 'fixed_height',
201
+ handleAction,
202
+ }),
203
+ );
204
+
205
+ await waitFor(() => getByTestId(`${attachment.actions[0].value}-action-button`));
206
+
207
+ expect(getByTestId('giphy-action-attachment')).toContainElement(
208
+ getByTestId(`${attachment.actions[0].value}-action-button`),
209
+ );
210
+
211
+ fireEvent.press(getByTestId(`${attachment.actions[0].value}-action-button`));
212
+
213
+ await waitFor(() => {
214
+ expect(handleAction).toHaveBeenCalledTimes(1);
215
+ });
216
+ });
217
+
218
+ it('giphy attachment UI should render within the message list with actions', async () => {
219
+ const user1 = generateUser();
220
+ const attachment = generateGiphyAttachment();
221
+ attachment.actions = [
222
+ { name: 'image_action', text: 'Send', value: 'send' },
223
+ { name: 'image_action', text: 'Shuffle', value: 'shuffle' },
224
+ {
225
+ name: 'image_action',
226
+ text: 'Cancel',
227
+ value: 'cancel',
228
+ },
229
+ ];
230
+ const mockedChannel = generateChannelResponse({
231
+ members: [generateMember({ user: user1 })],
232
+ messages: [
233
+ generateMessage({ user: user1 }),
234
+ generateMessage({ type: 'system', user: undefined }),
235
+ generateMessage({ attachments: [{ ...attachment }], user: user1 }),
236
+ ],
237
+ });
238
+
239
+ const chatClient = await getTestClientWithUser({ id: 'testID' });
240
+ useMockedApis(chatClient, [getOrCreateChannelApi(mockedChannel)]);
241
+ const channel = chatClient.channel('messaging', mockedChannel.id);
242
+ await channel.watch();
243
+
244
+ const { getByTestId, queryByTestId } = render(
245
+ <OverlayProvider>
246
+ <Chat client={chatClient}>
247
+ <Channel channel={channel}>
248
+ <MessageList />
249
+ </Channel>
250
+ </Chat>
251
+ </OverlayProvider>,
252
+ );
253
+
254
+ expect(queryByTestId('giphy-action-attachment')).toBeTruthy();
255
+ expect(getByTestId('cancel-action-button')).toBeTruthy();
256
+ expect(getByTestId('shuffle-action-button')).toBeTruthy();
257
+ expect(getByTestId('send-action-button')).toBeTruthy();
258
+ });
259
+
260
+ it('giphy attachment UI should render within the message list', async () => {
261
+ const user1 = generateUser();
262
+ const attachment = generateGiphyAttachment();
263
+
264
+ const mockedChannel = generateChannelResponse({
265
+ members: [generateMember({ user: user1 })],
266
+ messages: [
267
+ generateMessage({ user: user1 }),
268
+ generateMessage({ type: 'system', user: undefined }),
269
+ generateMessage({ attachments: [{ ...attachment }], user: user1 }),
270
+ ],
271
+ });
272
+
273
+ const chatClient = await getTestClientWithUser({ id: 'testID' });
274
+ useMockedApis(chatClient, [getOrCreateChannelApi(mockedChannel)]);
275
+ const channel = chatClient.channel('messaging', mockedChannel.id);
276
+ await channel.watch();
277
+
278
+ const { queryByTestId } = render(
279
+ <OverlayProvider>
280
+ <Chat client={chatClient}>
281
+ <Channel channel={channel}>
282
+ <MessageList />
283
+ </Channel>
284
+ </Chat>
285
+ </OverlayProvider>,
286
+ );
287
+
288
+ expect(queryByTestId('giphy-attachment')).toBeTruthy();
289
+ });
290
+ });