@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.
- package/.angular-mcp-cache/package.json +1 -0
- package/.cursor/angular18-accessibility-auditor-skill.md +442 -0
- package/.cursor/mcp.json +15 -0
- package/.github/workflows/playwright.yml +27 -0
- package/.playwright-mcp/console-2026-05-08T15-31-09-000Z.log +17 -0
- package/.playwright-mcp/console-2026-05-08T15-32-19-412Z.log +89 -0
- package/.playwright-mcp/console-2026-05-08T16-18-48-424Z.log +133 -0
- package/.playwright-mcp/console-2026-05-11T12-54-06-869Z.log +13 -0
- package/.playwright-mcp/console-2026-05-11T12-54-56-229Z.log +147 -0
- package/.playwright-mcp/console-2026-05-11T12-55-47-174Z.log +183 -0
- package/.playwright-mcp/console-2026-05-11T15-34-03-590Z.log +210 -0
- package/.playwright-mcp/console-2026-05-12T15-07-31-880Z.log +118 -0
- package/.playwright-mcp/page-2026-05-08T15-32-19-900Z.yml +851 -0
- package/.playwright-mcp/page-2026-05-08T15-32-47-264Z.yml +857 -0
- package/.playwright-mcp/page-2026-05-08T15-33-17-089Z.yml +1110 -0
- package/.playwright-mcp/page-2026-05-08T15-33-23-486Z.yml +1069 -0
- package/.playwright-mcp/page-2026-05-08T15-33-45-390Z.yml +1076 -0
- package/.playwright-mcp/page-2026-05-08T15-33-52-666Z.yml +1072 -0
- package/.playwright-mcp/page-2026-05-08T15-34-01-338Z.yml +1085 -0
- package/.playwright-mcp/page-2026-05-08T15-34-07-227Z.yml +1072 -0
- package/.playwright-mcp/page-2026-05-08T15-34-13-875Z.yml +1072 -0
- package/.playwright-mcp/page-2026-05-08T15-34-21-885Z.yml +1109 -0
- package/.playwright-mcp/page-2026-05-08T15-34-32-755Z.yml +1109 -0
- package/.playwright-mcp/page-2026-05-08T15-35-09-607Z.yml +1119 -0
- package/.playwright-mcp/page-2026-05-08T15-35-14-242Z.yml +1109 -0
- package/.playwright-mcp/page-2026-05-08T16-18-48-671Z.yml +44 -0
- package/.playwright-mcp/page-2026-05-08T16-18-52-753Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-19-13-919Z.yml +68 -0
- package/.playwright-mcp/page-2026-05-08T16-19-17-977Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-19-25-733Z.yml +120 -0
- package/.playwright-mcp/page-2026-05-08T16-19-29-252Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-19-39-269Z.yml +80 -0
- package/.playwright-mcp/page-2026-05-08T16-19-43-915Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-20-04-407Z.yml +81 -0
- package/.playwright-mcp/page-2026-05-08T16-20-08-984Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-20-32-397Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-20-58-658Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-21-12-320Z.yml +86 -0
- package/.playwright-mcp/page-2026-05-08T16-21-39-154Z.yml +91 -0
- package/.playwright-mcp/page-2026-05-08T16-21-45-420Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-22-21-062Z.yml +0 -0
- package/.playwright-mcp/page-2026-05-08T16-22-58-232Z.yml +91 -0
- package/.playwright-mcp/page-2026-05-08T16-23-36-520Z.yml +0 -0
- package/.playwright-mcp/page-2026-05-08T16-23-46-805Z.yml +100 -0
- package/.playwright-mcp/page-2026-05-08T16-23-55-169Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-24-26-574Z.yml +91 -0
- package/.playwright-mcp/page-2026-05-08T16-25-34-414Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-25-59-831Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-26-21-809Z.yml +91 -0
- package/.playwright-mcp/page-2026-05-08T16-26-47-443Z.yml +105 -0
- package/.playwright-mcp/page-2026-05-08T16-26-56-136Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-27-59-610Z.yml +48 -0
- package/.playwright-mcp/page-2026-05-11T12-54-07-180Z.yml +44 -0
- package/.playwright-mcp/page-2026-05-11T12-54-56-946Z.yml +4 -0
- package/.playwright-mcp/page-2026-05-11T12-55-47-503Z.yml +24 -0
- package/.playwright-mcp/page-2026-05-11T12-56-00-766Z.yml +28 -0
- package/.playwright-mcp/page-2026-05-11T12-56-06-438Z.yml +90 -0
- package/.playwright-mcp/page-2026-05-11T12-57-56-838Z.yml +106 -0
- package/.playwright-mcp/page-2026-05-11T12-58-00-124Z.yml +106 -0
- package/.playwright-mcp/page-2026-05-11T12-59-08-836Z.yml +61 -0
- package/.playwright-mcp/page-2026-05-11T12-59-12-088Z.yml +61 -0
- package/.playwright-mcp/page-2026-05-11T12-59-26-215Z.yml +69 -0
- package/.playwright-mcp/page-2026-05-11T12-59-29-519Z.yml +69 -0
- package/.playwright-mcp/page-2026-05-11T12-59-37-309Z.yml +0 -0
- package/.playwright-mcp/page-2026-05-11T12-59-39-968Z.yml +79 -0
- package/.playwright-mcp/page-2026-05-11T12-59-45-983Z.yml +78 -0
- package/.playwright-mcp/page-2026-05-11T12-59-49-951Z.yml +78 -0
- package/.playwright-mcp/page-2026-05-11T15-34-04-515Z.yml +0 -0
- package/.playwright-mcp/page-2026-05-12T15-07-32-171Z.yml +44 -0
- package/.playwright-mcp/page-2026-05-12T15-08-09-820Z.yml +119 -0
- package/CHANGELOG.md +54 -4
- package/angular.json +20 -3
- package/deploy_amazon_beta.sh +7 -17
- package/deploy_amazon_prod.sh +41 -0
- package/docs/TILEDESK_WIDGET_ACCESSIBILITY_STATEMENT_COMPLETE.md +379 -0
- package/env.sample +3 -2
- package/mocks/voice-websocket-mock/server.cjs +245 -0
- package/package.json +7 -3
- package/playwright-report/index.html +90 -0
- package/playwright.config.ts +41 -0
- package/src/app/app.component.html +2 -2
- package/src/app/app.component.scss +25 -14
- package/src/app/app.component.spec.ts +21 -6
- package/src/app/app.module.ts +4 -0
- package/src/app/component/conversation-detail/conversation/conversation.component.html +19 -11
- package/src/app/component/conversation-detail/conversation/conversation.component.scss +28 -0
- package/src/app/component/conversation-detail/conversation/conversation.component.spec.ts +644 -75
- package/src/app/component/conversation-detail/conversation/conversation.component.ts +61 -17
- package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.html +25 -13
- package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.spec.ts +123 -5
- package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.ts +1 -0
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.html +17 -7
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.scss +15 -3
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.spec.ts +249 -149
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.ts +0 -1
- package/src/app/component/conversation-detail/conversation-emojii/conversation-emojii.component.spec.ts +53 -3
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component copy.html +172 -0
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.html +112 -62
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.scss +133 -7
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.spec.ts +452 -78
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts +192 -84
- package/src/app/component/conversation-detail/conversation-header/conversation-header.component.html +113 -53
- package/src/app/component/conversation-detail/conversation-header/conversation-header.component.scss +12 -4
- package/src/app/component/conversation-detail/conversation-header/conversation-header.component.spec.ts +274 -29
- package/src/app/component/conversation-detail/conversation-internal-frame/conversation-internal-frame.component.html +23 -9
- package/src/app/component/conversation-detail/conversation-internal-frame/conversation-internal-frame.component.spec.ts +80 -8
- package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.html +29 -23
- package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.spec.ts +185 -16
- package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.ts +34 -14
- package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.html +43 -18
- package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.scss +56 -2
- package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.ts +135 -5
- package/src/app/component/error-alert/error-alert.component.spec.ts +65 -5
- package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.html +16 -7
- package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.scss +21 -0
- package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.spec.ts +89 -7
- package/src/app/component/form/form-builder/form-builder.component.html +1 -1
- package/src/app/component/form/form-builder/form-builder.component.spec.ts +163 -21
- package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.html +8 -4
- package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.scss +10 -5
- package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.spec.ts +90 -16
- package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.ts +26 -0
- package/src/app/component/form/inputs/form-label/form-label.component.spec.ts +45 -11
- package/src/app/component/form/inputs/form-radio-button/form-radio-button.component.spec.ts +24 -6
- package/src/app/component/form/inputs/form-select/form-select.component.spec.ts +14 -5
- package/src/app/component/form/inputs/form-text/form-text.component.html +14 -12
- package/src/app/component/form/inputs/form-text/form-text.component.scss +11 -1
- package/src/app/component/form/inputs/form-text/form-text.component.spec.ts +113 -17
- package/src/app/component/form/inputs/form-text/form-text.component.ts +26 -0
- package/src/app/component/form/inputs/form-textarea/form-textarea.component.html +13 -11
- package/src/app/component/form/inputs/form-textarea/form-textarea.component.scss +6 -5
- package/src/app/component/form/inputs/form-textarea/form-textarea.component.spec.ts +149 -13
- package/src/app/component/form/inputs/form-textarea/form-textarea.component.ts +26 -0
- package/src/app/component/form/prechat-form/prechat-form.component.html +14 -11
- package/src/app/component/form/prechat-form/prechat-form.component.spec.ts +102 -10
- package/src/app/component/form/prechat-form/prechat-form.component.ts +8 -1
- package/src/app/component/form/prechat-form-test-mock.ts +35 -0
- package/src/app/component/home/home.component.html +38 -31
- package/src/app/component/home/home.component.scss +4 -2
- package/src/app/component/home/home.component.spec.ts +226 -11
- package/src/app/component/home-conversations/home-conversations.component.html +30 -26
- package/src/app/component/home-conversations/home-conversations.component.scss +3 -0
- package/src/app/component/home-conversations/home-conversations.component.spec.ts +212 -36
- package/src/app/component/last-message/last-message.component.html +15 -9
- package/src/app/component/last-message/last-message.component.scss +16 -2
- package/src/app/component/last-message/last-message.component.spec.ts +204 -23
- package/src/app/component/launcher-button/launcher-button.component.html +8 -13
- package/src/app/component/launcher-button/launcher-button.component.spec.ts +104 -8
- package/src/app/component/list-all-conversations/list-all-conversations.component.html +12 -17
- package/src/app/component/list-all-conversations/list-all-conversations.component.scss +2 -0
- package/src/app/component/list-conversations/list-conversations.component.html +22 -22
- package/src/app/component/menu-options/menu-options.component.html +30 -20
- package/src/app/component/menu-options/menu-options.component.spec.ts +125 -9
- package/src/app/component/message/audio/audio.component.html +13 -15
- package/src/app/component/message/audio/audio.component.spec.ts +140 -5
- package/src/app/component/message/audio/audio.component.ts +1 -0
- package/src/app/component/message/audio-sync/audio-sync.component.scss +1 -0
- package/src/app/component/message/audio-sync/audio-sync.component.spec.ts +81 -1
- package/src/app/component/message/audio-sync/audio-sync.component.ts +133 -86
- package/src/app/component/message/avatar/avatar.component.html +2 -2
- package/src/app/component/message/avatar/avatar.component.spec.ts +99 -7
- package/src/app/component/message/bubble-message/bubble-message.component.html +39 -52
- package/src/app/component/message/bubble-message/bubble-message.component.scss +54 -1
- package/src/app/component/message/bubble-message/bubble-message.component.spec.ts +154 -57
- package/src/app/component/message/bubble-message/bubble-message.component.ts +138 -110
- package/src/app/component/message/buttons/action-button/action-button.component.html +3 -4
- package/src/app/component/message/buttons/action-button/action-button.component.spec.ts +49 -5
- package/src/app/component/message/buttons/link-button/link-button.component.scss +5 -8
- package/src/app/component/message/buttons/link-button/link-button.component.spec.ts +50 -5
- package/src/app/component/message/buttons/text-button/text-button.component.spec.ts +44 -5
- package/src/app/component/message/carousel/carousel.component.html +29 -16
- package/src/app/component/message/carousel/carousel.component.scss +20 -8
- package/src/app/component/message/carousel/carousel.component.spec.ts +80 -3
- package/src/app/component/message/carousel/carousel.component.ts +16 -0
- package/src/app/component/message/frame/frame.component.html +9 -4
- package/src/app/component/message/frame/frame.component.spec.ts +34 -15
- package/src/app/component/message/frame/frame.component.ts +7 -2
- package/src/app/component/message/html/html.component.html +1 -1
- package/src/app/component/message/html/html.component.scss +1 -1
- package/src/app/component/message/html/html.component.spec.ts +24 -7
- package/src/app/component/message/image/image.component.html +12 -10
- package/src/app/component/message/image/image.component.scss +16 -0
- package/src/app/component/message/image/image.component.spec.ts +101 -15
- package/src/app/component/message/image/image.component.ts +90 -51
- package/src/app/component/message/info-message/info-message.component.spec.ts +26 -14
- package/src/app/component/message/json-sources/json-sources.component.html +38 -0
- package/src/app/component/message/json-sources/json-sources.component.scss +197 -0
- package/src/app/component/message/json-sources/json-sources.component.ts +89 -0
- package/src/app/component/message/like-unlike/like-unlike.component.html +7 -9
- package/src/app/component/message/like-unlike/like-unlike.component.spec.ts +31 -3
- package/src/app/component/message/return-receipt/return-receipt.component.spec.ts +38 -17
- package/src/app/component/message/text/text.component.html +3 -3
- package/src/app/component/message/text/text.component.scss +80 -86
- package/src/app/component/message/text/text.component.spec.ts +106 -13
- package/src/app/component/message-attachment/message-attachment.component.spec.ts +134 -13
- package/src/app/component/selection-department/selection-department.component.html +21 -23
- package/src/app/component/selection-department/selection-department.component.spec.ts +159 -14
- package/src/app/component/selection-department/selection-department.component.ts +8 -1
- package/src/app/component/send-button/send-button.component.html +5 -13
- package/src/app/component/send-button/send-button.component.spec.ts +2 -2
- package/src/app/component/star-rating-widget/star-rating-widget.component.html +51 -81
- package/src/app/directives/tooltip.directive.spec.ts +8 -4
- package/src/app/modals/confirm-close/confirm-close.component.html +20 -8
- package/src/app/modals/confirm-close/confirm-close.component.scss +3 -0
- package/src/app/modals/confirm-close/confirm-close.component.spec.ts +13 -4
- package/src/app/modals/confirm-close/confirm-close.component.ts +8 -1
- package/src/app/pipe/html-entites-encode.pipe.spec.ts +35 -2
- package/src/app/pipe/marked.pipe.spec.ts +38 -2
- package/src/app/providers/app-config.service.ts +4 -2
- package/src/app/providers/brand.service.spec.ts +23 -2
- package/src/app/providers/brand.service.ts +1 -1
- package/src/app/providers/global-settings.service.spec.ts +1009 -14
- package/src/app/providers/global-settings.service.ts +30 -2
- package/src/app/providers/json-sources-parser.service.ts +182 -0
- package/src/app/providers/translator.service.ts +24 -6
- package/src/app/providers/tts-audio-playback-coordinator.service.spec.ts +117 -0
- package/src/app/providers/tts-audio-playback-coordinator.service.ts +39 -16
- package/src/app/providers/url-preview.service.ts +82 -0
- package/src/app/providers/voice/audio.types.ts +6 -0
- package/src/app/providers/voice/voice-streaming.service.spec.ts +23 -0
- package/src/app/providers/voice/voice-streaming.service.ts +710 -0
- package/src/app/providers/voice/voice-streaming.types.ts +113 -0
- package/src/app/providers/voice/voice.service.spec.ts +203 -3
- package/src/app/providers/voice/voice.service.ts +517 -13
- package/src/app/sass/_variables.scss +1 -1
- package/src/app/sass/animations.scss +19 -1
- package/src/app/utils/globals.ts +4 -0
- package/src/app/utils/json-sources-utils.ts +27 -0
- package/src/app/utils/url-utils.ts +98 -0
- package/src/app/utils/utils-resources.ts +1 -1
- package/src/assets/i18n/en.json +26 -1
- package/src/assets/i18n/es.json +106 -101
- package/src/assets/i18n/fr.json +106 -101
- package/src/assets/i18n/it.json +106 -99
- package/src/assets/twp/index-dev.html +18 -0
- package/src/assets/twp/tiledesk_widget_files/widget-css-override-example.css +14 -0
- package/src/chat21-core/providers/chat-manager.spec.ts +72 -0
- package/src/chat21-core/providers/scripts/script.service.spec.ts +12 -2
- package/src/chat21-core/utils/constants.ts +4 -0
- package/src/chat21-core/utils/utils-message.ts +23 -1
- package/src/widget-config-template.json +3 -1
- package/src/widget-config.json +28 -27
- package/test-results/.last-run.json +4 -0
- package/tests/widget-form-rich.spec.ts +67 -0
- package/tests/widget-index-dev-settings.spec.ts +52 -0
- package/tests/widget-twp-iframe.spec.ts +39 -0
|
@@ -1,49 +1,101 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { SimpleChange } from '@angular/core';
|
|
2
|
+
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
|
3
|
+
import { FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
+
import { provideHttpClientTesting } from '@angular/common/http/testing';
|
|
5
|
+
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
|
|
6
6
|
|
|
7
7
|
import { ConversationFooterComponent } from './conversation-footer.component';
|
|
8
|
-
import {
|
|
9
|
-
import { TypingService } from '
|
|
10
|
-
import {
|
|
11
|
-
import { ArchivedConversationsHandlerService } from '../../../../chat21-core/providers/abstract/archivedconversations-handler.service';
|
|
12
|
-
import { By } from '@angular/platform-browser';
|
|
13
|
-
import { NGXLogger } from 'ngx-logger';
|
|
14
|
-
import { CustomLogger } from 'src/chat21-core/providers/logger/customLogger';
|
|
8
|
+
import { ChatManager } from 'src/chat21-core/providers/chat-manager';
|
|
9
|
+
import { TypingService } from 'src/chat21-core/providers/abstract/typing.service';
|
|
10
|
+
import { UploadService } from 'src/chat21-core/providers/abstract/upload.service';
|
|
15
11
|
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
12
|
+
import { CustomLogger } from 'src/chat21-core/providers/logger/customLogger';
|
|
13
|
+
import { NGXLogger } from 'ngx-logger';
|
|
14
|
+
import { TYPE_MSG_TEXT } from 'src/chat21-core/utils/constants';
|
|
15
|
+
import { ConversationHandlerService } from 'src/chat21-core/providers/abstract/conversation-handler.service';
|
|
16
|
+
import { VoiceService } from 'src/app/providers/voice/voice.service';
|
|
17
|
+
import { TtsAudioPlaybackCoordinator } from 'src/app/providers/tts-audio-playback-coordinator.service';
|
|
18
|
+
import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service';
|
|
16
19
|
|
|
17
20
|
describe('ConversationFooterComponent', () => {
|
|
18
21
|
let component: ConversationFooterComponent;
|
|
19
22
|
let fixture: ComponentFixture<ConversationFooterComponent>;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
|
|
24
|
+
const ngxlogger = jasmine.createSpyObj('NGXLogger', ['log', 'trace', 'debug', 'warn', 'error', 'info']);
|
|
25
|
+
const customLogger = new CustomLogger(ngxlogger);
|
|
26
|
+
|
|
27
|
+
const voiceServiceMock = {
|
|
28
|
+
startSession: () => Promise.resolve(),
|
|
29
|
+
stopSession: () => Promise.resolve({ voiceIngressResultUrl: null as string | null }),
|
|
30
|
+
audioSegment$: { subscribe: () => ({ unsubscribe: () => undefined }) },
|
|
31
|
+
voiceTranscript$: { subscribe: () => ({ unsubscribe: () => undefined }) },
|
|
32
|
+
volume$: { subscribe: () => ({ unsubscribe: () => undefined }) },
|
|
33
|
+
isAcquisitionBlocked$: { subscribe: () => ({ unsubscribe: () => undefined }) },
|
|
34
|
+
};
|
|
35
|
+
const ttsMock = { stopAll: () => undefined, isTTSPlaying$: { subscribe: () => ({ unsubscribe: () => undefined }) } };
|
|
36
|
+
|
|
37
|
+
const conversationHandlerStub = {
|
|
38
|
+
sendMessage: jasmine.createSpy('sendMessage').and.returnValue({ uid: 'm1' }),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const chatManagerStub = {
|
|
42
|
+
getConversationHandlerByConversationId: jasmine
|
|
43
|
+
.createSpy('getConversationHandlerByConversationId')
|
|
44
|
+
.and.returnValue(conversationHandlerStub),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const typingStub = {
|
|
48
|
+
setTyping: jasmine.createSpy('setTyping'),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const uploadServiceStub = {
|
|
52
|
+
uploadFile: jasmine.createSpy('uploadFile'),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
beforeEach(async () => {
|
|
56
|
+
LoggerInstance.setInstance(customLogger);
|
|
57
|
+
|
|
58
|
+
await TestBed.configureTestingModule({
|
|
59
|
+
declarations: [ConversationFooterComponent],
|
|
60
|
+
imports: [FormsModule, ReactiveFormsModule],
|
|
61
|
+
providers: [
|
|
62
|
+
FormBuilder,
|
|
63
|
+
{ provide: ChatManager, useValue: chatManagerStub },
|
|
64
|
+
{ provide: TypingService, useValue: typingStub },
|
|
65
|
+
{ provide: UploadService, useValue: uploadServiceStub as unknown as UploadService },
|
|
66
|
+
{ provide: VoiceService, useValue: voiceServiceMock },
|
|
67
|
+
{ provide: TtsAudioPlaybackCoordinator, useValue: ttsMock },
|
|
68
|
+
{ provide: TiledeskAuthService, useValue: { getTiledeskToken: () => '' } },
|
|
69
|
+
provideHttpClient(withInterceptorsFromDi()),
|
|
70
|
+
provideHttpClientTesting(),
|
|
27
71
|
],
|
|
28
|
-
imports: [ FormsModule ],
|
|
29
|
-
providers: [
|
|
30
|
-
Globals,
|
|
31
|
-
ChatManager,
|
|
32
|
-
TypingService,
|
|
33
|
-
UploadService,
|
|
34
|
-
ConversationsHandlerService,
|
|
35
|
-
ArchivedConversationsHandlerService
|
|
36
|
-
]
|
|
37
72
|
})
|
|
38
|
-
|
|
39
|
-
|
|
73
|
+
.overrideComponent(ConversationFooterComponent, {
|
|
74
|
+
set: {
|
|
75
|
+
template: `
|
|
76
|
+
<textarea id="chat21-main-message-context" [(ngModel)]="textInputTextArea"></textarea>
|
|
77
|
+
<div id="chat21-button-send"></div>
|
|
78
|
+
<input id="chat21-file" type="file" />
|
|
79
|
+
`,
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
|
+
.compileComponents();
|
|
40
83
|
|
|
41
|
-
beforeEach(() => {
|
|
42
84
|
fixture = TestBed.createComponent(ConversationFooterComponent);
|
|
43
85
|
component = fixture.componentInstance;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
component
|
|
86
|
+
component.conversationWith = 'support-group-x';
|
|
87
|
+
component.senderId = 'user-1';
|
|
88
|
+
component.project = { id: 'proj-1' } as any;
|
|
89
|
+
component.channelType = 'group';
|
|
90
|
+
component.translationMap = new Map([
|
|
91
|
+
['GUEST_LABEL', 'Guest'],
|
|
92
|
+
['LABEL_PLACEHOLDER', 'Write…'],
|
|
93
|
+
]);
|
|
94
|
+
component.attributes = {} as any;
|
|
95
|
+
component.fileUploadAccept = '';
|
|
96
|
+
component.chat21_file = {
|
|
97
|
+
nativeElement: { value: '' },
|
|
98
|
+
} as any;
|
|
47
99
|
fixture.detectChanges();
|
|
48
100
|
});
|
|
49
101
|
|
|
@@ -51,54 +103,376 @@ describe('ConversationFooterComponent', () => {
|
|
|
51
103
|
expect(component).toBeTruthy();
|
|
52
104
|
});
|
|
53
105
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
106
|
+
describe('ngOnChanges', () => {
|
|
107
|
+
it('should load conversation handler when conversationWith changes', () => {
|
|
108
|
+
component.ngOnChanges({
|
|
109
|
+
conversationWith: new SimpleChange(undefined, 'support-group-x', true),
|
|
110
|
+
});
|
|
111
|
+
expect(chatManagerStub.getConversationHandlerByConversationId).toHaveBeenCalledWith('support-group-x');
|
|
112
|
+
expect(component.conversationHandlerService).toBe(conversationHandlerStub as unknown as ConversationHandlerService);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should call restoreTextArea when hideTextReply changes', () => {
|
|
116
|
+
const restore = spyOn(component as any, 'restoreTextArea');
|
|
117
|
+
component.ngOnChanges({
|
|
118
|
+
hideTextReply: new SimpleChange(false, true, false),
|
|
119
|
+
});
|
|
120
|
+
expect(restore).toHaveBeenCalled();
|
|
121
|
+
});
|
|
66
122
|
});
|
|
67
123
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
124
|
+
describe('ngAfterViewInit', () => {
|
|
125
|
+
it('should enable emoji picker flag', () => {
|
|
126
|
+
component.showEmojiPicker = false;
|
|
127
|
+
component.ngAfterViewInit();
|
|
128
|
+
expect(component.showEmojiPicker).toBe(true);
|
|
129
|
+
});
|
|
74
130
|
});
|
|
75
131
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
132
|
+
describe('sendMessage', () => {
|
|
133
|
+
beforeEach(() => {
|
|
134
|
+
component.textInputTextArea = ' hello ';
|
|
135
|
+
component.conversationHandlerService = conversationHandlerStub as any;
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should emit before/after and call handler when text is valid', () => {
|
|
139
|
+
spyOn(component.onBeforeMessageSent, 'emit');
|
|
140
|
+
spyOn(component.onAfterSendMessage, 'emit');
|
|
141
|
+
spyOn(component.onEmojiiPickerShow, 'emit');
|
|
142
|
+
component.sendMessage('Hi', TYPE_MSG_TEXT);
|
|
143
|
+
expect(component.onBeforeMessageSent.emit).toHaveBeenCalled();
|
|
144
|
+
expect(conversationHandlerStub.sendMessage).toHaveBeenCalled();
|
|
145
|
+
expect(component.onAfterSendMessage.emit).toHaveBeenCalled();
|
|
146
|
+
expect(component.onEmojiiPickerShow.emit).toHaveBeenCalledWith(false);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('should return early when emoji not allowed and text has emoji', () => {
|
|
150
|
+
component.showEmojiFooterButton = false;
|
|
151
|
+
component.textInputTextArea = '🙂';
|
|
152
|
+
const emitted = jasmine.createSpy();
|
|
153
|
+
component.onBeforeMessageSent.emit = emitted;
|
|
154
|
+
component.sendMessage('🙂', TYPE_MSG_TEXT);
|
|
155
|
+
expect(emitted).not.toHaveBeenCalled();
|
|
156
|
+
});
|
|
84
157
|
});
|
|
85
158
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
159
|
+
describe('uploadSingle observable success / error', () => {
|
|
160
|
+
beforeEach(() => {
|
|
161
|
+
component.conversationHandlerService = conversationHandlerStub as any;
|
|
162
|
+
component.chat21_file = { nativeElement: { value: '' } } as any;
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('should resolve upload and call sendMessage for image', fakeAsync(() => {
|
|
166
|
+
uploadServiceStub.uploadFile.and.resolveTo({
|
|
167
|
+
src: 'https://file',
|
|
168
|
+
downloadURL: 'https://dl',
|
|
169
|
+
});
|
|
170
|
+
const meta: any = { name: 'a.png', type: 'image/png', uid: 'u1' };
|
|
171
|
+
const file = new File(['x'], 'a.png', { type: 'image/png' });
|
|
172
|
+
spyOn(component, 'sendMessage').and.stub();
|
|
173
|
+
component.uploadSingle(meta, file, '');
|
|
174
|
+
tick();
|
|
175
|
+
expect(uploadServiceStub.uploadFile).toHaveBeenCalled();
|
|
176
|
+
expect(component.sendMessage).toHaveBeenCalled();
|
|
177
|
+
expect(component.isFilePendingToUpload).toBe(false);
|
|
178
|
+
}));
|
|
179
|
+
|
|
180
|
+
it('should handle upload rejection', fakeAsync(() => {
|
|
181
|
+
uploadServiceStub.uploadFile.and.rejectWith(new Error('net'));
|
|
182
|
+
const meta: any = { name: 'a.png', type: 'image/png', uid: 'u1' };
|
|
183
|
+
const file = new File(['x'], 'a.png', { type: 'image/png' });
|
|
184
|
+
component.uploadSingle(meta, file, '');
|
|
185
|
+
tick();
|
|
186
|
+
expect(component.isFilePendingToUpload).toBe(false);
|
|
187
|
+
}));
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
describe('onSendPressed', () => {
|
|
191
|
+
beforeEach(() => {
|
|
192
|
+
component.conversationHandlerService = conversationHandlerStub as any;
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('should ignore when emoji alert visible', () => {
|
|
196
|
+
component.showAlertEmoji = true;
|
|
197
|
+
spyOn(component, 'sendMessage');
|
|
198
|
+
component.onSendPressed({ preventDefault: jasmine.createSpy() } as any);
|
|
199
|
+
expect(component.sendMessage).not.toHaveBeenCalled();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('should send trimmed text message', () => {
|
|
203
|
+
component.showAlertEmoji = false;
|
|
204
|
+
component.isFilePendingToUpload = false;
|
|
205
|
+
component.textInputTextArea = 'abc';
|
|
206
|
+
spyOn(component, 'sendMessage').and.stub();
|
|
207
|
+
component.onSendPressed({ preventDefault: jasmine.createSpy() } as any);
|
|
208
|
+
expect(component.sendMessage).toHaveBeenCalledWith('abc', TYPE_MSG_TEXT);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
describe('checkForEmojii', () => {
|
|
213
|
+
it('should block when emoji disabled and text is emoji-only', () => {
|
|
214
|
+
component.showEmojiFooterButton = false;
|
|
215
|
+
expect(component.checkForEmojii('😀')).toBe(false);
|
|
216
|
+
expect(component.showAlertEmoji).toBe(true);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('should allow when emoji footer enabled', () => {
|
|
220
|
+
component.showEmojiFooterButton = true;
|
|
221
|
+
expect(component.checkForEmojii('😀')).toBe(true);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
describe('recording helpers', () => {
|
|
226
|
+
it('onStartRecording / onDeleteRecording / onEndRecording / onSendRecording should update flags', () => {
|
|
227
|
+
component.onStartRecording();
|
|
228
|
+
expect(component.isStartRec).toBe(true);
|
|
229
|
+
component.onDeleteRecording();
|
|
230
|
+
expect(component.isStartRec).toBe(false);
|
|
231
|
+
component.onEndRecording(new Blob());
|
|
232
|
+
expect(component.isStopRec).toBe(true);
|
|
233
|
+
uploadServiceStub.uploadFile.and.resolveTo({ src: '', downloadURL: '' });
|
|
234
|
+
spyOn(component, 'uploadSingle').and.stub();
|
|
235
|
+
component.onSendRecording(new Blob(['a'], { type: 'audio/webm' }));
|
|
236
|
+
expect(component.uploadSingle).toHaveBeenCalled();
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
describe('onEmojiiPickerClicked', () => {
|
|
241
|
+
it('should toggle emoji panel output', () => {
|
|
242
|
+
spyOn(component.onEmojiiPickerShow, 'emit');
|
|
243
|
+
component.isEmojiiPickerShow = false;
|
|
244
|
+
component.onEmojiiPickerClicked();
|
|
245
|
+
expect(component.onEmojiiPickerShow.emit).toHaveBeenCalledWith(true);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
describe('openNewConversation', () => {
|
|
250
|
+
it('should emit', () => {
|
|
251
|
+
spyOn(component.onNewConversationButtonClicked, 'emit');
|
|
252
|
+
component.openNewConversation();
|
|
253
|
+
expect(component.onNewConversationButtonClicked.emit).toHaveBeenCalled();
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
describe('reactive forms (pattern)', () => {
|
|
258
|
+
it('FormBuilder group validates required email-like field', () => {
|
|
259
|
+
const fb = TestBed.inject(FormBuilder);
|
|
260
|
+
const form = fb.group({
|
|
261
|
+
email: ['bad', []],
|
|
262
|
+
});
|
|
263
|
+
form.setValidators(() => null);
|
|
264
|
+
expect(form.value.email).toBe('bad');
|
|
265
|
+
form.patchValue({ email: 'user@test.com' });
|
|
266
|
+
expect(form.valid || form.value.email.includes('@')).toBe(true);
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
describe('setWritingMessages', () => {
|
|
271
|
+
it('should forward to TypingService', () => {
|
|
272
|
+
component.setWritingMessages('hi');
|
|
273
|
+
expect(typingStub.setTyping).toHaveBeenCalledWith(
|
|
274
|
+
'support-group-x',
|
|
275
|
+
'hi',
|
|
276
|
+
'user-1',
|
|
277
|
+
undefined,
|
|
278
|
+
);
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
describe('keyboard and paste handlers', () => {
|
|
283
|
+
it('onkeydown Enter should send non-empty text', () => {
|
|
284
|
+
const ta = document.getElementById('chat21-main-message-context') as HTMLTextAreaElement;
|
|
285
|
+
ta.value = 'hello';
|
|
286
|
+
spyOn(component, 'sendMessage');
|
|
287
|
+
const ev: any = { which: 13, keyCode: 13, preventDefault: jasmine.createSpy() };
|
|
288
|
+
component.onkeydown(ev);
|
|
289
|
+
expect(ev.preventDefault).toHaveBeenCalled();
|
|
290
|
+
expect(component.sendMessage).toHaveBeenCalledWith('hello', TYPE_MSG_TEXT);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it('onkeydown Tab should prevent default', () => {
|
|
294
|
+
const ev: any = { which: 9, keyCode: 9, preventDefault: jasmine.createSpy() };
|
|
295
|
+
component.onkeydown(ev);
|
|
296
|
+
expect(ev.preventDefault).toHaveBeenCalled();
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('onkeydown modifier+Enter should not send (browser newline)', () => {
|
|
300
|
+
spyOn(component, 'sendMessage');
|
|
301
|
+
const ev: any = {
|
|
302
|
+
which: 13,
|
|
303
|
+
keyCode: 13,
|
|
304
|
+
shiftKey: true,
|
|
305
|
+
preventDefault: jasmine.createSpy(),
|
|
306
|
+
};
|
|
307
|
+
component.onkeydown(ev);
|
|
308
|
+
expect(ev.preventDefault).not.toHaveBeenCalled();
|
|
309
|
+
expect(component.sendMessage).not.toHaveBeenCalled();
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('onkeydown Enter should not send when emoji alert is visible', () => {
|
|
313
|
+
const ta = document.getElementById('chat21-main-message-context') as HTMLTextAreaElement;
|
|
314
|
+
ta.value = 'x';
|
|
315
|
+
component.showAlertEmoji = true;
|
|
316
|
+
spyOn(component, 'sendMessage');
|
|
317
|
+
const ev: any = { which: 13, keyCode: 13, preventDefault: jasmine.createSpy() };
|
|
318
|
+
component.onkeydown(ev);
|
|
319
|
+
expect(ev.preventDefault).toHaveBeenCalled();
|
|
320
|
+
expect(component.sendMessage).not.toHaveBeenCalled();
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
describe('paste / drop', () => {
|
|
325
|
+
it('onPaste routes image clipboard items through detectFiles', () => {
|
|
326
|
+
const file = new File(['x'], 'paste.png', { type: 'image/png' });
|
|
327
|
+
const item = { type: 'image/png', getAsFile: () => file };
|
|
328
|
+
spyOn(component, 'detectFiles');
|
|
329
|
+
spyOn(component as any, 'restoreTextArea');
|
|
330
|
+
component.onPaste({
|
|
331
|
+
clipboardData: { items: [item] },
|
|
332
|
+
} as any);
|
|
333
|
+
expect(component.detectFiles).toHaveBeenCalled();
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it('onDrop forwards dataTransfer.files', () => {
|
|
337
|
+
spyOn(component, 'detectFiles');
|
|
338
|
+
const f = new File(['z'], 'drop.bin', { type: 'application/octet-stream' });
|
|
339
|
+
const dt = new DataTransfer();
|
|
340
|
+
dt.items.add(f);
|
|
341
|
+
component.onDrop({ dataTransfer: { files: dt.files } } as any);
|
|
342
|
+
expect(component.detectFiles).toHaveBeenCalled();
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
describe('detectFiles edge cases', () => {
|
|
347
|
+
it('should abort when MIME not accepted', () => {
|
|
348
|
+
component.fileUploadAccept = 'application/pdf';
|
|
349
|
+
const f = new File(['x'], 'a.png', { type: 'image/png' });
|
|
350
|
+
const dt = new DataTransfer();
|
|
351
|
+
dt.items.add(f);
|
|
352
|
+
const input = document.createElement('input');
|
|
353
|
+
Object.defineProperty(input, 'files', { value: dt.files });
|
|
354
|
+
component.detectFiles({ target: input });
|
|
355
|
+
expect(component.isFilePendingToUpload).toBe(false as any);
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
describe('loadFile size limit', () => {
|
|
360
|
+
it('should dispatch tooltip when file exceeds limit', () => {
|
|
361
|
+
spyOn(window, 'dispatchEvent');
|
|
362
|
+
component.arrayFilesLoad[0] = {
|
|
363
|
+
uid: 'u1',
|
|
364
|
+
file: { title: 'big.png', src: 'x', width: 1, height: 1 },
|
|
365
|
+
type: 'image/png',
|
|
366
|
+
size: 50 * 1024 * 1024,
|
|
367
|
+
} as any;
|
|
368
|
+
component.selectedFiles = { item: (i: number) => new File([], 'big.png') } as any;
|
|
369
|
+
component.loadFile();
|
|
370
|
+
expect(window.dispatchEvent).toHaveBeenCalled();
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
describe('Powered-by / analytics', () => {
|
|
375
|
+
it('managePoweredBy opens parent anchor href', () => {
|
|
376
|
+
const a = document.createElement('a');
|
|
377
|
+
a.setAttribute('href', 'https://example.test/logo');
|
|
378
|
+
const span = document.createElement('span');
|
|
379
|
+
a.appendChild(span);
|
|
380
|
+
spyOn(window, 'open');
|
|
381
|
+
window['analytics'] = {
|
|
382
|
+
page: jasmine.createSpy('page'),
|
|
383
|
+
identify: jasmine.createSpy('identify'),
|
|
384
|
+
track: jasmine.createSpy('track'),
|
|
385
|
+
};
|
|
386
|
+
const ev: any = {
|
|
387
|
+
stopPropagation: jasmine.createSpy(),
|
|
388
|
+
target: span,
|
|
389
|
+
};
|
|
390
|
+
component.managePoweredBy(ev);
|
|
391
|
+
expect(ev.stopPropagation).toHaveBeenCalled();
|
|
392
|
+
expect(window.open).toHaveBeenCalledWith('https://example.test/logo', '_blank');
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
describe('onSendPressed file branch', () => {
|
|
397
|
+
it('should call loadFile when upload pending', () => {
|
|
398
|
+
component.isFilePendingToUpload = true;
|
|
399
|
+
spyOn(component, 'loadFile');
|
|
400
|
+
component.onSendPressed({ preventDefault: jasmine.createSpy() } as any);
|
|
401
|
+
expect(component.loadFile).toHaveBeenCalled();
|
|
402
|
+
expect(component.isFilePendingToUpload).toBe(false as any);
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
describe('onTextAreaChange', () => {
|
|
407
|
+
it('should resize and set typing', () => {
|
|
408
|
+
component.textInputTextArea = 't';
|
|
409
|
+
spyOn(component, 'resizeInputField');
|
|
410
|
+
spyOn(component, 'setWritingMessages');
|
|
411
|
+
component.onTextAreaChange();
|
|
412
|
+
expect(component.resizeInputField).toHaveBeenCalled();
|
|
413
|
+
expect(component.setWritingMessages).toHaveBeenCalled();
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
describe('addEmoji', () => {
|
|
418
|
+
it('should append emoji when allowed', () => {
|
|
419
|
+
component.showEmojiFooterButton = true;
|
|
420
|
+
component.textInputTextArea = 'hi ';
|
|
421
|
+
spyOn(component.onEmojiiPickerShow, 'emit');
|
|
422
|
+
component.addEmoji({ emoji: { native: '⭐' } } as any);
|
|
423
|
+
expect(component.textInputTextArea).toContain('⭐');
|
|
424
|
+
expect(component.onEmojiiPickerShow.emit).toHaveBeenCalledWith(false);
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
describe('removeFocusOnId', () => {
|
|
429
|
+
it('should blur existing textarea', () => {
|
|
430
|
+
const ta = document.getElementById('chat21-main-message-context')!;
|
|
431
|
+
spyOn(ta, 'blur');
|
|
432
|
+
component.removeFocusOnId('chat21-main-message-context');
|
|
433
|
+
expect(ta.blur).toHaveBeenCalled();
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
describe('resizeInputField error handling', () => {
|
|
438
|
+
it('should swallow DOM errors from getElementById', () => {
|
|
439
|
+
const orig = document.getElementById.bind(document);
|
|
440
|
+
let throwOnce = true;
|
|
441
|
+
spyOn(document, 'getElementById').and.callFake((id: string) => {
|
|
442
|
+
if (id === 'chat21-main-message-context' && throwOnce) {
|
|
443
|
+
throwOnce = false;
|
|
444
|
+
throw new Error('dom');
|
|
445
|
+
}
|
|
446
|
+
return orig(id);
|
|
447
|
+
});
|
|
448
|
+
expect(() => component.resizeInputField()).not.toThrow();
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
describe('ngOnChanges dropEvent', () => {
|
|
453
|
+
it('should forward component.dropEvent to onDrop', () => {
|
|
454
|
+
const drop = new Event('drop');
|
|
455
|
+
component.dropEvent = drop as any;
|
|
456
|
+
spyOn(component, 'onDrop');
|
|
457
|
+
component.ngOnChanges({
|
|
458
|
+
dropEvent: new SimpleChange(undefined, drop, false),
|
|
459
|
+
});
|
|
460
|
+
expect(component.onDrop).toHaveBeenCalledWith(drop);
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
describe('uploadSingle audio branch', () => {
|
|
465
|
+
it('should send empty body for audio metadata', fakeAsync(() => {
|
|
466
|
+
uploadServiceStub.uploadFile.and.resolveTo({ src: 'https://a', downloadURL: 'https://a' });
|
|
467
|
+
component.conversationHandlerService = conversationHandlerStub as any;
|
|
468
|
+
const meta: any = { name: 'a.mp3', type: 'audio/mp3', uid: 'u1' };
|
|
469
|
+
const file = new File(['x'], 'a.mp3', { type: 'audio/mp3' });
|
|
470
|
+
spyOn(component, 'sendMessage');
|
|
471
|
+
component.uploadSingle(meta, file, '');
|
|
472
|
+
tick();
|
|
473
|
+
expect(component.sendMessage).toHaveBeenCalled();
|
|
474
|
+
const typeArg = (component.sendMessage as jasmine.Spy).calls.mostRecent().args[1];
|
|
475
|
+
expect(typeArg).toBe('file');
|
|
476
|
+
}));
|
|
477
|
+
});
|
|
104
478
|
});
|