@tellescope/sdk 1.3.19 → 1.3.21

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.
@@ -202,6 +202,42 @@ const meetings_tests = async (isSubscribed: boolean) => {
202
202
  await sdk.api.endusers.deleteOne(enduser.id)
203
203
  }
204
204
 
205
+ const endusers_tests = async (isSubscribed: boolean) => {
206
+ log_header(`Endusers Tests, isSubscribed=${isSubscribed}`)
207
+
208
+ if (isSubscribed) {
209
+ await sdk.api.webhooks.update({ subscriptionUpdates: {
210
+ ...emptySubscription,
211
+ chats: { create: true },
212
+ meetings: { create: true, update: true, delete: false },
213
+ endusers: { create: false, update: true, delete: false },
214
+ }})
215
+ }
216
+
217
+ const enduser = await sdk.api.endusers.createOne({ email: 'deleteme@tellescope.com' })
218
+ const update = { assignedTo: [sdk.userInfo.id] }
219
+ await sdk.api.endusers.updateOne(enduser.id, update)
220
+
221
+ await check_next_webhook(
222
+ a => (
223
+ objects_equivalent(a.updates?.[0]?.recordBeforeUpdate, enduser)
224
+ && objects_equivalent(a.updates?.[0]?.update, update)
225
+ ),
226
+ 'Enduser update error', 'Update enduser webhook', isSubscribed
227
+ )
228
+
229
+ // cleanup
230
+ if (isSubscribed) {
231
+ await sdk.api.webhooks.update({ subscriptionUpdates: {
232
+ ...emptySubscription,
233
+ chats: { create: true },
234
+ meetings: { create: true, update: true, delete: false },
235
+ }})
236
+ }
237
+
238
+ await sdk.api.endusers.deleteOne(enduser.id)
239
+ }
240
+
205
241
  const AUTOMATION_POLLING_DELAY_MS = 3000 - CHECK_WEBHOOK_DELAY_MS
206
242
  const test_automation_webhooks = async () => {
207
243
  log_header("Automation Events")
@@ -232,7 +268,9 @@ const test_automation_webhooks = async () => {
232
268
  await wait(undefined, AUTOMATION_POLLING_DELAY_MS)
233
269
 
234
270
  await check_next_webhook(
235
- ({ message }) => message === testMessage,
271
+ ({ message }) => {
272
+ return message === testMessage
273
+ },
236
274
  'Automation webhook received',
237
275
  'Automation webhook error',
238
276
  true
@@ -340,7 +378,8 @@ const calendar_event_reminders_tests = async (isSubscribed: boolean) => {
340
378
  await sdk.api.calendar_events.deleteOne(calendarEvent.id)
341
379
  }
342
380
 
343
- const tests: { [K in WebhookSupportedModel | 'calendarEventReminders']: (isSubscribed: boolean) => Promise<void> } = {
381
+ const tests: { [K in WebhookSupportedModel | 'calendarEventReminders']?: (isSubscribed: boolean) => Promise<void> } = {
382
+ endusers: endusers_tests,
344
383
  chats: chats_tests,
345
384
  calendarEventReminders: calendar_event_reminders_tests,
346
385
  meetings: meetings_tests,
@@ -404,10 +443,18 @@ const run_tests = async () => {
404
443
  { onResult: r => r.url === webhookURL && objects_equivalent(r.subscriptions, fullSubscription) }
405
444
  )
406
445
 
446
+ // reset to only poartial / testing fields
447
+ // todo: subscribe in individual tests to avoid issues in ordering of tests / subscriptions
448
+ await sdk.api.webhooks.update({ subscriptionUpdates: {
449
+ ...emptySubscription,
450
+ chats: { create: true },
451
+ meetings: { create: true, update: true, delete: false } }
452
+ })
453
+
407
454
  log_header("Webhooks Tests with Subscriptions")
408
455
  await test_automation_webhooks()
409
456
  for (const t in tests) {
410
- await tests[t as keyof typeof tests](true)
457
+ await tests[t as keyof typeof tests]?.(true)
411
458
  }
412
459
  const finalLength = handledEvents.length
413
460
 
@@ -423,8 +470,9 @@ const run_tests = async () => {
423
470
  continue // don't require subscription / can't unsubscribe
424
471
  }
425
472
 
426
- await tests[t as keyof typeof tests](false)
473
+ await tests[t as keyof typeof tests]?.(false)
427
474
  }
475
+
428
476
  assert(finalLength === handledEvents.length, 'length changed after subscriptions', 'No webhooks posted when no subscription')
429
477
 
430
478
  }