@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,6 +1,10 @@
1
- import { async, ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
1
+ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2
2
  import { By } from '@angular/platform-browser';
3
- import { MSG_STATUS_SENT } from 'src/chat21-core/utils/constants';
3
+ import {
4
+ MSG_STATUS_RETURN_RECEIPT,
5
+ MSG_STATUS_SENT,
6
+ MSG_STATUS_SENT_SERVER,
7
+ } from 'src/app/utils/constants';
4
8
 
5
9
  import { ReturnReceiptComponent } from './return-receipt.component';
6
10
 
@@ -10,31 +14,48 @@ describe('ReturnReceiptComponent', () => {
10
14
 
11
15
  beforeEach(waitForAsync(() => {
12
16
  TestBed.configureTestingModule({
13
- declarations: [ ReturnReceiptComponent ]
14
- })
15
- .compileComponents();
17
+ declarations: [ReturnReceiptComponent],
18
+ }).compileComponents();
16
19
  }));
17
20
 
18
21
  beforeEach(() => {
19
22
  fixture = TestBed.createComponent(ReturnReceiptComponent);
20
23
  component = fixture.componentInstance;
21
- fixture.detectChanges();
22
24
  });
23
25
 
24
26
  it('should create', () => {
27
+ fixture.detectChanges();
25
28
  expect(component).toBeTruthy();
26
29
  });
27
30
 
28
- it('shold render MSG_STATUS_SENT icon', ()=> {
29
- component.status= MSG_STATUS_SENT
31
+ it('should render schedule icon when status is falsy', () => {
32
+ component.status = 0 as any;
33
+ fixture.detectChanges();
34
+ const icons = fixture.debugElement.queryAll(By.css('.icon'));
35
+ expect(icons.length).toBe(1);
36
+ });
37
+
38
+ it('should render sent icon for MSG_STATUS_SENT', () => {
39
+ component.status = MSG_STATUS_SENT;
40
+ fixture.detectChanges();
41
+ expect(fixture.debugElement.queryAll(By.css('.icon')).length).toBe(1);
42
+ });
43
+
44
+ it('should render server-sent icon for MSG_STATUS_SENT_SERVER', () => {
45
+ component.status = MSG_STATUS_SENT_SERVER;
46
+ fixture.detectChanges();
47
+ expect(fixture.debugElement.queryAll(By.css('.icon')).length).toBe(1);
48
+ });
49
+
50
+ it('should render return receipt icon for MSG_STATUS_RETURN_RECEIPT', () => {
51
+ component.status = MSG_STATUS_RETURN_RECEIPT;
30
52
  fixture.detectChanges();
31
- expect(component.status).toBe(MSG_STATUS_SENT)
32
- })
33
-
34
- // it('shold render MSG_STATUS_SENT icon', ()=> {
35
- // component.status= MSG_STATUS_SENT
36
- // fixture.detectChanges();
37
- // let element = fixture.debugElement.query(By.css('icon'))
38
- // expect(element.classes).toBeE('icon')
39
- // })
53
+ expect(fixture.debugElement.queryAll(By.css('.icon')).length).toBe(1);
54
+ });
55
+
56
+ it('should expose status constants on component', () => {
57
+ expect(component.MSG_STATUS_SENT).toBe(MSG_STATUS_SENT);
58
+ expect(component.MSG_STATUS_SENT_SERVER).toBe(MSG_STATUS_SENT_SERVER);
59
+ expect(component.MSG_STATUS_RETURN_RECEIPT).toBe(MSG_STATUS_RETURN_RECEIPT);
60
+ });
40
61
  });
@@ -1,3 +1,3 @@
1
- <p #messageEl class="message_innerhtml marked"
2
- [innerHTML]="printMessage(text, messageEl, this) | marked"
3
- [style.color]="color"></p>
1
+ <div #messageEl class="message_innerhtml marked"
2
+ [innerHTML]="printMessage(text, messageEl, this) | marked"
3
+ [style.color]="color"></div>
@@ -1,113 +1,107 @@
1
- // Shadow DOM styles - isolati dal resto dell'applicazione
2
1
  :host {
3
2
  display: block;
4
- // Le variabili CSS custom properties possono attraversare il boundary del Shadow DOM
5
3
  font-size: var(--font-size-bubble-message, 14px);
6
4
  }
