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

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 +54 -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-report/index.html +90 -0
  80. package/playwright.config.ts +41 -0
  81. package/src/app/app.component.html +2 -2
  82. package/src/app/app.component.scss +25 -14
  83. package/src/app/app.component.spec.ts +21 -6
  84. package/src/app/app.module.ts +4 -0
  85. package/src/app/component/conversation-detail/conversation/conversation.component.html +19 -11
  86. package/src/app/component/conversation-detail/conversation/conversation.component.scss +28 -0
  87. package/src/app/component/conversation-detail/conversation/conversation.component.spec.ts +644 -75
  88. package/src/app/component/conversation-detail/conversation/conversation.component.ts +61 -17
  89. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.html +25 -13
  90. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.spec.ts +123 -5
  91. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.ts +1 -0
  92. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.html +17 -7
  93. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.scss +15 -3
  94. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.spec.ts +249 -149
  95. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.ts +0 -1
  96. package/src/app/component/conversation-detail/conversation-emojii/conversation-emojii.component.spec.ts +53 -3
  97. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component copy.html +172 -0
  98. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.html +112 -62
  99. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.scss +133 -7
  100. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.spec.ts +452 -78
  101. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts +192 -84
  102. package/src/app/component/conversation-detail/conversation-header/conversation-header.component.html +113 -53
  103. package/src/app/component/conversation-detail/conversation-header/conversation-header.component.scss +12 -4
  104. package/src/app/component/conversation-detail/conversation-header/conversation-header.component.spec.ts +274 -29
  105. package/src/app/component/conversation-detail/conversation-internal-frame/conversation-internal-frame.component.html +23 -9
  106. package/src/app/component/conversation-detail/conversation-internal-frame/conversation-internal-frame.component.spec.ts +80 -8
  107. package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.html +29 -23
  108. package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.spec.ts +185 -16
  109. package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.ts +34 -14
  110. package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.html +43 -18
  111. package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.scss +56 -2
  112. package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.ts +135 -5
  113. package/src/app/component/error-alert/error-alert.component.spec.ts +65 -5
  114. package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.html +16 -7
  115. package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.scss +21 -0
  116. package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.spec.ts +89 -7
  117. package/src/app/component/form/form-builder/form-builder.component.html +1 -1
  118. package/src/app/component/form/form-builder/form-builder.component.spec.ts +163 -21
  119. package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.html +8 -4
  120. package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.scss +10 -5
  121. package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.spec.ts +90 -16
  122. package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.ts +26 -0
  123. package/src/app/component/form/inputs/form-label/form-label.component.spec.ts +45 -11
  124. package/src/app/component/form/inputs/form-radio-button/form-radio-button.component.spec.ts +24 -6
  125. package/src/app/component/form/inputs/form-select/form-select.component.spec.ts +14 -5
  126. package/src/app/component/form/inputs/form-text/form-text.component.html +14 -12
  127. package/src/app/component/form/inputs/form-text/form-text.component.scss +11 -1
  128. package/src/app/component/form/inputs/form-text/form-text.component.spec.ts +113 -17
  129. package/src/app/component/form/inputs/form-text/form-text.component.ts +26 -0
  130. package/src/app/component/form/inputs/form-textarea/form-textarea.component.html +13 -11
  131. package/src/app/component/form/inputs/form-textarea/form-textarea.component.scss +6 -5
  132. package/src/app/component/form/inputs/form-textarea/form-textarea.component.spec.ts +149 -13
  133. package/src/app/component/form/inputs/form-textarea/form-textarea.component.ts +26 -0
  134. package/src/app/component/form/prechat-form/prechat-form.component.html +14 -11
  135. package/src/app/component/form/prechat-form/prechat-form.component.spec.ts +102 -10
  136. package/src/app/component/form/prechat-form/prechat-form.component.ts +8 -1
  137. package/src/app/component/form/prechat-form-test-mock.ts +35 -0
  138. package/src/app/component/home/home.component.html +38 -31
  139. package/src/app/component/home/home.component.scss +4 -2
  140. package/src/app/component/home/home.component.spec.ts +226 -11
  141. package/src/app/component/home-conversations/home-conversations.component.html +30 -26
  142. package/src/app/component/home-conversations/home-conversations.component.scss +3 -0
  143. package/src/app/component/home-conversations/home-conversations.component.spec.ts +212 -36
  144. package/src/app/component/last-message/last-message.component.html +15 -9
  145. package/src/app/component/last-message/last-message.component.scss +16 -2
  146. package/src/app/component/last-message/last-message.component.spec.ts +204 -23
  147. package/src/app/component/launcher-button/launcher-button.component.html +8 -13
  148. package/src/app/component/launcher-button/launcher-button.component.spec.ts +104 -8
  149. package/src/app/component/list-all-conversations/list-all-conversations.component.html +12 -17
  150. package/src/app/component/list-all-conversations/list-all-conversations.component.scss +2 -0
  151. package/src/app/component/list-conversations/list-conversations.component.html +22 -22
  152. package/src/app/component/menu-options/menu-options.component.html +30 -20
  153. package/src/app/component/menu-options/menu-options.component.spec.ts +125 -9
  154. package/src/app/component/message/audio/audio.component.html +13 -15
  155. package/src/app/component/message/audio/audio.component.spec.ts +140 -5
  156. package/src/app/component/message/audio/audio.component.ts +1 -0
  157. package/src/app/component/message/audio-sync/audio-sync.component.scss +1 -0
  158. package/src/app/component/message/audio-sync/audio-sync.component.spec.ts +81 -1
  159. package/src/app/component/message/audio-sync/audio-sync.component.ts +133 -86
  160. package/src/app/component/message/avatar/avatar.component.html +2 -2
  161. package/src/app/component/message/avatar/avatar.component.spec.ts +99 -7
  162. package/src/app/component/message/bubble-message/bubble-message.component.html +39 -52
  163. package/src/app/component/message/bubble-message/bubble-message.component.scss +54 -1
  164. package/src/app/component/message/bubble-message/bubble-message.component.spec.ts +154 -57
  165. package/src/app/component/message/bubble-message/bubble-message.component.ts +138 -110
  166. package/src/app/component/message/buttons/action-button/action-button.component.html +3 -4
  167. package/src/app/component/message/buttons/action-button/action-button.component.spec.ts +49 -5
  168. package/src/app/component/message/buttons/link-button/link-button.component.scss +5 -8
  169. package/src/app/component/message/buttons/link-button/link-button.component.spec.ts +50 -5
  170. package/src/app/component/message/buttons/text-button/text-button.component.spec.ts +44 -5
  171. package/src/app/component/message/carousel/carousel.component.html +29 -16
  172. package/src/app/component/message/carousel/carousel.component.scss +20 -8
  173. package/src/app/component/message/carousel/carousel.component.spec.ts +80 -3
  174. package/src/app/component/message/carousel/carousel.component.ts +16 -0
  175. package/src/app/component/message/frame/frame.component.html +9 -4
  176. package/src/app/component/message/frame/frame.component.spec.ts +34 -15
  177. package/src/app/component/message/frame/frame.component.ts +7 -2
  178. package/src/app/component/message/html/html.component.html +1 -1
  179. package/src/app/component/message/html/html.component.scss +1 -1
  180. package/src/app/component/message/html/html.component.spec.ts +24 -7
  181. package/src/app/component/message/image/image.component.html +12 -10
  182. package/src/app/component/message/image/image.component.scss +16 -0
  183. package/src/app/component/message/image/image.component.spec.ts +101 -15
  184. package/src/app/component/message/image/image.component.ts +90 -51
  185. package/src/app/component/message/info-message/info-message.component.spec.ts +26 -14
  186. package/src/app/component/message/json-sources/json-sources.component.html +38 -0
  187. package/src/app/component/message/json-sources/json-sources.component.scss +197 -0
  188. package/src/app/component/message/json-sources/json-sources.component.ts +89 -0
  189. package/src/app/component/message/like-unlike/like-unlike.component.html +7 -9
  190. package/src/app/component/message/like-unlike/like-unlike.component.spec.ts +31 -3
  191. package/src/app/component/message/return-receipt/return-receipt.component.spec.ts +38 -17
  192. package/src/app/component/message/text/text.component.html +3 -3
  193. package/src/app/component/message/text/text.component.scss +80 -86
  194. package/src/app/component/message/text/text.component.spec.ts +106 -13
  195. package/src/app/component/message-attachment/message-attachment.component.spec.ts +134 -13
  196. package/src/app/component/selection-department/selection-department.component.html +21 -23
  197. package/src/app/component/selection-department/selection-department.component.spec.ts +159 -14
  198. package/src/app/component/selection-department/selection-department.component.ts +8 -1
  199. package/src/app/component/send-button/send-button.component.html +5 -13
  200. package/src/app/component/send-button/send-button.component.spec.ts +2 -2
  201. package/src/app/component/star-rating-widget/star-rating-widget.component.html +51 -81
  202. package/src/app/directives/tooltip.directive.spec.ts +8 -4
  203. package/src/app/modals/confirm-close/confirm-close.component.html +20 -8
  204. package/src/app/modals/confirm-close/confirm-close.component.scss +3 -0
  205. package/src/app/modals/confirm-close/confirm-close.component.spec.ts +13 -4
  206. package/src/app/modals/confirm-close/confirm-close.component.ts +8 -1
  207. package/src/app/pipe/html-entites-encode.pipe.spec.ts +35 -2
  208. package/src/app/pipe/marked.pipe.spec.ts +38 -2
  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 +30 -2
  214. package/src/app/providers/json-sources-parser.service.ts +182 -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 +710 -0
  222. package/src/app/providers/voice/voice-streaming.types.ts +113 -0
  223. package/src/app/providers/voice/voice.service.spec.ts +203 -3
  224. package/src/app/providers/voice/voice.service.ts +517 -13
  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 +4 -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 +26 -1
  232. package/src/assets/i18n/es.json +106 -101
  233. package/src/assets/i18n/fr.json +106 -101
  234. package/src/assets/i18n/it.json +106 -99
  235. package/src/assets/twp/index-dev.html +18 -0
  236. package/src/assets/twp/tiledesk_widget_files/widget-css-override-example.css +14 -0
  237. package/src/chat21-core/providers/chat-manager.spec.ts +72 -0
  238. package/src/chat21-core/providers/scripts/script.service.spec.ts +12 -2
  239. package/src/chat21-core/utils/constants.ts +4 -0
  240. package/src/chat21-core/utils/utils-message.ts +23 -1
  241. package/src/widget-config-template.json +3 -1
  242. package/src/widget-config.json +28 -27
  243. package/test-results/.last-run.json +4 -0
  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,8 +1,14 @@
