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
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
6
|
+
import '@testing-library/jest-dom';
|
|
7
|
+
import { IntlProvider } from 'react-intl';
|
|
8
|
+
import CustomValuesEditor from '../CustomValuesEditor';
|
|
9
|
+
|
|
10
|
+
jest.mock('@capillarytech/cap-ui-library/CapRow', () => {
|
|
11
|
+
const React = require('react');
|
|
12
|
+
return function CapRow(props) {
|
|
13
|
+
return React.createElement('div', { className: props?.className, 'data-testid': 'cap-row' }, props?.children);
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
jest.mock('@capillarytech/cap-ui-library/CapSpin', () => {
|
|
17
|
+
const React = require('react');
|
|
18
|
+
return function CapSpin() {
|
|
19
|
+
return React.createElement('div', { 'data-testid': 'cap-spin' }, 'spin');
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
jest.mock('@capillarytech/cap-ui-library/CapSwitch', () => {
|
|
23
|
+
const React = require('react');
|
|
24
|
+
return function CapSwitch(props) {
|
|
25
|
+
return React.createElement('input', {
|
|
26
|
+
type: 'checkbox',
|
|
27
|
+
'data-testid': 'json-switch',
|
|
28
|
+
checked: props?.checked,
|
|
29
|
+
onChange: (e) => props?.onChange?.(e.target.checked),
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
jest.mock('@capillarytech/cap-ui-library/CapButton', () => {
|
|
34
|
+
const React = require('react');
|
|
35
|
+
return function CapButton(props) {
|
|
36
|
+
return React.createElement('button', {
|
|
37
|
+
type: 'button',
|
|
38
|
+
'data-testid': 'cap-button',
|
|
39
|
+
onClick: props?.onClick,
|
|
40
|
+
disabled: props?.disabled,
|
|
41
|
+
'data-loading': props?.loading,
|
|
42
|
+
}, props?.children);
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
jest.mock('@capillarytech/cap-ui-library/CapInput', () => {
|
|
46
|
+
const React = require('react');
|
|
47
|
+
return function CapInput(props) {
|
|
48
|
+
return React.createElement('input', {
|
|
49
|
+
'data-testid': 'tag-input',
|
|
50
|
+
value: props?.value,
|
|
51
|
+
placeholder: props?.placeholder,
|
|
52
|
+
onChange: props?.onChange,
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
jest.mock('@capillarytech/cap-ui-library/CapLabel', () => {
|
|
57
|
+
const React = require('react');
|
|
58
|
+
return function CapLabel(props) {
|
|
59
|
+
return React.createElement('div', { className: props?.className, 'data-testid': 'cap-label' }, props?.children);
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const formatMessage = (msg) => (typeof msg === 'object' && msg?.id ? msg.id : String(msg));
|
|
64
|
+
|
|
65
|
+
const baseProps = {
|
|
66
|
+
isExtractingTags: false,
|
|
67
|
+
isUpdatePreviewDisabled: false,
|
|
68
|
+
showJSON: false,
|
|
69
|
+
setShowJSON: jest.fn(),
|
|
70
|
+
customValues: { 'tag.a': 'v1' },
|
|
71
|
+
handleJSONTextChange: jest.fn(),
|
|
72
|
+
sections: [
|
|
73
|
+
{
|
|
74
|
+
key: 'sec1',
|
|
75
|
+
title: 'Section A',
|
|
76
|
+
requiredTags: [{ fullPath: 'tag.a', name: 'a' }],
|
|
77
|
+
optionalTags: [{ fullPath: 'tag.b', name: 'b' }],
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
handleCustomValueChange: jest.fn(),
|
|
81
|
+
handleDiscardCustomValues: jest.fn(),
|
|
82
|
+
handleUpdatePreview: jest.fn(),
|
|
83
|
+
isUpdatingPreview: false,
|
|
84
|
+
formatMessage,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
describe('CustomValuesEditor', () => {
|
|
88
|
+
beforeEach(() => {
|
|
89
|
+
jest.clearAllMocks();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('shows loading state when isExtractingTags', () => {
|
|
93
|
+
render(
|
|
94
|
+
<IntlProvider locale="en" messages={{}}>
|
|
95
|
+
<CustomValuesEditor {...baseProps} isExtractingTags />
|
|
96
|
+
</IntlProvider>,
|
|
97
|
+
);
|
|
98
|
+
expect(screen.getByTestId('cap-spin')).toBeInTheDocument();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('shows values missing label when isUpdatePreviewDisabled', () => {
|
|
102
|
+
render(
|
|
103
|
+
<IntlProvider locale="en" messages={{}}>
|
|
104
|
+
<CustomValuesEditor {...baseProps} isUpdatePreviewDisabled />
|
|
105
|
+
</IntlProvider>,
|
|
106
|
+
);
|
|
107
|
+
expect(document.querySelector('.values-missing-message')).toBeTruthy();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('toggles JSON mode and calls setShowJSON', () => {
|
|
111
|
+
const setShowJSON = jest.fn();
|
|
112
|
+
render(
|
|
113
|
+
<IntlProvider locale="en" messages={{}}>
|
|
114
|
+
<CustomValuesEditor {...baseProps} setShowJSON={setShowJSON} />
|
|
115
|
+
</IntlProvider>,
|
|
116
|
+
);
|
|
117
|
+
fireEvent.click(screen.getByTestId('json-switch'));
|
|
118
|
+
expect(setShowJSON).toHaveBeenCalled();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('renders JSON textarea and fires handleJSONTextChange', () => {
|
|
122
|
+
render(
|
|
123
|
+
<IntlProvider locale="en" messages={{}}>
|
|
124
|
+
<CustomValuesEditor {...baseProps} showJSON />
|
|
125
|
+
</IntlProvider>,
|
|
126
|
+
);
|
|
127
|
+
const ta = document.querySelector('.json-textarea');
|
|
128
|
+
expect(ta).toBeTruthy();
|
|
129
|
+
fireEvent.change(ta, { target: { value: '{}' } });
|
|
130
|
+
expect(baseProps.handleJSONTextChange).toHaveBeenCalledWith('{}');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('renders required and optional tag inputs when not JSON', () => {
|
|
134
|
+
render(
|
|
135
|
+
<IntlProvider locale="en" messages={{}}>
|
|
136
|
+
<CustomValuesEditor {...baseProps} />
|
|
137
|
+
</IntlProvider>,
|
|
138
|
+
);
|
|
139
|
+
const inputs = screen.getAllByTestId('tag-input');
|
|
140
|
+
expect(inputs.length).toBeGreaterThan(0);
|
|
141
|
+
fireEvent.change(inputs[0], { target: { value: 'new' } });
|
|
142
|
+
expect(baseProps.handleCustomValueChange).toHaveBeenCalledWith('tag.a', 'new');
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('calls discard and update handlers', () => {
|
|
146
|
+
render(
|
|
147
|
+
<IntlProvider locale="en" messages={{}}>
|
|
148
|
+
<CustomValuesEditor {...baseProps} />
|
|
149
|
+
</IntlProvider>,
|
|
150
|
+
);
|
|
151
|
+
const buttons = screen.getAllByTestId('cap-button');
|
|
152
|
+
fireEvent.click(buttons[0]);
|
|
153
|
+
fireEvent.click(buttons[buttons.length - 1]);
|
|
154
|
+
expect(baseProps.handleDiscardCustomValues).toHaveBeenCalled();
|
|
155
|
+
expect(baseProps.handleUpdatePreview).toHaveBeenCalled();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('skips sections with no tags', () => {
|
|
159
|
+
render(
|
|
160
|
+
<IntlProvider locale="en" messages={{}}>
|
|
161
|
+
<CustomValuesEditor
|
|
162
|
+
{...baseProps}
|
|
163
|
+
sections={[
|
|
164
|
+
{ key: 'empty', requiredTags: [], optionalTags: [] },
|
|
165
|
+
baseProps.sections[0],
|
|
166
|
+
]}
|
|
167
|
+
/>
|
|
168
|
+
</IntlProvider>,
|
|
169
|
+
);
|
|
170
|
+
expect(screen.getAllByTestId('tag-input').length).toBeGreaterThan(0);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('renders section title as FormattedMessage when title is an intl message object (not a string)', () => {
|
|
174
|
+
render(
|
|
175
|
+
<IntlProvider locale="en" messages={{ 'section.title.id': 'Intl Section Title' }}>
|
|
176
|
+
<CustomValuesEditor
|
|
177
|
+
{...baseProps}
|
|
178
|
+
sections={[
|
|
179
|
+
{
|
|
180
|
+
key: 'intl-sec',
|
|
181
|
+
title: { id: 'section.title.id', defaultMessage: 'Intl Section Title' },
|
|
182
|
+
requiredTags: [{ fullPath: 'tag.a', name: 'a' }],
|
|
183
|
+
optionalTags: [],
|
|
184
|
+
},
|
|
185
|
+
]}
|
|
186
|
+
/>
|
|
187
|
+
</IntlProvider>,
|
|
188
|
+
);
|
|
189
|
+
expect(screen.getByText('Intl Section Title')).toBeInTheDocument();
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('renders section title as plain text when title is a string', () => {
|
|
193
|
+
render(
|
|
194
|
+
<IntlProvider locale="en" messages={{}}>
|
|
195
|
+
<CustomValuesEditor
|
|
196
|
+
{...baseProps}
|
|
197
|
+
sections={[
|
|
198
|
+
{
|
|
199
|
+
key: 'str-sec',
|
|
200
|
+
title: 'Plain String Title',
|
|
201
|
+
requiredTags: [{ fullPath: 'tag.a', name: 'a' }],
|
|
202
|
+
optionalTags: [],
|
|
203
|
+
},
|
|
204
|
+
]}
|
|
205
|
+
/>
|
|
206
|
+
</IntlProvider>,
|
|
207
|
+
);
|
|
208
|
+
expect(screen.getByText('Plain String Title')).toBeInTheDocument();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('renders nothing for section title when title is null (does not crash)', () => {
|
|
212
|
+
render(
|
|
213
|
+
<IntlProvider locale="en" messages={{}}>
|
|
214
|
+
<CustomValuesEditor
|
|
215
|
+
{...baseProps}
|
|
216
|
+
sections={[
|
|
217
|
+
{
|
|
218
|
+
key: 'no-title-sec',
|
|
219
|
+
title: null,
|
|
220
|
+
requiredTags: [{ fullPath: 'tag.a', name: 'a' }],
|
|
221
|
+
optionalTags: [],
|
|
222
|
+
},
|
|
223
|
+
]}
|
|
224
|
+
/>
|
|
225
|
+
</IntlProvider>,
|
|
226
|
+
);
|
|
227
|
+
const inputs = screen.getAllByTestId('tag-input');
|
|
228
|
+
expect(inputs.length).toBeGreaterThan(0);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('uses tag.name as column label when fullPath is absent', () => {
|
|
232
|
+
render(
|
|
233
|
+
<IntlProvider locale="en" messages={{}}>
|
|
234
|
+
<CustomValuesEditor
|
|
235
|
+
{...baseProps}
|
|
236
|
+
sections={[
|
|
237
|
+
{
|
|
238
|
+
key: 'name-only',
|
|
239
|
+
title: 'Section',
|
|
240
|
+
requiredTags: [{ name: 'myTag' }],
|
|
241
|
+
optionalTags: [],
|
|
242
|
+
},
|
|
243
|
+
]}
|
|
244
|
+
/>
|
|
245
|
+
</IntlProvider>,
|
|
246
|
+
);
|
|
247
|
+
expect(screen.getByText('myTag')).toBeInTheDocument();
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('uses empty string as column label when both fullPath and name are absent', () => {
|
|
251
|
+
render(
|
|
252
|
+
<IntlProvider locale="en" messages={{}}>
|
|
253
|
+
<CustomValuesEditor
|
|
254
|
+
{...baseProps}
|
|
255
|
+
sections={[
|
|
256
|
+
{
|
|
257
|
+
key: 'no-label',
|
|
258
|
+
title: 'Section',
|
|
259
|
+
requiredTags: [{}],
|
|
260
|
+
optionalTags: [],
|
|
261
|
+
},
|
|
262
|
+
]}
|
|
263
|
+
/>
|
|
264
|
+
</IntlProvider>,
|
|
265
|
+
);
|
|
266
|
+
const inputs = screen.getAllByTestId('tag-input');
|
|
267
|
+
expect(inputs.length).toBeGreaterThan(0);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it('renders optional-only section (no requiredTags) correctly', () => {
|
|
271
|
+
render(
|
|
272
|
+
<IntlProvider locale="en" messages={{}}>
|
|
273
|
+
<CustomValuesEditor
|
|
274
|
+
{...baseProps}
|
|
275
|
+
sections={[
|
|
276
|
+
{
|
|
277
|
+
key: 'optional-only',
|
|
278
|
+
title: 'Optional Section',
|
|
279
|
+
requiredTags: [],
|
|
280
|
+
optionalTags: [{ fullPath: 'tag.opt', name: 'opt' }],
|
|
281
|
+
},
|
|
282
|
+
]}
|
|
283
|
+
/>
|
|
284
|
+
</IntlProvider>,
|
|
285
|
+
);
|
|
286
|
+
expect(screen.getByText('Optional Section')).toBeInTheDocument();
|
|
287
|
+
const inputs = screen.getAllByTestId('tag-input');
|
|
288
|
+
expect(inputs.length).toBeGreaterThan(0);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it('renders required-only section (no optionalTags) correctly', () => {
|
|
292
|
+
render(
|
|
293
|
+
<IntlProvider locale="en" messages={{}}>
|
|
294
|
+
<CustomValuesEditor
|
|
295
|
+
{...baseProps}
|
|
296
|
+
sections={[
|
|
297
|
+
{
|
|
298
|
+
key: 'required-only',
|
|
299
|
+
title: 'Required Section',
|
|
300
|
+
requiredTags: [{ fullPath: 'tag.req', name: 'req' }],
|
|
301
|
+
optionalTags: [],
|
|
302
|
+
},
|
|
303
|
+
]}
|
|
304
|
+
/>
|
|
305
|
+
</IntlProvider>,
|
|
306
|
+
);
|
|
307
|
+
expect(screen.getByText('Required Section')).toBeInTheDocument();
|
|
308
|
+
const inputs = screen.getAllByTestId('tag-input');
|
|
309
|
+
expect(inputs.length).toBeGreaterThan(0);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('renders line numbers in JSON mode matching JSON line count', () => {
|
|
313
|
+
const multiValueCustomValues = { a: 'val1', b: 'val2', c: 'val3' };
|
|
314
|
+
render(
|
|
315
|
+
<IntlProvider locale="en" messages={{}}>
|
|
316
|
+
<CustomValuesEditor
|
|
317
|
+
{...baseProps}
|
|
318
|
+
showJSON
|
|
319
|
+
customValues={multiValueCustomValues}
|
|
320
|
+
/>
|
|
321
|
+
</IntlProvider>,
|
|
322
|
+
);
|
|
323
|
+
const lineNumbers = document.querySelectorAll('.line-number');
|
|
324
|
+
const expectedLineCount = JSON.stringify(multiValueCustomValues, null, 2).split('\n').length;
|
|
325
|
+
expect(lineNumbers.length).toBe(expectedLineCount);
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('passes fullPath as key for required tag row when fullPath is present', () => {
|
|
329
|
+
const handleChange = jest.fn();
|
|
330
|
+
render(
|
|
331
|
+
<IntlProvider locale="en" messages={{}}>
|
|
332
|
+
<CustomValuesEditor
|
|
333
|
+
{...baseProps}
|
|
334
|
+
sections={[
|
|
335
|
+
{
|
|
336
|
+
key: 'sec',
|
|
337
|
+
title: 'S',
|
|
338
|
+
requiredTags: [{ fullPath: 'my.full.path', name: 'name' }],
|
|
339
|
+
optionalTags: [],
|
|
340
|
+
},
|
|
341
|
+
]}
|
|
342
|
+
handleCustomValueChange={handleChange}
|
|
343
|
+
customValues={{ 'my.full.path': 'existing' }}
|
|
344
|
+
/>
|
|
345
|
+
</IntlProvider>,
|
|
346
|
+
);
|
|
347
|
+
const input = screen.getByTestId('tag-input');
|
|
348
|
+
expect(input.value).toBe('existing');
|
|
349
|
+
fireEvent.change(input, { target: { value: 'updated' } });
|
|
350
|
+
expect(handleChange).toHaveBeenCalledWith('my.full.path', 'updated');
|
|
351
|
+
});
|
|
352
|
+
});
|