@chat21/chat21-web-widget 5.1.32-rc9 → 5.1.33-rc11

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 (246) hide show
  1. package/.angular-mcp-cache/package.json +1 -0
  2. package/.cursor/angular18-accessibility-auditor-skill.md +442 -0
  3. package/.cursor/mcp.json +15 -0
  4. package/.github/workflows/playwright.yml +27 -0
  5. package/.playwright-mcp/console-2026-05-08T15-31-09-000Z.log +17 -0
  6. package/.playwright-mcp/console-2026-05-08T15-32-19-412Z.log +89 -0
  7. package/.playwright-mcp/console-2026-05-08T16-18-48-424Z.log +133 -0
  8. package/.playwright-mcp/console-2026-05-11T12-54-06-869Z.log +13 -0
  9. package/.playwright-mcp/console-2026-05-11T12-54-56-229Z.log +147 -0
  10. package/.playwright-mcp/console-2026-05-11T12-55-47-174Z.log +183 -0
  11. package/.playwright-mcp/console-2026-05-11T15-34-03-590Z.log +210 -0
  12. package/.playwright-mcp/console-2026-05-12T15-07-31-880Z.log +118 -0
  13. package/.playwright-mcp/page-2026-05-08T15-32-19-900Z.yml +851 -0
  14. package/.playwright-mcp/page-2026-05-08T15-32-47-264Z.yml +857 -0
  15. package/.playwright-mcp/page-2026-05-08T15-33-17-089Z.yml +1110 -0
  16. package/.playwright-mcp/page-2026-05-08T15-33-23-486Z.yml +1069 -0
  17. package/.playwright-mcp/page-2026-05-08T15-33-45-390Z.yml +1076 -0
  18. package/.playwright-mcp/page-2026-05-08T15-33-52-666Z.yml +1072 -0
  19. package/.playwright-mcp/page-2026-05-08T15-34-01-338Z.yml +1085 -0
  20. package/.playwright-mcp/page-2026-05-08T15-34-07-227Z.yml +1072 -0
  21. package/.playwright-mcp/page-2026-05-08T15-34-13-875Z.yml +1072 -0
  22. package/.playwright-mcp/page-2026-05-08T15-34-21-885Z.yml +1109 -0
  23. package/.playwright-mcp/page-2026-05-08T15-34-32-755Z.yml +1109 -0
  24. package/.playwright-mcp/page-2026-05-08T15-35-09-607Z.yml +1119 -0
  25. package/.playwright-mcp/page-2026-05-08T15-35-14-242Z.yml +1109 -0
  26. package/.playwright-mcp/page-2026-05-08T16-18-48-671Z.yml +44 -0
  27. package/.playwright-mcp/page-2026-05-08T16-18-52-753Z.png +0 -0
  28. package/.playwright-mcp/page-2026-05-08T16-19-13-919Z.yml +68 -0
  29. package/.playwright-mcp/page-2026-05-08T16-19-17-977Z.png +0 -0
  30. package/.playwright-mcp/page-2026-05-08T16-19-25-733Z.yml +120 -0
  31. package/.playwright-mcp/page-2026-05-08T16-19-29-252Z.png +0 -0
  32. package/.playwright-mcp/page-2026-05-08T16-19-39-269Z.yml +80 -0
  33. package/.playwright-mcp/page-2026-05-08T16-19-43-915Z.png +0 -0
  34. package/.playwright-mcp/page-2026-05-08T16-20-04-407Z.yml +81 -0
  35. package/.playwright-mcp/page-2026-05-08T16-20-08-984Z.png +0 -0
  36. package/.playwright-mcp/page-2026-05-08T16-20-32-397Z.png +0 -0
  37. package/.playwright-mcp/page-2026-05-08T16-20-58-658Z.png +0 -0
  38. package/.playwright-mcp/page-2026-05-08T16-21-12-320Z.yml +86 -0
  39. package/.playwright-mcp/page-2026-05-08T16-21-39-154Z.yml +91 -0
  40. package/.playwright-mcp/page-2026-05-08T16-21-45-420Z.png +0 -0
  41. package/.playwright-mcp/page-2026-05-08T16-22-21-062Z.yml +0 -0
  42. package/.playwright-mcp/page-2026-05-08T16-22-58-232Z.yml +91 -0
  43. package/.playwright-mcp/page-2026-05-08T16-23-36-520Z.yml +0 -0
  44. package/.playwright-mcp/page-2026-05-08T16-23-46-805Z.yml +100 -0
  45. package/.playwright-mcp/page-2026-05-08T16-23-55-169Z.png +0 -0
  46. package/.playwright-mcp/page-2026-05-08T16-24-26-574Z.yml +91 -0
  47. package/.playwright-mcp/page-2026-05-08T16-25-34-414Z.png +0 -0
  48. package/.playwright-mcp/page-2026-05-08T16-25-59-831Z.png +0 -0
  49. package/.playwright-mcp/page-2026-05-08T16-26-21-809Z.yml +91 -0
  50. package/.playwright-mcp/page-2026-05-08T16-26-47-443Z.yml +105 -0
  51. package/.playwright-mcp/page-2026-05-08T16-26-56-136Z.png +0 -0
  52. package/.playwright-mcp/page-2026-05-08T16-27-59-610Z.yml +48 -0
  53. package/.playwright-mcp/page-2026-05-11T12-54-07-180Z.yml +44 -0
  54. package/.playwright-mcp/page-2026-05-11T12-54-56-946Z.yml +4 -0
  55. package/.playwright-mcp/page-2026-05-11T12-55-47-503Z.yml +24 -0
  56. package/.playwright-mcp/page-2026-05-11T12-56-00-766Z.yml +28 -0
  57. package/.playwright-mcp/page-2026-05-11T12-56-06-438Z.yml +90 -0
  58. package/.playwright-mcp/page-2026-05-11T12-57-56-838Z.yml +106 -0
  59. package/.playwright-mcp/page-2026-05-11T12-58-00-124Z.yml +106 -0
  60. package/.playwright-mcp/page-2026-05-11T12-59-08-836Z.yml +61 -0
  61. package/.playwright-mcp/page-2026-05-11T12-59-12-088Z.yml +61 -0
  62. package/.playwright-mcp/page-2026-05-11T12-59-26-215Z.yml +69 -0
  63. package/.playwright-mcp/page-2026-05-11T12-59-29-519Z.yml +69 -0
  64. package/.playwright-mcp/page-2026-05-11T12-59-37-309Z.yml +0 -0
  65. package/.playwright-mcp/page-2026-05-11T12-59-39-968Z.yml +79 -0
  66. package/.playwright-mcp/page-2026-05-11T12-59-45-983Z.yml +78 -0
  67. package/.playwright-mcp/page-2026-05-11T12-59-49-951Z.yml +78 -0
  68. package/.playwright-mcp/page-2026-05-11T15-34-04-515Z.yml +0 -0
  69. package/.playwright-mcp/page-2026-05-12T15-07-32-171Z.yml +44 -0
  70. package/.playwright-mcp/page-2026-05-12T15-08-09-820Z.yml +119 -0
  71. package/CHANGELOG.md +61 -4
  72. package/angular.json +20 -3
  73. package/deploy_amazon_beta.sh +7 -17
  74. package/deploy_amazon_prod.sh +41 -0
  75. package/docs/TILEDESK_WIDGET_ACCESSIBILITY_STATEMENT_COMPLETE.md +379 -0
  76. package/env.sample +3 -2
  77. package/mocks/voice-websocket-mock/server.cjs +245 -0
  78. package/package.json +7 -3
  79. package/playwright.config.ts +41 -0
  80. package/src/app/app.component.html +2 -2
  81. package/src/app/app.component.scss +25 -14
  82. package/src/app/app.component.spec.ts +21 -6
  83. package/src/app/app.module.ts +4 -0
  84. package/src/app/component/conversation-detail/conversation/conversation.component.html +19 -11
  85. package/src/app/component/conversation-detail/conversation/conversation.component.scss +28 -0
  86. package/src/app/component/conversation-detail/conversation/conversation.component.spec.ts +644 -75
  87. package/src/app/component/conversation-detail/conversation/conversation.component.ts +63 -17
  88. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.html +25 -13
  89. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.spec.ts +123 -5
  90. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.ts +1 -0
  91. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.html +17 -7
  92. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.scss +15 -3
  93. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.spec.ts +242 -149
  94. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.ts +7 -6
  95. package/src/app/component/conversation-detail/conversation-emojii/conversation-emojii.component.spec.ts +53 -3
  96. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component copy.html +172 -0
  97. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.html +112 -61
  98. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.scss +133 -16
  99. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.spec.ts +452 -78
  100. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts +198 -84
  101. package/src/app/component/conversation-detail/conversation-header/conversation-header.component.html +113 -53
  102. package/src/app/component/conversation-detail/conversation-header/conversation-header.component.scss +12 -4
  103. package/src/app/component/conversation-detail/conversation-header/conversation-header.component.spec.ts +274 -29
  104. package/src/app/component/conversation-detail/conversation-internal-frame/conversation-internal-frame.component.html +23 -9
  105. package/src/app/component/conversation-detail/conversation-internal-frame/conversation-internal-frame.component.spec.ts +80 -8
  106. package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.html +29 -23
  107. package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.spec.ts +185 -16
  108. package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.ts +34 -14
  109. package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.html +46 -18
  110. package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.scss +60 -2
  111. package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.ts +135 -5
  112. package/src/app/component/error-alert/error-alert.component.spec.ts +65 -5
  113. package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.html +16 -7
  114. package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.scss +21 -0
  115. package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.spec.ts +89 -7
  116. package/src/app/component/form/form-builder/form-builder.component.html +1 -1
  117. package/src/app/component/form/form-builder/form-builder.component.spec.ts +163 -21
  118. package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.html +8 -4
  119. package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.scss +10 -5
  120. package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.spec.ts +90 -16
  121. package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.ts +26 -0
  122. package/src/app/component/form/inputs/form-label/form-label.component.spec.ts +45 -11
  123. package/src/app/component/form/inputs/form-radio-button/form-radio-button.component.spec.ts +24 -6
  124. package/src/app/component/form/inputs/form-select/form-select.component.spec.ts +14 -5
  125. package/src/app/component/form/inputs/form-text/form-text.component.html +14 -12
  126. package/src/app/component/form/inputs/form-text/form-text.component.scss +11 -1
  127. package/src/app/component/form/inputs/form-text/form-text.component.spec.ts +113 -17
  128. package/src/app/component/form/inputs/form-text/form-text.component.ts +35 -3
  129. package/src/app/component/form/inputs/form-textarea/form-textarea.component.html +13 -11
  130. package/src/app/component/form/inputs/form-textarea/form-textarea.component.scss +6 -5
  131. package/src/app/component/form/inputs/form-textarea/form-textarea.component.spec.ts +149 -13
  132. package/src/app/component/form/inputs/form-textarea/form-textarea.component.ts +26 -0
  133. package/src/app/component/form/prechat-form/prechat-form.component.html +14 -11
  134. package/src/app/component/form/prechat-form/prechat-form.component.spec.ts +102 -10
  135. package/src/app/component/form/prechat-form/prechat-form.component.ts +8 -1
  136. package/src/app/component/form/prechat-form-test-mock.ts +35 -0
  137. package/src/app/component/home/home.component.html +38 -31
  138. package/src/app/component/home/home.component.scss +4 -2
  139. package/src/app/component/home/home.component.spec.ts +226 -11
  140. package/src/app/component/home-conversations/home-conversations.component.html +30 -26
  141. package/src/app/component/home-conversations/home-conversations.component.scss +3 -0
  142. package/src/app/component/home-conversations/home-conversations.component.spec.ts +212 -36
  143. package/src/app/component/last-message/last-message.component.html +15 -9
  144. package/src/app/component/last-message/last-message.component.scss +16 -2
  145. package/src/app/component/last-message/last-message.component.spec.ts +204 -23
  146. package/src/app/component/launcher-button/launcher-button.component.html +8 -13
  147. package/src/app/component/launcher-button/launcher-button.component.spec.ts +104 -8
  148. package/src/app/component/list-all-conversations/list-all-conversations.component.html +12 -17
  149. package/src/app/component/list-all-conversations/list-all-conversations.component.scss +2 -0
  150. package/src/app/component/list-conversations/list-conversations.component.html +22 -22
  151. package/src/app/component/menu-options/menu-options.component.html +30 -20
  152. package/src/app/component/menu-options/menu-options.component.spec.ts +125 -9
  153. package/src/app/component/message/audio/audio.component.html +13 -15
  154. package/src/app/component/message/audio/audio.component.spec.ts +140 -5
  155. package/src/app/component/message/audio/audio.component.ts +1 -0
  156. package/src/app/component/message/audio-sync/audio-sync.component.scss +1 -0
  157. package/src/app/component/message/audio-sync/audio-sync.component.spec.ts +81 -1
  158. package/src/app/component/message/audio-sync/audio-sync.component.ts +133 -86
  159. package/src/app/component/message/avatar/avatar.component.html +2 -2
  160. package/src/app/component/message/avatar/avatar.component.spec.ts +99 -7
  161. package/src/app/component/message/bubble-message/bubble-message.component.html +39 -52
  162. package/src/app/component/message/bubble-message/bubble-message.component.scss +59 -1
  163. package/src/app/component/message/bubble-message/bubble-message.component.spec.ts +154 -57
  164. package/src/app/component/message/bubble-message/bubble-message.component.ts +152 -110
  165. package/src/app/component/message/buttons/action-button/action-button.component.html +3 -4
  166. package/src/app/component/message/buttons/action-button/action-button.component.spec.ts +49 -5
  167. package/src/app/component/message/buttons/link-button/link-button.component.scss +5 -8
  168. package/src/app/component/message/buttons/link-button/link-button.component.spec.ts +50 -5
  169. package/src/app/component/message/buttons/text-button/text-button.component.spec.ts +44 -5
  170. package/src/app/component/message/carousel/carousel.component.html +29 -16
  171. package/src/app/component/message/carousel/carousel.component.scss +20 -8
  172. package/src/app/component/message/carousel/carousel.component.spec.ts +80 -3
  173. package/src/app/component/message/carousel/carousel.component.ts +16 -0
  174. package/src/app/component/message/frame/frame.component.html +9 -4
  175. package/src/app/component/message/frame/frame.component.spec.ts +34 -15
  176. package/src/app/component/message/frame/frame.component.ts +7 -2
  177. package/src/app/component/message/html/html.component.html +1 -1
  178. package/src/app/component/message/html/html.component.scss +1 -1
  179. package/src/app/component/message/html/html.component.spec.ts +24 -7
  180. package/src/app/component/message/image/image.component.html +12 -10
  181. package/src/app/component/message/image/image.component.scss +16 -0
  182. package/src/app/component/message/image/image.component.spec.ts +101 -15
  183. package/src/app/component/message/image/image.component.ts +90 -51
  184. package/src/app/component/message/info-message/info-message.component.spec.ts +26 -14
  185. package/src/app/component/message/json-sources/json-sources.component.html +38 -0
  186. package/src/app/component/message/json-sources/json-sources.component.scss +201 -0
  187. package/src/app/component/message/json-sources/json-sources.component.ts +89 -0
  188. package/src/app/component/message/like-unlike/like-unlike.component.html +7 -9
  189. package/src/app/component/message/like-unlike/like-unlike.component.spec.ts +31 -3
  190. package/src/app/component/message/return-receipt/return-receipt.component.spec.ts +38 -17
  191. package/src/app/component/message/text/text.component.html +3 -3
  192. package/src/app/component/message/text/text.component.scss +80 -86
  193. package/src/app/component/message/text/text.component.spec.ts +106 -13
  194. package/src/app/component/message-attachment/message-attachment.component.spec.ts +134 -13
  195. package/src/app/component/selection-department/selection-department.component.html +21 -23
  196. package/src/app/component/selection-department/selection-department.component.spec.ts +159 -14
  197. package/src/app/component/selection-department/selection-department.component.ts +8 -1
  198. package/src/app/component/send-button/send-button.component.html +5 -13
  199. package/src/app/component/send-button/send-button.component.spec.ts +2 -2
  200. package/src/app/component/star-rating-widget/star-rating-widget.component.html +51 -81
  201. package/src/app/directives/tooltip.directive.spec.ts +8 -4
  202. package/src/app/modals/confirm-close/confirm-close.component.html +20 -8
  203. package/src/app/modals/confirm-close/confirm-close.component.scss +3 -0
  204. package/src/app/modals/confirm-close/confirm-close.component.spec.ts +13 -4
  205. package/src/app/modals/confirm-close/confirm-close.component.ts +8 -1
  206. package/src/app/pipe/html-entites-encode.pipe.spec.ts +35 -2
  207. package/src/app/pipe/marked.pipe.spec.ts +38 -2
  208. package/src/app/pipe/marked.pipe.ts +51 -41
  209. package/src/app/providers/app-config.service.ts +4 -2
  210. package/src/app/providers/brand.service.spec.ts +23 -2
  211. package/src/app/providers/brand.service.ts +1 -1
  212. package/src/app/providers/global-settings.service.spec.ts +1009 -14
  213. package/src/app/providers/global-settings.service.ts +59 -2
  214. package/src/app/providers/json-sources-parser.service.ts +175 -0
  215. package/src/app/providers/translator.service.ts +24 -6
  216. package/src/app/providers/tts-audio-playback-coordinator.service.spec.ts +117 -0
  217. package/src/app/providers/tts-audio-playback-coordinator.service.ts +39 -16
  218. package/src/app/providers/url-preview.service.ts +82 -0
  219. package/src/app/providers/voice/audio.types.ts +6 -0
  220. package/src/app/providers/voice/voice-streaming.service.spec.ts +23 -0
  221. package/src/app/providers/voice/voice-streaming.service.ts +702 -0
  222. package/src/app/providers/voice/voice-streaming.types.ts +112 -0
  223. package/src/app/providers/voice/voice.service.spec.ts +170 -3
  224. package/src/app/providers/voice/voice.service.ts +691 -17
  225. package/src/app/sass/_variables.scss +1 -1
  226. package/src/app/sass/animations.scss +19 -1
  227. package/src/app/utils/globals.ts +14 -0
  228. package/src/app/utils/json-sources-utils.ts +27 -0
  229. package/src/app/utils/url-utils.ts +98 -0
  230. package/src/app/utils/utils-resources.ts +1 -1
  231. package/src/assets/i18n/en.json +106 -100
  232. package/src/assets/i18n/es.json +107 -101
  233. package/src/assets/i18n/fr.json +107 -101
  234. package/src/assets/i18n/it.json +107 -99
  235. package/src/assets/sounds/keyboard.mp3 +0 -0
  236. package/src/assets/twp/index-dev.html +18 -0
  237. package/src/assets/twp/tiledesk_widget_files/widget-css-override-example.css +14 -0
  238. package/src/chat21-core/providers/chat-manager.spec.ts +72 -0
  239. package/src/chat21-core/providers/scripts/script.service.spec.ts +12 -2
  240. package/src/chat21-core/utils/constants.ts +4 -0
  241. package/src/chat21-core/utils/utils-message.ts +23 -1
  242. package/src/widget-config-template.json +3 -1
  243. package/src/widget-config.json +28 -27
  244. package/tests/widget-form-rich.spec.ts +67 -0
  245. package/tests/widget-index-dev-settings.spec.ts +52 -0
  246. package/tests/widget-twp-iframe.spec.ts +39 -0
