@adobe/react-native-aepmessaging 7.2.1 → 7.4.0

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 (293) hide show
  1. package/RCTAEPMessaging.podspec +1 -1
  2. package/README.md +145 -16
  3. package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingConstants.java +3 -0
  4. package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingModule.java +103 -33
  5. package/babel.config.js +3 -0
  6. package/dist/module/Messaging.js +334 -0
  7. package/dist/module/Messaging.js.map +1 -0
  8. package/dist/module/index.js +30 -0
  9. package/dist/module/index.js.map +1 -0
  10. package/dist/module/models/ContentCard.js +24 -0
  11. package/dist/module/models/ContentCard.js.map +1 -0
  12. package/dist/{models → module/models}/HTMLProposition.js +8 -9
  13. package/dist/module/models/HTMLProposition.js.map +1 -0
  14. package/dist/module/models/InAppMessage.js +4 -0
  15. package/dist/module/models/InAppMessage.js.map +1 -0
  16. package/dist/module/models/JSONProposition.js +22 -0
  17. package/dist/module/models/JSONProposition.js.map +1 -0
  18. package/dist/module/models/Message.js +182 -0
  19. package/dist/module/models/Message.js.map +1 -0
  20. package/dist/module/models/MessagingDelegate.js +4 -0
  21. package/dist/module/models/MessagingDelegate.js.map +1 -0
  22. package/dist/module/models/MessagingEdgeEventType.js +24 -0
  23. package/dist/module/models/MessagingEdgeEventType.js.map +1 -0
  24. package/dist/module/models/MessagingProposition.js +57 -0
  25. package/dist/module/models/MessagingProposition.js.map +1 -0
  26. package/dist/module/models/MessagingPropositionItem.js +4 -0
  27. package/dist/module/models/MessagingPropositionItem.js.map +1 -0
  28. package/dist/module/models/PersonalizationSchema.js +26 -0
  29. package/dist/module/models/PersonalizationSchema.js.map +1 -0
  30. package/dist/module/models/PropositionItem.js +113 -0
  31. package/dist/module/models/PropositionItem.js.map +1 -0
  32. package/dist/module/models/ScopeDetails.js +2 -0
  33. package/dist/module/models/ScopeDetails.js.map +1 -0
  34. package/dist/{models/JSONProposition.js → module/models/index.js} +14 -12
  35. package/dist/module/models/index.js.map +1 -0
  36. package/dist/module/ui/components/Button/Button.js +57 -0
  37. package/dist/module/ui/components/Button/Button.js.map +1 -0
  38. package/dist/module/ui/components/Button/Button.spec.js +476 -0
  39. package/dist/module/ui/components/Button/Button.spec.js.map +1 -0
  40. package/dist/module/ui/components/ContentCardView/ContentCardView.js +257 -0
  41. package/dist/module/ui/components/ContentCardView/ContentCardView.js.map +1 -0
  42. package/dist/module/ui/components/ContentCardView/ContentCardView.spec.js +363 -0
  43. package/dist/module/ui/components/ContentCardView/ContentCardView.spec.js.map +1 -0
  44. package/dist/module/ui/components/DismissButton/DismissButton.js +70 -0
  45. package/dist/module/ui/components/DismissButton/DismissButton.js.map +1 -0
  46. package/dist/module/ui/components/DismissButton/DismissButton.spec.js +279 -0
  47. package/dist/module/ui/components/DismissButton/DismissButton.spec.js.map +1 -0
  48. package/dist/module/ui/components/FullScreenCenterView/FullScreenCenterView.js +34 -0
  49. package/dist/module/ui/components/FullScreenCenterView/FullScreenCenterView.js.map +1 -0
  50. package/dist/module/ui/components/Inbox/EmptyState.js +64 -0
  51. package/dist/module/ui/components/Inbox/EmptyState.js.map +1 -0
  52. package/dist/module/ui/components/Inbox/Inbox.js +235 -0
  53. package/dist/module/ui/components/Inbox/Inbox.js.map +1 -0
  54. package/dist/module/ui/components/Inbox/Inbox.spec.js +847 -0
  55. package/dist/module/ui/components/Inbox/Inbox.spec.js.map +1 -0
  56. package/dist/module/ui/components/Pagination/Pagination.js +176 -0
  57. package/dist/module/ui/components/Pagination/Pagination.js.map +1 -0
  58. package/dist/module/ui/components/Pagination/Pagination.spec.js +193 -0
  59. package/dist/module/ui/components/Pagination/Pagination.spec.js.map +1 -0
  60. package/dist/module/ui/components/UnreadIcon/UnreadIcon.js +184 -0
  61. package/dist/module/ui/components/UnreadIcon/UnreadIcon.js.map +1 -0
  62. package/dist/module/ui/components/UnreadIcon/UnreadIcon.spec.js +815 -0
  63. package/dist/module/ui/components/UnreadIcon/UnreadIcon.spec.js.map +1 -0
  64. package/dist/{models/ContentCard.js → module/ui/components/index.js} +12 -12
  65. package/dist/module/ui/components/index.js.map +1 -0
  66. package/dist/module/ui/hooks/index.js +18 -0
  67. package/dist/module/ui/hooks/index.js.map +1 -0
  68. package/dist/module/ui/hooks/useAspectRatio.js +33 -0
  69. package/dist/module/ui/hooks/useAspectRatio.js.map +1 -0
  70. package/dist/module/ui/hooks/useAspectRatio.spec.js +65 -0
  71. package/dist/module/ui/hooks/useAspectRatio.spec.js.map +1 -0
  72. package/dist/module/ui/hooks/useContentCardUI.js +51 -0
  73. package/dist/module/ui/hooks/useContentCardUI.js.map +1 -0
  74. package/dist/module/ui/hooks/useContentCardUI.spec.js +85 -0
  75. package/dist/module/ui/hooks/useContentCardUI.spec.js.map +1 -0
  76. package/dist/module/ui/hooks/useInbox.js +49 -0
  77. package/dist/module/ui/hooks/useInbox.js.map +1 -0
  78. package/dist/module/ui/hooks/useInbox.spec.js +93 -0
  79. package/dist/module/ui/hooks/useInbox.spec.js.map +1 -0
  80. package/dist/module/ui/hooks/useInboxSettings.js +26 -0
  81. package/dist/module/ui/hooks/useInboxSettings.js.map +1 -0
  82. package/dist/module/ui/hooks/useInboxSettings.spec.js +50 -0
  83. package/dist/module/ui/hooks/useInboxSettings.spec.js.map +1 -0
  84. package/dist/module/ui/index.js +10 -0
  85. package/dist/module/ui/index.js.map +1 -0
  86. package/dist/module/ui/providers/InboxProvider.js +27 -0
  87. package/dist/module/ui/providers/InboxProvider.js.map +1 -0
  88. package/dist/module/ui/theme/Theme.js +2 -0
  89. package/dist/module/ui/theme/Theme.js.map +1 -0
  90. package/dist/module/ui/theme/ThemeProvider.js +112 -0
  91. package/dist/module/ui/theme/ThemeProvider.js.map +1 -0
  92. package/dist/{models/InAppMessage.js → module/ui/theme/index.js} +6 -3
  93. package/dist/module/ui/theme/index.js.map +1 -0
  94. package/dist/module/ui/types/ContentViewEvent.js +2 -0
  95. package/dist/module/ui/types/ContentViewEvent.js.map +1 -0
  96. package/dist/module/ui/types/Templates.js +26 -0
  97. package/dist/module/ui/types/Templates.js.map +1 -0
  98. package/dist/{models/ScopeDetails.js → module/ui/types/index.js} +6 -3
  99. package/dist/module/ui/types/index.js.map +1 -0
  100. package/dist/module/ui/utils/generateCardHash.js +50 -0
  101. package/dist/module/ui/utils/generateCardHash.js.map +1 -0
  102. package/dist/module/ui/utils/generateCardHash.spec.js +103 -0
  103. package/dist/module/ui/utils/generateCardHash.spec.js.map +1 -0
  104. package/dist/module/ui/utils/inboxStorage.js +65 -0
  105. package/dist/module/ui/utils/inboxStorage.js.map +1 -0
  106. package/dist/module/ui/utils/inboxStorage.spec.js +123 -0
  107. package/dist/module/ui/utils/inboxStorage.spec.js.map +1 -0
  108. package/dist/module/ui/utils/index.js +5 -0
  109. package/dist/module/ui/utils/index.js.map +1 -0
  110. package/dist/{Messaging.d.ts → typescript/Messaging.d.ts} +23 -7
  111. package/dist/typescript/Messaging.d.ts.map +1 -0
  112. package/dist/{index.d.ts → typescript/index.d.ts} +4 -2
  113. package/dist/typescript/index.d.ts.map +1 -0
  114. package/dist/typescript/models/ContentCard.d.ts +57 -0
  115. package/dist/typescript/models/ContentCard.d.ts.map +1 -0
  116. package/dist/{models → typescript/models}/HTMLProposition.d.ts +1 -0
  117. package/dist/typescript/models/HTMLProposition.d.ts.map +1 -0
  118. package/dist/{models → typescript/models}/InAppMessage.d.ts +1 -0
  119. package/dist/typescript/models/InAppMessage.d.ts.map +1 -0
  120. package/dist/{models → typescript/models}/JSONProposition.d.ts +1 -0
  121. package/dist/typescript/models/JSONProposition.d.ts.map +1 -0
  122. package/dist/{models → typescript/models}/Message.d.ts +14 -0
  123. package/dist/typescript/models/Message.d.ts.map +1 -0
  124. package/dist/{models → typescript/models}/MessagingDelegate.d.ts +1 -0
  125. package/dist/typescript/models/MessagingDelegate.d.ts.map +1 -0
  126. package/dist/{models → typescript/models}/MessagingEdgeEventType.d.ts +1 -0
  127. package/dist/typescript/models/MessagingEdgeEventType.d.ts.map +1 -0
  128. package/dist/{models → typescript/models}/MessagingProposition.d.ts +1 -0
  129. package/dist/typescript/models/MessagingProposition.d.ts.map +1 -0
  130. package/dist/{models → typescript/models}/MessagingPropositionItem.d.ts +1 -0
  131. package/dist/typescript/models/MessagingPropositionItem.d.ts.map +1 -0
  132. package/dist/{models → typescript/models}/PersonalizationSchema.d.ts +2 -0
  133. package/dist/typescript/models/PersonalizationSchema.d.ts.map +1 -0
  134. package/dist/{models → typescript/models}/PropositionItem.d.ts +1 -0
  135. package/dist/typescript/models/PropositionItem.d.ts.map +1 -0
  136. package/dist/{models → typescript/models}/ScopeDetails.d.ts +1 -0
  137. package/dist/typescript/models/ScopeDetails.d.ts.map +1 -0
  138. package/dist/typescript/models/index.d.ts +11 -0
  139. package/dist/typescript/models/index.d.ts.map +1 -0
  140. package/dist/typescript/ui/components/Button/Button.d.ts +14 -0
  141. package/dist/typescript/ui/components/Button/Button.d.ts.map +1 -0
  142. package/dist/typescript/ui/components/Button/Button.spec.d.ts +2 -0
  143. package/dist/typescript/ui/components/Button/Button.spec.d.ts.map +1 -0
  144. package/dist/typescript/ui/components/ContentCardView/ContentCardView.d.ts +39 -0
  145. package/dist/typescript/ui/components/ContentCardView/ContentCardView.d.ts.map +1 -0
  146. package/dist/typescript/ui/components/ContentCardView/ContentCardView.spec.d.ts +2 -0
  147. package/dist/typescript/ui/components/ContentCardView/ContentCardView.spec.d.ts.map +1 -0
  148. package/dist/typescript/ui/components/DismissButton/DismissButton.d.ts +13 -0
  149. package/dist/typescript/ui/components/DismissButton/DismissButton.d.ts.map +1 -0
  150. package/dist/typescript/ui/components/DismissButton/DismissButton.spec.d.ts +2 -0
  151. package/dist/typescript/ui/components/DismissButton/DismissButton.spec.d.ts.map +1 -0
  152. package/dist/typescript/ui/components/FullScreenCenterView/FullScreenCenterView.d.ts +5 -0
  153. package/dist/typescript/ui/components/FullScreenCenterView/FullScreenCenterView.d.ts.map +1 -0
  154. package/dist/typescript/ui/components/Inbox/EmptyState.d.ts +19 -0
  155. package/dist/typescript/ui/components/Inbox/EmptyState.d.ts.map +1 -0
  156. package/dist/typescript/ui/components/Inbox/Inbox.d.ts +21 -0
  157. package/dist/typescript/ui/components/Inbox/Inbox.d.ts.map +1 -0
  158. package/dist/typescript/ui/components/Inbox/Inbox.spec.d.ts +2 -0
  159. package/dist/typescript/ui/components/Inbox/Inbox.spec.d.ts.map +1 -0
  160. package/dist/typescript/ui/components/Pagination/Pagination.d.ts +14 -0
  161. package/dist/typescript/ui/components/Pagination/Pagination.d.ts.map +1 -0
  162. package/dist/typescript/ui/components/Pagination/Pagination.spec.d.ts +2 -0
  163. package/dist/typescript/ui/components/Pagination/Pagination.spec.d.ts.map +1 -0
  164. package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.d.ts +14 -0
  165. package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.d.ts.map +1 -0
  166. package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.spec.d.ts +2 -0
  167. package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.spec.d.ts.map +1 -0
  168. package/dist/typescript/ui/components/index.d.ts +10 -0
  169. package/dist/typescript/ui/components/index.d.ts.map +1 -0
  170. package/dist/typescript/ui/hooks/index.d.ts +4 -0
  171. package/dist/typescript/ui/hooks/index.d.ts.map +1 -0
  172. package/dist/typescript/ui/hooks/useAspectRatio.d.ts +3 -0
  173. package/dist/typescript/ui/hooks/useAspectRatio.d.ts.map +1 -0
  174. package/dist/typescript/ui/hooks/useAspectRatio.spec.d.ts +2 -0
  175. package/dist/typescript/ui/hooks/useAspectRatio.spec.d.ts.map +1 -0
  176. package/dist/typescript/ui/hooks/useContentCardUI.d.ts +14 -0
  177. package/dist/typescript/ui/hooks/useContentCardUI.d.ts.map +1 -0
  178. package/dist/typescript/ui/hooks/useContentCardUI.spec.d.ts +2 -0
  179. package/dist/typescript/ui/hooks/useContentCardUI.spec.d.ts.map +1 -0
  180. package/dist/typescript/ui/hooks/useInbox.d.ts +12 -0
  181. package/dist/typescript/ui/hooks/useInbox.d.ts.map +1 -0
  182. package/dist/typescript/ui/hooks/useInbox.spec.d.ts +2 -0
  183. package/dist/typescript/ui/hooks/useInbox.spec.d.ts.map +1 -0
  184. package/dist/typescript/ui/hooks/useInboxSettings.d.ts +7 -0
  185. package/dist/typescript/ui/hooks/useInboxSettings.d.ts.map +1 -0
  186. package/dist/typescript/ui/hooks/useInboxSettings.spec.d.ts +2 -0
  187. package/dist/typescript/ui/hooks/useInboxSettings.spec.d.ts.map +1 -0
  188. package/dist/typescript/ui/index.d.ts +8 -0
  189. package/dist/typescript/ui/index.d.ts.map +1 -0
  190. package/dist/typescript/ui/providers/InboxProvider.d.ts +56 -0
  191. package/dist/typescript/ui/providers/InboxProvider.d.ts.map +1 -0
  192. package/dist/typescript/ui/theme/Theme.d.ts +44 -0
  193. package/dist/typescript/ui/theme/Theme.d.ts.map +1 -0
  194. package/dist/typescript/ui/theme/ThemeProvider.d.ts +21 -0
  195. package/dist/typescript/ui/theme/ThemeProvider.d.ts.map +1 -0
  196. package/dist/typescript/ui/theme/index.d.ts +3 -0
  197. package/dist/typescript/ui/theme/index.d.ts.map +1 -0
  198. package/dist/typescript/ui/types/ContentViewEvent.d.ts +9 -0
  199. package/dist/typescript/ui/types/ContentViewEvent.d.ts.map +1 -0
  200. package/dist/typescript/ui/types/Templates.d.ts +43 -0
  201. package/dist/typescript/ui/types/Templates.d.ts.map +1 -0
  202. package/dist/typescript/ui/types/index.d.ts +3 -0
  203. package/dist/typescript/ui/types/index.d.ts.map +1 -0
  204. package/dist/typescript/ui/utils/generateCardHash.d.ts +21 -0
  205. package/dist/typescript/ui/utils/generateCardHash.d.ts.map +1 -0
  206. package/dist/typescript/ui/utils/generateCardHash.spec.d.ts +2 -0
  207. package/dist/typescript/ui/utils/generateCardHash.spec.d.ts.map +1 -0
  208. package/dist/typescript/ui/utils/inboxStorage.d.ts +20 -0
  209. package/dist/typescript/ui/utils/inboxStorage.d.ts.map +1 -0
  210. package/dist/typescript/ui/utils/inboxStorage.spec.d.ts +2 -0
  211. package/dist/typescript/ui/utils/inboxStorage.spec.d.ts.map +1 -0
  212. package/dist/typescript/ui/utils/index.d.ts +3 -0
  213. package/dist/typescript/ui/utils/index.d.ts.map +1 -0
  214. package/ios/src/RCTAEPMessaging.mm +15 -0
  215. package/ios/src/RCTAEPMessaging.swift +61 -3
  216. package/ios/src/RCTAEPMessagingConstants.swift +4 -1
  217. package/jest.config.js +15 -0
  218. package/package.json +33 -5
  219. package/src/Messaging.ts +288 -32
  220. package/src/index.ts +3 -3
  221. package/src/models/ContentCard.ts +52 -27
  222. package/src/models/HTMLProposition.ts +1 -1
  223. package/src/models/JSONProposition.ts +1 -1
  224. package/src/models/Message.ts +50 -0
  225. package/src/models/PersonalizationSchema.ts +1 -0
  226. package/src/models/index.ts +22 -0
  227. package/src/ui/components/Button/Button.spec.tsx +496 -0
  228. package/src/ui/components/Button/Button.tsx +76 -0
  229. package/src/ui/components/ContentCardView/ContentCardView.spec.tsx +278 -0
  230. package/src/ui/components/ContentCardView/ContentCardView.tsx +400 -0
  231. package/src/ui/components/DismissButton/DismissButton.spec.tsx +314 -0
  232. package/src/ui/components/DismissButton/DismissButton.tsx +100 -0
  233. package/src/ui/components/FullScreenCenterView/FullScreenCenterView.tsx +32 -0
  234. package/src/ui/components/Inbox/EmptyState.tsx +89 -0
  235. package/src/ui/components/Inbox/Inbox.spec.tsx +478 -0
  236. package/src/ui/components/Inbox/Inbox.tsx +275 -0
  237. package/src/ui/components/Pagination/Pagination.spec.tsx +159 -0
  238. package/src/ui/components/Pagination/Pagination.tsx +222 -0
  239. package/src/ui/components/UnreadIcon/UnreadIcon.spec.tsx +878 -0
  240. package/src/ui/components/UnreadIcon/UnreadIcon.tsx +234 -0
  241. package/src/ui/components/index.ts +22 -0
  242. package/{dist/models/MessagingPropositionItem.js → src/ui/hooks/index.ts} +5 -4
  243. package/src/ui/hooks/useAspectRatio.spec.tsx +66 -0
  244. package/src/ui/hooks/useAspectRatio.tsx +39 -0
  245. package/src/ui/hooks/useContentCardUI.spec.tsx +82 -0
  246. package/src/ui/hooks/useContentCardUI.ts +48 -0
  247. package/src/ui/hooks/useInbox.spec.tsx +87 -0
  248. package/src/ui/hooks/useInbox.ts +46 -0
  249. package/src/ui/hooks/useInboxSettings.spec.tsx +41 -0
  250. package/src/ui/hooks/useInboxSettings.ts +24 -0
  251. package/src/ui/index.ts +7 -0
  252. package/src/ui/providers/InboxProvider.tsx +79 -0
  253. package/src/ui/theme/Theme.ts +57 -0
  254. package/src/ui/theme/ThemeProvider.tsx +120 -0
  255. package/src/ui/theme/index.ts +14 -0
  256. package/src/ui/types/ContentViewEvent.ts +20 -0
  257. package/src/ui/types/Templates.ts +77 -0
  258. package/src/ui/types/index.ts +14 -0
  259. package/src/ui/utils/generateCardHash.spec.tsx +86 -0
  260. package/src/ui/utils/generateCardHash.ts +59 -0
  261. package/src/ui/utils/inboxStorage.spec.tsx +136 -0
  262. package/src/ui/utils/inboxStorage.ts +64 -0
  263. package/src/ui/utils/index.ts +3 -0
  264. package/tutorials/ContentCardCustomizationGuide.md +661 -0
  265. package/tutorials/ContentCards.md +419 -0
  266. package/tutorials/In-App Messaging.md +31 -0
  267. package/tutorials/Inbox.md +515 -0
  268. package/tutorials/resources/image-only-template.png +0 -0
  269. package/tutorials/resources/large-image-template.png +0 -0
  270. package/tutorials/resources/small-image-template.png +0 -0
  271. package/dist/Messaging.js +0 -151
  272. package/dist/Messaging.js.map +0 -1
  273. package/dist/index.js +0 -34
  274. package/dist/index.js.map +0 -1
  275. package/dist/models/ContentCard.d.ts +0 -51
  276. package/dist/models/ContentCard.js.map +0 -1
  277. package/dist/models/HTMLProposition.js.map +0 -1
  278. package/dist/models/InAppMessage.js.map +0 -1
  279. package/dist/models/JSONProposition.js.map +0 -1
  280. package/dist/models/Message.js +0 -114
  281. package/dist/models/Message.js.map +0 -1
  282. package/dist/models/MessagingDelegate.js +0 -14
  283. package/dist/models/MessagingDelegate.js.map +0 -1
  284. package/dist/models/MessagingEdgeEventType.js +0 -24
  285. package/dist/models/MessagingEdgeEventType.js.map +0 -1
  286. package/dist/models/MessagingProposition.js +0 -59
  287. package/dist/models/MessagingProposition.js.map +0 -1
  288. package/dist/models/MessagingPropositionItem.js.map +0 -1
  289. package/dist/models/PersonalizationSchema.js +0 -25
  290. package/dist/models/PersonalizationSchema.js.map +0 -1
  291. package/dist/models/PropositionItem.js +0 -78
  292. package/dist/models/PropositionItem.js.map +0 -1
  293. package/dist/models/ScopeDetails.js.map +0 -1
