@capillarytech/creatives-library 9.1.8-alpha.sprint-cap-214249.38 → 9.2.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/constants/unified.js +4 -0
- package/index.js +13 -0
- package/package.json +1 -1
- package/services/getSchema.js +4 -1
- package/services/tests/getSchema.test.js +2 -2
- package/translations/en.json +1 -0
- package/translations/ja-JP.json +1 -0
- package/translations/zh.json +1 -0
- package/utils/common.js +6 -0
- package/utils/createMobilePushPayload.js +33 -47
- package/utils/tagValidations.js +35 -4
- package/utils/templateVarUtils.js +49 -0
- package/utils/tests/createMobilePushPayload.test.js +8 -102
- package/utils/tests/tagValidations.test.js +48 -0
- package/utils/tests/templateVarUtils.test.js +89 -0
- package/v2Components/CapMpushCTA/index.js +9 -10
- package/v2Components/CapMpushCTA/index.scss +3 -29
- package/v2Components/CapTagList/TagFallbackPanel.js +124 -0
- package/v2Components/CapTagList/constants.js +5 -0
- package/v2Components/CapTagList/index.js +46 -7
- package/v2Components/CapTagList/messages.js +44 -0
- package/v2Components/CapTagList/style.scss +113 -1
- package/v2Components/CapTagList/tests/TagFallback.test.js +222 -0
- package/v2Components/CapTagList/utils.js +17 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +13 -26
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
- package/v2Components/CommonTestAndPreview/constants.js +3 -2
- package/v2Components/CommonTestAndPreview/index.js +62 -62
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -79
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
- package/v2Components/CommonTestAndPreview/tests/utils.test.js +102 -0
- package/v2Components/CommonTestAndPreview/utils.js +42 -3
- package/v2Components/FormBuilder/Classic.js +24 -14
- package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +57 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
- package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +5 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +6 -0
- package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
- package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
- package/v2Components/FormBuilder/Functional/tests/manual.typingPerf.test.js +135 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.crossFlowParity.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpush.ctaFlows.parity.test.js +320 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.editContainer.parity.test.js +148 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.libraryValidity.parity.test.js +152 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.shellEvents.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpush.singlePlatform.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +22 -0
- package/v2Components/FormBuilder/tests/mpush.characterization.test.js +2 -2
- package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
- package/v2Components/TemplatePreview/index.js +17 -30
- package/v2Components/TemplatePreview/tests/index.test.js +0 -61
- package/v2Containers/Cap/index.js +3 -0
- package/v2Containers/Cap/messages.js +4 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +151 -70
- package/v2Containers/CreativesContainer/index.js +6 -3
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -29
- package/v2Containers/InApp/index.js +4 -1
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/Text/index.js +3 -1
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +16 -0
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
- package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +70 -0
- package/v2Containers/MobilePush/Create/actions.js +52 -0
- package/v2Containers/MobilePush/Create/constants.js +26 -0
- package/v2Containers/MobilePush/Create/index.js +2149 -0
- package/v2Containers/MobilePush/Create/messages.js +349 -0
- package/v2Containers/MobilePush/Create/reducer.js +72 -0
- package/v2Containers/MobilePush/Create/sagas.js +79 -0
- package/v2Containers/MobilePush/Create/selectors.js +29 -0
- package/v2Containers/MobilePush/Create/test/contentValidity.test.js +154 -0
- package/v2Containers/MobilePush/Create/test/saga.test.js +19 -0
- package/v2Containers/MobilePush/Create/test/stayOpenOnSave.test.js +80 -0
- package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +65 -0
- package/v2Containers/MobilePush/Edit/actions.js +94 -0
- package/v2Containers/MobilePush/Edit/constants.js +37 -0
- package/v2Containers/MobilePush/Edit/index.js +2407 -0
- package/v2Containers/MobilePush/Edit/messages.js +341 -0
- package/v2Containers/MobilePush/Edit/reducer.js +113 -0
- package/v2Containers/MobilePush/Edit/sagas.js +113 -0
- package/v2Containers/MobilePush/Edit/selectors.js +33 -0
- package/v2Containers/MobilePush/Edit/test/contentValidity.test.js +149 -0
- package/v2Containers/MobilePush/Edit/test/saga.test.js +255 -0
- package/v2Containers/MobilePush/Edit/test/stayOpenOnSave.test.js +60 -0
- package/v2Containers/MobilePush/commonMethods.js +333 -0
- package/v2Containers/MobilePush/eventsMap.js +130 -0
- package/v2Containers/MobilePush/tests/commonMethods.test.js +401 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +192 -207
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +121 -116
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +72 -316
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +16 -45
- package/v2Containers/MobilePushNew/constants.js +0 -5
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -52
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -38
- package/v2Containers/MobilePushNew/hooks/useUpload.js +39 -29
- package/v2Containers/MobilePushNew/index.js +192 -454
- package/v2Containers/MobilePushNew/index.scss +4 -188
- package/v2Containers/MobilePushNew/messages.js +6 -86
- package/v2Containers/MobilePushNew/tests/index.test.js +1 -450
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -25
- package/v2Containers/MobilePushNew/utils.js +0 -8
- package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +22 -0
- package/v2Containers/MobilepushWrapper/index.js +178 -0
- package/v2Containers/MobilepushWrapper/messages.js +29 -0
- package/v2Containers/Rcs/index.js +8 -1
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +59 -0
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/SmsTrai/Edit/index.js +17 -7
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +42 -0
- package/v2Containers/Templates/_templates.scss +2 -10
- package/v2Containers/Templates/index.js +90 -84
- package/v2Containers/Templates/tests/index.test.js +0 -68
- package/v2Containers/Viber/index.js +3 -1
- package/v2Containers/WebPush/Create/utils/validation.js +6 -0
- package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
- package/v2Containers/Whatsapp/index.js +9 -5
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Zalo/index.js +4 -1
- package/v2Components/CapMpushCTA/tests/index.test.js +0 -89
- /package/{v2Components/FormBuilder/Functional/tests/fixtures/mpushInitialSchema.js → v2Containers/MobilePush/initialSchema.js} +0 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Library/embedded-mode validity parity — the campaigns-host Done/Preview gates.
|
|
3
|
+
* Pins that the container's isFormValid tracks typing (Classic re-validates each change
|
|
4
|
+
* via the container round-trip, Classic.js:516-537; the Done click early-returns on
|
|
5
|
+
* !isFormValid) and the onContentValidityChange({isContentEmpty}) footer signal.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import '@testing-library/jest-dom';
|
|
9
|
+
import _ from 'lodash';
|
|
10
|
+
import { Router } from 'react-router-dom';
|
|
11
|
+
import { render, act, fireEvent } from '../../../../utils/test-utils';
|
|
12
|
+
import history from '../../../../utils/history';
|
|
13
|
+
import { response as mpushSchemaResponse } from '../../../../v2Containers/MobilePush/initialSchema';
|
|
14
|
+
import { Create } from '../../../../v2Containers/MobilePush/Create';
|
|
15
|
+
|
|
16
|
+
jest.mock('redux-auth-wrapper/history4/redirect', () => ({
|
|
17
|
+
connectedRouterRedirect: jest.fn(() => (Component) => Component),
|
|
18
|
+
}));
|
|
19
|
+
jest.mock('../../../../services/api', () => ({
|
|
20
|
+
...jest.requireActual('../../../../services/api'),
|
|
21
|
+
getUnsubscribeUrl: () => Promise.resolve({ response: { response: '' } }),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
// The gate is purely org-flag controlled — drive the flow via the flag reader.
|
|
25
|
+
let mockMpushFlag = false;
|
|
26
|
+
jest.mock('../../../../utils/common', () => ({
|
|
27
|
+
...jest.requireActual('../../../../utils/common'),
|
|
28
|
+
hasNewFormBuilderEnabledForMpush: () => mockMpushFlag,
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
const fullDefinition = () => _.cloneDeep(mpushSchemaResponse.metaEntities[0].definition);
|
|
32
|
+
|
|
33
|
+
const intl = {
|
|
34
|
+
formatMessage: (d) => (d && (d.defaultMessage || d.id)) || '',
|
|
35
|
+
locale: 'en',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const selectedAccount = {
|
|
39
|
+
id: 'acc-1',
|
|
40
|
+
name: 'Acc',
|
|
41
|
+
sourceTypeName: 'SOME_SDK',
|
|
42
|
+
sourceAccountIdentifier: 'lic-1',
|
|
43
|
+
configs: { android: '1', ios: '1', deeplink: '[]' },
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const buildProps = () => ({
|
|
47
|
+
intl,
|
|
48
|
+
params: { mode: 'text' },
|
|
49
|
+
route: { name: 'create' },
|
|
50
|
+
location: { pathname: '/mobilepush/create/text', query: { module: 'default', type: 'embedded' } },
|
|
51
|
+
router: { push: jest.fn() },
|
|
52
|
+
isFullMode: false,
|
|
53
|
+
isGetFormData: false,
|
|
54
|
+
isLoadingMetaEntities: false,
|
|
55
|
+
metaEntities: {},
|
|
56
|
+
Create: { createTemplateInProgress: false },
|
|
57
|
+
Edit: {},
|
|
58
|
+
Templates: { selectedWeChatAccount: selectedAccount },
|
|
59
|
+
actions: new Proxy({}, { get: (t, n) => { if (!t[n]) t[n] = jest.fn(); return t[n]; } }), // eslint-disable-line no-param-reassign
|
|
60
|
+
globalActions: {
|
|
61
|
+
fetchSchemaForEntity: jest.fn(),
|
|
62
|
+
addMessageToQueue: jest.fn(),
|
|
63
|
+
setInjectedTags: jest.fn(),
|
|
64
|
+
},
|
|
65
|
+
getFormLibraryData: jest.fn(),
|
|
66
|
+
onValidationFail: jest.fn(),
|
|
67
|
+
showLiquidErrorInFooter: jest.fn(),
|
|
68
|
+
onPersonalizationTokensChange: jest.fn(),
|
|
69
|
+
onContentValidityChange: jest.fn(),
|
|
70
|
+
getLiquidTags: jest.fn(),
|
|
71
|
+
injectedTags: {},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const setNativeValue = (el, value) => {
|
|
75
|
+
const proto = Object.getPrototypeOf(el);
|
|
76
|
+
Object.getOwnPropertyDescriptor(proto, 'value').set.call(el, value);
|
|
77
|
+
};
|
|
78
|
+
const typeInto = (id, value) => {
|
|
79
|
+
const el = document.getElementById(id);
|
|
80
|
+
if (!el) throw new Error(`no #${id} in DOM`);
|
|
81
|
+
setNativeValue(el, value);
|
|
82
|
+
fireEvent.change(el, { target: { value } });
|
|
83
|
+
fireEvent.blur(el);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
describe.each([
|
|
87
|
+
['Classic', 'false'],
|
|
88
|
+
['Functional', 'true'],
|
|
89
|
+
])('library-mode validity parity — %s', (flow, flagValue) => {
|
|
90
|
+
beforeEach(() => {
|
|
91
|
+
mockMpushFlag = flagValue === 'true';
|
|
92
|
+
jest.useFakeTimers();
|
|
93
|
+
});
|
|
94
|
+
afterEach(() => {
|
|
95
|
+
jest.useRealTimers();
|
|
96
|
+
mockMpushFlag = false;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('isFormValid flips true after typing valid content (Done gate) and content-emptiness reports live', () => {
|
|
100
|
+
let containerRef = null;
|
|
101
|
+
const props = buildProps();
|
|
102
|
+
const ui = (p) => (
|
|
103
|
+
<Router history={history}>
|
|
104
|
+
<Create ref={(r) => { if (r) containerRef = r; }} {...p} />
|
|
105
|
+
</Router>
|
|
106
|
+
);
|
|
107
|
+
const utils = render(ui(props));
|
|
108
|
+
const meta = { layouts: [{ definition: fullDefinition() }], tags: { standard: [] } };
|
|
109
|
+
act(() => { utils.rerender(ui({ ...props, metaEntities: meta })); });
|
|
110
|
+
act(() => { jest.runOnlyPendingTimers(); });
|
|
111
|
+
|
|
112
|
+
// mount: empty form — invalid, content empty
|
|
113
|
+
expect(containerRef.state.isFormValid).toBe(false);
|
|
114
|
+
expect(props.onContentValidityChange).toHaveBeenCalledWith({ isContentEmpty: true });
|
|
115
|
+
|
|
116
|
+
act(() => { typeInto('message-title', 'Hello title'); });
|
|
117
|
+
act(() => { typeInto('message-editor', 'Hello body'); });
|
|
118
|
+
act(() => { jest.advanceTimersByTime(1000); }); // flush debounced emissions
|
|
119
|
+
|
|
120
|
+
// the Done gate must see the typed content: valid + non-empty
|
|
121
|
+
expect(containerRef.state.isFormValid).toBe(true);
|
|
122
|
+
const contentCalls = props.onContentValidityChange.mock.calls.map((c) => c[0]);
|
|
123
|
+
expect(contentCalls[contentCalls.length - 1]).toEqual({ isContentEmpty: false });
|
|
124
|
+
|
|
125
|
+
// user repro: image write-back through the REAL prop path (Create's CWRP copies
|
|
126
|
+
// uploadedAssetData.metaInfo.public_url into the current tab, Create/index.js:167-172)
|
|
127
|
+
// then CTA check/uncheck — the create flow must not adopt the hardcoded tabCount={2}
|
|
128
|
+
// or the check scans the empty iOS tab.
|
|
129
|
+
act(() => {
|
|
130
|
+
utils.rerender(ui({
|
|
131
|
+
...props,
|
|
132
|
+
metaEntities: meta,
|
|
133
|
+
Create: { createTemplateInProgress: false, uploadedAssetData: { metaInfo: { public_url: 'blob:uploaded' } } },
|
|
134
|
+
}));
|
|
135
|
+
});
|
|
136
|
+
act(() => { jest.advanceTimersByTime(1000); });
|
|
137
|
+
expect(containerRef.state.formData[0].image).toBe('blob:uploaded'); // write-back landed
|
|
138
|
+
const pane = document.querySelectorAll('.ant-tabs-tabpane')[0] || document;
|
|
139
|
+
const label = Array.from(pane.querySelectorAll('label')).find((l) => /action link/i.test(l.textContent || ''));
|
|
140
|
+
const cta = (label && label.querySelector('input[type="checkbox"]')) || pane.querySelector('input[type="checkbox"]');
|
|
141
|
+
act(() => { fireEvent.click(cta); });
|
|
142
|
+
act(() => { jest.advanceTimersByTime(1000); });
|
|
143
|
+
act(() => { fireEvent.click(cta); });
|
|
144
|
+
act(() => { jest.advanceTimersByTime(1000); });
|
|
145
|
+
|
|
146
|
+
expect(containerRef.state.tabCount).toBe(1); // create flow never adopts the prop
|
|
147
|
+
const finalCalls = props.onContentValidityChange.mock.calls.map((c) => c[0]);
|
|
148
|
+
expect(finalCalls[finalCalls.length - 1]).toEqual({ isContentEmpty: false }); // buttons stay enabled
|
|
149
|
+
|
|
150
|
+
utils.unmount();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -9,7 +9,7 @@ import _ from 'lodash';
|
|
|
9
9
|
import { Router } from 'react-router-dom';
|
|
10
10
|
import { render, act, fireEvent } from '../../../../utils/test-utils';
|
|
11
11
|
import history from '../../../../utils/history';
|
|
12
|
-
import { response as mpushSchemaResponse } from '
|
|
12
|
+
import { response as mpushSchemaResponse } from '../../../../v2Containers/MobilePush/initialSchema';
|
|
13
13
|
import FunctionalFormBuilder from '../index';
|
|
14
14
|
|
|
15
15
|
jest.mock('redux-auth-wrapper/history4/redirect', () => ({
|
|
@@ -13,7 +13,7 @@ import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
|
|
|
13
13
|
import history from '../../../../utils/history';
|
|
14
14
|
import { initialReducer } from '../../../../initialReducer';
|
|
15
15
|
import { render, fireEvent, waitFor } from '../../../../utils/test-utils';
|
|
16
|
-
import { response as mpushSchemaResponse } from '
|
|
16
|
+
import { response as mpushSchemaResponse } from '../../../../v2Containers/MobilePush/initialSchema';
|
|
17
17
|
import FunctionalFormBuilder from '../index';
|
|
18
18
|
|
|
19
19
|
jest.mock('redux-auth-wrapper/history4/redirect', () => ({
|
|
@@ -43,6 +43,28 @@ describe('MpushInputField', () => {
|
|
|
43
43
|
}))[0].props.errorMessage).toBe('');
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
+
it('unquoted default error shows its own message; personalization still wins over it', () => {
|
|
47
|
+
const base = { field, onChange: () => {}, renderContext: { checkValidation: true, intl } };
|
|
48
|
+
expect(kids(MpushInputField({ ...base, value: '{{a | default: x}}', error: ERROR_VALUE.DEFAULT_QUOTE }))[0].props.errorMessage)
|
|
49
|
+
.toBe('Invalid label, default value must be within quotes');
|
|
50
|
+
expect(kids(MpushInputField({
|
|
51
|
+
...base, value: '{{a | default: x}}', error: ERROR_VALUE.DEFAULT_QUOTE, renderContext: { checkValidation: false, intl },
|
|
52
|
+
}))[0].props.errorMessage).toBe('Invalid label, default value must be within quotes');
|
|
53
|
+
expect(kids(MpushInputField({
|
|
54
|
+
...base,
|
|
55
|
+
value: 'hi {{first_name | default: x}}',
|
|
56
|
+
error: ERROR_VALUE.DEFAULT_QUOTE,
|
|
57
|
+
renderContext: { checkValidation: true, intl, restrictPersonalization: true },
|
|
58
|
+
}))[0].props.errorMessage).toContain('Personalization');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('falls back to empty message when error is not brace/quote and field has no errorMessage', () => {
|
|
62
|
+
const el = MpushInputField({
|
|
63
|
+
field: { id: 'x', width: 18 }, value: 'abc', error: 'someOtherError', onChange: () => {}, renderContext: { checkValidation: true, intl },
|
|
64
|
+
});
|
|
65
|
+
expect(kids(el)[0].props.errorMessage).toBe('');
|
|
66
|
+
});
|
|
67
|
+
|
|
46
68
|
it('shows brace/tag errors live, before checkValidation (Save/Update/Done) is set', () => {
|
|
47
69
|
const el = MpushInputField({
|
|
48
70
|
field, value: 'a {{b', error: ERROR_VALUE.BRACKET, onChange: () => {}, renderContext: { checkValidation: false, intl },
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These tests pin the CURRENT behavior of the FormBuilder monolith
|
|
5
5
|
* (app/v2Components/FormBuilder/Classic.js) for the MOBILEPUSH channel, using
|
|
6
|
-
* the real bundled layout schemas (
|
|
6
|
+
* the real bundled layout schemas (app/v2Containers/MobilePush/initialSchema.js,
|
|
7
7
|
* textSchema + imageSchema). They are the parity gate for the functional
|
|
8
8
|
* rewrite: the new implementation must keep every assertion here green.
|
|
9
9
|
*
|
|
@@ -28,7 +28,7 @@ import { initialReducer } from '../../../initialReducer';
|
|
|
28
28
|
import {
|
|
29
29
|
render, screen, fireEvent, waitFor, act,
|
|
30
30
|
} from '../../../utils/test-utils';
|
|
31
|
-
import { response as mpushSchemaResponse } from '
|
|
31
|
+
import { response as mpushSchemaResponse } from '../../../v2Containers/MobilePush/initialSchema';
|
|
32
32
|
|
|
33
33
|
// Same harness facts as the SMS suite: neutralize the auth-guarded TagList wrapper…
|
|
34
34
|
jest.mock('redux-auth-wrapper/history4/redirect', () => ({
|
|
@@ -745,23 +745,13 @@
|
|
|
745
745
|
justify-content: space-between;
|
|
746
746
|
flex-direction: row;
|
|
747
747
|
gap: $CAP_SPACE_08;
|
|
748
|
-
width: 100%;
|
|
749
|
-
// One button: centred. Two: equal halves, each centred, split by a divider.
|
|
750
748
|
.action{
|
|
751
|
-
flex: 1 1 0;
|
|
752
|
-
min-width: 0;
|
|
753
|
-
text-align: center;
|
|
754
|
-
white-space: nowrap;
|
|
755
|
-
overflow: hidden;
|
|
756
|
-
text-overflow: ellipsis;
|
|
757
749
|
font-size: $FONT_SIZE_S;
|
|
758
750
|
font-weight: 600;
|
|
759
|
-
color:
|
|
751
|
+
color: #1970DA;
|
|
760
752
|
height: 1.25rem;
|
|
753
|
+
text-transform: uppercase;
|
|
761
754
|
cursor: pointer;
|
|
762
|
-
& + .action {
|
|
763
|
-
border-left: 1px solid $CAP_G07;
|
|
764
|
-
}
|
|
765
755
|
&:hover {
|
|
766
756
|
text-decoration: underline;
|
|
767
757
|
}
|
|
@@ -168,20 +168,14 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
168
168
|
};
|
|
169
169
|
|
|
170
170
|
renderMobilePushCarousel = (content) => {
|
|
171
|
-
|
|
172
|
-
const cardsWithMedia = (content?.carouselData || []).filter((item) => {
|
|
173
|
-
const mediaType = item?.mediaType?.toLowerCase();
|
|
174
|
-
return (mediaType === IMAGE && (item?.imageUrl || item?.url))
|
|
175
|
-
|| (mediaType === VIDEO && (item?.videoPreviewImg || item?.videoSrc));
|
|
176
|
-
});
|
|
177
|
-
if (cardsWithMedia.length === 0) {
|
|
171
|
+
if (!content?.carouselData || content?.carouselData?.length === 0) {
|
|
178
172
|
return null;
|
|
179
173
|
}
|
|
180
174
|
|
|
181
175
|
return (
|
|
182
176
|
<CapRow type="flex" vertical noWrap className="msg-container-carousel mobile-push-carousel-container">
|
|
183
|
-
<CapRow
|
|
184
|
-
{
|
|
177
|
+
<CapRow className="scroll-container mobile-push-scroll-container">
|
|
178
|
+
{content?.carouselData?.map((item, idx) => (
|
|
185
179
|
<CapColumn
|
|
186
180
|
key={`carousel-card-${idx}`}
|
|
187
181
|
className="mobile-push-carousel-card message-pop align-left message-pop-carousel"
|
|
@@ -193,20 +187,13 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
193
187
|
className="carousel-image"
|
|
194
188
|
/>
|
|
195
189
|
)}
|
|
196
|
-
{item?.mediaType?.toLowerCase() === VIDEO &&
|
|
190
|
+
{item?.mediaType?.toLowerCase() === VIDEO && item?.videoPreviewImg && (
|
|
197
191
|
<CapRow className="video-preview">
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
/>
|
|
204
|
-
) : (
|
|
205
|
-
// No thumbnail from the upload: show the video's first frame
|
|
206
|
-
<video src={item?.videoSrc} className="carousel-video-preview" muted preload="metadata">
|
|
207
|
-
<track kind="captions" />
|
|
208
|
-
</video>
|
|
209
|
-
)}
|
|
192
|
+
<CapImage
|
|
193
|
+
src={item?.videoPreviewImg || item?.url}
|
|
194
|
+
alt="carousel-video-preview"
|
|
195
|
+
className="carousel-video-preview"
|
|
196
|
+
/>
|
|
210
197
|
<CapRow className="icon-position">
|
|
211
198
|
<CapImage className="video-icon" src={videoPlay} />
|
|
212
199
|
</CapRow>
|
|
@@ -920,17 +907,17 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
920
907
|
)}
|
|
921
908
|
{(content?.actions || []).filter((action) => action?.label)
|
|
922
909
|
.length && content?.carouselData?.length === 0 ? (
|
|
923
|
-
<CapRow
|
|
910
|
+
<CapRow className="actions">
|
|
924
911
|
{_.map(
|
|
925
912
|
content?.actions || [],
|
|
926
|
-
(action
|
|
913
|
+
(action) =>
|
|
927
914
|
!!action?.label && (
|
|
928
915
|
<span
|
|
929
916
|
className="action"
|
|
930
|
-
key={`action-${
|
|
917
|
+
key={`action-${action?.label}`}
|
|
931
918
|
title={action?.url || ''}
|
|
932
919
|
>
|
|
933
|
-
{action?.label}
|
|
920
|
+
{action?.label?.toUpperCase()}
|
|
934
921
|
</span>
|
|
935
922
|
)
|
|
936
923
|
)}
|
|
@@ -984,17 +971,17 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
984
971
|
)}
|
|
985
972
|
{(content?.actions || []).filter((action) => action?.label)
|
|
986
973
|
.length && content?.carouselData?.length === 0 ? (
|
|
987
|
-
<CapRow
|
|
974
|
+
<CapRow className="actions">
|
|
988
975
|
{_.map(
|
|
989
976
|
content?.actions || [],
|
|
990
|
-
(action
|
|
977
|
+
(action) =>
|
|
991
978
|
!!action?.label && (
|
|
992
979
|
<span
|
|
993
980
|
className="action"
|
|
994
|
-
key={`action-${
|
|
981
|
+
key={`action-${action?.label}`}
|
|
995
982
|
title={action?.url || ''}
|
|
996
983
|
>
|
|
997
|
-
{action?.label}
|
|
984
|
+
{action?.label?.toUpperCase()}
|
|
998
985
|
</span>
|
|
999
986
|
)
|
|
1000
987
|
)}
|
|
@@ -73,67 +73,6 @@ describe('Test Templates container', () => {
|
|
|
73
73
|
expect(renderedComponent).toMatchSnapshot();
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
describe('Mobile push action buttons', () => {
|
|
77
|
-
const renderMobilePush = (device, actions) => {
|
|
78
|
-
renderedComponent = shallowWithIntl(
|
|
79
|
-
<TemplatePreview
|
|
80
|
-
channel="MOBILEPUSH"
|
|
81
|
-
device={device}
|
|
82
|
-
content={{ header: 'Title', bodyText: 'Body', actions, carouselData: [] }}
|
|
83
|
-
/>,
|
|
84
|
-
);
|
|
85
|
-
return renderedComponent.find('.actions');
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
it.each(['android', 'ios'])('renders labels as typed on one flex row with index keys (%s)', (device) => {
|
|
89
|
-
const row = renderMobilePush(device, [
|
|
90
|
-
{ label: 'Shop', url: 'https://a.com' },
|
|
91
|
-
{ label: 'Shop' },
|
|
92
|
-
{ label: '' },
|
|
93
|
-
]);
|
|
94
|
-
const buttons = row.find('.action');
|
|
95
|
-
|
|
96
|
-
expect(row.props()).toEqual(expect.objectContaining({ type: 'flex', noWrap: true }));
|
|
97
|
-
expect(buttons).toHaveLength(2);
|
|
98
|
-
expect(buttons.map((button) => button.key())).toEqual(['action-0', 'action-1']);
|
|
99
|
-
expect(buttons.map((button) => button.text())).toEqual(['Shop', 'Shop']);
|
|
100
|
-
expect(buttons.at(0).prop('title')).toBe('https://a.com');
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const renderCarousel = (device, carouselData) => {
|
|
104
|
-
renderedComponent = shallowWithIntl(
|
|
105
|
-
<TemplatePreview
|
|
106
|
-
channel="MOBILEPUSH"
|
|
107
|
-
device={device}
|
|
108
|
-
content={{ header: 'Title', carouselData }}
|
|
109
|
-
/>,
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
it.each(['android', 'ios'])('shows only cards with media, in one horizontal row (%s)', (device) => {
|
|
114
|
-
renderCarousel(device, [
|
|
115
|
-
{ mediaType: 'IMAGE', imageUrl: 'https://a.url' },
|
|
116
|
-
{ mediaType: 'IMAGE' },
|
|
117
|
-
{ mediaType: 'VIDEO', videoPreviewImg: 'https://b.url' },
|
|
118
|
-
]);
|
|
119
|
-
const scrollRow = renderedComponent.find('.scroll-container');
|
|
120
|
-
|
|
121
|
-
expect(scrollRow.props()).toEqual(expect.objectContaining({ type: 'flex', noWrap: true }));
|
|
122
|
-
expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(2);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it.each(['android', 'ios'])('shows a video card with no thumbnail as the video itself (%s)', (device) => {
|
|
126
|
-
renderCarousel(device, [{ mediaType: 'video', videoSrc: 'https://v.mp4' }]);
|
|
127
|
-
expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(1);
|
|
128
|
-
expect(renderedComponent.find('video.carousel-video-preview').prop('src')).toBe('https://v.mp4');
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it.each(['android', 'ios'])('shows no carousel when no card has media (%s)', (device) => {
|
|
132
|
-
renderCarousel(device, [{ mediaType: 'IMAGE' }]);
|
|
133
|
-
expect(renderedComponent.find('.mobile-push-carousel-container')).toHaveLength(0);
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
76
|
describe('RCS carousel preview branches', () => {
|
|
138
77
|
const buildRcsContent = (cards) => ({
|
|
139
78
|
rcsPreviewContent: {
|
|
@@ -46,6 +46,7 @@ import { v2SmsCreateSagas } from '../Sms/Create/sagas';
|
|
|
46
46
|
import { v2EbillSagas } from '../Ebill/sagas';
|
|
47
47
|
import { v2EmailDuplicateTemplateSaga } from '../Email/sagas';
|
|
48
48
|
import { v2LineContainerSagas } from '../Line/Container/sagas'
|
|
49
|
+
import { v2MobilePushCreateSagas } from '../MobilePush/Create/sagas';
|
|
49
50
|
import { v2WechatMapTemplatesSagas } from '../WeChat/MapTemplates/sagas';
|
|
50
51
|
import { v2RcsSagas } from '../Rcs/sagas';
|
|
51
52
|
import { v2InAppSagas } from '../InApp/sagas';
|
|
@@ -642,6 +643,7 @@ const withSmsCreateSaga = injectSaga({ key: 'create', saga: v2SmsCreateSagas });
|
|
|
642
643
|
const withEbillSaga = injectSaga({ key: 'ebill', saga: v2EbillSagas });
|
|
643
644
|
const withEmailSaga = injectSaga({ key: 'email', saga: v2EmailDuplicateTemplateSaga });
|
|
644
645
|
const withLineContainerSaga = injectSaga({ key: 'lineCreate', saga: v2LineContainerSagas });
|
|
646
|
+
const withMobilePushCreateSaga = injectSaga({ key: 'mobileCreate', saga: v2MobilePushCreateSagas });
|
|
645
647
|
const withWechatMapTemplatesSaga = injectSaga({ key: 'weChatMapTemplate', saga: v2WechatMapTemplatesSagas });
|
|
646
648
|
const withRcsSaga = injectSaga({ key: 'rcs', saga: v2RcsSagas });
|
|
647
649
|
const withInAppSaga = injectSaga({ key: 'inapp', saga: v2InAppSagas, mode: DAEMON });
|
|
@@ -656,6 +658,7 @@ export default compose(
|
|
|
656
658
|
withEmailSaga,
|
|
657
659
|
withLiquidSaga,
|
|
658
660
|
withLineContainerSaga,
|
|
661
|
+
withMobilePushCreateSaga,
|
|
659
662
|
withWechatMapTemplatesSaga,
|
|
660
663
|
withRcsSaga,
|
|
661
664
|
withInAppSaga,
|
|
@@ -201,6 +201,10 @@ export default defineMessages({
|
|
|
201
201
|
id: `creatives.componentsV2.unbalanacedCurlyBraces`,
|
|
202
202
|
defaultMessage: 'Invalid label, please close all curly braces'
|
|
203
203
|
},
|
|
204
|
+
"unquotedTagDefaultValue": {
|
|
205
|
+
id: `creatives.componentsV2.unquotedTagDefaultValue`,
|
|
206
|
+
defaultMessage: 'Invalid label, default value must be within quotes'
|
|
207
|
+
},
|
|
204
208
|
"copyOf": {
|
|
205
209
|
id: 'creatives.componentsV2.copyOf',
|
|
206
210
|
defaultMessage: 'Copy of',
|
|
@@ -395,6 +395,7 @@ exports[`<Cap /> should render correct component 1`] = `
|
|
|
395
395
|
"creatives.componentsV2.TopBar.profile": "Profile",
|
|
396
396
|
"creatives.componentsV2.TopBar.settings": "Settings",
|
|
397
397
|
"creatives.componentsV2.unbalanacedCurlyBraces": "Invalid label, please close all curly braces",
|
|
398
|
+
"creatives.componentsV2.unquotedTagDefaultValue": "Invalid label, default value must be within quotes",
|
|
398
399
|
"creatives.componentsv2.MobilePushPreviewV2.header": "This is the MobilePushPreviewV2 component !",
|
|
399
400
|
"creatives.containers.Assets.Gallery.alphabetically": "Alphabetically",
|
|
400
401
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|