@tellescope/sdk 1.71.0 → 1.71.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/sdk.d.ts +1 -0
- package/lib/cjs/sdk.d.ts.map +1 -1
- package/lib/cjs/sdk.js +3 -3
- package/lib/cjs/sdk.js.map +1 -1
- package/lib/cjs/tests/tests.d.ts +1 -0
- package/lib/cjs/tests/tests.d.ts.map +1 -1
- package/lib/cjs/tests/tests.js +133 -50
- package/lib/cjs/tests/tests.js.map +1 -1
- package/lib/esm/sdk.d.ts +3 -2
- package/lib/esm/sdk.d.ts.map +1 -1
- package/lib/esm/sdk.js +3 -3
- package/lib/esm/sdk.js.map +1 -1
- package/lib/esm/session.d.ts +1 -0
- package/lib/esm/session.d.ts.map +1 -1
- package/lib/esm/tests/tests.d.ts +1 -0
- package/lib/esm/tests/tests.d.ts.map +1 -1
- package/lib/esm/tests/tests.js +132 -50
- package/lib/esm/tests/tests.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/sdk.ts +3 -3
- package/src/tests/tests.ts +96 -5
- package/test_generated.pdf +0 -0
package/src/tests/tests.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
UserDisplayInfo,
|
|
11
11
|
} from "@tellescope/types-client"
|
|
12
12
|
import {
|
|
13
|
+
CompoundFilter,
|
|
13
14
|
CreateTicketActionInfo,
|
|
14
15
|
CreateTicketAssignmentStrategies,
|
|
15
16
|
CreateTicketAssignmentStrategy,
|
|
@@ -32,7 +33,7 @@ import {
|
|
|
32
33
|
} from "@tellescope/validation"
|
|
33
34
|
|
|
34
35
|
import { Session, APIQuery, EnduserSession } from "../sdk"
|
|
35
|
-
import { weighted_round_robin } from "@tellescope/utilities"
|
|
36
|
+
import { FORM_LOGIC_CALCULATED_FIELDS, responses_satisfy_conditions, weighted_round_robin } from "@tellescope/utilities"
|
|
36
37
|
import { DEFAULT_OPERATIONS, PLACEHOLDER_ID } from "@tellescope/constants"
|
|
37
38
|
import {
|
|
38
39
|
schema,
|
|
@@ -53,6 +54,7 @@ import {
|
|
|
53
54
|
} from "@tellescope/utilities"
|
|
54
55
|
|
|
55
56
|
import fs from "fs"
|
|
57
|
+
import { response } from "express";
|
|
56
58
|
|
|
57
59
|
const UniquenessViolationMessage = 'Uniqueness Violation'
|
|
58
60
|
|
|
@@ -6070,12 +6072,13 @@ const enduser_access_tags_tests = async () => {
|
|
|
6070
6072
|
|
|
6071
6073
|
const matchTag = 'Access'
|
|
6072
6074
|
const dontMatchTag = 'No Access'
|
|
6075
|
+
const ticketTitle = 'ticket'
|
|
6073
6076
|
|
|
6074
6077
|
const matchEnduser = await sdk.api.endusers.createOne({ accessTags: [matchTag]})
|
|
6075
6078
|
const matchMultiTagEnduser = await sdk.api.endusers.createOne({ accessTags: [matchTag, dontMatchTag]})
|
|
6076
6079
|
const dontMatchEnduser = await sdk.api.endusers.createOne({ accessTags: [dontMatchTag]})
|
|
6077
|
-
const matchTicket = await sdk.api.tickets.createOne({ enduserId: matchEnduser.id, title:
|
|
6078
|
-
const dontMatchTicket = await sdk.api.tickets.createOne({ enduserId: dontMatchEnduser.id, title:
|
|
6080
|
+
const matchTicket = await sdk.api.tickets.createOne({ enduserId: matchEnduser.id, title: ticketTitle })
|
|
6081
|
+
const dontMatchTicket = await sdk.api.tickets.createOne({ enduserId: dontMatchEnduser.id, title: ticketTitle })
|
|
6079
6082
|
|
|
6080
6083
|
// start with disabled setting an no tags on non-admin
|
|
6081
6084
|
await sdk.api.users.updateOne(sdkNonAdmin.userInfo.id, { tags: [] }, { replaceObjectFields: true })
|
|
@@ -6087,6 +6090,10 @@ const enduser_access_tags_tests = async () => {
|
|
|
6087
6090
|
await async_test(`Setting disabled, matchEnduser`, () => sdkNonAdmin.api.endusers.getOne(matchEnduser.id), handleAnyError)
|
|
6088
6091
|
await async_test(`Setting disabled, dontMatchEnduser`, () => sdkNonAdmin.api.endusers.getOne(dontMatchEnduser.id), handleAnyError)
|
|
6089
6092
|
await async_test(`Setting disabled, no tags, tickets`, sdkNonAdmin.api.tickets.getSome, { onResult: r => r.length === 0 })
|
|
6093
|
+
await async_test(`Setting disabled, no tags, tickets search`,
|
|
6094
|
+
() => sdkNonAdmin.api.tickets.getSome({ search: { query: ticketTitle }}),
|
|
6095
|
+
{ onResult: r => r.length === 0 }
|
|
6096
|
+
)
|
|
6090
6097
|
await async_test(`Setting disabled, matchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(matchTicket.id), handleAnyError)
|
|
6091
6098
|
await async_test(`Setting disabled, dontMatchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(dontMatchTicket.id), handleAnyError)
|
|
6092
6099
|
await async_test(
|
|
@@ -6110,6 +6117,10 @@ const enduser_access_tags_tests = async () => {
|
|
|
6110
6117
|
await async_test(`enable setting, matchEnduser`, () => sdkNonAdmin.api.endusers.getOne(matchEnduser.id), handleAnyError)
|
|
6111
6118
|
await async_test(`enable setting, dontMatchEnduser`, () => sdkNonAdmin.api.endusers.getOne(dontMatchEnduser.id), handleAnyError)
|
|
6112
6119
|
await async_test(`enable setting, no tags, tickets`, sdkNonAdmin.api.tickets.getSome, { onResult: r => r.length === 0 })
|
|
6120
|
+
await async_test(`enable setting, no tags, tickets search`,
|
|
6121
|
+
() => sdkNonAdmin.api.tickets.getSome({ search: { query: ticketTitle }}),
|
|
6122
|
+
{ onResult: r => r.length === 0 }
|
|
6123
|
+
)
|
|
6113
6124
|
await async_test(`enable setting, matchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(matchTicket.id), handleAnyError)
|
|
6114
6125
|
await async_test(`enable setting, dontMatchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(dontMatchTicket.id), handleAnyError)
|
|
6115
6126
|
await async_test(
|
|
@@ -6134,6 +6145,10 @@ const enduser_access_tags_tests = async () => {
|
|
|
6134
6145
|
await async_test(`disable setting, matchEnduser`, () => sdkNonAdmin.api.endusers.getOne(matchEnduser.id), handleAnyError)
|
|
6135
6146
|
await async_test(`disable setting, dontMatchEnduser`, () => sdkNonAdmin.api.endusers.getOne(dontMatchEnduser.id), handleAnyError)
|
|
6136
6147
|
await async_test(`disable setting, enable tags, tickets`, sdkNonAdmin.api.tickets.getSome, { onResult: r => r.length === 0 })
|
|
6148
|
+
await async_test(`disable setting, no tags, tickets search`,
|
|
6149
|
+
() => sdkNonAdmin.api.tickets.getSome({ search: { query: ticketTitle }}),
|
|
6150
|
+
{ onResult: r => r.length === 0 }
|
|
6151
|
+
)
|
|
6137
6152
|
await async_test(`disable setting, matchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(matchTicket.id), handleAnyError)
|
|
6138
6153
|
await async_test(`disable setting, dontMatchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(dontMatchTicket.id), handleAnyError)
|
|
6139
6154
|
await async_test(
|
|
@@ -6158,9 +6173,13 @@ const enduser_access_tags_tests = async () => {
|
|
|
6158
6173
|
})
|
|
6159
6174
|
await async_test(`access matchEnduser`, () => sdkNonAdmin.api.endusers.getOne(matchEnduser.id), passOnAnyResult)
|
|
6160
6175
|
await async_test(`access dontMatchEnduser bad`, () => sdkNonAdmin.api.endusers.getOne(dontMatchEnduser.id), handleAnyError)
|
|
6161
|
-
await async_test(`access setting,
|
|
6176
|
+
await async_test(`access setting, tickets`, sdkNonAdmin.api.tickets.getSome, {
|
|
6162
6177
|
onResult: r => r.length === 1 && !r.find(t => t.id === dontMatchTicket.id)
|
|
6163
6178
|
})
|
|
6179
|
+
await async_test(`access setting tickets search`,
|
|
6180
|
+
() => sdkNonAdmin.api.tickets.getSome({ search: { query: ticketTitle }}),
|
|
6181
|
+
{ onResult: r => r.length === 1 }
|
|
6182
|
+
)
|
|
6164
6183
|
await async_test(`access, matchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(matchTicket.id), passOnAnyResult)
|
|
6165
6184
|
await async_test(`access, dontMatchEnduser ticket`, () => sdkNonAdmin.api.tickets.getOne(dontMatchTicket.id), handleAnyError)
|
|
6166
6185
|
await async_test(
|
|
@@ -6272,6 +6291,76 @@ const marketing_email_unsubscribe_tests = async () => {
|
|
|
6272
6291
|
])
|
|
6273
6292
|
}
|
|
6274
6293
|
|
|
6294
|
+
export const form_conditional_logic_tests = async () => {
|
|
6295
|
+
log_header("Form Conditional Logic Tests")
|
|
6296
|
+
|
|
6297
|
+
const responses: FormResponseValue[] = [
|
|
6298
|
+
{
|
|
6299
|
+
fieldId: "0",
|
|
6300
|
+
answer: { type: 'string', value: 'hello' },
|
|
6301
|
+
fieldTitle: '',
|
|
6302
|
+
},
|
|
6303
|
+
{
|
|
6304
|
+
fieldId: "0list",
|
|
6305
|
+
answer: { type: 'multiple_choice', value: ['hello'] },
|
|
6306
|
+
fieldTitle: '',
|
|
6307
|
+
},
|
|
6308
|
+
{
|
|
6309
|
+
fieldId: "1",
|
|
6310
|
+
answer: { type: 'string', value: '' },
|
|
6311
|
+
fieldTitle: '',
|
|
6312
|
+
},
|
|
6313
|
+
{
|
|
6314
|
+
fieldId: "2",
|
|
6315
|
+
answer: { type: 'multiple_choice', value: [''] },
|
|
6316
|
+
fieldTitle: '',
|
|
6317
|
+
},
|
|
6318
|
+
{
|
|
6319
|
+
fieldId: "3",
|
|
6320
|
+
answer: { type: 'number', value: 73 },
|
|
6321
|
+
fieldTitle: '',
|
|
6322
|
+
computedValueKey: 'Height',
|
|
6323
|
+
},
|
|
6324
|
+
{
|
|
6325
|
+
fieldId: "4",
|
|
6326
|
+
answer: { type: 'number', value: 190 },
|
|
6327
|
+
fieldTitle: '',
|
|
6328
|
+
computedValueKey: 'Weight',
|
|
6329
|
+
},
|
|
6330
|
+
]
|
|
6331
|
+
|
|
6332
|
+
let i = 0
|
|
6333
|
+
const run_conditional_form_test = (conditions: CompoundFilter<string>, expected: boolean, title=`Test ${++i}`) => {
|
|
6334
|
+
assert(
|
|
6335
|
+
responses_satisfy_conditions(responses, conditions) === expected,
|
|
6336
|
+
`Failed condition:\n${JSON.stringify(conditions, null, 2)}`,
|
|
6337
|
+
title,
|
|
6338
|
+
)
|
|
6339
|
+
}
|
|
6340
|
+
|
|
6341
|
+
run_conditional_form_test({ $and: [{ condition: { '0': { $contains: 'hel'} } }] }, true)
|
|
6342
|
+
run_conditional_form_test({ $and: [{ condition: { '0': { $contains: 'hello'} } }] }, true)
|
|
6343
|
+
run_conditional_form_test({ $and: [{ condition: { '0': { $contains: 'hllo'} } }] }, false)
|
|
6344
|
+
run_conditional_form_test({ $and: [{ condition: { '0list': { $contains: 'hel'} } }] }, true)
|
|
6345
|
+
run_conditional_form_test({ $and: [{ condition: { '0list': { $contains: 'hello'} } }] }, true)
|
|
6346
|
+
run_conditional_form_test({ $and: [{ condition: { '0list': { $contains: 'hllo'} } }] }, false)
|
|
6347
|
+
run_conditional_form_test({ $and: [{ condition: { '1': '' } }] }, true)
|
|
6348
|
+
run_conditional_form_test({ $and: [{ condition: { '1': { $exists: true } } }] }, false)
|
|
6349
|
+
run_conditional_form_test({ $and: [{ condition: { '1': { $exists: false } } }] }, true)
|
|
6350
|
+
run_conditional_form_test({ $and: [{ condition: { '2': '' } }] }, true)
|
|
6351
|
+
run_conditional_form_test({ $and: [{ condition: { '2': { $exists: true } } }] }, true)
|
|
6352
|
+
run_conditional_form_test({ $and: [{ condition: { '2': { $exists: false } } }] }, false)
|
|
6353
|
+
run_conditional_form_test({ $and: [{ condition: { '3': { $gt: 72 } } }] }, true)
|
|
6354
|
+
run_conditional_form_test({ $and: [{ condition: { '3': { $gt: 73 } } }] }, false)
|
|
6355
|
+
run_conditional_form_test({ $and: [{ condition: { '3': { $gt: 74 } } }] }, false)
|
|
6356
|
+
run_conditional_form_test({ $and: [{ condition: { '3': { $lt: 72 } } }] }, false)
|
|
6357
|
+
run_conditional_form_test({ $and: [{ condition: { '3': { $lt: 73 } } }] }, false)
|
|
6358
|
+
run_conditional_form_test({ $and: [{ condition: { '3': { $lt: 74 } } }] }, true)
|
|
6359
|
+
run_conditional_form_test({ $and: [{ condition: { [FORM_LOGIC_CALCULATED_FIELDS[0]]: { $exists: true } } }] }, true)
|
|
6360
|
+
run_conditional_form_test({ $and: [{ condition: { [FORM_LOGIC_CALCULATED_FIELDS[0]]: { $gt: 25 } } }] }, true)
|
|
6361
|
+
run_conditional_form_test({ $and: [{ condition: { [FORM_LOGIC_CALCULATED_FIELDS[0]]: { $lt: 25 } } }] }, false)
|
|
6362
|
+
}
|
|
6363
|
+
|
|
6275
6364
|
(async () => {
|
|
6276
6365
|
log_header("API")
|
|
6277
6366
|
|
|
@@ -6282,6 +6371,8 @@ const marketing_email_unsubscribe_tests = async () => {
|
|
|
6282
6371
|
)
|
|
6283
6372
|
|
|
6284
6373
|
try {
|
|
6374
|
+
form_conditional_logic_tests()
|
|
6375
|
+
|
|
6285
6376
|
await test_weighted_round_robin()
|
|
6286
6377
|
|
|
6287
6378
|
await validate_schema()
|
|
@@ -6312,9 +6403,9 @@ const marketing_email_unsubscribe_tests = async () => {
|
|
|
6312
6403
|
await mfa_tests()
|
|
6313
6404
|
await setup_tests()
|
|
6314
6405
|
await multi_tenant_tests() // should come right after setup tests
|
|
6406
|
+
await enduser_access_tags_tests()
|
|
6315
6407
|
await marketing_email_unsubscribe_tests()
|
|
6316
6408
|
await unique_strings_tests()
|
|
6317
|
-
await enduser_access_tags_tests()
|
|
6318
6409
|
await self_serve_appointment_booking_tests()
|
|
6319
6410
|
await alternate_phones_tests()
|
|
6320
6411
|
await ticket_queue_tests()
|
package/test_generated.pdf
CHANGED
|
Binary file
|