@capillarytech/creatives-library 8.0.242-alpha.1 → 8.0.242-alpha.11
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/assets/Android.png +0 -0
- package/assets/iOS.png +0 -0
- package/config/app.js +1 -1
- package/constants/unified.js +2 -2
- package/initialReducer.js +0 -2
- package/package.json +1 -1
- package/services/api.js +5 -10
- package/services/tests/api.test.js +0 -18
- package/translations/en.json +4 -3
- package/utils/common.js +6 -5
- package/utils/commonUtils.js +1 -14
- package/utils/imageUrlUpload.js +141 -0
- package/utils/tests/commonUtil.test.js +0 -224
- package/utils/transformTemplateConfig.js +10 -0
- package/v2Components/CapDeviceContent/index.js +56 -61
- package/v2Components/CapImageUpload/constants.js +2 -0
- package/v2Components/CapImageUpload/index.js +65 -16
- package/v2Components/CapImageUpload/index.scss +4 -1
- package/v2Components/CapImageUpload/messages.js +5 -1
- package/v2Components/CapImageUrlUpload/constants.js +26 -0
- package/v2Components/CapImageUrlUpload/index.js +365 -0
- package/v2Components/CapImageUrlUpload/index.scss +35 -0
- package/v2Components/CapImageUrlUpload/messages.js +47 -0
- package/v2Components/CapTagList/index.js +1 -6
- package/v2Components/CapTagListWithInput/index.js +1 -5
- package/v2Components/CapTagListWithInput/messages.js +1 -1
- package/v2Components/CapWhatsappCTA/tests/index.test.js +0 -5
- package/v2Components/ErrorInfoNote/index.js +72 -412
- package/v2Components/ErrorInfoNote/messages.js +0 -22
- package/v2Components/ErrorInfoNote/style.scss +2 -279
- package/v2Components/HtmlEditor/HTMLEditor.js +89 -210
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +133 -1132
- package/v2Components/HtmlEditor/__tests__/index.lazy.test.js +12 -17
- package/v2Components/HtmlEditor/_htmlEditor.scss +23 -8
- package/v2Components/HtmlEditor/_index.lazy.scss +1 -1
- package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +101 -13
- package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +139 -148
- package/v2Components/HtmlEditor/components/DeviceToggle/_deviceToggle.scss +1 -2
- package/v2Components/HtmlEditor/components/DeviceToggle/index.js +3 -3
- package/v2Components/HtmlEditor/components/EditorToolbar/index.js +1 -1
- package/v2Components/HtmlEditor/components/FullscreenModal/_fullscreenModal.scss +0 -1
- package/v2Components/HtmlEditor/components/InAppPreviewPane/DeviceFrame.js +7 -4
- package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/DeviceFrame.test.js +45 -35
- package/v2Components/HtmlEditor/components/InAppPreviewPane/_inAppPreviewPane.scss +3 -1
- package/v2Components/HtmlEditor/components/InAppPreviewPane/constants.js +33 -33
- package/v2Components/HtmlEditor/components/InAppPreviewPane/index.js +6 -7
- package/v2Components/HtmlEditor/components/PreviewPane/_previewPane.scss +6 -3
- package/v2Components/HtmlEditor/components/PreviewPane/index.js +11 -10
- package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/__tests__/index.test.js +62 -87
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/index.js +31 -49
- package/v2Components/HtmlEditor/constants.js +20 -29
- package/v2Components/HtmlEditor/hooks/__tests__/useInAppContent.test.js +16 -373
- package/v2Components/HtmlEditor/hooks/useEditorContent.js +2 -5
- package/v2Components/HtmlEditor/hooks/useInAppContent.js +146 -88
- package/v2Components/HtmlEditor/index.js +1 -1
- package/v2Components/HtmlEditor/messages.js +85 -95
- package/v2Components/HtmlEditor/utils/liquidTemplateSupport.js +101 -99
- package/v2Components/HtmlEditor/utils/properSyntaxHighlighting.js +25 -23
- package/v2Components/HtmlEditor/utils/validationAdapter.js +41 -34
- package/v2Components/MobilePushPreviewV2/index.js +7 -32
- package/v2Components/TemplatePreview/_templatePreview.scss +24 -44
- package/v2Components/TemplatePreview/index.js +32 -47
- package/v2Components/TemplatePreview/messages.js +0 -4
- package/v2Components/TestAndPreviewSlidebox/index.js +25 -31
- package/v2Containers/App/constants.js +5 -0
- package/v2Containers/BeeEditor/index.js +80 -82
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +4 -3
- package/v2Containers/CreativesContainer/SlideBoxContent.js +118 -148
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +3 -9
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +2 -2
- package/v2Containers/CreativesContainer/constants.js +2 -1
- package/v2Containers/CreativesContainer/index.js +41 -173
- package/v2Containers/CreativesContainer/messages.js +4 -4
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +210 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +354 -38
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -36
- package/v2Containers/Email/actions.js +0 -7
- package/v2Containers/Email/constants.js +1 -5
- package/v2Containers/Email/index.js +0 -13
- package/v2Containers/Email/messages.js +0 -32
- package/v2Containers/Email/reducer.js +1 -12
- package/v2Containers/Email/sagas.js +6 -41
- package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +0 -2
- package/v2Containers/EmailWrapper/components/EmailWrapperView.js +7 -193
- package/v2Containers/EmailWrapper/components/HTMLEditorTesting.js +74 -40
- package/v2Containers/EmailWrapper/components/__tests__/HTMLEditorTesting.test.js +67 -2
- package/v2Containers/EmailWrapper/constants.js +0 -2
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +67 -436
- package/v2Containers/EmailWrapper/index.js +23 -99
- package/v2Containers/EmailWrapper/messages.js +1 -61
- package/v2Containers/EmailWrapper/tests/EmailWrapperView.test.js +1 -26
- package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +77 -111
- package/v2Containers/InApp/actions.js +0 -7
- package/v2Containers/InApp/constants.js +4 -20
- package/v2Containers/InApp/index.js +357 -800
- package/v2Containers/InApp/index.scss +3 -4
- package/v2Containers/InApp/messages.js +3 -7
- package/v2Containers/InApp/reducer.js +3 -21
- package/v2Containers/InApp/sagas.js +9 -29
- package/v2Containers/InApp/selectors.js +5 -25
- package/v2Containers/InApp/tests/index.test.js +50 -154
- package/v2Containers/InApp/tests/reducer.test.js +0 -34
- package/v2Containers/InApp/tests/sagas.test.js +9 -61
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +12 -12
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +8 -8
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +100 -77
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +72 -63
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +184 -150
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +16 -12
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +32 -28
- package/v2Containers/TagList/index.js +1 -67
- package/v2Containers/Templates/ChannelTypeIllustration.js +13 -1
- package/v2Containers/Templates/_templates.scss +202 -56
- package/v2Containers/Templates/actions.js +2 -1
- package/v2Containers/Templates/constants.js +1 -0
- package/v2Containers/Templates/index.js +278 -128
- package/v2Containers/Templates/messages.js +24 -4
- package/v2Containers/Templates/reducer.js +2 -0
- package/v2Containers/Templates/tests/index.test.js +10 -0
- package/v2Containers/TemplatesV2/index.js +8 -1
- package/v2Containers/TemplatesV2/messages.js +4 -0
- package/v2Containers/WebPush/Create/components/BrandIconSection.js +108 -0
- package/v2Containers/WebPush/Create/components/ButtonForm.js +172 -0
- package/v2Containers/WebPush/Create/components/ButtonItem.js +101 -0
- package/v2Containers/WebPush/Create/components/ButtonList.js +145 -0
- package/v2Containers/WebPush/Create/components/ButtonsLinksSection.js +164 -0
- package/v2Containers/WebPush/Create/components/ButtonsLinksSection.test.js +463 -0
- package/v2Containers/WebPush/Create/components/FormActions.js +54 -0
- package/v2Containers/WebPush/Create/components/FormActions.test.js +163 -0
- package/v2Containers/WebPush/Create/components/MediaSection.js +142 -0
- package/v2Containers/WebPush/Create/components/MediaSection.test.js +341 -0
- package/v2Containers/WebPush/Create/components/MessageSection.js +103 -0
- package/v2Containers/WebPush/Create/components/MessageSection.test.js +268 -0
- package/v2Containers/WebPush/Create/components/NotificationTitleSection.js +87 -0
- package/v2Containers/WebPush/Create/components/NotificationTitleSection.test.js +210 -0
- package/v2Containers/WebPush/Create/components/TemplateNameSection.js +54 -0
- package/v2Containers/WebPush/Create/components/TemplateNameSection.test.js +143 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/ButtonsLinksSection.test.js.snap +86 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/FormActions.test.js.snap +16 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/MediaSection.test.js.snap +41 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/MessageSection.test.js.snap +54 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/NotificationTitleSection.test.js.snap +37 -0
- package/v2Containers/WebPush/Create/components/__snapshots__/TemplateNameSection.test.js.snap +21 -0
- package/v2Containers/WebPush/Create/components/_buttons.scss +246 -0
- package/v2Containers/WebPush/Create/components/tests/ButtonForm.test.js +554 -0
- package/v2Containers/WebPush/Create/components/tests/ButtonItem.test.js +607 -0
- package/v2Containers/WebPush/Create/components/tests/ButtonList.test.js +633 -0
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonForm.test.js.snap +666 -0
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonItem.test.js.snap +74 -0
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonList.test.js.snap +78 -0
- package/v2Containers/WebPush/Create/hooks/useButtonManagement.js +138 -0
- package/v2Containers/WebPush/Create/hooks/useButtonManagement.test.js +406 -0
- package/v2Containers/WebPush/Create/hooks/useCharacterCount.js +30 -0
- package/v2Containers/WebPush/Create/hooks/useCharacterCount.test.js +151 -0
- package/v2Containers/WebPush/Create/hooks/useImageUpload.js +104 -0
- package/v2Containers/WebPush/Create/hooks/useImageUpload.test.js +538 -0
- package/v2Containers/WebPush/Create/hooks/useTagManagement.js +122 -0
- package/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +633 -0
- package/v2Containers/WebPush/Create/index.js +1056 -0
- package/v2Containers/WebPush/Create/index.scss +134 -0
- package/v2Containers/WebPush/Create/messages.js +203 -0
- package/v2Containers/WebPush/Create/preview/DevicePreviewContent.js +228 -0
- package/v2Containers/WebPush/Create/preview/NotificationContainer.js +294 -0
- package/v2Containers/WebPush/Create/preview/PreviewContent.js +90 -0
- package/v2Containers/WebPush/Create/preview/PreviewControls.js +305 -0
- package/v2Containers/WebPush/Create/preview/PreviewDisclaimer.js +23 -0
- package/v2Containers/WebPush/Create/preview/WebPushPreview.js +150 -0
- package/v2Containers/WebPush/Create/preview/assets/Light.svg +53 -0
- package/v2Containers/WebPush/Create/preview/assets/Top.svg +5 -0
- package/v2Containers/WebPush/Create/preview/assets/android-arrow-down.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/android-arrow-up.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/chrome-icon.png +0 -0
- package/v2Containers/WebPush/Create/preview/assets/edge-icon.png +0 -0
- package/v2Containers/WebPush/Create/preview/assets/firefox-icon.svg +106 -0
- package/v2Containers/WebPush/Create/preview/assets/iOS.svg +26 -0
- package/v2Containers/WebPush/Create/preview/assets/macos-arrow-down-icon.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/macos-triple-dot-icon.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/opera-icon.svg +18 -0
- package/v2Containers/WebPush/Create/preview/assets/safari-icon.svg +29 -0
- package/v2Containers/WebPush/Create/preview/assets/windows-close-icon.svg +9 -0
- package/v2Containers/WebPush/Create/preview/assets/windows-triple-dot-icon.svg +9 -0
- package/v2Containers/WebPush/Create/preview/components/AndroidMobileChromeHeader.js +47 -0
- package/v2Containers/WebPush/Create/preview/components/AndroidMobileExpanded.js +141 -0
- package/v2Containers/WebPush/Create/preview/components/IOSHeader.js +45 -0
- package/v2Containers/WebPush/Create/preview/components/NotificationExpandedContent.js +68 -0
- package/v2Containers/WebPush/Create/preview/components/NotificationHeader.js +61 -0
- package/v2Containers/WebPush/Create/preview/components/WindowsChromeExpanded.js +99 -0
- package/v2Containers/WebPush/Create/preview/components/tests/AndroidMobileExpanded.test.js +733 -0
- package/v2Containers/WebPush/Create/preview/components/tests/WindowsChromeExpanded.test.js +571 -0
- package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/AndroidMobileExpanded.test.js.snap +81 -0
- package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/WindowsChromeExpanded.test.js.snap +81 -0
- package/v2Containers/WebPush/Create/preview/config/notificationMappings.js +50 -0
- package/v2Containers/WebPush/Create/preview/constants.js +637 -0
- package/v2Containers/WebPush/Create/preview/notification-container.scss +79 -0
- package/v2Containers/WebPush/Create/preview/preview.scss +351 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-chrome.scss +370 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-edge.scss +12 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-firefox.scss +12 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-opera.scss +12 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-chrome.scss +47 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-edge.scss +11 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-firefox.scss +11 -0
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-opera.scss +11 -0
- package/v2Containers/WebPush/Create/preview/styles/_base.scss +207 -0
- package/v2Containers/WebPush/Create/preview/styles/_ios.scss +153 -0
- package/v2Containers/WebPush/Create/preview/styles/_ipados.scss +107 -0
- package/v2Containers/WebPush/Create/preview/styles/_macos-chrome.scss +101 -0
- package/v2Containers/WebPush/Create/preview/styles/_windows-chrome.scss +229 -0
- package/v2Containers/WebPush/Create/preview/tests/DevicePreviewContent.test.js +909 -0
- package/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +1081 -0
- package/v2Containers/WebPush/Create/preview/tests/PreviewControls.test.js +723 -0
- package/v2Containers/WebPush/Create/preview/tests/WebPushPreview.test.js +943 -0
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/DevicePreviewContent.test.js.snap +131 -0
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/NotificationContainer.test.js.snap +112 -0
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/PreviewControls.test.js.snap +144 -0
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/WebPushPreview.test.js.snap +129 -0
- package/v2Containers/WebPush/Create/utils/payloadBuilder.js +94 -0
- package/v2Containers/WebPush/Create/utils/payloadBuilder.test.js +390 -0
- package/v2Containers/WebPush/Create/utils/previewUtils.js +89 -0
- package/v2Containers/WebPush/Create/utils/urlValidation.js +115 -0
- package/v2Containers/WebPush/Create/utils/urlValidation.test.js +449 -0
- package/v2Containers/WebPush/Create/utils/validation.js +75 -0
- package/v2Containers/WebPush/Create/utils/validation.test.js +283 -0
- package/v2Containers/WebPush/actions.js +60 -0
- package/v2Containers/WebPush/constants.js +128 -0
- package/v2Containers/WebPush/index.js +2 -0
- package/v2Containers/WebPush/reducer.js +104 -0
- package/v2Containers/WebPush/sagas.js +119 -0
- package/v2Containers/WebPush/selectors.js +65 -0
- package/v2Containers/WebPush/tests/reducer.test.js +863 -0
- package/v2Containers/WebPush/tests/sagas.test.js +566 -0
- package/v2Containers/WebPush/tests/selectors.test.js +843 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +528 -431
- package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +0 -254
- package/v2Components/HtmlEditor/components/ValidationTabs/index.js +0 -362
- package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +0 -51
- package/v2Containers/BeePopupEditor/constants.js +0 -10
- package/v2Containers/BeePopupEditor/index.js +0 -193
- package/v2Containers/BeePopupEditor/tests/index.test.js +0 -627
- package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +0 -1045
- package/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +0 -376
- package/v2Containers/InApp/__tests__/sagas.test.js +0 -363
- package/v2Containers/InApp/tests/selectors.test.js +0 -612
- package/v2Containers/InAppWrapper/components/InAppWrapperView.js +0 -162
- package/v2Containers/InAppWrapper/components/__tests__/InAppWrapperView.test.js +0 -267
- package/v2Containers/InAppWrapper/components/inAppWrapperView.scss +0 -9
- package/v2Containers/InAppWrapper/constants.js +0 -16
- package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +0 -473
- package/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +0 -198
- package/v2Containers/InAppWrapper/index.js +0 -148
- package/v2Containers/InAppWrapper/messages.js +0 -49
- package/v2Containers/InappAdvance/index.js +0 -1099
- package/v2Containers/InappAdvance/index.scss +0 -10
- package/v2Containers/InappAdvance/tests/index.test.js +0 -448
|
@@ -0,0 +1,943 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { act } from 'react-dom/test-utils';
|
|
3
|
+
import { mountWithIntl, shallowWithIntl } from '../../../../../helpers/intl-enzym-test-helpers';
|
|
4
|
+
import WebPushPreview from '../WebPushPreview';
|
|
5
|
+
import PreviewControls from '../PreviewControls';
|
|
6
|
+
import PreviewContent from '../PreviewContent';
|
|
7
|
+
import PreviewDisclaimer from '../PreviewDisclaimer';
|
|
8
|
+
import DevicePreviewContent from '../DevicePreviewContent';
|
|
9
|
+
import CapSlideBox from '@capillarytech/cap-ui-library/CapSlideBox';
|
|
10
|
+
import CapButton from '@capillarytech/cap-ui-library/CapButton';
|
|
11
|
+
import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
12
|
+
import CapColumn from '@capillarytech/cap-ui-library/CapColumn';
|
|
13
|
+
import {
|
|
14
|
+
OS_OPTIONS,
|
|
15
|
+
DEFAULT_OS,
|
|
16
|
+
DEFAULT_BROWSER,
|
|
17
|
+
OS_MACOS,
|
|
18
|
+
OS_WINDOWS,
|
|
19
|
+
OS_IOS,
|
|
20
|
+
OS_IPADOS,
|
|
21
|
+
OS_ANDROID_MOBILE,
|
|
22
|
+
OS_ANDROID_TABLET,
|
|
23
|
+
BROWSER_CHROME,
|
|
24
|
+
BROWSER_FIREFOX,
|
|
25
|
+
BROWSER_EDGE,
|
|
26
|
+
BROWSER_SAFARI,
|
|
27
|
+
BROWSER_OPERA,
|
|
28
|
+
} from '../constants';
|
|
29
|
+
import { getBrowserOptionsForOS } from '../config/notificationMappings';
|
|
30
|
+
|
|
31
|
+
// Mock CapSlideBox to control its behavior in tests
|
|
32
|
+
jest.mock('@capillarytech/cap-ui-library/CapSlideBox', () => {
|
|
33
|
+
const React = require('react');
|
|
34
|
+
return function MockCapSlideBox({ show, handleClose, content, header, className, size }) {
|
|
35
|
+
// Always render the component (even when show is false) so we can test it
|
|
36
|
+
// But use display: none or similar to hide it when show is false
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
className={`mock-cap-slidebox ${className || ''}`}
|
|
40
|
+
data-size={size}
|
|
41
|
+
data-testid={className === 'webpush-preview-slidebox' ? 'webpush-slidebox' : undefined}
|
|
42
|
+
style={{ display: show ? 'block' : 'none' }}
|
|
43
|
+
>
|
|
44
|
+
<div className="mock-slidebox-header">{header}</div>
|
|
45
|
+
<button className="mock-slidebox-close" onClick={handleClose} data-testid="close-slidebox">
|
|
46
|
+
Close
|
|
47
|
+
</button>
|
|
48
|
+
{show && <div className="mock-slidebox-content">{content}</div>}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('WebPushPreview', () => {
|
|
55
|
+
const defaultProps = {
|
|
56
|
+
notificationTitle: 'Test Notification Title',
|
|
57
|
+
notificationBody: 'Test notification body text',
|
|
58
|
+
url: 'https://www.example.com',
|
|
59
|
+
imageSrc: 'https://example.com/image.jpg',
|
|
60
|
+
brandIconSrc: 'https://example.com/icon.png',
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
beforeEach(() => {
|
|
64
|
+
jest.clearAllMocks();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('Basic Rendering', () => {
|
|
68
|
+
it('should render correctly with default props', () => {
|
|
69
|
+
const wrapper = shallowWithIntl(<WebPushPreview {...defaultProps} />);
|
|
70
|
+
expect(wrapper).toMatchSnapshot();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should render with minimal props', () => {
|
|
74
|
+
const wrapper = mountWithIntl(<WebPushPreview />);
|
|
75
|
+
expect(wrapper.exists()).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should render main container with correct class', () => {
|
|
79
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
80
|
+
const container = wrapper.find('.webpush-preview-container').first();
|
|
81
|
+
expect(container.exists()).toBe(true);
|
|
82
|
+
expect(container.is(CapRow)).toBe(true);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should render PreviewControls component', () => {
|
|
86
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
87
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
88
|
+
expect(previewControls.exists()).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should render PreviewContent component', () => {
|
|
92
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
93
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
94
|
+
expect(previewContent.exists()).toBe(true);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should render PreviewDisclaimer component', () => {
|
|
98
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
99
|
+
const previewDisclaimer = wrapper.find(PreviewDisclaimer);
|
|
100
|
+
expect(previewDisclaimer.exists()).toBe(true);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should render "Preview in all devices" button', () => {
|
|
104
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
105
|
+
const buttonRow = wrapper.find('.preview-all-devices-button');
|
|
106
|
+
expect(buttonRow.exists()).toBe(true);
|
|
107
|
+
const button = buttonRow.find(CapButton);
|
|
108
|
+
expect(button.exists()).toBe(true);
|
|
109
|
+
expect(button.hasClass('preview-all-devices-trigger')).toBe(true);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should render CapSlideBox component', () => {
|
|
113
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
114
|
+
const allSlideBoxes = wrapper.find(CapSlideBox);
|
|
115
|
+
let found = false;
|
|
116
|
+
for (let i = 0; i < allSlideBoxes.length; i++) {
|
|
117
|
+
if (allSlideBoxes.at(i).prop('className') === 'webpush-preview-slidebox') {
|
|
118
|
+
found = true;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
expect(found).toBe(true);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('Initial State', () => {
|
|
127
|
+
it('should initialize with default OS', () => {
|
|
128
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
129
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
130
|
+
expect(previewControls.prop('selectedOS')).toBe(DEFAULT_OS);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('should initialize with default browser', () => {
|
|
134
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
135
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
136
|
+
expect(previewControls.prop('selectedBrowser')).toBe(DEFAULT_BROWSER);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should initialize with slidebox closed', () => {
|
|
140
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
141
|
+
const allSlideBoxes = wrapper.find(CapSlideBox);
|
|
142
|
+
let showState = null;
|
|
143
|
+
for (let i = 0; i < allSlideBoxes.length; i++) {
|
|
144
|
+
if (allSlideBoxes.at(i).prop('className') === 'webpush-preview-slidebox') {
|
|
145
|
+
showState = allSlideBoxes.at(i).prop('show');
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
expect(showState).toBe(false);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('should pass correct browser options for default OS', () => {
|
|
153
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
154
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
155
|
+
const expectedBrowserOptions = getBrowserOptionsForOS(DEFAULT_OS);
|
|
156
|
+
expect(previewControls.prop('browserOptions')).toEqual(expectedBrowserOptions);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
describe('PreviewControls Props', () => {
|
|
161
|
+
it('should pass correct props to PreviewControls', () => {
|
|
162
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
163
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
164
|
+
|
|
165
|
+
expect(previewControls.prop('selectedOS')).toBe(DEFAULT_OS);
|
|
166
|
+
expect(previewControls.prop('selectedBrowser')).toBe(DEFAULT_BROWSER);
|
|
167
|
+
expect(previewControls.prop('osOptions')).toBe(OS_OPTIONS);
|
|
168
|
+
expect(previewControls.prop('layoutMode')).toBe('newRow');
|
|
169
|
+
expect(previewControls.prop('showStateDropdown')).toBe(false);
|
|
170
|
+
|
|
171
|
+
const expectedBrowserOptions = getBrowserOptionsForOS(DEFAULT_OS);
|
|
172
|
+
expect(previewControls.prop('browserOptions')).toEqual(expectedBrowserOptions);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should pass onOSChange handler to PreviewControls', () => {
|
|
176
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
177
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
178
|
+
expect(typeof previewControls.prop('onOSChange')).toBe('function');
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('should pass onBrowserChange handler to PreviewControls', () => {
|
|
182
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
183
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
184
|
+
expect(typeof previewControls.prop('onBrowserChange')).toBe('function');
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe('PreviewContent Props', () => {
|
|
189
|
+
it('should pass correct props to PreviewContent', () => {
|
|
190
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
191
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
192
|
+
|
|
193
|
+
expect(previewContent.prop('notificationTitle')).toBe(defaultProps.notificationTitle);
|
|
194
|
+
expect(previewContent.prop('notificationBody')).toBe(defaultProps.notificationBody);
|
|
195
|
+
expect(previewContent.prop('url')).toBe(defaultProps.url);
|
|
196
|
+
expect(previewContent.prop('selectedOS')).toBe(DEFAULT_OS);
|
|
197
|
+
expect(previewContent.prop('selectedBrowser')).toBe(DEFAULT_BROWSER);
|
|
198
|
+
expect(previewContent.prop('notificationState')).toBe('Collapsed');
|
|
199
|
+
expect(previewContent.prop('imageSrc')).toBe(defaultProps.imageSrc);
|
|
200
|
+
expect(previewContent.prop('brandIconSrc')).toBe(defaultProps.brandIconSrc);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('should pass updated OS to PreviewContent when OS changes', () => {
|
|
204
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
205
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
206
|
+
|
|
207
|
+
act(() => {
|
|
208
|
+
previewControls.prop('onOSChange')(OS_WINDOWS);
|
|
209
|
+
});
|
|
210
|
+
wrapper.update();
|
|
211
|
+
|
|
212
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
213
|
+
expect(previewContent.prop('selectedOS')).toBe(OS_WINDOWS);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it('should pass updated browser to PreviewContent when browser changes', () => {
|
|
217
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
218
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
219
|
+
|
|
220
|
+
act(() => {
|
|
221
|
+
previewControls.prop('onBrowserChange')(BROWSER_FIREFOX);
|
|
222
|
+
});
|
|
223
|
+
wrapper.update();
|
|
224
|
+
|
|
225
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
226
|
+
expect(previewContent.prop('selectedBrowser')).toBe(BROWSER_FIREFOX);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe('OS Change and Browser Reset', () => {
|
|
231
|
+
it('should update OS when handleOSChange is called', () => {
|
|
232
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
233
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
234
|
+
|
|
235
|
+
act(() => {
|
|
236
|
+
previewControls.prop('onOSChange')(OS_WINDOWS);
|
|
237
|
+
});
|
|
238
|
+
wrapper.update();
|
|
239
|
+
|
|
240
|
+
const updatedControls = wrapper.find(PreviewControls);
|
|
241
|
+
expect(updatedControls.prop('selectedOS')).toBe(OS_WINDOWS);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('should reset browser to first available option when OS changes', () => {
|
|
245
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
246
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
247
|
+
|
|
248
|
+
// Start with macOS and Safari
|
|
249
|
+
act(() => {
|
|
250
|
+
previewControls.prop('onOSChange')(OS_MACOS);
|
|
251
|
+
previewControls.prop('onBrowserChange')(BROWSER_SAFARI);
|
|
252
|
+
});
|
|
253
|
+
wrapper.update();
|
|
254
|
+
|
|
255
|
+
expect(wrapper.find(PreviewControls).prop('selectedBrowser')).toBe(BROWSER_SAFARI);
|
|
256
|
+
|
|
257
|
+
// Change to Windows (Safari not supported)
|
|
258
|
+
act(() => {
|
|
259
|
+
previewControls.prop('onOSChange')(OS_WINDOWS);
|
|
260
|
+
});
|
|
261
|
+
wrapper.update();
|
|
262
|
+
|
|
263
|
+
// Browser should be reset to first available option for Windows
|
|
264
|
+
const windowsBrowserOptions = getBrowserOptionsForOS(OS_WINDOWS);
|
|
265
|
+
expect(wrapper.find(PreviewControls).prop('selectedBrowser')).toBe(windowsBrowserOptions[0].value);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('should update browser options when OS changes', () => {
|
|
269
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
270
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
271
|
+
|
|
272
|
+
// macOS should have all browsers including Safari
|
|
273
|
+
act(() => {
|
|
274
|
+
previewControls.prop('onOSChange')(OS_MACOS);
|
|
275
|
+
});
|
|
276
|
+
wrapper.update();
|
|
277
|
+
|
|
278
|
+
let browserOptions = wrapper.find(PreviewControls).prop('browserOptions');
|
|
279
|
+
expect(browserOptions.some(opt => opt.value === BROWSER_SAFARI)).toBe(true);
|
|
280
|
+
|
|
281
|
+
// Windows should not have Safari
|
|
282
|
+
act(() => {
|
|
283
|
+
previewControls.prop('onOSChange')(OS_WINDOWS);
|
|
284
|
+
});
|
|
285
|
+
wrapper.update();
|
|
286
|
+
|
|
287
|
+
browserOptions = wrapper.find(PreviewControls).prop('browserOptions');
|
|
288
|
+
expect(browserOptions.some(opt => opt.value === BROWSER_SAFARI)).toBe(false);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it('should handle OS change for iOS', () => {
|
|
292
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
293
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
294
|
+
|
|
295
|
+
act(() => {
|
|
296
|
+
previewControls.prop('onOSChange')(OS_IOS);
|
|
297
|
+
});
|
|
298
|
+
wrapper.update();
|
|
299
|
+
|
|
300
|
+
expect(wrapper.find(PreviewControls).prop('selectedOS')).toBe(OS_IOS);
|
|
301
|
+
const browserOptions = wrapper.find(PreviewControls).prop('browserOptions');
|
|
302
|
+
expect(browserOptions.some(opt => opt.value === BROWSER_SAFARI)).toBe(true);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
it('should handle OS change for iPadOS', () => {
|
|
306
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
307
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
308
|
+
|
|
309
|
+
act(() => {
|
|
310
|
+
previewControls.prop('onOSChange')(OS_IPADOS);
|
|
311
|
+
});
|
|
312
|
+
wrapper.update();
|
|
313
|
+
|
|
314
|
+
expect(wrapper.find(PreviewControls).prop('selectedOS')).toBe(OS_IPADOS);
|
|
315
|
+
const browserOptions = wrapper.find(PreviewControls).prop('browserOptions');
|
|
316
|
+
expect(browserOptions.some(opt => opt.value === BROWSER_SAFARI)).toBe(true);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it('should handle OS change for Android Mobile', () => {
|
|
320
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
321
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
322
|
+
|
|
323
|
+
act(() => {
|
|
324
|
+
previewControls.prop('onOSChange')(OS_ANDROID_MOBILE);
|
|
325
|
+
});
|
|
326
|
+
wrapper.update();
|
|
327
|
+
|
|
328
|
+
expect(wrapper.find(PreviewControls).prop('selectedOS')).toBe(OS_ANDROID_MOBILE);
|
|
329
|
+
const browserOptions = wrapper.find(PreviewControls).prop('browserOptions');
|
|
330
|
+
expect(browserOptions.some(opt => opt.value === BROWSER_SAFARI)).toBe(false);
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it('should handle OS change for Android Tablet', () => {
|
|
334
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
335
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
336
|
+
|
|
337
|
+
act(() => {
|
|
338
|
+
previewControls.prop('onOSChange')(OS_ANDROID_TABLET);
|
|
339
|
+
});
|
|
340
|
+
wrapper.update();
|
|
341
|
+
|
|
342
|
+
expect(wrapper.find(PreviewControls).prop('selectedOS')).toBe(OS_ANDROID_TABLET);
|
|
343
|
+
const browserOptions = wrapper.find(PreviewControls).prop('browserOptions');
|
|
344
|
+
expect(browserOptions.some(opt => opt.value === BROWSER_SAFARI)).toBe(false);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it('should reset browser when OS changes and current browser is not available', () => {
|
|
348
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
349
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
350
|
+
|
|
351
|
+
// Set to macOS with Safari
|
|
352
|
+
act(() => {
|
|
353
|
+
previewControls.prop('onOSChange')(OS_MACOS);
|
|
354
|
+
previewControls.prop('onBrowserChange')(BROWSER_SAFARI);
|
|
355
|
+
});
|
|
356
|
+
wrapper.update();
|
|
357
|
+
|
|
358
|
+
expect(wrapper.find(PreviewControls).prop('selectedBrowser')).toBe(BROWSER_SAFARI);
|
|
359
|
+
|
|
360
|
+
// Change to Windows (Safari not available)
|
|
361
|
+
act(() => {
|
|
362
|
+
previewControls.prop('onOSChange')(OS_WINDOWS);
|
|
363
|
+
});
|
|
364
|
+
wrapper.update();
|
|
365
|
+
|
|
366
|
+
// Should reset to first available browser (Chrome)
|
|
367
|
+
const windowsBrowserOptions = getBrowserOptionsForOS(OS_WINDOWS);
|
|
368
|
+
expect(wrapper.find(PreviewControls).prop('selectedBrowser')).toBe(windowsBrowserOptions[0].value);
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it('should not reset browser when OS changes and current browser is still available', () => {
|
|
372
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
373
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
374
|
+
|
|
375
|
+
// Set to macOS with Chrome
|
|
376
|
+
act(() => {
|
|
377
|
+
previewControls.prop('onOSChange')(OS_MACOS);
|
|
378
|
+
previewControls.prop('onBrowserChange')(BROWSER_CHROME);
|
|
379
|
+
});
|
|
380
|
+
wrapper.update();
|
|
381
|
+
|
|
382
|
+
expect(wrapper.find(PreviewControls).prop('selectedBrowser')).toBe(BROWSER_CHROME);
|
|
383
|
+
|
|
384
|
+
// Change to Windows (Chrome is still available)
|
|
385
|
+
act(() => {
|
|
386
|
+
previewControls.prop('onOSChange')(OS_WINDOWS);
|
|
387
|
+
});
|
|
388
|
+
wrapper.update();
|
|
389
|
+
|
|
390
|
+
// Browser should remain Chrome
|
|
391
|
+
expect(wrapper.find(PreviewControls).prop('selectedBrowser')).toBe(BROWSER_CHROME);
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
describe('Browser Change', () => {
|
|
396
|
+
it('should update browser when handleBrowserChange is called', () => {
|
|
397
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
398
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
399
|
+
|
|
400
|
+
act(() => {
|
|
401
|
+
previewControls.prop('onBrowserChange')(BROWSER_FIREFOX);
|
|
402
|
+
});
|
|
403
|
+
wrapper.update();
|
|
404
|
+
|
|
405
|
+
const updatedControls = wrapper.find(PreviewControls);
|
|
406
|
+
expect(updatedControls.prop('selectedBrowser')).toBe(BROWSER_FIREFOX);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
it('should handle browser change for Chrome', () => {
|
|
410
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
411
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
412
|
+
|
|
413
|
+
act(() => {
|
|
414
|
+
previewControls.prop('onBrowserChange')(BROWSER_CHROME);
|
|
415
|
+
});
|
|
416
|
+
wrapper.update();
|
|
417
|
+
|
|
418
|
+
expect(wrapper.find(PreviewControls).prop('selectedBrowser')).toBe(BROWSER_CHROME);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
it('should handle browser change for Firefox', () => {
|
|
422
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
423
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
424
|
+
|
|
425
|
+
act(() => {
|
|
426
|
+
previewControls.prop('onBrowserChange')(BROWSER_FIREFOX);
|
|
427
|
+
});
|
|
428
|
+
wrapper.update();
|
|
429
|
+
|
|
430
|
+
expect(wrapper.find(PreviewControls).prop('selectedBrowser')).toBe(BROWSER_FIREFOX);
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
it('should handle browser change for Edge', () => {
|
|
434
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
435
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
436
|
+
|
|
437
|
+
act(() => {
|
|
438
|
+
previewControls.prop('onBrowserChange')(BROWSER_EDGE);
|
|
439
|
+
});
|
|
440
|
+
wrapper.update();
|
|
441
|
+
|
|
442
|
+
expect(wrapper.find(PreviewControls).prop('selectedBrowser')).toBe(BROWSER_EDGE);
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
it('should handle browser change for Safari on macOS', () => {
|
|
446
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
447
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
448
|
+
|
|
449
|
+
act(() => {
|
|
450
|
+
previewControls.prop('onOSChange')(OS_MACOS);
|
|
451
|
+
previewControls.prop('onBrowserChange')(BROWSER_SAFARI);
|
|
452
|
+
});
|
|
453
|
+
wrapper.update();
|
|
454
|
+
|
|
455
|
+
expect(wrapper.find(PreviewControls).prop('selectedBrowser')).toBe(BROWSER_SAFARI);
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
it('should handle browser change for Opera', () => {
|
|
459
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
460
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
461
|
+
|
|
462
|
+
act(() => {
|
|
463
|
+
previewControls.prop('onBrowserChange')(BROWSER_OPERA);
|
|
464
|
+
});
|
|
465
|
+
wrapper.update();
|
|
466
|
+
|
|
467
|
+
expect(wrapper.find(PreviewControls).prop('selectedBrowser')).toBe(BROWSER_OPERA);
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
describe('Slidebox Toggle', () => {
|
|
472
|
+
// Helper to get the actual CapSlideBox component props
|
|
473
|
+
// Use .get(i) to get the actual React node instead of an Enzyme wrapper
|
|
474
|
+
const getSlideBoxShowState = (wrapper) => {
|
|
475
|
+
const allSlideBoxes = wrapper.find(CapSlideBox);
|
|
476
|
+
for (let i = 0; i < allSlideBoxes.length; i++) {
|
|
477
|
+
try {
|
|
478
|
+
const reactNode = allSlideBoxes.get(i);
|
|
479
|
+
if (reactNode && reactNode.props && reactNode.props.className === 'webpush-preview-slidebox') {
|
|
480
|
+
return reactNode.props.show;
|
|
481
|
+
}
|
|
482
|
+
} catch (e) {
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return null;
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
const getSlideBoxHandleClose = (wrapper) => {
|
|
490
|
+
const allSlideBoxes = wrapper.find(CapSlideBox);
|
|
491
|
+
for (let i = 0; i < allSlideBoxes.length; i++) {
|
|
492
|
+
try {
|
|
493
|
+
const reactNode = allSlideBoxes.get(i);
|
|
494
|
+
if (reactNode && reactNode.props && reactNode.props.className === 'webpush-preview-slidebox') {
|
|
495
|
+
return reactNode.props.handleClose;
|
|
496
|
+
}
|
|
497
|
+
} catch (e) {
|
|
498
|
+
continue;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return null;
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
const getSlideBoxProp = (wrapper, propName) => {
|
|
505
|
+
const allSlideBoxes = wrapper.find(CapSlideBox);
|
|
506
|
+
for (let i = 0; i < allSlideBoxes.length; i++) {
|
|
507
|
+
try {
|
|
508
|
+
const reactNode = allSlideBoxes.get(i);
|
|
509
|
+
if (reactNode && reactNode.props && reactNode.props.className === 'webpush-preview-slidebox') {
|
|
510
|
+
return reactNode.props[propName];
|
|
511
|
+
}
|
|
512
|
+
} catch (e) {
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return null;
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
it('should open slidebox when button is clicked', () => {
|
|
520
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
521
|
+
const button = wrapper.find('[data-test-id="webpush-preview-toggle"]').first();
|
|
522
|
+
|
|
523
|
+
expect(getSlideBoxShowState(wrapper)).toBe(false);
|
|
524
|
+
|
|
525
|
+
act(() => {
|
|
526
|
+
button.prop('onClick')();
|
|
527
|
+
});
|
|
528
|
+
wrapper.update();
|
|
529
|
+
|
|
530
|
+
expect(getSlideBoxShowState(wrapper)).toBe(true);
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
it('should close slidebox when handleClose is called', () => {
|
|
534
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
535
|
+
const button = wrapper.find('[data-test-id="webpush-preview-toggle"]').first();
|
|
536
|
+
|
|
537
|
+
// Open slidebox
|
|
538
|
+
act(() => {
|
|
539
|
+
button.prop('onClick')();
|
|
540
|
+
});
|
|
541
|
+
wrapper.update();
|
|
542
|
+
|
|
543
|
+
expect(getSlideBoxShowState(wrapper)).toBe(true);
|
|
544
|
+
|
|
545
|
+
// Close slidebox
|
|
546
|
+
const handleClose = getSlideBoxHandleClose(wrapper);
|
|
547
|
+
act(() => {
|
|
548
|
+
handleClose();
|
|
549
|
+
});
|
|
550
|
+
wrapper.update();
|
|
551
|
+
|
|
552
|
+
expect(getSlideBoxShowState(wrapper)).toBe(false);
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
it('should toggle slidebox multiple times', () => {
|
|
556
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
557
|
+
const button = wrapper.find('[data-test-id="webpush-preview-toggle"]').first();
|
|
558
|
+
|
|
559
|
+
// Open
|
|
560
|
+
act(() => {
|
|
561
|
+
button.prop('onClick')();
|
|
562
|
+
});
|
|
563
|
+
wrapper.update();
|
|
564
|
+
expect(getSlideBoxShowState(wrapper)).toBe(true);
|
|
565
|
+
|
|
566
|
+
// Close
|
|
567
|
+
const handleClose = getSlideBoxHandleClose(wrapper);
|
|
568
|
+
act(() => {
|
|
569
|
+
handleClose();
|
|
570
|
+
});
|
|
571
|
+
wrapper.update();
|
|
572
|
+
expect(getSlideBoxShowState(wrapper)).toBe(false);
|
|
573
|
+
|
|
574
|
+
// Open again
|
|
575
|
+
act(() => {
|
|
576
|
+
button.prop('onClick')();
|
|
577
|
+
});
|
|
578
|
+
wrapper.update();
|
|
579
|
+
expect(getSlideBoxShowState(wrapper)).toBe(true);
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
it('should pass correct props to CapSlideBox', () => {
|
|
583
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
584
|
+
|
|
585
|
+
expect(getSlideBoxProp(wrapper, 'size')).toBe('size-xl');
|
|
586
|
+
expect(getSlideBoxProp(wrapper, 'className')).toBe('webpush-preview-slidebox');
|
|
587
|
+
expect(typeof getSlideBoxProp(wrapper, 'handleClose')).toBe('function');
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
it('should render DevicePreviewContent inside slidebox when open', () => {
|
|
591
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
592
|
+
const button = wrapper.find('[data-test-id="webpush-preview-toggle"]').first();
|
|
593
|
+
|
|
594
|
+
act(() => {
|
|
595
|
+
button.prop('onClick')();
|
|
596
|
+
});
|
|
597
|
+
wrapper.update();
|
|
598
|
+
|
|
599
|
+
const slideBoxContent = getSlideBoxProp(wrapper, 'content');
|
|
600
|
+
|
|
601
|
+
// Check if the content is a DevicePreviewContent React element
|
|
602
|
+
expect(slideBoxContent).toBeDefined();
|
|
603
|
+
expect(slideBoxContent.type).toBe(DevicePreviewContent);
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
it('should pass correct props to DevicePreviewContent in slidebox', () => {
|
|
607
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
608
|
+
const button = wrapper.find('[data-test-id="webpush-preview-toggle"]').first();
|
|
609
|
+
|
|
610
|
+
act(() => {
|
|
611
|
+
button.prop('onClick')();
|
|
612
|
+
});
|
|
613
|
+
wrapper.update();
|
|
614
|
+
|
|
615
|
+
const slideBoxContent = getSlideBoxProp(wrapper, 'content');
|
|
616
|
+
|
|
617
|
+
// Check the props directly on the React element
|
|
618
|
+
expect(slideBoxContent.props.notificationTitle).toBe(defaultProps.notificationTitle);
|
|
619
|
+
expect(slideBoxContent.props.notificationBody).toBe(defaultProps.notificationBody);
|
|
620
|
+
expect(slideBoxContent.props.url).toBe(defaultProps.url);
|
|
621
|
+
expect(slideBoxContent.props.imageSrc).toBe(defaultProps.imageSrc);
|
|
622
|
+
expect(slideBoxContent.props.brandIconSrc).toBe(defaultProps.brandIconSrc);
|
|
623
|
+
});
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
describe('Different OS/Browser Combinations', () => {
|
|
627
|
+
const testCombinations = [
|
|
628
|
+
{ os: OS_MACOS, browser: BROWSER_CHROME },
|
|
629
|
+
{ os: OS_MACOS, browser: BROWSER_SAFARI },
|
|
630
|
+
{ os: OS_MACOS, browser: BROWSER_FIREFOX },
|
|
631
|
+
{ os: OS_WINDOWS, browser: BROWSER_CHROME },
|
|
632
|
+
{ os: OS_WINDOWS, browser: BROWSER_EDGE },
|
|
633
|
+
{ os: OS_IOS, browser: BROWSER_CHROME },
|
|
634
|
+
{ os: OS_IOS, browser: BROWSER_SAFARI },
|
|
635
|
+
{ os: OS_IPADOS, browser: BROWSER_CHROME },
|
|
636
|
+
{ os: OS_ANDROID_MOBILE, browser: BROWSER_CHROME },
|
|
637
|
+
{ os: OS_ANDROID_TABLET, browser: BROWSER_CHROME },
|
|
638
|
+
];
|
|
639
|
+
|
|
640
|
+
testCombinations.forEach(({ os, browser }) => {
|
|
641
|
+
it(`should handle ${os} + ${browser} combination`, () => {
|
|
642
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
643
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
644
|
+
|
|
645
|
+
act(() => {
|
|
646
|
+
previewControls.prop('onOSChange')(os);
|
|
647
|
+
});
|
|
648
|
+
wrapper.update();
|
|
649
|
+
|
|
650
|
+
act(() => {
|
|
651
|
+
previewControls.prop('onBrowserChange')(browser);
|
|
652
|
+
});
|
|
653
|
+
wrapper.update();
|
|
654
|
+
|
|
655
|
+
const updatedControls = wrapper.find(PreviewControls);
|
|
656
|
+
expect(updatedControls.prop('selectedOS')).toBe(os);
|
|
657
|
+
expect(updatedControls.prop('selectedBrowser')).toBe(browser);
|
|
658
|
+
|
|
659
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
660
|
+
expect(previewContent.prop('selectedOS')).toBe(os);
|
|
661
|
+
expect(previewContent.prop('selectedBrowser')).toBe(browser);
|
|
662
|
+
});
|
|
663
|
+
});
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
describe('Props Updates', () => {
|
|
667
|
+
it('should update PreviewContent when notificationTitle changes', () => {
|
|
668
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
669
|
+
|
|
670
|
+
wrapper.setProps({ notificationTitle: 'New Title' });
|
|
671
|
+
wrapper.update();
|
|
672
|
+
|
|
673
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
674
|
+
expect(previewContent.prop('notificationTitle')).toBe('New Title');
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
it('should update PreviewContent when notificationBody changes', () => {
|
|
678
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
679
|
+
|
|
680
|
+
wrapper.setProps({ notificationBody: 'New Body' });
|
|
681
|
+
wrapper.update();
|
|
682
|
+
|
|
683
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
684
|
+
expect(previewContent.prop('notificationBody')).toBe('New Body');
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
it('should update PreviewContent when url changes', () => {
|
|
688
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
689
|
+
|
|
690
|
+
wrapper.setProps({ url: 'https://new-url.com' });
|
|
691
|
+
wrapper.update();
|
|
692
|
+
|
|
693
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
694
|
+
expect(previewContent.prop('url')).toBe('https://new-url.com');
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
it('should update PreviewContent when imageSrc changes', () => {
|
|
698
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
699
|
+
|
|
700
|
+
wrapper.setProps({ imageSrc: 'https://new-image.jpg' });
|
|
701
|
+
wrapper.update();
|
|
702
|
+
|
|
703
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
704
|
+
expect(previewContent.prop('imageSrc')).toBe('https://new-image.jpg');
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
it('should update PreviewContent when brandIconSrc changes', () => {
|
|
708
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
709
|
+
|
|
710
|
+
wrapper.setProps({ brandIconSrc: 'https://new-icon.png' });
|
|
711
|
+
wrapper.update();
|
|
712
|
+
|
|
713
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
714
|
+
expect(previewContent.prop('brandIconSrc')).toBe('https://new-icon.png');
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
describe('Edge Cases', () => {
|
|
719
|
+
it('should handle empty notificationTitle', () => {
|
|
720
|
+
const wrapper = mountWithIntl(
|
|
721
|
+
<WebPushPreview
|
|
722
|
+
notificationTitle=""
|
|
723
|
+
notificationBody={defaultProps.notificationBody}
|
|
724
|
+
url={defaultProps.url}
|
|
725
|
+
/>
|
|
726
|
+
);
|
|
727
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
728
|
+
expect(previewContent.prop('notificationTitle')).toBe('');
|
|
729
|
+
});
|
|
730
|
+
|
|
731
|
+
it('should handle empty notificationBody', () => {
|
|
732
|
+
const wrapper = mountWithIntl(
|
|
733
|
+
<WebPushPreview
|
|
734
|
+
notificationTitle={defaultProps.notificationTitle}
|
|
735
|
+
notificationBody=""
|
|
736
|
+
url={defaultProps.url}
|
|
737
|
+
/>
|
|
738
|
+
);
|
|
739
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
740
|
+
expect(previewContent.prop('notificationBody')).toBe('');
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
it('should handle empty url', () => {
|
|
744
|
+
const wrapper = mountWithIntl(
|
|
745
|
+
<WebPushPreview
|
|
746
|
+
notificationTitle={defaultProps.notificationTitle}
|
|
747
|
+
notificationBody={defaultProps.notificationBody}
|
|
748
|
+
url=""
|
|
749
|
+
/>
|
|
750
|
+
);
|
|
751
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
752
|
+
expect(previewContent.prop('url')).toBe('');
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
it('should handle missing imageSrc and brandIconSrc', () => {
|
|
756
|
+
const wrapper = mountWithIntl(
|
|
757
|
+
<WebPushPreview
|
|
758
|
+
notificationTitle={defaultProps.notificationTitle}
|
|
759
|
+
notificationBody={defaultProps.notificationBody}
|
|
760
|
+
url={defaultProps.url}
|
|
761
|
+
/>
|
|
762
|
+
);
|
|
763
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
764
|
+
expect(previewContent.prop('imageSrc')).toBe('');
|
|
765
|
+
expect(previewContent.prop('brandIconSrc')).toBe('');
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
it('should handle rapid OS and browser changes', () => {
|
|
769
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
770
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
771
|
+
|
|
772
|
+
act(() => {
|
|
773
|
+
previewControls.prop('onOSChange')(OS_MACOS);
|
|
774
|
+
previewControls.prop('onBrowserChange')(BROWSER_CHROME);
|
|
775
|
+
});
|
|
776
|
+
wrapper.update();
|
|
777
|
+
|
|
778
|
+
act(() => {
|
|
779
|
+
previewControls.prop('onOSChange')(OS_WINDOWS);
|
|
780
|
+
previewControls.prop('onBrowserChange')(BROWSER_FIREFOX);
|
|
781
|
+
});
|
|
782
|
+
wrapper.update();
|
|
783
|
+
|
|
784
|
+
act(() => {
|
|
785
|
+
previewControls.prop('onOSChange')(OS_IOS);
|
|
786
|
+
previewControls.prop('onBrowserChange')(BROWSER_SAFARI);
|
|
787
|
+
});
|
|
788
|
+
wrapper.update();
|
|
789
|
+
|
|
790
|
+
const updatedControls = wrapper.find(PreviewControls);
|
|
791
|
+
expect(updatedControls.prop('selectedOS')).toBe(OS_IOS);
|
|
792
|
+
expect(updatedControls.prop('selectedBrowser')).toBe(BROWSER_SAFARI);
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
it('should handle browser options being empty array', () => {
|
|
796
|
+
// This shouldn't happen in practice, but test the edge case
|
|
797
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
798
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
799
|
+
|
|
800
|
+
// Change to an OS that might have empty options (shouldn't happen)
|
|
801
|
+
act(() => {
|
|
802
|
+
previewControls.prop('onOSChange')(OS_WINDOWS);
|
|
803
|
+
});
|
|
804
|
+
wrapper.update();
|
|
805
|
+
|
|
806
|
+
const browserOptions = wrapper.find(PreviewControls).prop('browserOptions');
|
|
807
|
+
expect(Array.isArray(browserOptions)).toBe(true);
|
|
808
|
+
expect(browserOptions.length).toBeGreaterThan(0);
|
|
809
|
+
});
|
|
810
|
+
});
|
|
811
|
+
|
|
812
|
+
describe('Component Integration', () => {
|
|
813
|
+
it('should update all child components when OS changes', () => {
|
|
814
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
815
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
816
|
+
|
|
817
|
+
act(() => {
|
|
818
|
+
previewControls.prop('onOSChange')(OS_WINDOWS);
|
|
819
|
+
});
|
|
820
|
+
wrapper.update();
|
|
821
|
+
|
|
822
|
+
const updatedControls = wrapper.find(PreviewControls);
|
|
823
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
824
|
+
|
|
825
|
+
expect(updatedControls.prop('selectedOS')).toBe(OS_WINDOWS);
|
|
826
|
+
expect(previewContent.prop('selectedOS')).toBe(OS_WINDOWS);
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
it('should update all child components when browser changes', () => {
|
|
830
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
831
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
832
|
+
|
|
833
|
+
act(() => {
|
|
834
|
+
previewControls.prop('onBrowserChange')(BROWSER_FIREFOX);
|
|
835
|
+
});
|
|
836
|
+
wrapper.update();
|
|
837
|
+
|
|
838
|
+
const updatedControls = wrapper.find(PreviewControls);
|
|
839
|
+
const previewContent = wrapper.find(PreviewContent);
|
|
840
|
+
|
|
841
|
+
expect(updatedControls.prop('selectedBrowser')).toBe(BROWSER_FIREFOX);
|
|
842
|
+
expect(previewContent.prop('selectedBrowser')).toBe(BROWSER_FIREFOX);
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
it('should maintain state consistency across components', () => {
|
|
846
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
847
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
848
|
+
|
|
849
|
+
act(() => {
|
|
850
|
+
previewControls.prop('onOSChange')(OS_MACOS);
|
|
851
|
+
previewControls.prop('onBrowserChange')(BROWSER_SAFARI);
|
|
852
|
+
});
|
|
853
|
+
wrapper.update();
|
|
854
|
+
|
|
855
|
+
const controls = wrapper.find(PreviewControls);
|
|
856
|
+
const content = wrapper.find(PreviewContent);
|
|
857
|
+
|
|
858
|
+
expect(controls.prop('selectedOS')).toBe(content.prop('selectedOS'));
|
|
859
|
+
expect(controls.prop('selectedBrowser')).toBe(content.prop('selectedBrowser'));
|
|
860
|
+
});
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
describe('Browser Options Filtering', () => {
|
|
864
|
+
it('should filter Safari from Windows browser options', () => {
|
|
865
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
866
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
867
|
+
|
|
868
|
+
act(() => {
|
|
869
|
+
previewControls.prop('onOSChange')(OS_WINDOWS);
|
|
870
|
+
});
|
|
871
|
+
wrapper.update();
|
|
872
|
+
|
|
873
|
+
const browserOptions = wrapper.find(PreviewControls).prop('browserOptions');
|
|
874
|
+
expect(browserOptions.some(opt => opt.value === BROWSER_SAFARI)).toBe(false);
|
|
875
|
+
});
|
|
876
|
+
|
|
877
|
+
it('should include Safari in macOS browser options', () => {
|
|
878
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
879
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
880
|
+
|
|
881
|
+
act(() => {
|
|
882
|
+
previewControls.prop('onOSChange')(OS_MACOS);
|
|
883
|
+
});
|
|
884
|
+
wrapper.update();
|
|
885
|
+
|
|
886
|
+
const browserOptions = wrapper.find(PreviewControls).prop('browserOptions');
|
|
887
|
+
expect(browserOptions.some(opt => opt.value === BROWSER_SAFARI)).toBe(true);
|
|
888
|
+
});
|
|
889
|
+
|
|
890
|
+
it('should include Safari in iOS browser options', () => {
|
|
891
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
892
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
893
|
+
|
|
894
|
+
act(() => {
|
|
895
|
+
previewControls.prop('onOSChange')(OS_IOS);
|
|
896
|
+
});
|
|
897
|
+
wrapper.update();
|
|
898
|
+
|
|
899
|
+
const browserOptions = wrapper.find(PreviewControls).prop('browserOptions');
|
|
900
|
+
expect(browserOptions.some(opt => opt.value === BROWSER_SAFARI)).toBe(true);
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
it('should include Safari in iPadOS browser options', () => {
|
|
904
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
905
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
906
|
+
|
|
907
|
+
act(() => {
|
|
908
|
+
previewControls.prop('onOSChange')(OS_IPADOS);
|
|
909
|
+
});
|
|
910
|
+
wrapper.update();
|
|
911
|
+
|
|
912
|
+
const browserOptions = wrapper.find(PreviewControls).prop('browserOptions');
|
|
913
|
+
expect(browserOptions.some(opt => opt.value === BROWSER_SAFARI)).toBe(true);
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
it('should exclude Safari from Android Mobile browser options', () => {
|
|
917
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
918
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
919
|
+
|
|
920
|
+
act(() => {
|
|
921
|
+
previewControls.prop('onOSChange')(OS_ANDROID_MOBILE);
|
|
922
|
+
});
|
|
923
|
+
wrapper.update();
|
|
924
|
+
|
|
925
|
+
const browserOptions = wrapper.find(PreviewControls).prop('browserOptions');
|
|
926
|
+
expect(browserOptions.some(opt => opt.value === BROWSER_SAFARI)).toBe(false);
|
|
927
|
+
});
|
|
928
|
+
|
|
929
|
+
it('should exclude Safari from Android Tablet browser options', () => {
|
|
930
|
+
const wrapper = mountWithIntl(<WebPushPreview {...defaultProps} />);
|
|
931
|
+
const previewControls = wrapper.find(PreviewControls);
|
|
932
|
+
|
|
933
|
+
act(() => {
|
|
934
|
+
previewControls.prop('onOSChange')(OS_ANDROID_TABLET);
|
|
935
|
+
});
|
|
936
|
+
wrapper.update();
|
|
937
|
+
|
|
938
|
+
const browserOptions = wrapper.find(PreviewControls).prop('browserOptions');
|
|
939
|
+
expect(browserOptions.some(opt => opt.value === BROWSER_SAFARI)).toBe(false);
|
|
940
|
+
});
|
|
941
|
+
});
|
|
942
|
+
});
|
|
943
|
+
|