@tellescope/sdk 1.80.3 → 1.81.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 +42 -0
- package/lib/cjs/sdk.d.ts.map +1 -1
- package/lib/cjs/sdk.js +1 -0
- package/lib/cjs/sdk.js.map +1 -1
- package/lib/cjs/tests/tests.d.ts.map +1 -1
- package/lib/cjs/tests/tests.js +631 -94
- 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 +42 -0
- package/lib/esm/sdk.d.ts.map +1 -1
- package/lib/esm/sdk.js +1 -0
- package/lib/esm/sdk.js.map +1 -1
- package/lib/esm/tests/tests.d.ts.map +1 -1
- package/lib/esm/tests/tests.js +631 -94
- package/lib/esm/tests/tests.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/sdk.ts +1 -0
- package/src/tests/tests.ts +511 -17
- package/test_generated.pdf +0 -0
package/src/tests/tests.ts
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
ClientModelForName_required,
|
|
10
10
|
UserDisplayInfo,
|
|
11
11
|
Ticket,
|
|
12
|
+
VitalConfiguration,
|
|
13
|
+
EnduserObservation,
|
|
12
14
|
} from "@tellescope/types-client"
|
|
13
15
|
import {
|
|
14
16
|
CompoundFilter,
|
|
@@ -5363,7 +5365,7 @@ const nextReminderInMS_tests = async () => {
|
|
|
5363
5365
|
])
|
|
5364
5366
|
}
|
|
5365
5367
|
|
|
5366
|
-
const pollForResults = async <T>(f: () => Promise<T>, evaluate: (r: T) => boolean, intervalInMS=500, iterations=20) => {
|
|
5368
|
+
const pollForResults = async <T>(f: () => Promise<T>, evaluate: (r: T) => boolean, intervalInMS=500, iterations=20, shouldError=false) => {
|
|
5367
5369
|
let lastResult = undefined as any
|
|
5368
5370
|
for (let i = 0; i < iterations; i++) {
|
|
5369
5371
|
await wait(undefined, intervalInMS)
|
|
@@ -5372,6 +5374,8 @@ const pollForResults = async <T>(f: () => Promise<T>, evaluate: (r: T) => boolea
|
|
|
5372
5374
|
if (evaluate(result)) return result
|
|
5373
5375
|
}
|
|
5374
5376
|
|
|
5377
|
+
if (shouldError) return lastResult
|
|
5378
|
+
|
|
5375
5379
|
console.log(lastResult)
|
|
5376
5380
|
throw new Error("failed pollForResults")
|
|
5377
5381
|
}
|
|
@@ -5875,6 +5879,12 @@ export const ticket_queue_tests = async () => {
|
|
|
5875
5879
|
|
|
5876
5880
|
const enduser = await sdk.api.endusers.createOne({ fname: 'ticket' })
|
|
5877
5881
|
|
|
5882
|
+
await async_test(
|
|
5883
|
+
`Ticket queue empty on general pull`,
|
|
5884
|
+
() => sdk.api.tickets.assign_from_queue({ queueId: queue.id }),
|
|
5885
|
+
{ shouldError: true, onError: e => e.message === "Queue is empty" },
|
|
5886
|
+
)
|
|
5887
|
+
|
|
5878
5888
|
const ticket = await sdk.api.tickets.createOne({ title: 'ticket in queue', queueId: queue.id, enduserId: enduser.id })
|
|
5879
5889
|
const ticketUnshared = await sdk.api.tickets.createOne({ title: 'ticket no access', queueId: queueUnshared.id })
|
|
5880
5890
|
|
|
@@ -5946,22 +5956,29 @@ export const ticket_queue_tests = async () => {
|
|
|
5946
5956
|
passOnAnyResult
|
|
5947
5957
|
)
|
|
5948
5958
|
await async_test(
|
|
5949
|
-
`
|
|
5950
|
-
() =>
|
|
5951
|
-
|
|
5952
|
-
e => !!e.assignedTo?.includes(sdkNonAdmin.userInfo.id),
|
|
5953
|
-
50,
|
|
5954
|
-
10
|
|
5955
|
-
),
|
|
5956
|
-
passOnAnyResult
|
|
5959
|
+
`Added to care team after queue pull`,
|
|
5960
|
+
() => sdkNonAdmin.api.endusers.getOne(enduser.id),
|
|
5961
|
+
{ onResult: e => !!e.assignedTo?.includes(sdkNonAdmin.userInfo.id) }
|
|
5957
5962
|
)
|
|
5958
5963
|
|
|
5959
|
-
|
|
5964
|
+
const ticketToPull = await sdk.api.tickets.createOne({ title: 'ticket to pull without id', queueId: queue.id })
|
|
5965
|
+
await async_test(
|
|
5966
|
+
`Ticket queue general pull`,
|
|
5967
|
+
() => sdk.api.tickets.assign_from_queue({ queueId: queue.id }),
|
|
5968
|
+
{ onResult: r => r.ticket.id === ticketToPull.id },
|
|
5969
|
+
)
|
|
5970
|
+
await async_test(
|
|
5971
|
+
`Ticket queue empty on general pull again`,
|
|
5972
|
+
() => sdk.api.tickets.assign_from_queue({ queueId: queue.id }),
|
|
5973
|
+
{ shouldError: true, onError: e => e.message === "Queue is empty" },
|
|
5974
|
+
)
|
|
5975
|
+
|
|
5960
5976
|
await Promise.all([
|
|
5961
5977
|
sdk.api.ticket_queues.deleteOne(queue.id),
|
|
5962
5978
|
sdk.api.ticket_queues.deleteOne(queueUnshared.id),
|
|
5963
5979
|
sdk.api.endusers.deleteOne(enduser.id), // cleans up ticket
|
|
5964
5980
|
sdk.api.tickets.deleteOne(ticketUnshared.id),
|
|
5981
|
+
sdk.api.tickets.deleteOne(ticketToPull.id),
|
|
5965
5982
|
])
|
|
5966
5983
|
}
|
|
5967
5984
|
|
|
@@ -5995,6 +6012,7 @@ export const alternate_phones_tests = async () => {
|
|
|
5995
6012
|
|
|
5996
6013
|
const NO_TEST = () => {}
|
|
5997
6014
|
const tests: { [K in keyof ClientModelForName]: () => void } = {
|
|
6015
|
+
vital_configurations: NO_TEST,
|
|
5998
6016
|
enduser_encounters: NO_TEST,
|
|
5999
6017
|
enduser_orders: NO_TEST,
|
|
6000
6018
|
ticket_queues: NO_TEST,
|
|
@@ -6986,7 +7004,7 @@ const sync_tests = async () => {
|
|
|
6986
7004
|
await async_test(
|
|
6987
7005
|
"Other organization",
|
|
6988
7006
|
() => sdkOther.sync({ from }),
|
|
6989
|
-
{ onResult: ({ results }) => results.length === 0 },
|
|
7007
|
+
{ onResult: ({ results }) => results.filter(e => e.modelName === 'endusers' && e.data !== 'deleted').length === 0 },
|
|
6990
7008
|
)
|
|
6991
7009
|
|
|
6992
7010
|
await sdk.api.endusers.updateOne(e.id, { fname: "UPDATE_TEST"})
|
|
@@ -7014,7 +7032,7 @@ const sync_tests = async () => {
|
|
|
7014
7032
|
await async_test(
|
|
7015
7033
|
"Other organization",
|
|
7016
7034
|
() => sdkOther.sync({ from }),
|
|
7017
|
-
{ onResult: ({ results }) => results.length === 0 },
|
|
7035
|
+
{ onResult: ({ results }) => results.filter(e => e.modelName === 'endusers' && e.data !== 'deleted').length === 0 },
|
|
7018
7036
|
)
|
|
7019
7037
|
|
|
7020
7038
|
const t = await sdk.api.tickets.createOne({ title: 'access test' })
|
|
@@ -7092,7 +7110,7 @@ const sync_tests = async () => {
|
|
|
7092
7110
|
await async_test(
|
|
7093
7111
|
"Other organization",
|
|
7094
7112
|
() => sdkOther.sync({ from }),
|
|
7095
|
-
{ onResult: ({ results }) => results.length === 0 },
|
|
7113
|
+
{ onResult: ({ results }) => results.filter(e => e.modelName === 'endusers' && e.data !== 'deleted').length === 0 },
|
|
7096
7114
|
)
|
|
7097
7115
|
|
|
7098
7116
|
// bulk create test coverage
|
|
@@ -7122,7 +7140,7 @@ const sync_tests = async () => {
|
|
|
7122
7140
|
await async_test(
|
|
7123
7141
|
"Other organization",
|
|
7124
7142
|
() => sdkOther.sync({ from }),
|
|
7125
|
-
{ onResult: ({ results }) => results.length === 0 },
|
|
7143
|
+
{ onResult: ({ results }) => results.filter(e => e.modelName === 'endusers' && e.data !== 'deleted').length === 0 },
|
|
7126
7144
|
)
|
|
7127
7145
|
|
|
7128
7146
|
await sdk.api.endusers.deleteOne(e2.id)
|
|
@@ -7150,7 +7168,7 @@ const sync_tests = async () => {
|
|
|
7150
7168
|
await async_test(
|
|
7151
7169
|
"Other organization",
|
|
7152
7170
|
() => sdkOther.sync({ from }),
|
|
7153
|
-
{ onResult: ({ results }) => results.length === 0 },
|
|
7171
|
+
{ onResult: ({ results }) => results.filter(e => e.modelName === 'endusers' && e.data !== 'deleted').length === 0 },
|
|
7154
7172
|
)
|
|
7155
7173
|
}
|
|
7156
7174
|
|
|
@@ -7204,6 +7222,481 @@ const close_reasons_no_duplicates_tests = async () => {
|
|
|
7204
7222
|
])
|
|
7205
7223
|
}
|
|
7206
7224
|
|
|
7225
|
+
const vital_trigger_tests = async () => {
|
|
7226
|
+
log_header("Vital Update Trigger")
|
|
7227
|
+
|
|
7228
|
+
const runTriggerTest = async ({
|
|
7229
|
+
configurations: _configurations,
|
|
7230
|
+
triggers: _triggers,
|
|
7231
|
+
shouldTrigger,
|
|
7232
|
+
vitals,
|
|
7233
|
+
title,
|
|
7234
|
+
} : {
|
|
7235
|
+
configurations: Pick<VitalConfiguration, 'unit' | 'ranges'>[]
|
|
7236
|
+
triggers: { configurationIndexes: number[], classifications: string[] }[],
|
|
7237
|
+
vitals: (Pick<EnduserObservation, 'measurement'> & Pick<Partial<EnduserObservation>, | 'timestamp'>)[],
|
|
7238
|
+
shouldTrigger: boolean,
|
|
7239
|
+
title: string,
|
|
7240
|
+
}) => {
|
|
7241
|
+
const e = await sdk.api.endusers.createOne({ })
|
|
7242
|
+
const configurations = (
|
|
7243
|
+
await sdk.api.vital_configurations.createSome(_configurations.map((c, i) => ({
|
|
7244
|
+
title: `configuration ${i}`,
|
|
7245
|
+
...c,
|
|
7246
|
+
})))
|
|
7247
|
+
).created
|
|
7248
|
+
|
|
7249
|
+
const triggers = (
|
|
7250
|
+
await sdk.api.automation_triggers.createSome(_triggers.map((t, i) => ({
|
|
7251
|
+
title: `trigger ${i}`,
|
|
7252
|
+
status: 'Active',
|
|
7253
|
+
event: {
|
|
7254
|
+
type: "Vital Update",
|
|
7255
|
+
info: {
|
|
7256
|
+
classifications: t.classifications,
|
|
7257
|
+
configurationIds: configurations.filter((_, i) => t.configurationIndexes.includes(i)).map(c => c.id),
|
|
7258
|
+
}
|
|
7259
|
+
},
|
|
7260
|
+
action: {
|
|
7261
|
+
type: 'Add Tags',
|
|
7262
|
+
info: { tags: ['Triggered'] },
|
|
7263
|
+
},
|
|
7264
|
+
})))
|
|
7265
|
+
).created
|
|
7266
|
+
|
|
7267
|
+
await sdk.api.enduser_observations.createSome(vitals.map(v => ({
|
|
7268
|
+
...v,
|
|
7269
|
+
category: 'vital-signs',
|
|
7270
|
+
enduserId: e.id,
|
|
7271
|
+
status: 'registered',
|
|
7272
|
+
})))
|
|
7273
|
+
|
|
7274
|
+
await async_test(
|
|
7275
|
+
title,
|
|
7276
|
+
() => pollForResults(
|
|
7277
|
+
() => sdk.api.endusers.getOne(e.id),
|
|
7278
|
+
e => !!e.tags?.includes("Triggered"),
|
|
7279
|
+
50,
|
|
7280
|
+
10,
|
|
7281
|
+
!shouldTrigger
|
|
7282
|
+
),
|
|
7283
|
+
passOnAnyResult,
|
|
7284
|
+
)
|
|
7285
|
+
|
|
7286
|
+
await Promise.all([
|
|
7287
|
+
sdk.api.endusers.deleteOne(e.id),
|
|
7288
|
+
...configurations.map(c => sdk.api.vital_configurations.deleteOne(c.id)),
|
|
7289
|
+
...triggers.map(t => sdk.api.automation_triggers.deleteOne(t.id)),
|
|
7290
|
+
])
|
|
7291
|
+
}
|
|
7292
|
+
|
|
7293
|
+
const timestamp_for_day_offset = (day: number) => new Date(Date.now() - 1000 * 60 * 60 * 24 * day)
|
|
7294
|
+
|
|
7295
|
+
await runTriggerTest({
|
|
7296
|
+
title: "Basic Passing Test (Less Than Sucess)",
|
|
7297
|
+
shouldTrigger: true,
|
|
7298
|
+
configurations: [{
|
|
7299
|
+
unit: 'LB',
|
|
7300
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 0 }, ],
|
|
7301
|
+
}],
|
|
7302
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7303
|
+
vitals: [{
|
|
7304
|
+
measurement: { unit: 'LB', value: 1 },
|
|
7305
|
+
timestamp: new Date(),
|
|
7306
|
+
}]
|
|
7307
|
+
})
|
|
7308
|
+
await runTriggerTest({
|
|
7309
|
+
title: "Less Than Fail",
|
|
7310
|
+
shouldTrigger: false,
|
|
7311
|
+
configurations: [{
|
|
7312
|
+
unit: 'LB',
|
|
7313
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 1 }, trendIntervalInMS: 0 }, ],
|
|
7314
|
+
}],
|
|
7315
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7316
|
+
vitals: [{
|
|
7317
|
+
measurement: { unit: 'LB', value: 1 },
|
|
7318
|
+
timestamp: new Date(),
|
|
7319
|
+
}]
|
|
7320
|
+
})
|
|
7321
|
+
await runTriggerTest({
|
|
7322
|
+
title: "Greater Than Success",
|
|
7323
|
+
shouldTrigger: true,
|
|
7324
|
+
configurations: [{
|
|
7325
|
+
unit: 'LB',
|
|
7326
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 0 }, trendIntervalInMS: 0 }, ],
|
|
7327
|
+
}],
|
|
7328
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7329
|
+
vitals: [{
|
|
7330
|
+
measurement: { unit: 'LB', value: 1 },
|
|
7331
|
+
timestamp: new Date(),
|
|
7332
|
+
}]
|
|
7333
|
+
})
|
|
7334
|
+
await runTriggerTest({
|
|
7335
|
+
title: "Greater Than Fail",
|
|
7336
|
+
shouldTrigger: false,
|
|
7337
|
+
configurations: [{
|
|
7338
|
+
unit: 'LB',
|
|
7339
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 0 }, trendIntervalInMS: 0 }, ],
|
|
7340
|
+
}],
|
|
7341
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7342
|
+
vitals: [{
|
|
7343
|
+
measurement: { unit: 'LB', value: 0 },
|
|
7344
|
+
timestamp: new Date(),
|
|
7345
|
+
}]
|
|
7346
|
+
})
|
|
7347
|
+
await runTriggerTest({
|
|
7348
|
+
title: "Between Low Bound",
|
|
7349
|
+
shouldTrigger: true,
|
|
7350
|
+
configurations: [{
|
|
7351
|
+
unit: 'LB',
|
|
7352
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 1 } }, trendIntervalInMS: 0 }, ],
|
|
7353
|
+
}],
|
|
7354
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7355
|
+
vitals: [{
|
|
7356
|
+
measurement: { unit: 'LB', value: 0 },
|
|
7357
|
+
timestamp: new Date(),
|
|
7358
|
+
}]
|
|
7359
|
+
})
|
|
7360
|
+
await runTriggerTest({
|
|
7361
|
+
title: "Between Upper Bound",
|
|
7362
|
+
shouldTrigger: true,
|
|
7363
|
+
configurations: [{
|
|
7364
|
+
unit: 'LB',
|
|
7365
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 1 } }, trendIntervalInMS: 0 }, ],
|
|
7366
|
+
}],
|
|
7367
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7368
|
+
vitals: [{
|
|
7369
|
+
measurement: { unit: 'LB', value: 1 },
|
|
7370
|
+
timestamp: new Date(),
|
|
7371
|
+
}]
|
|
7372
|
+
})
|
|
7373
|
+
await runTriggerTest({
|
|
7374
|
+
title: "Between Middle",
|
|
7375
|
+
shouldTrigger: true,
|
|
7376
|
+
configurations: [{
|
|
7377
|
+
unit: 'LB',
|
|
7378
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 2 } }, trendIntervalInMS: 0 }, ],
|
|
7379
|
+
}],
|
|
7380
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7381
|
+
vitals: [{
|
|
7382
|
+
measurement: { unit: 'LB', value: 1 },
|
|
7383
|
+
timestamp: new Date(),
|
|
7384
|
+
}]
|
|
7385
|
+
})
|
|
7386
|
+
await runTriggerTest({
|
|
7387
|
+
title: "Between Below Low Bound",
|
|
7388
|
+
shouldTrigger: false,
|
|
7389
|
+
configurations: [{
|
|
7390
|
+
unit: 'LB',
|
|
7391
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 1 } }, trendIntervalInMS: 0 }, ],
|
|
7392
|
+
}],
|
|
7393
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7394
|
+
vitals: [{
|
|
7395
|
+
measurement: { unit: 'LB', value: -1 },
|
|
7396
|
+
timestamp: new Date(),
|
|
7397
|
+
}]
|
|
7398
|
+
})
|
|
7399
|
+
await runTriggerTest({
|
|
7400
|
+
title: "Between Above Upper Bound",
|
|
7401
|
+
shouldTrigger: false,
|
|
7402
|
+
configurations: [{
|
|
7403
|
+
unit: 'LB',
|
|
7404
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Between', value: { lower: 0, upper: 1 } }, trendIntervalInMS: 0 }, ],
|
|
7405
|
+
}],
|
|
7406
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7407
|
+
vitals: [{
|
|
7408
|
+
measurement: { unit: 'LB', value: 2 },
|
|
7409
|
+
timestamp: new Date(),
|
|
7410
|
+
}]
|
|
7411
|
+
})
|
|
7412
|
+
|
|
7413
|
+
await runTriggerTest({
|
|
7414
|
+
title: "Mismatch Unit",
|
|
7415
|
+
shouldTrigger: false,
|
|
7416
|
+
configurations: [{
|
|
7417
|
+
unit: 'DIFFERENT',
|
|
7418
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 }, ],
|
|
7419
|
+
}],
|
|
7420
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7421
|
+
vitals: [{
|
|
7422
|
+
measurement: { unit: 'LB', value: 1 },
|
|
7423
|
+
timestamp: new Date(),
|
|
7424
|
+
}]
|
|
7425
|
+
})
|
|
7426
|
+
await runTriggerTest({
|
|
7427
|
+
title: "Mismatch Classification",
|
|
7428
|
+
shouldTrigger: false,
|
|
7429
|
+
configurations: [{
|
|
7430
|
+
unit: 'LB',
|
|
7431
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 }, ],
|
|
7432
|
+
}],
|
|
7433
|
+
triggers: [{ classifications: ['High'], configurationIndexes: [0] }],
|
|
7434
|
+
vitals: [{
|
|
7435
|
+
measurement: { unit: 'LB', value: 1 },
|
|
7436
|
+
timestamp: new Date(),
|
|
7437
|
+
}]
|
|
7438
|
+
})
|
|
7439
|
+
await runTriggerTest({
|
|
7440
|
+
title: "Multiple Configurations (Classifications)",
|
|
7441
|
+
shouldTrigger: true,
|
|
7442
|
+
configurations: [{
|
|
7443
|
+
unit: 'LB',
|
|
7444
|
+
ranges: [
|
|
7445
|
+
{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 },
|
|
7446
|
+
{ classification: 'High', comparison: { type: 'Less Than', value: 100 }, trendIntervalInMS: 0 },
|
|
7447
|
+
],
|
|
7448
|
+
}],
|
|
7449
|
+
triggers: [{ classifications: ['High'], configurationIndexes: [0,1] }],
|
|
7450
|
+
vitals: [{
|
|
7451
|
+
measurement: { unit: 'LB', value: 1 },
|
|
7452
|
+
timestamp: new Date(),
|
|
7453
|
+
}]
|
|
7454
|
+
})
|
|
7455
|
+
await runTriggerTest({
|
|
7456
|
+
title: "Multiple Configurations (Comparisons)",
|
|
7457
|
+
shouldTrigger: true,
|
|
7458
|
+
configurations: [{
|
|
7459
|
+
unit: 'LB',
|
|
7460
|
+
ranges: [
|
|
7461
|
+
{ classification: 'Target', comparison: { type: 'Less Than', value: 0 }, trendIntervalInMS: 0 },
|
|
7462
|
+
{ classification: 'High', comparison: { type: 'Less Than', value: 100 }, trendIntervalInMS: 0 },
|
|
7463
|
+
],
|
|
7464
|
+
}],
|
|
7465
|
+
triggers: [{ classifications: ['High'], configurationIndexes: [0,1] }],
|
|
7466
|
+
vitals: [{
|
|
7467
|
+
measurement: { unit: 'LB', value: 1 },
|
|
7468
|
+
timestamp: new Date(),
|
|
7469
|
+
}]
|
|
7470
|
+
})
|
|
7471
|
+
|
|
7472
|
+
await runTriggerTest({
|
|
7473
|
+
title: "Multiple vitals, 0 passes",
|
|
7474
|
+
shouldTrigger: false,
|
|
7475
|
+
configurations: [{
|
|
7476
|
+
unit: 'LB',
|
|
7477
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 }, ],
|
|
7478
|
+
}],
|
|
7479
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7480
|
+
vitals: [
|
|
7481
|
+
{ measurement: { unit: 'LB', value: 500 }, timestamp: new Date() },
|
|
7482
|
+
{ measurement: { unit: 'LB', value: 1000 }, timestamp: new Date(Date.now() - 100) },
|
|
7483
|
+
{ measurement: { unit: 'LB', value: 250 }, timestamp: new Date(Date.now() - 250) },
|
|
7484
|
+
]
|
|
7485
|
+
})
|
|
7486
|
+
await runTriggerTest({
|
|
7487
|
+
title: "Multiple vitals, 1 passes",
|
|
7488
|
+
shouldTrigger: true,
|
|
7489
|
+
configurations: [{
|
|
7490
|
+
unit: 'LB',
|
|
7491
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 }, ],
|
|
7492
|
+
}],
|
|
7493
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7494
|
+
vitals: [
|
|
7495
|
+
{ measurement: { unit: 'LB', value: 500 }, timestamp: new Date() },
|
|
7496
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date(Date.now() - 100) },
|
|
7497
|
+
{ measurement: { unit: 'LB', value: 250 }, timestamp: new Date(Date.now() - 250) },
|
|
7498
|
+
]
|
|
7499
|
+
})
|
|
7500
|
+
await runTriggerTest({
|
|
7501
|
+
title: "Multiple vitals, multiple pass",
|
|
7502
|
+
shouldTrigger: true,
|
|
7503
|
+
configurations: [{
|
|
7504
|
+
unit: 'LB',
|
|
7505
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 0 }, ],
|
|
7506
|
+
}],
|
|
7507
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7508
|
+
vitals: [
|
|
7509
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
|
|
7510
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date(Date.now() - 100) },
|
|
7511
|
+
{ measurement: { unit: 'LB', value: 3 }, timestamp: new Date(Date.now() - 250) },
|
|
7512
|
+
]
|
|
7513
|
+
})
|
|
7514
|
+
|
|
7515
|
+
// trend tests
|
|
7516
|
+
await runTriggerTest({
|
|
7517
|
+
title: "Singleton trend should not work",
|
|
7518
|
+
shouldTrigger: false,
|
|
7519
|
+
configurations: [{
|
|
7520
|
+
unit: 'LB',
|
|
7521
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 200 }, trendIntervalInMS: 1000 }, ],
|
|
7522
|
+
}],
|
|
7523
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7524
|
+
vitals: [{
|
|
7525
|
+
measurement: { unit: 'LB', value: 1 },
|
|
7526
|
+
timestamp: new Date(),
|
|
7527
|
+
}]
|
|
7528
|
+
})
|
|
7529
|
+
await runTriggerTest({
|
|
7530
|
+
title: "2-point trend passing",
|
|
7531
|
+
shouldTrigger: true,
|
|
7532
|
+
configurations: [{
|
|
7533
|
+
unit: 'LB',
|
|
7534
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 1 }, trendIntervalInMS: 1000 }, ],
|
|
7535
|
+
}],
|
|
7536
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7537
|
+
vitals: [
|
|
7538
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
|
|
7539
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 999) },
|
|
7540
|
+
]
|
|
7541
|
+
})
|
|
7542
|
+
await runTriggerTest({
|
|
7543
|
+
title: "2-point trend failing for difference too small",
|
|
7544
|
+
shouldTrigger: true,
|
|
7545
|
+
configurations: [{
|
|
7546
|
+
unit: 'LB',
|
|
7547
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 1 }, trendIntervalInMS: 1000 }, ],
|
|
7548
|
+
}],
|
|
7549
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7550
|
+
vitals: [
|
|
7551
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
|
|
7552
|
+
{ measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 999) },
|
|
7553
|
+
]
|
|
7554
|
+
})
|
|
7555
|
+
await runTriggerTest({
|
|
7556
|
+
title: "2-point trend failing for point out of time range",
|
|
7557
|
+
shouldTrigger: false,
|
|
7558
|
+
configurations: [{
|
|
7559
|
+
unit: 'LB',
|
|
7560
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 5 }, trendIntervalInMS: 1000 }, ],
|
|
7561
|
+
}],
|
|
7562
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7563
|
+
vitals: [
|
|
7564
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
|
|
7565
|
+
{ measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 1001) },
|
|
7566
|
+
]
|
|
7567
|
+
})
|
|
7568
|
+
await runTriggerTest({
|
|
7569
|
+
title: "3-point trend passing (1 point of out range)",
|
|
7570
|
+
shouldTrigger: true,
|
|
7571
|
+
configurations: [{
|
|
7572
|
+
unit: 'LB',
|
|
7573
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 1000 }, ],
|
|
7574
|
+
}],
|
|
7575
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7576
|
+
vitals: [
|
|
7577
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
|
|
7578
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 100) },
|
|
7579
|
+
{ measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 1001) },
|
|
7580
|
+
]
|
|
7581
|
+
})
|
|
7582
|
+
await runTriggerTest({
|
|
7583
|
+
title: "3-point trend passing (1 point wrong unit)",
|
|
7584
|
+
shouldTrigger: true,
|
|
7585
|
+
configurations: [{
|
|
7586
|
+
unit: 'LB',
|
|
7587
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 1000 }, ],
|
|
7588
|
+
}],
|
|
7589
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7590
|
+
vitals: [
|
|
7591
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
|
|
7592
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 100) },
|
|
7593
|
+
{ measurement: { unit: 'OTHER', value: 0 }, timestamp: new Date(new Date().getTime() - 200) },
|
|
7594
|
+
]
|
|
7595
|
+
})
|
|
7596
|
+
await runTriggerTest({
|
|
7597
|
+
title: "3-point trend failing (1 point of out range)",
|
|
7598
|
+
shouldTrigger: false,
|
|
7599
|
+
configurations: [{
|
|
7600
|
+
unit: 'LB',
|
|
7601
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 1000 }, ],
|
|
7602
|
+
}],
|
|
7603
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7604
|
+
vitals: [
|
|
7605
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
|
|
7606
|
+
{ measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 100) },
|
|
7607
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 1001) },
|
|
7608
|
+
]
|
|
7609
|
+
})
|
|
7610
|
+
await runTriggerTest({
|
|
7611
|
+
title: "3-point trend failing (1 point wrong unit)",
|
|
7612
|
+
shouldTrigger: false,
|
|
7613
|
+
configurations: [{
|
|
7614
|
+
unit: 'LB',
|
|
7615
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Less Than', value: 2 }, trendIntervalInMS: 1000 }, ],
|
|
7616
|
+
}],
|
|
7617
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7618
|
+
vitals: [
|
|
7619
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
|
|
7620
|
+
{ measurement: { unit: 'LB', value: 0 }, timestamp: new Date(new Date().getTime() - 100) },
|
|
7621
|
+
{ measurement: { unit: 'OTHER', value: 1 }, timestamp: new Date(new Date().getTime() - 200) },
|
|
7622
|
+
]
|
|
7623
|
+
})
|
|
7624
|
+
await runTriggerTest({
|
|
7625
|
+
title: "multiple trend passing",
|
|
7626
|
+
shouldTrigger: true,
|
|
7627
|
+
configurations: [{
|
|
7628
|
+
unit: 'LB',
|
|
7629
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 }, ],
|
|
7630
|
+
}],
|
|
7631
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7632
|
+
vitals: [
|
|
7633
|
+
{ measurement: { unit: 'LB', value: 3 }, timestamp: new Date() },
|
|
7634
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
|
|
7635
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 200) },
|
|
7636
|
+
]
|
|
7637
|
+
})
|
|
7638
|
+
await runTriggerTest({
|
|
7639
|
+
title: "multiple trend failing (not enough)",
|
|
7640
|
+
shouldTrigger: false,
|
|
7641
|
+
configurations: [{
|
|
7642
|
+
unit: 'LB',
|
|
7643
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 }, ],
|
|
7644
|
+
}],
|
|
7645
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7646
|
+
vitals: [
|
|
7647
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date() },
|
|
7648
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
|
|
7649
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 200) },
|
|
7650
|
+
]
|
|
7651
|
+
})
|
|
7652
|
+
await runTriggerTest({
|
|
7653
|
+
title: "multiple trend failing (wrong order)",
|
|
7654
|
+
shouldTrigger: false,
|
|
7655
|
+
configurations: [{
|
|
7656
|
+
unit: 'LB',
|
|
7657
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 }, ],
|
|
7658
|
+
}],
|
|
7659
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7660
|
+
vitals: [
|
|
7661
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
|
|
7662
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
|
|
7663
|
+
{ measurement: { unit: 'LB', value: 3 }, timestamp: new Date(new Date().getTime() - 200) },
|
|
7664
|
+
]
|
|
7665
|
+
})
|
|
7666
|
+
await runTriggerTest({
|
|
7667
|
+
title: "multiple trend failing (not enough, and wrong order)",
|
|
7668
|
+
shouldTrigger: false,
|
|
7669
|
+
configurations: [{
|
|
7670
|
+
unit: 'LB',
|
|
7671
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 }, ],
|
|
7672
|
+
}],
|
|
7673
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7674
|
+
vitals: [
|
|
7675
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
|
|
7676
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
|
|
7677
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 200) },
|
|
7678
|
+
]
|
|
7679
|
+
})
|
|
7680
|
+
await runTriggerTest({
|
|
7681
|
+
title: "multiple trend failing (lots)",
|
|
7682
|
+
shouldTrigger: false,
|
|
7683
|
+
configurations: [{
|
|
7684
|
+
unit: 'LB',
|
|
7685
|
+
ranges: [{ classification: 'Target', comparison: { type: 'Greater Than', value: 1 }, trendIntervalInMS: 1000 }, ],
|
|
7686
|
+
}],
|
|
7687
|
+
triggers: [{ classifications: ['Target'], configurationIndexes: [0] }],
|
|
7688
|
+
vitals: [
|
|
7689
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date() },
|
|
7690
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 100) },
|
|
7691
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 200) },
|
|
7692
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 300) },
|
|
7693
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 400) },
|
|
7694
|
+
{ measurement: { unit: 'LB', value: 2 }, timestamp: new Date(new Date().getTime() - 500) },
|
|
7695
|
+
{ measurement: { unit: 'LB', value: 1 }, timestamp: new Date(new Date().getTime() - 600) },
|
|
7696
|
+
]
|
|
7697
|
+
})
|
|
7698
|
+
}
|
|
7699
|
+
|
|
7207
7700
|
(async () => {
|
|
7208
7701
|
log_header("API")
|
|
7209
7702
|
|
|
@@ -7254,9 +7747,11 @@ const close_reasons_no_duplicates_tests = async () => {
|
|
|
7254
7747
|
await mfa_tests()
|
|
7255
7748
|
await setup_tests()
|
|
7256
7749
|
await multi_tenant_tests() // should come right after setup tests
|
|
7750
|
+
await sync_tests() // should come directly after setup to avoid extra sync values
|
|
7751
|
+
await vital_trigger_tests()
|
|
7752
|
+
await ticket_queue_tests()
|
|
7257
7753
|
await close_reasons_no_duplicates_tests()
|
|
7258
7754
|
await register_as_enduser_tests()
|
|
7259
|
-
await sync_tests()
|
|
7260
7755
|
await lockout_tests()
|
|
7261
7756
|
await self_serve_appointment_booking_tests()
|
|
7262
7757
|
await delete_user_tests()
|
|
@@ -7267,7 +7762,6 @@ const close_reasons_no_duplicates_tests = async () => {
|
|
|
7267
7762
|
await marketing_email_unsubscribe_tests()
|
|
7268
7763
|
await unique_strings_tests()
|
|
7269
7764
|
await alternate_phones_tests()
|
|
7270
|
-
await ticket_queue_tests()
|
|
7271
7765
|
await no_chained_triggers_tests()
|
|
7272
7766
|
await field_equals_trigger_tests()
|
|
7273
7767
|
await test_ticket_automation_assignment_and_optimization()
|
package/test_generated.pdf
CHANGED
|
Binary file
|