@tellescope/sdk 1.242.8 → 1.242.9

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.
@@ -12629,8 +12629,8 @@ const replace_enduser_template_values_tests = async () => {
12629
12629
  const inbox_threads_building_tests = async () => {
12630
12630
  log_header("Inbox Thread Building Tests")
12631
12631
 
12632
- const e = await sdk.api.endusers.createOne({ })
12633
- const e2 = await sdk.api.endusers.createOne({ })
12632
+ const e = await sdk.api.endusers.createOne({ fname: 'Alice', lname: 'Wonderland' })
12633
+ const e2 = await sdk.api.endusers.createOne({ fname: 'Bob', lname: 'Builder' })
12634
12634
 
12635
12635
  const deleteBuiltThreads = async () => {
12636
12636
  const allBuiltThreadsForCleanup = (await sdk.api.inbox_threads.load_threads({ })).threads
@@ -12719,7 +12719,7 @@ const inbox_threads_building_tests = async () => {
12719
12719
  'load threads',
12720
12720
  () => sdk.api.inbox_threads.load_threads({ }),
12721
12721
  { onResult: ({ threads }) => (
12722
- threads.length === 5
12722
+ threads.length === 5
12723
12723
  && threads.some(t => t.type === 'Email' && t.emailMessageId === email.messageId && !object_is_empty(t.readBy ?? {}))
12724
12724
  && threads.some(t => t.type === 'SMS' && t.threadId === sms.id && !object_is_empty(t.readBy ?? {}))
12725
12725
  && threads.some(t => t.type === 'GroupMMS' && t.threadId === groupMMS.id && !object_is_empty(t.readBy ?? {}))
@@ -12728,7 +12728,34 @@ const inbox_threads_building_tests = async () => {
12728
12728
  && !threads.some(t => t.outboundPreview || t.outboundTimestamp)
12729
12729
  )}
12730
12730
  )
12731
-
12731
+
12732
+ // searchKeywords population tests
12733
+ await async_test(
12734
+ 'built threads have searchKeywords from enduser names',
12735
+ () => sdk.api.inbox_threads.load_threads({ }),
12736
+ { onResult: ({ threads }) => {
12737
+ const eThreads = threads.filter(t => t.enduserIds.includes(e.id))
12738
+ return eThreads.length === 5
12739
+ && eThreads.every(t =>
12740
+ !!t.searchKeywords
12741
+ && t.searchKeywords.includes('alice')
12742
+ && t.searchKeywords.includes('wonderland')
12743
+ && t.searchKeywords.length === 2 // fname, lname - no duplicates
12744
+ )
12745
+ }}
12746
+ )
12747
+
12748
+ // search by enduser name (via searchKeywords)
12749
+ await async_test(
12750
+ 'search by enduser first name finds threads',
12751
+ () => sdk.api.inbox_threads.load_threads({ search: 'Alice' }),
12752
+ { onResult: ({ threads }) => threads.length === 5 && threads.every(t => t.enduserIds.includes(e.id)) }
12753
+ )
12754
+ await async_test(
12755
+ 'search by enduser last name finds threads',
12756
+ () => sdk.api.inbox_threads.load_threads({ search: 'Wonderland' }),
12757
+ { onResult: ({ threads }) => threads.length === 5 && threads.every(t => t.enduserIds.includes(e.id)) }
12758
+ )
12732
12759
  await resetThreadBuildingDates()
12733
12760
  await async_test(
12734
12761
  're-build initial 1-message threads',
@@ -12812,6 +12839,21 @@ const inbox_threads_building_tests = async () => {
12812
12839
  )}
12813
12840
  )
12814
12841
 
12842
+ // verify second enduser's threads also have correct searchKeywords
12843
+ await async_test(
12844
+ 'second enduser threads have searchKeywords from enduser names',
12845
+ () => sdk.api.inbox_threads.load_threads({ }),
12846
+ { onResult: ({ threads }) => {
12847
+ const e2Threads = threads.filter(t => t.enduserIds.includes(e2.id))
12848
+ return e2Threads.length === 5
12849
+ && e2Threads.every(t =>
12850
+ !!t.searchKeywords
12851
+ && t.searchKeywords.includes('bob')
12852
+ && t.searchKeywords.includes('builder')
12853
+ )
12854
+ }}
12855
+ )
12856
+
12815
12857
  await resetThreadBuildingDates()
12816
12858
  await async_test(
12817
12859
  're-build initial 1-message threads for other enduser',
@@ -13033,6 +13075,28 @@ const inbox_threads_loading_tests = async () => {
13033
13075
  { onResult: ({ threads }) => threads.length === 2 }
13034
13076
  )
13035
13077
 
13078
+ // search parameter tests
13079
+ await async_test(
13080
+ 'search by title',
13081
+ () => sdk.api.inbox_threads.load_threads({ search: 'Email' }),
13082
+ { onResult: ({ threads }) => threads.length === 1 && threads[0].type === 'Email' }
13083
+ )
13084
+ await async_test(
13085
+ 'search by preview matches all threads',
13086
+ () => sdk.api.inbox_threads.load_threads({ search: 'Test' }),
13087
+ { onResult: ({ threads }) => threads.length === 5 }
13088
+ )
13089
+ await async_test(
13090
+ 'search with no match returns empty',
13091
+ () => sdk.api.inbox_threads.load_threads({ search: 'zzzznonexistent' }),
13092
+ { onResult: ({ threads }) => threads.length === 0 }
13093
+ )
13094
+ await async_test(
13095
+ 'short search (< 3 chars) returns unfiltered results',
13096
+ () => sdk.api.inbox_threads.load_threads({ search: 'ab' }),
13097
+ { onResult: ({ threads }) => threads.length === 5 }
13098
+ )
13099
+
13036
13100
  // adding to care team of e2 who belongs to only the phone thread
13037
13101
  await sdk.api.endusers.updateOne(e2.id, { assignedTo: [sdkNonAdmin.userInfo.id] }, { replaceObjectFields: true })
13038
13102
 
@@ -13042,8 +13106,17 @@ const inbox_threads_loading_tests = async () => {
13042
13106
  await async_test(
13043
13107
  'non-admin can load threads based on assignment/default access',
13044
13108
  () => sdkNonAdmin.api.inbox_threads.load_threads({ }),
13045
- { onResult: ({ threads }) =>
13046
- threads.length === 2
13109
+ { onResult: ({ threads }) =>
13110
+ threads.length === 2
13111
+ && threads.some(t => t.id === phone.id)
13112
+ && threads.some(t => t.id === sms.id)
13113
+ }
13114
+ )
13115
+ await async_test(
13116
+ 'assigned access search still respects access control',
13117
+ () => sdkNonAdmin.api.inbox_threads.load_threads({ search: 'Test' }),
13118
+ { onResult: ({ threads }) =>
13119
+ threads.length === 2
13047
13120
  && threads.some(t => t.id === phone.id)
13048
13121
  && threads.some(t => t.id === sms.id)
13049
13122
  }
@@ -13087,6 +13160,11 @@ const inbox_threads_loading_tests = async () => {
13087
13160
  () => sdkDefaultAccess.api.inbox_threads.load_threads({ }),
13088
13161
  { onResult: ({ threads }) => threads.length === 1 && threads.some(t => t.id === sms.id) }
13089
13162
  )
13163
+ await async_test(
13164
+ 'default access search still respects access control',
13165
+ () => sdkDefaultAccess.api.inbox_threads.load_threads({ search: 'Test' }),
13166
+ { onResult: ({ threads }) => threads.length === 1 && threads.some(t => t.id === sms.id) }
13167
+ )
13090
13168
 
13091
13169
 
13092
13170
  const noAccessRole = await sdk.api.role_based_access_permissions.createOne({
@@ -13121,6 +13199,11 @@ const inbox_threads_loading_tests = async () => {
13121
13199
  () => sdkNoAccess.api.inbox_threads.load_threads({ }),
13122
13200
  { onResult: ({ threads }) => threads.length === 0 },
13123
13201
  )
13202
+ await async_test(
13203
+ "No access reads nothing even with search",
13204
+ () => sdkNoAccess.api.inbox_threads.load_threads({ search: 'Test' }),
13205
+ { onResult: ({ threads }) => threads.length === 0 },
13206
+ )
13124
13207
 
13125
13208
  // Update existing threads with phone numbers for phoneNumber filtering tests
13126
13209
  await sdk.api.inbox_threads.updateOne(sms.id, { phoneNumber: '+15555555555' })
@@ -13160,6 +13243,17 @@ const inbox_threads_loading_tests = async () => {
13160
13243
  { onResult: ({ threads }) => threads.length === 0 }
13161
13244
  )
13162
13245
 
13246
+ // search by phone number (uses regex on phoneNumber/enduserPhoneNumber fields)
13247
+ await async_test(
13248
+ 'search by phone number',
13249
+ () => sdk.api.inbox_threads.load_threads({ search: '+15555555555' }),
13250
+ { onResult: ({ threads }) =>
13251
+ threads.length >= 2
13252
+ && threads.some(t => t.type === 'SMS')
13253
+ && threads.some(t => t.type === 'Phone')
13254
+ }
13255
+ )
13256
+
13163
13257
  await Promise.all([
13164
13258
  sdk.api.endusers.deleteOne(e1.id),
13165
13259
  sdk.api.endusers.deleteOne(e2.id),
Binary file