@capillarytech/creatives-library 8.0.329 → 8.0.330

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.
Files changed (122) hide show
  1. package/constants/unified.js +0 -14
  2. package/package.json +1 -1
  3. package/services/api.js +0 -17
  4. package/services/tests/api.test.js +0 -85
  5. package/utils/commonUtils.js +0 -10
  6. package/utils/tests/commonUtil.test.js +0 -169
  7. package/v2Components/CapTagList/index.js +0 -10
  8. package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +49 -70
  9. package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +2 -8
  10. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +21 -207
  11. package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -16
  12. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +10 -85
  13. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -30
  14. package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +11 -79
  15. package/v2Components/CommonTestAndPreview/SendTestMessage.js +53 -87
  16. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -20
  17. package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +4 -133
  18. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +34 -145
  19. package/v2Components/CommonTestAndPreview/actions.js +0 -10
  20. package/v2Components/CommonTestAndPreview/constants.js +1 -53
  21. package/v2Components/CommonTestAndPreview/index.js +168 -1006
  22. package/v2Components/CommonTestAndPreview/messages.js +3 -147
  23. package/v2Components/CommonTestAndPreview/reducer.js +0 -10
  24. package/v2Components/CommonTestAndPreview/sagas.js +6 -15
  25. package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +286 -328
  26. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +65 -231
  27. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +5 -118
  28. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +0 -341
  29. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +24 -65
  30. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +1 -199
  31. package/v2Components/CommonTestAndPreview/tests/constants.test.js +1 -31
  32. package/v2Components/CommonTestAndPreview/tests/index.test.js +4 -168
  33. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -71
  34. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +2 -2
  35. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -17
  36. package/v2Components/FormBuilder/index.js +1 -7
  37. package/v2Components/TestAndPreviewSlidebox/index.js +1 -8
  38. package/v2Components/TestAndPreviewSlidebox/sagas.js +4 -11
  39. package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +1 -3
  40. package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -36
  41. package/v2Containers/CreativesContainer/SlideBoxFooter.js +1 -10
  42. package/v2Containers/CreativesContainer/SlideBoxHeader.js +4 -29
  43. package/v2Containers/CreativesContainer/constants.js +0 -9
  44. package/v2Containers/CreativesContainer/index.js +93 -286
  45. package/v2Containers/CreativesContainer/index.scss +1 -51
  46. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +34 -78
  47. package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +16 -79
  48. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +0 -8
  49. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +98 -357
  50. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +10 -20
  51. package/v2Containers/CreativesContainer/tests/index.test.js +9 -71
  52. package/v2Containers/Rcs/constants.js +1 -34
  53. package/v2Containers/Rcs/index.js +884 -999
  54. package/v2Containers/Rcs/index.scss +6 -85
  55. package/v2Containers/Rcs/messages.js +1 -10
  56. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +2453 -41456
  57. package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +5 -0
  58. package/v2Containers/Rcs/tests/index.test.js +38 -41
  59. package/v2Containers/Rcs/tests/mockData.js +0 -38
  60. package/v2Containers/Rcs/tests/utils.test.js +1 -379
  61. package/v2Containers/Rcs/utils.js +10 -358
  62. package/v2Containers/Sms/Create/index.js +38 -100
  63. package/v2Containers/SmsTrai/Create/index.js +4 -9
  64. package/v2Containers/SmsTrai/Edit/constants.js +0 -2
  65. package/v2Containers/SmsTrai/Edit/index.js +128 -609
  66. package/v2Containers/SmsTrai/Edit/messages.js +4 -9
  67. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +2600 -4586
  68. package/v2Containers/SmsWrapper/index.js +8 -37
  69. package/v2Containers/TagList/index.js +0 -6
  70. package/v2Containers/Templates/_templates.scss +2 -63
  71. package/v2Containers/Templates/actions.js +0 -11
  72. package/v2Containers/Templates/constants.js +0 -2
  73. package/v2Containers/Templates/index.js +40 -90
  74. package/v2Containers/Templates/sagas.js +12 -57
  75. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1079 -1043
  76. package/v2Containers/Templates/tests/sagas.test.js +123 -193
  77. package/v2Containers/TemplatesV2/TemplatesV2.style.js +1 -72
  78. package/v2Containers/TemplatesV2/index.js +23 -86
  79. package/v2Containers/Whatsapp/index.js +20 -3
  80. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4872 -5790
  81. package/utils/templateVarUtils.js +0 -172
  82. package/utils/tests/templateVarUtils.test.js +0 -160
  83. package/v2Components/CommonTestAndPreview/AddTestCustomer.js +0 -42
  84. package/v2Components/CommonTestAndPreview/CustomerCreationModal.js +0 -155
  85. package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +0 -93
  86. package/v2Components/CommonTestAndPreview/previewApiUtils.js +0 -59
  87. package/v2Components/CommonTestAndPreview/tests/AddTestCustomer.test.js +0 -66
  88. package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +0 -648
  89. package/v2Components/CommonTestAndPreview/tests/CustomerCreationModal.test.js +0 -174
  90. package/v2Components/CommonTestAndPreview/tests/ExistingCustomerModal.test.js +0 -114
  91. package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +0 -67
  92. package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +0 -87
  93. package/v2Components/SmsFallback/constants.js +0 -73
  94. package/v2Components/SmsFallback/index.js +0 -955
  95. package/v2Components/SmsFallback/index.scss +0 -265
  96. package/v2Components/SmsFallback/messages.js +0 -78
  97. package/v2Components/SmsFallback/smsFallbackUtils.js +0 -107
  98. package/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +0 -50
  99. package/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +0 -147
  100. package/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +0 -304
  101. package/v2Components/SmsFallback/tests/smsFallbackUi.test.js +0 -197
  102. package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +0 -261
  103. package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +0 -422
  104. package/v2Components/SmsFallback/useLocalTemplateList.js +0 -92
  105. package/v2Components/VarSegmentMessageEditor/constants.js +0 -2
  106. package/v2Components/VarSegmentMessageEditor/index.js +0 -125
  107. package/v2Components/VarSegmentMessageEditor/index.scss +0 -46
  108. package/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +0 -43
  109. package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +0 -67
  110. package/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +0 -90
  111. package/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +0 -258
  112. package/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +0 -125
  113. package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +0 -205
  114. package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +0 -251
  115. package/v2Containers/Sms/smsFormDataHelpers.js +0 -67
  116. package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +0 -253
  117. package/v2Containers/SmsTrai/Edit/index.scss +0 -121
  118. package/v2Containers/Templates/TemplatesActionBar.js +0 -101
  119. package/v2Containers/Templates/tests/TemplatesActionBar.test.js +0 -120
  120. package/v2Containers/Templates/tests/smsTemplatesListApi.test.js +0 -180
  121. package/v2Containers/Templates/utils/smsTemplatesListApi.js +0 -79
  122. package/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +0 -131