@@ -0,0 +1,478 @@
1
+ /*
2
+ Copyright 2026 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the
4
+ "License"); you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
7
+ or agreed to in writing, software distributed under the License is
8
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
9
+ ANY KIND, either express or implied. See the License for the specific
10
+ language governing permissions and limitations under the License.
11
+ */
12
+
13
+ import { render, screen, act, waitFor } from '@testing-library/react-native';
14
+ import React from 'react';
15
+ import { Dimensions, Text } from 'react-native';
16
+ import { generateCardHash } from '../../utils/generateCardHash';
17
+ import EmptyState from './EmptyState';
18
+ import { Inbox } from './Inbox';
19
+
20
+ jest.mock('../../hooks', () => ({
21
+ useContentCardUI: jest.fn(),
22
+ useInbox: jest.fn(),
23
+ }));
24
+
25
+ jest.mock('../../utils/inboxStorage', () => ({
26
+ loadInboxState: jest.fn().mockResolvedValue({ dismissed: [], interacted: [] }),
27
+ saveInboxState: jest.fn().mockResolvedValue(undefined),
28
+ }));
29
+
30
+ const mockContentCardView: jest.Mock = jest.fn((..._args: any[]) => null);
31
+ jest.mock('../ContentCardView/ContentCardView', () => {
32
+ return {
33
+ ContentCardView: (props: any) => {
34
+ mockContentCardView(props);
35
+ return null;
36
+ },
37
+ };
38
+ });
39
+
40
+ jest.mock('../../providers/InboxProvider', () => ({
41
+ __esModule: true,
42
+ default: ({ children }: any) => children,
43
+ }));
44
+
45
+ // jest.mock('../../hooks/useAspectRatio', () => ({
46
+ // __esModule: true,
47
+ // default: () => 1.5,
48
+ // }));
49
+
50
+ const { useContentCardUI, useInbox } = jest.requireMock('../../hooks');
51
+ const { loadInboxState, saveInboxState } = jest.requireMock('../../utils/inboxStorage');
52
+
53
+ describe('Inbox', () => {
54
+ const surface = 'test-surface';
55
+
56
+ const baseSettings = {
57
+ content: {
58
+ heading: { content: 'Heading' },
59
+ layout: { orientation: 'horizontal' as const },
60
+ capacity: 10,
61
+ emptyStateSettings: {
62
+ message: { content: 'No Content Available' },
63
+ image: { light: { url: 'https://example.com/image.png' } },
64
+ },
65
+ unread_indicator: {
66
+ unread_bg: { clr: { light: '#EEE', dark: '#111' } },
67
+ unread_icon: { placement: 'topright', image: { url: 'https://example.com/icon.png' } },
68
+ },
69
+ isUnreadEnabled: true,
70
+ },
71
+ showPagination: false,
72
+ };
73
+
74
+ beforeEach(() => {
75
+ jest.clearAllMocks();
76
+ jest.spyOn(Dimensions, 'get').mockReturnValue({ width: 400, height: 800, scale: 2, fontScale: 2 } as any);
77
+ });
78
+
79
+
80
+ describe('outer inbox states', () => {
81
+ it('renders loading state', () => {
82
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: undefined, isLoading: true, error: null });
83
+
84
+ const Loading = <Text>Loading...</Text> as any;
85
+ const CC: any = Inbox;
86
+ render(<CC surface={surface} settings={baseSettings} isLoading LoadingComponent={Loading} />);
87
+ expect(screen.getByText('Loading...')).toBeTruthy();
88
+ });
89
+
90
+ it('renders error state', () => {
91
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: undefined, isLoading: false, error: null });
92
+
93
+ const ErrorComp = <Text>Error!</Text> as any;
94
+ const CC: any = Inbox;
95
+ render(<CC surface={surface} settings={baseSettings} error={new Error('x')} ErrorComponent={ErrorComp} />);
96
+ expect(screen.getByText('Error!')).toBeTruthy();
97
+ });
98
+
99
+ it('renders fallback when no settings provided', () => {
100
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: undefined, isLoading: false, error: null });
101
+
102
+ const Fallback = <Text>Fallback</Text> as any;
103
+ const CC: any = Inbox;
104
+ render(<CC surface={surface} settings={null} FallbackComponent={Fallback} />);
105
+ expect(screen.getByText('Fallback')).toBeTruthy();
106
+ });
107
+
108
+ it('renders outer LoadingComponent when inbox is loading', () => {
109
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: undefined, isLoading: false, error: null });
110
+
111
+ const Loading = <Text testID="outer-loading">Loading outer...</Text> as any;
112
+ const CC: any = Inbox;
113
+ render(<CC surface={surface} settings={baseSettings} isLoading LoadingComponent={Loading} />);
114
+ expect(screen.getByTestId('outer-loading')).toBeTruthy();
115
+ });
116
+ });
117
+
118
+ describe('empty content rendering', () => {
119
+ it('renders empty state when content is empty', () => {
120
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [], isLoading: false, error: null });
121
+
122
+ const CC: any = Inbox;
123
+ render(<CC surface={surface} settings={baseSettings} />);
124
+ expect(screen.getByText('No Content Available')).toBeTruthy();
125
+ });
126
+
127
+ it('handles empty content array', () => {
128
+ (useInbox as jest.Mock).mockReturnValue({ settings: baseSettings, isLoading: false, error: null });
129
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [], isLoading: false, error: null });
130
+
131
+ const CC: any = Inbox;
132
+ render(<CC surface={surface} settings={baseSettings} />);
133
+
134
+ expect(mockContentCardView.mock.calls.length).toBe(0);
135
+ expect(screen.getByText('No Content Available')).toBeTruthy();
136
+ });
137
+
138
+ it('uses light image when colorScheme is null and falls back to default message', () => {
139
+ jest.spyOn(require('react-native'), 'useColorScheme').mockReturnValue(null);
140
+ const settings = {
141
+ ...baseSettings,
142
+ content: {
143
+ ...baseSettings.content,
144
+ emptyStateSettings: {
145
+ image: { url: 'https://example.com/light-only.png' }
146
+ } as any
147
+ }
148
+ };
149
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [], isLoading: false, error: null });
150
+
151
+ const CC: any = Inbox;
152
+ const { UNSAFE_getByType } = render(<CC surface={surface} settings={settings} />);
153
+ const empty = UNSAFE_getByType(EmptyState);
154
+ expect(empty.props.image).toBe('https://example.com/light-only.png');
155
+ expect(empty.props.text).toBe('No Content Available');
156
+ });
157
+ });
158
+
159
+ describe('heading and layout', () => {
160
+ it('sets heading color based on color scheme: dark -> #FFFFFF', () => {
161
+ jest.spyOn(require('react-native'), 'useColorScheme').mockReturnValue('dark');
162
+ (useInbox as jest.Mock).mockReturnValue({ settings: baseSettings, isLoading: false, error: null });
163
+ const template = { id: '1', type: 'SmallImage', data: { content: { title: { content: 'T' }, body: { content: 'B' }, image: { url: 'u' } } } };
164
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [template], isLoading: false, error: null });
165
+ const CC: any = Inbox;
166
+ const { getByText } = render(<CC surface={surface} settings={baseSettings} />);
167
+ const heading = getByText('Heading');
168
+ const styles = Array.isArray(heading.props.style) ? heading.props.style : [heading.props.style];
169
+ expect(styles.some((s: any) => s && s.color === '#FFFFFF')).toBe(true);
170
+ });
171
+ });
172
+
173
+ describe('inner inbox states', () => {
174
+ it('renders inner ErrorComponent when data hook errors', () => {
175
+ (useInbox as jest.Mock).mockReturnValue({ settings: baseSettings, isLoading: false, error: null });
176
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: undefined, isLoading: false, error: new Error('inner') });
177
+
178
+ const ErrorComp = <Text testID="inner-error">Inner Error!</Text> as any;
179
+ const CC: any = Inbox;
180
+ render(<CC surface={surface} settings={baseSettings} ErrorComponent={ErrorComp} />);
181
+ expect(screen.getByTestId('inner-error')).toBeTruthy();
182
+ });
183
+
184
+ it('uses provided EmptyComponent and passes empty state settings (inner)', () => {
185
+ (useInbox as jest.Mock).mockReturnValue({ settings: baseSettings, isLoading: false, error: null });
186
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [], isLoading: false, error: null });
187
+
188
+ const EmptyStub = ({ message }: any) => (
189
+ <Text testID="inner-empty">{message?.content}</Text>
190
+ );
191
+ const CC: any = Inbox;
192
+ render(<CC surface={surface} settings={baseSettings} EmptyComponent={<EmptyStub />} />);
193
+ expect(screen.getByTestId('inner-empty')).toBeTruthy();
194
+ expect(screen.getByText('No Content Available')).toBeTruthy();
195
+ });
196
+
197
+ it('renders inner FallbackComponent when content is undefined and settings exist', () => {
198
+ (useInbox as jest.Mock).mockReturnValue({ settings: baseSettings, isLoading: false, error: null });
199
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: undefined, isLoading: false, error: null });
200
+
201
+ const Fallback = <Text testID="inner-fallback">Inner Fallback</Text> as any;
202
+ const CC: any = Inbox;
203
+ render(<CC surface={surface} FallbackComponent={Fallback} />);
204
+ expect(screen.getByTestId('inner-fallback')).toBeTruthy();
205
+ });
206
+ });
207
+
208
+ describe('renderItem passthrough', () => {
209
+ it('passes expected props to ContentCardView via renderItem (horizontal)', () => {
210
+ (useInbox as jest.Mock).mockReturnValue({ settings: baseSettings, isLoading: false, error: null });
211
+ const template = { id: '1', type: 'SmallImage', data: { content: { title: { content: 'T' }, body: { content: 'B' }, image: { url: 'u' } } } };
212
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [template], isLoading: false, error: null });
213
+
214
+ const CC: any = Inbox;
215
+ render(<CC surface={surface} settings={baseSettings} />);
216
+
217
+ expect(mockContentCardView).toHaveBeenCalled();
218
+ const args = mockContentCardView.mock.calls[0][0];
219
+ expect(args.template).toEqual(template);
220
+ expect(args.style).toEqual(expect.arrayContaining([expect.anything()]));
221
+ });
222
+ });
223
+
224
+ describe('capacity and dismissal', () => {
225
+ it('renders up to capacity and backfills after dismiss', async () => {
226
+ const capSettings = {
227
+ ...baseSettings,
228
+ content: { ...baseSettings.content, capacity: 2 },
229
+ };
230
+ (useInbox as jest.Mock).mockReturnValue({ settings: capSettings, isLoading: false, error: null });
231
+ const t1 = { id: '1', type: 'SmallImage', data: { content: { title: { content: 'T1' }, body: { content: 'B1' }, image: { url: 'u1' } } } };
232
+ const t2 = { id: '2', type: 'SmallImage', data: { content: { title: { content: 'T2' }, body: { content: 'B2' }, image: { url: 'u2' } } } };
233
+ const t3 = { id: '3', type: 'SmallImage', data: { content: { title: { content: 'T3' }, body: { content: 'B3' }, image: { url: 'u3' } } } };
234
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [t1, t2, t3], isLoading: false, error: null });
235
+
236
+ const CC: any = Inbox;
237
+ const utils = render(<CC surface={surface} settings={capSettings} />);
238
+
239
+ await waitFor(() => {
240
+ expect(mockContentCardView.mock.calls.length).toBeGreaterThanOrEqual(2);
241
+ });
242
+ // Get the last render's calls (component may render multiple times)
243
+ const lastTwoCalls = mockContentCardView.mock.calls.slice(-2);
244
+ expect(lastTwoCalls.length).toBe(2);
245
+ const firstProps = lastTwoCalls[0][0];
246
+
247
+ await act(async () => {
248
+ firstProps.listener?.('onDismiss', firstProps.template);
249
+ });
250
+ mockContentCardView.mockClear();
251
+ utils.rerender(<CC surface={surface} settings={capSettings} extraData={() => {}} />);
252
+
253
+ await waitFor(() => {
254
+ expect(mockContentCardView.mock.calls.length).toBeGreaterThanOrEqual(1);
255
+ });
256
+ const renderedIds = mockContentCardView.mock.calls.map(c => c[0].template.id);
257
+ expect(renderedIds).toEqual(expect.arrayContaining(['3']));
258
+ expect(renderedIds).not.toContain('1');
259
+ });
260
+ });
261
+
262
+ describe('layout and styling', () => {
263
+ it('renders cards vertically when layout orientation is vertical', () => {
264
+ const verticalSettings = {
265
+ ...baseSettings,
266
+ content: { ...baseSettings.content, layout: { orientation: 'vertical' as const } },
267
+ };
268
+ (useInbox as jest.Mock).mockReturnValue({ settings: verticalSettings, isLoading: false, error: null });
269
+ const template = { id: '1', type: 'SmallImage', data: { content: { title: { content: 'T' }, body: { content: 'B' }, image: { url: 'u' } } } };
270
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [template], isLoading: false, error: null });
271
+
272
+ const CC: any = Inbox;
273
+ render(<CC surface={surface} settings={verticalSettings} />);
274
+
275
+ expect(mockContentCardView).toHaveBeenCalled();
276
+ const args = mockContentCardView.mock.calls[0][0];
277
+ expect(args.style).toBeUndefined();
278
+ });
279
+
280
+ it('does not render heading when heading content is not provided', () => {
281
+ const settingsWithoutHeading = {
282
+ ...baseSettings,
283
+ content: { ...baseSettings.content, heading: undefined },
284
+ };
285
+ (useInbox as jest.Mock).mockReturnValue({ settings: settingsWithoutHeading, isLoading: false, error: null });
286
+ const template = { id: '1', type: 'SmallImage', data: { content: { title: { content: 'T' }, body: { content: 'B' }, image: { url: 'u' } } } };
287
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [template], isLoading: false, error: null });
288
+
289
+ const CC: any = Inbox;
290
+ const { queryByText } = render(<CC surface={surface} settings={settingsWithoutHeading} />);
291
+
292
+ expect(queryByText('Heading')).toBeNull();
293
+ });
294
+ });
295
+
296
+ describe('interaction tracking', () => {
297
+ it('does not add duplicate entries to store on multiple interactions', async () => {
298
+ const testSurface = 'test-surface-duplicate-interact';
299
+ (useInbox as jest.Mock).mockReturnValue({ settings: baseSettings, isLoading: false, error: null });
300
+ const template = { id: '1', type: 'SmallImage', data: { content: { title: { content: 'T' }, body: { content: 'B' }, image: { url: 'u' } } } };
301
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [template], isLoading: false, error: null });
302
+
303
+ const CC: any = Inbox;
304
+ render(<CC surface={testSurface} settings={baseSettings} />);
305
+
306
+ await waitFor(() => {
307
+ expect(mockContentCardView.mock.calls.length).toBeGreaterThan(0);
308
+ });
309
+
310
+ const args = mockContentCardView.mock.calls[0][0];
311
+
312
+ await act(async () => {
313
+ args.listener?.('onInteract', args.template);
314
+ args.listener?.('onInteract', args.template);
315
+ args.listener?.('onInteract', args.template);
316
+ });
317
+
318
+ const newContent = [{ ...template }];
319
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: newContent, isLoading: false, error: null });
320
+ mockContentCardView.mockClear();
321
+
322
+ render(<CC surface={testSurface} settings={baseSettings} />);
323
+ await waitFor(() => {
324
+ expect(mockContentCardView.mock.calls.length).toBeGreaterThan(0);
325
+ });
326
+
327
+ const updatedArgs = mockContentCardView.mock.calls[0][0];
328
+ expect(updatedArgs.template.isRead).toBe(true);
329
+ });
330
+ });
331
+
332
+ describe('loadInboxState effect (persisted state merge)', () => {
333
+ const template = {
334
+ id: '1',
335
+ type: 'SmallImage',
336
+ data: { content: { title: { content: 'T' }, body: { content: 'B' }, image: { url: 'u' } } },
337
+ };
338
+
339
+ it('merges persisted dismissed ids from loadInboxState into the store so those cards are not shown', async () => {
340
+ const hash = generateCardHash(template as any);
341
+ (loadInboxState as jest.Mock).mockResolvedValueOnce({ dismissed: [hash], interacted: [] });
342
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [template], isLoading: false, error: null });
343
+
344
+ const settingsWithActivity = {
345
+ ...baseSettings,
346
+ activityId: 'activity-load-merge',
347
+ };
348
+ const CC: any = Inbox;
349
+ render(<CC surface="surface-load-merge" settings={settingsWithActivity} />);
350
+
351
+ await waitFor(() => {
352
+ expect(loadInboxState).toHaveBeenCalledWith('activity-load-merge');
353
+ });
354
+ await waitFor(() => {
355
+ expect(screen.getByText('No Content Available')).toBeTruthy();
356
+ });
357
+ });
358
+
359
+ it('merges persisted interacted ids when isUnreadEnabled and marks matching cards as read', async () => {
360
+ const hash = generateCardHash(template as any);
361
+ (loadInboxState as jest.Mock).mockResolvedValueOnce({ dismissed: [], interacted: [hash] });
362
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [template], isLoading: false, error: null });
363
+
364
+ const settingsWithActivity = {
365
+ ...baseSettings,
366
+ activityId: 'activity-load-interacted',
367
+ content: { ...baseSettings.content, isUnreadEnabled: true },
368
+ };
369
+ const CC: any = Inbox;
370
+ render(<CC surface="surface-load-interacted" settings={settingsWithActivity} />);
371
+
372
+ await waitFor(() => expect(loadInboxState).toHaveBeenCalledWith('activity-load-interacted'));
373
+ await waitFor(() => expect(mockContentCardView.mock.calls.length).toBeGreaterThan(0));
374
+ const props = mockContentCardView.mock.calls[mockContentCardView.mock.calls.length - 1][0];
375
+ expect(props.template.isRead).toBe(true);
376
+ });
377
+
378
+ it('applies cleanup so resolving loadInboxState after unmount does not throw', async () => {
379
+ let resolveLoad: (v: { dismissed: string[]; interacted: string[] }) => void;
380
+ const loadPromise = new Promise<{ dismissed: string[]; interacted: string[] }>((resolve) => {
381
+ resolveLoad = resolve;
382
+ });
383
+ (loadInboxState as jest.Mock).mockImplementationOnce(() => loadPromise);
384
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [template], isLoading: false, error: null });
385
+
386
+ const settingsWithActivity = {
387
+ ...baseSettings,
388
+ activityId: 'activity-load-cancel',
389
+ };
390
+ const CC: any = Inbox;
391
+ const { unmount } = render(<CC surface="surface-load-cancel" settings={settingsWithActivity} />);
392
+
393
+ unmount();
394
+ await act(async () => {
395
+ resolveLoad!({ dismissed: [], interacted: [] });
396
+ await loadPromise;
397
+ });
398
+ });
399
+ });
400
+
401
+ describe('saveInboxState on card events', () => {
402
+ const template = {
403
+ id: '1',
404
+ type: 'SmallImage',
405
+ data: { content: { title: { content: 'T' }, body: { content: 'B' }, image: { url: 'u' } } },
406
+ };
407
+
408
+ it('calls saveInboxState on onDismiss when activityId is set', async () => {
409
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [template], isLoading: false, error: null });
410
+ const settingsWithActivity = {
411
+ ...baseSettings,
412
+ activityId: 'activity-save-dismiss',
413
+ };
414
+ const CC: any = Inbox;
415
+ render(<CC surface="surface-save-dismiss" settings={settingsWithActivity} />);
416
+
417
+ await waitFor(() => expect(mockContentCardView.mock.calls.length).toBeGreaterThan(0));
418
+ const props = mockContentCardView.mock.calls[0][0];
419
+ const expectedHash = generateCardHash(template as any);
420
+
421
+ await act(async () => {
422
+ props.listener?.('onDismiss', props.template);
423
+ });
424
+
425
+ expect(saveInboxState).toHaveBeenCalledWith(
426
+ 'activity-save-dismiss',
427
+ expect.objectContaining({
428
+ dismissed: expect.arrayContaining([expectedHash]),
429
+ interacted: [],
430
+ })
431
+ );
432
+ });
433
+
434
+ it('calls saveInboxState on onInteract when activityId is set and unread is enabled', async () => {
435
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [template], isLoading: false, error: null });
436
+ const settingsWithActivity = {
437
+ ...baseSettings,
438
+ activityId: 'activity-save-interact',
439
+ content: { ...baseSettings.content, isUnreadEnabled: true },
440
+ };
441
+ const CC: any = Inbox;
442
+ render(<CC surface="surface-save-interact" settings={settingsWithActivity} />);
443
+
444
+ await waitFor(() => expect(mockContentCardView.mock.calls.length).toBeGreaterThan(0));
445
+ const props = mockContentCardView.mock.calls[0][0];
446
+ const expectedHash = generateCardHash(template as any);
447
+
448
+ await act(async () => {
449
+ props.listener?.('onInteract', props.template);
450
+ });
451
+
452
+ expect(saveInboxState).toHaveBeenCalledWith(
453
+ 'activity-save-interact',
454
+ expect.objectContaining({
455
+ dismissed: [],
456
+ interacted: expect.arrayContaining([expectedHash]),
457
+ })
458
+ );
459
+ });
460
+
461
+ it('does not call saveInboxState on dismiss when activityId is missing', async () => {
462
+ (useContentCardUI as jest.Mock).mockReturnValue({ content: [template], isLoading: false, error: null });
463
+ (saveInboxState as jest.Mock).mockClear();
464
+
465
+ const CC: any = Inbox;
466
+ render(<CC surface="surface-no-activity" settings={baseSettings} />);
467
+
468
+ await waitFor(() => expect(mockContentCardView.mock.calls.length).toBeGreaterThan(0));
469
+ const props = mockContentCardView.mock.calls[0][0];
470
+
471
+ await act(async () => {
472
+ props.listener?.('onDismiss', props.template);
473
+ });
474
+
475
+ expect(saveInboxState).not.toHaveBeenCalled();
476
+ });
477
+ });
478
+ });