cap-creatives-ui 8.0.280 → 8.0.321
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/.github/workflows/pr-title-check.yml +88 -0
- package/app/constants/unified.js +21 -1
- package/app/containers/App/constants.js +0 -1
- package/app/containers/Login/test/index.test.js +123 -0
- package/app/containers/Login/test/selectors.test.js +165 -0
- package/app/initialState.js +0 -2
- package/app/services/api.js +6 -0
- package/app/services/tests/api.test.js +7 -0
- package/app/services/tests/getSchema.test.js +95 -0
- package/app/utils/common.js +23 -9
- package/app/utils/commonUtils.js +64 -93
- package/app/utils/tagValidations.js +83 -219
- package/app/utils/templateVarUtils.js +172 -0
- package/app/utils/tests/common.test.js +265 -323
- package/app/utils/tests/commonUtil.test.js +461 -118
- package/app/utils/tests/commonUtils.test.js +581 -0
- package/app/utils/tests/messageUtils.test.js +95 -0
- package/app/utils/tests/smsCharCount.test.js +304 -0
- package/app/utils/tests/smsCharCountV2.test.js +213 -10
- package/app/utils/tests/tagValidations.test.js +474 -357
- package/app/utils/tests/templateVarUtils.test.js +160 -0
- package/app/v2Components/CapDeviceContent/index.js +10 -7
- package/app/v2Components/CapTagList/index.js +32 -24
- package/app/v2Components/CapTagList/style.scss +48 -0
- package/app/v2Components/CapTagListWithInput/__tests__/CapTagListWithInput.test.js +63 -0
- package/app/v2Components/CapTagListWithInput/index.js +8 -0
- package/app/v2Components/CapWhatsappCTA/index.js +2 -0
- package/app/v2Components/CapWhatsappCarouselButton/index.js +32 -14
- package/app/v2Components/CapWhatsappCarouselButton/tests/index.test.js +120 -2
- package/app/v2Components/CommonTestAndPreview/CustomValuesEditor.js +70 -49
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +39 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +606 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +36 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +79 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/index.js +314 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +141 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +156 -0
- package/app/v2Components/CommonTestAndPreview/SendTestMessage.js +57 -1
- package/app/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +20 -1
- package/app/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +133 -4
- package/app/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +210 -4
- package/app/v2Components/CommonTestAndPreview/actions.js +20 -0
- package/app/v2Components/CommonTestAndPreview/constants.js +57 -1
- package/app/v2Components/CommonTestAndPreview/index.js +878 -156
- package/app/v2Components/CommonTestAndPreview/messages.js +41 -3
- package/app/v2Components/CommonTestAndPreview/previewApiUtils.js +59 -0
- package/app/v2Components/CommonTestAndPreview/reducer.js +47 -0
- package/app/v2Components/CommonTestAndPreview/sagas.js +75 -5
- package/app/v2Components/CommonTestAndPreview/selectors.js +51 -0
- package/app/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +352 -0
- package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +1156 -0
- package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +334 -0
- package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +576 -0
- package/app/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +156 -0
- package/app/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +199 -1
- package/app/v2Components/CommonTestAndPreview/tests/actions.test.js +50 -0
- package/app/v2Components/CommonTestAndPreview/tests/constants.test.js +18 -7
- package/app/v2Components/CommonTestAndPreview/tests/index.test.js +914 -5
- package/app/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +67 -0
- package/app/v2Components/CommonTestAndPreview/tests/reducer.test.js +118 -0
- package/app/v2Components/CommonTestAndPreview/tests/sagas.test.js +146 -378
- package/app/v2Components/CommonTestAndPreview/tests/selectors.test.js +146 -0
- package/app/v2Components/ErrorInfoNote/index.js +24 -26
- package/app/v2Components/FormBuilder/index.js +182 -204
- package/app/v2Components/FormBuilder/messages.js +4 -8
- package/app/v2Components/HtmlEditor/HTMLEditor.js +7 -6
- package/app/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +1 -1
- package/app/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +928 -17
- package/app/v2Components/HtmlEditor/components/CodeEditorPane/index.js +4 -2
- package/app/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +452 -3
- package/app/v2Components/HtmlEditor/hooks/useValidation.js +12 -9
- package/app/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +132 -0
- package/app/v2Components/HtmlEditor/utils/htmlValidator.js +4 -2
- package/app/v2Components/SmsFallback/SmsFallbackLocalSelector.js +87 -0
- package/app/v2Components/SmsFallback/constants.js +73 -0
- package/app/v2Components/SmsFallback/index.js +956 -0
- package/app/v2Components/SmsFallback/index.scss +265 -0
- package/app/v2Components/SmsFallback/messages.js +78 -0
- package/app/v2Components/SmsFallback/smsFallbackUtils.js +107 -0
- package/app/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +50 -0
- package/app/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +147 -0
- package/app/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +304 -0
- package/app/v2Components/SmsFallback/tests/smsFallbackUi.test.js +197 -0
- package/app/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +261 -0
- package/app/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +422 -0
- package/app/v2Components/SmsFallback/useLocalTemplateList.js +92 -0
- package/app/v2Components/TestAndPreviewSlidebox/index.js +22 -1
- package/app/v2Components/TestAndPreviewSlidebox/sagas.js +11 -4
- package/app/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +3 -1
- package/app/v2Components/VarSegmentMessageEditor/constants.js +2 -0
- package/app/v2Components/VarSegmentMessageEditor/index.js +125 -0
- package/app/v2Components/VarSegmentMessageEditor/index.scss +46 -0
- package/app/v2Containers/BeeEditor/index.js +3 -0
- package/app/v2Containers/BeePopupEditor/index.js +9 -2
- package/app/v2Containers/Cap/mockData.js +0 -14
- package/app/v2Containers/Cap/reducer.js +3 -55
- package/app/v2Containers/Cap/tests/reducer.test.js +0 -102
- package/app/v2Containers/CommunicationFlow/CommunicationFlow.js +291 -0
- package/app/v2Containers/CommunicationFlow/CommunicationFlow.scss +25 -0
- package/app/v2Containers/CommunicationFlow/Tests/CommunicationFlow.test.js +255 -0
- package/app/v2Containers/CommunicationFlow/constants.js +200 -0
- package/app/v2Containers/CommunicationFlow/index.js +102 -0
- package/app/v2Containers/CommunicationFlow/messages.js +346 -0
- package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.js +522 -0
- package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.scss +170 -0
- package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/ChannelSelectionStep.test.js +796 -0
- package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/index.js +5 -0
- package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/CommunicationStrategyStep.js +95 -0
- package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/Tests/CommunicationStrategyStep.test.js +133 -0
- package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/index.js +5 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +289 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.scss +70 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.js +319 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.scss +69 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/DeliverySettingsSection.test.js +616 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/SenderDetails.test.js +577 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/deliverySettingsConfig.test.js +1111 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/deliverySettingsConfig.js +696 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/index.js +7 -0
- package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/DynamicControlsStep.js +102 -0
- package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/DynamicControlsStep.scss +36 -0
- package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/Tests/DynamicControlsStep.test.js +91 -0
- package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/index.js +5 -0
- package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/MessageTypeStep.js +86 -0
- package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/Tests/MessageTypeStep.test.js +100 -0
- package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/index.js +5 -0
- package/app/v2Containers/CommunicationFlow/utils/getEnabledSteps.js +30 -0
- package/app/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +43 -0
- package/app/v2Containers/CreativesContainer/SlideBoxContent.js +127 -11
- package/app/v2Containers/CreativesContainer/SlideBoxFooter.js +62 -9
- package/app/v2Containers/CreativesContainer/SlideBoxHeader.js +29 -4
- package/app/v2Containers/CreativesContainer/constants.js +24 -0
- package/app/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +67 -0
- package/app/v2Containers/CreativesContainer/index.js +346 -71
- package/app/v2Containers/CreativesContainer/index.scss +51 -1
- package/app/v2Containers/CreativesContainer/messages.js +12 -0
- package/app/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +90 -0
- package/app/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +69 -1
- package/app/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +443 -0
- package/app/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +110 -0
- package/app/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +147 -4
- package/app/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +363 -0
- package/app/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +57 -10
- package/app/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +258 -0
- package/app/v2Containers/CreativesContainer/tests/index.test.js +71 -9
- package/app/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +125 -0
- package/app/v2Containers/Email/index.js +2 -5
- package/app/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +58 -77
- package/app/v2Containers/EmailWrapper/components/EmailWrapperView.js +3 -0
- package/app/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +158 -89
- package/app/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +16 -1
- package/app/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +17 -12
- package/app/v2Containers/EmailWrapper/index.js +4 -0
- package/app/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +1 -0
- package/app/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +133 -0
- package/app/v2Containers/FTP/index.js +2 -51
- package/app/v2Containers/FTP/messages.js +0 -4
- package/app/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +110 -155
- package/app/v2Containers/InApp/index.js +297 -118
- package/app/v2Containers/InApp/tests/index.test.js +17 -6
- package/app/v2Containers/InApp/tests/mockData.js +1 -1
- package/app/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +19 -0
- package/app/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +3 -0
- package/app/v2Containers/InAppWrapper/index.js +3 -0
- package/app/v2Containers/InappAdvance/index.js +5 -104
- package/app/v2Containers/InappAdvance/tests/index.test.js +2 -0
- package/app/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +24 -3
- package/app/v2Containers/Line/Container/Text/index.js +0 -1
- package/app/v2Containers/MobilePush/Create/index.js +105 -28
- package/app/v2Containers/MobilePush/Create/messages.js +4 -0
- package/app/v2Containers/MobilePush/Edit/index.js +250 -68
- package/app/v2Containers/MobilePush/Edit/messages.js +4 -0
- package/app/v2Containers/MobilePushNew/components/PlatformContentFields.js +36 -12
- package/app/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +68 -27
- package/app/v2Containers/MobilePushNew/index.js +78 -35
- package/app/v2Containers/MobilePushNew/messages.js +8 -0
- package/app/v2Containers/MobilepushWrapper/index.js +11 -1
- package/app/v2Containers/Rcs/constants.js +32 -1
- package/app/v2Containers/Rcs/index.js +963 -916
- package/app/v2Containers/Rcs/index.scss +85 -6
- package/app/v2Containers/Rcs/messages.js +10 -1
- package/app/v2Containers/Rcs/rcsLibraryHydrationUtils.js +205 -0
- package/app/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +41136 -1566
- package/app/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +0 -5
- package/app/v2Containers/Rcs/tests/index.test.js +41 -38
- package/app/v2Containers/Rcs/tests/mockData.js +38 -0
- package/app/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +251 -0
- package/app/v2Containers/Rcs/tests/utils.test.js +379 -1
- package/app/v2Containers/Rcs/utils.js +358 -10
- package/app/v2Containers/Sms/Create/index.js +122 -39
- package/app/v2Containers/Sms/Create/messages.js +4 -0
- package/app/v2Containers/Sms/Edit/index.js +37 -3
- package/app/v2Containers/Sms/commonMethods.js +3 -6
- package/app/v2Containers/Sms/smsFormDataHelpers.js +67 -0
- package/app/v2Containers/Sms/tests/commonMethods.test.js +122 -0
- package/app/v2Containers/Sms/tests/smsFormDataHelpers.test.js +253 -0
- package/app/v2Containers/SmsTrai/Create/index.js +9 -4
- package/app/v2Containers/SmsTrai/Create/index.scss +1 -1
- package/app/v2Containers/SmsTrai/Edit/constants.js +2 -0
- package/app/v2Containers/SmsTrai/Edit/index.js +667 -160
- package/app/v2Containers/SmsTrai/Edit/index.scss +121 -0
- package/app/v2Containers/SmsTrai/Edit/messages.js +9 -4
- package/app/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4590 -2436
- package/app/v2Containers/SmsWrapper/index.js +41 -8
- package/app/v2Containers/TagList/index.js +63 -2
- package/app/v2Containers/TagList/messages.js +8 -0
- package/app/v2Containers/TagList/tests/TagList.test.js +122 -20
- package/app/v2Containers/TagList/tests/mockdata.js +17 -0
- package/app/v2Containers/Templates/TemplatesActionBar.js +101 -0
- package/app/v2Containers/Templates/_templates.scss +61 -2
- package/app/v2Containers/Templates/actions.js +11 -0
- package/app/v2Containers/Templates/constants.js +2 -0
- package/app/v2Containers/Templates/index.js +90 -40
- package/app/v2Containers/Templates/reducer.js +3 -1
- package/app/v2Containers/Templates/sagas.js +57 -12
- package/app/v2Containers/Templates/tests/TemplatesActionBar.test.js +120 -0
- package/app/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1043 -1079
- package/app/v2Containers/Templates/tests/reducer.test.js +12 -0
- package/app/v2Containers/Templates/tests/sagas.test.js +193 -12
- package/app/v2Containers/Templates/tests/smsTemplatesListApi.test.js +180 -0
- package/app/v2Containers/Templates/utils/smsTemplatesListApi.js +79 -0
- package/app/v2Containers/TemplatesV2/TemplatesV2.style.js +72 -1
- package/app/v2Containers/TemplatesV2/index.js +147 -49
- package/app/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +131 -0
- package/app/v2Containers/Viber/index.js +9 -10
- package/app/v2Containers/Viber/index.scss +1 -1
- package/app/v2Containers/WebPush/Create/components/BrandIconSection.test.js +264 -0
- package/app/v2Containers/WebPush/Create/components/MessageSection.js +78 -19
- package/app/v2Containers/WebPush/Create/components/MessageSection.test.js +82 -0
- package/app/v2Containers/WebPush/Create/components/__snapshots__/BrandIconSection.test.js.snap +187 -0
- package/app/v2Containers/WebPush/Create/components/__snapshots__/MessageSection.test.js.snap +25 -17
- package/app/v2Containers/WebPush/Create/hooks/useAiraTriggerPosition.js +80 -0
- package/app/v2Containers/WebPush/Create/hooks/useAiraTriggerPosition.test.js +210 -0
- package/app/v2Containers/WebPush/Create/hooks/useTagManagement.js +1 -5
- package/app/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +0 -7
- package/app/v2Containers/WebPush/Create/index.js +36 -6
- package/app/v2Containers/WebPush/Create/index.scss +5 -0
- package/app/v2Containers/WebPush/Create/messages.js +8 -1
- package/app/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +269 -0
- package/app/v2Containers/WebPush/Create/utils/validation.js +31 -15
- package/app/v2Containers/WebPush/Create/utils/validation.test.js +72 -24
- package/app/v2Containers/Whatsapp/index.js +28 -53
- package/app/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +26939 -3982
- package/app/v2Containers/Whatsapp/tests/index.test.js +172 -0
- package/app/v2Containers/Zalo/index.js +5 -11
- package/package.json +2 -2
- package/version +9 -0
|
@@ -102,6 +102,7 @@ describe('useEmailWrapper', () => {
|
|
|
102
102
|
editor: null,
|
|
103
103
|
moduleType: '',
|
|
104
104
|
eventContextTags: [],
|
|
105
|
+
waitEventContextTags: {},
|
|
105
106
|
isLoyaltyModule: false,
|
|
106
107
|
cmsTemplatesLoader: false,
|
|
107
108
|
currentOrgDetails: { id: 'org1' },
|
|
@@ -120,6 +121,14 @@ describe('useEmailWrapper', () => {
|
|
|
120
121
|
expect(result.current.onTemplateNameChange).toBeInstanceOf(Function);
|
|
121
122
|
});
|
|
122
123
|
|
|
124
|
+
it('passes waitEventContextTags through emailProps', () => {
|
|
125
|
+
const waitMap = { block1: { eventName: 'E', blockName: 'B', tags: [] } };
|
|
126
|
+
const { result } = renderHook(() =>
|
|
127
|
+
useEmailWrapper({ ...mockProps, waitEventContextTags: waitMap }),
|
|
128
|
+
);
|
|
129
|
+
expect(result.current.emailProps.waitEventContextTags).toEqual(waitMap);
|
|
130
|
+
});
|
|
131
|
+
|
|
123
132
|
it('handles template name change correctly', () => {
|
|
124
133
|
const { result } = renderHook(() => useEmailWrapper(mockProps));
|
|
125
134
|
|
|
@@ -768,6 +777,130 @@ describe('useEmailWrapper', () => {
|
|
|
768
777
|
});
|
|
769
778
|
});
|
|
770
779
|
|
|
780
|
+
describe('templateId resolution (lines 209-213)', () => {
|
|
781
|
+
it('should call getTemplateDetails with templateId from params.id', async () => {
|
|
782
|
+
const templateId = 'from-params-id';
|
|
783
|
+
const editProps = {
|
|
784
|
+
...newFlowMockProps,
|
|
785
|
+
params: { id: templateId },
|
|
786
|
+
location: { pathname: '/email/edit/other', query: {} },
|
|
787
|
+
Email: {
|
|
788
|
+
...newFlowMockProps.Email,
|
|
789
|
+
templateDetails: null,
|
|
790
|
+
getTemplateDetailsInProgress: false,
|
|
791
|
+
},
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
renderHook((props) => useEmailWrapper(props), {
|
|
795
|
+
initialProps: editProps,
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
await waitFor(() => {
|
|
799
|
+
expect(mockEmailActions.getTemplateDetails).toHaveBeenCalledWith(templateId, 'email');
|
|
800
|
+
});
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
it('should call getTemplateDetails with templateId from location.query.id when params.id is missing', async () => {
|
|
804
|
+
const templateId = 'from-query-id';
|
|
805
|
+
const editProps = {
|
|
806
|
+
...newFlowMockProps,
|
|
807
|
+
params: {},
|
|
808
|
+
location: {
|
|
809
|
+
pathname: '/email/edit/something',
|
|
810
|
+
query: { id: templateId },
|
|
811
|
+
},
|
|
812
|
+
Email: {
|
|
813
|
+
...newFlowMockProps.Email,
|
|
814
|
+
templateDetails: null,
|
|
815
|
+
getTemplateDetailsInProgress: false,
|
|
816
|
+
},
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
renderHook((props) => useEmailWrapper(props), {
|
|
820
|
+
initialProps: editProps,
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
await waitFor(() => {
|
|
824
|
+
expect(mockEmailActions.getTemplateDetails).toHaveBeenCalledWith(templateId, 'email');
|
|
825
|
+
});
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
it('should call getTemplateDetails with templateId from location.params.id when params and query id are missing', async () => {
|
|
829
|
+
const templateId = 'from-location-params-id';
|
|
830
|
+
const editProps = {
|
|
831
|
+
...newFlowMockProps,
|
|
832
|
+
params: {},
|
|
833
|
+
location: {
|
|
834
|
+
pathname: '/email/edit/fallback',
|
|
835
|
+
query: {},
|
|
836
|
+
params: { id: templateId },
|
|
837
|
+
},
|
|
838
|
+
Email: {
|
|
839
|
+
...newFlowMockProps.Email,
|
|
840
|
+
templateDetails: null,
|
|
841
|
+
getTemplateDetailsInProgress: false,
|
|
842
|
+
},
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
renderHook((props) => useEmailWrapper(props), {
|
|
846
|
+
initialProps: editProps,
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
await waitFor(() => {
|
|
850
|
+
expect(mockEmailActions.getTemplateDetails).toHaveBeenCalledWith(templateId, 'email');
|
|
851
|
+
});
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
it('should call getTemplateDetails with templateId extracted from pathname /edit/ID when no params or query id', async () => {
|
|
855
|
+
const templateId = 'extracted-from-pathname';
|
|
856
|
+
const editProps = {
|
|
857
|
+
...newFlowMockProps,
|
|
858
|
+
params: {},
|
|
859
|
+
location: {
|
|
860
|
+
pathname: `/email/edit/${templateId}`,
|
|
861
|
+
query: {},
|
|
862
|
+
},
|
|
863
|
+
Email: {
|
|
864
|
+
...newFlowMockProps.Email,
|
|
865
|
+
templateDetails: null,
|
|
866
|
+
getTemplateDetailsInProgress: false,
|
|
867
|
+
},
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
renderHook((props) => useEmailWrapper(props), {
|
|
871
|
+
initialProps: editProps,
|
|
872
|
+
});
|
|
873
|
+
|
|
874
|
+
await waitFor(() => {
|
|
875
|
+
expect(mockEmailActions.getTemplateDetails).toHaveBeenCalledWith(templateId, 'email');
|
|
876
|
+
});
|
|
877
|
+
});
|
|
878
|
+
|
|
879
|
+
it('should not call getTemplateDetails when pathname includes /edit/ but has no id segment', async () => {
|
|
880
|
+
const editProps = {
|
|
881
|
+
...newFlowMockProps,
|
|
882
|
+
params: {},
|
|
883
|
+
location: {
|
|
884
|
+
pathname: '/email/edit/',
|
|
885
|
+
query: {},
|
|
886
|
+
},
|
|
887
|
+
Email: {
|
|
888
|
+
...newFlowMockProps.Email,
|
|
889
|
+
templateDetails: null,
|
|
890
|
+
getTemplateDetailsInProgress: false,
|
|
891
|
+
},
|
|
892
|
+
};
|
|
893
|
+
|
|
894
|
+
renderHook((props) => useEmailWrapper(props), {
|
|
895
|
+
initialProps: editProps,
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
await waitFor(() => {
|
|
899
|
+
expect(mockEmailActions.getTemplateDetails).not.toHaveBeenCalled();
|
|
900
|
+
}, { timeout: 500 });
|
|
901
|
+
});
|
|
902
|
+
});
|
|
903
|
+
|
|
771
904
|
describe('Edit Flow - BEE Editor Template', () => {
|
|
772
905
|
it('should call getTemplateDetails and set BEE editor for BEE template', async () => {
|
|
773
906
|
const templateId = 'bee-template-123';
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
CapTooltip,
|
|
23
23
|
} from '@capillarytech/cap-ui-library';
|
|
24
24
|
import { FONT_SIZE_L } from '@capillarytech/cap-ui-library/styled/variables';
|
|
25
|
-
import _, { find, cloneDeep, findIndex, isEmpty, isEqual, filter,
|
|
25
|
+
import _, { find, cloneDeep, findIndex, isEmpty, isEqual, filter, replace } from 'lodash';
|
|
26
26
|
import * as actions from './actions';
|
|
27
27
|
import { makeSelectFTP, makeSelectMetaEntities } from './selectors';
|
|
28
28
|
import { makeSelectLoyaltyPromotionDisplay, setInjectedTags } from '../Cap/selectors';
|
|
@@ -33,7 +33,6 @@ import * as globalActions from '../Cap/actions';
|
|
|
33
33
|
import { TagList } from '../TagList';
|
|
34
34
|
import { NO_COMMUNICATION, CREATE, EDIT, PREVIEW } from '../App/constants';
|
|
35
35
|
import { getTreeStructuredTags } from '../../utils/common';
|
|
36
|
-
import { transformInjectedTags, checkIfSupportedTag, skipTags } from '../../utils/tagValidations';
|
|
37
36
|
import injectSaga from '../../utils/injectSaga';
|
|
38
37
|
import injectReducer from '../../utils/injectReducer';
|
|
39
38
|
|
|
@@ -235,63 +234,16 @@ export class FTP extends React.Component {
|
|
|
235
234
|
}));
|
|
236
235
|
};
|
|
237
236
|
|
|
238
|
-
getFlatTags = (tags) => {
|
|
239
|
-
const flatTags = [];
|
|
240
|
-
tags.forEach((tag) => {
|
|
241
|
-
if ((tag.children || []).length) {
|
|
242
|
-
const innerTags = this.getFlatTags(tag.children);
|
|
243
|
-
flatTags.push(innerTags);
|
|
244
|
-
} else {
|
|
245
|
-
flatTags.push(tag.value);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
return flattenDeep(flatTags);
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
validateTags(content, tagsParam, injectedTagsParams) {
|
|
253
|
-
const tags = tagsParam;
|
|
254
|
-
const injectedTags = transformInjectedTags(injectedTagsParams);
|
|
255
|
-
const response = {};
|
|
256
|
-
response.valid = true;
|
|
257
|
-
response.unsupportedTags = [];
|
|
258
|
-
const flatTags = this.getFlatTags(tags);
|
|
259
|
-
if (flatTags && flatTags.length) {
|
|
260
|
-
const regex = /{{[(A-Z\w+(\s\w+)*$\(\)@!#$%^&*~.,/\\]+}}/g;
|
|
261
|
-
const matchedTags = [...content.matchAll(regex)];
|
|
262
|
-
matchedTags.forEach((tag) => {
|
|
263
|
-
let ifSupported = !!flatTags.find((t) => t === tag[0]);
|
|
264
|
-
const tagValue = tag[0].substring(this.indexOfEnd(tag[0], '{{'), tag[0].indexOf('}}'));
|
|
265
|
-
ifSupported = ifSupported || checkIfSupportedTag(tagValue, injectedTags) || skipTags(tagValue);
|
|
266
|
-
if (!ifSupported) {
|
|
267
|
-
response.unsupportedTags.push(tagValue);
|
|
268
|
-
response.valid = false;
|
|
269
|
-
}
|
|
270
|
-
if (response.unsupportedTags.length === 0) {
|
|
271
|
-
response.valid = true;
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
return response;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
237
|
indexOfEnd(targetString, string) {
|
|
279
238
|
const io = targetString.indexOf(string);
|
|
280
239
|
return io == -1 ? -1 : io + string.length;
|
|
281
240
|
}
|
|
282
241
|
|
|
283
242
|
getMessageContent = () => {
|
|
284
|
-
const { messageContent
|
|
243
|
+
const { messageContent } = this.state;
|
|
285
244
|
const { formatMessage } = this.props.intl;
|
|
286
245
|
const { metaEntities, selectedOfferDetails, injectedTags } = this.props;
|
|
287
246
|
const tagsRaw = metaEntities && metaEntities.tags ? metaEntities.tags.standard : [];
|
|
288
|
-
const validateTagResponse = !this.props?.isFullMode ? this.validateTags(messageContent, tagsTree, injectedTags) : { valid: true, unsupportedTags: [] };
|
|
289
|
-
let unsupportedTags = null;
|
|
290
|
-
let errorMessageText = '';
|
|
291
|
-
if (!validateTagResponse.valid) {
|
|
292
|
-
unsupportedTags = validateTagResponse.unsupportedTags.join(', ').toString();
|
|
293
|
-
errorMessageText = formatMessage(messages.unsupportedTagsValidationError, {unsupportedTags});
|
|
294
|
-
}
|
|
295
247
|
return (
|
|
296
248
|
<CapRow>
|
|
297
249
|
<CapColumn span={11}>
|
|
@@ -309,7 +261,6 @@ export class FTP extends React.Component {
|
|
|
309
261
|
label={formatMessage(messages.messageHeader)}
|
|
310
262
|
onChange={this.updateMessageBody}
|
|
311
263
|
value={messageContent}
|
|
312
|
-
errorMessage={errorMessageText}
|
|
313
264
|
/>
|
|
314
265
|
</div>
|
|
315
266
|
</CapColumn>
|
|
@@ -21,10 +21,6 @@ export default defineMessages({
|
|
|
21
21
|
id: 'creatives.containersV2.FTP.addColumn',
|
|
22
22
|
defaultMessage: 'Add column',
|
|
23
23
|
},
|
|
24
|
-
unsupportedTagsValidationError: {
|
|
25
|
-
id: 'creatives.containersV2.FTP.unsupportedTagsValidationError',
|
|
26
|
-
defaultMessage: 'Unsupported tags: {unsupportedTags}. Please remove them from this message.',
|
|
27
|
-
},
|
|
28
24
|
selectTag: {
|
|
29
25
|
id: 'creatives.containersV2.FTP.selectTag',
|
|
30
26
|
defaultMessage: 'Select tag',
|
|
@@ -39,33 +39,58 @@ jest.mock('../../../utils/common', () => ({
|
|
|
39
39
|
// Mock HTMLEditor component - must be before imports
|
|
40
40
|
jest.mock('../../../v2Components/HtmlEditor', () => {
|
|
41
41
|
const React = require('react');
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
|
|
43
|
+
const MockHTMLEditor = function MockHTMLEditor({
|
|
44
|
+
variant,
|
|
45
|
+
initialContent,
|
|
46
|
+
onContentChange,
|
|
47
|
+
onSave,
|
|
48
|
+
'data-test': dataTest,
|
|
49
|
+
}) {
|
|
50
|
+
return React.createElement(
|
|
51
|
+
'div',
|
|
52
|
+
{ 'data-testid': dataTest || 'inapp-html-editor' },
|
|
44
53
|
React.createElement('div', { 'data-testid': 'html-editor-variant' }, variant),
|
|
45
|
-
React.createElement(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
54
|
+
React.createElement(
|
|
55
|
+
'div',
|
|
56
|
+
{ 'data-testid': 'html-editor-initial-android' },
|
|
57
|
+
initialContent?.android || ''
|
|
58
|
+
),
|
|
59
|
+
React.createElement(
|
|
60
|
+
'div',
|
|
61
|
+
{ 'data-testid': 'html-editor-initial-ios' },
|
|
62
|
+
initialContent?.ios || ''
|
|
63
|
+
),
|
|
64
|
+
React.createElement(
|
|
65
|
+
'button',
|
|
66
|
+
{
|
|
67
|
+
'data-testid': 'html-editor-change-button',
|
|
68
|
+
onClick: () => {
|
|
69
|
+
if (onContentChange) {
|
|
70
|
+
onContentChange({
|
|
71
|
+
android: '<p>Updated Android HTML</p>',
|
|
72
|
+
ios: '<p>Updated iOS HTML</p>',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
'Simulate Content Change'
|
|
78
|
+
),
|
|
79
|
+
React.createElement(
|
|
80
|
+
'button',
|
|
81
|
+
{
|
|
82
|
+
'data-testid': 'html-editor-save-button',
|
|
83
|
+
onClick: () => {
|
|
84
|
+
if (onSave) {
|
|
85
|
+
onSave({
|
|
86
|
+
android: '<p>Saved Android HTML</p>',
|
|
87
|
+
ios: '<p>Saved iOS HTML</p>',
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
'Simulate Save'
|
|
93
|
+
)
|
|
69
94
|
);
|
|
70
95
|
};
|
|
71
96
|
MockHTMLEditor.displayName = 'MockHTMLEditor';
|
|
@@ -75,22 +100,25 @@ jest.mock('../../../v2Components/HtmlEditor', () => {
|
|
|
75
100
|
};
|
|
76
101
|
});
|
|
77
102
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
import { IntlProvider } from 'react-intl';
|
|
82
|
-
import { Provider } from 'react-redux';
|
|
83
|
-
import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
|
|
84
|
-
import history from '../../../utils/history';
|
|
85
|
-
import { initialReducer } from '../../../initialReducer';
|
|
86
|
-
import { InApp } from '../index';
|
|
87
|
-
import { INAPP_EDITOR_TYPES } from '../../InAppWrapper/constants';
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// Mock other dependencies
|
|
103
|
+
/**
|
|
104
|
+
* Mock CapDeviceContent to ensure HTMLEditor renders
|
|
105
|
+
*/
|
|
91
106
|
jest.mock('../../../v2Components/CapDeviceContent', () => {
|
|
107
|
+
const React = require('react');
|
|
108
|
+
const HTMLEditor = require('../../../v2Components/HtmlEditor').default;
|
|
109
|
+
|
|
92
110
|
return function MockCapDeviceContent() {
|
|
93
|
-
return
|
|
111
|
+
return (
|
|
112
|
+
<div data-testid="cap-device-content">
|
|
113
|
+
<HTMLEditor
|
|
114
|
+
variant="inapp"
|
|
115
|
+
initialContent={{ android: '', ios: '' }}
|
|
116
|
+
onContentChange={jest.fn()}
|
|
117
|
+
onSave={jest.fn()}
|
|
118
|
+
data-test="inapp-html-editor"
|
|
119
|
+
/>
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
94
122
|
};
|
|
95
123
|
});
|
|
96
124
|
|
|
@@ -100,7 +128,20 @@ jest.mock('../../../v2Components/TemplatePreview', () => {
|
|
|
100
128
|
};
|
|
101
129
|
});
|
|
102
130
|
|
|
131
|
+
import React from 'react';
|
|
132
|
+
import { render, screen, fireEvent, act } from '@testing-library/react';
|
|
133
|
+
import '@testing-library/jest-dom';
|
|
134
|
+
import { IntlProvider } from 'react-intl';
|
|
135
|
+
import { Provider } from 'react-redux';
|
|
136
|
+
import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
|
|
137
|
+
|
|
138
|
+
import history from '../../../utils/history';
|
|
139
|
+
import { initialReducer } from '../../../initialReducer';
|
|
140
|
+
import { InApp } from '../index';
|
|
141
|
+
import { INAPP_EDITOR_TYPES } from '../../InAppWrapper/constants';
|
|
142
|
+
|
|
103
143
|
let store;
|
|
144
|
+
|
|
104
145
|
beforeAll(() => {
|
|
105
146
|
store = configureStore({}, initialReducer, history);
|
|
106
147
|
});
|
|
@@ -135,8 +176,6 @@ const defaultProps = {
|
|
|
135
176
|
configs: {
|
|
136
177
|
android: '1',
|
|
137
178
|
ios: '1',
|
|
138
|
-
accessToken: 'test-token',
|
|
139
|
-
deeplink: '{}',
|
|
140
179
|
},
|
|
141
180
|
},
|
|
142
181
|
},
|
|
@@ -145,7 +184,6 @@ const defaultProps = {
|
|
|
145
184
|
query: {},
|
|
146
185
|
search: '',
|
|
147
186
|
},
|
|
148
|
-
getDefaultTags: null,
|
|
149
187
|
supportedTags: [],
|
|
150
188
|
metaEntities: {
|
|
151
189
|
tags: {
|
|
@@ -158,26 +196,11 @@ const defaultProps = {
|
|
|
158
196
|
currentOrgDetails: {
|
|
159
197
|
accessibleFeatures: [],
|
|
160
198
|
},
|
|
161
|
-
fetchingLiquidValidation: false,
|
|
162
|
-
getTemplateDetailsInProgress: false,
|
|
163
|
-
isEditInApp: false,
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
// Create stable defaultData objects outside renderComponent to avoid reference changes
|
|
167
|
-
const createStableDefaultData = (editorType) => {
|
|
168
|
-
if (!editorType) return {};
|
|
169
|
-
return { 'editor-type': editorType };
|
|
170
199
|
};
|
|
171
200
|
|
|
172
201
|
const renderComponent = (props = {}) => {
|
|
173
202
|
const mergedProps = { ...defaultProps, ...props };
|
|
174
|
-
|
|
175
|
-
if (!mergedProps.defaultData) {
|
|
176
|
-
mergedProps.defaultData = {};
|
|
177
|
-
} else if (mergedProps.defaultData['editor-type']) {
|
|
178
|
-
// Create a stable reference for defaultData
|
|
179
|
-
mergedProps.defaultData = createStableDefaultData(mergedProps.defaultData['editor-type']);
|
|
180
|
-
}
|
|
203
|
+
|
|
181
204
|
return render(
|
|
182
205
|
<Provider store={store}>
|
|
183
206
|
<IntlProvider locale="en" messages={{}}>
|
|
@@ -195,36 +218,33 @@ describe('InApp HTMLEditor Integration', () => {
|
|
|
195
218
|
describe('Template Name Editing', () => {
|
|
196
219
|
test('should not truncate template name when editing', async () => {
|
|
197
220
|
const showTemplateNameMock = jest.fn();
|
|
221
|
+
|
|
198
222
|
renderComponent({
|
|
199
|
-
defaultData: {
|
|
223
|
+
defaultData: {
|
|
224
|
+
'editor-type': INAPP_EDITOR_TYPES.HTML_EDITOR,
|
|
225
|
+
'template-name': 'abcd',
|
|
226
|
+
},
|
|
200
227
|
showTemplateName: showTemplateNameMock,
|
|
201
228
|
});
|
|
202
229
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
expect(screen.getByTestId('inapp-html-editor')).toBeInTheDocument();
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
// Verify showTemplateName was called with the template name
|
|
209
|
-
// The template name input is handled by the wrapper, not the InApp component
|
|
210
|
-
// So we verify that the callback was set up correctly
|
|
230
|
+
const editor = await screen.findByTestId('inapp-html-editor');
|
|
231
|
+
expect(editor).toBeInTheDocument();
|
|
211
232
|
expect(showTemplateNameMock).toBeDefined();
|
|
212
233
|
});
|
|
213
234
|
|
|
214
235
|
test('should preserve template name when showTemplateName callback is provided', async () => {
|
|
215
236
|
const showTemplateNameMock = jest.fn();
|
|
237
|
+
|
|
216
238
|
renderComponent({
|
|
217
|
-
defaultData: {
|
|
239
|
+
defaultData: {
|
|
240
|
+
'editor-type': INAPP_EDITOR_TYPES.HTML_EDITOR,
|
|
241
|
+
'template-name': 'test',
|
|
242
|
+
},
|
|
218
243
|
showTemplateName: showTemplateNameMock,
|
|
219
244
|
});
|
|
220
245
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
expect(screen.getByTestId('inapp-html-editor')).toBeInTheDocument();
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
// Verify the component renders correctly with template name
|
|
227
|
-
// The template name is managed by the wrapper component
|
|
246
|
+
const editor = await screen.findByTestId('inapp-html-editor');
|
|
247
|
+
expect(editor).toBeInTheDocument();
|
|
228
248
|
expect(showTemplateNameMock).toBeDefined();
|
|
229
249
|
});
|
|
230
250
|
});
|
|
@@ -232,40 +252,7 @@ describe('InApp HTMLEditor Integration', () => {
|
|
|
232
252
|
describe('TAG API Calls', () => {
|
|
233
253
|
test('should only make one TAG API call when HTML Editor is used', async () => {
|
|
234
254
|
const fetchSchemaForEntityMock = jest.fn();
|
|
235
|
-
|
|
236
|
-
renderComponent({
|
|
237
|
-
defaultData: { 'editor-type': INAPP_EDITOR_TYPES.HTML_EDITOR },
|
|
238
|
-
globalActions: {
|
|
239
|
-
...defaultProps.globalActions,
|
|
240
|
-
fetchSchemaForEntity: fetchSchemaForEntityMock,
|
|
241
|
-
},
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// Wait for component to mount and initialize
|
|
245
|
-
await waitFor(() => {
|
|
246
|
-
// Component should be rendered
|
|
247
|
-
expect(screen.getByTestId('inapp-html-editor')).toBeInTheDocument();
|
|
248
|
-
});
|
|
249
255
|
|
|
250
|
-
// Wait a bit for all useEffects to complete
|
|
251
|
-
await waitFor(() => {
|
|
252
|
-
// After isHTMLTemplate is set to true, fetchSchemaForEntity should not be called again
|
|
253
|
-
// The initial call might happen before isHTMLTemplate is set, but subsequent calls should not happen
|
|
254
|
-
// For HTML Editor, tags should only be fetched via handleOnTagsContextChange
|
|
255
|
-
}, { timeout: 1000 });
|
|
256
|
-
|
|
257
|
-
// For HTML Editor, fetchSchemaForEntity should not be called after isHTMLTemplate is set
|
|
258
|
-
// (It might be called once initially before isHTMLTemplate is set, but that's acceptable)
|
|
259
|
-
// The key is that it's not called multiple times
|
|
260
|
-
const callCount = fetchSchemaForEntityMock.mock.calls.length;
|
|
261
|
-
// Allow 0 or 1 calls (1 if it was called before isHTMLTemplate was set)
|
|
262
|
-
expect(callCount).toBeLessThanOrEqual(1);
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
test('should make TAG API call only once when handleOnTagsContextChange is called', async () => {
|
|
266
|
-
const fetchSchemaForEntityMock = jest.fn();
|
|
267
|
-
|
|
268
|
-
// We need to access the handler, but since it's internal, we'll test via HTMLEditor's onContextChange
|
|
269
256
|
renderComponent({
|
|
270
257
|
defaultData: { 'editor-type': INAPP_EDITOR_TYPES.HTML_EDITOR },
|
|
271
258
|
globalActions: {
|
|
@@ -274,19 +261,8 @@ describe('InApp HTMLEditor Integration', () => {
|
|
|
274
261
|
},
|
|
275
262
|
});
|
|
276
263
|
|
|
277
|
-
await
|
|
278
|
-
expect(screen.getByTestId('inapp-html-editor')).toBeInTheDocument();
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
// Wait a bit for all useEffects to complete
|
|
282
|
-
await waitFor(() => {
|
|
283
|
-
// After isHTMLTemplate is set to true, fetchSchemaForEntity should not be called again
|
|
284
|
-
}, { timeout: 1000 });
|
|
264
|
+
await screen.findByTestId('inapp-html-editor');
|
|
285
265
|
|
|
286
|
-
// Simulate context change from HTMLEditor (which would call onContextChange)
|
|
287
|
-
// Since we can't directly access the handler, we verify the behavior
|
|
288
|
-
// by checking that fetchSchemaForEntity is not called multiple times
|
|
289
|
-
// (It might be called once initially before isHTMLTemplate is set, but that's acceptable)
|
|
290
266
|
const callCount = fetchSchemaForEntityMock.mock.calls.length;
|
|
291
267
|
expect(callCount).toBeLessThanOrEqual(1);
|
|
292
268
|
});
|
|
@@ -298,45 +274,37 @@ describe('InApp HTMLEditor Integration', () => {
|
|
|
298
274
|
defaultData: { 'editor-type': INAPP_EDITOR_TYPES.HTML_EDITOR },
|
|
299
275
|
});
|
|
300
276
|
|
|
301
|
-
await
|
|
302
|
-
expect(screen.getByTestId('inapp-html-editor')).toBeInTheDocument();
|
|
303
|
-
});
|
|
277
|
+
await screen.findByTestId('inapp-html-editor');
|
|
304
278
|
|
|
305
|
-
// Simulate content being added
|
|
306
279
|
const changeButton = screen.getByTestId('html-editor-change-button');
|
|
280
|
+
|
|
307
281
|
act(() => {
|
|
308
282
|
fireEvent.click(changeButton);
|
|
309
283
|
});
|
|
310
284
|
|
|
311
|
-
// Get the layout radio buttons
|
|
312
285
|
const layoutRadios = container.querySelectorAll('input[type="radio"]');
|
|
313
|
-
expect(layoutRadios.length).toBeGreaterThan(0);
|
|
314
286
|
|
|
315
|
-
// Change layout type
|
|
316
287
|
if (layoutRadios.length > 1) {
|
|
317
288
|
act(() => {
|
|
318
|
-
fireEvent.change(layoutRadios[1], {
|
|
289
|
+
fireEvent.change(layoutRadios[1], {
|
|
290
|
+
target: { value: 'HEADER' },
|
|
291
|
+
});
|
|
319
292
|
});
|
|
320
293
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
await waitFor(() => {
|
|
324
|
-
const editor = screen.getByTestId('inapp-html-editor');
|
|
325
|
-
expect(editor).toBeInTheDocument();
|
|
326
|
-
});
|
|
294
|
+
const editor = await screen.findByTestId('inapp-html-editor');
|
|
295
|
+
expect(editor).toBeInTheDocument();
|
|
327
296
|
}
|
|
328
297
|
});
|
|
329
298
|
});
|
|
330
299
|
|
|
331
300
|
describe('Layout Labels', () => {
|
|
332
301
|
test('should use correct layout labels in constants', () => {
|
|
333
|
-
const { INAPP_LAYOUT_DETAILS, INAPP_MESSAGE_LAYOUT_TYPES } =
|
|
334
|
-
|
|
335
|
-
|
|
302
|
+
const { INAPP_LAYOUT_DETAILS, INAPP_MESSAGE_LAYOUT_TYPES } =
|
|
303
|
+
require('../constants');
|
|
304
|
+
|
|
336
305
|
expect(INAPP_MESSAGE_LAYOUT_TYPES.TOPBANNER).toBe('HEADER');
|
|
337
306
|
expect(INAPP_LAYOUT_DETAILS.HEADER).toBeDefined();
|
|
338
|
-
|
|
339
|
-
// Verify that FOOTER maps to Bottom banner
|
|
307
|
+
|
|
340
308
|
expect(INAPP_MESSAGE_LAYOUT_TYPES.BOTTOMBANNER).toBe('FOOTER');
|
|
341
309
|
expect(INAPP_LAYOUT_DETAILS.FOOTER).toBeDefined();
|
|
342
310
|
});
|
|
@@ -346,29 +314,16 @@ describe('InApp HTMLEditor Integration', () => {
|
|
|
346
314
|
test('should allow creating template with Android-only content when both devices supported', async () => {
|
|
347
315
|
renderComponent({
|
|
348
316
|
defaultData: { 'editor-type': INAPP_EDITOR_TYPES.HTML_EDITOR },
|
|
349
|
-
accountData: {
|
|
350
|
-
selectedWeChatAccount: {
|
|
351
|
-
...defaultProps.accountData.selectedWeChatAccount,
|
|
352
|
-
configs: {
|
|
353
|
-
android: '1',
|
|
354
|
-
ios: '1',
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
},
|
|
358
317
|
});
|
|
359
318
|
|
|
360
|
-
await
|
|
361
|
-
expect(screen.getByTestId('inapp-html-editor')).toBeInTheDocument();
|
|
362
|
-
});
|
|
319
|
+
await screen.findByTestId('inapp-html-editor');
|
|
363
320
|
|
|
364
|
-
// Simulate adding content only for Android
|
|
365
321
|
const changeButton = screen.getByTestId('html-editor-change-button');
|
|
322
|
+
|
|
366
323
|
act(() => {
|
|
367
324
|
fireEvent.click(changeButton);
|
|
368
325
|
});
|
|
369
326
|
|
|
370
|
-
// Done button should be enabled (not disabled)
|
|
371
|
-
// We can't directly test isDisableDone, but we can verify the component renders
|
|
372
327
|
expect(screen.getByTestId('inapp-html-editor')).toBeInTheDocument();
|
|
373
328
|
});
|
|
374
329
|
});
|