@capillarytech/creatives-library 8.0.209 → 8.0.211

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.209",
4
+ "version": "8.0.211",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -155,21 +155,35 @@ describe('ContentOverlay', () => {
155
155
  it('applies overlay positioning styles', () => {
156
156
  render(<ContentOverlay />);
157
157
  const overlay = document.querySelector('.content-overlay');
158
- const styles = window.getComputedStyle(overlay);
159
- expect(styles.position).toBe('absolute');
160
- expect(styles.backgroundColor).toBeTruthy();
158
+ // Check that the overlay element exists and has the correct CSS class
159
+ expect(overlay).toBeInTheDocument();
160
+ expect(overlay).toHaveClass('content-overlay');
161
+ expect(overlay).toHaveClass('content-overlay--popup'); // default layout type is MODAL which maps to 'popup' class
162
+
163
+ // Check that inline styles from getOverlayStyles() are applied
164
+ const inlineStyles = overlay.style;
165
+ expect(inlineStyles.top).toBe('50%');
166
+ expect(inlineStyles.left).toBe('50%');
167
+ expect(inlineStyles.transform).toBe('translate(-50%, -50%)');
161
168
  });
162
169
 
163
- it('applies iframe styles when content present', () => {
170
+ it('does not apply inline iframe styles (SCSS-managed)', () => {
164
171
  render(<ContentOverlay content="<p>Test</p>" />);
165
172
  const iframe = document.querySelector('iframe');
166
- // Check inline styles directly as jsdom doesn't compute styles properly
167
- expect(iframe.style.width).toBe('100%');
168
- expect(iframe.style.height).toBe('100%');
169
- // border: 'none' might be converted to empty string by React/jsdom
170
- expect(['none', '']).toContain(iframe.style.border);
171
- expect(iframe.style.display).toBe('block');
172
- expect(iframe.style.backgroundColor).toBeTruthy();
173
+
174
+ // Verify iframe styling is managed by SCSS, not inline styles
175
+ // The iframe should have no inline style attribute since all styling
176
+ // (width: 100%, height: 100%, border: none, display: block, backgroundColor)
177
+ // is handled via the .content-overlay iframe CSS rule in _inAppPreviewPane.scss
178
+ expect(iframe.style.cssText).toBe('');
179
+ expect(iframe.hasAttribute('style')).toBe(false);
180
+
181
+ // Ensure no inline style properties are set
182
+ expect(iframe.style.width).toBe('');
183
+ expect(iframe.style.height).toBe('');
184
+ expect(iframe.style.border).toBe('');
185
+ expect(iframe.style.display).toBe('');
186
+ expect(iframe.style.backgroundColor).toBe('');
173
187
  });
174
188
  });
175
189
 
@@ -513,17 +513,21 @@ export const Rcs = (props) => {
513
513
  case RCS_STATUSES.approved:
514
514
  setTemplateStatus(RCS_STATUSES.approved);
515
515
  break;
516
- case RCS_STATUSES.rejected:
517
- setTemplateStatus(RCS_STATUSES.rejected);
518
- break;
519
516
  case RCS_STATUSES.pending:
520
517
  setTemplateStatus(RCS_STATUSES.pending);
521
518
  break;
522
519
  case RCS_STATUSES.awaitingApproval:
523
520
  setTemplateStatus(RCS_STATUSES.awaitingApproval);
524
521
  break;
525
- default:
522
+ case RCS_STATUSES.unavailable:
526
523
  setTemplateStatus(RCS_STATUSES.unavailable);
524
+ break;
525
+ case RCS_STATUSES.rejected:
526
+ setTemplateStatus(RCS_STATUSES.rejected);
527
+ break;
528
+ default:
529
+ setTemplateStatus(status);
530
+ break;
527
531
  }
528
532
  };
529
533
 
@@ -1755,7 +1759,9 @@ const splitTemplateVarString = (str) => {
1755
1759
 
1756
1760
  const uploadRcsImage = useCallback((file, type, fileParams, index) => {
1757
1761
  setImageError(null);
1762
+ const isRcsThumbnail = index === 1;
1758
1763
  actions.uploadRcsAsset(file, type, {
1764
+ isRcsThumbnail,
1759
1765
  ...fileParams,
1760
1766
  dimensionType: selectedDimension,
1761
1767
  orientation: RCS_IMAGE_DIMENSIONS[selectedDimension].orientation,
@@ -2312,13 +2318,20 @@ const splitTemplateVarString = (str) => {
2312
2318
  case RCS_STATUSES.rejected:
2313
2319
  return (
2314
2320
  <>
2315
- <CapLabel type="label2" style={{ fontWeight: 500 }}>
2321
+ <CapLabel type="label2" className="rcs-status-label">
2316
2322
  {formatMessage(messages.rejectedStatusMsg)}
2317
2323
  </CapLabel>
2318
2324
  </>
2319
2325
  );
2320
- default:
2321
- // all cases except approved and rejected, return awaiting approval
2326
+ case RCS_STATUSES.unavailable:
2327
+ return (
2328
+ <>
2329
+ <CapLabel type="label2" className="rcs-status-label">
2330
+ {formatMessage(messages.unavailableStatusMsg)}
2331
+ </CapLabel>
2332
+ </>
2333
+ );
2334
+ case RCS_STATUSES.pending:
2322
2335
  return (
2323
2336
  <>
2324
2337
  <CapLabel type="label2" style={{ fontWeight: 500 }}>
@@ -2326,6 +2339,22 @@ const splitTemplateVarString = (str) => {
2326
2339
  </CapLabel>
2327
2340
  </>
2328
2341
  );
2342
+ case RCS_STATUSES.rejected:
2343
+ return (
2344
+ <>
2345
+ <CapLabel type="label2" style={{ fontWeight: 500 }}>
2346
+ {formatMessage(messages.rejectedStatusMsg)}
2347
+ </CapLabel>
2348
+ </>
2349
+ );
2350
+ default:
2351
+ return (
2352
+ <>
2353
+ <CapLabel type="label2" className="rcs-status-label">
2354
+ {formatMessage(messages.templateStatusGeneric, { templateStatus })}
2355
+ </CapLabel>
2356
+ </>
2357
+ );
2329
2358
  }
2330
2359
  };
2331
2360
 
@@ -141,4 +141,8 @@
141
141
  height: auto;
142
142
  border-radius: 4px;
143
143
  }
144
+ }
145
+
146
+ .rcs-status-label {
147
+ font-weight: 500;
144
148
  }
@@ -18,6 +18,14 @@ export default defineMessages({
18
18
  id: `${prefix}.awaitingStatusMsg`,
19
19
  defaultMessage: 'This template is awaiting approval',
20
20
  },
21
+ unavailableStatusMsg: {
22
+ id: `${prefix}.unavailableStatusMsg`,
23
+ defaultMessage: 'This template is unavailable',
24
+ },
25
+ templateStatusGeneric: {
26
+ id: `${prefix}.templateStatusGeneric`,
27
+ defaultMessage: 'This template has been - {templateStatus}',
28
+ },
21
29
  awaitingStatusDesc: {
22
30
  id: `${prefix}.awaitingStatusDesc`,
23
31
  defaultMessage:
@@ -391,6 +399,10 @@ export default defineMessages({
391
399
  id: `${prefix}.unavailable_STATUS`,
392
400
  defaultMessage: 'unavailable',
393
401
  },
402
+ unknown_STATUS: {
403
+ id: `${prefix}.unknown_STATUS`,
404
+ defaultMessage: 'unknown',
405
+ },
394
406
  templateTypeLabel: {
395
407
  id: `${prefix}.templateTypeLabel`,
396
408
  defaultMessage: 'Template Type',
@@ -137711,18 +137711,6 @@ new message content.",
137711
137711
  "id": "creatives.containersV2.Rcs.carousel",
137712
137712
  },
137713
137713
  ],
137714
- Array [
137715
- Object {
137716
- "defaultMessage": "Template Status",
137717
- "id": "creatives.containersV2.Rcs.templateStatusLabel",
137718
- },
137719
- ],
137720
- Array [
137721
- Object {
137722
- "defaultMessage": "This template is awaiting approval",
137723
- "id": "creatives.containersV2.Rcs.awaitingStatusMsg",
137724
- },
137725
- ],
137726
137714
  Array [
137727
137715
  Object {
137728
137716
  "defaultMessage": "Enter template name",
@@ -137855,18 +137843,6 @@ new message content.",
137855
137843
  "id": "creatives.containersV2.Rcs.carousel",
137856
137844
  },
137857
137845
  ],
137858
- Array [
137859
- Object {
137860
- "defaultMessage": "Template Status",
137861
- "id": "creatives.containersV2.Rcs.templateStatusLabel",
137862
- },
137863
- ],
137864
- Array [
137865
- Object {
137866
- "defaultMessage": "This template is awaiting approval",
137867
- "id": "creatives.containersV2.Rcs.awaitingStatusMsg",
137868
- },
137869
- ],
137870
137846
  Array [
137871
137847
  Object {
137872
137848
  "defaultMessage": "Enter template name",
@@ -138321,22 +138297,6 @@ new message content.",
138321
138297
  "type": "return",
138322
138298
  "value": undefined,
138323
138299
  },
138324
- Object {
138325
- "type": "return",
138326
- "value": undefined,
138327
- },
138328
- Object {
138329
- "type": "return",
138330
- "value": undefined,
138331
- },
138332
- Object {
138333
- "type": "return",
138334
- "value": undefined,
138335
- },
138336
- Object {
138337
- "type": "return",
138338
- "value": undefined,
138339
- },
138340
138300
  ],
138341
138301
  },
138342
138302
  }
@@ -138455,117 +138415,6 @@ new message content.",
138455
138415
  className="ant-spin-container ant-spin-blur"
138456
138416
  key="container"
138457
138417
  >
138458
- <CapRow
138459
- className="template-status-container"
138460
- >
138461
- <Row
138462
- className="cap-row-v2 template-status-container"
138463
- gutter={0}
138464
- >
138465
- <div
138466
- className="ant-row cap-row-v2 template-status-container"
138467
- >
138468
- <CapLabel
138469
- key=".0"
138470
- type="label2"
138471
- >
138472
- <div
138473
- className="CapLabel-n7zsf5-0 jzfptu"
138474
- type="label2"
138475
- />
138476
- </CapLabel>
138477
- <CapAlert
138478
- key=".1"
138479
- message={
138480
- <React.Fragment>
138481
- <CapLabel
138482
- style={
138483
- Object {
138484
- "fontWeight": 500,
138485
- }
138486
- }
138487
- type="label2"
138488
- />
138489
- </React.Fragment>
138490
- }
138491
- type="warning"
138492
- >
138493
- <Alert
138494
- className="cap-alert-v2"
138495
- message={
138496
- <React.Fragment>
138497
- <CapLabel
138498
- style={
138499
- Object {
138500
- "fontWeight": 500,
138501
- }
138502
- }
138503
- type="label2"
138504
- />
138505
- </React.Fragment>
138506
- }
138507
- type="warning"
138508
- >
138509
- <Animate
138510
- animation={Object {}}
138511
- component=""
138512
- componentProps={Object {}}
138513
- onAppear={[Function]}
138514
- onEnd={[Function]}
138515
- onEnter={[Function]}
138516
- onLeave={[Function]}
138517
- showProp="data-show"
138518
- transitionAppear={false}
138519
- transitionEnter={true}
138520
- transitionLeave={true}
138521
- transitionName="ant-alert-slide-up"
138522
- >
138523
- <AnimateChild
138524
- animation={Object {}}
138525
- key="rc_animate_1612267539410"
138526
- transitionAppear={false}
138527
- transitionEnter={true}
138528
- transitionLeave={true}
138529
- transitionName="ant-alert-slide-up"
138530
- >
138531
- <div
138532
- className="ant-alert ant-alert-warning ant-alert-no-icon cap-alert-v2"
138533
- data-show={true}
138534
- key="rc_animate_1612267539410"
138535
- >
138536
- <span
138537
- className="ant-alert-message"
138538
- >
138539
- <CapLabel
138540
- style={
138541
- Object {
138542
- "fontWeight": 500,
138543
- }
138544
- }
138545
- type="label2"
138546
- >
138547
- <div
138548
- className="CapLabel-n7zsf5-0 jzfptu"
138549
- style={
138550
- Object {
138551
- "fontWeight": 500,
138552
- }
138553
- }
138554
- type="label2"
138555
- />
138556
- </CapLabel>
138557
- </span>
138558
- <span
138559
- className="ant-alert-description"
138560
- />
138561
- </div>
138562
- </AnimateChild>
138563
- </Animate>
138564
- </Alert>
138565
- </CapAlert>
138566
- </div>
138567
- </Row>
138568
- </CapRow>
138569
138418
  <CapRow
138570
138419
  className="cap-rcs-creatives"
138571
138420
  >
@@ -179,6 +179,18 @@ describe('Creatives rcs test/>', () => {
179
179
  expect(renderedComponent).toMatchSnapshot();
180
180
  });
181
181
 
182
+ it('shows generic template status message for custom status', () => {
183
+ const details = JSON.parse(JSON.stringify(mockData.editData1.templateDetails));
184
+ details.versions.base.content.RCS.rcsContent.cardContent[0].Status = 'created';
185
+ renderHelper({ rcsData: { templateDetails: details } });
186
+
187
+ const calledWithGeneric = formatMessage.mock.calls.some(([msg, values]) => {
188
+ return msg && msg.id && msg.id.indexOf('.templateStatusGeneric') !== -1 && values && values.templateStatus === 'created';
189
+ });
190
+
191
+ expect(calledWithGeneric).toBe(true);
192
+ });
193
+
182
194
  it('template title change', () => {
183
195
  renderHelper({});
184
196
  // Test that title field is NOT present for text_message template type (default)
@@ -102,6 +102,9 @@ describe('RCS utils', () => {
102
102
  it('returns pending for awaitingApproval', () => {
103
103
  expect(getRcsStatusType(RCS_STATUSES.awaitingApproval)).toBe(RCS_STATUSES.pending);
104
104
  });
105
+ it('returns pending for pending', () => {
106
+ expect(getRcsStatusType(RCS_STATUSES.pending)).toBe(RCS_STATUSES.pending);
107
+ });
105
108
  it('returns rejected for rejected', () => {
106
109
  expect(getRcsStatusType(RCS_STATUSES.rejected)).toBe(RCS_STATUSES.rejected);
107
110
  });
@@ -111,8 +114,8 @@ describe('RCS utils', () => {
111
114
  it('returns approved for approved', () => {
112
115
  expect(getRcsStatusType(RCS_STATUSES.approved)).toBe(RCS_STATUSES.approved);
113
116
  });
114
- it('returns approved for unknown status', () => {
115
- expect(getRcsStatusType('some_unknown_status')).toBe(RCS_STATUSES.approved);
117
+ it('returns rejected for unknown status', () => {
118
+ expect(getRcsStatusType('some_unknown_status')).toBe(RCS_STATUSES.rejected);
116
119
  });
117
120
  });
118
121
 
@@ -11,12 +11,14 @@ export const getRcsStatusType = (status) => {
11
11
  switch (status) {
12
12
  case RCS_STATUSES.awaitingApproval:
13
13
  return RCS_STATUSES.pending;
14
- case RCS_STATUSES.rejected:
15
- return RCS_STATUSES.rejected;
16
14
  case RCS_STATUSES.unavailable:
17
15
  return RCS_STATUSES.unavailable;
18
- default:
16
+ case RCS_STATUSES.approved:
19
17
  return RCS_STATUSES.approved;
18
+ case RCS_STATUSES.pending:
19
+ return RCS_STATUSES.pending;
20
+ default:
21
+ return RCS_STATUSES.rejected;
20
22
  }
21
23
  };
22
24
 
@@ -1660,13 +1660,14 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1660
1660
  case RCS: {
1661
1661
  const status = get(template, "versions.base.content.RCS.rcsContent.cardContent[0].Status", "unavailable");
1662
1662
  const name = get(template, "name", "");
1663
+ const statusDisplay=getRcsStatusType(status);
1663
1664
  templateData.title = (
1664
1665
  <CapRow>
1665
1666
  <CapLabel className="whatsapp-rcs-template-name">{name}</CapLabel>
1666
1667
  <CapRow type="flex" align="middle" className="rcs-status-container zalo-status-color">
1667
1668
  <CapStatus
1668
- type={getRcsStatusType(status)}
1669
- text={status && this.props.intl.formatMessage(rcsMessages?.[`${status}_STATUS`])}
1669
+ type={statusDisplay}
1670
+ text={statusDisplay && this.props.intl.formatMessage(rcsMessages?.[`${statusDisplay}_STATUS`])}
1670
1671
  labelType="label3"
1671
1672
  />
1672
1673
  </CapRow>