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