1
1
  import { NO_ERRORS_SCHEMA } from '@angular/core';
2
- import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2
+ import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
3
+ import { By } from '@angular/platform-browser';
4
+
3
5
  import { NGXLogger } from 'ngx-logger';
6
+ import { ConversationModel } from 'src/chat21-core/models/conversation';
7
+ import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service';
4
8
  import { CustomLogger } from 'src/chat21-core/providers/logger/customLogger';
5
9
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
10
+ import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service';
11
+ import { HEADER_MENU_OPTION } from '../../utils/constants';
6
12
  import { Globals } from '../../utils/globals';
7
13
 
8
14
  import { HomeComponent } from './home.component';
@@ -10,31 +16,240 @@ import { HomeComponent } from './home.component';
10
16
  describe('HomeComponent', () => {
11
17
  let component: HomeComponent;
12
18
  let fixture: ComponentFixture<HomeComponent>;
13
- let ngxlogger: NGXLogger;
14
- let customLogger = new CustomLogger(ngxlogger)
19
+ let globals: Globals;
20
+ const ngxlogger = jasmine.createSpyObj('NGXLogger', ['log', 'trace', 'debug', 'warn', 'error', 'info']);
21
+
22
+ const tiledeskAuthStub = {
23
+ getCurrentUser: jasmine.createSpy('getCurrentUser').and.returnValue({
24
+ uid: 'u-1',
25
+ firstname: 'Ada',
26
+ lastname: 'Lovelace',
27
+ email: 'ada@example.com',
28
+ }),
29
+ };
30
+
31
+ const translateStub = {
32
+ translateLanguage: jasmine.createSpy('translateLanguage').and.callFake((keys: string[]) => {
33
+ const m = new Map<string, string>();
34
+ keys.forEach((k) => m.set(k, `T:${k}`));
35
+ return m;
36
+ }),
37
+ };
15
38
 
16
39
  beforeEach(waitForAsync(() => {
40
+ LoggerInstance.setInstance(new CustomLogger(ngxlogger));
17
41
  TestBed.configureTestingModule({
18
- declarations: [ HomeComponent ],
42
+ declarations: [HomeComponent],
19
43
  providers: [
20
44
  Globals,
21
- NGXLogger
45
+ { provide: NGXLogger, useValue: ngxlogger },
46
+ { provide: TiledeskAuthService, useValue: tiledeskAuthStub },
47
+ { provide: CustomTranslateService, useValue: translateStub },
22
48
  ],
23
- schemas: [NO_ERRORS_SCHEMA]
24
- })
25
- .compileComponents();
49
+ schemas: [NO_ERRORS_SCHEMA],
50
+ }).compileComponents();
26
51
  }));
