@capillarytech/creatives-library 8.0.359-alpha.0 → 8.0.360-alpha.0
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/index.html +1 -0
- package/package.json +1 -1
- package/utils/cdnTransformation.js +75 -3
- package/utils/tests/cdnTransformation.test.js +127 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/PreviewHeader.js +16 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberCarouselPreviewCards.js +132 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberPreviewContent.js +2 -37
- package/v2Components/CommonTestAndPreview/UnifiedPreview/WebPushPreviewContent.js +169 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +55 -85
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_viberCarouselPreviewCards.scss +127 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +52 -6
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +67 -3
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/PreviewHeader.test.js +163 -0
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/WebPushPreviewContent.test.js +522 -0
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +255 -0
- package/v2Components/CommonTestAndPreview/tests/constants.test.js +2 -1
- package/v2Components/CommonTestAndPreview/tests/index.test.js +194 -0
- package/v2Components/FormBuilder/index.js +162 -52
- package/v2Components/TestAndPreviewSlidebox/index.js +2 -2
- package/v2Containers/App/constants.js +3 -0
- package/v2Containers/App/tests/constants.test.js +61 -0
- package/v2Containers/CreativesContainer/index.js +60 -24
- package/v2Containers/Templates/index.js +72 -2
- package/v2Containers/Templates/sagas.js +6 -1
- package/v2Containers/Templates/tests/sagas.test.js +23 -6
- package/v2Containers/Templates/tests/webpush.test.js +375 -0
- package/v2Containers/Viber/index.js +24 -18
- package/v2Containers/Viber/index.scss +27 -0
- package/v2Containers/Viber/messages.js +4 -4
- package/v2Containers/WebPush/Create/index.js +91 -8
- package/v2Containers/WebPush/Create/index.scss +7 -0
- package/v2Containers/WebPush/Create/tests/getTemplateContent.test.js +348 -0
- package/v2Containers/WebPush/Create/tests/testAndPreviewIntegration.test.js +325 -0
|
@@ -119,6 +119,21 @@ jest.mock('../../UnifiedPreview/ZaloPreviewContent', () => ({
|
|
|
119
119
|
),
|
|
120
120
|
}));
|
|
121
121
|
|
|
122
|
+
jest.mock('../../UnifiedPreview/WebPushPreviewContent', () => ({
|
|
123
|
+
__esModule: true,
|
|
124
|
+
default: (props) => (
|
|
125
|
+
<div data-testid="webpush-preview">
|
|
126
|
+
<div data-testid="webpush-title">{props.notificationTitle}</div>
|
|
127
|
+
<div data-testid="webpush-body">{props.notificationBody}</div>
|
|
128
|
+
<div data-testid="webpush-image">{props.imageSrc}</div>
|
|
129
|
+
<div data-testid="webpush-icon">{props.brandIconSrc}</div>
|
|
130
|
+
<div data-testid="webpush-url">{props.url}</div>
|
|
131
|
+
<div data-testid="webpush-buttons">{JSON.stringify(props.buttons)}</div>
|
|
132
|
+
<div data-testid="webpush-fullscreen">{props.isFullscreenOpen ? 'true' : 'false'}</div>
|
|
133
|
+
</div>
|
|
134
|
+
),
|
|
135
|
+
}));
|
|
136
|
+
|
|
122
137
|
jest.mock('../../UnifiedPreview/PreviewHeader', () => ({
|
|
123
138
|
__esModule: true,
|
|
124
139
|
default: (props) => (
|
|
@@ -976,4 +991,244 @@ describe('UnifiedPreview', () => {
|
|
|
976
991
|
consoleSpy.mockRestore();
|
|
977
992
|
});
|
|
978
993
|
});
|
|
994
|
+
|
|
995
|
+
describe('Channel Routing - WEBPUSH', () => {
|
|
996
|
+
it('should render WebPushPreviewContent for WEBPUSH channel with object content', () => {
|
|
997
|
+
const content = {
|
|
998
|
+
content: {
|
|
999
|
+
title: 'Hello World',
|
|
1000
|
+
message: 'This is a notification',
|
|
1001
|
+
iconImageUrl: 'https://example.com/icon.png',
|
|
1002
|
+
cta: { actionLink: 'https://example.com' },
|
|
1003
|
+
expandableDetails: {
|
|
1004
|
+
media: [{ url: 'https://example.com/image.jpg' }],
|
|
1005
|
+
ctas: [{ title: 'Click me', actionLink: 'https://example.com/btn', type: 'EXTERNAL_URL' }],
|
|
1006
|
+
},
|
|
1007
|
+
},
|
|
1008
|
+
};
|
|
1009
|
+
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1010
|
+
|
|
1011
|
+
render(
|
|
1012
|
+
<TestWrapper>
|
|
1013
|
+
<ComponentToRender {...props} />
|
|
1014
|
+
</TestWrapper>
|
|
1015
|
+
);
|
|
1016
|
+
|
|
1017
|
+
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1018
|
+
expect(screen.getByTestId('webpush-title')).toHaveTextContent('Hello World');
|
|
1019
|
+
expect(screen.getByTestId('webpush-body')).toHaveTextContent('This is a notification');
|
|
1020
|
+
expect(screen.getByTestId('webpush-icon')).toHaveTextContent('https://example.com/icon.png');
|
|
1021
|
+
expect(screen.getByTestId('webpush-url')).toHaveTextContent('https://example.com');
|
|
1022
|
+
});
|
|
1023
|
+
|
|
1024
|
+
it('should render WebPushPreviewContent for WEBPUSH channel with JSON string content', () => {
|
|
1025
|
+
const contentObj = {
|
|
1026
|
+
content: {
|
|
1027
|
+
title: 'Push Title',
|
|
1028
|
+
message: 'Push message body',
|
|
1029
|
+
iconImageUrl: 'https://example.com/brand.png',
|
|
1030
|
+
},
|
|
1031
|
+
};
|
|
1032
|
+
const props = {
|
|
1033
|
+
...defaultProps,
|
|
1034
|
+
channel: CHANNELS.WEBPUSH,
|
|
1035
|
+
content: JSON.stringify(contentObj),
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
render(
|
|
1039
|
+
<TestWrapper>
|
|
1040
|
+
<ComponentToRender {...props} />
|
|
1041
|
+
</TestWrapper>
|
|
1042
|
+
);
|
|
1043
|
+
|
|
1044
|
+
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1045
|
+
expect(screen.getByTestId('webpush-title')).toHaveTextContent('Push Title');
|
|
1046
|
+
expect(screen.getByTestId('webpush-body')).toHaveTextContent('Push message body');
|
|
1047
|
+
expect(screen.getByTestId('webpush-icon')).toHaveTextContent('https://example.com/brand.png');
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
it('should fallback to empty object when JSON parse fails', () => {
|
|
1051
|
+
const props = {
|
|
1052
|
+
...defaultProps,
|
|
1053
|
+
channel: CHANNELS.WEBPUSH,
|
|
1054
|
+
content: 'INVALID_JSON{{{{',
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
render(
|
|
1058
|
+
<TestWrapper>
|
|
1059
|
+
<ComponentToRender {...props} />
|
|
1060
|
+
</TestWrapper>
|
|
1061
|
+
);
|
|
1062
|
+
|
|
1063
|
+
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1064
|
+
expect(screen.getByTestId('webpush-title')).toHaveTextContent('');
|
|
1065
|
+
expect(screen.getByTestId('webpush-body')).toHaveTextContent('');
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
it('should fallback to empty object when content is null', () => {
|
|
1069
|
+
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content: null };
|
|
1070
|
+
|
|
1071
|
+
render(
|
|
1072
|
+
<TestWrapper>
|
|
1073
|
+
<ComponentToRender {...props} />
|
|
1074
|
+
</TestWrapper>
|
|
1075
|
+
);
|
|
1076
|
+
|
|
1077
|
+
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1078
|
+
expect(screen.getByTestId('webpush-title')).toHaveTextContent('');
|
|
1079
|
+
});
|
|
1080
|
+
|
|
1081
|
+
it('should extract imageSrc from expandableDetails.media[0].url', () => {
|
|
1082
|
+
const content = {
|
|
1083
|
+
content: {
|
|
1084
|
+
title: 'T',
|
|
1085
|
+
message: 'M',
|
|
1086
|
+
expandableDetails: {
|
|
1087
|
+
media: [{ url: 'https://example.com/media.jpg' }],
|
|
1088
|
+
ctas: [],
|
|
1089
|
+
},
|
|
1090
|
+
},
|
|
1091
|
+
};
|
|
1092
|
+
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1093
|
+
|
|
1094
|
+
render(
|
|
1095
|
+
<TestWrapper>
|
|
1096
|
+
<ComponentToRender {...props} />
|
|
1097
|
+
</TestWrapper>
|
|
1098
|
+
);
|
|
1099
|
+
|
|
1100
|
+
expect(screen.getByTestId('webpush-image')).toHaveTextContent('https://example.com/media.jpg');
|
|
1101
|
+
});
|
|
1102
|
+
|
|
1103
|
+
it('should pass empty imageSrc when media array is empty', () => {
|
|
1104
|
+
const content = {
|
|
1105
|
+
content: {
|
|
1106
|
+
title: 'T',
|
|
1107
|
+
message: 'M',
|
|
1108
|
+
expandableDetails: { media: [], ctas: [] },
|
|
1109
|
+
},
|
|
1110
|
+
};
|
|
1111
|
+
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1112
|
+
|
|
1113
|
+
render(
|
|
1114
|
+
<TestWrapper>
|
|
1115
|
+
<ComponentToRender {...props} />
|
|
1116
|
+
</TestWrapper>
|
|
1117
|
+
);
|
|
1118
|
+
|
|
1119
|
+
expect(screen.getByTestId('webpush-image')).toHaveTextContent('');
|
|
1120
|
+
});
|
|
1121
|
+
|
|
1122
|
+
it('should map CTA buttons from expandableDetails.ctas', () => {
|
|
1123
|
+
const content = {
|
|
1124
|
+
content: {
|
|
1125
|
+
title: 'T',
|
|
1126
|
+
message: 'M',
|
|
1127
|
+
expandableDetails: {
|
|
1128
|
+
media: [],
|
|
1129
|
+
ctas: [
|
|
1130
|
+
{ title: 'Btn1', actionLink: 'https://a.com', type: 'EXTERNAL_URL' },
|
|
1131
|
+
{ title: 'Btn2', actionLink: 'https://b.com', type: 'SITE_URL' },
|
|
1132
|
+
],
|
|
1133
|
+
},
|
|
1134
|
+
},
|
|
1135
|
+
};
|
|
1136
|
+
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1137
|
+
|
|
1138
|
+
render(
|
|
1139
|
+
<TestWrapper>
|
|
1140
|
+
<ComponentToRender {...props} />
|
|
1141
|
+
</TestWrapper>
|
|
1142
|
+
);
|
|
1143
|
+
|
|
1144
|
+
const buttons = JSON.parse(screen.getByTestId('webpush-buttons').textContent);
|
|
1145
|
+
expect(buttons).toHaveLength(2);
|
|
1146
|
+
expect(buttons[0]).toEqual({ text: 'Btn1', url: 'https://a.com', type: 'EXTERNAL_URL' });
|
|
1147
|
+
expect(buttons[1]).toEqual({ text: 'Btn2', url: 'https://b.com', type: 'SITE_URL' });
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
it('should pass empty buttons array when no ctas', () => {
|
|
1151
|
+
const content = { content: { title: 'T', message: 'M' } };
|
|
1152
|
+
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1153
|
+
|
|
1154
|
+
render(
|
|
1155
|
+
<TestWrapper>
|
|
1156
|
+
<ComponentToRender {...props} />
|
|
1157
|
+
</TestWrapper>
|
|
1158
|
+
);
|
|
1159
|
+
|
|
1160
|
+
const buttons = JSON.parse(screen.getByTestId('webpush-buttons').textContent);
|
|
1161
|
+
expect(buttons).toEqual([]);
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
it('should NOT show device toggle for WEBPUSH channel', () => {
|
|
1165
|
+
const props = {
|
|
1166
|
+
...defaultProps,
|
|
1167
|
+
channel: CHANNELS.WEBPUSH,
|
|
1168
|
+
showDeviceToggle: true,
|
|
1169
|
+
showHeader: true,
|
|
1170
|
+
selectedCustomer: { name: 'Alice' },
|
|
1171
|
+
};
|
|
1172
|
+
|
|
1173
|
+
render(
|
|
1174
|
+
<TestWrapper>
|
|
1175
|
+
<ComponentToRender {...props} />
|
|
1176
|
+
</TestWrapper>
|
|
1177
|
+
);
|
|
1178
|
+
|
|
1179
|
+
// PreviewHeader is mocked - verify it receives showDeviceToggle=false for WEBPUSH
|
|
1180
|
+
const header = screen.getByTestId('preview-header');
|
|
1181
|
+
expect(header).toBeTruthy();
|
|
1182
|
+
});
|
|
1183
|
+
|
|
1184
|
+
it('should include WEBPUSH in supported channels list', () => {
|
|
1185
|
+
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content: {} };
|
|
1186
|
+
|
|
1187
|
+
render(
|
|
1188
|
+
<TestWrapper>
|
|
1189
|
+
<ComponentToRender {...props} />
|
|
1190
|
+
</TestWrapper>
|
|
1191
|
+
);
|
|
1192
|
+
|
|
1193
|
+
// WEBPUSH should render WebPushPreviewContent, not the unsupported placeholder
|
|
1194
|
+
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1195
|
+
expect(screen.queryByText(/Coming Soon/)).toBeNull();
|
|
1196
|
+
});
|
|
1197
|
+
|
|
1198
|
+
it('should pass isUpdating to WebPushPreviewContent in loading state', () => {
|
|
1199
|
+
const props = {
|
|
1200
|
+
...defaultProps,
|
|
1201
|
+
channel: CHANNELS.WEBPUSH,
|
|
1202
|
+
content: { content: { title: 'T', message: 'M' } },
|
|
1203
|
+
isUpdating: true,
|
|
1204
|
+
};
|
|
1205
|
+
|
|
1206
|
+
render(
|
|
1207
|
+
<TestWrapper>
|
|
1208
|
+
<ComponentToRender {...props} />
|
|
1209
|
+
</TestWrapper>
|
|
1210
|
+
);
|
|
1211
|
+
|
|
1212
|
+
// When isUpdating, component shows loading spinner, not WebPushPreviewContent
|
|
1213
|
+
expect(screen.queryByTestId('webpush-preview')).toBeNull();
|
|
1214
|
+
});
|
|
1215
|
+
|
|
1216
|
+
it('should pass error to WebPushPreviewContent in error state', () => {
|
|
1217
|
+
const props = {
|
|
1218
|
+
...defaultProps,
|
|
1219
|
+
channel: CHANNELS.WEBPUSH,
|
|
1220
|
+
content: { content: { title: 'T', message: 'M' } },
|
|
1221
|
+
error: 'Network error',
|
|
1222
|
+
};
|
|
1223
|
+
|
|
1224
|
+
render(
|
|
1225
|
+
<TestWrapper>
|
|
1226
|
+
<ComponentToRender {...props} />
|
|
1227
|
+
</TestWrapper>
|
|
1228
|
+
);
|
|
1229
|
+
|
|
1230
|
+
// When error, component shows error state, not WebPushPreviewContent
|
|
1231
|
+
expect(screen.queryByTestId('webpush-preview')).toBeNull();
|
|
1232
|
+
});
|
|
1233
|
+
});
|
|
979
1234
|
});
|
|
@@ -179,10 +179,11 @@ describe('CommonTestAndPreview Constants', () => {
|
|
|
179
179
|
expect(CHANNELS.MOBILEPUSH).toBe('MOBILEPUSH');
|
|
180
180
|
expect(CHANNELS.VIBER).toBe('VIBER');
|
|
181
181
|
expect(CHANNELS.ZALO).toBe('ZALO');
|
|
182
|
+
expect(CHANNELS.WEBPUSH).toBe('WEBPUSH');
|
|
182
183
|
});
|
|
183
184
|
|
|
184
185
|
it('should have all required channel keys', () => {
|
|
185
|
-
const expectedChannels = ['EMAIL', 'SMS', 'RCS', 'WHATSAPP', 'INAPP', 'MOBILEPUSH', 'VIBER', 'ZALO'];
|
|
186
|
+
const expectedChannels = ['EMAIL', 'SMS', 'RCS', 'WHATSAPP', 'INAPP', 'MOBILEPUSH', 'VIBER', 'ZALO', 'WEBPUSH'];
|
|
186
187
|
expect(Object.keys(CHANNELS)).toEqual(expect.arrayContaining(expectedChannels));
|
|
187
188
|
expect(Object.keys(CHANNELS).length).toBe(expectedChannels.length);
|
|
188
189
|
});
|
|
@@ -1174,6 +1174,50 @@ describe('CommonTestAndPreview', () => {
|
|
|
1174
1174
|
expect(screen.getByTestId('preview-section')).toBeTruthy();
|
|
1175
1175
|
});
|
|
1176
1176
|
});
|
|
1177
|
+
|
|
1178
|
+
it('should handle WEBPUSH channel', async () => {
|
|
1179
|
+
const webpushContent = {
|
|
1180
|
+
content: { title: 'Web Push', message: 'Hello from web push' },
|
|
1181
|
+
accountId: 'acc-001',
|
|
1182
|
+
};
|
|
1183
|
+
const props = {
|
|
1184
|
+
...defaultProps,
|
|
1185
|
+
channel: CHANNELS.WEBPUSH,
|
|
1186
|
+
content: webpushContent,
|
|
1187
|
+
};
|
|
1188
|
+
|
|
1189
|
+
render(
|
|
1190
|
+
<TestWrapper>
|
|
1191
|
+
<CommonTestAndPreview {...props} />
|
|
1192
|
+
</TestWrapper>
|
|
1193
|
+
);
|
|
1194
|
+
|
|
1195
|
+
await waitFor(() => {
|
|
1196
|
+
expect(screen.getByTestId('left-panel')).toBeTruthy();
|
|
1197
|
+
expect(screen.getByTestId('preview-section')).toBeTruthy();
|
|
1198
|
+
});
|
|
1199
|
+
});
|
|
1200
|
+
|
|
1201
|
+
it('should treat WEBPUSH content as object (same branch as WHATSAPP)', async () => {
|
|
1202
|
+
// The WEBPUSH channel uses the same contentObj branch as WHATSAPP (JSON string or object)
|
|
1203
|
+
const props = {
|
|
1204
|
+
...defaultProps,
|
|
1205
|
+
channel: CHANNELS.WEBPUSH,
|
|
1206
|
+
content: JSON.stringify({
|
|
1207
|
+
content: { title: 'Stringified', message: 'Content' },
|
|
1208
|
+
}),
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1211
|
+
render(
|
|
1212
|
+
<TestWrapper>
|
|
1213
|
+
<CommonTestAndPreview {...props} />
|
|
1214
|
+
</TestWrapper>
|
|
1215
|
+
);
|
|
1216
|
+
|
|
1217
|
+
await waitFor(() => {
|
|
1218
|
+
expect(screen.getByTestId('preview-section')).toBeTruthy();
|
|
1219
|
+
});
|
|
1220
|
+
});
|
|
1177
1221
|
});
|
|
1178
1222
|
|
|
1179
1223
|
describe('Device Initialization', () => {
|
|
@@ -2629,6 +2673,156 @@ describe('CommonTestAndPreview', () => {
|
|
|
2629
2673
|
});
|
|
2630
2674
|
});
|
|
2631
2675
|
});
|
|
2676
|
+
|
|
2677
|
+
describe('preparePreviewPayload - WEBPUSH', () => {
|
|
2678
|
+
it('should build WEBPUSH payload with title and message', async () => {
|
|
2679
|
+
const webpushContent = {
|
|
2680
|
+
content: {
|
|
2681
|
+
title: 'Push Title',
|
|
2682
|
+
message: 'Push message body',
|
|
2683
|
+
},
|
|
2684
|
+
accountId: 'acc-123',
|
|
2685
|
+
messageSubject: 'Push Title',
|
|
2686
|
+
};
|
|
2687
|
+
const props = {
|
|
2688
|
+
...defaultProps,
|
|
2689
|
+
channel: CHANNELS.WEBPUSH,
|
|
2690
|
+
content: JSON.stringify(webpushContent),
|
|
2691
|
+
};
|
|
2692
|
+
|
|
2693
|
+
render(
|
|
2694
|
+
<TestWrapper>
|
|
2695
|
+
<CommonTestAndPreview {...props} />
|
|
2696
|
+
</TestWrapper>
|
|
2697
|
+
);
|
|
2698
|
+
|
|
2699
|
+
await waitFor(() => {
|
|
2700
|
+
expect(screen.getByTestId('left-panel')).toBeTruthy();
|
|
2701
|
+
expect(screen.getByTestId('preview-section')).toBeTruthy();
|
|
2702
|
+
});
|
|
2703
|
+
});
|
|
2704
|
+
|
|
2705
|
+
it('should handle WEBPUSH content with iconImageUrl', async () => {
|
|
2706
|
+
const webpushContent = {
|
|
2707
|
+
content: {
|
|
2708
|
+
title: 'Hello',
|
|
2709
|
+
message: 'World',
|
|
2710
|
+
iconImageUrl: 'https://example.com/icon.png',
|
|
2711
|
+
},
|
|
2712
|
+
accountId: 'acc-123',
|
|
2713
|
+
};
|
|
2714
|
+
const props = {
|
|
2715
|
+
...defaultProps,
|
|
2716
|
+
channel: CHANNELS.WEBPUSH,
|
|
2717
|
+
content: webpushContent,
|
|
2718
|
+
};
|
|
2719
|
+
|
|
2720
|
+
render(
|
|
2721
|
+
<TestWrapper>
|
|
2722
|
+
<CommonTestAndPreview {...props} />
|
|
2723
|
+
</TestWrapper>
|
|
2724
|
+
);
|
|
2725
|
+
|
|
2726
|
+
await waitFor(() => {
|
|
2727
|
+
expect(screen.getByTestId('preview-section')).toBeTruthy();
|
|
2728
|
+
});
|
|
2729
|
+
});
|
|
2730
|
+
|
|
2731
|
+
it('should handle WEBPUSH content with cta', async () => {
|
|
2732
|
+
const webpushContent = {
|
|
2733
|
+
content: {
|
|
2734
|
+
title: 'Hello',
|
|
2735
|
+
message: 'World',
|
|
2736
|
+
cta: { type: 'EXTERNAL_URL', actionLink: 'https://example.com' },
|
|
2737
|
+
},
|
|
2738
|
+
accountId: 'acc-123',
|
|
2739
|
+
};
|
|
2740
|
+
const props = {
|
|
2741
|
+
...defaultProps,
|
|
2742
|
+
channel: CHANNELS.WEBPUSH,
|
|
2743
|
+
content: webpushContent,
|
|
2744
|
+
};
|
|
2745
|
+
|
|
2746
|
+
render(
|
|
2747
|
+
<TestWrapper>
|
|
2748
|
+
<CommonTestAndPreview {...props} />
|
|
2749
|
+
</TestWrapper>
|
|
2750
|
+
);
|
|
2751
|
+
|
|
2752
|
+
await waitFor(() => {
|
|
2753
|
+
expect(screen.getByTestId('preview-section')).toBeTruthy();
|
|
2754
|
+
});
|
|
2755
|
+
});
|
|
2756
|
+
|
|
2757
|
+
it('should handle WEBPUSH content with expandableDetails', async () => {
|
|
2758
|
+
const webpushContent = {
|
|
2759
|
+
content: {
|
|
2760
|
+
title: 'Hello',
|
|
2761
|
+
message: 'World',
|
|
2762
|
+
expandableDetails: {
|
|
2763
|
+
media: [{ url: 'https://example.com/image.jpg', type: 'IMAGE' }],
|
|
2764
|
+
ctas: [{ title: 'Click', actionLink: 'https://example.com', type: 'EXTERNAL_URL' }],
|
|
2765
|
+
},
|
|
2766
|
+
},
|
|
2767
|
+
accountId: 'acc-123',
|
|
2768
|
+
};
|
|
2769
|
+
const props = {
|
|
2770
|
+
...defaultProps,
|
|
2771
|
+
channel: CHANNELS.WEBPUSH,
|
|
2772
|
+
content: webpushContent,
|
|
2773
|
+
};
|
|
2774
|
+
|
|
2775
|
+
render(
|
|
2776
|
+
<TestWrapper>
|
|
2777
|
+
<CommonTestAndPreview {...props} />
|
|
2778
|
+
</TestWrapper>
|
|
2779
|
+
);
|
|
2780
|
+
|
|
2781
|
+
await waitFor(() => {
|
|
2782
|
+
expect(screen.getByTestId('preview-section')).toBeTruthy();
|
|
2783
|
+
});
|
|
2784
|
+
});
|
|
2785
|
+
|
|
2786
|
+
it('should handle WEBPUSH with null formData gracefully', async () => {
|
|
2787
|
+
const props = {
|
|
2788
|
+
...defaultProps,
|
|
2789
|
+
channel: CHANNELS.WEBPUSH,
|
|
2790
|
+
formData: null,
|
|
2791
|
+
content: null,
|
|
2792
|
+
};
|
|
2793
|
+
|
|
2794
|
+
render(
|
|
2795
|
+
<TestWrapper>
|
|
2796
|
+
<CommonTestAndPreview {...props} />
|
|
2797
|
+
</TestWrapper>
|
|
2798
|
+
);
|
|
2799
|
+
|
|
2800
|
+
await waitFor(() => {
|
|
2801
|
+
expect(screen.getByTestId('preview-section')).toBeTruthy();
|
|
2802
|
+
});
|
|
2803
|
+
});
|
|
2804
|
+
|
|
2805
|
+
it('should handle WEBPUSH channel with object content (non-string)', async () => {
|
|
2806
|
+
const props = {
|
|
2807
|
+
...defaultProps,
|
|
2808
|
+
channel: CHANNELS.WEBPUSH,
|
|
2809
|
+
content: {
|
|
2810
|
+
content: { title: 'ObjTitle', message: 'ObjMessage' },
|
|
2811
|
+
accountId: 'acc-999',
|
|
2812
|
+
},
|
|
2813
|
+
};
|
|
2814
|
+
|
|
2815
|
+
render(
|
|
2816
|
+
<TestWrapper>
|
|
2817
|
+
<CommonTestAndPreview {...props} />
|
|
2818
|
+
</TestWrapper>
|
|
2819
|
+
);
|
|
2820
|
+
|
|
2821
|
+
await waitFor(() => {
|
|
2822
|
+
expect(screen.getByTestId('preview-section')).toBeTruthy();
|
|
2823
|
+
});
|
|
2824
|
+
});
|
|
2825
|
+
});
|
|
2632
2826
|
});
|
|
2633
2827
|
|
|
2634
2828
|
describe('Tag Extraction', () => {
|