web-push-notifications 3.40.1 → 3.44.1
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/.editorconfig +11 -0
- package/.gitlab-ci.yml +190 -0
- package/babel.config.js +7 -0
- package/ci/cdn/Dockerfile +12 -0
- package/ci/dev/Dockerfile +30 -0
- package/ci/dev/rootfs/entrypoint.sh +18 -0
- package/ci/dev/rootfs/entrypoint.sh.d/nginx.sh +6 -0
- package/ci/dev/rootfs/entrypoint.sh.d/supervisor.sh +5 -0
- package/ci/dev/rootfs/etc/nginx/_real_ip.conf +2 -0
- package/ci/dev/rootfs/etc/nginx/conf.d/default.conf +20 -0
- package/ci/dev/rootfs/etc/supervisor.d/nginx.ini +11 -0
- package/ci/github/Dockerfile +59 -0
- package/ci/github/release-zip.js +61 -0
- package/ci/npm/Dockerfile +19 -0
- package/config/config.js +24 -0
- package/config/configBuilder.js +126 -0
- package/config/helpers.js +9 -0
- package/config/index.js +1 -0
- package/develop/README.md +42 -0
- package/develop/favicon.png +0 -0
- package/develop/index.html +511 -0
- package/eslint.config.mjs +114 -0
- package/package.json +4 -34
- package/{lib → public}/index.d.ts +10 -10
- package/scripts/zip.js +26 -0
- package/src/core/Pushwoosh.ts +768 -0
- package/src/core/Pushwoosh.types.ts +254 -0
- package/src/core/Safari.types.ts +26 -0
- package/src/core/constants.ts +58 -0
- package/src/core/events.types.ts +46 -0
- package/src/core/functions.ts +33 -0
- package/src/core/legacyEventsMap.ts +64 -0
- package/src/core/logger.ts +64 -0
- package/src/core/modules/EventBus/EventBus.ts +66 -0
- package/src/core/modules/EventBus/index.ts +1 -0
- package/src/core/storage.ts +254 -0
- package/src/helpers/logger.ts +81 -0
- package/src/helpers/pwlogger/Logger.constants.ts +31 -0
- package/src/helpers/pwlogger/Logger.ts +218 -0
- package/src/helpers/pwlogger/Logger.types.ts +66 -0
- package/src/helpers/pwlogger/handlers/handler-console/handler-console.ts +40 -0
- package/src/helpers/pwlogger/index.ts +2 -0
- package/src/helpers/unescape.ts +36 -0
- package/src/models/InboxMessages.ts +202 -0
- package/src/models/InboxMessages.types.ts +111 -0
- package/src/models/NotificationPayload.ts +216 -0
- package/src/models/NotificationPayload.types.ts +65 -0
- package/src/modules/Api/Api.ts +386 -0
- package/src/modules/Api/Api.types.ts +7 -0
- package/src/modules/ApiClient/ApiClient.ts +153 -0
- package/src/modules/ApiClient/ApiClient.types.ts +222 -0
- package/src/modules/Data/Data.ts +345 -0
- package/src/modules/DateModule.ts +53 -0
- package/src/modules/InboxMessagesPublic.ts +222 -0
- package/src/modules/PlatformChecker/PlatformChecker.ts +170 -0
- package/src/modules/PlatformChecker/PlatformChecker.types.ts +5 -0
- package/src/modules/PlatformChecker/index.ts +1 -0
- package/src/modules/storage/Storage.ts +164 -0
- package/src/modules/storage/Storage.types.ts +54 -0
- package/src/modules/storage/Store.ts +104 -0
- package/src/modules/storage/migrations/26-11-2018.ts +25 -0
- package/src/modules/storage/migrations/MigrationExecutor.ts +31 -0
- package/src/modules/storage/migrations/Migrations.ts +41 -0
- package/src/modules/storage/migrations/constants.ts +8 -0
- package/src/modules/storage/migrations/helpers.ts +16 -0
- package/src/modules/storage/migrations/initial.ts +47 -0
- package/src/modules/storage/version.ts +2 -0
- package/src/npm.ts +1 -0
- package/src/pushwoosh-web-notifications.ts +47 -0
- package/src/pushwoosh-widget-inbox.ts +8 -0
- package/src/pushwoosh-widget-subscribe-popup.ts +9 -0
- package/src/pushwoosh-widget-subscription-button.ts +8 -0
- package/src/pushwoosh-widget-subscription-prompt.ts +6 -0
- package/src/service-worker.ts +455 -0
- package/src/services/PushService/PushService.ts +2 -0
- package/src/services/PushService/PushService.types.ts +74 -0
- package/src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.ts +235 -0
- package/src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.types.ts +3 -0
- package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.ts +125 -0
- package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.types.ts +4 -0
- package/src/widget-inbox.ts +1 -0
- package/src/widget-subscribe-popup.ts +1 -0
- package/src/widget-subscription-button.ts +1 -0
- package/src/widget-subscription-prompt.ts +33 -0
- package/src/widgets/Inbox/InboxWidget.ts +564 -0
- package/src/widgets/Inbox/constants.ts +49 -0
- package/src/widgets/Inbox/css/inboxWidgetStyle.css +274 -0
- package/src/widgets/Inbox/helpers.ts +63 -0
- package/src/widgets/Inbox/inbox.d.ts +9 -0
- package/src/widgets/Inbox/inbox_widget.types.ts +41 -0
- package/src/widgets/Inbox/index.ts +1 -0
- package/src/widgets/Inbox/widgetTemplates.ts +55 -0
- package/src/widgets/SubscribePopup/SubscribePopup.ts +241 -0
- package/src/widgets/SubscribePopup/constants.ts +66 -0
- package/src/widgets/SubscribePopup/helpers.ts +11 -0
- package/src/widgets/SubscribePopup/index.ts +1 -0
- package/src/widgets/SubscribePopup/popupTemplates.ts +24 -0
- package/src/widgets/SubscribePopup/styles/popup.css +226 -0
- package/src/widgets/SubscribePopup/types/subscribe-popup.ts +68 -0
- package/src/widgets/SubscriptionButton/assets/css/main.css +205 -0
- package/src/widgets/SubscriptionButton/bell.ts +67 -0
- package/src/widgets/SubscriptionButton/constants.ts +28 -0
- package/src/widgets/SubscriptionButton/index.ts +377 -0
- package/src/widgets/SubscriptionButton/positioning.ts +165 -0
- package/src/widgets/SubscriptionButton/subscribe_widget.types.ts +53 -0
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.constants.ts +1 -0
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.helpers.ts +110 -0
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.ts +102 -0
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.types.ts +23 -0
- package/src/widgets/SubscriptionPrompt/constants.ts +22 -0
- package/src/widgets/SubscriptionPrompt/helpers.ts +42 -0
- package/src/widgets/widgets.d.ts +4 -0
- package/src/worker/global.ts +36 -0
- package/src/worker/notification.ts +34 -0
- package/src/worker/worker.types.ts +4 -0
- package/test/__helpers__/apiHelpers.ts +22 -0
- package/test/__helpers__/keyValueHelpers.ts +15 -0
- package/test/__helpers__/platformHelpers.ts +54 -0
- package/test/__helpers__/sinonHelpers.ts +7 -0
- package/test/__helpers__/storageHelpers.ts +56 -0
- package/test/__mocks__/apiRequests.ts +26 -0
- package/test/__mocks__/idbMock.ts +12 -0
- package/test/__mocks__/idbObjectStoreMock.ts +38 -0
- package/test/__mocks__/inboxMessages.ts +292 -0
- package/test/__mocks__/models/inboxModel.ts +71 -0
- package/test/__mocks__/modules/apiClientModule.ts +18 -0
- package/test/__mocks__/modules/dateModule.ts +34 -0
- package/test/__mocks__/modules/inboxParamsModule.ts +21 -0
- package/test/__mocks__/modules/paramsBuilder.ts +12 -0
- package/test/__mocks__/modules/paramsModule.ts +35 -0
- package/test/__mocks__/modules/payloadBuilderModule.ts +15 -0
- package/test/__mocks__/modules/storageModule.ts +58 -0
- package/test/__mocks__/navigator.ts +38 -0
- package/test/__mocks__/notification.ts +84 -0
- package/test/__mocks__/pushwoosh.ts +12 -0
- package/test/__mocks__/userAgents +8 -0
- package/test/functions.test.ts +22 -0
- package/test/ignore-html.js +6 -0
- package/test/mocha.opts +6 -0
- package/test/modules/DateModule/unit.test.ts +80 -0
- package/test/modules/storage/Storage/unit.test.ts +180 -0
- package/test/modules/storage/Store/unit.test.ts +192 -0
- package/testRegister.js +24 -0
- package/tsconfig.json +31 -0
- package/webpack.config.js +163 -0
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/service-worker.js +0 -2
- package/lib/service-worker.js.map +0 -1
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import {dateMock} from './modules/dateModule';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const existedDeletedInboxMessageMock: IInboxMessage = {
|
|
5
|
+
action_params: JSON.stringify({
|
|
6
|
+
l: '/'
|
|
7
|
+
}),
|
|
8
|
+
order: '0',
|
|
9
|
+
action_type: 'URL',
|
|
10
|
+
image: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
11
|
+
inbox_id: 'test_inbox_code5',
|
|
12
|
+
rt: '1544504828',
|
|
13
|
+
send_date:'1544504828',
|
|
14
|
+
status: 4,
|
|
15
|
+
text: 'test 152 5',
|
|
16
|
+
title: 'Pushwoosh notification'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const inboxMessageMock: IInboxMessage = {
|
|
20
|
+
action_params: JSON.stringify({
|
|
21
|
+
l: '/'
|
|
22
|
+
}),
|
|
23
|
+
order: '0',
|
|
24
|
+
action_type: 'URL',
|
|
25
|
+
image: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
26
|
+
inbox_id: 'test_inbox_code0',
|
|
27
|
+
rt: '1544504828',
|
|
28
|
+
send_date:'1544504828',
|
|
29
|
+
status: 1,
|
|
30
|
+
text: 'test 152',
|
|
31
|
+
title: 'Pushwoosh notification'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
export const existedInboxMessagesMock: Array<IInboxMessage> = [
|
|
36
|
+
{
|
|
37
|
+
action_params: JSON.stringify({
|
|
38
|
+
l: '/'
|
|
39
|
+
}),
|
|
40
|
+
order: '0',
|
|
41
|
+
action_type: 'URL',
|
|
42
|
+
image: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
43
|
+
inbox_id: 'test_inbox_code0',
|
|
44
|
+
rt: '1544504828',
|
|
45
|
+
send_date:'1544504828',
|
|
46
|
+
status: 1,
|
|
47
|
+
text: 'test 152',
|
|
48
|
+
title: 'Pushwoosh notification'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
action_params: JSON.stringify({
|
|
52
|
+
l: '/'
|
|
53
|
+
}),
|
|
54
|
+
order: '0',
|
|
55
|
+
action_type: 'URL',
|
|
56
|
+
image: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
57
|
+
inbox_id: 'test_inbox_code1',
|
|
58
|
+
rt: '1544504828',
|
|
59
|
+
send_date:'1544504828',
|
|
60
|
+
status: 1,
|
|
61
|
+
text: 'test 152 1',
|
|
62
|
+
title: 'Pushwoosh notification'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
action_params: JSON.stringify({
|
|
66
|
+
l: '/'
|
|
67
|
+
}),
|
|
68
|
+
order: '0',
|
|
69
|
+
action_type: 'URL',
|
|
70
|
+
image: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
71
|
+
inbox_id: 'test_inbox_code2',
|
|
72
|
+
rt: '1544504828',
|
|
73
|
+
send_date:'1544504828',
|
|
74
|
+
status: 2,
|
|
75
|
+
text: 'test 152 2',
|
|
76
|
+
title: 'Pushwoosh notification'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
action_params: JSON.stringify({
|
|
80
|
+
l: '/'
|
|
81
|
+
}),
|
|
82
|
+
order: '0',
|
|
83
|
+
action_type: 'URL',
|
|
84
|
+
image: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
85
|
+
inbox_id: 'test_inbox_code3',
|
|
86
|
+
rt: '1544504828',
|
|
87
|
+
send_date:'1544504828',
|
|
88
|
+
status: 3,
|
|
89
|
+
text: 'test 152 3',
|
|
90
|
+
title: 'Pushwoosh notification'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
action_params: JSON.stringify({
|
|
94
|
+
l: '/'
|
|
95
|
+
}),
|
|
96
|
+
order: '0',
|
|
97
|
+
action_type: 'URL',
|
|
98
|
+
image: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
99
|
+
inbox_id: 'test_inbox_code4',
|
|
100
|
+
rt: '1544504828',
|
|
101
|
+
send_date:'1544504828',
|
|
102
|
+
status: 1,
|
|
103
|
+
text: 'test 152 4',
|
|
104
|
+
title: 'Pushwoosh notification'
|
|
105
|
+
},
|
|
106
|
+
existedDeletedInboxMessageMock
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
export const receivedInboxMessagesMock: Array<IInboxMessage> = [
|
|
111
|
+
{
|
|
112
|
+
action_params: JSON.stringify({
|
|
113
|
+
l: '/'
|
|
114
|
+
}),
|
|
115
|
+
order: '15445048280000',
|
|
116
|
+
action_type: 'URL',
|
|
117
|
+
image: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
118
|
+
inbox_id: 'test_inbox_code2',
|
|
119
|
+
rt: '1544504828',
|
|
120
|
+
send_date:'1544504828',
|
|
121
|
+
status: 2,
|
|
122
|
+
text: 'test 152 2',
|
|
123
|
+
title: 'Pushwoosh notification'
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
action_params: JSON.stringify({
|
|
127
|
+
l: 'https://google.com'
|
|
128
|
+
}),
|
|
129
|
+
order: '15445048280000',
|
|
130
|
+
action_type: 'URL',
|
|
131
|
+
image: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
132
|
+
inbox_id: 'test_inbox_code5',
|
|
133
|
+
rt: '1544504828',
|
|
134
|
+
send_date:'1544504828',
|
|
135
|
+
status: 3,
|
|
136
|
+
text: 'test 152 5',
|
|
137
|
+
title: 'Pushwoosh notification'
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
export const actionParamsMessageTypeMap = [
|
|
143
|
+
[
|
|
144
|
+
0,
|
|
145
|
+
{}
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
1,
|
|
149
|
+
{h: 'test_richmedia_data_1'}
|
|
150
|
+
],
|
|
151
|
+
[
|
|
152
|
+
1,
|
|
153
|
+
{rm: 'test_richmedia_data_2'}
|
|
154
|
+
],
|
|
155
|
+
[
|
|
156
|
+
1,
|
|
157
|
+
{r: 'test_richmedia_data_3'}
|
|
158
|
+
],
|
|
159
|
+
[
|
|
160
|
+
2,
|
|
161
|
+
{l: 'http://test.domain'}
|
|
162
|
+
],
|
|
163
|
+
[
|
|
164
|
+
2,
|
|
165
|
+
{l: 'https://test.domain'}
|
|
166
|
+
],
|
|
167
|
+
[
|
|
168
|
+
3,
|
|
169
|
+
{l: '/'}
|
|
170
|
+
],
|
|
171
|
+
];
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
export const publicMessageMock: IInboxMessagePublic = {
|
|
175
|
+
code: 'test_inbox_code0',
|
|
176
|
+
title: 'Pushwoosh notification',
|
|
177
|
+
message: 'test 152',
|
|
178
|
+
imageUrl: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
179
|
+
sendDate: new Date(dateMock).toISOString(),
|
|
180
|
+
type: 0,
|
|
181
|
+
isRead: false,
|
|
182
|
+
isActionPerformed: false
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
export const deliveredInboxMessagesMock: Array<IInboxMessage> = [
|
|
187
|
+
{
|
|
188
|
+
order: '1',
|
|
189
|
+
action_params: JSON.stringify({
|
|
190
|
+
l: '/'
|
|
191
|
+
}),
|
|
192
|
+
action_type: 'URL',
|
|
193
|
+
image: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
194
|
+
inbox_id: 'test_inbox_code0',
|
|
195
|
+
rt: '1544504828',
|
|
196
|
+
send_date:'1544504828',
|
|
197
|
+
status: 1,
|
|
198
|
+
text: 'test 152',
|
|
199
|
+
title: 'Pushwoosh notification'
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
order: '4',
|
|
203
|
+
action_params: JSON.stringify({
|
|
204
|
+
l: '/'
|
|
205
|
+
}),
|
|
206
|
+
action_type: 'URL',
|
|
207
|
+
image: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
208
|
+
inbox_id: 'test_inbox_code1',
|
|
209
|
+
rt: '1544504828',
|
|
210
|
+
send_date:'1544504828',
|
|
211
|
+
status: 1,
|
|
212
|
+
text: 'test 152 1',
|
|
213
|
+
title: 'Pushwoosh notification'
|
|
214
|
+
}
|
|
215
|
+
];
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
export const readOpenInboxMessagesMock: Array<IInboxMessage> = [
|
|
219
|
+
{
|
|
220
|
+
order: '3',
|
|
221
|
+
action_params: JSON.stringify({
|
|
222
|
+
l: '/'
|
|
223
|
+
}),
|
|
224
|
+
action_type: 'URL',
|
|
225
|
+
image: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
226
|
+
inbox_id: 'test_inbox_code2',
|
|
227
|
+
rt: '1544504828',
|
|
228
|
+
send_date:'1544504828',
|
|
229
|
+
status: 2,
|
|
230
|
+
text: 'test 152 2',
|
|
231
|
+
title: 'Pushwoosh notification'
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
order: '3',
|
|
235
|
+
action_params: JSON.stringify({
|
|
236
|
+
l: '/'
|
|
237
|
+
}),
|
|
238
|
+
action_type: 'URL',
|
|
239
|
+
image: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
240
|
+
inbox_id: 'test_inbox_code3',
|
|
241
|
+
rt: '1544504828',
|
|
242
|
+
send_date:'154450000',
|
|
243
|
+
status: 3,
|
|
244
|
+
text: 'test 152 3',
|
|
245
|
+
title: 'Pushwoosh notification'
|
|
246
|
+
},
|
|
247
|
+
];
|
|
248
|
+
|
|
249
|
+
export const publicInboxMessagesOrderSortedMock: Array<IInboxMessagePublic> = [
|
|
250
|
+
{
|
|
251
|
+
code: 'test_inbox_code1',
|
|
252
|
+
title: 'Pushwoosh notification',
|
|
253
|
+
message: 'test 152 1',
|
|
254
|
+
imageUrl: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
255
|
+
sendDate: new Date(dateMock).toISOString(),
|
|
256
|
+
type: 3,
|
|
257
|
+
isRead: false,
|
|
258
|
+
isActionPerformed: false
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
code: 'test_inbox_code2',
|
|
262
|
+
title: 'Pushwoosh notification',
|
|
263
|
+
message: 'test 152 2',
|
|
264
|
+
imageUrl: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
265
|
+
sendDate: new Date(dateMock).toISOString(),
|
|
266
|
+
type: 3,
|
|
267
|
+
isRead: true,
|
|
268
|
+
isActionPerformed: false
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
code: 'test_inbox_code3',
|
|
272
|
+
title: 'Pushwoosh notification',
|
|
273
|
+
message: 'test 152 3',
|
|
274
|
+
imageUrl: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
275
|
+
sendDate: new Date(dateMock).toISOString(),
|
|
276
|
+
type: 3,
|
|
277
|
+
isRead: true,
|
|
278
|
+
isActionPerformed: true
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
code: 'test_inbox_code0',
|
|
282
|
+
title: 'Pushwoosh notification',
|
|
283
|
+
message: 'test 152',
|
|
284
|
+
imageUrl: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
285
|
+
sendDate: new Date(dateMock).toISOString(),
|
|
286
|
+
type: 3,
|
|
287
|
+
isRead: false,
|
|
288
|
+
isActionPerformed: false
|
|
289
|
+
},
|
|
290
|
+
];
|
|
291
|
+
|
|
292
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {SinonSandbox, SinonStub} from 'sinon';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export class InboxModelMock {
|
|
5
|
+
putBulkMessagesStub: SinonStub;
|
|
6
|
+
getDeliveredReadMessagesCountStub: SinonStub;
|
|
7
|
+
getDeliveredMessagesCountStub: SinonStub;
|
|
8
|
+
messagesCountStub: SinonStub;
|
|
9
|
+
getReadOpenMessagesStub: SinonStub;
|
|
10
|
+
getDeliveredMessagesStub: SinonStub;
|
|
11
|
+
getMessageStub: SinonStub;
|
|
12
|
+
putMessageStub: SinonStub;
|
|
13
|
+
updateMessagesStub: SinonStub;
|
|
14
|
+
|
|
15
|
+
putBulkMessages() {}
|
|
16
|
+
getDeliveredReadMessagesCount() {}
|
|
17
|
+
getDeliveredMessagesCount() {}
|
|
18
|
+
messagesCount() {}
|
|
19
|
+
getReadOpenMessages() {}
|
|
20
|
+
getDeliveredMessages() {}
|
|
21
|
+
getMessage() {}
|
|
22
|
+
putMessage() {}
|
|
23
|
+
updateMessages() {}
|
|
24
|
+
|
|
25
|
+
setMethodStubs(sandbox: SinonSandbox) {
|
|
26
|
+
this.setPutBulkMessagesStub(sandbox);
|
|
27
|
+
this.setGetDeliveredReadMessagesCountStub(sandbox);
|
|
28
|
+
this.setGetDeliveredMessagesCountStub(sandbox);
|
|
29
|
+
this.setMessagesCountStub(sandbox);
|
|
30
|
+
this.setGetReadOpenMessagesStub(sandbox);
|
|
31
|
+
this.setGetDeliveredMessagesStub(sandbox);
|
|
32
|
+
this.setGetMessageStub(sandbox);
|
|
33
|
+
this.setPutMessageStub(sandbox);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setPutBulkMessagesStub(sandbox: SinonSandbox) {
|
|
37
|
+
this.putBulkMessagesStub = sandbox.stub(this, 'putBulkMessages');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
setGetDeliveredReadMessagesCountStub(sandbox: SinonSandbox) {
|
|
41
|
+
this.getDeliveredReadMessagesCountStub = sandbox.stub(this, 'getDeliveredReadMessagesCount');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
setGetDeliveredMessagesCountStub(sandbox: SinonSandbox) {
|
|
45
|
+
this.getDeliveredMessagesCountStub = sandbox.stub(this, 'getDeliveredMessagesCount');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
setMessagesCountStub(sandbox: SinonSandbox) {
|
|
49
|
+
this.messagesCountStub = sandbox.stub(this, 'messagesCount');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setGetReadOpenMessagesStub(sandbox: SinonSandbox) {
|
|
53
|
+
this.getReadOpenMessagesStub = sandbox.stub(this, 'getReadOpenMessages');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
setGetDeliveredMessagesStub(sandbox: SinonSandbox) {
|
|
57
|
+
this.getDeliveredMessagesStub = sandbox.stub(this, 'getDeliveredMessages');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
setGetMessageStub(sandbox: SinonSandbox) {
|
|
61
|
+
this.getMessageStub = sandbox.stub(this, 'getMessage');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setPutMessageStub(sandbox: SinonSandbox) {
|
|
65
|
+
this.putMessageStub = sandbox.stub(this, 'putMessage');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
setUpdateMessagesStub(sandbox: SinonSandbox) {
|
|
69
|
+
this.updateMessagesStub = sandbox.stub(this, 'updateMessages');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as sinon from 'sinon';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const getInboxMessagesResponseMock: IGetInboxMessagesResponse = {
|
|
5
|
+
messages: [],
|
|
6
|
+
new_inbox: 0,
|
|
7
|
+
deleted: [],
|
|
8
|
+
next: ''
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export class ApiClientMock {
|
|
13
|
+
getInboxMessages = sinon.fake.resolves(getInboxMessagesResponseMock);
|
|
14
|
+
inboxStatus = sinon.fake();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export default new ApiClientMock();
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as sinon from 'sinon';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const utcTimestampMock = 1544086800;
|
|
5
|
+
export const timestampMock = 1544087800;
|
|
6
|
+
export const fakeInboxOrderMock = '154408780000';
|
|
7
|
+
export const dateMock = '2018/12/07 10:20';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export class DateModuleMock {
|
|
11
|
+
_date: Date;
|
|
12
|
+
setLocal = sinon.fake();
|
|
13
|
+
getInboxFakeOrder = sinon.fake.returns(fakeInboxOrderMock);
|
|
14
|
+
|
|
15
|
+
set date(date: Date) {
|
|
16
|
+
this._date = new Date(dateMock);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get date() {
|
|
20
|
+
return this._date
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
addDays(days: number) {}
|
|
24
|
+
|
|
25
|
+
getUtcTimestamp() {
|
|
26
|
+
return utcTimestampMock;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getTimestamp() {
|
|
30
|
+
return timestampMock;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default new DateModuleMock();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as sinon from 'sinon';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const lastRequestCodeMock = 'test_last_code';
|
|
5
|
+
export const lastRequestTimeMock = 1544086800;
|
|
6
|
+
|
|
7
|
+
export class InboxParamsMock {
|
|
8
|
+
setLastRequestTime = sinon.fake.resolves(null);
|
|
9
|
+
setLastRequestCode = sinon.fake.resolves(null);
|
|
10
|
+
setNewMessagesCount = sinon.fake.resolves(null);
|
|
11
|
+
|
|
12
|
+
get lastRequestCode() {
|
|
13
|
+
return lastRequestCodeMock;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get lastRequestTime() {
|
|
17
|
+
return lastRequestTimeMock;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default new InboxParamsMock();
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_NOTIFICATION_IMAGE,
|
|
3
|
+
DEFAULT_NOTIFICATION_TITLE,
|
|
4
|
+
} from '../../../src/core/constants';
|
|
5
|
+
|
|
6
|
+
export const hwidMock = 'test_hwid';
|
|
7
|
+
export const appCodeMock = '#####-#####';
|
|
8
|
+
export const userIdMock = 'test_user_id';
|
|
9
|
+
|
|
10
|
+
export class ParamsModuleWithoutUserIdMockBase {
|
|
11
|
+
get hwid() {
|
|
12
|
+
return hwidMock;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get appCode() {
|
|
16
|
+
return appCodeMock;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class ParamsMock extends ParamsModuleWithoutUserIdMockBase {
|
|
21
|
+
get userId() {
|
|
22
|
+
return userIdMock;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get defaultNotificationTitle() {
|
|
26
|
+
return DEFAULT_NOTIFICATION_TITLE;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get defaultNotificationImage() {
|
|
30
|
+
return DEFAULT_NOTIFICATION_IMAGE;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const paramsModuleInstanceWithutUserIdMock = new ParamsModuleWithoutUserIdMockBase();
|
|
35
|
+
export default new ParamsMock();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as sinon from 'sinon';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getInboxMessagesRequestMock,
|
|
5
|
+
inboxStatusRequestMock
|
|
6
|
+
} from '../apiRequests';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export class PayloadBuilderMock {
|
|
10
|
+
getInboxMessages = sinon.fake.resolves(getInboxMessagesRequestMock);
|
|
11
|
+
inboxStatus = sinon.fake.resolves(inboxStatusRequestMock);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export default new PayloadBuilderMock();
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {SinonSandbox, SinonStub} from 'sinon';
|
|
2
|
+
import {existedDeletedInboxMessageMock, existedInboxMessagesMock} from '../inboxMessages';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export class StorageMock {
|
|
6
|
+
getStub: SinonStub;
|
|
7
|
+
putStub: SinonStub;
|
|
8
|
+
deleteStub: SinonStub;
|
|
9
|
+
countStub: SinonStub;
|
|
10
|
+
countByIndexStub: SinonStub;
|
|
11
|
+
getAllStub: SinonStub;
|
|
12
|
+
|
|
13
|
+
get() {};
|
|
14
|
+
put() {};
|
|
15
|
+
delete() {};
|
|
16
|
+
count() {};
|
|
17
|
+
countByIndex() {};
|
|
18
|
+
getAll() {};
|
|
19
|
+
|
|
20
|
+
setMethodStubs(sandbox: SinonSandbox) {
|
|
21
|
+
this.setGetMethodStub(sandbox);
|
|
22
|
+
this.setPutMethodStub(sandbox);
|
|
23
|
+
this.setDeleteMethodStub(sandbox);
|
|
24
|
+
this.setCountByIndexStub(sandbox);
|
|
25
|
+
this.setGetAllStub(sandbox);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setGetMethodStub(sandbox: SinonSandbox) {
|
|
29
|
+
this.getStub = sandbox.stub(this, 'get');
|
|
30
|
+
|
|
31
|
+
// inboxMessages get
|
|
32
|
+
this.getStub.returns(existedInboxMessagesMock[0]);
|
|
33
|
+
this.getStub.withArgs('inboxMessages', existedDeletedInboxMessageMock.inbox_id)
|
|
34
|
+
.resolves(existedDeletedInboxMessageMock);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
setPutMethodStub(sandbox: SinonSandbox) {
|
|
38
|
+
this.putStub = sandbox.stub(this, 'put');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
setDeleteMethodStub(sandbox: SinonSandbox) {
|
|
42
|
+
this.deleteStub = sandbox.stub(this, 'delete');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setCountMethodStub(sandbox: SinonSandbox) {
|
|
46
|
+
this.countStub = sandbox.stub(this, 'count');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setCountByIndexStub(sandbox: SinonSandbox) {
|
|
50
|
+
this.countByIndexStub = sandbox.stub(this, 'countByIndex');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
setGetAllStub(sandbox: SinonSandbox) {
|
|
54
|
+
this.getAllStub = sandbox.stub(this, 'getAll');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default new StorageMock();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const readline = require('readline');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const userAgentsMock: Promise<Array<string>> = new Promise(resolve => {
|
|
7
|
+
const userAgents: string[] = [];
|
|
8
|
+
|
|
9
|
+
const lineReader = readline.createInterface({
|
|
10
|
+
input: fs.createReadStream(path.resolve(__dirname, 'userAgents'))
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
lineReader.on('line', function (line: string) {
|
|
14
|
+
userAgents.push(line);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
lineReader.on('close', function () {
|
|
18
|
+
resolve(userAgents);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const userAgentsBrowserVersionMapMock = [
|
|
23
|
+
['Chrome 70', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36'],
|
|
24
|
+
['Opera 56', '5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 OPR/56.0.3051.52'],
|
|
25
|
+
['Safari 12.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.1 Safari/605.1.15'],
|
|
26
|
+
['Firefox 62', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:62.0) Gecko/20100101 Firefox/62.0'],
|
|
27
|
+
['IE 11', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/7.0; Tablet PC 2.0; .NET4.0E; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET4.0C'],
|
|
28
|
+
['Edge 12', 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10130'],
|
|
29
|
+
['Edge 17', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; MSAppHost/3.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134']
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
export const chromeUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36';
|
|
33
|
+
export const operaUserAgent = '5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 OPR/56.0.3051.52';
|
|
34
|
+
export const safariUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.1 Safari/605.1.15';
|
|
35
|
+
export const firefoxUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:62.0) Gecko/20100101 Firefox/62.0';
|
|
36
|
+
export const edgeUserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; MSAppHost/3.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134';
|
|
37
|
+
export const ie11UserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/7.0; Tablet PC 2.0; .NET4.0E; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET4.0C';
|
|
38
|
+
export const macOSPlatform = 'MacIntel';
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
|
|
2
|
+
export const notificationPayloadBodyMock = 'test_body';
|
|
3
|
+
export const notificationPayloadHashMock = 'test_hash';
|
|
4
|
+
export const notificationPayloadHeaderMock = 'Test Header';
|
|
5
|
+
export const notificationPayloadDurationMock = '30';
|
|
6
|
+
export const notificationPayloadIconMock = 'https://icon.test/icon.png';
|
|
7
|
+
export const notificationPayloadCustomDataMock = JSON.stringify({customData: 'test custom data'});
|
|
8
|
+
export const notificationPayloadLinkMock = '/home';
|
|
9
|
+
export const notificationPayloadSilent = false;
|
|
10
|
+
export const notificationPayloadCampaignIdMock = '#####-CAMPA';
|
|
11
|
+
export const notificationPayloadImageMock = 'https://image.test/image.png';
|
|
12
|
+
export const notificationPayloadButtonsMock = JSON.stringify([
|
|
13
|
+
{
|
|
14
|
+
title: 'action 1',
|
|
15
|
+
url: 'https://go.pushwoosh.com/img/tmp.icon.png'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
title: 'action 2',
|
|
19
|
+
url: 'https://go.pushwoosh.com/img/tmp.icon.png'
|
|
20
|
+
}
|
|
21
|
+
]);
|
|
22
|
+
export const notificationPayloadActionsMock: Array<INotificationButton> = [
|
|
23
|
+
{
|
|
24
|
+
action: 'action-0',
|
|
25
|
+
title: 'action 1',
|
|
26
|
+
url: 'https://go.pushwoosh.com/img/tmp.icon.png'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
action: 'action-1',
|
|
30
|
+
title: 'action 2',
|
|
31
|
+
url: 'https://go.pushwoosh.com/img/tmp.icon.png'
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
export const notificationPayloadInboxIdMock = 'testInboxId';
|
|
35
|
+
export const notificationPayloadInboxParamsMock = {
|
|
36
|
+
image: 'https://inbox-image.test/inbox-image.png',
|
|
37
|
+
rt: '1544086800'
|
|
38
|
+
};
|
|
39
|
+
export const notificationPayloadRootParamsMock = {
|
|
40
|
+
badge: 'https://inbox-badge.test/inbox-badge.png',
|
|
41
|
+
rootParam: 'root param'
|
|
42
|
+
};
|
|
43
|
+
export const notificationPayloadInvalidDurationMock = 'invalid_duration';
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export const notificationMinimalPayloadMock: INotificationPayload = {
|
|
47
|
+
body: notificationPayloadBodyMock,
|
|
48
|
+
p: notificationPayloadHashMock,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const notificationMinimalChromePayloadMock: IChromeNotificationPayload = {
|
|
52
|
+
data: {
|
|
53
|
+
body: notificationPayloadBodyMock,
|
|
54
|
+
p: notificationPayloadHashMock
|
|
55
|
+
},
|
|
56
|
+
from: 'test'
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const notificationMinimalPayloadInvalidDurationPayloadMock: INotificationPayload = {
|
|
60
|
+
body: notificationPayloadBodyMock,
|
|
61
|
+
p: notificationPayloadHashMock,
|
|
62
|
+
duration: notificationPayloadInvalidDurationMock
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const notificationMaximumPayloadMock: INotificationPayload = {
|
|
66
|
+
...notificationPayloadRootParamsMock,
|
|
67
|
+
body: notificationPayloadBodyMock,
|
|
68
|
+
p: notificationPayloadHashMock,
|
|
69
|
+
header: notificationPayloadHeaderMock,
|
|
70
|
+
duration: notificationPayloadDurationMock,
|
|
71
|
+
i: notificationPayloadIconMock,
|
|
72
|
+
u: notificationPayloadCustomDataMock,
|
|
73
|
+
l: notificationPayloadLinkMock,
|
|
74
|
+
pwcid: notificationPayloadCampaignIdMock,
|
|
75
|
+
image: notificationPayloadImageMock,
|
|
76
|
+
buttons: notificationPayloadButtonsMock,
|
|
77
|
+
pw_inbox: notificationPayloadInboxIdMock,
|
|
78
|
+
inbox_params: JSON.stringify(notificationPayloadInboxParamsMock),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const notificationSilentPayloadMock: INotificationPayload = {
|
|
82
|
+
...notificationMaximumPayloadMock,
|
|
83
|
+
silent: 'true'
|
|
84
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const initParams = {
|
|
2
|
+
applicationCode: 'XXXXX-XXXXX',
|
|
3
|
+
safariWebsitePushID: 'web.io.test',
|
|
4
|
+
defaultNotificationTitle: 'Pushwoosh',
|
|
5
|
+
defaultNotificationImage: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
6
|
+
autoSubscribe: false,
|
|
7
|
+
userId: 'test_user_id',
|
|
8
|
+
tags: {
|
|
9
|
+
Name: 'Test Name',
|
|
10
|
+
},
|
|
11
|
+
serviceWorkerUrl: '/pushwoosh-service-worker.js',
|
|
12
|
+
};
|