27
52
 
28
53
  beforeEach(() => {
29
54
  fixture = TestBed.createComponent(HomeComponent);
30
55
  component = fixture.componentInstance;
31
- let loggerInstance = LoggerInstance.setInstance(customLogger)
32
- let logger = LoggerInstance.getInstance()
33
- component['logger']= logger
56
+ globals = TestBed.inject(Globals);
57
+ globals.initDefafultParameters();
58
+ globals.welcomeTitle = 'Benvenuto';
59
+ globals.welcomeMsg = 'Intro';
60
+ globals.themeForegroundColor = '#fff';
61
+ globals.colorGradient = 'linear-gradient(red,blue)';
62
+ globals.project = { logoChat: 'nologo' } as any;
63
+ globals.poweredBy = '<a href="https://brand.example"><span id="pb-inner">Logo</span></a>';
64
+ globals.whatsappNumber = '1234567890';
65
+ globals.telegramUsername = '';
66
+ globals.messangerPageTitle = '';
67
+
68
+ component.listConversations = [];
69
+ component.archivedConversations = [];
70
+ component.hideSettings = true;
71
+ component.hideNewConversationButton = false;
72
+ component.stylesMap = new Map([
73
+ ['themeColor', '#111'],
74
+ ['foregroundColor', '#fff'],
75
+ ]);
76
+ component.size = 'min';
77
+ component.fullscreenMode = false;
78
+ component.hideHeaderConversationOptionsMenu = false;
79
+ component.isButtonsDisabled = false;
80
+ component.translationMap = new Map([
81
+ ['MAXIMIZE', 'Massimizza'],
82
+ ['MINIMIZE', 'Riduci'],
83
+ ['CENTER', 'Centra'],
84
+ ]);
85
+
34
86
  fixture.detectChanges();
35
87
  });
36
88
 
37
89
  it('should create', () => {
38
90
  expect(component).toBeTruthy();
39
91
  });
