@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,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SimpleChange } from '@angular/core';
|
|
2
|
+
import { ComponentFixture, TestBed, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
|
|
3
|
+
import { By } from '@angular/platform-browser';
|
|
2
4
|
|
|
3
5
|
import { ActionButtonComponent } from './action-button.component';
|
|
4
6
|
|
|
@@ -6,20 +8,62 @@ describe('ActionButtonComponent', () => {
|
|
|
6
8
|
let component: ActionButtonComponent;
|
|
7
9
|
let fixture: ComponentFixture<ActionButtonComponent>;
|
|
8
10
|
|
|
9
|
-
beforeEach(
|
|
11
|
+
beforeEach(waitForAsync(() => {
|
|
10
12
|
TestBed.configureTestingModule({
|
|
11
|
-
declarations: [
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
13
|
+
declarations: [ActionButtonComponent],
|
|
14
|
+
}).compileComponents();
|
|
14
15
|
}));
|
|
15
16
|
|
|
16
17
|
beforeEach(() => {
|
|
17
18
|
fixture = TestBed.createComponent(ActionButtonComponent);
|
|
18
19
|
component = fixture.componentInstance;
|
|
20
|
+
component.button = { value: 'OK', action: 'go' };
|
|
19
21
|
fixture.detectChanges();
|
|
20
22
|
});
|
|
21
23
|
|
|
22
24
|
it('should create', () => {
|
|
23
25
|
expect(component).toBeTruthy();
|
|
24
26
|
});
|
|
27
|
+
|
|
28
|
+
it('ngOnChanges should map theme CSS variables onto .action', () => {
|
|
29
|
+
component.fontSize = '16px';
|
|
30
|
+
component.backgroundColor = '#111';
|
|
31
|
+
component.textColor = '#222';
|
|
32
|
+
component.hoverBackgroundColor = '#333';
|
|
33
|
+
component.hoverTextColor = '#444';
|
|
34
|
+
component.ngOnChanges({
|
|
35
|
+
fontSize: new SimpleChange(null, '16px', true),
|
|
36
|
+
});
|
|
37
|
+
const el = fixture.nativeElement.querySelector('.action') as HTMLElement;
|
|
38
|
+
expect(el.style.getPropertyValue('--buttonFontSize').trim()).toBe('16px');
|
|
39
|
+
expect(el.style.getPropertyValue('--buttonBackgroundColor').trim()).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('actionButtonAction should emit when action present', fakeAsync(() => {
|
|
43
|
+
spyOn(component.onButtonClicked, 'emit');
|
|
44
|
+
const de = fixture.debugElement.query(By.css('.action'));
|
|
45
|
+
de.triggerEventHandler('click', {});
|
|
46
|
+
tick(500);
|
|
47
|
+
expect(component.onButtonClicked.emit).toHaveBeenCalled();
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
it('actionButtonAction should no-op when button has no action', () => {
|
|
51
|
+
component.button = { value: 'X', action: '' };
|
|
52
|
+
fixture.detectChanges();
|
|
53
|
+
spyOn(component.onButtonClicked, 'emit');
|
|
54
|
+
component.actionButtonAction();
|
|
55
|
+
expect(component.onButtonClicked.emit).not.toHaveBeenCalled();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('mouseover and mouseout should not throw', () => {
|
|
59
|
+
expect(() => component.onMouseOver({} as any)).not.toThrow();
|
|
60
|
+
expect(() => component.onMouseOut({} as any)).not.toThrow();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('template should mark archived conversations as disabled', () => {
|
|
64
|
+
component.isConversationArchived = true;
|
|
65
|
+
fixture.detectChanges();
|
|
66
|
+
const el = fixture.nativeElement.querySelector('.action');
|
|
67
|
+
expect(el.classList.contains('disabled')).toBe(true);
|
|
68
|
+
});
|
|
25
69
|
});
|
|
@@ -42,20 +42,17 @@
|
|
|
42
42
|
transition: background-color .6s ease;
|
|
43
43
|
.icon-button-action {
|
|
44
44
|
position: absolute;
|
|
45
|
-
top:
|
|
46
|
-
right:
|
|
47
|
-
transform: translateY(-50%);
|
|
45
|
+
top: -1px;
|
|
46
|
+
right: 1px;
|
|
48
47
|
svg {
|
|
49
|
-
fill: var(--
|
|
48
|
+
fill: var(--buttonTextColor);
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
.icon-button-action-self{
|
|
53
52
|
position: absolute;
|
|
54
|
-
|
|
55
|
-
right: 8px;
|
|
56
|
-
transform: translateY(-50%);
|
|
53
|
+
right: 1px;
|
|
57
54
|
svg {
|
|
58
|
-
fill: var(--
|
|
55
|
+
fill: var(--buttonTextColor);
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
58
|
&:focus,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SimpleChange } from '@angular/core';
|
|
2
|
+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
3
|
+
import { By } from '@angular/platform-browser';
|
|
2
4
|
|
|
3
5
|
import { LinkButtonComponent } from './link-button.component';
|
|
4
6
|
|
|
@@ -6,20 +8,63 @@ describe('LinkButtonComponent', () => {
|
|
|
6
8
|
let component: LinkButtonComponent;
|
|
7
9
|
let fixture: ComponentFixture<LinkButtonComponent>;
|
|
8
10
|
|
|
9
|
-
beforeEach(
|
|
11
|
+
beforeEach(waitForAsync(() => {
|
|
10
12
|
TestBed.configureTestingModule({
|
|
11
|
-
declarations: [
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
13
|
+
declarations: [LinkButtonComponent],
|
|
14
|
+
}).compileComponents();
|
|
14
15
|
}));
|
|
15
16
|
|
|
16
17
|
beforeEach(() => {
|
|
17
18
|
fixture = TestBed.createComponent(LinkButtonComponent);
|
|
18
19
|
component = fixture.componentInstance;
|
|
20
|
+
component.button = { value: 'Open', link: 'https://x.test', target: 'blank' };
|
|
19
21
|
fixture.detectChanges();
|
|
20
22
|
});
|
|
21
23
|
|
|
22
24
|
it('should create', () => {
|
|
23
25
|
expect(component).toBeTruthy();
|
|
24
26
|
});
|
|
27
|
+
|
|
28
|
+
it('ngOnChanges should set CSS variables on .url', () => {
|
|
29
|
+
component.fontSize = '12px';
|
|
30
|
+
component.backgroundColor = '#aaa';
|
|
31
|
+
component.textColor = '#bbb';
|
|
32
|
+
component.hoverBackgroundColor = '#ccc';
|
|
33
|
+
component.hoverTextColor = '#ddd';
|
|
34
|
+
component.ngOnChanges({
|
|
35
|
+
fontSize: new SimpleChange(null, '12px', true),
|
|
36
|
+
});
|
|
37
|
+
const el = fixture.nativeElement.querySelector('.url') as HTMLElement;
|
|
38
|
+
expect(el.style.getPropertyValue('--buttonFontSize').trim()).toBe('12px');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('actionButtonUrl should emit when link set', () => {
|
|
42
|
+
spyOn(component.onButtonClicked, 'emit');
|
|
43
|
+
component.actionButtonUrl();
|
|
44
|
+
expect(component.onButtonClicked.emit).toHaveBeenCalled();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('actionButtonUrl should not emit when link empty', () => {
|
|
48
|
+
component.button = { value: 'x', link: '' };
|
|
49
|
+
spyOn(component.onButtonClicked, 'emit');
|
|
50
|
+
component.actionButtonUrl();
|
|
51
|
+
expect(component.onButtonClicked.emit).not.toHaveBeenCalled();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should render external icon when target is not self', () => {
|
|
55
|
+
component.button = { value: 'L', link: 'u', target: 'blank' };
|
|
56
|
+
fixture.detectChanges();
|
|
57
|
+
expect(fixture.debugElement.query(By.css('.icon-button-action'))).toBeTruthy();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should render self icon when target is self', () => {
|
|
61
|
+
component.button = { value: 'L', link: 'u', target: 'self' };
|
|
62
|
+
fixture.detectChanges();
|
|
63
|
+
expect(fixture.debugElement.query(By.css('.icon-button-action-self'))).toBeTruthy();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('mouseover and mouseout should not throw', () => {
|
|
67
|
+
expect(() => component.onMouseOver({} as any)).not.toThrow();
|
|
68
|
+
expect(() => component.onMouseOut({} as any)).not.toThrow();
|
|
69
|
+
});
|
|
25
70
|
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SimpleChange } from '@angular/core';
|
|
2
|
+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
3
|
+
import { By } from '@angular/platform-browser';
|
|
2
4
|
|
|
3
5
|
import { TextButtonComponent } from './text-button.component';
|
|
4
6
|
|
|
@@ -6,20 +8,57 @@ describe('TextButtonComponent', () => {
|
|
|
6
8
|
let component: TextButtonComponent;
|
|
7
9
|
let fixture: ComponentFixture<TextButtonComponent>;
|
|
8
10
|
|
|
9
|
-
beforeEach(
|
|
11
|
+
beforeEach(waitForAsync(() => {
|
|
10
12
|
TestBed.configureTestingModule({
|
|
11
|
-
declarations: [
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
13
|
+
declarations: [TextButtonComponent],
|
|
14
|
+
}).compileComponents();
|
|
14
15
|
}));
|
|
15
16
|
|
|
16
17
|
beforeEach(() => {
|
|
17
18
|
fixture = TestBed.createComponent(TextButtonComponent);
|
|
18
19
|
component = fixture.componentInstance;
|
|
20
|
+
component.button = { value: 'Reply' };
|
|
21
|
+
component.isConversationArchived = false;
|
|
19
22
|
fixture.detectChanges();
|
|
20
23
|
});
|
|
21
24
|
|
|
22
25
|
it('should create', () => {
|
|
23
26
|
expect(component).toBeTruthy();
|
|
24
27
|
});
|
|
28
|
+
|
|
29
|
+
it('ngOnChanges should set CSS variables on .text', () => {
|
|
30
|
+
component.fontSize = '13px';
|
|
31
|
+
component.backgroundColor = '#111';
|
|
32
|
+
component.textColor = '#222';
|
|
33
|
+
component.hoverBackgroundColor = '#333';
|
|
34
|
+
component.hoverTextColor = '#444';
|
|
35
|
+
component.ngOnChanges({
|
|
36
|
+
fontSize: new SimpleChange(null, '13px', true),
|
|
37
|
+
});
|
|
38
|
+
const el = fixture.nativeElement.querySelector('.text') as HTMLElement;
|
|
39
|
+
expect(el.style.getPropertyValue('--buttonFontSize').trim()).toBe('13px');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('actionButtonText should emit click payload', () => {
|
|
43
|
+
spyOn(component.onButtonClicked, 'emit');
|
|
44
|
+
component.actionButtonText();
|
|
45
|
+
expect(component.onButtonClicked.emit).toHaveBeenCalled();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('click on template should invoke actionButtonText', () => {
|
|
49
|
+
spyOn(component, 'actionButtonText');
|
|
50
|
+
fixture.debugElement.query(By.css('.text')).triggerEventHandler('click', {});
|
|
51
|
+
expect(component.actionButtonText).toHaveBeenCalled();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should add disabled class when conversation archived', () => {
|
|
55
|
+
component.isConversationArchived = true;
|
|
56
|
+
fixture.detectChanges();
|
|
57
|
+
expect(fixture.nativeElement.querySelector('.text').classList.contains('disabled')).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('mouseover and mouseout should not throw', () => {
|
|
61
|
+
expect(() => component.onMouseOver({} as any)).not.toThrow();
|
|
62
|
+
expect(() => component.onMouseOut({} as any)).not.toThrow();
|
|
63
|
+
});
|
|
25
64
|
});
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
<div class="wrapper"
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<div class="wrapper"
|
|
2
|
+
role="region"
|
|
3
|
+
aria-roledescription="carousel"
|
|
4
|
+
[attr.aria-label]="translationMap?.get('CAROUSEL_LABEL') || 'Cards carousel'">
|
|
5
|
+
<button type="button"
|
|
6
|
+
id="left"
|
|
7
|
+
class="arrow left c21-button-clean"
|
|
8
|
+
[attr.aria-label]="translationMap?.get('CAROUSEL_PREVIOUS') || 'Previous slide'"
|
|
9
|
+
(click)="goTo('previous')" *ngIf="activeElement > 1">
|
|
10
|
+
<svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
|
|
4
11
|
<path d="M0 0h24v24H0V0z" fill="none"/><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12l4.58-4.59z"/>
|
|
5
12
|
</svg>
|
|
6
|
-
</
|
|
13
|
+
</button>
|
|
7
14
|
<div class="carousel">
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
<div class="card"
|
|
16
|
+
*ngFor="let card of gallery; let i = index"
|
|
17
|
+
role="group"
|
|
18
|
+
aria-roledescription="slide"
|
|
19
|
+
[attr.aria-label]="getSlideLabel(i + 1, gallery?.length)">
|
|
11
20
|
<div>
|
|
12
21
|
<div class="card-image" *ngIf="card?.preview?.src !== ''">
|
|
13
|
-
<img [src]="card?.preview?.src" alt="
|
|
22
|
+
<img [src]="card?.preview?.src" [attr.alt]="card?.title || 'Carousel image'" draggable="false">
|
|
14
23
|
</div>
|
|
15
24
|
<div class="card-image card-image-placeholder" *ngIf="card?.preview?.src == ''">
|
|
16
|
-
<img src="assets/images/icons/no-image.svg" alt="
|
|
25
|
+
<img src="assets/images/icons/no-image.svg" alt="" draggable="false">
|
|
17
26
|
<span>Image not available</span>
|
|
18
27
|
</div>
|
|
19
28
|
<div class="card-content">
|
|
@@ -21,20 +30,24 @@
|
|
|
21
30
|
<div class="card-description">{{card?.description}}</div>
|
|
22
31
|
</div>
|
|
23
32
|
<div class="buttons" *ngIf="card?.buttons && card?.buttons.length > 0">
|
|
24
|
-
<
|
|
25
|
-
class="single-button action"
|
|
33
|
+
<button type="button" *ngFor="let button of card?.buttons"
|
|
34
|
+
class="single-button action c21-button-clean"
|
|
26
35
|
[ngClass]="{'disabled': (isConversationArchived || (!isLastMessage && button.type !== TYPE_BUTTON.URL)), 'active': button?.active}"
|
|
36
|
+
[attr.aria-label]="button?.value"
|
|
27
37
|
(click)="actionButtonClick($event, button, i)" >
|
|
28
38
|
{{button.value}}
|
|
29
|
-
</
|
|
39
|
+
</button>
|
|
30
40
|
</div>
|
|
31
41
|
</div>
|
|
32
42
|
</div>
|
|
33
|
-
<!-- <div class="card" style="width: 17px;"></div> -->
|
|
34
43
|
</div>
|
|
35
|
-
<
|
|
36
|
-
|
|
44
|
+
<button type="button"
|
|
45
|
+
id="right"
|
|
46
|
+
class="arrow right c21-button-clean"
|
|
47
|
+
[attr.aria-label]="translationMap?.get('CAROUSEL_NEXT') || 'Next slide'"
|
|
48
|
+
(click)="goTo('next')" *ngIf="activeElement !== gallery.length">
|
|
49
|
+
<svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
|
|
37
50
|
<path d="M0 0h24v24H0V0z" fill="none"/><path d="M10.02 6L8.61 7.41 13.19 12l-4.58 4.59L10.02 18l6-6-6-6z"/>
|
|
38
51
|
</svg>
|
|
39
|
-
</
|
|
52
|
+
</button>
|
|
40
53
|
</div>
|
|
@@ -24,13 +24,17 @@
|
|
|
24
24
|
font-size: 14px;
|
|
25
25
|
// margin: 0 25px;
|
|
26
26
|
}
|
|
27
|
-
.wrapper
|
|
27
|
+
.wrapper button.arrow {
|
|
28
28
|
top: 50%;
|
|
29
29
|
height: 40px;
|
|
30
30
|
width: 40px;
|
|
31
31
|
cursor: pointer;
|
|
32
32
|
position: absolute;
|
|
33
33
|
background: #fff;
|
|
34
|
+
border: none;
|
|
35
|
+
padding: 0;
|
|
36
|
+
-webkit-appearance: none;
|
|
37
|
+
appearance: none;
|
|
34
38
|
border-radius: 50%;
|
|
35
39
|
box-shadow: 0 3px 6px rgba(0,0,0,0.23);
|
|
36
40
|
transform: translateY(-50%);
|
|
@@ -41,13 +45,13 @@
|
|
|
41
45
|
justify-content: center;
|
|
42
46
|
align-items: center;
|
|
43
47
|
}
|
|
44
|
-
.wrapper
|
|
48
|
+
.wrapper button.arrow:active{
|
|
45
49
|
transform: translateY(-50%) scale(0.85);
|
|
46
50
|
}
|
|
47
|
-
.wrapper
|
|
51
|
+
.wrapper button.arrow:first-child{
|
|
48
52
|
left: -22px;
|
|
49
53
|
}
|
|
50
|
-
.wrapper
|
|
54
|
+
.wrapper button.arrow:last-child{
|
|
51
55
|
right: -22px;
|
|
52
56
|
}
|
|
53
57
|
.wrapper .carousel{
|
|
@@ -192,13 +196,18 @@
|
|
|
192
196
|
|
|
193
197
|
|
|
194
198
|
.single-button{
|
|
195
|
-
|
|
196
|
-
|
|
199
|
+
width: 100%;
|
|
200
|
+
box-sizing: border-box;
|
|
201
|
+
margin: 0;
|
|
202
|
+
border: none;
|
|
203
|
+
border-top: 1px dashed rgba(0, 0, 0, 0.08);
|
|
204
|
+
text-align: center;
|
|
205
|
+
-webkit-appearance: none;
|
|
206
|
+
appearance: none;
|
|
197
207
|
-webkit-box-align: center;
|
|
198
208
|
-ms-flex-align: center;
|
|
199
209
|
align-items: center;
|
|
200
210
|
justify-content: center;
|
|
201
|
-
border-top: 1px dashed rgba(0, 0, 0, 0.08);
|
|
202
211
|
cursor: pointer;
|
|
203
212
|
display: -webkit-box;
|
|
204
213
|
display: -ms-flexbox;
|
|
@@ -222,7 +231,6 @@
|
|
|
222
231
|
line-height: 16px;
|
|
223
232
|
padding: 8px 16px!important;
|
|
224
233
|
|
|
225
|
-
&:focus,
|
|
226
234
|
&:hover {
|
|
227
235
|
color: var(--hoverTextColor);
|
|
228
236
|
background: var(--hoverBackgroundColor);
|
|
@@ -233,6 +241,10 @@
|
|
|
233
241
|
}
|
|
234
242
|
}
|
|
235
243
|
}
|
|
244
|
+
&:focus-visible {
|
|
245
|
+
outline: 2px solid var(--hoverBackgroundColor, #1565c0);
|
|
246
|
+
outline-offset: 2px;
|
|
247
|
+
}
|
|
236
248
|
&:after {
|
|
237
249
|
content: "";
|
|
238
250
|
position: absolute;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { By } from '@angular/platform-browser';
|
|
3
|
+
import { TYPE_BUTTON } from 'src/chat21-core/utils/constants';
|
|
2
4
|
|
|
3
5
|
import { CarouselComponent } from './carousel.component';
|
|
4
6
|
|
|
@@ -6,18 +8,93 @@ describe('CarouselComponent', () => {
|
|
|
6
8
|
let component: CarouselComponent;
|
|
7
9
|
let fixture: ComponentFixture<CarouselComponent>;
|
|
8
10
|
|
|
11
|
+
const btnA = { type: TYPE_BUTTON.TEXT, value: 'Go', action: '', link: '', text: 'x', active: false };
|
|
12
|
+
const gallery = [
|
|
13
|
+
{ preview: { src: 'https://a/img.png' }, title: 'A', description: 'da', buttons: [btnA] },
|
|
14
|
+
{ preview: { src: 'https://b/img.png' }, title: 'B', description: 'db', buttons: [{ type: TYPE_BUTTON.TEXT, value: 'B2', action: 'a', text: 't', active: false }] },
|
|
15
|
+
];
|
|
16
|
+
|
|
9
17
|
beforeEach(async () => {
|
|
10
18
|
await TestBed.configureTestingModule({
|
|
11
|
-
declarations: [
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
19
|
+
declarations: [CarouselComponent],
|
|
20
|
+
}).compileComponents();
|
|
14
21
|
|
|
15
22
|
fixture = TestBed.createComponent(CarouselComponent);
|
|
16
23
|
component = fixture.componentInstance;
|
|
24
|
+
component.message = { attributes: { attachment: { gallery } } } as any;
|
|
25
|
+
component.gallery = gallery;
|
|
26
|
+
component.stylesMap = new Map<string, string>([
|
|
27
|
+
['buttonFontSize', '14px'],
|
|
28
|
+
['buttonBackgroundColor', '#111'],
|
|
29
|
+
['buttonTextColor', '#222'],
|
|
30
|
+
['buttonHoverBackgroundColor', '#333'],
|
|
31
|
+
['buttonHoverTextColor', '#444'],
|
|
32
|
+
]);
|
|
33
|
+
component.isConversationArchived = false;
|
|
34
|
+
component.isLastMessage = true;
|
|
17
35
|
fixture.detectChanges();
|
|
18
36
|
});
|
|
19
37
|
|
|
20
38
|
it('should create', () => {
|
|
21
39
|
expect(component).toBeTruthy();
|
|
40
|
+
expect(component.gallery.length).toBe(2);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('ngOnChanges should apply style map to wrapper', () => {
|
|
44
|
+
component.ngOnChanges({
|
|
45
|
+
stylesMap: {
|
|
46
|
+
previousValue: undefined,
|
|
47
|
+
currentValue: component.stylesMap,
|
|
48
|
+
firstChange: true,
|
|
49
|
+
isFirstChange: () => true,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
const wrap = fixture.nativeElement.querySelector('.wrapper') as HTMLElement;
|
|
53
|
+
expect(wrap.style.getPropertyValue('--buttonFontSize').trim()).toBe('14px');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('goTo should bump activeElement for next and previous', () => {
|
|
57
|
+
const carouselEl = component.carousel;
|
|
58
|
+
spyOnProperty(carouselEl, 'offsetWidth', 'get').and.returnValue(400);
|
|
59
|
+
const cards = carouselEl.querySelectorAll('.card');
|
|
60
|
+
expect(cards.length).toBeGreaterThanOrEqual(2);
|
|
61
|
+
const card1 = cards[1] as HTMLElement;
|
|
62
|
+
spyOnProperty(card1, 'offsetWidth', 'get').and.returnValue(180);
|
|
63
|
+
const startEl = component.activeElement;
|
|
64
|
+
component.goTo('next');
|
|
65
|
+
expect(component.activeElement).toBe(startEl + 1);
|
|
66
|
+
component.goTo('previous');
|
|
67
|
+
expect(component.activeElement).toBe(startEl);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('actionButtonClick should emit onAttachmentButtonClicked', () => {
|
|
71
|
+
spyOn(component.onAttachmentButtonClicked, 'emit');
|
|
72
|
+
const ev = { target: { classList: { add: jasmine.createSpy('add') } } };
|
|
73
|
+
component.gallery = gallery;
|
|
74
|
+
component.actionButtonClick(ev as any, btnA, 0);
|
|
75
|
+
expect(component.onAttachmentButtonClicked.emit).toHaveBeenCalled();
|
|
76
|
+
expect(btnA.active).toBe(true);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('actionButtonClick should ignore empty button', () => {
|
|
80
|
+
spyOn(component.onAttachmentButtonClicked, 'emit');
|
|
81
|
+
const empty = { type: TYPE_BUTTON.TEXT, value: '', action: '', link: '', text: '', active: false };
|
|
82
|
+
component.actionButtonClick({ target: { classList: { add: () => {} } } } as any, empty, 0);
|
|
83
|
+
expect(component.onAttachmentButtonClicked.emit).not.toHaveBeenCalled();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('arrow clicks should invoke goTo', () => {
|
|
87
|
+
spyOn(component, 'goTo');
|
|
88
|
+
component.activeElement = 1;
|
|
89
|
+
component.gallery = gallery;
|
|
90
|
+
fixture.detectChanges();
|
|
91
|
+
const right = fixture.debugElement.query(By.css('.arrow.right'));
|
|
92
|
+
expect(right).toBeTruthy();
|
|
93
|
+
right!.triggerEventHandler('click', {});
|
|
94
|
+
expect(component.goTo).toHaveBeenCalledWith('next');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('TYPE_BUTTON should be exposed for template', () => {
|
|
98
|
+
expect(component.TYPE_BUTTON).toBe(TYPE_BUTTON);
|
|
22
99
|
});
|
|
23
100
|
});
|
|
@@ -15,6 +15,7 @@ export class CarouselComponent implements OnInit{
|
|
|
15
15
|
@Input() isConversationArchived: boolean;
|
|
16
16
|
@Input() isLastMessage: boolean;
|
|
17
17
|
@Input() stylesMap: Map<string, string>;
|
|
18
|
+
@Input() translationMap: Map<string, string>;
|
|
18
19
|
@Output() onAttachmentButtonClicked = new EventEmitter<any>();
|
|
19
20
|
@Output() onElementRendered = new EventEmitter<{element: string, status: boolean}>()
|
|
20
21
|
// ========= end:: Input/Output values ============//
|
|
@@ -108,6 +109,21 @@ export class CarouselComponent implements OnInit{
|
|
|
108
109
|
|
|
109
110
|
}
|
|
110
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Builds an accessible label for each carousel slide, e.g. "Slide 2 of 5".
|
|
114
|
+
* Uses the i18n template `CAROUSEL_SLIDE_LABEL` if available, otherwise falls back to English.
|
|
115
|
+
*/
|
|
116
|
+
getSlideLabel(current: number, total: number): string {
|
|
117
|
+
const template = this.translationMap?.get('CAROUSEL_SLIDE_LABEL');
|
|
118
|
+
const safeTotal = total || 0;
|
|
119
|
+
if (template && typeof template === 'string') {
|
|
120
|
+
return template
|
|
121
|
+
.replace('{current}', String(current))
|
|
122
|
+
.replace('{total}', String(safeTotal));
|
|
123
|
+
}
|
|
124
|
+
return `Slide ${current} of ${safeTotal}`;
|
|
125
|
+
}
|
|
126
|
+
|
|
111
127
|
actionButtonClick(ev, button, index){
|
|
112
128
|
this.button = button
|
|
113
129
|
this.type = button.type
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
<div
|
|
2
|
-
<div *ngIf="loading" class="loader" [ngStyle]
|
|
3
|
-
<iframe
|
|
1
|
+
<div [ngStyle]="{ 'max-width': '100%', 'width': width, 'height': height }">
|
|
2
|
+
<div *ngIf="loading" class="loader" [ngStyle]="{ 'width': width, 'height': height }"></div>
|
|
3
|
+
<iframe allowfullscreen
|
|
4
4
|
[ngClass]="{'isLoadingImage': loading}"
|
|
5
|
-
width
|
|
5
|
+
width="100%" height="100%"
|
|
6
|
+
[title]="frameTitle"
|
|
6
7
|
[src]="url"
|
|
8
|
+
sandbox="allow-scripts allow-same-origin allow-popups allow-forms allow-popups-to-escape-sandbox"
|
|
9
|
+
referrerpolicy="strict-origin-when-cross-origin"
|
|
10
|
+
loading="lazy"
|
|
7
11
|
(load)="onLoaded($event)"></iframe>
|
|
8
12
|
</div>
|
|
13
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
2
2
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
3
3
|
|
|
4
4
|
import { FrameComponent } from './frame.component';
|
|
@@ -9,29 +9,48 @@ describe('FrameComponent', () => {
|
|
|
9
9
|
|
|
10
10
|
beforeEach(waitForAsync(() => {
|
|
11
11
|
TestBed.configureTestingModule({
|
|
12
|
-
declarations: [
|
|
13
|
-
|
|
14
|
-
{
|
|
15
|
-
provide: DomSanitizer,
|
|
16
|
-
useValue: {
|
|
17
|
-
sanitize: () => 'safeString',
|
|
18
|
-
bypassSecurityTrustResourceUrl: () => 'safeString'
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
,]
|
|
22
|
-
})
|
|
23
|
-
.compileComponents();
|
|
12
|
+
declarations: [FrameComponent],
|
|
13
|
+
}).compileComponents();
|
|
24
14
|
}));
|
|
25
15
|
|
|
26
16
|
beforeEach(() => {
|
|
27
17
|
fixture = TestBed.createComponent(FrameComponent);
|
|
28
18
|
component = fixture.componentInstance;
|
|
29
|
-
fixture.detectChanges();
|
|
30
19
|
});
|
|
31
20
|
|
|
32
21
|
it('should create', () => {
|
|
33
|
-
component.
|
|
22
|
+
component.metadata = { src: 'https://www.example.com/embed' };
|
|
23
|
+
component.width = 400;
|
|
24
|
+
component.height = 300;
|
|
34
25
|
fixture.detectChanges();
|
|
35
26
|
expect(component).toBeTruthy();
|
|
36
27
|
});
|
|
28
|
+
|
|
29
|
+
it('ngOnInit should trust resource URL when metadata.src present', () => {
|
|
30
|
+
component.metadata = { src: 'https://player.example/v/1' };
|
|
31
|
+
component.ngOnInit();
|
|
32
|
+
expect(component.url).toBeTruthy();
|
|
33
|
+
expect((component.url as any).changingThisBreaksApplicationSecurity).toBe('https://player.example/v/1');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('ngOnInit should leave url null when metadata missing src', () => {
|
|
37
|
+
component.metadata = {};
|
|
38
|
+
component.ngOnInit();
|
|
39
|
+
expect(component.url).toBeNull();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('onLoaded should clear loading and emit', () => {
|
|
43
|
+
spyOn(component.onElementRendered, 'emit');
|
|
44
|
+
component.loading = true;
|
|
45
|
+
component.onLoaded({} as any);
|
|
46
|
+
expect(component.loading).toBe(false);
|
|
47
|
+
expect(component.onElementRendered.emit).toHaveBeenCalledWith({ element: 'frame', status: true });
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('ngOnDestroy should clear trusted url', () => {
|
|
51
|
+
const sanitizer = TestBed.inject(DomSanitizer);
|
|
52
|
+
component.url = sanitizer.bypassSecurityTrustResourceUrl('https://x');
|
|
53
|
+
component.ngOnDestroy();
|
|
54
|
+
expect(component.url).toBeNull();
|
|
55
|
+
});
|
|
37
56
|
});
|
|
@@ -15,14 +15,19 @@ export class FrameComponent implements OnInit {
|
|
|
15
15
|
|
|
16
16
|
url: SafeResourceUrl = null
|
|
17
17
|
loading: boolean = true
|
|
18
|
+
frameTitle: string = 'Embedded content'
|
|
18
19
|
constructor(private sanitizer: DomSanitizer) { }
|
|
19
20
|
|
|
20
21
|
ngOnInit() {
|
|
21
22
|
if(this.metadata && this.metadata.src){
|
|
22
23
|
this.url = this.sanitizer.bypassSecurityTrustResourceUrl(this.metadata.src);
|
|
24
|
+
try {
|
|
25
|
+
const host = new URL(this.metadata.src).hostname;
|
|
26
|
+
this.frameTitle = `Embedded content from ${host}`;
|
|
27
|
+
} catch (_) {
|
|
28
|
+
this.frameTitle = 'Embedded content';
|
|
29
|
+
}
|
|
23
30
|
}
|
|
24
|
-
// this.width = this.getSizeImg(this.metadata).width;
|
|
25
|
-
// this.height = this.getSizeImg(this.metadata).height;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
ngOnDestroy(){
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
Security: render HTML messages as plain text (no DOM interpretation).
|
|
3
3
|
This preserves the exact input (e.g. "<h1>...</h1>") including line breaks.
|
|
4
4
|
-->
|
|
5
|
-
<pre
|
|
5
|
+
<pre class="htmlCode" #htmlCode [textContent]="htmlText"></pre>
|