@patternfly/chatbot 6.8.0-prerelease.8 → 6.8.0-prerelease.9

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 (307) hide show
  1. package/dist/cjs/CodeModal/CodeModal.js +5 -0
  2. package/dist/cjs/MarkdownContent/MarkdownContent.d.ts +26 -7
  3. package/dist/cjs/MarkdownContent/MarkdownContent.js +79 -166
  4. package/dist/cjs/MarkdownContent/MarkdownRenderer.d.ts +6 -0
  5. package/dist/cjs/MarkdownContent/MarkdownRenderer.js +187 -0
  6. package/dist/cjs/Message/Message.d.ts +3 -4
  7. package/dist/cjs/Message/Message.js +0 -2
  8. package/dist/cjs/MessageBox/MessageBox.js +5 -1
  9. package/dist/cjs/index.d.ts +0 -8
  10. package/dist/cjs/index.js +1 -13
  11. package/dist/css/main.css +18 -3
  12. package/dist/css/main.css.map +1 -1
  13. package/dist/esm/CodeModal/CodeModal.js +5 -0
  14. package/dist/esm/MarkdownContent/MarkdownContent.d.ts +26 -7
  15. package/dist/esm/MarkdownContent/MarkdownContent.js +52 -165
  16. package/dist/esm/MarkdownContent/MarkdownRenderer.d.ts +6 -0
  17. package/dist/esm/MarkdownContent/MarkdownRenderer.js +182 -0
  18. package/dist/esm/Message/Message.d.ts +3 -4
  19. package/dist/esm/Message/Message.js +0 -2
  20. package/dist/esm/MessageBox/MessageBox.js +5 -1
  21. package/dist/esm/index.d.ts +0 -8
  22. package/dist/esm/index.js +0 -8
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/generate-index.js +41 -16
  25. package/generate-index.test.js +68 -0
  26. package/monaco-environment.js +45 -0
  27. package/package.json +20 -2
  28. package/patternfly-docs/content/extensions/chatbot/chatbot.md +1 -0
  29. package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +1 -1
  30. package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickStart.tsx +2 -2
  31. package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +2 -2
  32. package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +1 -1
  33. package/patternfly-docs/content/extensions/chatbot/examples/Messages/monitor-sampleapp-quickstart.ts +1 -0
  34. package/patternfly-docs/content/extensions/chatbot/tree-shaking.md +124 -0
  35. package/patternfly-docs/monaco-environment.js +45 -0
  36. package/patternfly-docs/patternfly-docs.css.js +6 -0
  37. package/src/Chatbot/Chatbot.scss +4 -0
  38. package/src/ChatbotContent/ChatbotContent.scss +1 -1
  39. package/src/ChatbotFooter/ChatbotFooter.scss +2 -2
  40. package/src/ChatbotHeader/ChatbotHeader.scss +4 -0
  41. package/src/ChatbotModal/ChatbotModal.scss +10 -0
  42. package/src/CodeModal/CodeModal.tsx +6 -0
  43. package/src/DeepThinking/DeepThinking.test.tsx +10 -12
  44. package/src/MarkdownContent/MarkdownContent.test.tsx +52 -5
  45. package/src/MarkdownContent/MarkdownContent.tsx +77 -220
  46. package/src/MarkdownContent/MarkdownRenderer.tsx +235 -0
  47. package/src/Message/Message.test.tsx +5 -0
  48. package/src/Message/Message.tsx +3 -5
  49. package/src/MessageBox/MessageBox.tsx +13 -1
  50. package/src/ResponseActions/ResponseActions.test.tsx +42 -48
  51. package/src/ToolCall/ToolCall.test.tsx +6 -9
  52. package/src/ToolResponse/ToolResponse.test.tsx +16 -22
  53. package/src/index.ts +0 -12
  54. package/src/test-utils/markdownTestUtils.ts +21 -0
  55. package/tsconfig.json +6 -1
  56. package/dist/cjs/AttachmentEdit/AttachmentEdit.test.d.ts +0 -1
  57. package/dist/cjs/AttachmentEdit/AttachmentEdit.test.js +0 -77
  58. package/dist/cjs/Chatbot/Chatbot.test.d.ts +0 -1
  59. package/dist/cjs/Chatbot/Chatbot.test.js +0 -32
  60. package/dist/cjs/ChatbotAlert/ChatbotAlert.test.d.ts +0 -1
  61. package/dist/cjs/ChatbotAlert/ChatbotAlert.test.js +0 -27
  62. package/dist/cjs/ChatbotContent/ChatbotContent.test.d.ts +0 -1
  63. package/dist/cjs/ChatbotContent/ChatbotContent.test.js +0 -22
  64. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.d.ts +0 -1
  65. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.js +0 -75
  66. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.d.ts +0 -1
  67. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +0 -601
  68. package/dist/cjs/ChatbotFooter/ChatbotFooter.test.d.ts +0 -1
  69. package/dist/cjs/ChatbotFooter/ChatbotFooter.test.js +0 -27
  70. package/dist/cjs/ChatbotFooter/ChatbotFooternote.test.d.ts +0 -1
  71. package/dist/cjs/ChatbotFooter/ChatbotFooternote.test.js +0 -87
  72. package/dist/cjs/ChatbotHeader/ChatbotHeader.test.d.ts +0 -1
  73. package/dist/cjs/ChatbotHeader/ChatbotHeader.test.js +0 -18
  74. package/dist/cjs/ChatbotHeader/ChatbotHeaderActions.test.d.ts +0 -1
  75. package/dist/cjs/ChatbotHeader/ChatbotHeaderActions.test.js +0 -18
  76. package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.test.d.ts +0 -1
  77. package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.test.js +0 -22
  78. package/dist/cjs/ChatbotHeader/ChatbotHeaderMain.test.d.ts +0 -1
  79. package/dist/cjs/ChatbotHeader/ChatbotHeaderMain.test.js +0 -18
  80. package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.d.ts +0 -1
  81. package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.js +0 -22
  82. package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.test.d.ts +0 -1
  83. package/dist/cjs/ChatbotHeader/ChatbotHeaderNewChatButton.test.js +0 -22
  84. package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.d.ts +0 -1
  85. package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.js +0 -46
  86. package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.d.ts +0 -1
  87. package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +0 -44
  88. package/dist/cjs/ChatbotHeader/ChatbotHeaderTitle.test.d.ts +0 -1
  89. package/dist/cjs/ChatbotHeader/ChatbotHeaderTitle.test.js +0 -55
  90. package/dist/cjs/ChatbotModal/ChatbotModal.test.d.ts +0 -1
  91. package/dist/cjs/ChatbotModal/ChatbotModal.test.js +0 -16
  92. package/dist/cjs/ChatbotToggle/ChatbotToggle.test.d.ts +0 -1
  93. package/dist/cjs/ChatbotToggle/ChatbotToggle.test.js +0 -64
  94. package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.d.ts +0 -1
  95. package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +0 -61
  96. package/dist/cjs/CodeModal/CodeModal.test.d.ts +0 -1
  97. package/dist/cjs/CodeModal/CodeModal.test.js +0 -34
  98. package/dist/cjs/Compare/Compare.test.d.ts +0 -1
  99. package/dist/cjs/Compare/Compare.test.js +0 -18
  100. package/dist/cjs/DeepThinking/DeepThinking.test.d.ts +0 -1
  101. package/dist/cjs/DeepThinking/DeepThinking.test.js +0 -146
  102. package/dist/cjs/FileDetails/FileDetails.test.d.ts +0 -1
  103. package/dist/cjs/FileDetails/FileDetails.test.js +0 -42
  104. package/dist/cjs/FileDetailsLabel/FileDetailsLabel.test.d.ts +0 -1
  105. package/dist/cjs/FileDetailsLabel/FileDetailsLabel.test.js +0 -79
  106. package/dist/cjs/FileDropZone/FileDropZone.test.d.ts +0 -1
  107. package/dist/cjs/FileDropZone/FileDropZone.test.js +0 -100
  108. package/dist/cjs/FilePreview/FilePreview.test.d.ts +0 -1
  109. package/dist/cjs/FilePreview/FilePreview.test.js +0 -97
  110. package/dist/cjs/ImagePreview/ImagePreview.test.d.ts +0 -1
  111. package/dist/cjs/ImagePreview/ImagePreview.test.js +0 -225
  112. package/dist/cjs/MarkdownContent/MarkdownContent.test.d.ts +0 -1
  113. package/dist/cjs/MarkdownContent/MarkdownContent.test.js +0 -192
  114. package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.test.d.ts +0 -1
  115. package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.test.js +0 -131
  116. package/dist/cjs/Message/ErrorMessage/ErrorMessage.test.d.ts +0 -1
  117. package/dist/cjs/Message/ErrorMessage/ErrorMessage.test.js +0 -30
  118. package/dist/cjs/Message/Message.test.d.ts +0 -1
  119. package/dist/cjs/Message/Message.test.js +0 -1128
  120. package/dist/cjs/Message/MessageAndActions/MessageAndActions.test.d.ts +0 -1
  121. package/dist/cjs/Message/MessageAndActions/MessageAndActions.test.js +0 -25
  122. package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.test.d.ts +0 -1
  123. package/dist/cjs/Message/MessageAttachments/MessageAttachmentItem.test.js +0 -25
  124. package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.test.d.ts +0 -1
  125. package/dist/cjs/Message/MessageAttachments/MessageAttachmentsContainer.test.js +0 -25
  126. package/dist/cjs/Message/MessageLoading.test.d.ts +0 -1
  127. package/dist/cjs/Message/MessageLoading.test.js +0 -25
  128. package/dist/cjs/Message/QuickResponse/QuickResponse.test.d.ts +0 -1
  129. package/dist/cjs/Message/QuickResponse/QuickResponse.test.js +0 -109
  130. package/dist/cjs/Message/QuickStarts/QuickStartTileDescription.test.d.ts +0 -1
  131. package/dist/cjs/Message/QuickStarts/QuickStartTileDescription.test.js +0 -76
  132. package/dist/cjs/Message/UserFeedback/UserFeedback.test.d.ts +0 -1
  133. package/dist/cjs/Message/UserFeedback/UserFeedback.test.js +0 -181
  134. package/dist/cjs/Message/UserFeedback/UserFeedbackComplete.test.d.ts +0 -1
  135. package/dist/cjs/Message/UserFeedback/UserFeedbackComplete.test.js +0 -243
  136. package/dist/cjs/MessageBar/AttachButton.test.d.ts +0 -1
  137. package/dist/cjs/MessageBar/AttachButton.test.js +0 -152
  138. package/dist/cjs/MessageBar/MessageBar.test.d.ts +0 -1
  139. package/dist/cjs/MessageBar/MessageBar.test.js +0 -338
  140. package/dist/cjs/MessageBar/SendButton.test.d.ts +0 -1
  141. package/dist/cjs/MessageBar/SendButton.test.js +0 -58
  142. package/dist/cjs/MessageBar/StopButton.test.d.ts +0 -1
  143. package/dist/cjs/MessageBar/StopButton.test.js +0 -58
  144. package/dist/cjs/MessageBox/JumpButton.test.d.ts +0 -1
  145. package/dist/cjs/MessageBox/JumpButton.test.js +0 -39
  146. package/dist/cjs/MessageBox/MessageBox.test.d.ts +0 -1
  147. package/dist/cjs/MessageBox/MessageBox.test.js +0 -294
  148. package/dist/cjs/MessageDivider/MessageDivider.test.d.ts +0 -1
  149. package/dist/cjs/MessageDivider/MessageDivider.test.js +0 -29
  150. package/dist/cjs/Onboarding/Onboarding.test.d.ts +0 -1
  151. package/dist/cjs/Onboarding/Onboarding.test.js +0 -80
  152. package/dist/cjs/PreviewAttachment/PreviewAttachment.test.d.ts +0 -1
  153. package/dist/cjs/PreviewAttachment/PreviewAttachment.test.js +0 -50
  154. package/dist/cjs/ResponseActions/ResponseActionButton.test.d.ts +0 -1
  155. package/dist/cjs/ResponseActions/ResponseActionButton.test.js +0 -54
  156. package/dist/cjs/ResponseActions/ResponseActions.test.d.ts +0 -1
  157. package/dist/cjs/ResponseActions/ResponseActions.test.js +0 -455
  158. package/dist/cjs/ResponseActions/ResponseActionsGroups.test.d.ts +0 -1
  159. package/dist/cjs/ResponseActions/ResponseActionsGroups.test.js +0 -25
  160. package/dist/cjs/Settings/SettingsForm.test.d.ts +0 -1
  161. package/dist/cjs/Settings/SettingsForm.test.js +0 -35
  162. package/dist/cjs/SourcesCard/SourcesCard.test.d.ts +0 -1
  163. package/dist/cjs/SourcesCard/SourcesCard.test.js +0 -39
  164. package/dist/cjs/SourcesCardBase/SourcesCardBase.test.d.ts +0 -1
  165. package/dist/cjs/SourcesCardBase/SourcesCardBase.test.js +0 -199
  166. package/dist/cjs/TermsOfUse/TermsOfUse.test.d.ts +0 -1
  167. package/dist/cjs/TermsOfUse/TermsOfUse.test.js +0 -77
  168. package/dist/cjs/ToolCall/ToolCall.test.d.ts +0 -1
  169. package/dist/cjs/ToolCall/ToolCall.test.js +0 -201
  170. package/dist/cjs/ToolResponse/ToolResponse.test.d.ts +0 -1
  171. package/dist/cjs/ToolResponse/ToolResponse.test.js +0 -184
  172. package/dist/cjs/__mocks__/monaco-editor.d.ts +0 -11
  173. package/dist/cjs/__mocks__/monaco-editor.js +0 -18
  174. package/dist/cjs/__mocks__/rehype-external-links.d.ts +0 -2
  175. package/dist/cjs/__mocks__/rehype-external-links.js +0 -4
  176. package/dist/cjs/__mocks__/rehype-highlight.d.ts +0 -2
  177. package/dist/cjs/__mocks__/rehype-highlight.js +0 -4
  178. package/dist/cjs/__mocks__/rehype-sanitize.d.ts +0 -2
  179. package/dist/cjs/__mocks__/rehype-sanitize.js +0 -4
  180. package/dist/cjs/__mocks__/rehype-unwrap-images.d.ts +0 -2
  181. package/dist/cjs/__mocks__/rehype-unwrap-images.js +0 -4
  182. package/dist/esm/AttachmentEdit/AttachmentEdit.test.d.ts +0 -1
  183. package/dist/esm/AttachmentEdit/AttachmentEdit.test.js +0 -72
  184. package/dist/esm/Chatbot/Chatbot.test.d.ts +0 -1
  185. package/dist/esm/Chatbot/Chatbot.test.js +0 -27
  186. package/dist/esm/ChatbotAlert/ChatbotAlert.test.d.ts +0 -1
  187. package/dist/esm/ChatbotAlert/ChatbotAlert.test.js +0 -22
  188. package/dist/esm/ChatbotContent/ChatbotContent.test.d.ts +0 -1
  189. package/dist/esm/ChatbotContent/ChatbotContent.test.js +0 -17
  190. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.d.ts +0 -1
  191. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.js +0 -70
  192. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.d.ts +0 -1
  193. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +0 -596
  194. package/dist/esm/ChatbotFooter/ChatbotFooter.test.d.ts +0 -1
  195. package/dist/esm/ChatbotFooter/ChatbotFooter.test.js +0 -22
  196. package/dist/esm/ChatbotFooter/ChatbotFooternote.test.d.ts +0 -1
  197. package/dist/esm/ChatbotFooter/ChatbotFooternote.test.js +0 -82
  198. package/dist/esm/ChatbotHeader/ChatbotHeader.test.d.ts +0 -1
  199. package/dist/esm/ChatbotHeader/ChatbotHeader.test.js +0 -13
  200. package/dist/esm/ChatbotHeader/ChatbotHeaderActions.test.d.ts +0 -1
  201. package/dist/esm/ChatbotHeader/ChatbotHeaderActions.test.js +0 -13
  202. package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.test.d.ts +0 -1
  203. package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.test.js +0 -20
  204. package/dist/esm/ChatbotHeader/ChatbotHeaderMain.test.d.ts +0 -1
  205. package/dist/esm/ChatbotHeader/ChatbotHeaderMain.test.js +0 -13
  206. package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.d.ts +0 -1
  207. package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.js +0 -20
  208. package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.d.ts +0 -1
  209. package/dist/esm/ChatbotHeader/ChatbotHeaderNewChatButton.test.js +0 -20
  210. package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.d.ts +0 -1
  211. package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.js +0 -44
  212. package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.d.ts +0 -1
  213. package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +0 -42
  214. package/dist/esm/ChatbotHeader/ChatbotHeaderTitle.test.d.ts +0 -1
  215. package/dist/esm/ChatbotHeader/ChatbotHeaderTitle.test.js +0 -50
  216. package/dist/esm/ChatbotModal/ChatbotModal.test.d.ts +0 -1
  217. package/dist/esm/ChatbotModal/ChatbotModal.test.js +0 -11
  218. package/dist/esm/ChatbotToggle/ChatbotToggle.test.d.ts +0 -1
  219. package/dist/esm/ChatbotToggle/ChatbotToggle.test.js +0 -59
  220. package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.d.ts +0 -1
  221. package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +0 -56
  222. package/dist/esm/CodeModal/CodeModal.test.d.ts +0 -1
  223. package/dist/esm/CodeModal/CodeModal.test.js +0 -29
  224. package/dist/esm/Compare/Compare.test.d.ts +0 -1
  225. package/dist/esm/Compare/Compare.test.js +0 -13
  226. package/dist/esm/DeepThinking/DeepThinking.test.d.ts +0 -1
  227. package/dist/esm/DeepThinking/DeepThinking.test.js +0 -141
  228. package/dist/esm/FileDetails/FileDetails.test.d.ts +0 -1
  229. package/dist/esm/FileDetails/FileDetails.test.js +0 -37
  230. package/dist/esm/FileDetailsLabel/FileDetailsLabel.test.d.ts +0 -1
  231. package/dist/esm/FileDetailsLabel/FileDetailsLabel.test.js +0 -74
  232. package/dist/esm/FileDropZone/FileDropZone.test.d.ts +0 -1
  233. package/dist/esm/FileDropZone/FileDropZone.test.js +0 -95
  234. package/dist/esm/FilePreview/FilePreview.test.d.ts +0 -1
  235. package/dist/esm/FilePreview/FilePreview.test.js +0 -92
  236. package/dist/esm/ImagePreview/ImagePreview.test.d.ts +0 -1
  237. package/dist/esm/ImagePreview/ImagePreview.test.js +0 -220
  238. package/dist/esm/MarkdownContent/MarkdownContent.test.d.ts +0 -1
  239. package/dist/esm/MarkdownContent/MarkdownContent.test.js +0 -187
  240. package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.test.d.ts +0 -1
  241. package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.test.js +0 -126
  242. package/dist/esm/Message/ErrorMessage/ErrorMessage.test.d.ts +0 -1
  243. package/dist/esm/Message/ErrorMessage/ErrorMessage.test.js +0 -25
  244. package/dist/esm/Message/Message.test.d.ts +0 -1
  245. package/dist/esm/Message/Message.test.js +0 -1123
  246. package/dist/esm/Message/MessageAndActions/MessageAndActions.test.d.ts +0 -1
  247. package/dist/esm/Message/MessageAndActions/MessageAndActions.test.js +0 -20
  248. package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.test.d.ts +0 -1
  249. package/dist/esm/Message/MessageAttachments/MessageAttachmentItem.test.js +0 -20
  250. package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.test.d.ts +0 -1
  251. package/dist/esm/Message/MessageAttachments/MessageAttachmentsContainer.test.js +0 -20
  252. package/dist/esm/Message/MessageLoading.test.d.ts +0 -1
  253. package/dist/esm/Message/MessageLoading.test.js +0 -20
  254. package/dist/esm/Message/QuickResponse/QuickResponse.test.d.ts +0 -1
  255. package/dist/esm/Message/QuickResponse/QuickResponse.test.js +0 -104
  256. package/dist/esm/Message/QuickStarts/QuickStartTileDescription.test.d.ts +0 -1
  257. package/dist/esm/Message/QuickStarts/QuickStartTileDescription.test.js +0 -48
  258. package/dist/esm/Message/UserFeedback/UserFeedback.test.d.ts +0 -1
  259. package/dist/esm/Message/UserFeedback/UserFeedback.test.js +0 -176
  260. package/dist/esm/Message/UserFeedback/UserFeedbackComplete.test.d.ts +0 -1
  261. package/dist/esm/Message/UserFeedback/UserFeedbackComplete.test.js +0 -238
  262. package/dist/esm/MessageBar/AttachButton.test.d.ts +0 -1
  263. package/dist/esm/MessageBar/AttachButton.test.js +0 -147
  264. package/dist/esm/MessageBar/MessageBar.test.d.ts +0 -1
  265. package/dist/esm/MessageBar/MessageBar.test.js +0 -333
  266. package/dist/esm/MessageBar/SendButton.test.d.ts +0 -1
  267. package/dist/esm/MessageBar/SendButton.test.js +0 -53
  268. package/dist/esm/MessageBar/StopButton.test.d.ts +0 -1
  269. package/dist/esm/MessageBar/StopButton.test.js +0 -53
  270. package/dist/esm/MessageBox/JumpButton.test.d.ts +0 -1
  271. package/dist/esm/MessageBox/JumpButton.test.js +0 -34
  272. package/dist/esm/MessageBox/MessageBox.test.d.ts +0 -1
  273. package/dist/esm/MessageBox/MessageBox.test.js +0 -289
  274. package/dist/esm/MessageDivider/MessageDivider.test.d.ts +0 -1
  275. package/dist/esm/MessageDivider/MessageDivider.test.js +0 -24
  276. package/dist/esm/Onboarding/Onboarding.test.d.ts +0 -1
  277. package/dist/esm/Onboarding/Onboarding.test.js +0 -75
  278. package/dist/esm/PreviewAttachment/PreviewAttachment.test.d.ts +0 -1
  279. package/dist/esm/PreviewAttachment/PreviewAttachment.test.js +0 -48
  280. package/dist/esm/ResponseActions/ResponseActionButton.test.d.ts +0 -1
  281. package/dist/esm/ResponseActions/ResponseActionButton.test.js +0 -49
  282. package/dist/esm/ResponseActions/ResponseActions.test.d.ts +0 -1
  283. package/dist/esm/ResponseActions/ResponseActions.test.js +0 -450
  284. package/dist/esm/ResponseActions/ResponseActionsGroups.test.d.ts +0 -1
  285. package/dist/esm/ResponseActions/ResponseActionsGroups.test.js +0 -20
  286. package/dist/esm/Settings/SettingsForm.test.d.ts +0 -1
  287. package/dist/esm/Settings/SettingsForm.test.js +0 -33
  288. package/dist/esm/SourcesCard/SourcesCard.test.d.ts +0 -1
  289. package/dist/esm/SourcesCard/SourcesCard.test.js +0 -34
  290. package/dist/esm/SourcesCardBase/SourcesCardBase.test.d.ts +0 -1
  291. package/dist/esm/SourcesCardBase/SourcesCardBase.test.js +0 -194
  292. package/dist/esm/TermsOfUse/TermsOfUse.test.d.ts +0 -1
  293. package/dist/esm/TermsOfUse/TermsOfUse.test.js +0 -72
  294. package/dist/esm/ToolCall/ToolCall.test.d.ts +0 -1
  295. package/dist/esm/ToolCall/ToolCall.test.js +0 -196
  296. package/dist/esm/ToolResponse/ToolResponse.test.d.ts +0 -1
  297. package/dist/esm/ToolResponse/ToolResponse.test.js +0 -179
  298. package/dist/esm/__mocks__/monaco-editor.d.ts +0 -11
  299. package/dist/esm/__mocks__/monaco-editor.js +0 -18
  300. package/dist/esm/__mocks__/rehype-external-links.d.ts +0 -2
  301. package/dist/esm/__mocks__/rehype-external-links.js +0 -2
  302. package/dist/esm/__mocks__/rehype-highlight.d.ts +0 -2
  303. package/dist/esm/__mocks__/rehype-highlight.js +0 -2
  304. package/dist/esm/__mocks__/rehype-sanitize.d.ts +0 -2
  305. package/dist/esm/__mocks__/rehype-sanitize.js +0 -2
  306. package/dist/esm/__mocks__/rehype-unwrap-images.d.ts +0 -2
  307. package/dist/esm/__mocks__/rehype-unwrap-images.js +0 -2