92
+
93
+ describe('translations and DOM shell', () => {
94
+ it('initiTranslations should fill header/footer maps via CustomTranslateService', () => {
95
+ component.initiTranslations();
96
+ expect(component.translationMapHeader?.get('BUTTON_CLOSE_TO_ICON')).toBe('T:BUTTON_CLOSE_TO_ICON');
97
+ expect(component.translationMapFooter?.get('SWITCH_TO')).toBe('T:SWITCH_TO');
98
+ });
99
+
100
+ it('should render region root, welcome title and close control', () => {
101
+ const region = fixture.debugElement.query(By.css('#chat21-home-component'));
102
+ expect(region).toBeTruthy();
103
+ const h1 = fixture.nativeElement.querySelector('.c21-text-welcome') as HTMLElement;
104
+ expect(h1.textContent).toContain('Benvenuto');
105
+ const closeBtn = fixture.debugElement.query(By.css('.c21-close-button-body'));
106
+ expect(closeBtn).toBeTruthy();
107
+ });
108
+
109
+ it('should set region aria-label from welcomeTitle (accessibility / MCP home shell)', () => {
110
+ globals.welcomeTitle = 'Ciao, benvenuto su BrandExample';
111
+ fixture.detectChanges();
112
+ const host = fixture.nativeElement.querySelector('#chat21-home-component') as HTMLElement;
113
+ expect(host.getAttribute('aria-label')).toBe('Ciao, benvenuto su BrandExample');
114
+ });
115
+
116
+ it('should render welcome intro paragraph when welcomeMsg is set', () => {
117
+ globals.welcomeMsg = 'Come possiamo aiutarti?';
118
+ fixture.detectChanges();
119
+ const intro = fixture.nativeElement.querySelector('.c21-text-intro') as HTMLElement;
120
+ expect(intro.textContent).toContain('Come possiamo aiutarti?');
121
+ });
122
+ });
123
+
124
+ describe('outputs and actions', () => {
125
+ it('f21_close should emit onCloseWidget and add start-animation class', () => {
126
+ spyOn(component.onCloseWidget, 'emit');
127
+ component.f21_close();
128
+ expect(component.onCloseWidget.emit).toHaveBeenCalled();
129
+ const root = fixture.debugElement.query(By.css('#chat21-home-component')).nativeElement as HTMLElement;
130
+ expect(root.classList.contains('start-animation')).toBe(true);
131
+ });
132
+
133
+ it('onChangeSize should emit correct HEADER_MENU_OPTION', () => {
134
+ spyOn(component.onMenuOptionClick, 'emit');
135
+ component.onChangeSize('min');
136
+ component.onChangeSize('max');
137
+ component.onChangeSize('top');
138
+ expect(component.onMenuOptionClick.emit).toHaveBeenCalledWith(HEADER_MENU_OPTION.MINIMIZE);
139
+ expect(component.onMenuOptionClick.emit).toHaveBeenCalledWith(HEADER_MENU_OPTION.MAXIMIZE);
140
+ expect(component.onMenuOptionClick.emit).toHaveBeenCalledWith(HEADER_MENU_OPTION.TOP);
141
+ });
142
+
143
+ it('onNewConversationFN should emit onNewConversation and strip animation', () => {
144
+ spyOn(component.onNewConversation, 'emit');
145
+ const root = fixture.debugElement.query(By.css('#chat21-home-component')).nativeElement as HTMLElement;
146
+ root.classList.add('start-animation');
147
+ component.onNewConversationFN();
148
+ expect(component.onNewConversation.emit).toHaveBeenCalled();
149
+ expect(root.classList.contains('start-animation')).toBe(false);
150
+ });
151
+
152
+ it('onConversationSelectedFN should emit conversation', () => {
153
+ spyOn(component.onConversationSelected, 'emit');
154
+ const conv = { uid: 'c1' } as ConversationModel;
155
+ component.onConversationSelectedFN(conv);
156
+ expect(component.onConversationSelected.emit).toHaveBeenCalledWith(conv);
157
+ });
158
+
159
+ it('onConversationSelectedFN should ignore null', () => {
160
+ spyOn(component.onConversationSelected, 'emit');
161
+ component.onConversationSelectedFN(null as any);
162
+ expect(component.onConversationSelected.emit).not.toHaveBeenCalled();
163
+ });
164
+
165
+ it('onOpenAllConversation should emit onOpenAllConvesations', () => {
166
+ spyOn(component.onOpenAllConvesations, 'emit');
167
+ component.onOpenAllConversation();
168
+ expect(component.onOpenAllConvesations.emit).toHaveBeenCalled();
169
+ });
170
+
171
+ it('onSignOutFN should emit onSignOut', () => {
172
+ spyOn(component.onSignOut, 'emit');
173
+ component.onSignOutFN();
174
+ expect(component.onSignOut.emit).toHaveBeenCalled();
175
+ });
176
+
177
+ it('onImageLoadedFN / onConversationLoadedFN should forward emits', () => {
178
+ spyOn(component.onImageLoaded, 'emit');
179
+ spyOn(component.onConversationLoaded, 'emit');
180
+ const c = { uid: 'x' } as ConversationModel;
181
+ component.onImageLoadedFN(c);
182
+ component.onConversationLoadedFN(c);
183
+ expect(component.onImageLoaded.emit).toHaveBeenCalledWith(c);
184
+ expect(component.onConversationLoaded.emit).toHaveBeenCalledWith(c);
185
+ });
186
+ });
187
+
188
+ describe('hideMenuOptions and openConversationOnPlatform', () => {
189
+ it('hideMenuOptions should set isOpenMenuOptions on Globals', () => {
190
+ spyOn(globals, 'setParameter');
191
+ component.hideMenuOptions();
192
+ expect(globals.setParameter).toHaveBeenCalledWith('isOpenMenuOptions', false, true);
193
+ });
194
+
195
+ it('openConversationOnPlatform should open external URLs', () => {
196
+ spyOn(window, 'open');
197
+ globals.telegramUsername = 'mybot';
198
+ globals.whatsappNumber = '39333';
199
+ globals.messangerPageTitle = 'mypage';
200
+ component.openConversationOnPlatform('telegram');
201
+ component.openConversationOnPlatform('whatsapp');
202
+ component.openConversationOnPlatform('messanger');
203
+ expect(window.open).toHaveBeenCalledWith('https://telegram.me/mybot', '_blank');
204
+ expect(window.open).toHaveBeenCalledWith(jasmine.stringMatching(/^https:\/\/wa\.me\/39333/), '_blank');
205
+ expect(window.open).toHaveBeenCalledWith('https://m.me/mypage', '_blank');
206
+ });
207
+ });
208
+
209
+ describe('managePoweredBy and analytics', () => {
210
+ it('managePoweredBy should open parent anchor href', () => {
211
+ spyOn(window, 'open');
212
+ const anchor = document.createElement('a');
213
+ anchor.setAttribute('href', 'https://brand.example');
214
+ const inner = document.createElement('span');
215
+ anchor.appendChild(inner);
216
+ const ev = new MouseEvent('click', { bubbles: true });
217
+ Object.defineProperty(ev, 'target', { value: inner, configurable: true });
218
+ component.managePoweredBy(ev);
219
+ expect(window.open).toHaveBeenCalledWith('https://brand.example', '_blank');
220
+ });
221
+
222
+ it('segmentLogoClick should invoke analytics when present', () => {
223
+ (window as any).analytics = {
224
+ page: jasmine.createSpy('page'),
225
+ identify: jasmine.createSpy('identify'),
226
+ track: jasmine.createSpy('track'),
227
+ };
228
+ (component as any).segmentLogoClick();
229
+ expect((window as any).analytics.page).toHaveBeenCalled();
230
+ expect((window as any).analytics.identify).toHaveBeenCalled();
231
+ expect((window as any).analytics.track).toHaveBeenCalled();
232
+ delete (window as any).analytics;
233
+ });
234
+ });
235
+
236
+ describe('ngAfterViewInit', () => {
237
+ it('should add animation only on first open then clear flag', () => {
238
+ globals.firstOpen = true;
239
+ component.ngAfterViewInit();
240
+ const root = fixture.debugElement.query(By.css('#chat21-home-component')).nativeElement as HTMLElement;
241
+ expect(root.classList.contains('start-animation')).toBe(true);
242
+ expect(globals.firstOpen).toBe(false);
243
+ });
244
+
245
+ it('should focus aflistconv after delay when present', fakeAsync(() => {
246
+ const btn = document.createElement('button');
247
+ btn.setAttribute('aflistconv', '');
248
+ spyOn(btn, 'focus');
249
+ (component as any).aflistconv = { nativeElement: btn };
250
+ component.ngAfterViewInit();
251
+ tick(1000);
252
+ expect(btn.focus).toHaveBeenCalled();
253
+ }));
254
+ });
40
255
  });
