@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,53 +1,72 @@
1
- import { async, ComponentFixture, TestBed, waitForAsync, inject } from '@angular/core/testing';
1
+ import { SimpleChange } from '@angular/core';
2
+ import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
3
+ import { provideHttpClientTesting } from '@angular/common/http/testing';
4
+ import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
5
+ import { BehaviorSubject } from 'rxjs';
2
6
 
7
+ import { UploadService } from 'src/chat21-core/providers/abstract/upload.service';
8
+ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
9
+ import { CustomLogger } from 'src/chat21-core/providers/logger/customLogger';
10
+ import { NGXLogger } from 'ngx-logger';
11
+ import { MAX_WIDTH_IMAGES } from 'src/app/utils/constants';
3
12
  import { ConversationContentComponent } from './conversation-content.component';
4
- import { MarkedPipe } from '../../../pipe/marked.pipe';
5
- import { HtmlEntitiesEncodePipe } from '../../../pipe/html-entities-encode.pipe';
6
- import { UploadService } from '../../../../chat21-core/providers/abstract/upload.service';
7
- import { CustomLogger } from '../../../../chat21-core/providers/logger/customLogger';
8
- import { LoggerInstance } from '../../../../chat21-core/providers/logger/loggerInstance';
9
- import { NO_ERRORS_SCHEMA, Injectable } from '@angular/core';
10
- import { By } from '@angular/platform-browser';
11
- import { ImageRepoService } from '../../../../chat21-core/providers/abstract/image-repo.service';
12
13
 
