@capillarytech/creatives-library 9.1.6 → 9.1.7-alpha.sprint-notifygatewayfix.33
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 +1 -1
- package/services/api.js +6 -2
- package/services/tests/api.test.js +24 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.js +1 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +5 -1
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/DeliverySettingsSection.test.js +23 -4
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -343,9 +343,13 @@ export const getTemplateDetails = async ({id, channel}) => {
|
|
|
343
343
|
return { ...compressedTemplatesData, response: decompressData};
|
|
344
344
|
};
|
|
345
345
|
|
|
346
|
-
|
|
346
|
+
// When `priority` is supplied (e.g. CapNotify passes 'HIGH'), fetch priority-scoped domains instead.
|
|
347
|
+
export const getDomainProperties = (channels, orgUnitId, priority) => {
|
|
347
348
|
const queryString = channels?.map((channel) => `channel=${channel?.toUpperCase()}`)?.join('&');
|
|
348
|
-
const
|
|
349
|
+
const path = priority
|
|
350
|
+
? `domainPropertiesByPriority?${queryString}&priority=${priority}`
|
|
351
|
+
: `domainProperties?${queryString}`;
|
|
352
|
+
const url = `${CAMPAIGNS_API_ORG_ENDPOINT}/meta/${path}`;
|
|
349
353
|
return request(url, getAPICallObject('GET', null, false, true, orgUnitId));
|
|
350
354
|
};
|
|
351
355
|
|
|
@@ -64,6 +64,30 @@ describe('getDomainProperties -- Test with valid responses', () => {
|
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
+
describe('getDomainProperties -- endpoint selection', () => {
|
|
68
|
+
const originalFetch = global.fetch;
|
|
69
|
+
beforeEach(() => {
|
|
70
|
+
global.fetch = jest.fn(() => Promise.resolve({ status: 200, json: () => Promise.resolve({}) }));
|
|
71
|
+
});
|
|
72
|
+
afterEach(() => {
|
|
73
|
+
global.fetch = originalFetch;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('calls domainProperties when no priority is given', () => {
|
|
77
|
+
getDomainProperties(['sms', 'EMAIL'], null);
|
|
78
|
+
const [url] = global.fetch.mock.calls[0];
|
|
79
|
+
expect(url).toContain('/meta/domainProperties?channel=SMS&channel=EMAIL&time=');
|
|
80
|
+
expect(url).not.toContain('domainPropertiesByPriority');
|
|
81
|
+
expect(url).not.toContain('priority=');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('calls domainPropertiesByPriority with the priority param when priority is given', () => {
|
|
85
|
+
getDomainProperties(['EMAIL'], null, 'HIGH');
|
|
86
|
+
const [url] = global.fetch.mock.calls[0];
|
|
87
|
+
expect(url).toContain('/meta/domainPropertiesByPriority?channel=EMAIL&priority=HIGH&time=');
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
67
91
|
describe('getCdnTransformationConfigs -- Test with valid responses', () => {
|
|
68
92
|
it('Should return correct response', () =>
|
|
69
93
|
expect(getCdnTransformationConfig()).toEqual(Promise.resolve()));
|
|
@@ -491,6 +491,7 @@ const ChannelSelectionStep = ({
|
|
|
491
491
|
onDeliverySettingChange={(deliverySetting) => onChange({ deliverySetting })}
|
|
492
492
|
onDomainPropertiesLoaded={setDomainPropertiesData}
|
|
493
493
|
orgUnitId={config?.context?.ouId}
|
|
494
|
+
domainPropertiesPriority={config?.context?.domainPropertiesPriority}
|
|
494
495
|
intl={intl}
|
|
495
496
|
/>
|
|
496
497
|
)}
|
package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js
CHANGED
|
@@ -37,6 +37,7 @@ const DeliverySettingsSection = ({
|
|
|
37
37
|
onDeliverySettingChange,
|
|
38
38
|
onDomainPropertiesLoaded,
|
|
39
39
|
orgUnitId,
|
|
40
|
+
domainPropertiesPriority,
|
|
40
41
|
intl,
|
|
41
42
|
}) => {
|
|
42
43
|
const [showSlidebox, setShowSlidebox] = useState(false);
|
|
@@ -119,7 +120,7 @@ const DeliverySettingsSection = ({
|
|
|
119
120
|
// uses) so both screens fetch domains for the same org unit; fall back to the logged-in
|
|
120
121
|
// user's own cached OU only when a consumer hasn't supplied one.
|
|
121
122
|
const resolvedOrgUnitId = orgUnitId ?? (loadItem('ouId') || loadItem('orgID'));
|
|
122
|
-
const response = await getDomainProperties(deliveryFetchChannels, resolvedOrgUnitId);
|
|
123
|
+
const response = await getDomainProperties(deliveryFetchChannels, resolvedOrgUnitId, domainPropertiesPriority);
|
|
123
124
|
if (!cancelled) {
|
|
124
125
|
const raw = response?.entity || response;
|
|
125
126
|
// Normalize channel keys to uppercase (API may return Viber, viber, etc.)
|
|
@@ -365,6 +366,8 @@ DeliverySettingsSection.propTypes = {
|
|
|
365
366
|
onDeliverySettingChange: PropTypes.func,
|
|
366
367
|
onDomainPropertiesLoaded: PropTypes.func,
|
|
367
368
|
orgUnitId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
369
|
+
// Consumer opt-in (config.context.domainPropertiesPriority) — switches to domainPropertiesByPriority.
|
|
370
|
+
domainPropertiesPriority: PropTypes.string,
|
|
368
371
|
intl: PropTypes.object.isRequired,
|
|
369
372
|
};
|
|
370
373
|
|
|
@@ -374,6 +377,7 @@ DeliverySettingsSection.defaultProps = {
|
|
|
374
377
|
deliverySetting: null,
|
|
375
378
|
onDeliverySettingChange: null,
|
|
376
379
|
orgUnitId: undefined,
|
|
380
|
+
domainPropertiesPriority: undefined,
|
|
377
381
|
};
|
|
378
382
|
|
|
379
383
|
export default injectIntl(DeliverySettingsSection);
|
|
@@ -154,6 +154,7 @@ function renderSection(props = {}) {
|
|
|
154
154
|
deliverySetting = {},
|
|
155
155
|
onDeliverySettingChange,
|
|
156
156
|
orgUnitId,
|
|
157
|
+
domainPropertiesPriority,
|
|
157
158
|
} = props;
|
|
158
159
|
return render(
|
|
159
160
|
<IntlProvider locale="en" messages={{}} defaultLocale="en">
|
|
@@ -163,6 +164,7 @@ function renderSection(props = {}) {
|
|
|
163
164
|
deliverySetting={deliverySetting}
|
|
164
165
|
onDeliverySettingChange={onDeliverySettingChange}
|
|
165
166
|
orgUnitId={orgUnitId}
|
|
167
|
+
domainPropertiesPriority={domainPropertiesPriority}
|
|
166
168
|
/>
|
|
167
169
|
</IntlProvider>,
|
|
168
170
|
);
|
|
@@ -298,7 +300,7 @@ describe('DeliverySettingsSection — marketer flows', () => {
|
|
|
298
300
|
|
|
299
301
|
renderSection({ contentItems: [{ channel: 'SMS' }] });
|
|
300
302
|
|
|
301
|
-
await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['SMS'], 'fallback-org'));
|
|
303
|
+
await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['SMS'], 'fallback-org', undefined));
|
|
302
304
|
});
|
|
303
305
|
|
|
304
306
|
it('prefers the consumer-supplied orgUnitId (config.context.ouId) over local storage — same source Preview-and-test uses, so both fetch the same org unit', async () => {
|
|
@@ -307,7 +309,24 @@ describe('DeliverySettingsSection — marketer flows', () => {
|
|
|
307
309
|
|
|
308
310
|
renderSection({ contentItems: [{ channel: 'SMS' }], orgUnitId: 'consumer-ou' });
|
|
309
311
|
|
|
310
|
-
await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['SMS'], 'consumer-ou'));
|
|
312
|
+
await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['SMS'], 'consumer-ou', undefined));
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('forwards the consumer-supplied domainPropertiesPriority (e.g. CapNotify HIGH) to the domain-properties fetch', async () => {
|
|
316
|
+
getDomainProperties.mockResolvedValue({ entity: apiEntity.SMS });
|
|
317
|
+
|
|
318
|
+
renderSection({ contentItems: [{ channel: 'SMS' }], orgUnitId: 'consumer-ou', domainPropertiesPriority: 'HIGH' });
|
|
319
|
+
|
|
320
|
+
await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['SMS'], 'consumer-ou', 'HIGH'));
|
|
321
|
+
expect(await screen.findByText('+1002003001')).toBeInTheDocument();
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('does not pass a priority when the consumer has not opted in', async () => {
|
|
325
|
+
getDomainProperties.mockResolvedValue({ entity: apiEntity.SMS });
|
|
326
|
+
|
|
327
|
+
renderSection({ contentItems: [{ channel: 'SMS' }], orgUnitId: 'consumer-ou' });
|
|
328
|
+
|
|
329
|
+
await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['SMS'], 'consumer-ou', undefined));
|
|
311
330
|
});
|
|
312
331
|
|
|
313
332
|
it('accepts the whole response as the entity when `entity` is omitted (some clients)', async () => {
|
|
@@ -611,7 +630,7 @@ describe('DeliverySettingsSection — marketer flows', () => {
|
|
|
611
630
|
|
|
612
631
|
renderSection({ contentItems: [rcsWithFallbackContentItem] });
|
|
613
632
|
|
|
614
|
-
await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['RCS', 'SMS'], 'test-ou'));
|
|
633
|
+
await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['RCS', 'SMS'], 'test-ou', undefined));
|
|
615
634
|
});
|
|
616
635
|
|
|
617
636
|
it('does not fetch SMS domains when the RCS content has no SMS-fallback content', async () => {
|
|
@@ -619,7 +638,7 @@ describe('DeliverySettingsSection — marketer flows', () => {
|
|
|
619
638
|
|
|
620
639
|
renderSection({ contentItems: [{ channel: 'RCS' }] });
|
|
621
640
|
|
|
622
|
-
await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['RCS'], 'test-ou'));
|
|
641
|
+
await waitFor(() => expect(getDomainProperties).toHaveBeenCalledWith(['RCS'], 'test-ou', undefined));
|
|
623
642
|
});
|
|
624
643
|
|
|
625
644
|
it('shows a "Fallback SMS sender ID" summary row sourced from the SMS domain default sender', async () => {
|