@@ -1,265 +0,0 @@
1
- @import '~@capillarytech/cap-ui-library/styles/_variables';
2
-
3
- /* Edit SMS Fallback slidebox: back control before title (CapHeader `prefix`) */
4
- .sms-fallback-slidebox-header--edit {
5
- .sms-fallback-slidebox-header__prefix {
6
- display: inline-flex;
7
- align-items: center;
8
- margin-right: $CAP_SPACE_12;
9
- }
10
-
11
- .sms-fallback-slidebox-header__back {
12
- display: inline-flex;
13
- align-items: center;
14
- justify-content: center;
15
- padding: $CAP_SPACE_04;
16
- margin: 0;
17
- border: none;
18
- background: transparent;
19
- cursor: pointer;
20
- color: inherit;
21
- border-radius: $CAP_SPACE_04;
22
- line-height: 1;
23
-
24
- &:focus-visible {
25
- outline: $CAP_SPACE_01 solid map-get($CAP_SECONDARY, base);
26
- outline-offset: $CAP_SPACE_02;
27
- }
28
-
29
- .anticon {
30
- font-size: 1rem;
31
- }
32
- }
33
- }
34
-
35
- .sms-fallback-header-row {
36
- margin-bottom: $CAP_SPACE_12;
37
- }
38
-
39
- /* Selected fallback template card: thin line under SMS title row (matches preview card layout) */
40
- .sms-fallback-card-wrap {
41
- .ant-card.cap-custom-card.SMS .ant-card-head {
42
- border-bottom: $CAP_SPACE_01 solid $CAP_COLOR_16;
43
- }
44
-
45
- /* Breathing room between header rule and body copy */
46
- .ant-card.cap-custom-card.SMS .ant-card-body {
47
- padding-top: $CAP_SPACE_16;
48
- }
49
- }
50
-
51
- /* "Select template" — scoped via wrapper; no `ant-*` selectors */
52
- .sms-fallback-select-wrap {
53
- /* `button` bumps specificity vs library defaults without targeting ant classes */
54
- button.sms-fallback-select-btn {
55
- $sms-fallback-secondary: map-get($CAP_SECONDARY, base);
56
-
57
- /* Same padding + radius default vs hover so the control doesn’t grow on hover */
58
- min-width: auto;
59
- min-height: auto;
60
- height: auto;
61
- padding: $CAP_SPACE_08 $CAP_SPACE_12;
62
- border: none;
63
- border-radius: $CAP_SPACE_04;
64
- color: $sms-fallback-secondary;
65
- font-weight: $FONT_WEIGHT_MEDIUM;
66
- line-height: 1.25;
67
- background-color: transparent;
68
- box-shadow: none;
69
-
70
- &:hover:not(:disabled) {
71
- color: $sms-fallback-secondary;
72
- background-color: #ebf8ff;
73
- font-weight: $FONT_WEIGHT_MEDIUM;
74
- }
75
-
76
- &:hover:not(:disabled) span {
77
- font-weight: $FONT_WEIGHT_MEDIUM;
78
- }
79
-
80
- &:focus:not(:disabled) {
81
- color: $sms-fallback-secondary;
82
- font-weight: $FONT_WEIGHT_MEDIUM;
83
- }
84
-
85
- &:focus-visible:not(:disabled) {
86
- outline: $CAP_SPACE_01 solid $sms-fallback-secondary;
87
- outline-offset: $CAP_SPACE_02;
88
- }
89
-
90
- &:disabled {
91
- color: $FONT_COLOR_03;
92
- background-color: transparent;
93
- border: none;
94
- opacity: 1;
95
- cursor: not-allowed;
96
- }
97
- }
98
- }
99
-
100
- .sms-fallback-inline-editor {
101
- margin-top: $CAP_SPACE_08;
102
- }
103
-
104
- /* Toolbar search uses shared `.action-container__toolbar-row .search-text` (13.125rem) from `_templates.scss` — same as other channels. */
105
-
106
- .sms-fallback-selector {
107
- position: relative;
108
- min-height: 12.5rem;
109
- }
110
-
111
- /* Portal’d template picker: give the slidebox a real height so the grid flex fills the space (no dead band below the cards). */
112
- .sms-fallback-selector:not(.sms-fallback-selector--visually-hidden) {
113
- height: 100vh;
114
- max-height: 100vh;
115
- display: flex;
116
- flex-direction: column;
117
- min-height: 0;
118
- box-sizing: border-box;
119
-
120
- .add-creatives-section.creatives-slidebox--local-sms-templates {
121
- flex: 1 1 0%;
122
- min-height: 0;
123
- height: 100%;
124
- max-height: 100%;
125
- display: flex;
126
- flex-direction: column;
127
-
128
- .cap-slide-box-v2-container {
129
- flex: 1 1 0%;
130
- min-height: 0;
131
- height: 100%;
132
- max-height: 100%;
133
- }
134
- }
135
- }
136
-
137
- /* Off-screen but in DOM: avoid huge pixel offsets; clip + fixed corner. */
138
- .sms-fallback-selector--visually-hidden {
139
- position: fixed;
140
- top: 0;
141
- left: 0;
142
- width: 0.0625rem;
143
- height: 0.0625rem;
144
- margin: -0.0625rem;
145
- padding: 0;
146
- overflow: hidden;
147
- clip: rect(0, 0, 0, 0);
148
- white-space: nowrap;
149
- border: 0;
150
- opacity: 0;
151
- pointer-events: none;
152
- z-index: -1;
153
- }
154
-
155
- .sms-fallback-selector__loading {
156
- position: absolute;
157
- inset: 0;
158
- z-index: 10;
159
- display: flex;
160
- align-items: center;
161
- justify-content: center;
162
- background-color: rgba($CAP_WHITE, 0.7);
163
- }
164
-
165
- /* Creatives SMS create: same title alignment as `SlideBoxHeader` + `.support-video-elements` */
166
- .sms-fallback-create-slidebox-header.support-video-elements {
167
- .cap-header-v2-title {
168
- display: inline-flex;
169
- align-items: center;
170
- }
171
- }
172
-
173
- .sms-fallback-create-slidebox-header__prefix {
174
- margin-right: $CAP_SPACE_16;
175
- display: inline-flex;
176
- align-items: center;
177
- }
178
-
179
- .sms-fallback-slidebox,
180
- .rcs-sms-fallback-slidebox {
181
- z-index: 10010;
182
-
183
- > .cap-slide-box-v2-container {
184
- z-index: 10011;
185
- background: $CAP_WHITE;
186
- /*
187
- * cap-ui sets overflow-y:auto on the panel; combined with our old min-height/height:auto overrides
188
- * the whole panel scrolled and the footer looked like a separate band with a second scrollbar.
189
- * Normal SMS edit: only `.slidebox-content-container` scrolls; footer stays in the fixed slot.
190
- */
191
- overflow: hidden;
192
- }
193
-
194
- .slidebox-header,
195
- .slidebox-content-container,
196
- .slidebox-footer {
197
- background: $CAP_WHITE;
198
- }
199
- }
200
-
201
- /*
202
- * Embedded SMS create in RCS fallback: same flex layout as Creatives `creatives-slidebox--local-sms-templates`
203
- * so only the middle scrolls and `SlideBoxFooter` stays in cap-ui’s fixed footer slot (no huge empty gap).
204
- */
205
- .sms-fallback-slidebox--embedded-sms-create {
206
- .cap-slide-box-v2-container {
207
- display: flex;
208
- flex-direction: column;
209
- min-height: 0;
210
- max-height: 100vh;
211
- }
212
-
213
- .slidebox-content-container {
214
- flex: 1;
215
- min-height: 0;
216
- display: flex;
217
- flex-direction: column;
218
- overflow: hidden;
219
- }
220
-
221
- .slidebox-content-container > div {
222
- flex: 1;
223
- min-height: 0;
224
- display: flex;
225
- flex-direction: column;
226
- overflow: hidden;
227
- }
228
-
229
- .sms-create-container {
230
- flex: 1;
231
- min-height: 0;
232
- display: flex;
233
- flex-direction: column;
234
- overflow: hidden;
235
- }
236
-
237
- .sms-create-container .ant-spin-nested-loading {
238
- flex: 1;
239
- min-height: 0;
240
- display: flex;
241
- flex-direction: column;
242
- overflow: hidden;
243
- }
244
-
245
- .sms-create-container .ant-spin-container {
246
- flex: 1;
247
- min-height: 0;
248
- overflow-y: auto;
249
- overflow-x: hidden;
250
- }
251
- }
252
-
253
- /* Same as CreativesContainer `creatives-library-mode` for embedded SMS (no tab bar chrome). */
254
- .add-creatives-section.creatives-library-mode {
255
- .sms-create-container {
256
- .ant-tabs-top-bar {
257
- display: none;
258
- }
259
- }
260
- }
261
-
262
- .sms-fallback-taglist-popover,
263
- .rcs-sms-fallback-taglist-popover {
264
- z-index: 10020;
265
- }
@@ -1,78 +0,0 @@
1
- import { defineMessages } from 'react-intl';
2
-
3
- const scope = 'creatives.componentsV2.SmsFallback';
4
-
5
- export default defineMessages({
6
- sectionTitle: {
7
- id: `${scope}.sectionTitle`,
8
- defaultMessage: 'Fallback SMS message (Optional)',
9
- },
10
- sectionTitleWithoutOptional: {
11
- id: `${scope}.sectionTitleWithoutOptional`,
12
- defaultMessage: 'Fallback SMS message',
13
- },
14
- selectTemplate: {
15
- id: `${scope}.selectTemplate`,
16
- defaultMessage: 'Select template',
17
- },
18
- templateListTitle: {
19
- id: `${scope}.templateListTitle`,
20
- defaultMessage: 'Creative templates',
21
- },
22
- templateListDescription: {
23
- id: `${scope}.templateListDescription`,
24
- defaultMessage: 'Select only one creative',
25
- },
26
- searchByCreativeName: {
27
- id: `${scope}.searchByCreativeName`,
28
- defaultMessage: 'Search by creative name',
29
- },
30
- createNew: {
31
- id: `${scope}.createNew`,
32
- defaultMessage: 'Create new',
33
- },
34
- uploadNew: {
35
- id: `${scope}.uploadNew`,
36
- defaultMessage: 'Upload template',
37
- },
38
- createTitle: {
39
- id: `${scope}.createTitle`,
40
- defaultMessage: 'Create SMS template',
41
- },
42
- backToTemplates: {
43
- id: `${scope}.backToTemplates`,
44
- defaultMessage: 'Back to templates',
45
- },
46
- editTitle: {
47
- id: `${scope}.editTitle`,
48
- defaultMessage: 'Edit SMS Fallback',
49
- },
50
- messagePreview: {
51
- id: `${scope}.messagePreview`,
52
- defaultMessage: 'Message: {message}',
53
- },
54
- editTemplate: {
55
- id: `${scope}.editTemplate`,
56
- defaultMessage: 'Edit',
57
- },
58
- removeTemplate: {
59
- id: `${scope}.removeTemplate`,
60
- defaultMessage: 'Remove',
61
- },
62
- messageLabel: {
63
- id: `${scope}.messageLabel`,
64
- defaultMessage: 'Message',
65
- },
66
- totalCharacters: {
67
- id: `${scope}.totalCharacters`,
68
- defaultMessage: '{smsCount} SMS ({number} characters)',
69
- },
70
- unicodeLabel: {
71
- id: `${scope}.unicodeLabel`,
72
- defaultMessage: 'Allow unicode characters',
73
- },
74
- fallbackCardUntitled: {
75
- id: `${scope}.fallbackCardUntitled`,
76
- defaultMessage: 'Untitled creative',
77
- },
78
- });
@@ -1,107 +0,0 @@
1
- import get from 'lodash/get';
2
- import { getFallbackResolvedContentForCardDisplay } from '../../utils/templateVarUtils';
3
- import { SMS_CATEGORY_FILTERS } from './constants';
4
-
5
- export function buildFallbackDataFromTemplate(template) {
6
- const base = get(template, 'versions.base', {});
7
- const smsEditor = base['sms-editor'] || '';
8
- /**
9
- * `templateContent` is the raw template string (may contain {{vars}} / {#slots#}).
10
- * `content` is the display/send body — identical here since no resolution happens at pick time.
11
- * They diverge in `buildFallbackDataFromCreativesPayload` where `messageBody` (resolved) differs
12
- * from `tc.template` (raw). Consumers should prefer `templateContent`; read `content` as fallback
13
- * (see `mapFallbackValueToEditTemplateData`).
14
- */
15
- const templateContent = smsEditor;
16
- const content = smsEditor;
17
- const headerList = Array.isArray(base.header) ? base.header : [];
18
- const senderId = (headerList[0]) || base.senderId || '';
19
- return {
20
- smsTemplateId: template._id || '',
21
- templateName: template.name || '',
22
- content,
23
- templateContent,
24
- senderId,
25
- /** TRAI DLT registered sender IDs — used by Test & Preview delivery settings filtering. */
26
- registeredSenderIds: headerList,
27
- unicodeValidity: typeof base['unicode-validity'] === 'boolean' ? base['unicode-validity'] : true,
28
- };
29
- }
30
-
31
- export function mapFallbackValueToEditTemplateData(source) {
32
- if (!source) return null;
33
- const rcsSmsFallbackVarMappedFromSource = source?.rcsSmsFallbackVarMapped;
34
- const hasPersistedFallbackVarMap =
35
- rcsSmsFallbackVarMappedFromSource != null
36
- && typeof rcsSmsFallbackVarMappedFromSource === 'object'
37
- && Object.keys(rcsSmsFallbackVarMappedFromSource).length > 0;
38
- return {
39
- _id: source?.smsTemplateId,
40
- name: source?.templateName,
41
- versions: {
42
- base: {
43
- 'sms-editor': source?.templateContent || source?.content,
44
- ...(Array.isArray(source?.registeredSenderIds) && source.registeredSenderIds.length
45
- ? { header: source.registeredSenderIds }
46
- : {}),
47
- ...(typeof source?.unicodeValidity === 'boolean'
48
- ? { 'unicode-validity': source.unicodeValidity }
49
- : {}),
50
- ...(hasPersistedFallbackVarMap
51
- ? { 'rcs-sms-fallback-var-mapped': rcsSmsFallbackVarMappedFromSource }
52
- : {}),
53
- },
54
- },
55
- };
56
- }
57
-
58
- export function getBaseFromSmsTraiFormData(formData) {
59
- const base = get(formData, 'versions.base', get(formData, 'value.base', {})) || {};
60
- return { base };
61
- }
62
-
63
- export function resolveContentFromTraiBase(base) {
64
- const smsEditor = base['sms-editor'] || '';
65
- return smsEditor;
66
- }
67
-
68
- /**
69
- * Card body: show TagList / VarSegment values where filled; otherwise show raw `{{…}}` / `{#…#}` tokens
70
- * (so saving without slot labels still shows `{#var#}` on the card).
71
- */
72
- export function getSmsFallbackCardDisplayContent(value) {
73
- if (!value || typeof value !== 'object') return '';
74
- const templateStr = String(value.templateContent ?? value.content ?? '');
75
- const map = value.rcsSmsFallbackVarMapped;
76
- return getFallbackResolvedContentForCardDisplay(templateStr, map && typeof map === 'object' ? map : {});
77
- }
78
-
79
- export function filterSmsTemplatesByCategory(templates, smsFilter) {
80
- if (!Array.isArray(templates)) return [];
81
- if (!smsFilter || smsFilter === SMS_CATEGORY_FILTERS.ALL) return templates;
82
- return templates.filter((template) =>
83
- (get(template, 'versions.base.type') || '').toLowerCase().includes(smsFilter),
84
- );
85
- }
86
-
87
- /**
88
- * Maps `CreativesContainer` `getCreativesData` payload (after save / create) to SmsFallback `value` shape.
89
- * See `CreativesContainer.getCreativesData` SMS branch for `messageBody` / `templateConfigs`.
90
- */
91
- export function buildFallbackDataFromCreativesPayload(creativesData) {
92
- if (!creativesData || creativesData.channel !== 'SMS') return null;
93
- const tc = creativesData.templateConfigs || {};
94
- const templateStr = typeof tc.template === 'string' ? tc.template : '';
95
- const bodyRaw = creativesData.messageBody;
96
- const body = typeof bodyRaw === 'string' ? bodyRaw : templateStr;
97
- const headerList = Array.isArray(tc.registeredSenderIds) ? tc.registeredSenderIds : [];
98
- return {
99
- smsTemplateId: tc.templateId != null ? String(tc.templateId) : '',
100
- templateName: tc.templateName != null ? String(tc.templateName) : '',
101
- content: body,
102
- templateContent: templateStr || body,
103
- senderId: headerList[0] || '',
104
- registeredSenderIds: headerList,
105
- unicodeValidity: true,
106
- };
107
- }
@@ -1,50 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import '@testing-library/jest-dom';
4
- import { SmsFallbackLocalSelector } from '../SmsFallbackLocalSelector';
5
-
6
- jest.mock('v2Containers/CreativesContainer', () => ({
7
- __esModule: true,
8
- default: () => <div data-testid="creatives-mock">CreativesContainer</div>,
9
- }));
10
-
11
- jest.mock('v2Components/CapPageSpinner', () => ({
12
- __esModule: true,
13
- default: () => <span data-testid="spinner">spinner</span>,
14
- }));
15
-
16
- describe('SmsFallbackLocalSelector', () => {
17
- const baseProps = {
18
- hidden: false,
19
- fetchDetailsLoading: false,
20
- templateList: {
21
- templates: [],
22
- loading: false,
23
- loadMore: jest.fn(),
24
- search: '',
25
- setSearch: jest.fn(),
26
- reset: jest.fn(),
27
- },
28
- channelsToHide: ['email'],
29
- smsRegister: {},
30
- onCloseCreatives: jest.fn(),
31
- onSelectTemplate: jest.fn(),
32
- filterContent: <div>filters</div>,
33
- getCreativesData: jest.fn(),
34
- };
35
-
36
- it('renders CreativesContainer with local template config', () => {
37
- render(<SmsFallbackLocalSelector {...baseProps} />);
38
- expect(screen.getByTestId('creatives-mock')).toBeInTheDocument();
39
- });
40
-
41
- it('shows loading overlay when fetchDetailsLoading is true', () => {
42
- render(<SmsFallbackLocalSelector {...baseProps} fetchDetailsLoading />);
43
- expect(screen.getByTestId('spinner')).toBeInTheDocument();
44
- });
45
-
46
- it('applies visually hidden class when hidden', () => {
47
- const { container } = render(<SmsFallbackLocalSelector {...baseProps} hidden />);
48
- expect(container.querySelector('.sms-fallback-selector--visually-hidden')).toBeTruthy();
49
- });
50
- });
@@ -1,147 +0,0 @@
1
- /**
2
- * RCS SMS fallback — acceptance / regression tests.
3
- *
4
- * Covers documented product behavior for the SMS fallback picker (SmsFallback) and
5
- * related payload expectations. Full end-to-end flows (CreativesContainer + SlideBox + SmsTraiEdit)
6
- * are better suited to manual or browser automation; those are marked with it.todo below.
7
- */
8
-
9
- import React from 'react';
10
- import { render, screen, fireEvent, waitFor } from '@testing-library/react';
11
- import '@testing-library/jest-dom';
12
- import { Provider } from 'react-redux';
13
- import { createStore } from 'redux';
14
- import { IntlProvider } from 'react-intl';
15
- import SmsFallback from '../index';
16
- import smsFallbackMessages from '../messages';
17
-
18
-
19
- jest.mock('react-redux', () => ({
20
- ...jest.requireActual('react-redux'),
21
- useDispatch: () => jest.fn(),
22
- }));
23
-
24
- jest.mock('../../../services/api', () => ({
25
- getTemplateDetails: jest.fn().mockResolvedValue({ response: {} }),
26
- }));
27
-
28
- jest.mock('../../../v2Containers/Templates/utils/smsTemplatesListApi', () => ({
29
- fetchSmsTemplatesListPage: jest.fn().mockResolvedValue({ templates: [], totalCount: 0 }),
30
- }));
31
-
32
- jest.mock('react-dom', () => ({
33
- ...jest.requireActual('react-dom'),
34
- createPortal: (node) => node,
35
- }));
36
-
37
- jest.mock('../../../v2Containers/CreativesContainer', () => ({
38
- __esModule: true,
39
- default: () => <div data-testid="sms-fallback-creatives-container">CreativesContainer</div>,
40
- }));
41
-
42
- jest.mock('../../../v2Containers/SmsTrai/Edit', () => ({
43
- __esModule: true,
44
- default: () => <div data-testid="sms-trai-edit-mock">SmsTraiEdit</div>,
45
- }));
46
-
47
- jest.mock('../../../v2Containers/SmsWrapper', () => ({
48
- __esModule: true,
49
- default: () => <div data-testid="sms-wrapper-mock">SmsWrapper</div>,
50
- }));
51
-
52
- const intlMessages = Object.keys(smsFallbackMessages).reduce((acc, key) => {
53
- const m = smsFallbackMessages[key];
54
- acc[m.id] = m.defaultMessage;
55
- return acc;
56
- }, {});
57
-
58
- const renderSmsFallback = (props = {}) => {
59
- const store = createStore((state = {}) => state);
60
- return render(
61
- <Provider store={store}>
62
- <IntlProvider locale="en" messages={intlMessages}>
63
- <SmsFallback
64
- onChange={jest.fn()}
65
- smsRegister={props.smsRegister ?? 'DLT'}
66
- isFullMode={props.isFullMode ?? true}
67
- {...props}
68
- />
69
- </IntlProvider>
70
- </Provider>
71
- );
72
- };
73
-
74
- describe('RCS SMS fallback — Create/Edit UI (SmsFallback)', () => {
75
- it('shows “Fallback SMS message (Optional)” section title when no template is selected', () => {
76
- renderSmsFallback({ value: null });
77
- expect(
78
- screen.getByText(smsFallbackMessages.sectionTitle.defaultMessage)
79
- ).toBeInTheDocument();
80
- });
81
-
82
- it('renders Select template control when no fallback value is set', () => {
83
- renderSmsFallback({ value: null });
84
- expect(
85
- screen.getByRole('button', { name: smsFallbackMessages.selectTemplate.defaultMessage })
86
- ).toBeInTheDocument();
87
- });
88
-
89
- it('opens embedded SMS template list (CreativesContainer) when Select template is clicked', async () => {
90
- renderSmsFallback({ value: null });
91
- fireEvent.click(
92
- screen.getByRole('button', { name: smsFallbackMessages.selectTemplate.defaultMessage })
93
- );
94
- await waitFor(() => {
95
- expect(screen.getByTestId('sms-fallback-creatives-container')).toBeInTheDocument();
96
- });
97
- });
98
-
99
- it('shows template name and content on the card when a fallback value is set', () => {
100
- renderSmsFallback({
101
- value: {
102
- templateName: 'Promo SMS',
103
- content: 'Hello {{name}}',
104
- },
105
- showAsCard: true,
106
- });
107
- expect(screen.getByText('Promo SMS')).toBeInTheDocument();
108
- expect(screen.getByText(/Hello/)).toBeInTheDocument();
109
- });
110
-
111
- it('wraps the SMS fallback card in sms-fallback-card-wrap for header border styling', () => {
112
- const { container } = renderSmsFallback({
113
- value: {
114
- templateName: 'Promo SMS',
115
- content: 'Hello',
116
- },
117
- showAsCard: true,
118
- });
119
- expect(container.querySelector('.sms-fallback-card-wrap')).toBeTruthy();
120
- expect(container.querySelector('.sms-fallback-card-wrap .sms-fallback-card')).toBeTruthy();
121
- });
122
-
123
- it.todo('Edit icon / more menu → Edit should open SlideBox in edit mode with header “Edit SMS Fallback” and SmsTraiEdit (Ant Dropdown + portal — use E2E or user-event + getPopupContainer)');
124
- it.todo('More menu → Remove should clear selection and show Select template CTA again');
125
-
126
- it.todo('SlideBox list header should match product copy for template selection (see CreativesContainer / TemplatesV2)');
127
- it.todo('Template grid should list only SMS creatives approved per channel filters (API + DLT category filters)');
128
- it.todo('Selecting a template should load details and transition to SmsTraiEdit with correct templateData');
129
- it.todo('Done/Save in SmsTraiEdit should persist card and close slidebox (integration)');
130
- });
131
-
132
- describe('RCS SMS fallback — SlideBox interactions', () => {
133
- it.todo('Closing SlideBox without confirming should not set fallback when none was selected');
134
- });
135
-
136
- /**
137
- * Payload: `app/v2Containers/Rcs/tests/index.test.js` asserts `smsFallBackContent` is omitted when no SmsFallback data.
138
- */
139
- describe('RCS SMS fallback — Create/Edit payload', () => {
140
- it.todo('Create/Update RCS without selecting fallback should not send smsFallBackContent (covered in Rcs index.test.js — keep in sync)');
141
- });
142
-
143
- describe('RCS SMS fallback — Edit flow (hydration & save)', () => {
144
- it.todo('Opening an existing RCS template with smsFallBackContent should pre-populate the fallback card');
145
- it.todo('Editing fallback on an existing RCS should update the card after Done/Save');
146
- it.todo('Removing fallback on an existing RCS should clear card and omit smsFallBackContent on next save');
147
- });