13
14
  describe('ConversationContentComponent', () => {
14
15
  let component: ConversationContentComponent;
15
16
  let fixture: ComponentFixture<ConversationContentComponent>;
17
+ let uploadState$: BehaviorSubject<any>;
16
18
 
17
- beforeEach(waitForAsync(() => {
18
- TestBed.configureTestingModule({
19
- declarations: [
20
- ConversationContentComponent,
21
- // BubbleMessageComponent,
22
- // ReturnReceiptComponent,
23
- // AvatarComponent,
24
- // InfoMessageComponent,
25
- // MessageAttachmentComponent,
26
- // ImageComponent,
27
- // FrameComponent,
28
- // TextComponent,
29
- // TextButtonComponent,
30
- // LinkButtonComponent,
31
- // ActionButtonComponent,
32
-
33
- MarkedPipe,
34
- HtmlEntitiesEncodePipe,
35
- ],
36
- imports: [
37
- ],
38
- providers: [
39
- UploadService,
40
- ImageRepoService
19
+ const ngxlogger = jasmine.createSpyObj('NGXLogger', ['log', 'trace', 'debug', 'warn', 'error', 'info']);
20
+ const customLogger = new CustomLogger(ngxlogger);
21
+
22
+ const uploadServiceStub = {
23
+ BSStateUpload: new BehaviorSubject<any>(null),
24
+ initialize: jasmine.createSpy('initialize'),
25
+ upload: jasmine.createSpy('upload').and.resolveTo({ downloadURL: '', src: '' }),
26
+ uploadFile: jasmine.createSpy('uploadFile').and.resolveTo({ downloadURL: '', src: '' }),
27
+ uploadAsset: jasmine.createSpy('uploadAsset').and.resolveTo({ downloadURL: '', src: '' }),
28
+ uploadProfile: jasmine.createSpy('uploadProfile').and.resolveTo({}),
29
+ delete: jasmine.createSpy('delete').and.resolveTo({}),
30
+ deleteFile: jasmine.createSpy('deleteFile').and.resolveTo({}),
31
+ deleteAsset: jasmine.createSpy('deleteAsset').and.resolveTo({}),
32
+ deleteProfile: jasmine.createSpy('deleteProfile').and.resolveTo({}),
33
+ setBaseUrl: jasmine.createSpy('setBaseUrl'),
34
+ getBaseUrl: jasmine.createSpy('getBaseUrl').and.returnValue(''),
35
+ };
36
+
37
+ beforeEach(async () => {
38
+ LoggerInstance.setInstance(customLogger);
39
+
40
+ await TestBed.configureTestingModule({
41
+ declarations: [ConversationContentComponent],
42
+ providers: [
43
+ { provide: UploadService, useValue: uploadServiceStub },
44
+ provideHttpClient(withInterceptorsFromDi()),
45
+ provideHttpClientTesting(),
41
46
  ],
42
- schemas: [NO_ERRORS_SCHEMA],
43
47
  })
44
- .compileComponents();
45
- }));
48
+ .overrideComponent(ConversationContentComponent, {
49
+ set: {
50
+ template: `
51
+ <div class="c21-body">
52
+ <div #scrollMe>
53
+ <div id="c21-contentScroll" style="height:20px;">inner</div>
54
+ </div>
55
+ </div>
56
+ `,
57
+ },
58
+ })
59
+ .compileComponents();
46
60
 
47
- beforeEach(() => {
61
+ uploadState$ = uploadServiceStub.BSStateUpload as BehaviorSubject<any>;
48
62
  fixture = TestBed.createComponent(ConversationContentComponent);
49
- let upload = fixture.debugElement.injector.get(UploadService) as UploadService
50
- upload.BSStateUpload.next({ upload: 100, type: 'image' })
63
+ component = fixture.componentInstance;
64
+ component.messages = [];
65
+ component.stylesMap = new Map([
66
+ ['bubbleSentTextColor', '#111'],
67
+ ['bubbleReceivedTextColor', '#222'],
68
+ ]);
69
+ component.translationMap = new Map([['LABEL_LOADING', 'Loading']]);
51
70
  fixture.detectChanges();
52
71
  });
53
72
 
@@ -55,120 +74,194 @@ describe('ConversationContentComponent', () => {
55
74
  expect(component).toBeTruthy();
56
75
  });
57
76
 
58
- it('renders a div el with class ".c21-body"', () => {
59
- const bubble_message = fixture.debugElement.query(By.css('.c21-body'));
60
- expect(bubble_message).toBeTruthy();
61
- })
62
-
63
- it('renders a div el with class ".base_receive"', () => {
64
- const messages: [any] = [{
65
- attributes: {
66
- projectId: "6013ec749b32000045be650e",
67
- tiledesk_message_id: "611cbf8ffb379b00346660e7"
68
- },
69
- channel_type: "group",
70
- recipient: "support-group-6013ec749b32000045be650e-4904aee91f8b487aad117bcda860549d",
71
- recipient_fullname: "Guest ",
72
- sender: "bot_602256f6c001b800342cb76f",
73
- sender_fullname: "BOT2",
74
- status: 150,
75
- text: "Hello 👋. I'm a bot 🤖.\n\nChoose one of the options below or write a message to reach our staff.",
76
- timestamp: 1629273999970,
77
- type: "text",
78
- uid: "-MhNI3eaIoLTOLoX3TAu",
79
- isSender: false
80
- }
81
- ]
82
- component.messages = messages
83
- component.senderId = '9d3b6aa5-0aea-4b7e-935f-1c1c675cd8d4'
84
- component.baseLocation = 'http://tiledesk-widget-pre.s3-eu-west-1.amazonaws.com'
85
- component.translationMap = new Map();
86
- component.stylesMap = new Map();
87
- fixture.detectChanges()
88
- const nativeEl: HTMLElement = fixture.nativeElement;
89
- const baseReceiveEl = nativeEl.querySelector('.base_receive');
90
- expect(baseReceiveEl).toBeTruthy();
77
+ describe('ngOnInit', () => {
78
+ it('should subscribe to upload progress', () => {
79
+ spyOn(component, 'scrollToBottom');
80
+ uploadState$.next({ upload: 50, type: 'image/png' });
81
+ expect(component.showUploadProgress).toBe(true);
82
+ expect(component.uploadProgress).toBe(50);
83
+ expect(component.scrollToBottom).toHaveBeenCalled();
84
+ });
85
+
86
+ it('should hide progress when upload is complete (100 or NaN)', () => {
87
+ uploadState$.next({ upload: 100, type: 'image/png' });
88
+ expect(component.showUploadProgress).toBe(false);
89
+ });
91
90
  });
92
91
 
93
- it('renders the right textContext of div el with class ".message_sender_fullname"', () => {
94
- const messages: [any] = [{
95
- attributes: {
96
- projectId: "6013ec749b32000045be650e",
97
- tiledesk_message_id: "611cbf8ffb379b00346660e7"
98
- },
99
- channel_type: "group",
100
- recipient: "support-group-6013ec749b32000045be650e-4904aee91f8b487aad117bcda860549d",
101
- recipient_fullname: "Guest ",
102
- sender: "bot_602256f6c001b800342cb76f",
103
- sender_fullname: "BOT2",
104
- status: 150,
105
- text: "Hello 👋. I'm a bot 🤖.\n\nChoose one of the options below or write a message to reach our staff.",
106
- timestamp: 1629273999970,
107
- type: "text",
108
- uid: "-MhNI3eaIoLTOLoX3TAu",
109
- isSender: false
110
- }
111
- ]
112
- component.messages = messages
113
- component.senderId = '9d3b6aa5-0aea-4b7e-935f-1c1c675cd8d4'
114
- component.baseLocation = 'http://tiledesk-widget-pre.s3-eu-west-1.amazonaws.com'
115
- component.translationMap = new Map();
116
- component.stylesMap = new Map();
117
- const nativeEl: HTMLElement = fixture.nativeElement;
118
- const baseReceiveEl = nativeEl.querySelector('.message_sender_fullname');
119
- fixture.detectChanges()
120
- expect(baseReceiveEl.textContent).toBe('BOT2');
92
+ describe('ngOnChanges', () => {
93
+ it('should set CSS variables on .c21-body from stylesMap', () => {
94
+ const body = (fixture.debugElement.nativeElement as HTMLElement).querySelector('.c21-body') as HTMLElement;
95
+ spyOn(body.style, 'setProperty');
96
+ component.ngOnChanges({
97
+ stylesMap: new SimpleChange(null, component.stylesMap, true),
98
+ });
99
+ expect(body.style.setProperty).toHaveBeenCalledWith('--textColorSent', '#111');
100
+ expect(body.style.setProperty).toHaveBeenCalledWith('--textColorReceive', '#222');
101
+ });
121
102
  });
122
103
 
123
- it('renders a chat-avatar-image & chat-bubble-message components in div with ".base_receive" class', () => {
124
- const messages: Array<any> = [{
125
- attributes: {
126
- projectId: "6013ec749b32000045be650e",
127
- tiledesk_message_id: "611cbf8ffb379b00346660e7"
128
- },
129
- channel_type: "group",
130
- recipient: "support-group-6013ec749b32000045be650e-4904aee91f8b487aad117bcda860549d",
131
- recipient_fullname: "Guest ",
132
- sender: "bot_602256f6c001b800342cb76f",
133
- sender_fullname: "BOT2",
134
- status: 150,
135
- text: "Hello 👋. I'm a bot 🤖.\n\nChoose one of the options below or write a message to reach our staff.",
136
- timestamp: 1629273999970,
137
- type: "text",
138
- uid: "-MhNI3eaIoLTOLoX3TAu",
139
- isSender: false
140
- },
141
- {
142
- attributes: {
143
- projectId: "6013ec749b32000045be650e",
144
- tiledesk_message_id: "611cbf8ffb379b00346660e7"
145
- },
146
- channel_type: "group",
147
- recipient: "support-group-6013ec749b32000045be650e-4904aee91f8b487aad117bcda860549d",
148
- recipient_fullname: "Guest ",
149
- sender: "bot_602256f6c001b800342cb76f",
150
- sender_fullname: "BOT1",
151
- status: 150,
152
- text: "Hello 👋. I'm a bot 🤖.\n\nChoose one of the options below or write a message to reach our staff.",
153
- timestamp: 1629273999970,
154
- type: "text",
155
- uid: "-MhNI3eaIoLTOLoX3TAu",
156
- isSender: false
157
- }
158
- ]
159
- component.messages = messages
160
- component.senderId = '9d3b6aa5-0aea-4b7e-935f-1c1c675cd8d4'
161
- component.baseLocation = 'http://tiledesk-widget-pre.s3-eu-west-1.amazonaws.com'
162
- component.translationMap = new Map();
163
- component.stylesMap = new Map();
164
-
165
- const nativeEl: HTMLElement = fixture.nativeElement;
166
- const baseReceiveEl = nativeEl.querySelectorAll('.base_receive')
167
- const chatImageComponentChild = baseReceiveEl[0].querySelector('chat-avatar-image')
168
- const bubbleMessageComponentChild = baseReceiveEl[0].querySelector('chat-bubble-message.msg_receive')
169
- fixture.detectChanges()
170
- expect(chatImageComponentChild).toBeTruthy();
171
- expect(bubbleMessageComponentChild).toBeTruthy();
104
+ describe('getMetadataSize', () => {
105
+ it('should default width/height and scale wide images', () => {
106
+ const meta: any = { width: MAX_WIDTH_IMAGES * 2, height: 100 };
107
+ const s = component.getMetadataSize(meta);
108
+ expect(s.width).toBe(MAX_WIDTH_IMAGES);
109
+ const ratio = meta.width / meta.height;
110
+ expect(s.height).toBeCloseTo(MAX_WIDTH_IMAGES / ratio, 5);
111
+ });
112
+
113
+ it('should fill missing dimensions', () => {
114
+ const s = component.getMetadataSize({});
115
+ expect(s.width).toBe('100%');
116
+ expect(s.height).toBe(MAX_WIDTH_IMAGES);
117
+ });
118
+ });
119
+
120
+ describe('scroll and badge', () => {
121
+ beforeEach(() => {
122
+ const scrollHost = document.createElement('div');
123
+ scrollHost.style.height = '100px';
124
+ scrollHost.style.overflow = 'auto';
125
+ const inner = document.createElement('div');
126
+ inner.style.height = '300px';
127
+ scrollHost.appendChild(inner);
128
+ component.scrollMe = { nativeElement: scrollHost } as any;
129
+ });
130
+
131
+ it('onScroll should emit true at bottom', () => {
132
+ spyOn(component.onScrollContent, 'emit');
133
+ const el = component.scrollMe.nativeElement;
134
+ el.scrollTop = el.scrollHeight - el.clientHeight;
135
+ component.onScroll({ target: el });
136
+ expect(component.onScrollContent.emit).toHaveBeenCalledWith(true);
137
+ });
138
+
139
+ it('checkContentScrollPosition should return false when not at bottom', () => {
140
+ spyOn(component, 'checkContentScrollPosition').and.callThrough();
141
+ const el = component.scrollMe.nativeElement;
142
+ Object.defineProperty(el, 'scrollHeight', { configurable: true, value: 500 });
143
+ Object.defineProperty(el, 'clientHeight', { configurable: true, value: 100 });
144
+ el.scrollTop = 0;
145
+ expect(component.checkContentScrollPosition(el)).toBe(false);
146
+ });
147
+
148
+ it('scrollToBottom should emit onScrollContent true', fakeAsync(() => {
149
+ const wrap = document.createElement('div');
150
+ wrap.style.height = '40px';
151
+ wrap.style.overflow = 'auto';
152
+ const inner = document.createElement('div');
153
+ inner.id = 'c21-contentScroll';
154
+ inner.style.height = '200px';
155
+ wrap.appendChild(inner);
156
+ document.body.appendChild(wrap);
157
+ spyOn(component.onScrollContent, 'emit');
158
+ component.scrollToBottom(true);
159
+ tick(0);
160
+ expect(component.onScrollContent.emit).toHaveBeenCalledWith(true);
161
+ document.body.removeChild(wrap);
162
+ }));
163
+ });
164
+
165
+ describe('emitters', () => {
166
+ it('hideOutsideElements should close menus', () => {
167
+ spyOn(component.onMenuOptionShow, 'emit');
168
+ spyOn(component.onEmojiiPickerShow, 'emit');
169
+ component.hideOutsideElements();
170
+ expect(component.onMenuOptionShow.emit).toHaveBeenCalledWith(false);
171
+ expect(component.onEmojiiPickerShow.emit).toHaveBeenCalledWith(false);
172
+ });
173
+
174
+ it('onAttachmentButtonClickedFN should forward event', () => {
175
+ spyOn(component.onAttachmentButtonClicked, 'emit');
176
+ const ev = { a: 1 };
177
+ component.onAttachmentButtonClickedFN(ev);
178
+ expect(component.onAttachmentButtonClicked.emit).toHaveBeenCalledWith(ev);
179
+ });
180
+
181
+ it('onBeforeMessageRenderFN / onAfterMessageRenderFN should emit', () => {
182
+ spyOn(component.onBeforeMessageRender, 'emit');
183
+ spyOn(component.onAfterMessageRender, 'emit');
184
+ const ev = { x: 'y' };
185
+ component.onBeforeMessageRenderFN(ev);
186
+ component.onAfterMessageRenderFN(ev);
187
+ expect(component.onBeforeMessageRender.emit).toHaveBeenCalledWith(ev);
188
+ expect(component.onAfterMessageRender.emit).toHaveBeenCalledWith(ev);
189
+ });
190
+
191
+ it('onElementRenderedFN with status should call scrollToBottom', () => {
192
+ spyOn(component, 'scrollToBottom');
193
+ component.scrollMe = { nativeElement: document.createElement('div') } as any;
194
+ component.onElementRenderedFN({ status: true });
195
+ expect(component.scrollToBottom).toHaveBeenCalled();
196
+ });
197
+
198
+ it('onElementRenderedFN with status false should not scroll', () => {
199
+ spyOn(component, 'scrollToBottom');
200
+ component.scrollMe = { nativeElement: document.createElement('div') } as any;
201
+ component.onElementRenderedFN({ status: false });
202
+ expect(component.scrollToBottom).not.toHaveBeenCalled();
203
+ });
204
+ });
205
+
206
+ describe('upload observable edge cases', () => {
207
+ it('should ignore null BSStateUpload payloads', () => {
208
+ component.showUploadProgress = true;
209
+ uploadState$.next(null);
210
+ expect(component.showUploadProgress).toBe(true);
211
+ });
212
+
213
+ it('should treat NaN upload as complete for progress UI', () => {
214
+ uploadState$.next({ upload: NaN, type: 'image/png' });
215
+ expect(component.showUploadProgress).toBe(false);
216
+ });
217
+ });
218
+
219
+ describe('onScroll without ViewChild', () => {
220
+ it('should not emit when scrollMe is missing', () => {
221
+ spyOn(component.onScrollContent, 'emit');
222
+ component.scrollMe = undefined as any;
223
+ component.onScroll({ target: document.createElement('div') });
224
+ expect(component.onScrollContent.emit).not.toHaveBeenCalled();
225
+ });
226
+ });
227
+
228
+ describe('scrollToBottom error path (sync)', () => {
229
+ it('should log when getElementById throws synchronously', () => {
230
+ spyOn(document, 'getElementById').and.throwError('no-dom');
231
+ spyOn((component as any).logger, 'error');
232
+ component.scrollToBottom();
233
+ expect((component as any).logger.error).toHaveBeenCalled();
234
+ });
235
+ });
236
+
237
+ describe('message helper delegates', () => {
238
+ it('isLastMessage / isSameSender / isFirstMessage use messages array', () => {
239
+ component.messages = [
240
+ { uid: 'm1', sender: 'alice' },
241
+ { uid: 'm2', sender: 'alice' },
242
+ ] as any;
243
+ expect(component.isLastMessage('m2')).toBe(true);
244
+ expect(component.isSameSender('alice', 1)).toBe(true);
245
+ expect(component.isFirstMessage('alice', 0)).toBe(true);
246
+ });
247
+ });
248
+
249
+ describe('getMetadataSize string width', () => {
250
+ it('should not scale when width is non-numeric string', () => {
251
+ const s = component.getMetadataSize({ width: '100%', height: 200 });
252
+ expect(s.width).toBe('100%');
253
+ });
254
+ });
255
+
256
+ describe('ngOnChanges styles edge', () => {
257
+ it('should not touch DOM when bubble color keys are absent', () => {
258
+ const spy = spyOn((component as any).elementRef.nativeElement, 'querySelector');
259
+ component.stylesMap = new Map();
260
+ component.ngOnChanges({
261
+ stylesMap: new SimpleChange(null, component.stylesMap, false),
262
+ });
263
+ expect(spy).not.toHaveBeenCalled();
264
+ });
172
265
  });
173
266
 
174
267
  });
@@ -1,4 +1,5 @@
1
- import { ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
1
+ import { ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnInit, OnDestroy, Output, SimpleChanges, ViewChild } from '@angular/core';
2
+ import { Subscription } from 'rxjs';
2
3
  import { MAX_WIDTH_IMAGES, MSG_STATUS_RETURN_RECEIPT, MSG_STATUS_SENT, MSG_STATUS_SENT_SERVER } from 'src/app/utils/constants';
3
4
  import { MessageModel } from 'src/chat21-core/models/message';
4
5
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
@@ -12,7 +13,7 @@ import { isCarousel, isEmojii, isFirstMessage, isFrame, isImage, isInfo, isLastM
12
13
  templateUrl: './conversation-content.component.html',
13
14
  styleUrls: ['./conversation-content.component.scss']
14
15
  })
15
- export class ConversationContentComponent implements OnInit {
16
+ export class ConversationContentComponent implements OnInit, OnDestroy {
16
17
  @ViewChild('scrollMe') public scrollMe: ElementRef;
17
18
 
18
19
  @Input() messages: MessageModel[]
@@ -73,6 +74,7 @@ export class ConversationContentComponent implements OnInit {
73
74
  showUploadProgress: boolean = false;
74
75
  fileType: string;
75
76
  private logger: LoggerService = LoggerInstance.getInstance();
77
+ private uploadSub?: Subscription;
76
78
 
77
79
  constructor(private cdref: ChangeDetectorRef,
78
80
  private elementRef: ElementRef,
@@ -82,8 +84,8 @@ export class ConversationContentComponent implements OnInit {
82
84
  this.listenToUploadFileProgress();
83
85
  }
84
86
 
85
- ngAfterContentChecked() {
86
- this.cdref.detectChanges();
87
+ ngOnDestroy() {
88
+ this.uploadSub?.unsubscribe();
87
89
  }
88
90
 
89
91
  ngOnChanges(changes: SimpleChanges){
@@ -93,7 +95,6 @@ export class ConversationContentComponent implements OnInit {
93
95
 
94
96
  }
95
97
 
96
-
97
98
  /**
98
99
  *
99
100
  * @param message
@@ -122,7 +123,7 @@ export class ConversationContentComponent implements OnInit {
122
123
 
123
124
  // ENABLE HTML SECTION 'FILE PENDING UPLOAD'
124
125
  listenToUploadFileProgress() {
125
- this.uploadService.BSStateUpload.subscribe((data: any) => {
126
+ this.uploadSub = this.uploadService.BSStateUpload.subscribe((data: any) => {
126
127
  this.logger.debug('[CONV-CONTENT] BSStateUpload', data);
127
128
  // && data.type.startsWith("application")
128
129
  if (data) {
@@ -1,23 +1,73 @@
1
1
  import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { provideHttpClientTesting } from '@angular/common/http/testing';
3
+ import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
2
4
 
3
5
  import { ConversationEmojiiComponent } from './conversation-emojii.component';
4
6
 
7
+ /** Template references `stylesMap`, which is not declared on the component; use a shallow template for unit tests. */
5
8
  describe('ConversationEmojiiComponent', () => {
6
9
  let component: ConversationEmojiiComponent;
7
10
  let fixture: ComponentFixture<ConversationEmojiiComponent>;
8
11
 
9
12
  beforeEach(async () => {
10
13
  await TestBed.configureTestingModule({
11
- declarations: [ ConversationEmojiiComponent ]
14
+ declarations: [ConversationEmojiiComponent],
15
+ providers: [
16
+ provideHttpClient(withInterceptorsFromDi()),
17
+ provideHttpClientTesting(),
18
+ ],
12
19
  })
13
- .compileComponents();
20
+ .overrideComponent(ConversationEmojiiComponent, {
21
+ set: { template: '<span></span>' },
22
+ })
23
+ .compileComponents();
14
24
 
15
25
  fixture = TestBed.createComponent(ConversationEmojiiComponent);
16
26
  component = fixture.componentInstance;
17
- fixture.detectChanges();
18
27
  });
19
28
 
20
29
  it('should create', () => {
30
+ fixture.detectChanges();
21
31
  expect(component).toBeTruthy();
22
32
  });
33
+
34
+ describe('ngOnInit', () => {
35
+ it('should initialise default emoji-mart options', () => {
36
+ component.ngOnInit();
37
+ expect(component.emojiiOptions.emojiPerLine).toBe(9);
38
+ expect(component.emojiiOptions.include).toContain('people');
39
+ });
40
+ });
41
+
42
+ describe('addEmojiFN', () => {
43
+ it('should emit addEmoji when picker selects an emoji', () => {
44
+ let emitted: unknown;
45
+ component.addEmoji.subscribe((e) => (emitted = e));
46
+ const payload = { emoji: { native: '🙂' } };
47
+ component.addEmojiFN(payload);
48
+ expect(emitted).toEqual(payload);
49
+ });
50
+
51
+ it('should emit multiple selections to all subscribers', () => {
52
+ const out: unknown[] = [];
53
+ component.addEmoji.subscribe((e) => out.push(e));
54
+ component.addEmoji.subscribe((e) => out.push(e));
55
+ const p = { emoji: { native: '🎯' } };
56
+ component.addEmojiFN(p);
57
+ expect(out).toEqual([p, p]);
58
+ });
59
+
60
+ it('should forward undefined-like payloads without throwing', () => {
61
+ spyOn(component.addEmoji, 'emit');
62
+ component.addEmojiFN(undefined);
63
+ expect(component.addEmoji.emit).toHaveBeenCalledWith(undefined);
64
+ });
65
+ });
66
+
67
+ describe('@Input var', () => {
68
+ it('should accept custom picker label', () => {
69
+ component.var = 'picker-a';
70
+ expect(component.var).toBe('picker-a');
71
+ });
72
+ });
23
73
  });