@@ -1,32 +1,34 @@
1
1
  <div id='c21-app-list-conversations'>
2
- <!-- tabindex="1100"-->
3
2
 
4
3
  <div class="c21-header">
5
4
  <div *ngIf="checkShowAllConversation()">
6
5
  <div class="c21-title">{{g.PREV_CONVERSATIONS}}</div>
7
6
 
8
- <div *ngIf="g.showAllConversations == true" class="c21-button" (click)="returnOpenAllConversation()">
9
- <div style="display:inline-block; line-height: 40px; margin-right: 10px;" (click)="returnOpenAllConversation()">{{g.SHOW_ALL_CONV}} </div>
10
- <button tabindex="1101" aria-label=" tutte le conversazioni" class="c21-button-clean">
11
- <!-- <svg xmlns="http://www.w3.org/2000/svg" [ngStyle]="{'fill': g.themeColor }" width="18" height="18" viewBox="0 0 24 24">
12
- <path fill="none" d="M0 0h24v24H0V0z" />
13
- <path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7zm-4 6h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/>
14
- </svg> -->
15
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20" style="enable-background:new 0 0 20 20;" xml:space="preserve">
16
- <path d="M1.9,15.4h16.2v-1.8H1.9V15.4z M1.9,10.9h16.2V9.1H1.9V10.9z M1.9,4.6v1.8h16.2V4.6H1.9z"/>
17
- </svg>
18
- </button>
19
- </div>
7
+ <button *ngIf="g.showAllConversations == true"
8
+ type="button"
9
+ class="c21-button c21-button-clean"
10
+ [attr.aria-label]="g.SHOW_ALL_CONV"
11
+ (click)="returnOpenAllConversation()">
12
+ <span style="display:inline-block; line-height: 40px; margin-right: 10px;">{{g.SHOW_ALL_CONV}} </span>
13
+ <svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20" style="enable-background:new 0 0 20 20;" xml:space="preserve">
14
+ <path d="M1.9,15.4h16.2v-1.8H1.9V15.4z M1.9,10.9h16.2V9.1H1.9V10.9z M1.9,4.6v1.8h16.2V4.6H1.9z"/>
15
+ </svg>
16
+ </button>
20
17
 
21
18
  </div>
22
19
  <div *ngIf="!checkShowAllConversation()">
23
20
  <div class="c21-title">{{g.NO_CONVERSATION}}</div>
24
- <div *ngIf="listConversations && listConversations.length > 0" class="c21-button" (click)="returnOpenAllConversation()">
25
- <div style="display:inline-block; line-height: 40px; margin-right: 10px;">{{g.SHOW_ALL_CONV}}</div>
26
- <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24">
21
+ <div *ngIf="listConversations && listConversations.length > 0">
22
+ <button type="button"
23
+ class="c21-button c21-button-clean"
24
+ [attr.aria-label]="g.SHOW_ALL_CONV"
25
+ (click)="returnOpenAllConversation()">
26
+ <span style="display:inline-block; line-height: 40px; margin-right: 10px;">{{g.SHOW_ALL_CONV}}</span>
27
+ <svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24">
27
28
  <path fill="none" d="M0 0h24v24H0V0z" />
28
29
  <path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7zm-4 6h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/>
29
30
  </svg>
31
+ </button>
30
32
  </div>
31
33
  </div>
32
34
  </div>
@@ -63,15 +65,18 @@
63
65
  <div *ngIf="isImageLoaded(agent)" #avatarImage class="c21-avatar-image" [style.background-image]="'url(' + agent.imageurl + ')'"></div>