@@ -1,94 +1,663 @@
1
- import { TiledeskRequestsService } from './../../../../chat21-core/providers/tiledesk/tiledesk-requests.service';
2
- import { StarRatingWidgetService } from './../../../providers/star-rating-widget.service';
3
- import { StarRatingWidgetComponent } from './../../star-rating-widget/star-rating-widget.component';
1
+ import { SimpleChange } from '@angular/core';
2
+ import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
4
3
  import { provideHttpClientTesting } from '@angular/common/http/testing';
5
-
6
- import { Triggerhandler } from './../../../../chat21-core/utils/triggerHandler';
7
- import { AppComponent } from './../../../app.component';
8
- import { AppConfigService } from './../../../providers/app-config.service';
9
-
10
- import { Globals } from './../../../utils/globals';
11
- import { NO_ERRORS_SCHEMA, ElementRef } from '@angular/core';
12
- import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
4
+ import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
5
+ import { Subject, BehaviorSubject } from 'rxjs';
13
6
 
14
7
  import { ConversationComponent } from './conversation.component';
15
- import { GlobalSettingsService } from '../../../providers/global-settings.service';
16
- import { TranslatorService } from '../../../providers/translator.service';
17
-
18
- import { AppStorageService } from '../../../../chat21-core/providers/abstract/app-storage.service';
19
-
20
- import { CustomTranslateService } from '../../../../chat21-core/providers/custom-translate.service';
21
- import { MessagingAuthService } from '../../../../chat21-core/providers/abstract/messagingAuth.service';
22
- import { TiledeskAuthService } from '../../../../chat21-core/providers/tiledesk/tiledesk-auth.service';
23
- import { PresenceService } from '../../../../chat21-core/providers/abstract/presence.service';
24
- import { ConversationsHandlerService } from '../../../../chat21-core/providers/abstract/conversations-handler.service';
25
- import { ArchivedConversationsHandlerService } from '../../../../chat21-core/providers/abstract/archivedconversations-handler.service';
26
- import { ConversationHandlerBuilderService } from '../../../../chat21-core/providers/abstract/conversation-handler-builder.service';
27
- import { ChatManager } from '../../../../chat21-core/providers/chat-manager';
28
- import { TypingService } from '../../../../chat21-core/providers/abstract/typing.service';
29
- import { ImageRepoService } from '../../../../chat21-core/providers/abstract/image-repo.service';
30
- import { UploadService } from '../../../../chat21-core/providers/abstract/upload.service';
31
- import { TranslateModule } from '@ngx-translate/core';
32
- import { NGXLogger } from 'ngx-logger';
33
- import { CustomLogger } from 'src/chat21-core/providers/logger/customLogger';
8
+ import { Globals } from '../../../utils/globals';
9
+ import { AppConfigService } from '../../../providers/app-config.service';
10
+ import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
11
+ import { StarRatingWidgetService } from '../../../providers/star-rating-widget.service';
12
+ import { ConversationHandlerBuilderService } from 'src/chat21-core/providers/abstract/conversation-handler-builder.service';
13
+ import { ChatManager } from 'src/chat21-core/providers/chat-manager';
14
+ import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service';
15
+ import { TypingService } from 'src/chat21-core/providers/abstract/typing.service';
16
+ import { TiledeskRequestsService } from 'src/chat21-core/providers/tiledesk/tiledesk-requests.service';
17
+ import { EventsService } from '../../../providers/events.service';
18
+ import { MessageModel } from 'src/chat21-core/models/message';
19
+ import { HEADER_MENU_OPTION } from 'src/app/utils/constants';
34
20
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
35
- import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
36
-
21
+ import { CustomLogger } from 'src/chat21-core/providers/logger/customLogger';
37
22
  describe('ConversationComponent', () => {
38
23
  let component: ConversationComponent;
39
24
  let fixture: ComponentFixture<ConversationComponent>;
40
- let ngxlogger: NGXLogger;
41
- let customLogger = new CustomLogger(ngxlogger)
42
- class MockElementRef {}
43
-
44
- beforeEach(waitForAsync(() => {
45
- TestBed.configureTestingModule({
46
- declarations: [ConversationComponent],
47
- schemas: [NO_ERRORS_SCHEMA],
48
- imports: [TranslateModule.forRoot()],
49
- providers: [
25
+ let globals: Globals;
26
+
27
+ const ngxlogger = jasmine.createSpyObj('NGXLogger', ['log', 'trace', 'debug', 'warn', 'error', 'info']);
28
+ const customLogger = new CustomLogger(ngxlogger);
29
+
30
+ let conversationHandlerMock: {
31
+ messageAdded: Subject<MessageModel>;
32
+ messageWait: Subject<any>;
33
+ messageInfo: Subject<any>;
34
+ messages: MessageModel[];
35
+ connect: jasmine.Spy;
36
+ initialize: jasmine.Spy;
37
+ sendMessage: jasmine.Spy;
38
+ };
39
+
40
+ const setupHandler = () => {
41
+ conversationHandlerMock = {
42
+ messageAdded: new Subject(),
43
+ messageWait: new Subject(),
44
+ messageInfo: new Subject(),
45
+ messages: [],
46
+ connect: jasmine.createSpy('connect'),
47
+ initialize: jasmine.createSpy('initialize').and.returnValue(Promise.resolve()),
48
+ sendMessage: jasmine.createSpy('sendMessage').and.returnValue({ uid: 'm1', sender: 'me' }),
49
+ };
50
+ return conversationHandlerMock;
51
+ };
52
+
53
+ let chatManagerStub: any;
54
+ let tiledeskStub: any;
55
+ let starRatingStub: any;
56
+ let builderStub: { build: jasmine.Spy };
57
+
58
+ beforeEach(async () => {
59
+ LoggerInstance.setInstance(customLogger);
60
+ setupHandler();
61
+
62
+ const convHandlerSvc = {
63
+ getConversationDetail: jasmine.createSpy('getConversationDetail').and.callFake((id: string, cb: (c: any) => void) => {
64
+ cb(null);
65
+ }),
66
+ conversationRemoved: new Subject<any>(),
67
+ conversationChanged: new Subject<any>(),
68
+ setConversationRead: jasmine.createSpy('setConversationRead'),
69
+ countIsNew: jasmine.createSpy('countIsNew').and.returnValue(0),
70
+ };
71
+
72
+ const archivedSvc = {
73
+ getConversationDetail: jasmine.createSpy('archGet').and.callFake((id: string, cb: (c: any) => void) => {
74
+ cb(null);
75
+ }),
76
+ setConversationRead: jasmine.createSpy('setConversationReadArchived'),
77
+ };
78
+
79
+ chatManagerStub = {
80
+ getConversationHandlerByConversationId: jasmine.createSpy('getH').and.returnValue(null),
81
+ addConversationHandler: jasmine.createSpy('addH'),
82
+ conversationsHandlerService: convHandlerSvc,
83
+ archivedConversationsService: archivedSvc,
84
+ };
85
+
86
+ tiledeskStub = {
87
+ getMyRequests: jasmine.createSpy('getMyRequests').and.resolveTo({ requests: [] }),
88
+ closeSupportGroup: jasmine.createSpy('closeSupportGroup').and.resolveTo('closed'),
89
+ };
90
+
91
+ starRatingStub = {
92
+ obsCloseConversation: new BehaviorSubject<boolean | null>(false),
93
+ setOsservable: jasmine.createSpy('setOsservable'),
94
+ };
95
+
96
+ const customTranslateStub = {
97
+ translateLanguage: jasmine.createSpy('translateLanguage').and.callFake((keys: string[]) => {
98
+ const m = new Map<string, string>();
99
+ keys.forEach((k) => m.set(k, k));
100
+ return m;
101
+ }),
102
+ };
103
+
104
+ builderStub = {
105
+ build: jasmine.createSpy('build').and.returnValue(conversationHandlerMock),
106
+ };
107
+
108
+ spyOn(ConversationComponent.prototype, 'ngAfterViewInit').and.stub();
109
+ spyOn(ConversationComponent.prototype, 'ngAfterViewChecked').and.stub();
110
+ spyOn(ConversationComponent.prototype, 'ngOnDestroy').and.stub();
111
+
112
+ await TestBed.configureTestingModule({
113
+ declarations: [ConversationComponent],
114
+ providers: [
50
115
  Globals,
51
- AppConfigService,
52
- AppComponent,
53
- { provide: ElementRef, useClass: MockElementRef },
54
- GlobalSettingsService,
55
- Triggerhandler,
56
- TranslatorService,
57
- AppConfigService,
58
- AppStorageService,
59
- CustomTranslateService,
60
- MessagingAuthService,
61
- TiledeskAuthService,
62
- PresenceService,
63
- ConversationsHandlerService,
64
- ArchivedConversationsHandlerService,
65
- ConversationHandlerBuilderService,
66
- ChatManager,
67
- TypingService,
68
- ImageRepoService,
69
- UploadService,
70
- StarRatingWidgetService,
71
- TiledeskRequestsService,
72
- NGXLogger,
116
+ { provide: AppConfigService, useValue: { getConfig: () => ({ apiUrl: 'https://api.test/' }) } },
117
+ { provide: StarRatingWidgetService, useValue: starRatingStub },
118
+ { provide: AppStorageService, useValue: { getItem: jasmine.createSpy().and.returnValue(null), setItem: jasmine.createSpy(), removeItem: jasmine.createSpy() } },
119
+ { provide: ConversationHandlerBuilderService, useValue: builderStub },
120
+ { provide: ChatManager, useValue: chatManagerStub },
121
+ { provide: CustomTranslateService, useValue: customTranslateStub },
122
+ { provide: TypingService, useValue: { isTyping: jasmine.createSpy(), BSIsTyping: new Subject() } },
123
+ { provide: TiledeskRequestsService, useValue: tiledeskStub },
124
+ EventsService,
73
125
  provideHttpClient(withInterceptorsFromDi()),
74
- provideHttpClientTesting()
75
- ]
76
- })
77
- .compileComponents();
78
- }));
126
+ provideHttpClientTesting(),
127
+ ],
128
+ })
129
+ .overrideComponent(ConversationComponent, {
130
+ set: { template: '' },
131
+ })
132
+ .compileComponents();
79
133
 
80
- beforeEach(() => {
81
134
  fixture = TestBed.createComponent(ConversationComponent);
82
135
  component = fixture.componentInstance;
83
- LoggerInstance.setInstance(customLogger)
84
- let logger = LoggerInstance.getInstance()
85
- component['logger']= logger
86
- let globals = fixture.debugElement.injector.get(Globals) as Globals;
87
- globals.initDefafultParameters()
136
+
137
+ globals = TestBed.inject(Globals);
138
+ globals.initDefafultParameters();
139
+ globals.setParameter('recipientId', 'support-group-proj-abc');
140
+ globals.setParameter('projectid', 'proj1');
141
+ globals.setParameter('channelType', 'group');
142
+ globals.senderId = 'visitor-1';
143
+ (globals as any).attributes = (globals as any).attributes ?? {};
144
+
145
+ component.conversationId = 'support-group-proj-abc';
146
+ component.conversationWith = 'support-group-proj-abc';
147
+ component.senderId = 'visitor-1';
148
+ component.isOpen = true;
149
+ component.stylesMap = new Map([
150
+ ['themeColor', '#2a6ac1'],
151
+ ['foregroundColor', '#fff'],
152
+ ]);
153
+
154
+ /** ViewChild refs stay undefined with empty template; assign after first CD cycle. */
88
155
  fixture.detectChanges();
156
+ component.conversationFooter = {
157
+ sendMessage: jasmine.createSpy('sendMessage'),
158
+ textInputTextArea: '',
159
+ uploadSingle: jasmine.createSpy('uploadSingle'),
160
+ isFilePendingToUpload: false,
161
+ removeFocusOnId: jasmine.createSpy('removeFocusOnId'),
162
+ } as any;
163
+
164
+ component.conversationContent = {
165
+ scrollToBottom: jasmine.createSpy('scrollToBottom'),
166
+ checkContentScrollPosition: jasmine.createSpy('checkContentScrollPosition').and.returnValue(true),
167
+ scrollMe: { nativeElement: { style: { height: '' } } },
168
+ } as any;
169
+
170
+ component.mydialog = {
171
+ nativeElement: { showModal: jasmine.createSpy('showModal'), close: jasmine.createSpy('close') },
172
+ } as any;
173
+
174
+ component.conversationsHandlerService = chatManagerStub.conversationsHandlerService as any;
175
+ component.archivedConversationsHandlerService = chatManagerStub.archivedConversationsService as any;
89
176
  });
90
177
 
91
178
  it('should create', () => {
92
179
  expect(component).toBeTruthy();
93
180
  });
181
+
182
+ describe('ngOnInit', () => {
183
+ it('should initialise translations and default welcome flag', () => {
184
+ expect(component.showMessageWelcome).toBe(false);
185
+ expect(component.translationMapHeader).toBeDefined();
186
+ expect(component.translationMapFooter).toBeDefined();
187
+ });
188
+ });
189
+
190
+ describe('scrollToBottom and translations', () => {
191
+ it('scrollToBottom should delegate to conversation content', () => {
192
+ component.scrollToBottom();
193
+ expect(component.conversationContent.scrollToBottom).toHaveBeenCalled();
194
+ });
195
+
196
+ it('translations should refresh all translation maps', () => {
197
+ component.translations();
198
+ expect(component.translationMapPreview?.size).toBeGreaterThan(0);
199
+ expect(component.translationMapCloseChatDialog?.size).toBeGreaterThan(0);
200
+ });
201
+ });
202
+
203
+ describe('updateConversationBadge archived branch', () => {
204
+ it('should call archived handler when conversation is archived', () => {
205
+ component.isConversationArchived = true;
206
+ component.conversationId = 'arch-1';
207
+ component.archivedConversationsHandlerService = chatManagerStub.archivedConversationsService as any;
208
+ component.updateConversationBadge();
209
+ expect(chatManagerStub.archivedConversationsService.setConversationRead).toHaveBeenCalledWith('arch-1');
210
+ });
211
+ });
212
+
213
+ describe('drag / drop edge paths', () => {
214
+ it('drag should return early when dropped file type is not allowed (hover unchanged)', () => {
215
+ (globals as any).fileUploadAccept = 'application/pdf';
216
+ component.isHovering = true;
217
+ const dt = new DataTransfer();
218
+ dt.items.add(new File(['x'], 'a.png', { type: 'image/png' }));
219
+ const ev: any = {
220
+ preventDefault: jasmine.createSpy(),
221
+ stopPropagation: jasmine.createSpy(),
222
+ dataTransfer: { files: dt.files },
223
+ };
224
+ component.drag(ev);
225
+ expect(component.isHovering).toBe(true);
226
+ });
227
+
228
+ it('drag should clear hovering when there is no file payload', () => {
229
+ component.isHovering = true;
230
+ const ev: any = {
231
+ preventDefault: jasmine.createSpy(),
232
+ stopPropagation: jasmine.createSpy(),
233
+ dataTransfer: null,
234
+ };
235
+ component.drag(ev);
236
+ expect(component.isHovering).toBe(false);
237
+ });
238
+ });
239
+
240
+ describe('onResize', () => {
241
+ it('should log resize', () => {
242
+ component.onResize(new Event('resize'));
243
+ expect(component).toBeTruthy();
244
+ });
245
+ });
246
+
247
+ describe('ngOnChanges', () => {
248
+ it('should apply CSS variables from stylesMap', () => {
249
+ const el = fixture.nativeElement as HTMLElement;
250
+ spyOn(el.style, 'setProperty');
251
+ (component as any).elementRef = { nativeElement: el };
252
+ component.ngOnChanges({ stylesMap: new SimpleChange(null, component.stylesMap, false) });
253
+ expect(el.style.setProperty).toHaveBeenCalled();
254
+ });
255
+ });
256
+
257
+ describe('updateConversationBadge', () => {
258
+ it('should mark conversation read when active list', () => {
259
+ component.isConversationArchived = false;
260
+ component.conversationId = 'c1';
261
+ component.conversationsHandlerService = chatManagerStub.conversationsHandlerService;
262
+ component.updateConversationBadge();
263
+ expect(chatManagerStub.conversationsHandlerService.setConversationRead).toHaveBeenCalledWith('c1');
264
+ });
265
+ });
266
+
267
+ describe('getConversationDetail', () => {
268
+ it('should resolve active conversation', fakeAsync(() => {
269
+ chatManagerStub.conversationsHandlerService.getConversationDetail.and.callFake((id: string, cb: any) => cb({ uid: 'x' }));
270
+ let result: boolean | null = null;
271
+ component.getConversationDetail().then((r) => (result = r));
272
+ tick();
273
+ expect(result).toBe(false);
274
+ expect(component.conversation).toEqual({ uid: 'x' } as any);
275
+ }));
276
+
277
+ it('should fall back to archived when active missing', fakeAsync(() => {
278
+ chatManagerStub.conversationsHandlerService.getConversationDetail.and.callFake((id: string, cb: any) => cb(null));
279
+ chatManagerStub.archivedConversationsService.getConversationDetail.and.callFake((id: string, cb: any) =>
280
+ cb({ uid: 'arch' }),
281
+ );
282
+ let result: boolean | null = null;
283
+ component.getConversationDetail().then((r) => (result = r));
284
+ tick();
285
+ expect(result).toBe(true);
286
+ }));
287
+
288
+ it('should recover when getMyRequests rejects (component catch returns empty list)', async () => {
289
+ chatManagerStub.conversationsHandlerService.getConversationDetail.and.callFake((id: string, cb: any) => cb(null));
290
+ chatManagerStub.archivedConversationsService.getConversationDetail.and.callFake((id: string, cb: any) => cb(null));
291
+ tiledeskStub.getMyRequests.and.returnValue(Promise.reject(new Error('network')));
292
+ await component.getConversationDetail();
293
+ expect(component.isConversationArchived).toBe(true);
294
+ });
295
+
296
+ it('should match request by request_id', fakeAsync(() => {
297
+ chatManagerStub.conversationsHandlerService.getConversationDetail.and.callFake((id: string, cb: any) => cb(null));
298
+ chatManagerStub.archivedConversationsService.getConversationDetail.and.callFake((id: string, cb: any) => cb(null));
299
+ tiledeskStub.getMyRequests.and.resolveTo({
300
+ requests: [{ request_id: component.conversationId }],
301
+ });
302
+ let result: boolean | null = null;
303
+ component.getConversationDetail().then((r) => (result = r));
304
+ tick();
305
+ expect(result).toBe(false);
306
+ }));
307
+ });
308
+
309
+ describe('emitter handlers', () => {
310
+ it('onBackHomeFN emits', () => {
311
+ spyOn(component.onBackHome, 'emit');
312
+ component.onBackHomeFN();
313
+ expect(component.onBackHome.emit).toHaveBeenCalled();
314
+ });
315
+
316
+ it('onSoundChangeFN emits', () => {
317
+ spyOn(component.onSoundChange, 'emit');
318
+ component.onSoundChangeFN(true);
319
+ expect(component.onSoundChange.emit).toHaveBeenCalledWith(true);
320
+ });
321
+
322
+ it('onMenuOptionClick LOGOUT emits signOut', () => {
323
+ spyOn(component.onSignOut, 'emit');
324
+ component.onMenuOptionClick(HEADER_MENU_OPTION.LOGOUT);
325
+ expect(component.onSignOut.emit).toHaveBeenCalledWith(true);
326
+ });
327
+
328
+ it('onMenuOptionClick VOLUME emits sound', () => {
329
+ spyOn(component.onSoundChange, 'emit');
330
+ component.onMenuOptionClick(HEADER_MENU_OPTION.VOLUME_ON);
331
+ component.onMenuOptionClick(HEADER_MENU_OPTION.VOLUME_OFF);
332
+ expect(component.onSoundChange.emit).toHaveBeenCalledWith(true);
333
+ expect(component.onSoundChange.emit).toHaveBeenCalledWith(false);
334
+ });
335
+
336
+ it('onMenuOptionClick CLOSE opens dialog', () => {
337
+ component.conversation = { uid: 'c1' } as any;
338
+ component.onMenuOptionClick(HEADER_MENU_OPTION.CLOSE);
339
+ expect(component.mydialog.nativeElement.showModal).toHaveBeenCalled();
340
+ });
341
+
342
+ it('onMenuOptionClick RESTART sends /start', () => {
343
+ component.onMenuOptionClick(HEADER_MENU_OPTION.RESTART);
344
+ expect(component.conversationFooter.sendMessage).toHaveBeenCalled();
345
+ });
346
+ });
347
+
348
+ describe('onCloseDialog', () => {
349
+ it('back closes modal', () => {
350
+ component.onCloseDialog({ type: 'back', data: null });
351
+ expect(component.mydialog.nativeElement.close).toHaveBeenCalled();
352
+ });
353
+
354
+ it('confirm resolves closeSupportGroup success', fakeAsync(() => {
355
+ component.conversationId = 'cid';
356
+ component.onCloseDialog({ type: 'confirm', data: null });
357
+ tick();
358
+ expect(tiledeskStub.closeSupportGroup).toHaveBeenCalledWith('cid');
359
+ expect(component.mydialog.nativeElement.close).toHaveBeenCalled();
360
+ }));
361
+
362
+ it('confirm logs on close failure', fakeAsync(() => {
363
+ tiledeskStub.closeSupportGroup.and.returnValue(Promise.reject('e'));
364
+ component.onCloseDialog({ type: 'confirm', data: null });
365
+ tick();
366
+ expect(component).toBeTruthy();
367
+ }));
368
+ });
369
+
370
+ describe('newMessageAdded', () => {
371
+ it('should scroll for own messages', fakeAsync(() => {
372
+ const msg = { sender: 'visitor-1', timestamp: Date.now() } as MessageModel;
373
+ component.senderId = 'visitor-1';
374
+ component.newMessageAdded(msg);
375
+ tick(250);
376
+ expect(component.conversationContent.scrollToBottom).toHaveBeenCalled();
377
+ }));
378
+
379
+ it('should increment badge when scrolled up', () => {
380
+ component.senderId = 'visitor-1';
381
+ component.conversationContent = {
382
+ ...component.conversationContent,
383
+ checkContentScrollPosition: jasmine.createSpy('chk').and.returnValue(false),
384
+ } as any;
385
+ const msg = { sender: 'agent', attributes: {}, timestamp: Date.now() } as MessageModel;
386
+ const before = component.messagesBadgeCount;
387
+ component.newMessageAdded(msg);
388
+ expect(component.messagesBadgeCount).toBe(before + 1);
389
+ });
390
+ });
391
+
392
+ describe('onScrollContent', () => {
393
+ it('should reset badge when reaching bottom', () => {
394
+ component.messagesBadgeCount = 3;
395
+ component.onScrollContent(true);
396
+ expect(component.messagesBadgeCount).toBe(0);
397
+ });
398
+ });
399
+
400
+ describe('onAfterSendMessageFN', () => {
401
+ it('should set thinking for own messages', () => {
402
+ spyOn(component.onAfterSendMessage, 'emit');
403
+ const msg = { sender: 'visitor-1' } as MessageModel;
404
+ component.senderId = 'visitor-1';
405
+ component.onAfterSendMessageFN(msg);
406
+ expect(component.showThinkingMessage).toBe(true);
407
+ });
408
+ });
409
+
410
+ describe('drop / allowDrop / drag', () => {
411
+ it('allowDrop sets hovering', () => {
412
+ const ev = { preventDefault: jasmine.createSpy(), stopPropagation: jasmine.createSpy() } as any;
413
+ component.allowDrop(ev);
414
+ expect(component.isHovering).toBe(true);
415
+ });
416
+
417
+ it('drop stores dropEvent when files present', () => {
418
+ const file = new File(['b'], 'b.txt');
419
+ const dt = new DataTransfer();
420
+ dt.items.add(file);
421
+ const ev: any = {
422
+ preventDefault: jasmine.createSpy(),
423
+ stopPropagation: jasmine.createSpy(),
424
+ dataTransfer: { files: dt.files },
425
+ };
426
+ component.drop(ev);
427
+ expect(component.dropEvent).toBe(ev);
428
+ });
429
+ });
430
+
431
+ describe('unsubscribe()', () => {
432
+ it('clears subscription entries', () => {
433
+ component.conversationHandlerService = conversationHandlerMock as any;
434
+ (component as any).typingService = TestBed.inject(TypingService);
435
+ component.subscriptions = [];
436
+ component.unsubscribe();
437
+ expect(component.subscriptions.length).toBe(0);
438
+ });
439
+ });
440
+
441
+ describe('lead / user info updates (visitor profile)', () => {
442
+ it('updateLeadInfo should persist fullname/email to Globals and storage', () => {
443
+ const storage = TestBed.inject(AppStorageService);
444
+ const msg = {
445
+ attributes: { updateUserFullname: 'Jane', updateUserEmail: 'jane@example.com' },
446
+ } as MessageModel;
447
+ component.updateLeadInfo(msg);
448
+ expect((globals as any).userFullname).toContain('Jane');
449
+ expect(storage.setItem).toHaveBeenCalled();
450
+ });
451
+
452
+ it('updateUserInfo should copy customAttributes onto Globals', () => {
453
+ component.updateUserInfo({ userFullname: 'Bob', userEmail: 'bob@example.com' });
454
+ expect((globals as any).userFullname).toBe('Bob');
455
+ });
456
+ });
457
+
458
+ describe('onAttachmentButtonClicked', () => {
459
+ beforeEach(() => {
460
+ component.conversationFooter = {
461
+ sendMessage: jasmine.createSpy('sendMessage'),
462
+ } as any;
463
+ });
464
+
465
+ it('should return early when payload is incomplete', () => {
466
+ component.onAttachmentButtonClicked(null);
467
+ expect(component.conversationFooter.sendMessage).not.toHaveBeenCalled();
468
+ });
469
+
470
+ it('should send text button value', () => {
471
+ component.onAttachmentButtonClicked({
472
+ target: { type: 'text', button: { value: 'OK' } },
473
+ });
474
+ expect(component.conversationFooter.sendMessage).toHaveBeenCalled();
475
+ });
476
+ });
477
+
478
+ describe('onWidgetSizeChange', () => {
479
+ it('should short-circuit when mobile', () => {
480
+ (globals as any).isMobile = true;
481
+ component.onWidgetSizeChange('min');
482
+ expect(globals.fullscreenMode).toBe(true);
483
+ (globals as any).isMobile = false;
484
+ });
485
+
486
+ it('should persist size and toggle classes when tiledeskdiv exists', () => {
487
+ const storage = TestBed.inject(AppStorageService);
488
+ const tiledeskDiv = document.createElement('div');
489
+ tiledeskDiv.id = 'tiledeskdiv';
490
+ const parent = document.createElement('div');
491
+ parent.appendChild(tiledeskDiv);
492
+ document.body.appendChild(parent);
493
+ (globals as any).windowContext = {
494
+ window: { document: { getElementById: (id: string) => (id === 'tiledeskdiv' ? tiledeskDiv : null) } },
495
+ };
496
+ (globals as any).isMobile = false;
497
+ (globals as any).align = 'right';
498
+ (globals as any).marginX = '10px';
499
+ (globals as any).marginY = '10px';
500
+ (globals as any).mobileMarginX = '5px';
501
+ (globals as any).mobileMarginY = '5px';
502
+
503
+ component.onWidgetSizeChange('max');
504
+ expect(tiledeskDiv.classList.contains('max-size')).toBe(true);
505
+ expect(storage.setItem).toHaveBeenCalled();
506
+
507
+ component.onWidgetSizeChange('top');
508
+ expect(parent.classList.contains('overlay--popup')).toBe(true);
509
+
510
+ document.body.removeChild(parent);
511
+ });
512
+ });
513
+
514
+ describe('skipToCompose', () => {
515
+ it('should focus composer when textarea exists', () => {
516
+ const ta = document.createElement('textarea');
517
+ ta.id = 'chat21-main-message-context';
518
+ document.body.appendChild(ta);
519
+ spyOn(ta, 'focus');
520
+ component.skipToCompose();
521
+ expect(ta.focus).toHaveBeenCalled();
522
+ document.body.removeChild(ta);
523
+ });
524
+ });
525
+
526
+ describe('header / widget chrome handlers', () => {
527
+ it('onCloseWidgetFN should strip size classes and emit', () => {
528
+ spyOn(component.onCloseWidget, 'emit');
529
+ const tiledeskDiv = document.createElement('div');
530
+ tiledeskDiv.classList.add('max-size', 'min-size');
531
+ (globals as any).windowContext = {
532
+ window: { document: { getElementById: () => tiledeskDiv } },
533
+ };
534
+ component.onCloseWidgetFN();
535
+ expect(component.onCloseWidget.emit).toHaveBeenCalled();
536
+ expect(tiledeskDiv.classList.contains('max-size')).toBe(false);
537
+ expect(tiledeskDiv.classList.contains('min-size')).toBe(false);
538
+ });
539
+
540
+ it('onCloseChat should open dialog', () => {
541
+ component.conversation = { uid: 'c1' } as any;
542
+ component.onCloseChat();
543
+ expect(component.mydialog.nativeElement.showModal).toHaveBeenCalled();
544
+ expect(component.isMenuShow).toBe(false);
545
+ });
546
+
547
+ it('onRestartChat should send /start with attributes', () => {
548
+ (globals as any).attributes = { k: 'v' };
549
+ component.onRestartChat();
550
+ expect(component.conversationFooter.sendMessage).toHaveBeenCalled();
551
+ const args = (component.conversationFooter.sendMessage as jasmine.Spy).calls.mostRecent().args;
552
+ expect(args[0]).toBe('/start');
553
+ });
554
+
555
+ it('onMenuOptionClick should route MAXIMIZE and MINIMIZE', () => {
556
+ spyOn(component, 'onWidgetSizeChange');
557
+ component.onMenuOptionClick(HEADER_MENU_OPTION.MAXIMIZE);
558
+ component.onMenuOptionClick(HEADER_MENU_OPTION.MINIMIZE);
559
+ expect(component.onWidgetSizeChange).toHaveBeenCalledWith('max');
560
+ expect(component.onWidgetSizeChange).toHaveBeenCalledWith('min');
561
+ });
562
+
563
+ it('onMenuOption should update visibility and blur composer', () => {
564
+ component.onMenuOption(false);
565
+ expect(component.isMenuShow).toBe(false);
566
+ expect(component.conversationFooter.removeFocusOnId).toHaveBeenCalledWith('chat21-main-message-context');
567
+ });
568
+ });
569
+
570
+ describe('content and preview bridges', () => {
571
+ it('onBeforeMessageRenderFN and onAfterMessageRenderFN should emit', () => {
572
+ spyOn(component.onBeforeMessageRender, 'emit');
573
+ spyOn(component.onAfterMessageRender, 'emit');
574
+ component.onBeforeMessageRenderFN({ a: 1 });
575
+ component.onAfterMessageRenderFN({ b: 2 });
576
+ expect(component.onBeforeMessageRender.emit).toHaveBeenCalledWith({ a: 1 });
577
+ expect(component.onAfterMessageRender.emit).toHaveBeenCalledWith({ b: 2 });
578
+ });
579
+
580
+ it('onAttachmentButtonClicked url should call openLink', () => {
581
+ spyOn(component as any, 'openLink');
582
+ component.onAttachmentButtonClicked({ target: { type: 'url', button: { href: 'x' } } });
583
+ expect((component as any).openLink).toHaveBeenCalled();
584
+ });
585
+
586
+ it('onAttachmentButtonClicked action should call actionButton', () => {
587
+ spyOn(component as any, 'actionButton');
588
+ component.onAttachmentButtonClicked({ target: { type: 'action', button: {} } });
589
+ expect((component as any).actionButton).toHaveBeenCalled();
590
+ });
591
+
592
+ it('onScrollContent false should show scroll-to-bottom affordance', () => {
593
+ component.onScrollContent(false);
594
+ expect(component.showBadgeScroollToBottom).toBe(true);
595
+ });
596
+
597
+ it('onOpenExternalFrame should open window', () => {
598
+ spyOn(window, 'open');
599
+ component.onOpenExternalFrame({ link: 'https://ex.example' });
600
+ expect(window.open).toHaveBeenCalledWith('https://ex.example', '_blank');
601
+ });
602
+
603
+ it('onCloseInternalFrame should clear button state', () => {
604
+ spyOn(component as any, 'restoreDefaultWidgetSize').and.stub();
605
+ component.isButtonUrl = true;
606
+ component.buttonClicked = { x: 1 } as any;
607
+ component.onCloseInternalFrame({});
608
+ expect(component.isButtonUrl).toBe(false);
609
+ expect(component.buttonClicked).toBeNull();
610
+ });
611
+
612
+ it('onSendAttachment should close preview and call uploadSingle', () => {
613
+ component.isOpenAttachmentPreview = true;
614
+ component.attachments = [{ metadata: { uid: '1' }, file: new File([], 'a.png') }] as any;
615
+ component.conversationFooter.uploadSingle = jasmine.createSpy('uploadSingle');
616
+ component.onSendAttachment('cap');
617
+ expect(component.isOpenAttachmentPreview).toBe(false);
618
+ expect(component.conversationFooter.uploadSingle).toHaveBeenCalled();
619
+ });
620
+
621
+ it('onCloseModalPreview should reset footer upload flag', () => {
622
+ component.isOpenAttachmentPreview = true;
623
+ (component.conversationFooter as any).isFilePendingToUpload = true;
624
+ component.onCloseModalPreview();
625
+ expect(component.isOpenAttachmentPreview).toBe(false);
626
+ expect((component.conversationFooter as any).isFilePendingToUpload).toBe(false);
627
+ });
628
+
629
+ it('onEmojiiPickerShow should mirror state', () => {
630
+ component.onEmojiiPickerShow(true);
631
+ expect(component.isEmojiiPickerShow).toBe(true);
632
+ });
633
+
634
+ it('onBeforeMessangeSentFN should emit', () => {
635
+ spyOn(component.onBeforeMessageSent, 'emit');
636
+ const m = { uid: 'm' } as MessageModel;
637
+ component.onBeforeMessangeSentFN(m);
638
+ expect(component.onBeforeMessageSent.emit).toHaveBeenCalledWith(m);
639
+ });
640
+
641
+ it('onChangeTextArea should resize scroll host for medium heights', () => {
642
+ const scrollHost = component.conversationContent.scrollMe.nativeElement;
643
+ component.onChangeTextArea({
644
+ textAreaEl: { style: { height: '40px' } },
645
+ } as any);
646
+ expect(scrollHost.style.height).toContain('calc');
647
+ });
648
+
649
+ it('onAttachmentFileButtonClicked should open preview', () => {
650
+ const ev = { attachments: [{ f: 1 }], message: 'm' };
651
+ component.onAttachmentFileButtonClicked(ev as any);
652
+ expect(component.isOpenAttachmentPreview).toBe(true);
653
+ expect(component.attachments as any).toEqual([{ f: 1 }]);
654
+ expect(component.textInputTextArea).toBe('m');
655
+ });
656
+
657
+ it('onNewConversationButtonClickedFN should emit', () => {
658
+ spyOn(component.onNewConversationButtonClicked, 'emit');
659
+ component.onNewConversationButtonClickedFN(null);
660
+ expect(component.onNewConversationButtonClicked.emit).toHaveBeenCalled();
661
+ });
662
+ });
94
663
  });