7
5
 
8
6
  .message_innerhtml {
9
7
  margin: 0px;
10
- // padding: 0px 14px;
11
- &.marked{
8
+
9
+ &.marked {
12
10
  padding: 12px 16px;
13
- margin-block-start: 0em!important;
14
- margin-block-end: 0em!important;
11
+ margin-block-start: 0em !important;
12
+ margin-block-end: 0em !important;
15
13
  }
16
-
14
+
17
15
  .text-message {
18
16
  padding-top: 14px;
19
17
  }
20
- }
21
18
 
22
- p {
23
- font-size: inherit;
24
- margin: 0;
25
- // padding: 14px;
26
- line-height: 1.4em;
27
- font-style: normal;
28
- letter-spacing: normal;
29
- font-stretch: normal;
30
- font-variant: normal;
31
- font-weight: 300;
32
- overflow: hidden;
33
- }
19
+ p {
20
+ font-size: inherit;
21
+ margin: 0;
22
+ line-height: 1.4em;
23
+ font-style: normal;
24
+ letter-spacing: normal;
25
+ font-stretch: normal;
26
+ font-variant: normal;
27
+ font-weight: 300;
28
+ overflow: hidden;
29
+ }
34
30
 
35
- p ::ng-deep a,
36
- p a {
37
- word-break: break-word;
38
- color: inherit; // Eredita il colore dal parent
39
- text-decoration: underline;
40
- }
31
+ a {
32
+ word-break: break-word;
33
+ color: inherit;
34
+ text-decoration: underline;
35
+ }
41
36
 
42
- p ::ng-deep p,
43
- p a:hover{
44
- margin-block-end: 0em;
45
- margin-block-start: 0em;
46
- }
37
+ a:hover {
38
+ margin-block-end: 0em;
39
+ margin-block-start: 0em;
40
+ }
47
41
 
48
- p ol {
49
- margin-block-end: 0em;
50
- margin-block-start: 0em;
51
- padding-inline-start: 15px;
52
-
53
- li::before {
54
- content: "";
55
- font-size: 1.4em;
56
- vertical-align: middle;
42
+ ol {
43
+ margin-block-end: 0em;
44
+ margin-block-start: 0em;
45
+ padding-inline-start: 15px;
46
+
47
+ li::before {
48
+ content: "";
49
+ font-size: 1.4em;
50
+ vertical-align: middle;
51
+ }
57
52
  }
58
- }
59
53
 
60
- // Stili aggiuntivi per elementi markdown comuni
61
- p h1, p h2, p h3, p h4, p h5, p h6 {
62
- margin-block-start: 0.5em;
63
- margin-block-end: 0.5em;
64
- font-weight: bold;
65
- color: inherit; // Eredita il colore dal parent
66
- }
54
+ h1, h2, h3, h4, h5, h6 {
55
+ margin-block-start: 0.5em;
56
+ margin-block-end: 0.5em;
57
+ font-weight: bold;
58
+ color: inherit;
59
+ }
67
60
 
68
- .message_innerhtml.marked h1 {
69
- line-height: normal;
70
- }
61
+ &.marked h1 {
62
+ line-height: normal;
63
+ }
71
64
 
72
- p ul {
73
- margin-block-end: 0em;
74
- margin-block-start: 0em;
75
- padding-inline-start: 15px;
76
- }
65
+ ul {
66
+ margin-block-end: 0em;
67
+ margin-block-start: 0em;
68
+ padding-inline-start: 15px;
69
+ }
77
70
 
78
- p code {
79
- background-color: rgba(0, 0, 0, 0.05);
80
- padding: 2px 4px;
81
- border-radius: 3px;
82
- font-family: monospace;
83
- }
71
+ code {
72
+ background-color: rgba(0, 0, 0, 0.05);
73
+ padding: 2px 4px;
74
+ border-radius: 3px;
75
+ font-family: monospace;
76
+ }
84
77
 
85
- p pre {
86
- background-color: rgba(0, 0, 0, 0.05);
87
- padding: 10px;
88
- border-radius: 3px;
89
- overflow-x: auto;
90
- }
78
+ pre {
79
+ background-color: rgba(0, 0, 0, 0.05);
80
+ padding: 10px;
81
+ border-radius: 3px;
82
+ overflow-x: auto;
83
+ }
91
84
 
92
- p blockquote {
93
- border-left: 3px solid rgba(0, 0, 0, 0.1);
94
- padding-left: 10px;
95
- margin-left: 0;
96
- font-style: italic;
97
- }
85
+ blockquote {
86
+ border-left: 3px solid rgba(0, 0, 0, 0.1);
87
+ padding-left: 10px;
88
+ margin-left: 0;
89
+ font-style: italic;
90
+ }
98
91
 
99
- p table {
100
- border-collapse: collapse;
101
- width: 100%;
102
- margin: 10px 0;
103
- }
92
+ table {
93
+ border-collapse: collapse;
94
+ width: 100%;
95
+ margin: 10px 0;
96
+ }
104
97
 
105
- p table td, p table th {
106
- border: 1px solid rgba(0, 0, 0, 0.1);
107
- padding: 8px;
108
- }
98
+ table td, table th {
99
+ border: 1px solid rgba(0, 0, 0, 0.1);
100
+ padding: 8px;
101
+ }
109
102
 
110
- p table th {
111
- background-color: rgba(0, 0, 0, 0.05);
112
- font-weight: bold;
103
+ table th {
104
+ background-color: rgba(0, 0, 0, 0.05);
105
+ font-weight: bold;
106
+ }
113
107
  }
@@ -1,33 +1,126 @@
1
- import { HtmlEntitiesEncodePipe } from './../../../pipe/html-entities-encode.pipe';
2
- import { MarkedPipe } from './../../../pipe/marked.pipe';
3
- import { async, ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
1
+ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
4
2
 
3
+ import { MarkedPipe } from '../../../pipe/marked.pipe';
5
4
  import { TextComponent } from './text.component';
6
5
 
7
- describe('TextComponent', () => {
6
+ /**
7
+ * Il template usa solo `| marked` su ciò che ritorna `printMessage(...)`:
8
+ * `[innerHTML]="printMessage(text, messageEl, this) | marked"`
9
+ * I test qui riproducono gli stessi use case (XSS / HTML grezzo / markdown) sulla pipeline reale del componente.
10
+ */
11
+ describe('TextComponent (render via MarkedPipe)', () => {
8
12
  let component: TextComponent;
9
13
  let fixture: ComponentFixture<TextComponent>;
14
+ let markedPipe: MarkedPipe;
15
+
16
+ function shadowInnerHtml(): string {
17
+ const host = fixture.nativeElement as HTMLElement;
18
+ const root = host.shadowRoot;
19
+ if (!root) {
20
+ throw new Error('Expected ShadowDom root');
21
+ }
22
+ return (root.querySelector('.message_innerhtml') as HTMLElement).innerHTML;
23
+ }
10
24
 
11
25
  beforeEach(waitForAsync(() => {
12
26
  TestBed.configureTestingModule({
13
- declarations: [
14
- TextComponent,
15
- MarkedPipe,
16
- HtmlEntitiesEncodePipe
17
- ]
18
- })
19
- .compileComponents();
27
+ declarations: [TextComponent, MarkedPipe],
28
+ }).compileComponents();
20
29
  }));
21
30
 
22
31
  beforeEach(() => {
23
32
  fixture = TestBed.createComponent(TextComponent);
24
33
  component = fixture.componentInstance;
25
- component.text = 'Msg text'
26
- component.color= 'black'
34
+ markedPipe = new MarkedPipe();
35
+ component.text = 'Msg text';
36
+ component.color = 'black';
27
37
  fixture.detectChanges();
28
38
  });
29
39
 
30
40
  it('should create', () => {
31
41
  expect(component).toBeTruthy();
32
42
  });
43
+
44
+ it('printMessage should emit before and after and return text (input grezzo per la pipe)', () => {
45
+ spyOn(component.onBeforeMessageRender, 'emit');
46
+ spyOn(component.onAfterMessageRender, 'emit');
47
+ const out = component.printMessage('Hello', {} as any, component);
48
+ expect(out).toBe('Hello');
49
+ expect(component.onBeforeMessageRender.emit).toHaveBeenCalled();
50
+ expect(component.onAfterMessageRender.emit).toHaveBeenCalled();
51
+ });
52
+
53
+ it('should render message container with color style', () => {
54
+ const host = fixture.nativeElement as HTMLElement;
55
+ const el = host.shadowRoot!.querySelector('div.message_innerhtml') as HTMLElement;
56
+ expect(el).toBeTruthy();
57
+ expect(el.style.color).toBe('black');
58
+ });
59
+
60
+ describe('markdown (use case contenuto legittimo)', () => {
61
+ it('should render heading and bold from markdown', () => {
62
+ component.text = '# Title\n\n**Bold**';
63
+ fixture.detectChanges();
64
+ const html = shadowInnerHtml();
65
+ expect(html).toMatch(/<h1|<h2/i);
66
+ expect(html).toMatch(/<strong>|<b>/i);
67
+ });
68
+
69
+ it('should render unordered list from markdown', () => {
70
+ component.text = '- uno\n- due';
71
+ fixture.detectChanges();
72
+ const html = shadowInnerHtml();
73
+ expect(html).toMatch(/<ul/i);
74
+ expect(html).toMatch(/<li/i);
75
+ });
76
+
77
+ it('should render safe https link with rel=noopener (MarkedPipe renderer)', () => {
78
+ component.text = '[label](https://example.com/path)';
79
+ fixture.detectChanges();
80
+ const html = shadowInnerHtml();
81
+ expect(html).toContain('https://example.com/path');
82
+ expect(html).toContain('rel="noopener noreferrer"');
83
+ expect(html).toContain('target="_blank"');
84
+ });
85
+ });
86
+
87
+ describe('sicurezza / anti code-injection (stesso use case, solo marked)', () => {
88
+ it('should not leave raw script tags in DOM innerHTML', () => {
89
+ component.text = '<script>alert(1)</script>testo';
90
+ fixture.detectChanges();
91
+ const html = shadowInnerHtml();
92
+ expect(html.toLowerCase()).not.toContain('<script');
93
+ expect(html).toContain('&lt;');
94
+ });
95
+
96
+ it('should escape inline HTML img/onerror so it is not a live <img> node', () => {
97
+ component.text = 'Hi <img src=x onerror="alert(1)">';
98
+ fixture.detectChanges();
99
+ const html = shadowInnerHtml();
100
+ expect(html.toLowerCase()).not.toContain('<img');
101
+ expect(html).toContain('&lt;');
102
+ });
103
+
104
+ it('should not emit javascript: href for markdown link', () => {
105
+ component.text = '[bad](javascript:void(0))';
106
+ fixture.detectChanges();
107
+ const html = shadowInnerHtml();
108
+ expect(html).not.toMatch(/href=["']javascript:/i);
109
+ });
110
+
111
+ it('should not emit data: href for markdown link', () => {
112
+ component.text = '[bad](data:text/html,<script>alert(1)</script>)';
113
+ fixture.detectChanges();
114
+ const html = shadowInnerHtml();
115
+ expect(html).not.toMatch(/href=["']data:/i);
116
+ });
117
+
118
+ it('DOM innerHTML should match MarkedPipe applied to printMessage output (stessa pipeline del template)', () => {
119
+ component.text = 'Line1\n\n**x**';
120
+ fixture.detectChanges();
121
+ const raw = component.printMessage(component.text, {} as any, component);
122
+ const viaPipe = markedPipe.transform(raw) as string;
123
+ expect(shadowInnerHtml()).toBe(viaPipe);
124
+ });
125
+ });
33
126
  });
@@ -1,33 +1,154 @@
1
- import { ActionButtonComponent } from './../message/buttons/action-button/action-button.component';
2
- import { TextButtonComponent } from './../message/buttons/text-button/text-button.component';
3
- import { LinkButtonComponent } from './../message/buttons/link-button/link-button.component';
4
- import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
1
+ import { CommonModule } from '@angular/common';
2
+ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
3
+ import { By } from '@angular/platform-browser';
4
+
5
+ import { MessageModel } from 'src/chat21-core/models/message';
6
+ import { ActionButtonComponent } from '../message/buttons/action-button/action-button.component';
7
+ import { LinkButtonComponent } from '../message/buttons/link-button/link-button.component';
8
+ import { TextButtonComponent } from '../message/buttons/text-button/text-button.component';
5
9
 
6
10
  import { MessageAttachmentComponent } from './message-attachment.component';
7
11
 
12
+ function makeMessageWithAttachment(buttons: any[]): MessageModel {
13
+ return new MessageModel(
14
+ 'm1',
15
+ 'it',
16
+ 'r1',
17
+ 'Recipient',
18
+ 's1',
19
+ 'Sender',
20
+ 200,
21
+ {},
22
+ 'testo',
23
+ Date.now(),
24
+ 'text',
25
+ {
26
+ attachment: {
27
+ type: 'template',
28
+ buttons,
29
+ },
30
+ },
31
+ 'chat',
32
+ true,
33
+ false,
34
+ );
35
+ }
36
+
8
37
  describe('MessageAttachmentComponent', () => {
9
38
  let component: MessageAttachmentComponent;
10
39
  let fixture: ComponentFixture<MessageAttachmentComponent>;
11
40
 
12
41
  beforeEach(waitForAsync(() => {
13
42
  TestBed.configureTestingModule({
14
- declarations: [
15
- MessageAttachmentComponent,
16
- LinkButtonComponent,
17
- TextButtonComponent,
18
- ActionButtonComponent
19
- ]
20
- })
21
- .compileComponents();
43
+ imports: [CommonModule],
44
+ declarations: [
45
+ MessageAttachmentComponent,
46
+ LinkButtonComponent,
47
+ TextButtonComponent,
48
+ ActionButtonComponent,
49
+ ],
50
+ }).compileComponents();
22
51
  }));
23
52
 
24
53
  beforeEach(() => {
25
54
  fixture = TestBed.createComponent(MessageAttachmentComponent);
26
55
  component = fixture.componentInstance;
27
- fixture.detectChanges();
56
+ component.isConversationArchived = false;
57
+ component.isLastMessage = true;
58
+ component.fullscreenMode = false;
59
+ component.limit = 5;
60
+ component.stylesMap = new Map<string, string>([
61
+ ['buttonFontSize', '14px'],
62
+ ['buttonBackgroundColor', '#eee'],
63
+ ['buttonTextColor', '#111'],
64
+ ['buttonHoverBackgroundColor', '#ddd'],
65
+ ['buttonHoverTextColor', '#000'],
66
+ ]);
28
67
  });
29
68
 
30
69
  it('should create', () => {
70
+ component.message = makeMessageWithAttachment([]);
71
+ fixture.detectChanges();
31
72
  expect(component).toBeTruthy();
32
73
  });
74
+
75
+ it('getAttachmentButton should read type and buttons from message.attributes.attachment', () => {
76
+ component.message = makeMessageWithAttachment([
77
+ { type: 'text', value: 'OK' },
78
+ { type: 'url', value: 'Apri', link: 'https://example.com' },
79
+ ]);
80
+ component.ngOnInit();
81
+ expect(component.type).toBe('template');
82
+ expect((component.buttons as unknown as any[]).length).toBe(2);
83
+ });
84
+
85
+ it('should render text and url attachment buttons in DOM when isLastMessage is true for text', () => {
86
+ component.message = makeMessageWithAttachment([
87
+ { type: 'text', value: 'Conferma' },
88
+ { type: 'url', value: 'Vai', link: 'https://example.com', target: '_blank' },
89
+ ]);
90
+ fixture.detectChanges();
91
+ const root = fixture.nativeElement.querySelector('#buttons-in-message') as HTMLElement;
92
+ expect(root).toBeTruthy();
93
+ expect(fixture.nativeElement.querySelector('chat-text-button-attachment')).toBeTruthy();
94
+ expect(fixture.nativeElement.querySelector('chat-link-button-attachment')).toBeTruthy();
95
+ const textBtn = fixture.nativeElement.querySelector('chat-text-button-attachment .text') as HTMLElement;
96
+ expect(textBtn.textContent?.trim()).toContain('Conferma');
97
+ });
98
+
99
+ it('should respect limit via slice (only first button when limit is 1)', () => {
100
+ component.limit = 1;
101
+ component.message = makeMessageWithAttachment([
102
+ { type: 'text', value: 'A' },
103
+ { type: 'text', value: 'B' },
104
+ ]);
105
+ fixture.detectChanges();
106
+ const textButtons = fixture.nativeElement.querySelectorAll('chat-text-button-attachment');
107
+ expect(textButtons.length).toBe(1);
108
+ });
109
+
110
+ it('should hide text and action buttons when isLastMessage is false', () => {
111
+ component.isLastMessage = false;
112
+ component.message = makeMessageWithAttachment([
113
+ { type: 'text', value: 'Nascosto' },
114
+ { type: 'url', value: 'Visibile', link: 'https://x.com' },
115
+ ]);
116
+ fixture.detectChanges();
117
+ expect(fixture.nativeElement.querySelector('chat-text-button-attachment')).toBeNull();
118
+ expect(fixture.nativeElement.querySelector('chat-link-button-attachment')).toBeTruthy();
119
+ });
120
+
121
+ it('returnOnAttachmentButtonClicked should emit structured event when target exists', () => {
122
+ component.message = makeMessageWithAttachment([{ type: 'text', value: 'X' }]);
123
+ fixture.detectChanges();
124
+ spyOn(component.onAttachmentButtonClicked, 'emit');
125
+ const inner = fixture.debugElement.query(By.css('chat-text-button-attachment .text'));
126
+ inner.triggerEventHandler('click', {});
127
+ expect(component.onAttachmentButtonClicked.emit).toHaveBeenCalled();
128
+ const arg = (component.onAttachmentButtonClicked.emit as jasmine.Spy).calls.mostRecent().args[0];
129
+ expect(arg.message).toBe(component.message);
130
+ expect(arg.target).toBeTruthy();
131
+ });
132
+
133
+ it('returnOnAttachmentButtonClicked should not emit when event has no target', () => {
134
+ component.message = makeMessageWithAttachment([{ type: 'text', value: 'X' }]);
135
+ fixture.detectChanges();
136
+ spyOn(component.onAttachmentButtonClicked, 'emit');
137
+ component.returnOnAttachmentButtonClicked({} as any);
138
+ expect(component.onAttachmentButtonClicked.emit).not.toHaveBeenCalled();
139
+ });
140
+
141
+ it('ngAfterViewInit should emit onElementRendered for attachment', () => {
142
+ spyOn(component.onElementRendered, 'emit');
143
+ component.message = makeMessageWithAttachment([{ type: 'url', value: 'L', link: 'https://a' }]);
144
+ fixture.detectChanges();
145
+ component.ngAfterViewInit();
146
+ expect(component.onElementRendered.emit).toHaveBeenCalledWith({ element: 'attachment', status: true });
147
+ });
148
+
149
+ it('should render action button when type is action and isLastMessage', () => {
150
+ component.message = makeMessageWithAttachment([{ type: 'action', value: 'Azione', action: 'reply' }]);
151
+ fixture.detectChanges();
152
+ expect(fixture.nativeElement.querySelector('chat-action-button-attachment')).toBeTruthy();
153
+ });
33
154
  });
@@ -1,24 +1,25 @@
1
- <!-- <div id="chat21-modal-content modal-body"></div> -->
2
- <!-- tabindex="1200"-->
3
-
4
- <div id="chat21-selection-department"
1
+ <div id="chat21-selection-department"
5
2
  #afSelectionDepartment
6
- tabindex="1200"
3
+ role="dialog"
7
4
  aria-modal="true"
8
- onFocus="document.querySelector('[start-focus-chat21-selection-department]').focus()">
5
+ cdkTrapFocus
6
+ [cdkTrapFocusAutoCapture]="true"
7
+ [attr.aria-label]="g.LABEL_SELECT_TOPIC">
9
8
 
10
9
  <!-- HEADER -->
11
- <div class="c21-header" [ngStyle]="{'color': g.themeForegroundColor, 'background-image': g.colorGradient180 }" >
10
+ <div class="c21-header" [ngStyle]="{'color': g.themeForegroundColor, 'background-image': g.colorGradient180 }">
12
11
  <div class="c21-header-container">
13
12
 
14
- <!-- ICON CLOSE CHAT -->
13
+ <!-- ICON CLOSE PANEL -->
15
14
  <div class="c21-header-button">
16
- <div class="c21-close-button c21-small" role="button">
17
- <button tabindex="1210" aria-label=" chiudi pannello" class="c21-close-button-body" (click)="closePage()">
18
- <svg role="img" aria-labelledby="altIconTitle" xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewBox="0 0 24 24">
15
+ <div class="c21-close-button c21-small">
16
+ <button type="button"
17
+ [attr.aria-label]="g.BUTTON_CLOSE_TO_ICON || 'Close panel'"
18
+ class="c21-close-button-body"
19
+ (click)="closePage()">
20
+ <svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" width="20px" height="20px" viewBox="0 0 24 24">
19
21
  <path fill="none" d="M0 0h24v24H0V0z"/>
20
22
  <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"/>
21
- <!-- <title id="altIconTitle">{{BUTTON_CLOSE_CHAT}}</title> -->
22
23
  </svg>
23
24
  </button>
24
25
  </div>
@@ -26,9 +27,7 @@
26
27
 
27
28
  <!-- CONTENT HEADER -->
28
29
  <div class="c21-header-content">
29
- <!-- TITLE HEADER -->
30
30
  <div class="c21-title" [ngStyle]="{'color': g.themeForegroundColor}">
31
- <!-- <span>{{g.LABEL_SELECT_TOPIC}}</span> -->
32
31
  </div>
33
32
  </div>
34
33
 
@@ -40,15 +39,17 @@
40
39
  <div class="c21-body-container">
41
40
 
42
41
  <div class="c21-body-header">
43
- <div start-focus-chat21-selection-department tabindex="1201" class="c21-message-field">{{g.LABEL_SELECT_TOPIC}}</div>
42
+ <h2 start-focus-chat21-selection-department class="c21-message-field">{{g.LABEL_SELECT_TOPIC}}</h2>
44
43
  </div>
45
44
 
46
- <div class="c21-body-content" tabindex="211" onFocus="document.querySelector('[start-focus]').focus()">
45
+ <div class="c21-body-content">
47
46
  <ul class="chat21-content-modal-select">
48
47
  <li *ngFor="let department of departments; let i = index">
49
- <button tabindex="1202" class="c21-button-department c21-button-clean" (click)="onSelectDepartment(department)">
50
- <span class="chat21-badge">{{i+1}}</span>
51
- <span class="chat21-name-list" >{{department?.name}}</span>
48
+ <button type="button"
49
+ class="c21-button-department c21-button-clean"
50
+ (click)="onSelectDepartment(department)">
51
+ <span class="chat21-badge" aria-hidden="true">{{i+1}}</span>
52
+ <span class="chat21-name-list">{{department?.name}}</span>
52
53
  </button>
53
54
  </li>
54
55
  </ul>
@@ -56,7 +57,4 @@
56
57
 
57
58
  </div>
58
59
  </div>
59
-
60
- <span style="height:0px" tabindex="1299" onFocus="document.querySelector('[start-focus-chat21-selection-department]').focus()"></span>
61
- </div>
62
-
60
+ </div>