64
66
  </div>
65
67
  </div>
66
- <button tabindex="1040" aflistconv #aflistconv class="c21-button-primary" (click)="openNewConversation()" [ngStyle]="{'background-color': g.themeColor, 'border-color': g.themeColor, 'color': g.themeForegroundColor }">
68
+ <button type="button" aflistconv #aflistconv class="c21-button-primary"
69
+ [attr.aria-label]="g.LABEL_START_NW_CONV"
70
+ (click)="openNewConversation()"
71
+ [ngStyle]="{'background-color': g.themeColor, 'border-color': g.themeColor, 'color': g.themeForegroundColor }">
67
72
  <span class="v-align-center">
68
- <svg [ngStyle]="{'fill': 'yellow' }" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24">
73
+ <svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24">
69
74
  <path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" [ngStyle]="{'fill': g.themeForegroundColor}"/>
70
75
  </svg>
71
76
  </span>
72
77
  <span class="v-align-center c21-label-button">
73
78
  {{g.LABEL_START_NW_CONV}}
74
- </span>
79
+ </span>
75
80
  <div class="clear"></div>
76
81
  </button>
77
82
  </div>
@@ -88,16 +93,15 @@
88
93
  (onConversationLoaded)="onConversationLoadedFN($event)">
89
94
  </chat-list-conversations>
90
95
 
91
- <div class="c21-new-conversation" >
92
- <!-- *ngIf="this.g.supportMode" -->
93
- <button tabindex="1040" aflistconv #aflistconv class="c21-button-primary" (click)="openNewConversation()" [ngStyle]="{'background-color': g.themeColor, 'border-color': g.themeColor, 'color': g.themeForegroundColor }">
96
+ <div class="c21-new-conversation">
97
+ <button type="button" aflistconv #aflistconv class="c21-button-primary"
98
+ [attr.aria-label]="g.LABEL_START_NW_CONV"
99
+ (click)="openNewConversation()"
100
+ [ngStyle]="{'background-color': g.themeColor, 'border-color': g.themeColor, 'color': g.themeForegroundColor }">
94
101
  <span class="v-align-center">
95
- <svg [ngStyle]="{'fill': 'yellow' }" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24">
102
+ <svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24">
96
103
  <path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" [ngStyle]="{'fill': g.themeForegroundColor}"/>
97
104
  </svg>
98
- <!-- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 20 20" width="20" height="20" style="enable-background:new 0 0 20 20;" xml:space="preserve" >
99
- <path d="M16.3,10.9h-5.4v5.4H9.1v-5.4H3.7V9.1h5.4V3.7h1.8v5.4h5.4V10.9z" [ngStyle]="{'fill': g.themeForegroundColor}"/>
100
- </svg> -->
101
105
  </span>
102
106
  <span class="v-align-center c21-label-button">
103
107
  <!-- {{LABEL_START_NW_CONV}} -->
@@ -31,6 +31,9 @@
31
31
  padding: 0px 5px;
32
32
  float: right;
33
33
  fill: var(--blue);
