@capillarytech/creatives-library 8.0.303 → 8.0.304

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.
@@ -202,114 +202,6 @@ exports[`Test SlideBoxContent container Email component isTestAndPreviewMode IIF
202
202
  </SlideBoxContent__CreativesWrapper>
203
203
  `;
204
204
 
205
- exports[`Test SlideBoxContent container InApp vs InAppWrapper rendering conditions renders InApp when isFullMode=false and loyalty module enabled 1`] = `
206
- <SlideBoxContent__CreativesWrapper>
207
- <Component
208
- getDefaultTags=""
209
- isFullMode={false}
210
- key="creatives-inapp-create"
211
- location={
212
- Object {
213
- "pathname": "/inapp/create",
214
- "query": Object {
215
- "isEditFromCampaigns": undefined,
216
- "module": "library",
217
- "type": "embedded",
218
- },
219
- "search": "",
220
- }
221
- }
222
- onCreateComplete={[MockFunction]}
223
- templateData={
224
- Object {
225
- "mode": "create",
226
- }
227
- }
228
- />
229
- </SlideBoxContent__CreativesWrapper>
230
- `;
231
-
232
- exports[`Test SlideBoxContent container InApp vs InAppWrapper rendering conditions renders InApp when not full mode, not loyalty and new editor disabled 1`] = `
233
- <SlideBoxContent__CreativesWrapper>
234
- <Component
235
- getDefaultTags=""
236
- isFullMode={false}
237
- key="creatives-inapp-create"
238
- location={
239
- Object {
240
- "pathname": "/inapp/create",
241
- "query": Object {
242
- "isEditFromCampaigns": undefined,
243
- "module": "library",
244
- "type": "embedded",
245
- },
246
- "search": "",
247
- }
248
- }
249
- onCreateComplete={[MockFunction]}
250
- templateData={
251
- Object {
252
- "mode": "create",
253
- }
254
- }
255
- />
256
- </SlideBoxContent__CreativesWrapper>
257
- `;
258
-
259
- exports[`Test SlideBoxContent container InApp vs InAppWrapper rendering conditions renders InAppWrapper when full mode and new editor enabled 1`] = `
260
- <SlideBoxContent__CreativesWrapper>
261
- <Component
262
- getDefaultTags=""
263
- isFullMode={true}
264
- key="creatives-inapp-create"
265
- location={
266
- Object {
267
- "pathname": "/inapp/create",
268
- "query": Object {
269
- "isEditFromCampaigns": undefined,
270
- "module": "default",
271
- "type": false,
272
- },
273
- "search": "",
274
- }
275
- }
276
- onCreateComplete={[MockFunction]}
277
- templateData={
278
- Object {
279
- "mode": "create",
280
- }
281
- }
282
- />
283
- </SlideBoxContent__CreativesWrapper>
284
- `;
285
-
286
- exports[`Test SlideBoxContent container InApp vs InAppWrapper rendering conditions renders InAppWrapper when isFullMode=true and new editor disabled 1`] = `
287
- <SlideBoxContent__CreativesWrapper>
288
- <Component
289
- getDefaultTags=""
290
- isFullMode={true}
291
- key="creatives-inapp-create"
292
- location={
293
- Object {
294
- "pathname": "/inapp/create",
295
- "query": Object {
296
- "isEditFromCampaigns": undefined,
297
- "module": "default",
298
- "type": false,
299
- },
300
- "search": "",
301
- }
302
- }
303
- onCreateComplete={[MockFunction]}
304
- templateData={
305
- Object {
306
- "mode": "create",
307
- }
308
- }
309
- />
310
- </SlideBoxContent__CreativesWrapper>
311
- `;
312
-
313
205
  exports[`Test SlideBoxContent container Should handle isTestAndPreviewMode IIFE implementation correctly 1`] = `
314
206
  <SlideBoxContent__CreativesWrapper>
315
207
  <ForwardRef
@@ -1211,26 +1103,17 @@ exports[`Test SlideBoxContent container Should render correct component for what
1211
1103
 
1212
1104
  exports[`Test SlideBoxContent container Should render correct component for whatsapp channel create mode 2`] = `
1213
1105
  <SlideBoxContent__CreativesWrapper>
1214
- <Component
1106
+ <Connect(Connect(UserIsAuthenticated(InjectIntl(CreativesCommon))))
1107
+ date={0}
1215
1108
  getDefaultTags=""
1216
- key="creatives-inapp-create"
1217
- location={
1218
- Object {
1219
- "pathname": "/inapp/create",
1220
- "query": Object {
1221
- "isEditFromCampaigns": undefined,
1222
- "module": "library",
1223
- "type": "embedded",
1224
- },
1225
- "search": "",
1226
- }
1227
- }
1109
+ key="creatives-inapp-wrapper"
1228
1110
  onCreateComplete={[MockFunction]}
1229
1111
  templateData={
1230
1112
  Object {
1231
1113
  "mode": "create",
1232
1114
  }
1233
1115
  }
1116
+ type=""
1234
1117
  />
1235
1118
  </SlideBoxContent__CreativesWrapper>
1236
1119
  `;
@@ -956,8 +956,8 @@ const EmailHTMLEditor = (props) => {
956
956
  }
957
957
  };
