@tellescope/sdk 1.242.9 → 1.243.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/lib/cjs/enduser.d.ts +20 -0
- package/lib/cjs/enduser.d.ts.map +1 -1
- package/lib/cjs/sdk.d.ts +45 -0
- package/lib/cjs/sdk.d.ts.map +1 -1
- package/lib/cjs/sdk.js +2 -0
- package/lib/cjs/sdk.js.map +1 -1
- package/lib/cjs/tests/api_tests/concurrent_build_threads.test.d.ts +6 -0
- package/lib/cjs/tests/api_tests/concurrent_build_threads.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/concurrent_build_threads.test.js +169 -0
- package/lib/cjs/tests/api_tests/concurrent_build_threads.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/custom_aggregation.test.d.ts.map +1 -1
- package/lib/cjs/tests/api_tests/custom_aggregation.test.js +109 -7
- package/lib/cjs/tests/api_tests/custom_aggregation.test.js.map +1 -1
- package/lib/cjs/tests/api_tests/custom_dashboards.test.d.ts +6 -0
- package/lib/cjs/tests/api_tests/custom_dashboards.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/custom_dashboards.test.js +304 -0
- package/lib/cjs/tests/api_tests/custom_dashboards.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/inbox_thread_assignment_updates.test.d.ts.map +1 -1
- package/lib/cjs/tests/api_tests/inbox_thread_assignment_updates.test.js +655 -139
- package/lib/cjs/tests/api_tests/inbox_thread_assignment_updates.test.js.map +1 -1
- package/lib/cjs/tests/api_tests/no_access_permission_checks.test.d.ts +20 -0
- package/lib/cjs/tests/api_tests/no_access_permission_checks.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/no_access_permission_checks.test.js +481 -0
- package/lib/cjs/tests/api_tests/no_access_permission_checks.test.js.map +1 -0
- package/lib/cjs/tests/tests.d.ts.map +1 -1
- package/lib/cjs/tests/tests.js +125 -112
- package/lib/cjs/tests/tests.js.map +1 -1
- package/lib/esm/enduser.d.ts +20 -0
- package/lib/esm/enduser.d.ts.map +1 -1
- package/lib/esm/sdk.d.ts +45 -0
- package/lib/esm/sdk.d.ts.map +1 -1
- package/lib/esm/sdk.js +2 -0
- package/lib/esm/sdk.js.map +1 -1
- package/lib/esm/tests/api_tests/concurrent_build_threads.test.d.ts +6 -0
- package/lib/esm/tests/api_tests/concurrent_build_threads.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/concurrent_build_threads.test.js +165 -0
- package/lib/esm/tests/api_tests/concurrent_build_threads.test.js.map +1 -0
- package/lib/esm/tests/api_tests/custom_aggregation.test.d.ts.map +1 -1
- package/lib/esm/tests/api_tests/custom_aggregation.test.js +110 -8
- package/lib/esm/tests/api_tests/custom_aggregation.test.js.map +1 -1
- package/lib/esm/tests/api_tests/custom_dashboards.test.d.ts +6 -0
- package/lib/esm/tests/api_tests/custom_dashboards.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/custom_dashboards.test.js +300 -0
- package/lib/esm/tests/api_tests/custom_dashboards.test.js.map +1 -0
- package/lib/esm/tests/api_tests/inbox_thread_assignment_updates.test.d.ts.map +1 -1
- package/lib/esm/tests/api_tests/inbox_thread_assignment_updates.test.js +655 -139
- package/lib/esm/tests/api_tests/inbox_thread_assignment_updates.test.js.map +1 -1
- package/lib/esm/tests/api_tests/no_access_permission_checks.test.d.ts +20 -0
- package/lib/esm/tests/api_tests/no_access_permission_checks.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/no_access_permission_checks.test.js +477 -0
- package/lib/esm/tests/api_tests/no_access_permission_checks.test.js.map +1 -0
- package/lib/esm/tests/tests.d.ts.map +1 -1
- package/lib/esm/tests/tests.js +125 -112
- package/lib/esm/tests/tests.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/sdk.ts +9 -1
- package/src/tests/api_tests/concurrent_build_threads.test.ts +103 -0
- package/src/tests/api_tests/custom_aggregation.test.ts +74 -0
- package/src/tests/api_tests/custom_dashboards.test.ts +258 -0
- package/src/tests/api_tests/inbox_thread_assignment_updates.test.ts +431 -1
- package/src/tests/api_tests/no_access_permission_checks.test.ts +365 -0
- package/src/tests/tests.ts +8 -1
- package/test_generated.pdf +0 -0
|
@@ -56,11 +56,11 @@ var host = process.env.API_URL || 'http://localhost:8080';
|
|
|
56
56
|
var inbox_thread_assignment_updates_tests = function (_a) {
|
|
57
57
|
var sdk = _a.sdk, sdkNonAdmin = _a.sdkNonAdmin;
|
|
58
58
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
-
var timestamp, testUser, testEnduser, defaultThreadFields, emailSubject, emailThreadId, emailThread, testEmail, smsThread, testSMS, testChatRoom, chatThread, loadedThreads, updatedEmailThread, loadedThreads2, updatedSMSThread, loadedThreads3, updatedChatThread, loadedThreads4, unchangedThread, loadedThreads5, clearedAssignThread, fixedTimestamp, matchingTimestampSubject, matchingTimestampThreadId, matchingTimestampEmailThread_1, matchingTimestampEmail, loadedThreads6, matchingTimestampUpdatedThread, matchingTimestampSMSThread_1, matchingTimestampSMS, loadedThreads7, matchingTimestampSMSUpdatedThread, orphanEmail, threadsBeforeOrphanUpdate, threadCountBefore, threadsAfterOrphanUpdate, threadCountAfter, upsertSMS, threadsAfterUpsertTest, upsertedThread, countResult, allThreads, filteredThreads, filteredCount, nonMatchingCount, emailTypeFilter, foundEmailByType, foundSmsByType, multiTypeFilter, foundEmailMulti, foundSmsMulti, foundChatMulti, assigneeFilter, foundAssigned, combinedFilter, foundCombined, mdbFilterCount, emptyMdbFilter, idsFilterResult, foundEmailById, foundSmsById, foundChatById, singleIdResult, idsCombinedResult, idsCountResult, emptyIdsResult, sortTestBaseTime, sortThread1, sortThread2, sortThread3, defaultSortResult, timestampSortResult, outboundSortResult, statusTestSMS1, statusTestFrom, statusTestThreads, statusTestThread, statusTestSMS2, threadAfterOutbound, statusTestSMS3, threadAfterNewInbound, readByTestSMS1, readByTestFrom, readByTestThreads, readByTestThread, threadAfterRead, readByTestSMS2, smsThreadAfterOutbound, readByTestSMS3, smsThreadAfterNewInbound, readByTestEmail1, readByEmailTestFrom, readByEmailTestThreads, readByEmailTestThread, emailThreadAfterRead, readByTestEmail2, emailThreadAfterOutbound, readByTestEmail3, emailThreadAfterNewInbound, err_1;
|
|
60
|
-
var _b, _c;
|
|
59
|
+
var timestamp, testUser, testEnduser, defaultThreadFields, emailSubject, emailThreadId, emailThread, testEmail, smsThread, testSMS, testChatRoom, chatThread, loadedThreads, updatedEmailThread, loadedThreads2, updatedSMSThread, loadedThreads3, updatedChatThread, loadedThreads4, unchangedThread, loadedThreads5, clearedAssignThread, fixedTimestamp, matchingTimestampSubject, matchingTimestampThreadId, matchingTimestampEmailThread_1, matchingTimestampEmail, loadedThreads6, matchingTimestampUpdatedThread, matchingTimestampSMSThread_1, matchingTimestampSMS, loadedThreads7, matchingTimestampSMSUpdatedThread, orphanEmail, threadsBeforeOrphanUpdate, threadCountBefore, threadsAfterOrphanUpdate, threadCountAfter, upsertSMS, threadsAfterUpsertTest, upsertedThread, countResult, allThreads, filteredThreads, filteredCount, nonMatchingCount, emailTypeFilter, foundEmailByType, foundSmsByType, multiTypeFilter, foundEmailMulti, foundSmsMulti, foundChatMulti, assigneeFilter, foundAssigned, combinedFilter, foundCombined, mdbFilterCount, emptyMdbFilter, idsFilterResult, foundEmailById, foundSmsById, foundChatById, singleIdResult, idsCombinedResult, idsCountResult, emptyIdsResult, sortTestBaseTime, sortThread1, sortThread2, sortThread3, defaultSortResult, timestampSortResult, outboundSortResult, statusTestSMS1, statusTestFrom, statusTestThreads, statusTestThread, statusTestSMS2, threadAfterOutbound, statusTestSMS3, threadAfterNewInbound, readByTestSMS1, readByTestFrom, readByTestThreads, readByTestThread, threadAfterRead, readByTestSMS2, smsThreadAfterOutbound, readByTestSMS3, smsThreadAfterNewInbound, readByTestEmail1, readByEmailTestFrom, readByEmailTestThreads, readByEmailTestThread, emailThreadAfterRead, readByTestEmail2, emailThreadAfterOutbound, readByTestEmail3, emailThreadAfterNewInbound, narrowRangeTestSMS1, narrowRangeThreads, narrowRangeThread, narrowRangeFrom, narrowRangeTestSMS2, threadAfterNarrowBuild, narrowRangeTestEmail1, narrowRangeEmailThreads, narrowRangeEmailThread, narrowRangeEmailFrom, narrowRangeTestEmail2, emailThreadAfterNarrowBuild, zendeskTicketThread_1, zendeskTicketComment, zendeskThreads, zendeskThread, updatedZendeskThreads, updatedZendeskThread, zendeskThreadAfterRead, zendeskOutboundComment, zendeskThreadAfterOutbound, zendeskNewInboundComment, zendeskThreadAfterNewInbound, freshZendeskThreads, freshZendeskThread, zendeskNarrowRangeFrom, zendeskNarrowRangeOutbound, zendeskThreadAfterNarrowBuild, filteredZendeskThreads, multiTypeZendeskThreads, emptyZendeskTicketThread_1, allZendeskThreadsAfterEmpty, emptyZendeskThread, accessControlTicketThread_1, accessControlComment, adminZendeskThreads, accessControlThread, noTicketThreadsRole, accessControlTestEmail, accessControlTestUser, _b, sdkNoTicketAccess, _c, restrictedUserZendeskThreads, restrictedUserAllThreads, restrictedUserHasZendesk, remainingZendeskThreads, err_1;
|
|
61
60
|
var _d, _e, _f, _g, _h, _j, _k;
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
var _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
62
|
+
return __generator(this, function (_0) {
|
|
63
|
+
switch (_0.label) {
|
|
64
64
|
case 0:
|
|
65
65
|
(0, testing_1.log_header)("InboxThread Assignment Update Tests");
|
|
66
66
|
timestamp = Date.now();
|
|
@@ -71,7 +71,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
71
71
|
notificationEmailsDisabled: true
|
|
72
72
|
})];
|
|
73
73
|
case 1:
|
|
74
|
-
testUser =
|
|
74
|
+
testUser = _0.sent();
|
|
75
75
|
return [4 /*yield*/, sdk.api.endusers.createOne({
|
|
76
76
|
fname: "Test",
|
|
77
77
|
lname: "Patient",
|
|
@@ -80,7 +80,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
80
80
|
// Default thread fields following the test pattern
|
|
81
81
|
];
|
|
82
82
|
case 2:
|
|
83
|
-
testEnduser =
|
|
83
|
+
testEnduser = _0.sent();
|
|
84
84
|
defaultThreadFields = {
|
|
85
85
|
assignedTo: [],
|
|
86
86
|
enduserIds: [testEnduser.id],
|
|
@@ -93,7 +93,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
93
93
|
emailThreadId = emailSubject.toLowerCase().replaceAll("re:", "").replaceAll(" ", "");
|
|
94
94
|
return [4 /*yield*/, sdk.api.inbox_threads.createOne(__assign(__assign({}, defaultThreadFields), { type: "Email", title: "Test Email Assignment", threadId: emailThreadId }))];
|
|
95
95
|
case 3:
|
|
96
|
-
emailThread =
|
|
96
|
+
emailThread = _0.sent();
|
|
97
97
|
return [4 /*yield*/, sdk.api.emails.createOne({
|
|
98
98
|
subject: emailSubject,
|
|
99
99
|
textContent: "Test email content",
|
|
@@ -103,10 +103,10 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
103
103
|
logOnly: true,
|
|
104
104
|
})];
|
|
105
105
|
case 4:
|
|
106
|
-
testEmail =
|
|
106
|
+
testEmail = _0.sent();
|
|
107
107
|
return [4 /*yield*/, sdk.api.inbox_threads.createOne(__assign(__assign({}, defaultThreadFields), { type: "SMS", title: "Test SMS Assignment", threadId: "test-sms-thread-".concat(timestamp), phoneNumber: "+15555555555", enduserPhoneNumber: "+15555555556" }))];
|
|
108
108
|
case 5:
|
|
109
|
-
smsThread =
|
|
109
|
+
smsThread = _0.sent();
|
|
110
110
|
return [4 /*yield*/, sdk.api.sms_messages.createOne({
|
|
111
111
|
message: "Test SMS message",
|
|
112
112
|
enduserId: testEnduser.id,
|
|
@@ -117,7 +117,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
117
117
|
logOnly: true,
|
|
118
118
|
})];
|
|
119
119
|
case 6:
|
|
120
|
-
testSMS =
|
|
120
|
+
testSMS = _0.sent();
|
|
121
121
|
return [4 /*yield*/, sdk.api.chat_rooms.createOne({
|
|
122
122
|
title: "Test Assignment Room",
|
|
123
123
|
userIds: [testUser.id],
|
|
@@ -126,12 +126,12 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
126
126
|
// Create chat thread AFTER the chat message so timestamps align
|
|
127
127
|
];
|
|
128
128
|
case 7:
|
|
129
|
-
testChatRoom =
|
|
129
|
+
testChatRoom = _0.sent();
|
|
130
130
|
return [4 /*yield*/, sdk.api.inbox_threads.createOne(__assign(__assign({}, defaultThreadFields), { type: "Chat", title: "Test Chat Assignment", threadId: testChatRoom.id, timestamp: new Date() }))
|
|
131
131
|
// Add a chat message to make the room show up in threads (requires recentMessageSentAt)
|
|
132
132
|
];
|
|
133
133
|
case 8:
|
|
134
|
-
chatThread =
|
|
134
|
+
chatThread = _0.sent();
|
|
135
135
|
// Add a chat message to make the room show up in threads (requires recentMessageSentAt)
|
|
136
136
|
return [4 /*yield*/, sdk.api.chats.createOne({
|
|
137
137
|
roomId: testChatRoom.id,
|
|
@@ -143,15 +143,15 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
143
143
|
];
|
|
144
144
|
case 9:
|
|
145
145
|
// Add a chat message to make the room show up in threads (requires recentMessageSentAt)
|
|
146
|
-
|
|
146
|
+
_0.sent();
|
|
147
147
|
// Wait for the recentMessageSentAt to be set
|
|
148
148
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 500); })];
|
|
149
149
|
case 10:
|
|
150
150
|
// Wait for the recentMessageSentAt to be set
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
_0.sent();
|
|
152
|
+
_0.label = 11;
|
|
153
153
|
case 11:
|
|
154
|
-
|
|
154
|
+
_0.trys.push([11, , 187, 191]);
|
|
155
155
|
// Test 1: Email Assignment Updates
|
|
156
156
|
console.log("Testing email assignment updates...");
|
|
157
157
|
// Update email assignment
|
|
@@ -162,17 +162,17 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
162
162
|
];
|
|
163
163
|
case 12:
|
|
164
164
|
// Update email assignment
|
|
165
|
-
|
|
165
|
+
_0.sent();
|
|
166
166
|
// Wait for side effects to process
|
|
167
167
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1500); })
|
|
168
168
|
// Verify thread assignment was updated
|
|
169
169
|
];
|
|
170
170
|
case 13:
|
|
171
171
|
// Wait for side effects to process
|
|
172
|
-
|
|
172
|
+
_0.sent();
|
|
173
173
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
174
174
|
case 14:
|
|
175
|
-
loadedThreads =
|
|
175
|
+
loadedThreads = _0.sent();
|
|
176
176
|
updatedEmailThread = loadedThreads.threads.find(function (t) { return t.id === emailThread.id; });
|
|
177
177
|
(0, testing_1.assert)(!!updatedEmailThread, "Email thread should be found");
|
|
178
178
|
(0, testing_1.assert)(JSON.stringify(updatedEmailThread.assignedTo) === JSON.stringify([testUser.id]), "Email thread assignment should be updated");
|
|
@@ -183,13 +183,13 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
183
183
|
assignedTo: [testUser.id]
|
|
184
184
|
}, { replaceObjectFields: true })];
|
|
185
185
|
case 15:
|
|
186
|
-
|
|
186
|
+
_0.sent();
|
|
187
187
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1500); })];
|
|
188
188
|
case 16:
|
|
189
|
-
|
|
189
|
+
_0.sent();
|
|
190
190
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
191
191
|
case 17:
|
|
192
|
-
loadedThreads2 =
|
|
192
|
+
loadedThreads2 = _0.sent();
|
|
193
193
|
updatedSMSThread = loadedThreads2.threads.find(function (t) { return t.id === smsThread.id; });
|
|
194
194
|
(0, testing_1.assert)(!!updatedSMSThread, "SMS thread should be found");
|
|
195
195
|
(0, testing_1.assert)(JSON.stringify(updatedSMSThread.assignedTo) === JSON.stringify([testUser.id]), "SMS thread assignment should be updated");
|
|
@@ -200,13 +200,13 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
200
200
|
assignedTo: [testUser.id]
|
|
201
201
|
}, { replaceObjectFields: true })];
|
|
202
202
|
case 18:
|
|
203
|
-
|
|
203
|
+
_0.sent();
|
|
204
204
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1500); })];
|
|
205
205
|
case 19:
|
|
206
|
-
|
|
206
|
+
_0.sent();
|
|
207
207
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
208
208
|
case 20:
|
|
209
|
-
loadedThreads3 =
|
|
209
|
+
loadedThreads3 = _0.sent();
|
|
210
210
|
updatedChatThread = loadedThreads3.threads.find(function (t) { return t.id === chatThread.id; });
|
|
211
211
|
(0, testing_1.assert)(!!updatedChatThread, "Chat thread should be found");
|
|
212
212
|
(0, testing_1.assert)(JSON.stringify(updatedChatThread.assignedTo) === JSON.stringify([testUser.id]), "Chat thread assignment should be updated");
|
|
@@ -220,15 +220,15 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
220
220
|
}, { replaceObjectFields: true })];
|
|
221
221
|
case 21:
|
|
222
222
|
// Update email with same assignment (should not trigger thread update)
|
|
223
|
-
|
|
223
|
+
_0.sent();
|
|
224
224
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1500); })
|
|
225
225
|
// Verify thread assignment still correct (function should early return)
|
|
226
226
|
];
|
|
227
227
|
case 22:
|
|
228
|
-
|
|
228
|
+
_0.sent();
|
|
229
229
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
230
230
|
case 23:
|
|
231
|
-
loadedThreads4 =
|
|
231
|
+
loadedThreads4 = _0.sent();
|
|
232
232
|
unchangedThread = loadedThreads4.threads.find(function (t) { return t.id === emailThread.id; });
|
|
233
233
|
(0, testing_1.assert)(!!unchangedThread, "Email thread should still be found");
|
|
234
234
|
(0, testing_1.assert)(JSON.stringify(unchangedThread.assignedTo) === JSON.stringify([testUser.id]), "Thread assignment should remain unchanged");
|
|
@@ -239,13 +239,13 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
239
239
|
assignedTo: []
|
|
240
240
|
}, { replaceObjectFields: true })];
|
|
241
241
|
case 24:
|
|
242
|
-
|
|
242
|
+
_0.sent();
|
|
243
243
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1500); })];
|
|
244
244
|
case 25:
|
|
245
|
-
|
|
245
|
+
_0.sent();
|
|
246
246
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
247
247
|
case 26:
|
|
248
|
-
loadedThreads5 =
|
|
248
|
+
loadedThreads5 = _0.sent();
|
|
249
249
|
clearedAssignThread = loadedThreads5.threads.find(function (t) { return t.id === emailThread.id; });
|
|
250
250
|
(0, testing_1.assert)(!!clearedAssignThread, "Email thread should still be found");
|
|
251
251
|
(0, testing_1.assert)(JSON.stringify(clearedAssignThread.assignedTo) === JSON.stringify([]), "Thread assignment should be cleared");
|
|
@@ -258,7 +258,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
258
258
|
return [4 /*yield*/, sdk.api.inbox_threads.createOne(__assign(__assign({}, defaultThreadFields), { type: "Email", title: "Matching Timestamp Email Test", threadId: matchingTimestampThreadId, timestamp: fixedTimestamp // Same timestamp we'll use for message
|
|
259
259
|
}))];
|
|
260
260
|
case 27:
|
|
261
|
-
matchingTimestampEmailThread_1 =
|
|
261
|
+
matchingTimestampEmailThread_1 = _0.sent();
|
|
262
262
|
return [4 /*yield*/, sdk.api.emails.createOne({
|
|
263
263
|
subject: matchingTimestampSubject,
|
|
264
264
|
textContent: "Test email with matching timestamp",
|
|
@@ -272,20 +272,20 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
272
272
|
// Update email assignment - should work even with matching timestamps
|
|
273
273
|
];
|
|
274
274
|
case 28:
|
|
275
|
-
matchingTimestampEmail =
|
|
275
|
+
matchingTimestampEmail = _0.sent();
|
|
276
276
|
// Update email assignment - should work even with matching timestamps
|
|
277
277
|
return [4 /*yield*/, sdk.api.emails.updateOne(matchingTimestampEmail.id, {
|
|
278
278
|
assignedTo: [testUser.id]
|
|
279
279
|
}, { replaceObjectFields: true })];
|
|
280
280
|
case 29:
|
|
281
281
|
// Update email assignment - should work even with matching timestamps
|
|
282
|
-
|
|
282
|
+
_0.sent();
|
|
283
283
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1500); })];
|
|
284
284
|
case 30:
|
|
285
|
-
|
|
285
|
+
_0.sent();
|
|
286
286
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
287
287
|
case 31:
|
|
288
|
-
loadedThreads6 =
|
|
288
|
+
loadedThreads6 = _0.sent();
|
|
289
289
|
matchingTimestampUpdatedThread = loadedThreads6.threads.find(function (t) { return t.id === matchingTimestampEmailThread_1.id; });
|
|
290
290
|
(0, testing_1.assert)(!!matchingTimestampUpdatedThread, "Matching timestamp email thread should be found");
|
|
291
291
|
(0, testing_1.assert)(JSON.stringify(matchingTimestampUpdatedThread.assignedTo) === JSON.stringify([testUser.id]), "Email thread assignment should update even with matching timestamps");
|
|
@@ -295,7 +295,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
295
295
|
return [4 /*yield*/, sdk.api.inbox_threads.createOne(__assign(__assign({}, defaultThreadFields), { type: "SMS", title: "Matching Timestamp SMS Test", threadId: "matching-timestamp-sms-".concat(timestamp), phoneNumber: "+15555555557", enduserPhoneNumber: "+15555555558", timestamp: fixedTimestamp // Same timestamp we'll use for message
|
|
296
296
|
}))];
|
|
297
297
|
case 32:
|
|
298
|
-
matchingTimestampSMSThread_1 =
|
|
298
|
+
matchingTimestampSMSThread_1 = _0.sent();
|
|
299
299
|
return [4 /*yield*/, sdk.api.sms_messages.createOne({
|
|
300
300
|
message: "Matching timestamp SMS test",
|
|
301
301
|
enduserId: testEnduser.id,
|
|
@@ -309,20 +309,20 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
309
309
|
// Update SMS assignment - should work even with matching timestamps
|
|
310
310
|
];
|
|
311
311
|
case 33:
|
|
312
|
-
matchingTimestampSMS =
|
|
312
|
+
matchingTimestampSMS = _0.sent();
|
|
313
313
|
// Update SMS assignment - should work even with matching timestamps
|
|
314
314
|
return [4 /*yield*/, sdk.api.sms_messages.updateOne(matchingTimestampSMS.id, {
|
|
315
315
|
assignedTo: [testUser.id]
|
|
316
316
|
}, { replaceObjectFields: true })];
|
|
317
317
|
case 34:
|
|
318
318
|
// Update SMS assignment - should work even with matching timestamps
|
|
319
|
-
|
|
319
|
+
_0.sent();
|
|
320
320
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1500); })];
|
|
321
321
|
case 35:
|
|
322
|
-
|
|
322
|
+
_0.sent();
|
|
323
323
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
324
324
|
case 36:
|
|
325
|
-
loadedThreads7 =
|
|
325
|
+
loadedThreads7 = _0.sent();
|
|
326
326
|
matchingTimestampSMSUpdatedThread = loadedThreads7.threads.find(function (t) { return t.id === matchingTimestampSMSThread_1.id; });
|
|
327
327
|
(0, testing_1.assert)(!!matchingTimestampSMSUpdatedThread, "Matching timestamp SMS thread should be found");
|
|
328
328
|
(0, testing_1.assert)(JSON.stringify(matchingTimestampSMSUpdatedThread.assignedTo) === JSON.stringify([testUser.id]), "SMS thread assignment should update even with matching timestamps");
|
|
@@ -338,7 +338,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
338
338
|
];
|
|
339
339
|
case 37:
|
|
340
340
|
// Cleanup additional test resources
|
|
341
|
-
|
|
341
|
+
_0.sent();
|
|
342
342
|
// Test 8: Non-Existent Thread Case - Should NOT Create New Thread
|
|
343
343
|
console.log("Testing behavior when no matching thread exists...");
|
|
344
344
|
return [4 /*yield*/, sdk.api.emails.createOne({
|
|
@@ -352,10 +352,10 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
352
352
|
// Count existing threads before update
|
|
353
353
|
];
|
|
354
354
|
case 38:
|
|
355
|
-
orphanEmail =
|
|
355
|
+
orphanEmail = _0.sent();
|
|
356
356
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
357
357
|
case 39:
|
|
358
|
-
threadsBeforeOrphanUpdate =
|
|
358
|
+
threadsBeforeOrphanUpdate = _0.sent();
|
|
359
359
|
threadCountBefore = threadsBeforeOrphanUpdate.threads.length;
|
|
360
360
|
// Update assignment on email that has no matching thread
|
|
361
361
|
return [4 /*yield*/, sdk.api.emails.updateOne(orphanEmail.id, {
|
|
@@ -363,15 +363,15 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
363
363
|
}, { replaceObjectFields: true })];
|
|
364
364
|
case 40:
|
|
365
365
|
// Update assignment on email that has no matching thread
|
|
366
|
-
|
|
366
|
+
_0.sent();
|
|
367
367
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1500); })
|
|
368
368
|
// Verify no new thread was created (current expected behavior)
|
|
369
369
|
];
|
|
370
370
|
case 41:
|
|
371
|
-
|
|
371
|
+
_0.sent();
|
|
372
372
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
373
373
|
case 42:
|
|
374
|
-
threadsAfterOrphanUpdate =
|
|
374
|
+
threadsAfterOrphanUpdate = _0.sent();
|
|
375
375
|
threadCountAfter = threadsAfterOrphanUpdate.threads.length;
|
|
376
376
|
(0, testing_1.assert)(threadCountAfter === threadCountBefore, "No new thread should be created when no matching thread exists");
|
|
377
377
|
console.log("✅ Non-existent thread test passed - no thread created as expected");
|
|
@@ -388,15 +388,15 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
388
388
|
logOnly: true,
|
|
389
389
|
})];
|
|
390
390
|
case 43:
|
|
391
|
-
upsertSMS =
|
|
391
|
+
upsertSMS = _0.sent();
|
|
392
392
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1500); })
|
|
393
393
|
// Check if a new thread was created (would indicate upsert capability)
|
|
394
394
|
];
|
|
395
395
|
case 44:
|
|
396
|
-
|
|
396
|
+
_0.sent();
|
|
397
397
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
398
398
|
case 45:
|
|
399
|
-
threadsAfterUpsertTest =
|
|
399
|
+
threadsAfterUpsertTest = _0.sent();
|
|
400
400
|
upsertedThread = threadsAfterUpsertTest.threads.find(function (t) {
|
|
401
401
|
return t.type === "SMS" &&
|
|
402
402
|
t.phoneNumber === "+15555555559" &&
|
|
@@ -409,11 +409,11 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
409
409
|
return [4 /*yield*/, sdk.api.inbox_threads.deleteOne(upsertedThread.id)];
|
|
410
410
|
case 46:
|
|
411
411
|
// Cleanup the upserted thread
|
|
412
|
-
|
|
412
|
+
_0.sent();
|
|
413
413
|
return [3 /*break*/, 48];
|
|
414
414
|
case 47:
|
|
415
415
|
console.log("✅ No upsert capability - thread was not created (current behavior)");
|
|
416
|
-
|
|
416
|
+
_0.label = 48;
|
|
417
417
|
case 48:
|
|
418
418
|
// Cleanup orphan email and upsert SMS
|
|
419
419
|
return [4 /*yield*/, Promise.all([
|
|
@@ -424,27 +424,27 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
424
424
|
];
|
|
425
425
|
case 49:
|
|
426
426
|
// Cleanup orphan email and upsert SMS
|
|
427
|
-
|
|
427
|
+
_0.sent();
|
|
428
428
|
// Test 10: returnCount parameter - basic count
|
|
429
429
|
console.log("Testing load_threads returnCount parameter...");
|
|
430
430
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ returnCount: true })];
|
|
431
431
|
case 50:
|
|
432
|
-
countResult =
|
|
432
|
+
countResult = _0.sent();
|
|
433
433
|
(0, testing_1.assert)(typeof countResult.count === 'number', "returnCount should return a count field with a number");
|
|
434
434
|
(0, testing_1.assert)(countResult.threads === undefined, "returnCount should not return threads array");
|
|
435
435
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
436
436
|
case 51:
|
|
437
|
-
allThreads =
|
|
437
|
+
allThreads = _0.sent();
|
|
438
438
|
(0, testing_1.assert)(countResult.count === allThreads.threads.length, "Count (".concat(countResult.count, ") should match threads length (").concat(allThreads.threads.length, ")"));
|
|
439
439
|
console.log("✅ returnCount basic test passed");
|
|
440
440
|
// Test 11: returnCount with enduserIds filter
|
|
441
441
|
console.log("Testing returnCount with enduserIds filter...");
|
|
442
442
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ enduserIds: [testEnduser.id] })];
|
|
443
443
|
case 52:
|
|
444
|
-
filteredThreads =
|
|
444
|
+
filteredThreads = _0.sent();
|
|
445
445
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ enduserIds: [testEnduser.id], returnCount: true })];
|
|
446
446
|
case 53:
|
|
447
|
-
filteredCount =
|
|
447
|
+
filteredCount = _0.sent();
|
|
448
448
|
(0, testing_1.assert)(typeof filteredCount.count === 'number', "Filtered returnCount should return a count");
|
|
449
449
|
(0, testing_1.assert)(filteredCount.count === filteredThreads.threads.length, "Filtered count (".concat(filteredCount.count, ") should match filtered threads length (").concat(filteredThreads.threads.length, ")"));
|
|
450
450
|
console.log("✅ returnCount with enduserIds filter test passed");
|
|
@@ -455,7 +455,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
455
455
|
returnCount: true
|
|
456
456
|
})];
|
|
457
457
|
case 54:
|
|
458
|
-
nonMatchingCount =
|
|
458
|
+
nonMatchingCount = _0.sent();
|
|
459
459
|
(0, testing_1.assert)(nonMatchingCount.count === 0, "Non-matching filter count should be 0, got ".concat(nonMatchingCount.count));
|
|
460
460
|
console.log("✅ returnCount with non-matching filter test passed");
|
|
461
461
|
// Test 13: mdbFilter - filter by type
|
|
@@ -464,7 +464,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
464
464
|
mdbFilter: { type: 'Email' }
|
|
465
465
|
})];
|
|
466
466
|
case 55:
|
|
467
|
-
emailTypeFilter =
|
|
467
|
+
emailTypeFilter = _0.sent();
|
|
468
468
|
foundEmailByType = emailTypeFilter.threads.find(function (t) { return t.id === emailThread.id; });
|
|
469
469
|
foundSmsByType = emailTypeFilter.threads.find(function (t) { return t.id === smsThread.id; });
|
|
470
470
|
(0, testing_1.assert)(!!foundEmailByType, 'Email thread should be found when filtering by Email type');
|
|
@@ -476,7 +476,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
476
476
|
mdbFilter: { type: { $in: ['Email', 'SMS'] } }
|
|
477
477
|
})];
|
|
478
478
|
case 56:
|
|
479
|
-
multiTypeFilter =
|
|
479
|
+
multiTypeFilter = _0.sent();
|
|
480
480
|
foundEmailMulti = multiTypeFilter.threads.find(function (t) { return t.id === emailThread.id; });
|
|
481
481
|
foundSmsMulti = multiTypeFilter.threads.find(function (t) { return t.id === smsThread.id; });
|
|
482
482
|
foundChatMulti = multiTypeFilter.threads.find(function (t) { return t.id === chatThread.id; });
|
|
@@ -490,12 +490,12 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
490
490
|
return [4 /*yield*/, sdk.api.inbox_threads.updateOne(emailThread.id, { assignedTo: [testUser.id] })];
|
|
491
491
|
case 57:
|
|
492
492
|
// First assign the email thread (may already be assigned from earlier tests)
|
|
493
|
-
|
|
493
|
+
_0.sent();
|
|
494
494
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({
|
|
495
495
|
mdbFilter: { assignedTo: testUser.id }
|
|
496
496
|
})];
|
|
497
497
|
case 58:
|
|
498
|
-
assigneeFilter =
|
|
498
|
+
assigneeFilter = _0.sent();
|
|
499
499
|
foundAssigned = assigneeFilter.threads.find(function (t) { return t.id === emailThread.id; });
|
|
500
500
|
(0, testing_1.assert)(!!foundAssigned, 'Email thread should be found when filtering by assignee');
|
|
501
501
|
console.log("✅ mdbFilter assignedTo filter test passed");
|
|
@@ -506,7 +506,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
506
506
|
mdbFilter: { type: 'Email' }
|
|
507
507
|
})];
|
|
508
508
|
case 59:
|
|
509
|
-
combinedFilter =
|
|
509
|
+
combinedFilter = _0.sent();
|
|
510
510
|
foundCombined = combinedFilter.threads.find(function (t) { return t.id === emailThread.id; });
|
|
511
511
|
(0, testing_1.assert)(!!foundCombined, 'Email thread should be found with combined filters');
|
|
512
512
|
console.log("✅ mdbFilter combined filter test passed");
|
|
@@ -517,9 +517,9 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
517
517
|
returnCount: true
|
|
518
518
|
})];
|
|
519
519
|
case 60:
|
|
520
|
-
mdbFilterCount =
|
|
520
|
+
mdbFilterCount = _0.sent();
|
|
521
521
|
(0, testing_1.assert)(typeof mdbFilterCount.count === 'number', 'mdbFilter with returnCount should return count');
|
|
522
|
-
(0, testing_1.assert)(((
|
|
522
|
+
(0, testing_1.assert)(((_l = mdbFilterCount.count) !== null && _l !== void 0 ? _l : 0) >= 1, 'Count should be at least 1 for Email type');
|
|
523
523
|
console.log("✅ mdbFilter with returnCount test passed");
|
|
524
524
|
// Test 18: mdbFilter with empty object (should return all)
|
|
525
525
|
console.log("Testing mdbFilter with empty object...");
|
|
@@ -527,7 +527,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
527
527
|
mdbFilter: {}
|
|
528
528
|
})];
|
|
529
529
|
case 61:
|
|
530
|
-
emptyMdbFilter =
|
|
530
|
+
emptyMdbFilter = _0.sent();
|
|
531
531
|
(0, testing_1.assert)(emptyMdbFilter.threads.length > 0, 'Empty mdbFilter should return threads');
|
|
532
532
|
console.log("✅ mdbFilter empty object test passed");
|
|
533
533
|
// Test 19: ids filter - filter by specific thread ids
|
|
@@ -536,7 +536,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
536
536
|
ids: [emailThread.id, smsThread.id]
|
|
537
537
|
})];
|
|
538
538
|
case 62:
|
|
539
|
-
idsFilterResult =
|
|
539
|
+
idsFilterResult = _0.sent();
|
|
540
540
|
(0, testing_1.assert)(idsFilterResult.threads.length === 2, "ids filter should return exactly 2 threads, got ".concat(idsFilterResult.threads.length));
|
|
541
541
|
foundEmailById = idsFilterResult.threads.find(function (t) { return t.id === emailThread.id; });
|
|
542
542
|
foundSmsById = idsFilterResult.threads.find(function (t) { return t.id === smsThread.id; });
|
|
@@ -551,7 +551,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
551
551
|
ids: [emailThread.id]
|
|
552
552
|
})];
|
|
553
553
|
case 63:
|
|
554
|
-
singleIdResult =
|
|
554
|
+
singleIdResult = _0.sent();
|
|
555
555
|
(0, testing_1.assert)(singleIdResult.threads.length === 1, "Single id filter should return exactly 1 thread, got ".concat(singleIdResult.threads.length));
|
|
556
556
|
(0, testing_1.assert)(singleIdResult.threads[0].id === emailThread.id, 'Should return the correct thread');
|
|
557
557
|
console.log("✅ ids filter single id test passed");
|
|
@@ -562,7 +562,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
562
562
|
mdbFilter: { type: 'Email' }
|
|
563
563
|
})];
|
|
564
564
|
case 64:
|
|
565
|
-
idsCombinedResult =
|
|
565
|
+
idsCombinedResult = _0.sent();
|
|
566
566
|
(0, testing_1.assert)(idsCombinedResult.threads.length === 1, "Combined ids + mdbFilter should return 1 thread, got ".concat(idsCombinedResult.threads.length));
|
|
567
567
|
(0, testing_1.assert)(idsCombinedResult.threads[0].id === emailThread.id, 'Should return only the email thread');
|
|
568
568
|
console.log("✅ ids filter combined with mdbFilter test passed");
|
|
@@ -573,7 +573,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
573
573
|
returnCount: true
|
|
574
574
|
})];
|
|
575
575
|
case 65:
|
|
576
|
-
idsCountResult =
|
|
576
|
+
idsCountResult = _0.sent();
|
|
577
577
|
(0, testing_1.assert)(idsCountResult.count === 3, "ids filter with returnCount should return 3, got ".concat(idsCountResult.count));
|
|
578
578
|
console.log("✅ ids filter with returnCount test passed");
|
|
579
579
|
// Test 23: ids filter with empty array (should return all)
|
|
@@ -582,7 +582,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
582
582
|
ids: []
|
|
583
583
|
})];
|
|
584
584
|
case 66:
|
|
585
|
-
emptyIdsResult =
|
|
585
|
+
emptyIdsResult = _0.sent();
|
|
586
586
|
(0, testing_1.assert)(emptyIdsResult.threads.length >= 3, 'Empty ids array should not filter (return all threads)');
|
|
587
587
|
console.log("✅ ids filter empty array test passed");
|
|
588
588
|
// Test 24: sortBy parameter - default behavior (timestamp)
|
|
@@ -590,20 +590,20 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
590
590
|
sortTestBaseTime = Date.now();
|
|
591
591
|
return [4 /*yield*/, sdk.api.inbox_threads.createOne(__assign(__assign({}, defaultThreadFields), { type: "SMS", title: "Sort Test Thread 1", threadId: "sort-test-1-".concat(timestamp), phoneNumber: "+15555550001", enduserPhoneNumber: "+15555550002", timestamp: new Date(sortTestBaseTime - 3000), outboundTimestamp: new Date(sortTestBaseTime) }))];
|
|
592
592
|
case 67:
|
|
593
|
-
sortThread1 =
|
|
593
|
+
sortThread1 = _0.sent();
|
|
594
594
|
return [4 /*yield*/, sdk.api.inbox_threads.createOne(__assign(__assign({}, defaultThreadFields), { type: "SMS", title: "Sort Test Thread 2", threadId: "sort-test-2-".concat(timestamp), phoneNumber: "+15555550003", enduserPhoneNumber: "+15555550004", timestamp: new Date(sortTestBaseTime - 1000), outboundTimestamp: new Date(sortTestBaseTime - 3000) }))];
|
|
595
595
|
case 68:
|
|
596
|
-
sortThread2 =
|
|
596
|
+
sortThread2 = _0.sent();
|
|
597
597
|
return [4 /*yield*/, sdk.api.inbox_threads.createOne(__assign(__assign({}, defaultThreadFields), { type: "SMS", title: "Sort Test Thread 3", threadId: "sort-test-3-".concat(timestamp), phoneNumber: "+15555550005", enduserPhoneNumber: "+15555550006", timestamp: new Date(sortTestBaseTime - 2000), outboundTimestamp: new Date(sortTestBaseTime - 2000) }))
|
|
598
598
|
// Test default sort (should be by timestamp descending)
|
|
599
599
|
];
|
|
600
600
|
case 69:
|
|
601
|
-
sortThread3 =
|
|
601
|
+
sortThread3 = _0.sent();
|
|
602
602
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({
|
|
603
603
|
ids: [sortThread1.id, sortThread2.id, sortThread3.id]
|
|
604
604
|
})];
|
|
605
605
|
case 70:
|
|
606
|
-
defaultSortResult =
|
|
606
|
+
defaultSortResult = _0.sent();
|
|
607
607
|
(0, testing_1.assert)(defaultSortResult.threads.length === 3, 'Should return 3 sort test threads');
|
|
608
608
|
(0, testing_1.assert)(defaultSortResult.threads[0].id === sortThread2.id, 'Default sort: newest timestamp should be first');
|
|
609
609
|
(0, testing_1.assert)(defaultSortResult.threads[1].id === sortThread3.id, 'Default sort: middle timestamp should be second');
|
|
@@ -616,7 +616,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
616
616
|
sortBy: 'timestamp'
|
|
617
617
|
})];
|
|
618
618
|
case 71:
|
|
619
|
-
timestampSortResult =
|
|
619
|
+
timestampSortResult = _0.sent();
|
|
620
620
|
(0, testing_1.assert)(timestampSortResult.threads[0].id === sortThread2.id, 'Explicit timestamp sort: newest should be first');
|
|
621
621
|
(0, testing_1.assert)(timestampSortResult.threads[1].id === sortThread3.id, 'Explicit timestamp sort: middle should be second');
|
|
622
622
|
(0, testing_1.assert)(timestampSortResult.threads[2].id === sortThread1.id, 'Explicit timestamp sort: oldest should be last');
|
|
@@ -628,7 +628,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
628
628
|
sortBy: 'outboundTimestamp'
|
|
629
629
|
})];
|
|
630
630
|
case 72:
|
|
631
|
-
outboundSortResult =
|
|
631
|
+
outboundSortResult = _0.sent();
|
|
632
632
|
(0, testing_1.assert)(outboundSortResult.threads[0].id === sortThread1.id, 'OutboundTimestamp sort: newest outbound should be first');
|
|
633
633
|
(0, testing_1.assert)(outboundSortResult.threads[1].id === sortThread3.id, 'OutboundTimestamp sort: middle outbound should be second');
|
|
634
634
|
(0, testing_1.assert)(outboundSortResult.threads[2].id === sortThread2.id, 'OutboundTimestamp sort: oldest outbound should be last');
|
|
@@ -645,7 +645,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
645
645
|
];
|
|
646
646
|
case 73:
|
|
647
647
|
// Cleanup sort test threads
|
|
648
|
-
|
|
648
|
+
_0.sent();
|
|
649
649
|
// ========== InboxStatus Preservation Tests ==========
|
|
650
650
|
// These tests verify that outbound messages do NOT reset inboxStatus
|
|
651
651
|
// Test 27: Outbound SMS should NOT reset inboxStatus
|
|
@@ -661,17 +661,17 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
661
661
|
// Build threads using reset_threads + build_threads pattern
|
|
662
662
|
];
|
|
663
663
|
case 74:
|
|
664
|
-
statusTestSMS1 =
|
|
664
|
+
statusTestSMS1 = _0.sent();
|
|
665
665
|
statusTestFrom = new Date(Date.now() - 60000);
|
|
666
666
|
return [4 /*yield*/, sdk.api.inbox_threads.reset_threads()];
|
|
667
667
|
case 75:
|
|
668
|
-
|
|
668
|
+
_0.sent();
|
|
669
669
|
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: statusTestFrom, to: new Date() })];
|
|
670
670
|
case 76:
|
|
671
|
-
|
|
671
|
+
_0.sent();
|
|
672
672
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
673
673
|
case 77:
|
|
674
|
-
statusTestThreads =
|
|
674
|
+
statusTestThreads = _0.sent();
|
|
675
675
|
statusTestThread = statusTestThreads.threads.find(function (t) {
|
|
676
676
|
return t.type === 'SMS' && t.enduserIds.includes(testEnduser.id) && t.phoneNumber === "+15555559999";
|
|
677
677
|
});
|
|
@@ -683,7 +683,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
683
683
|
];
|
|
684
684
|
case 78:
|
|
685
685
|
// Update thread status to "Resolved"
|
|
686
|
-
|
|
686
|
+
_0.sent();
|
|
687
687
|
return [4 /*yield*/, sdk.api.sms_messages.createOne({
|
|
688
688
|
message: "Outbound reply - should not reset status",
|
|
689
689
|
enduserId: testEnduser.id,
|
|
@@ -695,15 +695,15 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
695
695
|
// Rebuild threads - status should remain "Resolved"
|
|
696
696
|
];
|
|
697
697
|
case 79:
|
|
698
|
-
statusTestSMS2 =
|
|
698
|
+
statusTestSMS2 = _0.sent();
|
|
699
699
|
// Rebuild threads - status should remain "Resolved"
|
|
700
700
|
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: statusTestFrom, to: new Date() })];
|
|
701
701
|
case 80:
|
|
702
702
|
// Rebuild threads - status should remain "Resolved"
|
|
703
|
-
|
|
703
|
+
_0.sent();
|
|
704
704
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [statusTestThread.id] })];
|
|
705
705
|
case 81:
|
|
706
|
-
threadAfterOutbound = (
|
|
706
|
+
threadAfterOutbound = (_0.sent()).threads[0];
|
|
707
707
|
(0, testing_1.assert)(threadAfterOutbound.inboxStatus === 'Resolved', "Status should remain 'Resolved' after outbound message, got '".concat(threadAfterOutbound.inboxStatus, "'"));
|
|
708
708
|
(0, testing_1.assert)(!!threadAfterOutbound.outboundTimestamp, "outboundTimestamp should be set after outbound message");
|
|
709
709
|
console.log("✅ Outbound SMS does NOT reset inboxStatus test passed");
|
|
@@ -713,7 +713,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
713
713
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1100); })];
|
|
714
714
|
case 82:
|
|
715
715
|
// Wait to ensure ObjectId timestamps are in different seconds (MongoDB ObjectIds have second-level precision)
|
|
716
|
-
|
|
716
|
+
_0.sent();
|
|
717
717
|
return [4 /*yield*/, sdk.api.sms_messages.createOne({
|
|
718
718
|
message: "New inbound - should update status",
|
|
719
719
|
enduserId: testEnduser.id,
|
|
@@ -726,15 +726,15 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
726
726
|
// Rebuild threads - status SHOULD be updated from new inbound
|
|
727
727
|
];
|
|
728
728
|
case 83:
|
|
729
|
-
statusTestSMS3 =
|
|
729
|
+
statusTestSMS3 = _0.sent();
|
|
730
730
|
// Rebuild threads - status SHOULD be updated from new inbound
|
|
731
731
|
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: statusTestFrom, to: new Date() })];
|
|
732
732
|
case 84:
|
|
733
733
|
// Rebuild threads - status SHOULD be updated from new inbound
|
|
734
|
-
|
|
734
|
+
_0.sent();
|
|
735
735
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [statusTestThread.id] })];
|
|
736
736
|
case 85:
|
|
737
|
-
threadAfterNewInbound = (
|
|
737
|
+
threadAfterNewInbound = (_0.sent()).threads[0];
|
|
738
738
|
(0, testing_1.assert)(threadAfterNewInbound.inboxStatus === 'New', "Status SHOULD be 'New' after new inbound message, got '".concat(threadAfterNewInbound.inboxStatus, "'"));
|
|
739
739
|
console.log("✅ New inbound SMS DOES update inboxStatus test passed");
|
|
740
740
|
// Cleanup status preservation test resources
|
|
@@ -750,7 +750,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
750
750
|
];
|
|
751
751
|
case 86:
|
|
752
752
|
// Cleanup status preservation test resources
|
|
753
|
-
|
|
753
|
+
_0.sent();
|
|
754
754
|
// ========== ReadBy Preservation Tests ==========
|
|
755
755
|
// These tests verify that outbound messages do NOT reset readBy
|
|
756
756
|
// Test 29: Outbound SMS should NOT reset readBy
|
|
@@ -766,34 +766,34 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
766
766
|
// Build threads
|
|
767
767
|
];
|
|
768
768
|
case 87:
|
|
769
|
-
readByTestSMS1 =
|
|
769
|
+
readByTestSMS1 = _0.sent();
|
|
770
770
|
readByTestFrom = new Date(Date.now() - 60000);
|
|
771
771
|
return [4 /*yield*/, sdk.api.inbox_threads.reset_threads()];
|
|
772
772
|
case 88:
|
|
773
|
-
|
|
773
|
+
_0.sent();
|
|
774
774
|
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: readByTestFrom, to: new Date() })];
|
|
775
775
|
case 89:
|
|
776
|
-
|
|
776
|
+
_0.sent();
|
|
777
777
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
778
778
|
case 90:
|
|
779
|
-
readByTestThreads =
|
|
779
|
+
readByTestThreads = _0.sent();
|
|
780
780
|
readByTestThread = readByTestThreads.threads.find(function (t) {
|
|
781
781
|
return t.type === 'SMS' && t.enduserIds.includes(testEnduser.id) && t.phoneNumber === "+15555558888";
|
|
782
782
|
});
|
|
783
783
|
(0, testing_1.assert)(!!readByTestThread, "readBy test SMS thread should be created");
|
|
784
784
|
// Mark thread as read
|
|
785
785
|
return [4 /*yield*/, sdk.api.inbox_threads.updateOne(readByTestThread.id, {
|
|
786
|
-
readBy: (
|
|
786
|
+
readBy: (_d = {}, _d[sdk.userInfo.id] = new Date(), _d)
|
|
787
787
|
})
|
|
788
788
|
// Verify thread is marked as read
|
|
789
789
|
];
|
|
790
790
|
case 91:
|
|
791
791
|
// Mark thread as read
|
|
792
|
-
|
|
792
|
+
_0.sent();
|
|
793
793
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [readByTestThread.id] })];
|
|
794
794
|
case 92:
|
|
795
|
-
threadAfterRead = (
|
|
796
|
-
(0, testing_1.assert)(!!((
|
|
795
|
+
threadAfterRead = (_0.sent()).threads[0];
|
|
796
|
+
(0, testing_1.assert)(!!((_m = threadAfterRead.readBy) === null || _m === void 0 ? void 0 : _m[sdk.userInfo.id]), "Thread should be marked as read");
|
|
797
797
|
return [4 /*yield*/, sdk.api.sms_messages.createOne({
|
|
798
798
|
message: "Outbound reply - should not reset readBy",
|
|
799
799
|
enduserId: testEnduser.id,
|
|
@@ -805,16 +805,16 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
805
805
|
// Rebuild threads - readBy should remain set
|
|
806
806
|
];
|
|
807
807
|
case 93:
|
|
808
|
-
readByTestSMS2 =
|
|
808
|
+
readByTestSMS2 = _0.sent();
|
|
809
809
|
// Rebuild threads - readBy should remain set
|
|
810
810
|
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: readByTestFrom, to: new Date() })];
|
|
811
811
|
case 94:
|
|
812
812
|
// Rebuild threads - readBy should remain set
|
|
813
|
-
|
|
813
|
+
_0.sent();
|
|
814
814
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [readByTestThread.id] })];
|
|
815
815
|
case 95:
|
|
816
|
-
smsThreadAfterOutbound = (
|
|
817
|
-
(0, testing_1.assert)(!!((
|
|
816
|
+
smsThreadAfterOutbound = (_0.sent()).threads[0];
|
|
817
|
+
(0, testing_1.assert)(!!((_o = smsThreadAfterOutbound.readBy) === null || _o === void 0 ? void 0 : _o[sdk.userInfo.id]), "readBy should remain set after outbound message, got ".concat(JSON.stringify(smsThreadAfterOutbound.readBy)));
|
|
818
818
|
(0, testing_1.assert)(!!smsThreadAfterOutbound.outboundTimestamp, "outboundTimestamp should be set after outbound message");
|
|
819
819
|
console.log("✅ Outbound SMS does NOT reset readBy test passed");
|
|
820
820
|
// Test 30: New inbound SMS SHOULD clear readBy
|
|
@@ -823,7 +823,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
823
823
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1100); })];
|
|
824
824
|
case 96:
|
|
825
825
|
// Wait for different timestamp
|
|
826
|
-
|
|
826
|
+
_0.sent();
|
|
827
827
|
return [4 /*yield*/, sdk.api.sms_messages.createOne({
|
|
828
828
|
message: "New inbound - should clear readBy",
|
|
829
829
|
enduserId: testEnduser.id,
|
|
@@ -835,16 +835,16 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
835
835
|
// Rebuild threads - readBy SHOULD be cleared
|
|
836
836
|
];
|
|
837
837
|
case 97:
|
|
838
|
-
readByTestSMS3 =
|
|
838
|
+
readByTestSMS3 = _0.sent();
|
|
839
839
|
// Rebuild threads - readBy SHOULD be cleared
|
|
840
840
|
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: readByTestFrom, to: new Date() })];
|
|
841
841
|
case 98:
|
|
842
842
|
// Rebuild threads - readBy SHOULD be cleared
|
|
843
|
-
|
|
843
|
+
_0.sent();
|
|
844
844
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [readByTestThread.id] })];
|
|
845
845
|
case 99:
|
|
846
|
-
smsThreadAfterNewInbound = (
|
|
847
|
-
(0, testing_1.assert)(!((
|
|
846
|
+
smsThreadAfterNewInbound = (_0.sent()).threads[0];
|
|
847
|
+
(0, testing_1.assert)(!((_p = smsThreadAfterNewInbound.readBy) === null || _p === void 0 ? void 0 : _p[sdk.userInfo.id]), "readBy SHOULD be cleared after new inbound message, got ".concat(JSON.stringify(smsThreadAfterNewInbound.readBy)));
|
|
848
848
|
console.log("✅ New inbound SMS DOES clear readBy test passed");
|
|
849
849
|
// Cleanup SMS readBy tests
|
|
850
850
|
return [4 /*yield*/, Promise.all([
|
|
@@ -857,7 +857,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
857
857
|
];
|
|
858
858
|
case 100:
|
|
859
859
|
// Cleanup SMS readBy tests
|
|
860
|
-
|
|
860
|
+
_0.sent();
|
|
861
861
|
// Test 31: Outbound Email should NOT reset readBy
|
|
862
862
|
console.log("Testing outbound Email should NOT reset readBy...");
|
|
863
863
|
return [4 /*yield*/, sdk.api.emails.createOne({
|
|
@@ -870,34 +870,34 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
870
870
|
// Build threads
|
|
871
871
|
];
|
|
872
872
|
case 101:
|
|
873
|
-
readByTestEmail1 =
|
|
873
|
+
readByTestEmail1 = _0.sent();
|
|
874
874
|
readByEmailTestFrom = new Date(Date.now() - 60000);
|
|
875
875
|
return [4 /*yield*/, sdk.api.inbox_threads.reset_threads()];
|
|
876
876
|
case 102:
|
|
877
|
-
|
|
877
|
+
_0.sent();
|
|
878
878
|
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: readByEmailTestFrom, to: new Date() })];
|
|
879
879
|
case 103:
|
|
880
|
-
|
|
880
|
+
_0.sent();
|
|
881
881
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
882
882
|
case 104:
|
|
883
|
-
readByEmailTestThreads =
|
|
883
|
+
readByEmailTestThreads = _0.sent();
|
|
884
884
|
readByEmailTestThread = readByEmailTestThreads.threads.find(function (t) {
|
|
885
885
|
return t.type === 'Email' && t.enduserIds.includes(testEnduser.id);
|
|
886
886
|
});
|
|
887
887
|
(0, testing_1.assert)(!!readByEmailTestThread, "readBy test Email thread should be created");
|
|
888
888
|
// Mark thread as read
|
|
889
889
|
return [4 /*yield*/, sdk.api.inbox_threads.updateOne(readByEmailTestThread.id, {
|
|
890
|
-
readBy: (
|
|
890
|
+
readBy: (_e = {}, _e[sdk.userInfo.id] = new Date(), _e)
|
|
891
891
|
})
|
|
892
892
|
// Verify thread is marked as read
|
|
893
893
|
];
|
|
894
894
|
case 105:
|
|
895
895
|
// Mark thread as read
|
|
896
|
-
|
|
896
|
+
_0.sent();
|
|
897
897
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [readByEmailTestThread.id] })];
|
|
898
898
|
case 106:
|
|
899
|
-
emailThreadAfterRead = (
|
|
900
|
-
(0, testing_1.assert)(!!((
|
|
899
|
+
emailThreadAfterRead = (_0.sent()).threads[0];
|
|
900
|
+
(0, testing_1.assert)(!!((_q = emailThreadAfterRead.readBy) === null || _q === void 0 ? void 0 : _q[sdk.userInfo.id]), "Email thread should be marked as read");
|
|
901
901
|
return [4 /*yield*/, sdk.api.emails.createOne({
|
|
902
902
|
subject: "Re: Inbound test email for readBy test",
|
|
903
903
|
textContent: "Outbound reply - should not reset readBy",
|
|
@@ -908,16 +908,16 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
908
908
|
// Rebuild threads - readBy should remain set
|
|
909
909
|
];
|
|
910
910
|
case 107:
|
|
911
|
-
readByTestEmail2 =
|
|
911
|
+
readByTestEmail2 = _0.sent();
|
|
912
912
|
// Rebuild threads - readBy should remain set
|
|
913
913
|
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: readByEmailTestFrom, to: new Date() })];
|
|
914
914
|
case 108:
|
|
915
915
|
// Rebuild threads - readBy should remain set
|
|
916
|
-
|
|
916
|
+
_0.sent();
|
|
917
917
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [readByEmailTestThread.id] })];
|
|
918
918
|
case 109:
|
|
919
|
-
emailThreadAfterOutbound = (
|
|
920
|
-
(0, testing_1.assert)(!!((
|
|
919
|
+
emailThreadAfterOutbound = (_0.sent()).threads[0];
|
|
920
|
+
(0, testing_1.assert)(!!((_r = emailThreadAfterOutbound.readBy) === null || _r === void 0 ? void 0 : _r[sdk.userInfo.id]), "Email readBy should remain set after outbound message, got ".concat(JSON.stringify(emailThreadAfterOutbound.readBy)));
|
|
921
921
|
(0, testing_1.assert)(!!emailThreadAfterOutbound.outboundTimestamp, "outboundTimestamp should be set after outbound email");
|
|
922
922
|
console.log("✅ Outbound Email does NOT reset readBy test passed");
|
|
923
923
|
// Test 32: New inbound Email SHOULD clear readBy
|
|
@@ -926,7 +926,7 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
926
926
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1100); })];
|
|
927
927
|
case 110:
|
|
928
928
|
// Wait for different timestamp
|
|
929
|
-
|
|
929
|
+
_0.sent();
|
|
930
930
|
return [4 /*yield*/, sdk.api.emails.createOne({
|
|
931
931
|
subject: "Re: Inbound test email for readBy test",
|
|
932
932
|
textContent: "New inbound - should clear readBy",
|
|
@@ -937,16 +937,16 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
937
937
|
// Rebuild threads - readBy SHOULD be cleared
|
|
938
938
|
];
|
|
939
939
|
case 111:
|
|
940
|
-
readByTestEmail3 =
|
|
940
|
+
readByTestEmail3 = _0.sent();
|
|
941
941
|
// Rebuild threads - readBy SHOULD be cleared
|
|
942
942
|
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: readByEmailTestFrom, to: new Date() })];
|
|
943
943
|
case 112:
|
|
944
944
|
// Rebuild threads - readBy SHOULD be cleared
|
|
945
|
-
|
|
945
|
+
_0.sent();
|
|
946
946
|
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [readByEmailTestThread.id] })];
|
|
947
947
|
case 113:
|
|
948
|
-
emailThreadAfterNewInbound = (
|
|
949
|
-
(0, testing_1.assert)(!((
|
|
948
|
+
emailThreadAfterNewInbound = (_0.sent()).threads[0];
|
|
949
|
+
(0, testing_1.assert)(!((_s = emailThreadAfterNewInbound.readBy) === null || _s === void 0 ? void 0 : _s[sdk.userInfo.id]), "Email readBy SHOULD be cleared after new inbound message, got ".concat(JSON.stringify(emailThreadAfterNewInbound.readBy)));
|
|
950
950
|
console.log("✅ New inbound Email DOES clear readBy test passed");
|
|
951
951
|
// Cleanup Email readBy tests
|
|
952
952
|
return [4 /*yield*/, Promise.all([
|
|
@@ -954,14 +954,530 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
954
954
|
sdk.api.emails.deleteOne(readByTestEmail2.id),
|
|
955
955
|
sdk.api.emails.deleteOne(readByTestEmail3.id),
|
|
956
956
|
sdk.api.inbox_threads.deleteOne(readByEmailTestThread.id),
|
|
957
|
-
])
|
|
957
|
+
])
|
|
958
|
+
// Test 33: Outbound SMS with NARROW time range should NOT reset readBy
|
|
959
|
+
// This tests the production scenario where incremental builds only include recent messages
|
|
960
|
+
];
|
|
958
961
|
case 114:
|
|
959
962
|
// Cleanup Email readBy tests
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
+
_0.sent();
|
|
964
|
+
// Test 33: Outbound SMS with NARROW time range should NOT reset readBy
|
|
965
|
+
// This tests the production scenario where incremental builds only include recent messages
|
|
966
|
+
console.log("Testing outbound SMS with NARROW time range should NOT reset readBy...");
|
|
967
|
+
return [4 /*yield*/, sdk.api.sms_messages.createOne({
|
|
968
|
+
message: "Inbound for narrow range test",
|
|
969
|
+
enduserId: testEnduser.id,
|
|
970
|
+
inbound: true,
|
|
971
|
+
phoneNumber: "+15555559999",
|
|
972
|
+
enduserPhoneNumber: "+15555559998",
|
|
973
|
+
logOnly: true,
|
|
974
|
+
})
|
|
975
|
+
// Build threads with wide range (includes inbound)
|
|
976
|
+
];
|
|
963
977
|
case 115:
|
|
964
|
-
|
|
978
|
+
narrowRangeTestSMS1 = _0.sent();
|
|
979
|
+
// Build threads with wide range (includes inbound)
|
|
980
|
+
return [4 /*yield*/, sdk.api.inbox_threads.reset_threads()];
|
|
981
|
+
case 116:
|
|
982
|
+
// Build threads with wide range (includes inbound)
|
|
983
|
+
_0.sent();
|
|
984
|
+
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: new Date(Date.now() - 60000), to: new Date() })];
|
|
985
|
+
case 117:
|
|
986
|
+
_0.sent();
|
|
987
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
988
|
+
case 118:
|
|
989
|
+
narrowRangeThreads = _0.sent();
|
|
990
|
+
narrowRangeThread = narrowRangeThreads.threads.find(function (t) {
|
|
991
|
+
return t.type === 'SMS' && t.phoneNumber === "+15555559999";
|
|
992
|
+
});
|
|
993
|
+
(0, testing_1.assert)(!!narrowRangeThread, "Narrow range test thread should exist");
|
|
994
|
+
// Mark thread as read
|
|
995
|
+
return [4 /*yield*/, sdk.api.inbox_threads.updateOne(narrowRangeThread.id, {
|
|
996
|
+
readBy: (_f = {}, _f[sdk.userInfo.id] = new Date(), _f)
|
|
997
|
+
})
|
|
998
|
+
// Wait and capture a timestamp AFTER the inbound was created
|
|
999
|
+
];
|
|
1000
|
+
case 119:
|
|
1001
|
+
// Mark thread as read
|
|
1002
|
+
_0.sent();
|
|
1003
|
+
// Wait and capture a timestamp AFTER the inbound was created
|
|
1004
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })];
|
|
1005
|
+
case 120:
|
|
1006
|
+
// Wait and capture a timestamp AFTER the inbound was created
|
|
1007
|
+
_0.sent();
|
|
1008
|
+
narrowRangeFrom = new Date();
|
|
1009
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })
|
|
1010
|
+
// Create outbound message (after narrowRangeFrom)
|
|
1011
|
+
];
|
|
1012
|
+
case 121:
|
|
1013
|
+
_0.sent();
|
|
1014
|
+
return [4 /*yield*/, sdk.api.sms_messages.createOne({
|
|
1015
|
+
message: "Outbound for narrow range test",
|
|
1016
|
+
enduserId: testEnduser.id,
|
|
1017
|
+
inbound: false,
|
|
1018
|
+
phoneNumber: "+15555559999",
|
|
1019
|
+
enduserPhoneNumber: "+15555559998",
|
|
1020
|
+
logOnly: true,
|
|
1021
|
+
})
|
|
1022
|
+
// Rebuild with NARROW range that excludes the original inbound
|
|
1023
|
+
];
|
|
1024
|
+
case 122:
|
|
1025
|
+
narrowRangeTestSMS2 = _0.sent();
|
|
1026
|
+
// Rebuild with NARROW range that excludes the original inbound
|
|
1027
|
+
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: narrowRangeFrom, to: new Date() })
|
|
1028
|
+
// readBy should still be preserved (not reset)
|
|
1029
|
+
];
|
|
1030
|
+
case 123:
|
|
1031
|
+
// Rebuild with NARROW range that excludes the original inbound
|
|
1032
|
+
_0.sent();
|
|
1033
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [narrowRangeThread.id] })];
|
|
1034
|
+
case 124:
|
|
1035
|
+
threadAfterNarrowBuild = (_0.sent()).threads[0];
|
|
1036
|
+
(0, testing_1.assert)(!!((_t = threadAfterNarrowBuild.readBy) === null || _t === void 0 ? void 0 : _t[sdk.userInfo.id]), "readBy should remain set after outbound-only incremental build, got ".concat(JSON.stringify(threadAfterNarrowBuild.readBy)));
|
|
1037
|
+
console.log("Outbound SMS with narrow time range does NOT reset readBy test passed");
|
|
1038
|
+
// Cleanup narrow range test
|
|
1039
|
+
return [4 /*yield*/, Promise.all([
|
|
1040
|
+
sdk.api.sms_messages.deleteOne(narrowRangeTestSMS1.id),
|
|
1041
|
+
sdk.api.sms_messages.deleteOne(narrowRangeTestSMS2.id),
|
|
1042
|
+
sdk.api.inbox_threads.deleteOne(narrowRangeThread.id),
|
|
1043
|
+
])
|
|
1044
|
+
// Test 34: Outbound Email with NARROW time range should NOT reset readBy
|
|
1045
|
+
// This tests the production scenario where incremental builds only include recent messages
|
|
1046
|
+
];
|
|
1047
|
+
case 125:
|
|
1048
|
+
// Cleanup narrow range test
|
|
1049
|
+
_0.sent();
|
|
1050
|
+
// Test 34: Outbound Email with NARROW time range should NOT reset readBy
|
|
1051
|
+
// This tests the production scenario where incremental builds only include recent messages
|
|
1052
|
+
console.log("Testing outbound Email with NARROW time range should NOT reset readBy...");
|
|
1053
|
+
return [4 /*yield*/, sdk.api.emails.createOne({
|
|
1054
|
+
subject: "Inbound email for narrow range test",
|
|
1055
|
+
textContent: "Test inbound email content",
|
|
1056
|
+
enduserId: testEnduser.id,
|
|
1057
|
+
inbound: true,
|
|
1058
|
+
logOnly: true,
|
|
1059
|
+
})
|
|
1060
|
+
// Build threads with wide range (includes inbound)
|
|
1061
|
+
];
|
|
1062
|
+
case 126:
|
|
1063
|
+
narrowRangeTestEmail1 = _0.sent();
|
|
1064
|
+
// Build threads with wide range (includes inbound)
|
|
1065
|
+
return [4 /*yield*/, sdk.api.inbox_threads.reset_threads()];
|
|
1066
|
+
case 127:
|
|
1067
|
+
// Build threads with wide range (includes inbound)
|
|
1068
|
+
_0.sent();
|
|
1069
|
+
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: new Date(Date.now() - 60000), to: new Date() })];
|
|
1070
|
+
case 128:
|
|
1071
|
+
_0.sent();
|
|
1072
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({})];
|
|
1073
|
+
case 129:
|
|
1074
|
+
narrowRangeEmailThreads = _0.sent();
|
|
1075
|
+
narrowRangeEmailThread = narrowRangeEmailThreads.threads.find(function (t) {
|
|
1076
|
+
return t.type === 'Email' && t.enduserIds.includes(testEnduser.id) && t.title === "Inbound email for narrow range test";
|
|
1077
|
+
});
|
|
1078
|
+
(0, testing_1.assert)(!!narrowRangeEmailThread, "Narrow range test Email thread should exist");
|
|
1079
|
+
// Mark thread as read
|
|
1080
|
+
return [4 /*yield*/, sdk.api.inbox_threads.updateOne(narrowRangeEmailThread.id, {
|
|
1081
|
+
readBy: (_g = {}, _g[sdk.userInfo.id] = new Date(), _g)
|
|
1082
|
+
})
|
|
1083
|
+
// Wait and capture a timestamp AFTER the inbound was created
|
|
1084
|
+
];
|
|
1085
|
+
case 130:
|
|
1086
|
+
// Mark thread as read
|
|
1087
|
+
_0.sent();
|
|
1088
|
+
// Wait and capture a timestamp AFTER the inbound was created
|
|
1089
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })];
|
|
1090
|
+
case 131:
|
|
1091
|
+
// Wait and capture a timestamp AFTER the inbound was created
|
|
1092
|
+
_0.sent();
|
|
1093
|
+
narrowRangeEmailFrom = new Date();
|
|
1094
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })
|
|
1095
|
+
// Create outbound email (after narrowRangeEmailFrom)
|
|
1096
|
+
];
|
|
1097
|
+
case 132:
|
|
1098
|
+
_0.sent();
|
|
1099
|
+
return [4 /*yield*/, sdk.api.emails.createOne({
|
|
1100
|
+
subject: "Re: Inbound email for narrow range test",
|
|
1101
|
+
textContent: "Outbound reply for narrow range test",
|
|
1102
|
+
enduserId: testEnduser.id,
|
|
1103
|
+
inbound: false,
|
|
1104
|
+
logOnly: true,
|
|
1105
|
+
})
|
|
1106
|
+
// Rebuild with NARROW range that excludes the original inbound
|
|
1107
|
+
];
|
|
1108
|
+
case 133:
|
|
1109
|
+
narrowRangeTestEmail2 = _0.sent();
|
|
1110
|
+
// Rebuild with NARROW range that excludes the original inbound
|
|
1111
|
+
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: narrowRangeEmailFrom, to: new Date() })
|
|
1112
|
+
// readBy should still be preserved (not reset)
|
|
1113
|
+
];
|
|
1114
|
+
case 134:
|
|
1115
|
+
// Rebuild with NARROW range that excludes the original inbound
|
|
1116
|
+
_0.sent();
|
|
1117
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [narrowRangeEmailThread.id] })];
|
|
1118
|
+
case 135:
|
|
1119
|
+
emailThreadAfterNarrowBuild = (_0.sent()).threads[0];
|
|
1120
|
+
(0, testing_1.assert)(!!((_u = emailThreadAfterNarrowBuild.readBy) === null || _u === void 0 ? void 0 : _u[sdk.userInfo.id]), "Email readBy should remain set after outbound-only incremental build, got ".concat(JSON.stringify(emailThreadAfterNarrowBuild.readBy)));
|
|
1121
|
+
console.log("Outbound Email with narrow time range does NOT reset readBy test passed");
|
|
1122
|
+
// Cleanup narrow range email test
|
|
1123
|
+
return [4 /*yield*/, Promise.all([
|
|
1124
|
+
sdk.api.emails.deleteOne(narrowRangeTestEmail1.id),
|
|
1125
|
+
sdk.api.emails.deleteOne(narrowRangeTestEmail2.id),
|
|
1126
|
+
sdk.api.inbox_threads.deleteOne(narrowRangeEmailThread.id),
|
|
1127
|
+
])
|
|
1128
|
+
// ========== Zendesk Thread Tests ==========
|
|
1129
|
+
// Test 35: Basic Zendesk thread building
|
|
1130
|
+
];
|
|
1131
|
+
case 136:
|
|
1132
|
+
// Cleanup narrow range email test
|
|
1133
|
+
_0.sent();
|
|
1134
|
+
// ========== Zendesk Thread Tests ==========
|
|
1135
|
+
// Test 35: Basic Zendesk thread building
|
|
1136
|
+
console.log("Testing Zendesk thread building...");
|
|
1137
|
+
return [4 /*yield*/, sdk.api.ticket_threads.createOne({
|
|
1138
|
+
enduserId: testEnduser.id,
|
|
1139
|
+
subject: "Test Zendesk Thread",
|
|
1140
|
+
})];
|
|
1141
|
+
case 137:
|
|
1142
|
+
zendeskTicketThread_1 = _0.sent();
|
|
1143
|
+
return [4 /*yield*/, sdk.api.ticket_thread_comments.createOne({
|
|
1144
|
+
ticketThreadId: zendeskTicketThread_1.id,
|
|
1145
|
+
enduserId: testEnduser.id,
|
|
1146
|
+
plaintext: "Test ticket comment",
|
|
1147
|
+
html: "<p>Test ticket comment</p>",
|
|
1148
|
+
public: true,
|
|
1149
|
+
inbound: true,
|
|
1150
|
+
})];
|
|
1151
|
+
case 138:
|
|
1152
|
+
zendeskTicketComment = _0.sent();
|
|
1153
|
+
return [4 /*yield*/, sdk.api.inbox_threads.reset_threads()];
|
|
1154
|
+
case 139:
|
|
1155
|
+
_0.sent();
|
|
1156
|
+
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: new Date(Date.now() - 60000), to: new Date() })];
|
|
1157
|
+
case 140:
|
|
1158
|
+
_0.sent();
|
|
1159
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ mdbFilter: { type: 'Zendesk' } })];
|
|
1160
|
+
case 141:
|
|
1161
|
+
zendeskThreads = _0.sent();
|
|
1162
|
+
zendeskThread = zendeskThreads.threads.find(function (t) { return t.threadId === zendeskTicketThread_1.id; });
|
|
1163
|
+
(0, testing_1.assert)(!!zendeskThread, "Zendesk thread should exist");
|
|
1164
|
+
(0, testing_1.assert)(zendeskThread.type === 'Zendesk', "Type should be Zendesk");
|
|
1165
|
+
(0, testing_1.assert)(zendeskThread.title === "Test Zendesk Thread", "Title should match subject");
|
|
1166
|
+
(0, testing_1.assert)(zendeskThread.preview.includes("Test ticket comment"), "Preview should match comment");
|
|
1167
|
+
(0, testing_1.assert)(zendeskThread.enduserIds.includes(testEnduser.id), "Should have enduser");
|
|
1168
|
+
console.log("Basic Zendesk thread building test passed");
|
|
1169
|
+
// Test 36: Zendesk assignment updates
|
|
1170
|
+
console.log("Testing Zendesk assignment updates...");
|
|
1171
|
+
// Update comment assignment
|
|
1172
|
+
return [4 /*yield*/, sdk.api.ticket_thread_comments.updateOne(zendeskTicketComment.id, {
|
|
1173
|
+
assignedTo: [testUser.id]
|
|
1174
|
+
}, { replaceObjectFields: true })
|
|
1175
|
+
// Wait for side effects (the side effect should update the inbox thread directly)
|
|
1176
|
+
];
|
|
1177
|
+
case 142:
|
|
1178
|
+
// Update comment assignment
|
|
1179
|
+
_0.sent();
|
|
1180
|
+
// Wait for side effects (the side effect should update the inbox thread directly)
|
|
1181
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1500); })
|
|
1182
|
+
// Verify - NO rebuild needed, side effect should have handled it
|
|
1183
|
+
];
|
|
1184
|
+
case 143:
|
|
1185
|
+
// Wait for side effects (the side effect should update the inbox thread directly)
|
|
1186
|
+
_0.sent();
|
|
1187
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [zendeskThread.id] })];
|
|
1188
|
+
case 144:
|
|
1189
|
+
updatedZendeskThreads = _0.sent();
|
|
1190
|
+
updatedZendeskThread = updatedZendeskThreads.threads[0];
|
|
1191
|
+
(0, testing_1.assert)(JSON.stringify(updatedZendeskThread.assignedTo) === JSON.stringify([testUser.id]), "Zendesk thread assignment should be updated from comment, got ".concat(JSON.stringify(updatedZendeskThread.assignedTo)));
|
|
1192
|
+
console.log("Zendesk assignment update test passed");
|
|
1193
|
+
// Test 37: Zendesk outbound comment should NOT reset readBy
|
|
1194
|
+
console.log("Testing Zendesk outbound should NOT reset readBy...");
|
|
1195
|
+
// Mark thread as read
|
|
1196
|
+
return [4 /*yield*/, sdk.api.inbox_threads.updateOne(zendeskThread.id, {
|
|
1197
|
+
readBy: (_h = {}, _h[sdk.userInfo.id] = new Date(), _h)
|
|
1198
|
+
})
|
|
1199
|
+
// Verify marked as read
|
|
1200
|
+
];
|
|
1201
|
+
case 145:
|
|
1202
|
+
// Mark thread as read
|
|
1203
|
+
_0.sent();
|
|
1204
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [zendeskThread.id] })];
|
|
1205
|
+
case 146:
|
|
1206
|
+
zendeskThreadAfterRead = (_0.sent()).threads[0];
|
|
1207
|
+
(0, testing_1.assert)(!!((_v = zendeskThreadAfterRead.readBy) === null || _v === void 0 ? void 0 : _v[sdk.userInfo.id]), "Zendesk thread should be marked as read");
|
|
1208
|
+
return [4 /*yield*/, sdk.api.ticket_thread_comments.createOne({
|
|
1209
|
+
ticketThreadId: zendeskTicketThread_1.id,
|
|
1210
|
+
enduserId: testEnduser.id,
|
|
1211
|
+
plaintext: "Outbound staff reply",
|
|
1212
|
+
html: "<p>Outbound staff reply</p>",
|
|
1213
|
+
public: true,
|
|
1214
|
+
inbound: false,
|
|
1215
|
+
userId: sdk.userInfo.id,
|
|
1216
|
+
})
|
|
1217
|
+
// Rebuild threads
|
|
1218
|
+
];
|
|
1219
|
+
case 147:
|
|
1220
|
+
zendeskOutboundComment = _0.sent();
|
|
1221
|
+
// Rebuild threads
|
|
1222
|
+
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: new Date(Date.now() - 60000), to: new Date() })
|
|
1223
|
+
// readBy should remain set
|
|
1224
|
+
];
|
|
1225
|
+
case 148:
|
|
1226
|
+
// Rebuild threads
|
|
1227
|
+
_0.sent();
|
|
1228
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [zendeskThread.id] })];
|
|
1229
|
+
case 149:
|
|
1230
|
+
zendeskThreadAfterOutbound = (_0.sent()).threads[0];
|
|
1231
|
+
(0, testing_1.assert)(!!((_w = zendeskThreadAfterOutbound.readBy) === null || _w === void 0 ? void 0 : _w[sdk.userInfo.id]), "readBy should remain set after outbound Zendesk comment, got ".concat(JSON.stringify(zendeskThreadAfterOutbound.readBy)));
|
|
1232
|
+
(0, testing_1.assert)(!!zendeskThreadAfterOutbound.outboundTimestamp, "outboundTimestamp should be set");
|
|
1233
|
+
(0, testing_1.assert)(!!((_x = zendeskThreadAfterOutbound.outboundPreview) === null || _x === void 0 ? void 0 : _x.includes("Outbound staff reply")), "outboundPreview should match");
|
|
1234
|
+
console.log("Zendesk outbound does NOT reset readBy test passed");
|
|
1235
|
+
// Test 38: New Zendesk inbound SHOULD clear readBy
|
|
1236
|
+
console.log("Testing new Zendesk inbound SHOULD clear readBy...");
|
|
1237
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1100); })];
|
|
1238
|
+
case 150:
|
|
1239
|
+
_0.sent();
|
|
1240
|
+
return [4 /*yield*/, sdk.api.ticket_thread_comments.createOne({
|
|
1241
|
+
ticketThreadId: zendeskTicketThread_1.id,
|
|
1242
|
+
enduserId: testEnduser.id,
|
|
1243
|
+
plaintext: "New inbound from customer",
|
|
1244
|
+
html: "<p>New inbound from customer</p>",
|
|
1245
|
+
public: true,
|
|
1246
|
+
inbound: true,
|
|
1247
|
+
})];
|
|
1248
|
+
case 151:
|
|
1249
|
+
zendeskNewInboundComment = _0.sent();
|
|
1250
|
+
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: new Date(Date.now() - 60000), to: new Date() })];
|
|
1251
|
+
case 152:
|
|
1252
|
+
_0.sent();
|
|
1253
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [zendeskThread.id] })];
|
|
1254
|
+
case 153:
|
|
1255
|
+
zendeskThreadAfterNewInbound = (_0.sent()).threads[0];
|
|
1256
|
+
(0, testing_1.assert)(!((_y = zendeskThreadAfterNewInbound.readBy) === null || _y === void 0 ? void 0 : _y[sdk.userInfo.id]), "readBy SHOULD be cleared after new inbound Zendesk comment, got ".concat(JSON.stringify(zendeskThreadAfterNewInbound.readBy)));
|
|
1257
|
+
console.log("New Zendesk inbound DOES clear readBy test passed");
|
|
1258
|
+
// Test 39: Zendesk narrow range build preserves readBy
|
|
1259
|
+
console.log("Testing Zendesk narrow range build preserves readBy...");
|
|
1260
|
+
// Reset and build fresh
|
|
1261
|
+
return [4 /*yield*/, sdk.api.inbox_threads.reset_threads()];
|
|
1262
|
+
case 154:
|
|
1263
|
+
// Reset and build fresh
|
|
1264
|
+
_0.sent();
|
|
1265
|
+
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: new Date(Date.now() - 60000), to: new Date() })
|
|
1266
|
+
// Get fresh thread
|
|
1267
|
+
];
|
|
1268
|
+
case 155:
|
|
1269
|
+
_0.sent();
|
|
1270
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ mdbFilter: { type: 'Zendesk', threadId: zendeskTicketThread_1.id } })];
|
|
1271
|
+
case 156:
|
|
1272
|
+
freshZendeskThreads = _0.sent();
|
|
1273
|
+
freshZendeskThread = freshZendeskThreads.threads.find(function (t) { return t.threadId === zendeskTicketThread_1.id; });
|
|
1274
|
+
(0, testing_1.assert)(!!freshZendeskThread, "Fresh Zendesk thread should exist");
|
|
1275
|
+
// Mark as read
|
|
1276
|
+
return [4 /*yield*/, sdk.api.inbox_threads.updateOne(freshZendeskThread.id, {
|
|
1277
|
+
readBy: (_j = {}, _j[sdk.userInfo.id] = new Date(), _j)
|
|
1278
|
+
})
|
|
1279
|
+
// Wait and capture narrow range start
|
|
1280
|
+
];
|
|
1281
|
+
case 157:
|
|
1282
|
+
// Mark as read
|
|
1283
|
+
_0.sent();
|
|
1284
|
+
// Wait and capture narrow range start
|
|
1285
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })];
|
|
1286
|
+
case 158:
|
|
1287
|
+
// Wait and capture narrow range start
|
|
1288
|
+
_0.sent();
|
|
1289
|
+
zendeskNarrowRangeFrom = new Date();
|
|
1290
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })
|
|
1291
|
+
// Create outbound comment after narrowRangeFrom
|
|
1292
|
+
];
|
|
1293
|
+
case 159:
|
|
1294
|
+
_0.sent();
|
|
1295
|
+
return [4 /*yield*/, sdk.api.ticket_thread_comments.createOne({
|
|
1296
|
+
ticketThreadId: zendeskTicketThread_1.id,
|
|
1297
|
+
enduserId: testEnduser.id,
|
|
1298
|
+
plaintext: "Outbound in narrow range",
|
|
1299
|
+
html: "<p>Outbound in narrow range</p>",
|
|
1300
|
+
public: true,
|
|
1301
|
+
inbound: false,
|
|
1302
|
+
userId: sdk.userInfo.id,
|
|
1303
|
+
})
|
|
1304
|
+
// Rebuild with narrow range (excludes original inbound)
|
|
1305
|
+
];
|
|
1306
|
+
case 160:
|
|
1307
|
+
zendeskNarrowRangeOutbound = _0.sent();
|
|
1308
|
+
// Rebuild with narrow range (excludes original inbound)
|
|
1309
|
+
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: zendeskNarrowRangeFrom, to: new Date() })
|
|
1310
|
+
// readBy should still be preserved
|
|
1311
|
+
];
|
|
1312
|
+
case 161:
|
|
1313
|
+
// Rebuild with narrow range (excludes original inbound)
|
|
1314
|
+
_0.sent();
|
|
1315
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ ids: [freshZendeskThread.id] })];
|
|
1316
|
+
case 162:
|
|
1317
|
+
zendeskThreadAfterNarrowBuild = (_0.sent()).threads[0];
|
|
1318
|
+
(0, testing_1.assert)(!!((_z = zendeskThreadAfterNarrowBuild.readBy) === null || _z === void 0 ? void 0 : _z[sdk.userInfo.id]), "readBy should remain set after outbound-only Zendesk incremental build, got ".concat(JSON.stringify(zendeskThreadAfterNarrowBuild.readBy)));
|
|
1319
|
+
console.log("Zendesk narrow range build preserves readBy test passed");
|
|
1320
|
+
// Test 40: Zendesk channel filtering
|
|
1321
|
+
console.log("Testing Zendesk channel filtering...");
|
|
1322
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({
|
|
1323
|
+
mdbFilter: { type: 'Zendesk' }
|
|
1324
|
+
})];
|
|
1325
|
+
case 163:
|
|
1326
|
+
filteredZendeskThreads = _0.sent();
|
|
1327
|
+
(0, testing_1.assert)(filteredZendeskThreads.threads.length >= 1, "Should find Zendesk threads");
|
|
1328
|
+
(0, testing_1.assert)(filteredZendeskThreads.threads.every(function (t) { return t.type === 'Zendesk'; }), "All filtered threads should be Zendesk type");
|
|
1329
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({
|
|
1330
|
+
mdbFilter: { type: { $in: ['Zendesk', 'SMS'] } }
|
|
1331
|
+
})];
|
|
1332
|
+
case 164:
|
|
1333
|
+
multiTypeZendeskThreads = _0.sent();
|
|
1334
|
+
(0, testing_1.assert)(multiTypeZendeskThreads.threads.every(function (t) { return t.type === 'Zendesk' || t.type === 'SMS'; }), "Multi-type filter should work with Zendesk");
|
|
1335
|
+
console.log("Zendesk channel filtering test passed");
|
|
1336
|
+
// Test 41: Zendesk thread without comments is skipped
|
|
1337
|
+
console.log("Testing Zendesk thread without comments is skipped...");
|
|
1338
|
+
return [4 /*yield*/, sdk.api.ticket_threads.createOne({
|
|
1339
|
+
enduserId: testEnduser.id,
|
|
1340
|
+
subject: "Empty Zendesk Thread",
|
|
1341
|
+
})];
|
|
1342
|
+
case 165:
|
|
1343
|
+
emptyZendeskTicketThread_1 = _0.sent();
|
|
1344
|
+
return [4 /*yield*/, sdk.api.inbox_threads.reset_threads()];
|
|
1345
|
+
case 166:
|
|
1346
|
+
_0.sent();
|
|
1347
|
+
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: new Date(Date.now() - 60000), to: new Date() })];
|
|
1348
|
+
case 167:
|
|
1349
|
+
_0.sent();
|
|
1350
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ mdbFilter: { type: 'Zendesk' } })];
|
|
1351
|
+
case 168:
|
|
1352
|
+
allZendeskThreadsAfterEmpty = _0.sent();
|
|
1353
|
+
emptyZendeskThread = allZendeskThreadsAfterEmpty.threads.find(function (t) { return t.threadId === emptyZendeskTicketThread_1.id; });
|
|
1354
|
+
(0, testing_1.assert)(!emptyZendeskThread, "Zendesk thread without comments should NOT be built");
|
|
1355
|
+
console.log("Zendesk thread without comments is skipped test passed");
|
|
1356
|
+
// Test 42: Zendesk access control - verify access is blocked when user lacks ticket_threads permission
|
|
1357
|
+
console.log("Testing Zendesk access control (blocking)...");
|
|
1358
|
+
return [4 /*yield*/, sdk.api.ticket_threads.createOne({
|
|
1359
|
+
enduserId: testEnduser.id,
|
|
1360
|
+
subject: "Access Control Test Thread",
|
|
1361
|
+
})];
|
|
1362
|
+
case 169:
|
|
1363
|
+
accessControlTicketThread_1 = _0.sent();
|
|
1364
|
+
return [4 /*yield*/, sdk.api.ticket_thread_comments.createOne({
|
|
1365
|
+
ticketThreadId: accessControlTicketThread_1.id,
|
|
1366
|
+
enduserId: testEnduser.id,
|
|
1367
|
+
plaintext: "Access control test comment",
|
|
1368
|
+
html: "<p>Access control test comment</p>",
|
|
1369
|
+
public: true,
|
|
1370
|
+
inbound: true,
|
|
1371
|
+
})];
|
|
1372
|
+
case 170:
|
|
1373
|
+
accessControlComment = _0.sent();
|
|
1374
|
+
return [4 /*yield*/, sdk.api.inbox_threads.reset_threads()];
|
|
1375
|
+
case 171:
|
|
1376
|
+
_0.sent();
|
|
1377
|
+
return [4 /*yield*/, sdk.api.inbox_threads.build_threads({ from: new Date(Date.now() - 60000), to: new Date() })
|
|
1378
|
+
// Verify admin can see the Zendesk thread
|
|
1379
|
+
];
|
|
1380
|
+
case 172:
|
|
1381
|
+
_0.sent();
|
|
1382
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({
|
|
1383
|
+
mdbFilter: { type: 'Zendesk' }
|
|
1384
|
+
})];
|
|
1385
|
+
case 173:
|
|
1386
|
+
adminZendeskThreads = _0.sent();
|
|
1387
|
+
(0, testing_1.assert)(adminZendeskThreads.threads.length >= 1, "Admin should see Zendesk threads");
|
|
1388
|
+
accessControlThread = adminZendeskThreads.threads.find(function (t) { return t.threadId === accessControlTicketThread_1.id; });
|
|
1389
|
+
(0, testing_1.assert)(!!accessControlThread, "Admin should see the access control test thread");
|
|
1390
|
+
return [4 /*yield*/, sdk.api.role_based_access_permissions.createOne({
|
|
1391
|
+
role: 'No Ticket Threads Access',
|
|
1392
|
+
permissions: {
|
|
1393
|
+
ticket_threads: { read: null, create: null, update: null, delete: null },
|
|
1394
|
+
// Give access to other inbox types so we can verify selective blocking
|
|
1395
|
+
emails: { read: 'Default', create: 'Default', update: 'Default', delete: 'Default' },
|
|
1396
|
+
sms_messages: { read: 'Default', create: 'Default', update: 'Default', delete: 'Default' },
|
|
1397
|
+
},
|
|
1398
|
+
})
|
|
1399
|
+
// Create a test user for access control testing
|
|
1400
|
+
];
|
|
1401
|
+
case 174:
|
|
1402
|
+
noTicketThreadsRole = _0.sent();
|
|
1403
|
+
accessControlTestEmail = 'zendesk.access.control.test@tellescope.com';
|
|
1404
|
+
return [4 /*yield*/, sdk.api.users.getOne({ email: accessControlTestEmail }).catch(function () { return null; })];
|
|
1405
|
+
case 175:
|
|
1406
|
+
_b = (_0.sent());
|
|
1407
|
+
if (_b) return [3 /*break*/, 177];
|
|
1408
|
+
return [4 /*yield*/, sdk.api.users.createOne({ email: accessControlTestEmail, notificationEmailsDisabled: true, verifiedEmail: true })];
|
|
1409
|
+
case 176:
|
|
1410
|
+
_b = (_0.sent());
|
|
1411
|
+
_0.label = 177;
|
|
1412
|
+
case 177:
|
|
1413
|
+
accessControlTestUser = _b;
|
|
1414
|
+
// Assign the restricted role to the test user
|
|
1415
|
+
return [4 /*yield*/, sdk.api.users.updateOne(accessControlTestUser.id, { roles: [noTicketThreadsRole.role] }, { replaceObjectFields: true })];
|
|
1416
|
+
case 178:
|
|
1417
|
+
// Assign the restricted role to the test user
|
|
1418
|
+
_0.sent();
|
|
1419
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })
|
|
1420
|
+
// Create SDK session for the restricted user
|
|
1421
|
+
]; // Wait for role change
|
|
1422
|
+
case 179:
|
|
1423
|
+
_0.sent(); // Wait for role change
|
|
1424
|
+
_c = sdk_1.Session.bind;
|
|
1425
|
+
_k = {
|
|
1426
|
+
host: host
|
|
1427
|
+
};
|
|
1428
|
+
return [4 /*yield*/, sdk.api.users.generate_auth_token({ id: accessControlTestUser.id })];
|
|
1429
|
+
case 180:
|
|
1430
|
+
sdkNoTicketAccess = new (_c.apply(sdk_1.Session, [void 0, (_k.authToken = (_0.sent()).authToken,
|
|
1431
|
+
_k)]))();
|
|
1432
|
+
return [4 /*yield*/, sdkNoTicketAccess.api.inbox_threads.load_threads({
|
|
1433
|
+
mdbFilter: { type: 'Zendesk' }
|
|
1434
|
+
})];
|
|
1435
|
+
case 181:
|
|
1436
|
+
restrictedUserZendeskThreads = _0.sent();
|
|
1437
|
+
(0, testing_1.assert)(restrictedUserZendeskThreads.threads.length === 0, "User without ticket_threads access should NOT see Zendesk threads, but found ".concat(restrictedUserZendeskThreads.threads.length));
|
|
1438
|
+
console.log("Verified: User without ticket_threads access cannot see Zendesk threads");
|
|
1439
|
+
return [4 /*yield*/, sdkNoTicketAccess.api.inbox_threads.load_threads({})];
|
|
1440
|
+
case 182:
|
|
1441
|
+
restrictedUserAllThreads = _0.sent();
|
|
1442
|
+
restrictedUserHasZendesk = restrictedUserAllThreads.threads.some(function (t) { return t.type === 'Zendesk'; });
|
|
1443
|
+
(0, testing_1.assert)(!restrictedUserHasZendesk, "User without ticket_threads access should not see ANY Zendesk threads even in unfiltered query");
|
|
1444
|
+
console.log("Verified: Zendesk threads are filtered from all queries for restricted user");
|
|
1445
|
+
// Cleanup access control test resources
|
|
1446
|
+
return [4 /*yield*/, Promise.all([
|
|
1447
|
+
sdk.api.ticket_thread_comments.deleteOne(accessControlComment.id).catch(function () { }),
|
|
1448
|
+
sdk.api.ticket_threads.deleteOne(accessControlTicketThread_1.id).catch(function () { }),
|
|
1449
|
+
sdk.api.users.deleteOne(accessControlTestUser.id).catch(function () { }),
|
|
1450
|
+
sdk.api.role_based_access_permissions.deleteOne(noTicketThreadsRole.id).catch(function () { }),
|
|
1451
|
+
])];
|
|
1452
|
+
case 183:
|
|
1453
|
+
// Cleanup access control test resources
|
|
1454
|
+
_0.sent();
|
|
1455
|
+
console.log("Zendesk access control (blocking) test passed");
|
|
1456
|
+
// Cleanup Zendesk test resources
|
|
1457
|
+
return [4 /*yield*/, Promise.all([
|
|
1458
|
+
sdk.api.ticket_thread_comments.deleteOne(zendeskTicketComment.id).catch(function () { }),
|
|
1459
|
+
sdk.api.ticket_thread_comments.deleteOne(zendeskOutboundComment.id).catch(function () { }),
|
|
1460
|
+
sdk.api.ticket_thread_comments.deleteOne(zendeskNewInboundComment.id).catch(function () { }),
|
|
1461
|
+
sdk.api.ticket_thread_comments.deleteOne(zendeskNarrowRangeOutbound.id).catch(function () { }),
|
|
1462
|
+
sdk.api.ticket_threads.deleteOne(zendeskTicketThread_1.id).catch(function () { }),
|
|
1463
|
+
sdk.api.ticket_threads.deleteOne(emptyZendeskTicketThread_1.id).catch(function () { }),
|
|
1464
|
+
])
|
|
1465
|
+
// Delete any Zendesk inbox threads
|
|
1466
|
+
];
|
|
1467
|
+
case 184:
|
|
1468
|
+
// Cleanup Zendesk test resources
|
|
1469
|
+
_0.sent();
|
|
1470
|
+
return [4 /*yield*/, sdk.api.inbox_threads.load_threads({ mdbFilter: { type: 'Zendesk' } })];
|
|
1471
|
+
case 185:
|
|
1472
|
+
remainingZendeskThreads = _0.sent();
|
|
1473
|
+
return [4 /*yield*/, Promise.all(remainingZendeskThreads.threads.map(function (t) { return sdk.api.inbox_threads.deleteOne(t.id).catch(function () { }); }))];
|
|
1474
|
+
case 186:
|
|
1475
|
+
_0.sent();
|
|
1476
|
+
console.log("All Zendesk thread tests passed!");
|
|
1477
|
+
console.log("All InboxThread assignment update tests passed!");
|
|
1478
|
+
return [3 /*break*/, 191];
|
|
1479
|
+
case 187:
|
|
1480
|
+
_0.trys.push([187, 189, , 190]);
|
|
965
1481
|
return [4 /*yield*/, Promise.all([
|
|
966
1482
|
sdk.api.inbox_threads.deleteOne(emailThread.id),
|
|
967
1483
|
sdk.api.inbox_threads.deleteOne(smsThread.id),
|
|
@@ -972,15 +1488,15 @@ var inbox_thread_assignment_updates_tests = function (_a) {
|
|
|
972
1488
|
sdk.api.endusers.deleteOne(testEnduser.id),
|
|
973
1489
|
sdk.api.users.deleteOne(testUser.id),
|
|
974
1490
|
])];
|
|
975
|
-
case
|
|
976
|
-
|
|
977
|
-
return [3 /*break*/,
|
|
978
|
-
case
|
|
979
|
-
err_1 =
|
|
1491
|
+
case 188:
|
|
1492
|
+
_0.sent();
|
|
1493
|
+
return [3 /*break*/, 190];
|
|
1494
|
+
case 189:
|
|
1495
|
+
err_1 = _0.sent();
|
|
980
1496
|
console.error("Cleanup error:", err_1);
|
|
981
|
-
return [3 /*break*/,
|
|
982
|
-
case
|
|
983
|
-
case
|
|
1497
|
+
return [3 /*break*/, 190];
|
|
1498
|
+
case 190: return [7 /*endfinally*/];
|
|
1499
|
+
case 191: return [2 /*return*/];
|
|
984
1500
|
}
|
|
985
1501
|
});
|
|
986
1502
|
});
|