34
+ color: var(--dark-gray);
35
+ font-weight: 300;
36
+ align-items: center;
34
37
  button {
35
38
  width: 40px;
36
39
  height: 40px;
@@ -1,59 +1,235 @@
1
- import { CustomTranslateService } from './../../../chat21-core/providers/custom-translate.service';
2
- import { TranslatorService } from './../../providers/translator.service';
3
- import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
4
- import { AppConfigService } from './../../providers/app-config.service';
5
- import { WaitingService } from './../../providers/waiting.service';
6
- import { ChatManager } from './../../../chat21-core/providers/chat-manager';
7
- import { Globals } from './../../utils/globals';
8
1
  import { NO_ERRORS_SCHEMA } from '@angular/core';
9
- import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
3
+ import { By } from '@angular/platform-browser';
4
+ import { of, Subscription } from 'rxjs';
10
5
 
11
- import { HomeConversationsComponent } from './home-conversations.component';
12
- import { ImageRepoService } from '../../../chat21-core/providers/abstract/image-repo.service';
13
- import { ConversationsHandlerService } from '../../../chat21-core/providers/abstract/conversations-handler.service';
14
- import { ArchivedConversationsHandlerService } from '../../../chat21-core/providers/abstract/archivedconversations-handler.service';
15
- import { TranslateModule } from '@ngx-translate/core';
16
- import { NGXLogger } from 'ngx-logger';
6
+ import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service';
7
+ import { TranslatorService } from 'src/app/providers/translator.service';
8
+ import { ChatManager } from 'src/chat21-core/providers/chat-manager';
9
+ import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service';
17
10
  import { CustomLogger } from 'src/chat21-core/providers/logger/customLogger';
18
11
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
12
+ import { ConversationModel } from 'src/chat21-core/models/conversation';
13
+ import { UserAgent } from 'src/models/userAgent';
14
+
15
+ import { WaitingService } from 'src/app/providers/waiting.service';
16
+ import { Globals } from '../../utils/globals';
17
+ import { HomeConversationsComponent } from './home-conversations.component';
19
18
 
20
19
  describe('HomeConversationsComponent', () => {
21
20
  let component: HomeConversationsComponent;
22
21
  let fixture: ComponentFixture<HomeConversationsComponent>;
23
- let ngxlogger: NGXLogger;
24
- let customLogger = new CustomLogger(ngxlogger)
25
-
22
+ let globals: Globals;
23
+ const ngxlogger = jasmine.createSpyObj('NGXLogger', ['log', 'trace', 'debug', 'warn', 'error', 'info']);
24
+
25
+ const waitingStub = {
26
+ getCurrent: jasmine.createSpy('getCurrent').and.returnValue(of([{ waiting_time_avg: 45000 }])),
27
+ };
28
+
29
+ const imageRepoStub = {
30
+ getImagePhotoUrl: jasmine.createSpy('getImagePhotoUrl').and.returnValue('https://cdn.example/photo.png'),
31
+ checkImageExists: jasmine.createSpy('checkImageExists'),
32
+ };
33
+
34
+ const translateStub = {
35
+ translateLanguage: jasmine.createSpy('translateLanguage').and.callFake((keys: string[]) => {
36
+ const m = new Map<string, string>();
37
+ keys.forEach((k) => m.set(k, `T:${k}`));
38
+ return m;
39
+ }),
40
+ };
41
+
26
42
  beforeEach(waitForAsync(() => {
43
+ LoggerInstance.setInstance(new CustomLogger(ngxlogger));
27
44
  TestBed.configureTestingModule({
28
- declarations: [HomeConversationsComponent],
29
- schemas: [NO_ERRORS_SCHEMA],
30
- imports: [TranslateModule.forRoot()],
31
- providers: [
45
+ declarations: [HomeConversationsComponent],
46
+ schemas: [NO_ERRORS_SCHEMA],
47
+ providers: [
32
48
  Globals,
33
- ImageRepoService,
34
- ChatManager,
35
- ConversationsHandlerService,
36
- ArchivedConversationsHandlerService,
37
- WaitingService,
38
- AppConfigService,
39
- TranslatorService,
40
- CustomTranslateService,
41
- provideHttpClient(withInterceptorsFromDi())
42
- ]
43
- })
44
- .compileComponents();
49
+ { provide: ImageRepoService, useValue: imageRepoStub },
50
+ { provide: ChatManager, useValue: {} },
51
+ { provide: TranslatorService, useValue: { getLanguage: () => 'en' } },
52
+ { provide: CustomTranslateService, useValue: translateStub },
53
+ { provide: WaitingService, useValue: waitingStub },
54
+ ],
55
+ }).compileComponents();
45
56
  }));
46
57
 
47
58
  beforeEach(() => {
59
+ globals = TestBed.inject(Globals);
60
+ globals.initDefafultParameters();
61
+ globals.projectid = 'proj-1';
62
+ globals.WAITING_TIME_FOUND = 'Tempo stimato $reply_time';
63
+ globals.dynamicWaitTimeReply = true;
64
+ globals.showWaitTime = true;
65
+ globals.PREV_CONVERSATIONS = 'Le tue conversazioni';
66
+ globals.NO_CONVERSATION = 'Nessuna';
67
+ globals.SHOW_ALL_CONV = 'Vedi tutte';
68
+ globals.LABEL_START_NW_CONV = 'Nuova';
69
+ globals.themeColor = '#00f';
70
+ globals.themeForegroundColor = '#fff';
71
+ globals.showAllConversations = true;
72
+ globals.showAvailableAgents = false;
73
+ globals.availableAgents = [{ id: 'a1', firstname: 'Ada', imageurl: '' } as UserAgent];
74
+
48
75
  fixture = TestBed.createComponent(HomeConversationsComponent);
49
76
  component = fixture.componentInstance;
50
- LoggerInstance.setInstance(customLogger)
51
- let logger = LoggerInstance.getInstance()
52
- component['logger']= logger
77
+ component.stylesMap = new Map();
78
+ component.listConversations = [];
79
+ component.archivedConversations = [];
80
+ component.hideNewConversationButton = false;
81
+
53
82
  fixture.detectChanges();
54
83
  });
55
84
 
56
85
  it('should create', () => {
57
86
  expect(component).toBeTruthy();
58
87
  });
88
+
89
+ describe('initialize and waiting time', () => {
90
+ it('should load translations and agent image URLs', () => {
91
+ expect(translateStub.translateLanguage).toHaveBeenCalled();
92
+ expect(imageRepoStub.getImagePhotoUrl).toHaveBeenCalledWith('a1');
93
+ expect(component.availableAgents.length).toBe(1);
94
+ });
95
+
96
+ it('should set waitingTime and placeholder when API returns averages', fakeAsync(() => {
97
+ tick(0);
98
+ expect(waitingStub.getCurrent).toHaveBeenCalledWith('proj-1');
99
+ expect(component.waitingTime).toBe(45000);
100
+ expect(component.humanWaitingTime).toBeTruthy();
101
+ expect(component.WAITING_TIME_FOUND_WITH_REPLYTIME_PLACEHOLDER).toContain(component.humanWaitingTime);
102
+ }));
103
+
104
+ it('should render root container id', () => {
105
+ const root = fixture.debugElement.query(By.css('#c21-app-list-conversations'));
106
+ expect(root).toBeTruthy();
107
+ });
108
+ });
109
+
110
+ /** Allineato a twp/index + tiledesk_open: lista vuota, CTA primaria, footer tempo attesa */
111
+ describe('empty state UI (widget integration)', () => {
112
+ beforeEach(() => {
113
+ globals.NO_CONVERSATION = 'Nessuna conversazione attiva';
114
+ globals.LABEL_START_NW_CONV = 'Nuova conversazione';
115
+ globals.showAvailableAgents = false;
116
+ globals.availableAgents = [{ id: 'solo', firstname: 'Ada', imageurl: 'https://cdn.example/photo.png' } as UserAgent];
117
+ component.listConversations = [];
118
+ component.archivedConversations = [];
119
+ fixture.detectChanges();
120
+ });
121
+
122
+ it('should show NO_CONVERSATION title in header when both lists are empty', () => {
123
+ const titleEl = fixture.nativeElement.querySelector('.c21-header .c21-title') as HTMLElement;
124
+ expect(titleEl.textContent?.trim()).toBe('Nessuna conversazione attiva');
125
+ });
126
+
127
+ it('should render primary new-conversation button with theme label and paper-plane icon', () => {
128
+ const btn = fixture.nativeElement.querySelector('.c21-new-conversation .c21-button-primary') as HTMLButtonElement;
129
+ expect(btn).toBeTruthy();
130
+ expect(btn.getAttribute('aria-label')).toBe('Nuova conversazione');
131
+ expect(btn.textContent).toContain('Nuova conversazione');
132
+ expect(btn.querySelector('svg')).toBeTruthy();
133
+ });
134
+
135
+ it('should surface waiting footer copy when showWaitTime and API returned average', fakeAsync(() => {
136
+ tick(0);
137
+ fixture.detectChanges();
138
+ const footer = fixture.nativeElement.querySelector('.c21-footer .c21-waiting-time') as HTMLElement;
139
+ expect(footer).toBeTruthy();
140
+ expect(footer.textContent).toContain(component.humanWaitingTime);
141
+ }));
142
+ });
143
+
144
+ describe('checkShowAllConversation', () => {
145
+ it('should return true when archived list has items', () => {
146
+ component.archivedConversations = [{ uid: 'x' } as ConversationModel];
147
+ expect(component.checkShowAllConversation()).toBe(true);
148
+ });
149
+
150
+ it('should return true when active list has items', () => {
151
+ component.archivedConversations = [];
152
+ component.listConversations = [{ uid: 'y' } as ConversationModel];
153
+ expect(component.checkShowAllConversation()).toBe(true);
154
+ });
155
+
156
+ it('should return false when both lists are empty', () => {
157
+ component.archivedConversations = [];
158
+ component.listConversations = [];
159
+ expect(component.checkShowAllConversation()).toBe(false);
160
+ });
161
+ });
162
+
163
+ describe('outputs and selection', () => {
164
+ it('openNewConversation should emit onNewConversation', () => {
165
+ spyOn(component.onNewConversation, 'emit');
166
+ component.openNewConversation();
167
+ expect(component.onNewConversation.emit).toHaveBeenCalled();
168
+ });
169
+
170
+ it('returnOpenAllConversation should emit onOpenAllConvesations', () => {
171
+ spyOn(component.onOpenAllConvesations, 'emit');
172
+ component.returnOpenAllConversation();
173
+ expect(component.onOpenAllConvesations.emit).toHaveBeenCalled();
174
+ });
175
+
176
+ it('onConversationSelectedFN should emit when conversation is defined', () => {
177
+ spyOn(component.onConversationSelected, 'emit');
178
+ const c = { uid: 'c1' } as ConversationModel;
179
+ component.onConversationSelectedFN(c);
180
+ expect(component.onConversationSelected.emit).toHaveBeenCalledWith(c);
181
+ });
182
+
183
+ it('onConversationSelectedFN should not emit for falsy conversation', () => {
184
+ spyOn(component.onConversationSelected, 'emit');
185
+ component.onConversationSelectedFN(null as any);
186
+ expect(component.onConversationSelected.emit).not.toHaveBeenCalled();
187
+ });
188
+
189
+ it('onImageLoadedFN / onConversationLoadedFN should forward', () => {
190
+ spyOn(component.onImageLoaded, 'emit');
191
+ spyOn(component.onConversationLoaded, 'emit');
192
+ const c = { uid: 'z' } as ConversationModel;
193
+ component.onImageLoadedFN(c);
194
+ component.onConversationLoadedFN(c);
195
+ expect(component.onImageLoaded.emit).toHaveBeenCalledWith(c);
196
+ expect(component.onConversationLoaded.emit).toHaveBeenCalledWith(c);
197
+ });
198
+ });
199
+
200
+ describe('agent image map', () => {
201
+ it('isImageLoaded should be false without url or before load', () => {
202
+ const agent = { id: 'x2', firstname: 'B', imageurl: '' } as UserAgent;
203
+ expect(component.isImageLoaded(agent)).toBe(false);
204
+ });
205
+
206
+ it('onImageLoad should mark agent as loaded', () => {
207
+ const agent = { id: 'x3', imageurl: 'https://x' } as UserAgent;
208
+ component.onImageLoad(agent);
209
+ expect(component.isImageLoaded(agent)).toBe(true);
210
+ });
211
+
212
+ it('onImageError should mark agent as not loaded', () => {
213
+ const agent = { id: 'x4', imageurl: 'https://x' } as UserAgent;
214
+ component.onImageError(agent);
215
+ expect(component.imageLoadedMap.get('x4')).toBe(false);
216
+ });
217
+ });
218
+
219
+ describe('ngOnDestroy and unsubscribe', () => {
220
+ it('unsubscribe should clear subscription list', () => {
221
+ const sub = new Subscription();
222
+ spyOn(sub, 'unsubscribe');
223
+ component.subscriptions.push(sub);
224
+ component.unsubscribe();
225
+ expect(sub.unsubscribe).toHaveBeenCalled();
226
+ expect(component.subscriptions.length).toBe(0);
227
+ });
228
+
229
+ it('ngOnDestroy should call unsubscribe', () => {
230
+ spyOn(component, 'unsubscribe');
231
+ component.ngOnDestroy();
232
+ expect(component.unsubscribe).toHaveBeenCalled();
233
+ });
234
+ });
59
235
  });