@@ -1,1123 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
- import { Fragment } from 'react';
12
- import { render, screen } from '@testing-library/react';
13
- import '@testing-library/jest-dom';
14
- import Message from './Message';
15
- import userEvent from '@testing-library/user-event';
16
- import { monitorSampleAppQuickStart } from './QuickStarts/monitor-sampleapp-quickstart';
17
- import { monitorSampleAppQuickStartWithImage } from './QuickStarts/monitor-sampleapp-quickstart-with-image';
18
- import rehypeExternalLinks from '../__mocks__/rehype-external-links';
19
- import { AlertActionLink, Button, CodeBlockAction } from '@patternfly/react-core';
20
- // Mock the icon components
21
- jest.mock('@patternfly/react-icons', () => (Object.assign(Object.assign({}, jest.requireActual('@patternfly/react-icons')), { RhUiLikeIcon: () => _jsx("div", { children: "RhUiLikeIcon" }), RhUiLikeFillIcon: () => _jsx("div", { children: "RhUiLikeFillIcon" }), RhUiDislikeIcon: () => _jsx("div", { children: "RhUiDislikeIcon" }), RhUiDislikeFillIcon: () => _jsx("div", { children: "RhUiDislikeFillIcon" }), RhUiCopyIcon: () => _jsx("div", { children: "RhUiCopyIcon" }), RhUiCopyFillIcon: () => _jsx("div", { children: "RhUiCopyFillIcon" }), RhUiEditIcon: () => _jsx("div", { children: "RhUiEditIcon" }), RhUiEditFillIcon: () => _jsx("div", { children: "RhUiEditFillIcon" }), RhUiVolumeUpIcon: () => _jsx("div", { children: "RhUiVolumeUpIcon" }), RhUiVolumeUpFillIcon: () => _jsx("div", { children: "RhUiVolumeUpFillIcon" }), RhUiExportIcon: () => _jsx("div", { children: "RhUiExportIcon" }), RhUiExportFillIcon: () => _jsx("div", { children: "RhUiExportFillIcon" }), RhMicronsInformationFillIcon: () => _jsx("div", { children: "RhMicronsInformationFillIcon" }), RhUiBackwardsIcon: () => _jsx("div", { children: "RhUiBackwardsIcon" }), RhMicronsExternalLinkIcon: () => _jsx("div", { children: "RhMicronsExternalLinkIcon" }), RhMicronsCheckmarkIcon: () => _jsx("div", { children: "RhMicronsCheckmarkIcon" }), RhMicronsCloseIcon: () => _jsx("div", { children: "RhMicronsCloseIcon" }), RhUiBookmarkIcon: () => _jsx("div", { children: "RhUiBookmarkIcon" }), RhUiClockIcon: () => _jsx("div", { children: "RhUiClockIcon" }), RhUiRocketFillIcon: () => _jsx("div", { children: "RhUiRocketFillIcon" }) })));
22
- const ALL_ACTIONS = [
23
- { label: /Good response/i },
24
- { label: /Bad response/i },
25
- { label: /Copy/i },
26
- { label: /Edit/i },
27
- { label: /Share/i },
28
- { label: /Listen/i }
29
- ];
30
- const UNORDERED_LIST = `
31
- Here is an unordered list:
32
-
33
- * Item 1
34
- * Item 2
35
- * Item 3
36
- `;
37
- const ORDERED_LIST = `
38
- Here is an ordered list:
39
-
40
- 1. Item 1
41
- 2. Item 2
42
- 3. Item 3
43
- `;
44
- const CODE_MESSAGE = `
45
- Here is some YAML code:
46
-
47
- ~~~yaml
48
- apiVersion: helm.openshift.io/v1beta1/
49
- kind: HelmChartRepository
50
- metadata:
51
- name: azure-sample-repo0oooo00ooo
52
- spec:
53
- connectionConfig:
54
- url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs
55
- ~~~`;
56
- const CODE = `
57
- apiVersion: helm.openshift.io/v1beta1/
58
- kind: HelmChartRepository
59
- metadata:
60
- name: azure-sample-repo0oooo00ooo
61
- spec:
62
- connectionConfig:
63
- url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs
64
- `;
65
- const INLINE_CODE = `Here is an inline code - \`() => void\``;
66
- const ORDERED_LIST_WITH_CODE = `
67
- 1. Item 1
68
- 2. Item 2
69
-
70
- \`\`\`yaml
71
- - name: Hello World Playbook
72
- hosts: localhost
73
- tasks:
74
- - name: Print Hello World
75
- ansible.builtin.debug:
76
- msg: "Hello, World!"
77
- \`\`\`
78
-
79
- 3. Item 3
80
- `;
81
- const HEADING = `
82
- # h1 Heading
83
-
84
- ## h2 Heading
85
-
86
- ### h3 Heading
87
-
88
- #### h4 Heading
89
-
90
- ##### h5 Heading
91
-
92
- ###### h6 Heading
93
- `;
94
- const BLOCK_QUOTES = `> Blockquotes can also be nested...
95
- >> ...by using additional greater-than signs (>) right next to each other...
96
- > > > ...or with spaces between each sign.`;
97
- const TABLE = `
98
-
99
- | Column 1 | Column 2 |
100
- |-|-|
101
- | Cell 1 | Cell 2 |
102
- | Cell 3 | Cell 4 |
103
-
104
- `;
105
- const TABLE_WITH_INLINE_CODE = `
106
- | Status | Finding |
107
- |---|---|
108
- | \`1/1 Running\`, 0 restarts | Healthy — no crashes |
109
- | \`1/1 Ready\` | Desired replicas met |
110
- `;
111
- const ONE_COLUMN_TABLE = `
112
-
113
- | Column 1 |
114
- |-|
115
- | Cell 1 |
116
- | Cell 2 |
117
-
118
- `;
119
- const ONE_CELL_TABLE = `
120
-
121
- | Column 1 |
122
- |-|
123
- | Cell 1 |
124
-
125
- `;
126
- const HEADERLESS_TABLE = `
127
-
128
- | |
129
- |-|
130
- | Cell 1 |
131
-
132
- `;
133
- const CHILDLESS_TABLE = `
134
-
135
- | Column 1 |
136
- |-|
137
- | |
138
-
139
- `;
140
- const EMPTY_TABLE = `
141
-
142
- | |
143
- |-|
144
- | |
145
-
146
- `;
147
- const FOOTNOTE = `This is some text with a footnote[^1] and here's a longer one.[^bignote]
148
-
149
- You can also reference the same footnote multiple times[^1].
150
-
151
- [^1]: This is the full footnote text. You can click the arrow to go back up.
152
-
153
- [^bignote]: Here's one with multiple paragraphs and **formatting**.
154
-
155
- Indent paragraphs to include them in the footnote.
156
-
157
- Add as many paragraphs as you like. You can include *italic text*, **bold text**, and even \`code\`.
158
-
159
- > You can even include blockquotes in footnotes!`;
160
- const IMAGE = `![Multi-colored wavy lines on a black background](https://cdn.dribbble.com/userupload/10651749/file/original-8a07b8e39d9e8bf002358c66fce1223e.gif)`;
161
- const INLINE_IMAGE = `inline text ![Multi-colored wavy lines on a black background](https://cdn.dribbble.com/userupload/10651749/file/original-8a07b8e39d9e8bf002358c66fce1223e.gif)`;
162
- const DEEP_THINKING = {
163
- toggleContent: 'Show thinking',
164
- subheading: 'Thought for 3 seconds',
165
- body: "Here's why I said this."
166
- };
167
- const ERROR = {
168
- title: 'Could not load chat',
169
- children: 'Wait a few minutes and check your network settings. If the issue persists: ',
170
- actionLinks: (_jsxs(Fragment, { children: [_jsx(AlertActionLink, { component: "a", href: "#", children: "Start a new chat" }), _jsx(AlertActionLink, { component: "a", href: "#", children: "Contact support" })] }))
171
- };
172
- const checkListItemsRendered = () => {
173
- const items = ['Item 1', 'Item 2', 'Item 3'];
174
- expect(screen.getAllByRole('listitem')).toHaveLength(3);
175
- items.forEach((item) => {
176
- // list item text gets wrapped in a span by the third-party library so we can't just check the listitem
177
- expect(screen.getByText(item)).toBeTruthy();
178
- });
179
- };
180
- describe('Message', () => {
181
- beforeEach(() => {
182
- jest.clearAllMocks();
183
- });
184
- it('should render user messages correctly', () => {
185
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "Hi" }));
186
- expect(screen.getByText('User')).toBeTruthy();
187
- expect(screen.getByText('Hi')).toBeTruthy();
188
- const date = new Date();
189
- const formattedDate = date.toLocaleDateString();
190
- expect(screen.getByText((content, element) => {
191
- const hasText = content.includes(formattedDate);
192
- const isVisible = (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'script' && (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'style';
193
- return hasText && isVisible;
194
- })).toBeInTheDocument();
195
- expect(screen.queryByText('Loading message')).toBeFalsy();
196
- expect(screen.getByRole('img')).toHaveAttribute('src', './img');
197
- });
198
- it('should render bot messages correctly', () => {
199
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi" }));
200
- expect(screen.getByText('Bot')).toBeTruthy();
201
- expect(screen.getByText('AI')).toBeTruthy();
202
- expect(screen.getByText('Hi')).toBeTruthy();
203
- const date = new Date();
204
- const formattedDate = date.toLocaleDateString();
205
- expect(screen.getByText((content, element) => {
206
- const hasText = content.includes(formattedDate);
207
- const isVisible = (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'script' && (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'style';
208
- return hasText && isVisible;
209
- })).toBeInTheDocument();
210
- });
211
- it('should render avatar correctly', () => {
212
- render(_jsx(Message, { avatar: "./testImg", role: "user", name: "A", content: "Hi" }));
213
- expect(screen.getByRole('img')).toHaveAttribute('src', './testImg');
214
- });
215
- it('should not render avatar if no avatar prop is passed', () => {
216
- render(_jsx(Message, { role: "user", name: "A", content: "Hi" }));
217
- expect(screen.queryByRole('img')).not.toBeInTheDocument();
218
- });
219
- it('should render bot avatar if no avatar prop is passed', () => {
220
- render(_jsx(Message, { role: "bot", name: "Bot", content: "Hi" }));
221
- expect(screen.queryAllByRole('img', { hidden: true })[0]).toBeVisible();
222
- });
223
- it('should not render avatar if isAvatarHidden is passed', () => {
224
- render(_jsx(Message, { role: "user", name: "A", content: "Hi", isAvatarHidden: true }));
225
- expect(screen.queryByRole('img')).not.toBeInTheDocument();
226
- });
227
- it('should not render bot avatar if isAvatarHidden is passed', () => {
228
- render(_jsx(Message, { role: "bot", name: "Bot", content: "Hi", isAvatarHidden: true }));
229
- expect(screen.queryByRole('img')).not.toBeInTheDocument();
230
- });
231
- it('should render botWord correctly', () => {
232
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", botWord: "\u4EBA\u5DE5\u77E5\u80FD" }));
233
- expect(screen.getByText('Bot')).toBeTruthy();
234
- expect(screen.getByText('人工知能')).toBeTruthy();
235
- expect(screen.queryByText('AI')).toBeFalsy();
236
- expect(screen.getByText('Hi')).toBeTruthy();
237
- });
238
- it('should render timestamps', () => {
239
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", timestamp: "2 hours ago" }));
240
- expect(screen.getByText('Bot')).toBeTruthy();
241
- expect(screen.getByText('AI')).toBeTruthy();
242
- expect(screen.getByText('Hi')).toBeTruthy();
243
- expect(screen.getByText('2 hours ago')).toBeTruthy();
244
- const date = new Date();
245
- const formattedDate = date.toLocaleDateString();
246
- expect(screen.queryByText((content, element) => {
247
- const hasText = content.includes(formattedDate);
248
- const isVisible = (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'script' && (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'style';
249
- return hasText && isVisible;
250
- })).not.toBeInTheDocument();
251
- });
252
- it('Does not render metadata when isMetadataVisible is false', () => {
253
- render(_jsx(Message, { isMetadataVisible: false, avatar: "./img", role: "bot", name: "Bot", content: "Hi", timestamp: "2 hours ago" }));
254
- expect(screen.queryByText('Bot')).not.toBeInTheDocument();
255
- expect(screen.queryByText('AI')).not.toBeInTheDocument();
256
- expect(screen.queryByText('2 hours ago')).not.toBeInTheDocument();
257
- });
258
- it('should render attachments', () => {
259
- render(_jsx(Message, { avatar: "./img", role: "user", content: "Hi", attachments: [{ name: 'testAttachment' }] }));
260
- expect(screen.getByText('Hi')).toBeTruthy();
261
- expect(screen.getByText('testAttachment')).toBeTruthy();
262
- });
263
- it('should be able to click attachments', () => __awaiter(void 0, void 0, void 0, function* () {
264
- const spy = jest.fn();
265
- render(_jsx(Message, { avatar: "./img", role: "user", content: "Hi", attachments: [{ name: 'testAttachment', onClick: spy }] }));
266
- expect(screen.getByText('Hi')).toBeTruthy();
267
- expect(screen.getByText('testAttachment')).toBeTruthy();
268
- yield userEvent.click(screen.getByRole('button', { name: /testAttachment/i }));
269
- expect(spy).toHaveBeenCalledTimes(1);
270
- }));
271
- it('should be able to close attachments', () => __awaiter(void 0, void 0, void 0, function* () {
272
- const spy = jest.fn();
273
- render(_jsx(Message, { avatar: "./img", role: "user", content: "Hi", attachments: [{ name: 'testAttachment', onClose: spy }] }));
274
- expect(screen.getByText('Hi')).toBeTruthy();
275
- expect(screen.getByText('testAttachment')).toBeTruthy();
276
- expect(screen.getByRole('button', { name: /close testAttachment/i })).toBeTruthy();
277
- yield userEvent.click(screen.getByRole('button', { name: /close testAttachment/i }));
278
- expect(spy).toHaveBeenCalledTimes(1);
279
- }));
280
- it('should render loading state', () => {
281
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", isLoading: true }));
282
- expect(screen.getByText('Bot')).toBeTruthy();
283
- expect(screen.getByText('AI')).toBeTruthy();
284
- expect(screen.queryByText('Hi')).toBeFalsy();
285
- const date = new Date();
286
- const formattedDate = date.toLocaleDateString();
287
- expect(screen.getByText((content, element) => {
288
- const hasText = content.includes(formattedDate);
289
- const isVisible = (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'script' && (element === null || element === void 0 ? void 0 : element.tagName.toLowerCase()) !== 'style';
290
- return hasText && isVisible;
291
- })).toBeInTheDocument();
292
- expect(screen.getByText('Loading message')).toBeTruthy();
293
- });
294
- it('should be able to show sources', () => __awaiter(void 0, void 0, void 0, function* () {
295
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", sources: {
296
- sources: [
297
- {
298
- title: 'Getting started with Red Hat OpenShift',
299
- link: '#',
300
- body: 'Red Hat OpenShift on IBM Cloud is a managed offering to create your own cluster of compute hosts where you can deploy and manage containerized apps on IBM Cloud ...'
301
- }
302
- ]
303
- } }));
304
- expect(screen.getByText('Getting started with Red Hat OpenShift')).toBeTruthy();
305
- }));
306
- it('should not show sources if loading', () => {
307
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", isLoading: true, sources: {
308
- sources: [
309
- {
310
- title: 'Getting started with Red Hat OpenShift',
311
- link: '#',
312
- body: 'Red Hat OpenShift on IBM Cloud is a managed offering to create your own cluster of compute hosts where you can deploy and manage containerized apps on IBM Cloud ...'
313
- }
314
- ]
315
- } }));
316
- expect(screen.getByText('Loading message')).toBeTruthy();
317
- expect(screen.queryByText('Getting started with Red Hat OpenShift')).toBeFalsy();
318
- });
319
- it('should be able to show quick response', () => __awaiter(void 0, void 0, void 0, function* () {
320
- const spy = jest.fn();
321
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", quickResponses: [
322
- {
323
- id: '1',
324
- content: 'Yes',
325
- onClick: spy,
326
- className: 'test'
327
- }
328
- ] }));
329
- const quickResponse = screen.getByRole('button', { name: /Yes/i });
330
- expect(quickResponse).toBeTruthy();
331
- yield userEvent.click(quickResponse);
332
- expect(spy).toHaveBeenCalledTimes(1);
333
- }));
334
- it('should be able to handle isCompact', () => __awaiter(void 0, void 0, void 0, function* () {
335
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", quickResponses: [
336
- {
337
- id: '1',
338
- content: 'Yes',
339
- onClick: jest.fn(),
340
- className: 'test'
341
- }
342
- ], isCompact: true }));
343
- const parent = screen.getByRole('button', { name: /Yes/i }).parentNode;
344
- expect(parent).toHaveClass('pf-m-compact');
345
- }));
346
- it('should be able to show more than 1 quick response', () => __awaiter(void 0, void 0, void 0, function* () {
347
- const spy = jest.fn();
348
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", quickResponses: [
349
- {
350
- id: '1',
351
- content: 'Yes',
352
- onClick: spy
353
- },
354
- {
355
- id: '2',
356
- content: 'No',
357
- onClick: spy
358
- }
359
- ] }));
360
- expect(screen.getByRole('button', { name: /Yes/i })).toBeTruthy();
361
- expect(screen.getByRole('button', { name: /No/i })).toBeTruthy();
362
- }));
363
- it('should be able to spread quickResponseContainerProps', () => __awaiter(void 0, void 0, void 0, function* () {
364
- const spy = jest.fn();
365
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", quickResponses: [
366
- {
367
- id: '1',
368
- content: 'Yes',
369
- onClick: spy
370
- },
371
- {
372
- id: '2',
373
- content: 'No',
374
- onClick: spy
375
- }
376
- ],
377
- // this is a LabelGroup prop that changes the default number shown
378
- // to be different than what we use in ChatBot
379
- quickResponseContainerProps: { numLabels: 1 } }));
380
- expect(screen.getByRole('button', { name: /Yes/i })).toBeTruthy();
381
- expect(screen.queryByRole('button', { name: /No/i })).toBeFalsy();
382
- expect(screen.getByRole('button', { name: /1 more/i }));
383
- }));
384
- it('Renders response actions when a single actions object is passed', () => __awaiter(void 0, void 0, void 0, function* () {
385
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", actions: {
386
- // eslint-disable-next-line no-console
387
- positive: { onClick: () => console.log('Good response') },
388
- // eslint-disable-next-line no-console
389
- negative: { onClick: () => console.log('Bad response') },
390
- // eslint-disable-next-line no-console
391
- copy: { onClick: () => console.log('Copy') },
392
- // eslint-disable-next-line no-console
393
- edit: { onClick: () => console.log('Edit') },
394
- // eslint-disable-next-line no-console
395
- share: { onClick: () => console.log('Share') },
396
- // eslint-disable-next-line no-console
397
- download: { onClick: () => console.log('Download') },
398
- // eslint-disable-next-line no-console
399
- listen: { onClick: () => console.log('Listen') }
400
- } }));
401
- ALL_ACTIONS.forEach(({ label }) => {
402
- expect(screen.getByRole('button', { name: label })).toBeVisible();
403
- });
404
- }));
405
- it('Renders response actions when an array of actions objects is passed', () => __awaiter(void 0, void 0, void 0, function* () {
406
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", actions: [
407
- {
408
- // eslint-disable-next-line no-console
409
- positive: { onClick: () => console.log('Good response') },
410
- // eslint-disable-next-line no-console
411
- negative: { onClick: () => console.log('Bad response') }
412
- },
413
- {
414
- // eslint-disable-next-line no-console
415
- copy: { onClick: () => console.log('Copy') },
416
- // eslint-disable-next-line no-console
417
- edit: { onClick: () => console.log('Edit') },
418
- // eslint-disable-next-line no-console
419
- share: { onClick: () => console.log('Share') },
420
- // eslint-disable-next-line no-console
421
- download: { onClick: () => console.log('Download') }
422
- },
423
- {
424
- // eslint-disable-next-line no-console
425
- listen: { onClick: () => console.log('Listen') }
426
- }
427
- ] }));
428
- ALL_ACTIONS.forEach(({ label }) => {
429
- expect(screen.getByRole('button', { name: label })).toBeVisible();
430
- });
431
- }));
432
- it('Renders response actions when an array of objects containing actions objects is passed', () => __awaiter(void 0, void 0, void 0, function* () {
433
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", actions: [
434
- {
435
- actions: {
436
- // eslint-disable-next-line no-console
437
- positive: { onClick: () => console.log('Good response') },
438
- // eslint-disable-next-line no-console
439
- negative: { onClick: () => console.log('Bad response') }
440
- }
441
- },
442
- {
443
- actions: {
444
- // eslint-disable-next-line no-console
445
- copy: { onClick: () => console.log('Copy') },
446
- // eslint-disable-next-line no-console
447
- edit: { onClick: () => console.log('Edit') },
448
- // eslint-disable-next-line no-console
449
- share: { onClick: () => console.log('Share') },
450
- // eslint-disable-next-line no-console
451
- download: { onClick: () => console.log('Download') }
452
- }
453
- },
454
- {
455
- actions: {
456
- // eslint-disable-next-line no-console
457
- listen: { onClick: () => console.log('Listen') }
458
- }
459
- }
460
- ] }));
461
- ALL_ACTIONS.forEach(({ label }) => {
462
- expect(screen.getByRole('button', { name: label })).toBeVisible();
463
- });
464
- }));
465
- it('should handle persistActionSelection correctly when a single actions object is passed', () => __awaiter(void 0, void 0, void 0, function* () {
466
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Test message", persistActionSelection: true, actions: {
467
- positive: { onClick: jest.fn() },
468
- negative: { onClick: jest.fn() }
469
- } }));
470
- const goodBtn = screen.getByRole('button', { name: /Good response/i });
471
- const badBtn = screen.getByRole('button', { name: /Bad response/i });
472
- yield userEvent.click(goodBtn);
473
- expect(screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
474
- yield userEvent.click(screen.getByText('Test message'));
475
- expect(screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
476
- yield userEvent.click(badBtn);
477
- expect(screen.getByRole('button', { name: /Bad response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
478
- expect(goodBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
479
- }));
480
- it('should handle persistActionSelection correctly when an array of actions objects is passed', () => __awaiter(void 0, void 0, void 0, function* () {
481
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Test message", persistActionSelection: true, actions: [
482
- {
483
- positive: { onClick: jest.fn() },
484
- negative: { onClick: jest.fn() }
485
- },
486
- {
487
- copy: { onClick: jest.fn() }
488
- }
489
- ] }));
490
- const goodBtn = screen.getByRole('button', { name: /Good response/i });
491
- const copyBtn = screen.getByRole('button', { name: /Copy/i });
492
- yield userEvent.click(goodBtn);
493
- expect(screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
494
- yield userEvent.click(screen.getByText('Test message'));
495
- expect(screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
496
- yield userEvent.click(copyBtn);
497
- expect(screen.getByRole('button', { name: /Copied/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
498
- yield userEvent.click(screen.getByText('Test message'));
499
- expect(screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
500
- expect(screen.getByRole('button', { name: /Copied/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
501
- }));
502
- it('should handle persistActionSelection correctly when an array of objects containing actions objects is passed', () => __awaiter(void 0, void 0, void 0, function* () {
503
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Test message", actions: [
504
- {
505
- actions: {
506
- positive: { onClick: jest.fn() },
507
- negative: { onClick: jest.fn() }
508
- },
509
- persistActionSelection: true
510
- },
511
- {
512
- actions: {
513
- copy: { onClick: jest.fn() }
514
- },
515
- persistActionSelection: false
516
- }
517
- ] }));
518
- const goodBtn = screen.getByRole('button', { name: /Good response/i });
519
- const copyBtn = screen.getByRole('button', { name: /Copy/i });
520
- yield userEvent.click(goodBtn);
521
- expect(screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
522
- yield userEvent.click(copyBtn);
523
- expect(screen.getByRole('button', { name: /Copied/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
524
- yield userEvent.click(screen.getByText('Test message'));
525
- expect(screen.getByRole('button', { name: /Good response recorded/i })).toHaveClass('pf-chatbot__button--response-action-clicked');
526
- expect(copyBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
527
- }));
528
- it('should not show actions if loading', () => __awaiter(void 0, void 0, void 0, function* () {
529
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", isLoading: true, actions: {
530
- // eslint-disable-next-line no-console
531
- positive: { onClick: () => console.log('Good response') },
532
- // eslint-disable-next-line no-console
533
- negative: { onClick: () => console.log('Bad response') },
534
- // eslint-disable-next-line no-console
535
- copy: { onClick: () => console.log('Copy') },
536
- // eslint-disable-next-line no-console
537
- edit: { onClick: () => console.log('Edit') },
538
- // eslint-disable-next-line no-console
539
- share: { onClick: () => console.log('Share') },
540
- // eslint-disable-next-line no-console
541
- download: { onClick: () => console.log('Download') },
542
- // eslint-disable-next-line no-console
543
- listen: { onClick: () => console.log('Listen') }
544
- } }));
545
- expect(screen.getByText('Loading message')).toBeTruthy();
546
- ALL_ACTIONS.forEach(({ label }) => {
547
- expect(screen.queryByRole('button', { name: label })).toBeFalsy();
548
- });
549
- }));
550
- it('should not show actions if isEditable is true', () => __awaiter(void 0, void 0, void 0, function* () {
551
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", isEditable: true, actions: {
552
- // eslint-disable-next-line no-console
553
- positive: { onClick: () => console.log('Good response') },
554
- // eslint-disable-next-line no-console
555
- negative: { onClick: () => console.log('Bad response') },
556
- // eslint-disable-next-line no-console
557
- copy: { onClick: () => console.log('Copy') },
558
- // eslint-disable-next-line no-console
559
- edit: { onClick: () => console.log('Edit') },
560
- // eslint-disable-next-line no-console
561
- share: { onClick: () => console.log('Share') },
562
- // eslint-disable-next-line no-console
563
- download: { onClick: () => console.log('Download') },
564
- // eslint-disable-next-line no-console
565
- listen: { onClick: () => console.log('Listen') }
566
- } }));
567
- ALL_ACTIONS.forEach(({ label }) => {
568
- expect(screen.queryByRole('button', { name: label })).toBeFalsy();
569
- });
570
- }));
571
- it('should render unordered lists correctly', () => {
572
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: UNORDERED_LIST }));
573
- expect(screen.getByText('Here is an unordered list:')).toBeTruthy();
574
- checkListItemsRendered();
575
- });
576
- it('should render ordered lists correctly', () => {
577
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: ORDERED_LIST }));
578
- expect(screen.getByText('Here is an ordered list:')).toBeTruthy();
579
- checkListItemsRendered();
580
- });
581
- it('should render ordered lists correctly if there is interstitial content', () => {
582
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: ORDERED_LIST_WITH_CODE }));
583
- checkListItemsRendered();
584
- const list = screen.getAllByRole('list')[1];
585
- expect(list).toHaveAttribute('start', '3');
586
- });
587
- it('should render inline code', () => {
588
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: INLINE_CODE }));
589
- expect(screen.getByText(/() => void/i)).toBeTruthy();
590
- expect(screen.queryByRole('button', { name: 'Copy code button' })).toBeFalsy();
591
- });
592
- it('should render code correctly', () => {
593
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE }));
594
- expect(screen.getByText('Here is some YAML code:')).toBeTruthy();
595
- expect(screen.getByRole('button', { name: 'Copy code' })).toBeTruthy();
596
- expect(screen.getByText(/yaml/)).toBeTruthy();
597
- expect(screen.getByText(/apiVersion:/i)).toBeTruthy();
598
- expect(screen.getByText(/helm.openshift.io\/v1beta1/i)).toBeTruthy();
599
- expect(screen.getByText(/metadata:/i)).toBeTruthy();
600
- expect(screen.getByText(/name:/i)).toBeTruthy();
601
- expect(screen.getByText(/azure-sample-repo0oooo00ooo/i)).toBeTruthy();
602
- expect(screen.getByText(/spec/i)).toBeTruthy();
603
- expect(screen.getByText(/connectionConfig:/i)).toBeTruthy();
604
- expect(screen.getByText(/url:/i)).toBeTruthy();
605
- expect(screen.getByText(/https:\/\/raw.githubusercontent.com\/Azure-Samples\/helm-charts\/master\/docs/i)).toBeTruthy();
606
- });
607
- it('should render expandable code correctly', () => {
608
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE, codeBlockProps: { isExpandable: true } }));
609
- expect(screen.getByText('Here is some YAML code:')).toBeTruthy();
610
- expect(screen.getByRole('button', { name: 'Copy code' })).toBeTruthy();
611
- expect(screen.getByText(/yaml/)).toBeTruthy();
612
- expect(screen.getByText(/apiVersion/i)).toBeTruthy();
613
- expect(screen.getByRole('button', { name: /Show more/i })).toBeTruthy();
614
- });
615
- it('should handle click on expandable code correctly', () => __awaiter(void 0, void 0, void 0, function* () {
616
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE, codeBlockProps: { isExpandable: true } }));
617
- const button = screen.getByRole('button', { name: /Show more/i });
618
- yield userEvent.click(button);
619
- expect(screen.getByRole('button', { name: /Show less/i })).toBeTruthy();
620
- expect(screen.getByText(/yaml/)).toBeTruthy();
621
- expect(screen.getByText(/apiVersion:/i)).toBeTruthy();
622
- expect(screen.getByText(/helm.openshift.io\/v1beta1/i)).toBeTruthy();
623
- expect(screen.getByText(/metadata:/i)).toBeTruthy();
624
- expect(screen.getByText(/name:/i)).toBeTruthy();
625
- expect(screen.getByText(/azure-sample-repo0oooo00ooo/i)).toBeTruthy();
626
- expect(screen.getByText(/spec/i)).toBeTruthy();
627
- expect(screen.getByText(/connectionConfig:/i)).toBeTruthy();
628
- expect(screen.getByText(/url:/i)).toBeTruthy();
629
- expect(screen.getByText(/https:\/\/raw.githubusercontent.com\/Azure-Samples\/helm-charts\/master\/docs/i)).toBeTruthy();
630
- }));
631
- it('can click copy code button', () => __awaiter(void 0, void 0, void 0, function* () {
632
- // need explicit setup since RTL stubs clipboard if you do this
633
- const user = userEvent.setup();
634
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE }));
635
- expect(screen.getByRole('button', { name: 'Copy code' })).toBeTruthy();
636
- yield user.click(screen.getByRole('button', { name: 'Copy code' }));
637
- const clipboardText = yield navigator.clipboard.readText();
638
- expect(clipboardText.trim()).toEqual(CODE.trim());
639
- }));
640
- it('should handle codeBlockProps correctly by spreading it onto the CodeMessage', () => {
641
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE, codeBlockProps: { 'aria-label': 'test' } }));
642
- expect(screen.getByRole('button', { name: 'test' })).toBeTruthy();
643
- });
644
- it('should be able to add custom actions to CodeMessage', () => {
645
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE, codeBlockProps: {
646
- customActions: (_jsx(CodeBlockAction, { children: _jsx(Button, { children: "New custom action" }) }))
647
- } }));
648
- expect(screen.getByRole('button', { name: /New custom action/i })).toBeTruthy();
649
- });
650
- it('should handle hasRoundAvatar correctly when it is true', () => {
651
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "Hi", hasRoundAvatar: true }));
652
- expect(screen.getByRole('img')).toBeTruthy();
653
- expect(screen.getByRole('img')).toHaveClass('pf-chatbot__message-avatar');
654
- expect(screen.getByRole('img')).toHaveClass('pf-chatbot__message-avatar--round');
655
- });
656
- it('should handle hasRoundAvatar correctly when it is false', () => {
657
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "Hi", hasRoundAvatar: false }));
658
- expect(screen.getByRole('img')).toBeTruthy();
659
- expect(screen.getByRole('img')).toHaveClass('pf-chatbot__message-avatar');
660
- expect(screen.getByRole('img')).not.toHaveClass('pf-chatbot__message-avatar--round');
661
- });
662
- it('should handle avatarProps correctly by spreading it onto the Message Avatar', () => {
663
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "Hi", avatarProps: { className: 'test' } }));
664
- expect(screen.getByRole('img')).toBeTruthy();
665
- expect(screen.getByRole('img')).toHaveClass('test');
666
- });
667
- it('should handle avatarProps and hasRoundAvatar correctly', () => {
668
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "Hi", avatarProps: { className: 'test' }, hasRoundAvatar: false }));
669
- expect(screen.getByRole('img')).toBeTruthy();
670
- expect(screen.getByRole('img')).toHaveClass('test');
671
- expect(screen.getByRole('img')).toHaveClass('pf-chatbot__message-avatar');
672
- });
673
- it('should handle QuickStart tile correctly', () => {
674
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "Hi", quickStarts: {
675
- quickStart: monitorSampleAppQuickStart,
676
- onSelectQuickStart: (id) => alert(id)
677
- } }));
678
- expect(screen.getByRole('button', { name: 'Monitoring your sample application' })).toBeTruthy();
679
- expect(screen.getByRole('heading', { name: '1 Prerequisite' })).toBeTruthy();
680
- expect(screen.getByRole('button', { name: 'Show prerequisites' })).toBeTruthy();
681
- expect(screen.getByRole('button', { name: 'Start' })).toBeTruthy();
682
- });
683
- it('should handle click on QuickStart tile correctly', () => __awaiter(void 0, void 0, void 0, function* () {
684
- const spy = jest.fn();
685
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "Hi", quickStarts: {
686
- quickStart: monitorSampleAppQuickStart,
687
- onSelectQuickStart: (id) => spy(id)
688
- } }));
689
- yield userEvent.click(screen.getByRole('button', { name: 'Monitoring your sample application' }));
690
- expect(spy).toHaveBeenCalledTimes(1);
691
- expect(spy).toHaveBeenCalledWith(monitorSampleAppQuickStart.metadata.name);
692
- }));
693
- it('should handle QuickStart tile with image correctly', () => __awaiter(void 0, void 0, void 0, function* () {
694
- const spy = jest.fn();
695
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "Hi", quickStarts: {
696
- quickStart: monitorSampleAppQuickStartWithImage,
697
- onSelectQuickStart: (id) => spy(id)
698
- } }));
699
- expect(screen.getAllByRole('img')[1]).toHaveAttribute('src', 'test.png');
700
- }));
701
- it('should handle tool response correctly', () => __awaiter(void 0, void 0, void 0, function* () {
702
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "Hi", toolResponse: {
703
- toggleContent: 'Tool response: Name',
704
- subheading: 'Thought for 3 seconds',
705
- body: 'Lorem ipsum dolor sit amet',
706
- cardTitle: 'Card title',
707
- cardBody: 'Card body'
708
- } }));
709
- expect(screen.getByRole('button', { name: /Tool response: Name/i })).toBeTruthy();
710
- expect(screen.getByText('Thought for 3 seconds')).toBeTruthy();
711
- expect(screen.getByText('Lorem ipsum dolor sit amet')).toBeTruthy();
712
- expect(screen.getByText('Card title')).toBeTruthy();
713
- expect(screen.getByText('Card body')).toBeTruthy();
714
- }));
715
- it('should handle block quote correctly', () => {
716
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: BLOCK_QUOTES }));
717
- expect(screen.getByText(/Blockquotes can also be nested.../)).toBeTruthy();
718
- expect(screen.getByText('...by using additional greater-than signs (>) right next to each other...')).toBeTruthy();
719
- expect(screen.getByText(/...or with spaces between each sign./)).toBeTruthy();
720
- });
721
- it('should handle heading correctly', () => {
722
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: HEADING }));
723
- expect(screen.getByRole('heading', { name: /h1 Heading/i })).toBeTruthy();
724
- expect(screen.getByRole('heading', { name: /h2 Heading/i })).toBeTruthy();
725
- expect(screen.getByRole('heading', { name: /h3 Heading/i })).toBeTruthy();
726
- expect(screen.getByRole('heading', { name: /h4 Heading/i })).toBeTruthy();
727
- expect(screen.getByRole('heading', { name: /h5 Heading/i })).toBeTruthy();
728
- expect(screen.getByRole('heading', { name: /h6 Heading/i })).toBeTruthy();
729
- });
730
- it('should render table correctly', () => {
731
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: TABLE }));
732
- expect(screen.getByRole('row', { name: /Column 1 Column 2/i })).toBeTruthy();
733
- expect(screen.getByRole('row', { name: /Cell 1 Cell 2/i })).toBeTruthy();
734
- expect(screen.getByRole('row', { name: /Cell 3 Cell 4/i })).toBeTruthy();
735
- expect(screen.getByRole('columnheader', { name: /Column 1/i })).toBeTruthy();
736
- expect(screen.getByRole('columnheader', { name: /Column 2/i })).toBeTruthy();
737
- expect(screen.getByRole('cell', { name: /Cell 1/i })).toBeTruthy();
738
- expect(screen.getByRole('cell', { name: /Cell 2/i })).toBeTruthy();
739
- expect(screen.getByRole('cell', { name: /Cell 3/i })).toBeTruthy();
740
- expect(screen.getByRole('cell', { name: /Cell 4/i })).toBeTruthy();
741
- });
742
- it('should render table data labels correctly for mobile breakpoint', () => {
743
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: TABLE }));
744
- expect(screen.getByRole('row', { name: /Cell 1 Cell 2/i })).toHaveAttribute('extraHeaders', 'Column 1,Column 2');
745
- expect(screen.getByRole('row', { name: /Cell 3 Cell 4/i })).toHaveAttribute('extraHeaders', 'Column 1,Column 2');
746
- expect(screen.getByRole('cell', { name: /Cell 1/i })).toHaveAttribute('data-label', 'Column 1');
747
- expect(screen.getByRole('cell', { name: /Cell 2/i })).toHaveAttribute('data-label', 'Column 2');
748
- expect(screen.getByRole('cell', { name: /Cell 3/i })).toHaveAttribute('data-label', 'Column 1');
749
- expect(screen.getByRole('cell', { name: /Cell 4/i })).toHaveAttribute('data-label', 'Column 2');
750
- });
751
- it('should render table data labels correctly for mobile breakpoint for one column table', () => {
752
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: ONE_COLUMN_TABLE }));
753
- expect(screen.getByRole('row', { name: /Cell 1/i })).toHaveAttribute('extraHeaders', 'Column 1');
754
- expect(screen.getByRole('row', { name: /Cell 2/i })).toHaveAttribute('extraHeaders', 'Column 1');
755
- expect(screen.getByRole('cell', { name: /Cell 1/i })).toHaveAttribute('data-label', 'Column 1');
756
- expect(screen.getByRole('cell', { name: /Cell 2/i })).toHaveAttribute('data-label', 'Column 1');
757
- });
758
- it('should render table data labels correctly for mobile breakpoint for one cell table', () => {
759
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: ONE_CELL_TABLE }));
760
- expect(screen.getByRole('row', { name: /Cell 1/i })).toHaveAttribute('extraHeaders', 'Column 1');
761
- expect(screen.getByRole('cell', { name: /Cell 1/i })).toHaveAttribute('data-label', 'Column 1');
762
- });
763
- it('should render table data labels correctly for mobile breakpoint for headerless', () => {
764
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: HEADERLESS_TABLE }));
765
- expect(screen.getByRole('row', { name: /Cell 1/i })).toHaveAttribute('extraHeaders', '');
766
- expect(screen.getByRole('cell', { name: /Cell 1/i })).not.toHaveAttribute('data-label');
767
- });
768
- it('should render table data labels correctly for mobile breakpoint for childless', () => {
769
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: CHILDLESS_TABLE }));
770
- expect(screen.getByRole('cell')).not.toHaveAttribute('extraHeaders', 'Column 1');
771
- });
772
- it('should render table data labels correctly for mobile breakpoint for empty', () => {
773
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: EMPTY_TABLE }));
774
- expect(screen.getByRole('cell')).not.toHaveAttribute('extraHeaders', '');
775
- });
776
- it('should render custom table aria label correctly', () => {
777
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: TABLE, tableProps: { 'aria-label': 'Test' } }));
778
- expect(screen.getByRole('grid', { name: /Test/i })).toBeTruthy();
779
- });
780
- it('should wrap table cell content so inline code does not break grid layout', () => {
781
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: TABLE_WITH_INLINE_CODE, tableProps: { 'aria-label': 'Inline code table' } }));
782
- const statusCell = screen.getByRole('cell', { name: /1\/1 Running/i });
783
- expect(statusCell.querySelector(':scope > .pf-chatbot__message-table-cell-content')).toBeTruthy();
784
- expect(statusCell.querySelector(':scope > code')).toBeFalsy();
785
- expect(statusCell.querySelector('.pf-chatbot__message-inline-code')).toBeTruthy();
786
- expect(screen.getByRole('columnheader', { name: /Status/i }).querySelector('.pf-chatbot__message-table-cell-content')).toBeTruthy();
787
- });
788
- it('should render footnote correctly', () => {
789
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: FOOTNOTE }));
790
- expect(screen.getByText(/This is some text with a footnote/i)).toBeTruthy();
791
- expect(screen.getByText(/and here's a longer one./i)).toBeTruthy();
792
- expect(screen.getByText(/You can also reference the same footnote multiple times./i)).toBeTruthy();
793
- expect(screen.getByRole('heading', { name: /Footnotes/i })).toBeTruthy();
794
- expect(screen.getByText(/This is the full footnote text. You can click the arrow to go back up./i)).toBeTruthy();
795
- expect(screen.getByText(/Here's one with multiple paragraphs and/i)).toBeTruthy();
796
- expect(screen.getByText(/formatting/i)).toBeTruthy();
797
- expect(screen.getByText(/Indent paragraphs to include them in the footnote./i)).toBeTruthy();
798
- expect(screen.getByText(/Add as many paragraphs as you like. You can include/i)).toBeTruthy();
799
- expect(screen.getByText(/italic text/i)).toBeTruthy();
800
- expect(screen.getByText(/bold text/i)).toBeTruthy();
801
- expect(screen.getByText(/, and even/i)).toBeTruthy();
802
- expect(screen.getByText(/code/i)).toBeTruthy();
803
- expect(screen.getByText(/You can even include blockquotes in footnotes!/i)).toBeTruthy();
804
- expect(screen.getAllByRole('link', { name: '1' })).toHaveLength(2);
805
- expect(screen.getAllByRole('link', { name: '2' })).toBeTruthy();
806
- expect(screen.getByRole('link', { name: 'Back to reference 1' })).toBeTruthy();
807
- expect(screen.getByRole('link', { name: 'Back to reference 1-2' })).toBeTruthy();
808
- expect(screen.getByRole('link', { name: /Back to reference 2/i })).toBeTruthy();
809
- });
810
- it('should render beforeMainContent with main content', () => {
811
- const mainContent = 'Main message content';
812
- const beforeMainContentText = 'Before main content';
813
- const beforeMainContent = _jsx("div", { children: beforeMainContentText });
814
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: mainContent, extraContent: { beforeMainContent } }));
815
- expect(screen.getByText(beforeMainContentText)).toBeTruthy();
816
- expect(screen.getByText(mainContent)).toBeTruthy();
817
- });
818
- it('should render afterMainContent with main content', () => {
819
- const mainContent = 'Main message content';
820
- const afterMainContentText = 'After main content';
821
- const afterMainContent = _jsx("div", { children: afterMainContentText });
822
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: mainContent, extraContent: { afterMainContent } }));
823
- expect(screen.getByText(afterMainContentText)).toBeTruthy();
824
- expect(screen.getByText(mainContent)).toBeTruthy();
825
- });
826
- it('should render endContent with main content', () => {
827
- const mainContent = 'Main message content';
828
- const endMainContentText = 'End content';
829
- const endContent = _jsx("div", { children: endMainContentText });
830
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: mainContent, extraContent: { endContent } }));
831
- expect(screen.getByText(endMainContentText)).toBeTruthy();
832
- expect(screen.getByText(mainContent)).toBeTruthy();
833
- });
834
- it('should render all parts of extraContent with main content', () => {
835
- const beforeMainContent = _jsx("div", { children: "Before main content" });
836
- const afterMainContent = _jsx("div", { children: "After main content" });
837
- const endContent = _jsx("div", { children: "End content" });
838
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "Main message content", extraContent: { beforeMainContent, afterMainContent, endContent } }));
839
- expect(screen.getByText('Before main content')).toBeTruthy();
840
- expect(screen.getByText('Main message content')).toBeTruthy();
841
- expect(screen.getByText('After main content')).toBeTruthy();
842
- expect(screen.getByText('End content')).toBeTruthy();
843
- });
844
- it('should not render extraContent when not provided', () => {
845
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "Main message content" }));
846
- // Ensure no extraContent is rendered
847
- expect(screen.getByText('Main message content')).toBeTruthy();
848
- expect(screen.queryByText('Before main content')).toBeFalsy();
849
- expect(screen.queryByText('After main content')).toBeFalsy();
850
- expect(screen.queryByText('end message content')).toBeFalsy();
851
- });
852
- it('should handle undefined or null values in extraContent gracefully', () => {
853
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "Main message content", extraContent: { beforeMainContent: null, afterMainContent: undefined, endContent: null } }));
854
- // Ensure that no extraContent is rendered if they are null or undefined
855
- expect(screen.getByText('Main message content')).toBeTruthy();
856
- expect(screen.queryByText('Before main content')).toBeFalsy();
857
- expect(screen.queryByText('After main content')).toBeFalsy();
858
- expect(screen.queryByText('end message content')).toBeFalsy();
859
- });
860
- it('should render JSX in extraContent correctly', () => {
861
- const beforeMainContent = (_jsx("div", { "data-testid": "before-main-content", children: _jsx("strong", { children: "Bold before content" }) }));
862
- const afterMainContent = (_jsx("div", { "data-testid": "after-main-content", children: _jsx("strong", { children: "Bold after content" }) }));
863
- const endContent = (_jsx("div", { "data-testid": "end-main-content", children: _jsx("strong", { children: "Bold end content" }) }));
864
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "Main message content", extraContent: { beforeMainContent, afterMainContent, endContent } }));
865
- // Check that the JSX is correctly rendered
866
- expect(screen.getByTestId('before-main-content')).toContainHTML('<strong>Bold before content</strong>');
867
- expect(screen.getByTestId('after-main-content')).toContainHTML('<strong>Bold after content</strong>');
868
- expect(screen.getByTestId('end-main-content')).toContainHTML('<strong>Bold end content</strong>');
869
- });
870
- it('should handle image correctly for user', () => {
871
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: IMAGE }));
872
- expect(screen.queryByRole('img', { name: /Multi-colored wavy lines on a black background/i })).toBeFalsy();
873
- });
874
- it('should handle image correctly for bot', () => {
875
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: IMAGE }));
876
- expect(screen.getByRole('img', { name: /Multi-colored wavy lines on a black background/i })).toBeTruthy();
877
- });
878
- it('inline image parent should have class pf-chatbot__message-and-actions', () => {
879
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: INLINE_IMAGE }));
880
- expect(screen.getByRole('img', { name: /Multi-colored wavy lines on a black background/i })).toBeTruthy();
881
- expect(screen.getByRole('img', { name: /Multi-colored wavy lines on a black background/i }).parentElement).toHaveClass('pf-chatbot__message-and-actions');
882
- });
883
- it('should handle external links correctly', () => {
884
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: `[PatternFly](https://www.patternfly.org/)` }));
885
- // we are mocking rehype libraries, so we can't test target _blank addition on links directly with RTL
886
- expect(rehypeExternalLinks).toHaveBeenCalledTimes(1);
887
- });
888
- it('should handle external links correctly', () => {
889
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: `[PatternFly](https://www.patternfly.org/)`, openLinkInNewTab: false }));
890
- // we are mocking rehype libraries, so we can't test target _blank addition on links directly with RTL
891
- expect(rehypeExternalLinks).not.toHaveBeenCalled();
892
- });
893
- it('should handle extra link props correctly', () => __awaiter(void 0, void 0, void 0, function* () {
894
- const spy = jest.fn();
895
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: `[PatternFly](https://www.patternfly.org/)`, linkProps: { onClick: spy } }));
896
- yield userEvent.click(screen.getByRole('link', { name: /PatternFly/i }));
897
- expect(spy).toHaveBeenCalledTimes(1);
898
- }));
899
- it('should handle error correctly', () => {
900
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", error: ERROR }));
901
- expect(screen.getByRole('heading', { name: /Could not load chat/i })).toBeTruthy();
902
- expect(screen.getByRole('link', { name: /Start a new chat/i })).toBeTruthy();
903
- expect(screen.getByRole('link', { name: /Contact support/i })).toBeTruthy();
904
- expect(screen.getByText('Wait a few minutes and check your network settings. If the issue persists:')).toBeTruthy();
905
- });
906
- it('should handle error correctly when loading', () => {
907
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", error: ERROR, isLoading: true }));
908
- expect(screen.queryByRole('heading', { name: /Could not load chat/i })).toBeFalsy();
909
- expect(screen.getByText('Loading message')).toBeTruthy();
910
- });
911
- it('should handle error correctly when these is content', () => {
912
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", error: ERROR, content: "Test" }));
913
- expect(screen.getByRole('heading', { name: /Could not load chat/i })).toBeTruthy();
914
- expect(screen.queryByText('Test')).toBeFalsy();
915
- });
916
- it('should handle isEditable when there is message content', () => {
917
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, content: "Test" }));
918
- expect(screen.getByRole('textbox')).toBeTruthy();
919
- expect(screen.getByRole('textbox')).toHaveValue('Test');
920
- expect(screen.getByRole('button', { name: /Update/i })).toBeTruthy();
921
- expect(screen.getByRole('button', { name: /Cancel/i })).toBeTruthy();
922
- });
923
- it('should handle isEditable when there is no message content', () => {
924
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", isEditable: true }));
925
- expect(screen.getByRole('textbox')).toBeTruthy();
926
- expect(screen.getByRole('textbox')).toHaveValue('');
927
- expect(screen.getByRole('textbox')).toHaveAttribute('placeholder', 'Edit prompt message...');
928
- expect(screen.getByRole('button', { name: /Update/i })).toBeTruthy();
929
- expect(screen.getByRole('button', { name: /Cancel/i })).toBeTruthy();
930
- });
931
- it('should be able to change edit placeholder', () => {
932
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, editPlaceholder: "I am a placeholder" }));
933
- expect(screen.getByRole('textbox')).toBeTruthy();
934
- expect(screen.getByRole('textbox')).toHaveValue('');
935
- expect(screen.getByRole('textbox')).toHaveAttribute('placeholder', 'I am a placeholder');
936
- });
937
- it('should be able to change updateWord', () => {
938
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, updateWord: "Submit" }));
939
- expect(screen.getByRole('button', { name: /Submit/i })).toBeTruthy();
940
- });
941
- it('should be able to change cancelWord', () => {
942
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, cancelWord: "Don't submit" }));
943
- expect(screen.getByRole('button', { name: /Don't submit/i })).toBeTruthy();
944
- });
945
- it('should be able to add onEditUpdate', () => __awaiter(void 0, void 0, void 0, function* () {
946
- const spy = jest.fn();
947
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, onEditUpdate: spy }));
948
- yield userEvent.click(screen.getByRole('button', { name: /Update/i }));
949
- expect(spy).toHaveBeenCalledTimes(1);
950
- }));
951
- it('should be able to add onEditCancel', () => __awaiter(void 0, void 0, void 0, function* () {
952
- const spy = jest.fn();
953
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, onEditCancel: spy }));
954
- yield userEvent.click(screen.getByRole('button', { name: /Cancel/i }));
955
- expect(spy).toHaveBeenCalledTimes(1);
956
- }));
957
- it('should be able to add editFormProps', () => {
958
- const { container } = render(_jsx(Message, { avatar: "./img", role: "user", name: "User", isEditable: true, editFormProps: { className: 'test' } }));
959
- const form = container.querySelector('form');
960
- expect(form).toHaveClass('test');
961
- });
962
- it('should be able to disable markdown parsing', () => {
963
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE, isMarkdownDisabled: true }));
964
- // this is looking for markdown syntax that is ordinarily stripped
965
- expect(screen.getByText(/~~~yaml/i)).toBeTruthy();
966
- });
967
- it('should be able to pass props to react-markdown, such as disabling tags', () => {
968
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE, reactMarkdownProps: { disallowedElements: ['code'] } }));
969
- expect(screen.getByText('Here is some YAML code:')).toBeTruthy();
970
- // code block isn't rendering
971
- expect(screen.queryByRole('button', { name: 'Copy code' })).toBeFalsy();
972
- });
973
- it('should disable images and additional tags for user messages', () => {
974
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: `${IMAGE} ${CODE_MESSAGE}`, reactMarkdownProps: { disallowedElements: ['code'] } }));
975
- expect(screen.getByText('Here is some YAML code:')).toBeTruthy();
976
- // code block isn't rendering
977
- expect(screen.queryByRole('button', { name: 'Copy code' })).toBeFalsy();
978
- expect(screen.queryByRole('img', { name: /Multi-colored wavy lines on a black background/i })).toBeFalsy();
979
- });
980
- it('can override image tag removal default for user messages', () => {
981
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: IMAGE, hasNoImagesInUserMessages: false }));
982
- expect(screen.getByRole('img', { name: /Multi-colored wavy lines on a black background/i })).toBeTruthy();
983
- });
984
- it('should render deep thinking section correctly', () => {
985
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "", deepThinking: DEEP_THINKING }));
986
- expect(screen.getByRole('button', { name: /Show thinking/i })).toBeTruthy();
987
- expect(screen.getByText('Thought for 3 seconds')).toBeTruthy();
988
- expect(screen.getByText("Here's why I said this.")).toBeTruthy();
989
- });
990
- it('should handle isPrimary correctly for inline code when it is true', () => {
991
- const { container } = render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: INLINE_CODE, isPrimary: true }));
992
- expect(container.querySelector('.pf-m-primary')).toBeTruthy();
993
- });
994
- it('should handle isPrimary correctly for inline code when it is false', () => {
995
- const { container } = render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: INLINE_CODE }));
996
- expect(container.querySelector('.pf-m-primary')).toBeFalsy();
997
- });
998
- it('should handle isPrimary correctly for table when it is true', () => {
999
- const { container } = render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: TABLE, isPrimary: true }));
1000
- expect(container.querySelector('.pf-m-primary')).toBeTruthy();
1001
- });
1002
- it('should handle isPrimary correctly for table when it is false', () => {
1003
- const { container } = render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: TABLE }));
1004
- expect(container.querySelector('.pf-m-primary')).toBeFalsy();
1005
- });
1006
- it('should handle isPrimary correctly for loading when it is true', () => {
1007
- const { container } = render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "", isPrimary: true, isLoading: true }));
1008
- expect(container.querySelector('.pf-m-primary')).toBeTruthy();
1009
- });
1010
- it('should handle isPrimary correctly for loading when it is false', () => {
1011
- const { container } = render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "", isLoading: true }));
1012
- expect(container.querySelector('.pf-m-primary')).toBeFalsy();
1013
- });
1014
- it('should handle isPrimary correctly for attachments when it is true', () => {
1015
- const { container } = render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "", isPrimary: true, attachments: [{ name: 'testAttachment' }] }));
1016
- expect(container.querySelector('.pf-m-outline')).toBeTruthy();
1017
- });
1018
- it('should handle isPrimary correctly for attachments when it is false', () => {
1019
- const { container } = render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "", attachments: [{ name: 'testAttachment' }] }));
1020
- expect(container.querySelector('.pf-m-outline')).toBeFalsy();
1021
- });
1022
- it('Renders without pf-m-end class by default', () => {
1023
- render(_jsx(Message, { avatar: "./img", role: "user", name: "User", content: "" }));
1024
- expect(screen.getByRole('region')).not.toHaveClass('pf-m-end');
1025
- });
1026
- it('Renders with pf-m-end class when alignment="end"', () => {
1027
- render(_jsx(Message, { alignment: "end", avatar: "./img", role: "user", name: "User", content: "" }));
1028
- expect(screen.getByRole('region')).toHaveClass('pf-m-end');
1029
- });
1030
- // We're just testing the positive action here to ensure logic passes through as needed, the other actions are
1031
- // tested in ResponseActions.test.tsx along with other aspects of this functionality
1032
- it('should not swap icons when useFilledIconsOnClick is omitted', () => __awaiter(void 0, void 0, void 0, function* () {
1033
- const user = userEvent.setup();
1034
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", actions: {
1035
- positive: { onClick: jest.fn() }
1036
- } }));
1037
- expect(screen.getByText('RhUiLikeIcon')).toBeInTheDocument();
1038
- yield user.click(screen.getByRole('button', { name: /Good response/i }));
1039
- expect(screen.getByText('RhUiLikeIcon')).toBeInTheDocument();
1040
- expect(screen.queryByText('RhUiLikeFillIcon')).not.toBeInTheDocument();
1041
- }));
1042
- it('should swap icons when useFilledIconsOnClick is true', () => __awaiter(void 0, void 0, void 0, function* () {
1043
- const user = userEvent.setup();
1044
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", actions: {
1045
- positive: { onClick: jest.fn() }
1046
- }, useFilledIconsOnClick: true }));
1047
- yield user.click(screen.getByRole('button', { name: /Good response/i }));
1048
- expect(screen.getByText('RhUiLikeFillIcon')).toBeInTheDocument();
1049
- expect(screen.queryByText('RhUiLikeIcon')).not.toBeInTheDocument();
1050
- }));
1051
- it('should apply pf-m-visible-interaction class to response actions when showActionsOnInteraction is true', () => {
1052
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", showActionsOnInteraction: true, actions: {
1053
- positive: { onClick: jest.fn() }
1054
- } }));
1055
- const responseContainer = screen
1056
- .getByRole('button', { name: 'Good response' })
1057
- .closest('.pf-chatbot__response-actions');
1058
- expect(responseContainer).toHaveClass('pf-m-visible-interaction');
1059
- });
1060
- it('should not apply pf-m-visible-interaction class to response actions when showActionsOnInteraction is false', () => {
1061
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", showActionsOnInteraction: false, actions: {
1062
- positive: { onClick: jest.fn() }
1063
- } }));
1064
- const responseContainer = screen
1065
- .getByRole('button', { name: 'Good response' })
1066
- .closest('.pf-chatbot__response-actions');
1067
- expect(responseContainer).not.toHaveClass('pf-m-visible-interaction');
1068
- });
1069
- it('should not apply pf-m-visible-interaction class to response actions by default', () => {
1070
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", actions: {
1071
- positive: { onClick: jest.fn() }
1072
- } }));
1073
- const responseContainer = screen
1074
- .getByRole('button', { name: 'Good response' })
1075
- .closest('.pf-chatbot__response-actions');
1076
- expect(responseContainer).not.toHaveClass('pf-m-visible-interaction');
1077
- });
1078
- it('should apply pf-m-visible-interaction class to grouped actions container when showActionsOnInteraction is true', () => {
1079
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", showActionsOnInteraction: true, actions: [
1080
- {
1081
- positive: { onClick: jest.fn() },
1082
- negative: { onClick: jest.fn() }
1083
- },
1084
- {
1085
- copy: { onClick: jest.fn() }
1086
- }
1087
- ] }));
1088
- const responseContainer = screen
1089
- .getByRole('button', { name: 'Good response' })
1090
- .closest('.pf-chatbot__response-actions-groups');
1091
- expect(responseContainer).toHaveClass('pf-m-visible-interaction');
1092
- });
1093
- it('should not apply pf-m-visible-interaction class to grouped actions container when showActionsOnInteraction is false', () => {
1094
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", showActionsOnInteraction: false, actions: [
1095
- {
1096
- positive: { onClick: jest.fn() },
1097
- negative: { onClick: jest.fn() }
1098
- },
1099
- {
1100
- copy: { onClick: jest.fn() }
1101
- }
1102
- ] }));
1103
- const responseContainer = screen
1104
- .getByRole('button', { name: 'Good response' })
1105
- .closest('.pf-chatbot__response-actions-groups');
1106
- expect(responseContainer).not.toHaveClass('pf-m-visible-interaction');
1107
- });
1108
- it('should not apply pf-m-visible-interaction class to grouped actions container by default', () => {
1109
- render(_jsx(Message, { avatar: "./img", role: "bot", name: "Bot", content: "Hi", actions: [
1110
- {
1111
- positive: { onClick: jest.fn() },
1112
- negative: { onClick: jest.fn() }
1113
- },
1114
- {
1115
- copy: { onClick: jest.fn() }
1116
- }
1117
- ] }));
1118
- const responseContainer = screen
1119
- .getByRole('button', { name: 'Good response' })
1120
- .closest('.pf-chatbot__response-actions-groups');
1121
- expect(responseContainer).not.toHaveClass('pf-m-visible-interaction');
1122
- });
1123
- });