958
958
 
959
- // If liquid enabled, validate first using extractTags API (skip in full/standalone mode)
960
- if (isLiquidEnabled && getLiquidTags && !isFullMode) {
959
+ // If liquid enabled, validate first using extractTags API
960
+ if (isLiquidEnabled && getLiquidTags) {
961
961
  // Note: API validation errors are already cleared at the start of handleSave
962
962
  // This ensures fresh validation on every save attempt
963
963
 
@@ -1176,10 +1176,9 @@ describe('EmailHTMLEditor', () => {
1176
1176
  mockGetAllIssues.mockReturnValue([]);
1177
1177
 
1178
1178
  // Set subject and content via component interactions
1179
- // Use isFullMode: false (library mode) to test liquid validation path
1180
1179
  const { rerender } = renderWithIntl({
1181
1180
  isGetFormData: false,
1182
- isFullMode: false,
1181
+ isFullMode: true,
1183
1182
  metaEntities: {
1184
1183
  tags: {
1185
1184
  standard: [{ name: 'customer.name' }],
@@ -1207,7 +1206,7 @@ describe('EmailHTMLEditor', () => {
1207
1206
  <EmailHTMLEditor
1208
1207
  {...defaultProps}
1209
1208
  isGetFormData
1210
- isFullMode={false}
1209
+ isFullMode
1211
1210
  metaEntities={{
1212
1211
  tags: {
1213
1212
  standard: [{ name: 'customer.name' }],
@@ -1232,10 +1231,9 @@ describe('EmailHTMLEditor', () => {
1232
1231
  mockGetAllIssues.mockReturnValue([]);
1233
1232
 
1234
1233
  // Set subject and content via component interactions
1235
- // Use isFullMode: false (library mode) to test liquid validation path
1236
1234
  const { rerender } = renderWithIntl({
1237
1235
  isGetFormData: false,
1238
- isFullMode: false,
1236
+ isFullMode: true,
1239
1237
  isLiquidEnabled: true,
1240
1238
  getLiquidTags,
1241
1239
  });
@@ -1255,7 +1253,7 @@ describe('EmailHTMLEditor', () => {
1255
1253
  await act(async () => {
1256
1254
  rerender(
1257
1255
  <IntlProvider locale="en" messages={{}}>
1258
- <EmailHTMLEditor {...defaultProps} isGetFormData isFullMode={false} getLiquidTags={getLiquidTags} />
1256
+ <EmailHTMLEditor {...defaultProps} isGetFormData isFullMode getLiquidTags={getLiquidTags} />
1259
1257
  </IntlProvider>
1260
1258
  );
1261
1259
  });
@@ -1283,10 +1281,9 @@ describe('EmailHTMLEditor', () => {
1283
1281
  mockGetAllIssues.mockReturnValue([]);
1284
1282
 
1285
1283
  // Set subject and content via component interactions
1286
- // Use isFullMode: false (library mode) to test liquid validation path
1287
1284
  const { rerender } = renderWithIntl({
1288
1285
  isGetFormData: false,
1289
- isFullMode: false,
1286
+ isFullMode: true,
1290
1287
  isLiquidEnabled: true,
1291
1288
  getLiquidTags,
1292
1289
  showLiquidErrorInFooter,
@@ -1308,7 +1305,7 @@ describe('EmailHTMLEditor', () => {
1308
1305
  await act(async () => {
1309
1306
  rerender(
1310
1307
  <IntlProvider locale="en" messages={{}}>
1311
- <EmailHTMLEditor {...defaultProps} isGetFormData isFullMode={false} getLiquidTags={getLiquidTags} showLiquidErrorInFooter={showLiquidErrorInFooter} onValidationFail={onValidationFail} />
1308
+ <EmailHTMLEditor {...defaultProps} isGetFormData isFullMode getLiquidTags={getLiquidTags} showLiquidErrorInFooter={showLiquidErrorInFooter} onValidationFail={onValidationFail} />
1312
1309
  </IntlProvider>
1313
1310
  );
1314
1311
  });
@@ -1328,7 +1325,13 @@ describe('EmailHTMLEditor', () => {
1328
1325
  return Promise.resolve(true);
1329
1326
  });
1330
1327
 
1331
- const getFormdata = jest.fn();
1328
+ const emailActions = {
1329
+ ...defaultProps.emailActions,
1330
+ transformEmailTemplate: jest.fn((obj, callback) => callback(obj)),
1331
+ createTemplate: jest.fn((obj, callback) => {
1332
+ callback({ templateId: { _id: '123', versions: {} } });
1333
+ }),
1334
+ };
1332
1335
  const getLiquidTags = jest.fn((content, callback) => {
1333
1336
  callback({ askAiraResponse: { data: [] }, isError: false });
1334
1337
  });
@@ -1336,12 +1339,12 @@ describe('EmailHTMLEditor', () => {
1336
1339
  mockGetAllIssues.mockReturnValue([]);
1337
1340
 
1338
1341
  // Set subject and content via component interactions
1339
- // Use isFullMode: false (library mode) to test liquid validation path
1340
1342
  const { rerender } = renderWithIntl({
1341
1343
  isGetFormData: false,
1342
- isFullMode: false,
1344
+ isFullMode: true,
1345
+ isLiquidEnabled: true,
1343
1346
  getLiquidTags,
1344
- getFormdata,
1347
+ emailActions,
1345
1348
  templateName: 'New Template',
1346
1349
  });
1347
1350
  const input = screen.getByTestId('subject-input');
@@ -1360,7 +1363,7 @@ describe('EmailHTMLEditor', () => {
1360
1363
  await act(async () => {
1361
1364
  rerender(
1362
1365
  <IntlProvider locale="en" messages={{}}>
1363
- <EmailHTMLEditor {...defaultProps} isGetFormData isFullMode={false} getLiquidTags={getLiquidTags} getFormdata={getFormdata} templateName="New Template" />
1366
+ <EmailHTMLEditor {...defaultProps} isGetFormData isFullMode getLiquidTags={getLiquidTags} emailActions={emailActions} templateName="New Template" />
1364
1367
  </IntlProvider>
1365
1368
  );
1366
1369
  });
@@ -1369,9 +1372,8 @@ describe('EmailHTMLEditor', () => {
1369
1372
  expect(validateLiquidTemplateContent).toHaveBeenCalled();
1370
1373
  }, { timeout: 5000 });
1371
1374
 
1372
- // In library mode (isFullMode=false), save proceeds via getFormdata
1373
1375
  await waitFor(() => {
1374
- expect(getFormdata).toHaveBeenCalled();
1376
+ expect(emailActions.createTemplate).toHaveBeenCalled();
1375
1377
  }, { timeout: 5000 });
1376
1378
  });
1377
1379
 
@@ -2709,98 +2711,4 @@ describe('EmailHTMLEditor', () => {
2709
2711
  expect(screen.getByTestId('html-editor')).toBeInTheDocument();
2710
2712
  });
2711
2713
  });
2712
-
2713
- describe('isFullMode - skip liquid validation on save', () => {
2714
- it('skips liquid validation when isFullMode is true', async () => {
2715
- validateLiquidTemplateContent.mockClear();
2716
- const getLiquidTags = jest.fn((content, callback) => {
2717
- callback({ askAiraResponse: { data: [] }, isError: false });
2718
- });
2719
- const getFormdata = jest.fn();
2720
- // Ensure no HTML/Label/Liquid errors from HtmlEditor
2721
- mockGetAllIssues.mockReturnValue([]);
2722
-
2723
- const { rerender } = renderWithIntl({
2724
- isGetFormData: false,
2725
- isFullMode: true,
2726
- isLiquidEnabled: true,
2727
- getLiquidTags,
2728
- getFormdata,
2729
- });
2730
- const input = screen.getByTestId('subject-input');
2731
- await act(async () => {
2732
- fireEvent.change(input, { target: { value: 'Valid Subject' } });
2733
- });
2734
- const changeButton = screen.getByTestId('trigger-content-change');
2735
- await act(async () => {
2736
- fireEvent.click(changeButton);
2737
- });
2738
- await act(async () => {
2739
- await new Promise((resolve) => setTimeout(resolve, 100));
2740
- });
2741
- // Trigger save
2742
- await act(async () => {
2743
- rerender(
2744
- <IntlProvider locale="en" messages={{}}>
2745
- <EmailHTMLEditor {...defaultProps} isGetFormData isFullMode getLiquidTags={getLiquidTags} getFormdata={getFormdata} />
2746
- </IntlProvider>
2747
- );
2748
- });
2749
-
2750
- // In full mode, liquid validation should be skipped entirely
2751
- await act(async () => {
2752
- await new Promise((resolve) => setTimeout(resolve, 200));
2753
- });
2754
- expect(validateLiquidTemplateContent).not.toHaveBeenCalled();
2755
- });
2756
-
2757
- it('proceeds directly to save without liquid validation in full mode', async () => {
2758
- validateLiquidTemplateContent.mockClear();
2759
- const getLiquidTags = jest.fn((content, callback) => {
2760
- callback({ askAiraResponse: { data: [] }, isError: false });
2761
- });
2762
- const emailActions = {
2763
- ...defaultProps.emailActions,
2764
- transformEmailTemplate: jest.fn((obj, callback) => callback(obj)),
2765
- createTemplate: jest.fn((obj, callback) => {
2766
- callback({ templateId: { _id: '123', versions: {} } });
2767
- }),
2768
- };
2769
- // Ensure no HTML/Label/Liquid errors from HtmlEditor
2770
- mockGetAllIssues.mockReturnValue([]);
2771
-
2772
- const { rerender } = renderWithIntl({
2773
- isGetFormData: false,
2774
- isFullMode: true,
2775
- getLiquidTags,
2776
- emailActions,
2777
- templateName: 'New Template',
2778
- });
2779
- const input = screen.getByTestId('subject-input');
2780
- await act(async () => {
2781
- fireEvent.change(input, { target: { value: 'Valid Subject' } });
2782
- });
2783
- const changeButton = screen.getByTestId('trigger-content-change');
2784
- await act(async () => {
2785
- fireEvent.click(changeButton);
2786
- });
2787
- await act(async () => {
2788
- await new Promise((resolve) => setTimeout(resolve, 100));
2789
- });
2790
- // Trigger save
2791
- await act(async () => {
2792
- rerender(
2793
- <IntlProvider locale="en" messages={{}}>
2794
- <EmailHTMLEditor {...defaultProps} isGetFormData isFullMode getLiquidTags={getLiquidTags} emailActions={emailActions} templateName="New Template" />
2795
- </IntlProvider>
2796
- );
2797
- });
2798
-
2799
- // Should skip liquid validation and proceed to save directly
2800
- await waitFor(() => {
2801
- expect(emailActions.createTemplate).toHaveBeenCalled();
2802
- }, { timeout: 5000 });
2803
- expect(validateLiquidTemplateContent).not.toHaveBeenCalled();
2804
- });
2805
- });
2806
2714
  });