@tellescope/sdk 1.5.0 → 1.5.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/tests/tests.d.ts +1 -0
- package/lib/cjs/tests/tests.d.ts.map +1 -1
- package/lib/cjs/tests/tests.js +141 -16
- package/lib/cjs/tests/tests.js.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 +139 -15
- package/lib/esm/tests/tests.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/tests/tests.ts +99 -1
package/lib/esm/tests/tests.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const formUnsubmittedCancelConditionTest: () => Promise<void>;
|
|
2
2
|
export declare const formsUnsubmittedCancelConditionTest: () => Promise<void>;
|
|
3
3
|
export declare const formsUnsubmittedTest: () => Promise<void>;
|
|
4
|
+
export declare const formsSubmittedNoUnsubmittedTest: () => Promise<void>;
|
|
4
5
|
export declare const automationSameJourneyTests: () => Promise<void>;
|
|
5
6
|
export declare const meetings_tests: () => Promise<void>;
|
|
6
7
|
export declare const managed_content_records_tests: () => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["../../../src/tests/tests.ts"],"names":[],"mappings":"AAw/DA,eAAO,MAAM,kCAAkC,qBA4I9C,CAAA;AAED,eAAO,MAAM,mCAAmC,qBAsK/C,CAAA;AAGD,eAAO,MAAM,oBAAoB,qBAkHhC,CAAA;
|
|
1
|
+
{"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["../../../src/tests/tests.ts"],"names":[],"mappings":"AAw/DA,eAAO,MAAM,kCAAkC,qBA4I9C,CAAA;AAED,eAAO,MAAM,mCAAmC,qBAsK/C,CAAA;AAGD,eAAO,MAAM,oBAAoB,qBAkHhC,CAAA;AAED,eAAO,MAAM,+BAA+B,qBAsF3C,CAAA;AAID,eAAO,MAAM,0BAA0B,qBAqCtC,CAAA;AAwJD,eAAO,MAAM,cAAc,qBAqC1B,CAAA;AA0eD,eAAO,MAAM,6BAA6B,qBAgCzC,CAAA;AAED,eAAO,MAAM,0BAA0B,qBAmFtC,CAAA;AAoED,eAAO,MAAM,eAAe,qBA8C3B,CAAA;AAED,eAAO,MAAM,oBAAoB,6BAsBhC,CAAA;AAED,eAAO,MAAM,oCAAoC,qBAuJhD,CAAA;AAED,eAAO,MAAM,mCAAmC,qBAkE/C,CAAA"}
|
package/lib/esm/tests/tests.js
CHANGED
|
@@ -3061,6 +3061,121 @@ export var formsUnsubmittedTest = function () { return __awaiter(void 0, void 0,
|
|
|
3061
3061
|
}
|
|
3062
3062
|
});
|
|
3063
3063
|
}); };
|
|
3064
|
+
export var formsSubmittedNoUnsubmittedTest = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3065
|
+
var enduser, journey, form, field, triggerStep, form_responses;
|
|
3066
|
+
return __generator(this, function (_a) {
|
|
3067
|
+
switch (_a.label) {
|
|
3068
|
+
case 0:
|
|
3069
|
+
log_header("formsSubmitted, with no unsubmitted branch, Tests");
|
|
3070
|
+
return [4 /*yield*/, sdk.api.endusers.createOne({ email: 'deletemeee@tellescope.com' })];
|
|
3071
|
+
case 1:
|
|
3072
|
+
enduser = _a.sent();
|
|
3073
|
+
return [4 /*yield*/, sdk.api.journeys.createOne({ title: 'test journey ' })];
|
|
3074
|
+
case 2:
|
|
3075
|
+
journey = _a.sent();
|
|
3076
|
+
return [4 /*yield*/, sdk.api.forms.createOne({ title: 'test form' })];
|
|
3077
|
+
case 3:
|
|
3078
|
+
form = _a.sent();
|
|
3079
|
+
return [4 /*yield*/, sdk.api.form_fields.createOne({
|
|
3080
|
+
formId: form.id, title: 'question', type: 'string',
|
|
3081
|
+
previousFields: [{ type: 'root', info: {} }]
|
|
3082
|
+
})
|
|
3083
|
+
// this action won't be fired, because patient isn't added to journey as part of tests
|
|
3084
|
+
];
|
|
3085
|
+
case 4:
|
|
3086
|
+
field = _a.sent();
|
|
3087
|
+
return [4 /*yield*/, sdk.api.automation_steps.createOne({
|
|
3088
|
+
journeyId: journey.id,
|
|
3089
|
+
events: [{ type: 'onJourneyStart', info: {} }],
|
|
3090
|
+
// in practice, this would send a form, so that the next step(s) could handle the response
|
|
3091
|
+
// but we don't want to send emails in testing, and can still attach this Id to a form response to test a trigger
|
|
3092
|
+
action: {
|
|
3093
|
+
type: 'setEnduserStatus',
|
|
3094
|
+
info: { status: 'start' },
|
|
3095
|
+
},
|
|
3096
|
+
})
|
|
3097
|
+
// test for all forms submitted triggering update
|
|
3098
|
+
];
|
|
3099
|
+
case 5:
|
|
3100
|
+
triggerStep = _a.sent();
|
|
3101
|
+
// test for all forms submitted triggering update
|
|
3102
|
+
return [4 /*yield*/, sdk.api.automation_steps.createOne({
|
|
3103
|
+
journeyId: journey.id,
|
|
3104
|
+
events: [{
|
|
3105
|
+
type: 'formResponses',
|
|
3106
|
+
info: { automationStepId: triggerStep.id }
|
|
3107
|
+
}],
|
|
3108
|
+
action: {
|
|
3109
|
+
type: 'setEnduserStatus',
|
|
3110
|
+
info: { status: 'formsSubmitted' },
|
|
3111
|
+
},
|
|
3112
|
+
})
|
|
3113
|
+
// simulates sending 2 outstanding forms to pt with expected follow-up
|
|
3114
|
+
];
|
|
3115
|
+
case 6:
|
|
3116
|
+
// test for all forms submitted triggering update
|
|
3117
|
+
_a.sent();
|
|
3118
|
+
// simulates sending 2 outstanding forms to pt with expected follow-up
|
|
3119
|
+
return [4 /*yield*/, sdk.api.templates.get_templated_message({
|
|
3120
|
+
channel: 'Email',
|
|
3121
|
+
enduserId: enduser.id,
|
|
3122
|
+
message: "{{forms.".concat(form.id, ".link:title}} {{forms.").concat(form.id, ".link:title}}"),
|
|
3123
|
+
userId: sdk.userInfo.id,
|
|
3124
|
+
automationStepId: triggerStep.id,
|
|
3125
|
+
})];
|
|
3126
|
+
case 7:
|
|
3127
|
+
// simulates sending 2 outstanding forms to pt with expected follow-up
|
|
3128
|
+
_a.sent();
|
|
3129
|
+
return [4 /*yield*/, sdk.api.form_responses.getSome()
|
|
3130
|
+
// trigger submission
|
|
3131
|
+
];
|
|
3132
|
+
case 8:
|
|
3133
|
+
form_responses = _a.sent();
|
|
3134
|
+
// trigger submission
|
|
3135
|
+
return [4 /*yield*/, sdk.api.form_responses.submit_form_response({ accessCode: form_responses[0].accessCode, automationStepId: triggerStep.id, responses: [{
|
|
3136
|
+
answer: {
|
|
3137
|
+
type: 'string',
|
|
3138
|
+
value: 'answer'
|
|
3139
|
+
},
|
|
3140
|
+
fieldId: field.id,
|
|
3141
|
+
fieldTitle: field.title,
|
|
3142
|
+
}] })];
|
|
3143
|
+
case 9:
|
|
3144
|
+
// trigger submission
|
|
3145
|
+
_a.sent();
|
|
3146
|
+
return [4 /*yield*/, wait(undefined, 5000)]; // allow background creation with generous pause
|
|
3147
|
+
case 10:
|
|
3148
|
+
_a.sent(); // allow background creation with generous pause
|
|
3149
|
+
return [4 /*yield*/, async_test("formResponses not triggered yet after 1 form remaining", function () { return sdk.api.endusers.getOne(enduser.id); }, { onResult: function (e) { var _a; return ((_a = e === null || e === void 0 ? void 0 : e.journeys) === null || _a === void 0 ? void 0 : _a[journey.id]) !== 'formsSubmitted'; } })];
|
|
3150
|
+
case 11:
|
|
3151
|
+
_a.sent();
|
|
3152
|
+
return [4 /*yield*/, sdk.api.form_responses.submit_form_response({ accessCode: form_responses[1].accessCode, automationStepId: triggerStep.id, responses: [{
|
|
3153
|
+
answer: {
|
|
3154
|
+
type: 'string',
|
|
3155
|
+
value: 'answer'
|
|
3156
|
+
},
|
|
3157
|
+
fieldId: field.id,
|
|
3158
|
+
fieldTitle: field.title,
|
|
3159
|
+
}] })];
|
|
3160
|
+
case 12:
|
|
3161
|
+
_a.sent();
|
|
3162
|
+
return [4 /*yield*/, wait(undefined, 5000)]; // allow background creation with generous pause
|
|
3163
|
+
case 13:
|
|
3164
|
+
_a.sent(); // allow background creation with generous pause
|
|
3165
|
+
return [4 /*yield*/, async_test("formResponses triggered after both forms submitted", function () { return sdk.api.endusers.getOne(enduser.id); }, { onResult: function (e) { var _a; return ((_a = e === null || e === void 0 ? void 0 : e.journeys) === null || _a === void 0 ? void 0 : _a[journey.id]) === 'formsSubmitted'; } })];
|
|
3166
|
+
case 14:
|
|
3167
|
+
_a.sent();
|
|
3168
|
+
return [4 /*yield*/, Promise.all([
|
|
3169
|
+
sdk.api.forms.deleteOne(form.id),
|
|
3170
|
+
sdk.api.journeys.deleteOne(journey.id),
|
|
3171
|
+
sdk.api.endusers.deleteOne(enduser.id)
|
|
3172
|
+
])];
|
|
3173
|
+
case 15:
|
|
3174
|
+
_a.sent();
|
|
3175
|
+
return [2 /*return*/];
|
|
3176
|
+
}
|
|
3177
|
+
});
|
|
3178
|
+
}); };
|
|
3064
3179
|
// ensure child steps come from the same journey
|
|
3065
3180
|
export var automationSameJourneyTests = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3066
3181
|
var journey, journey2, badRoot;
|
|
@@ -3146,27 +3261,33 @@ var addToJourneyTests = function () { return __awaiter(void 0, void 0, void 0, f
|
|
|
3146
3261
|
case 5:
|
|
3147
3262
|
// add to journey and re-add
|
|
3148
3263
|
_a.sent();
|
|
3149
|
-
return [4 /*yield*/, wait(undefined,
|
|
3264
|
+
return [4 /*yield*/, wait(undefined, 250)];
|
|
3150
3265
|
case 6:
|
|
3151
|
-
_a.sent();
|
|
3152
|
-
return [4 /*yield*/, sdk.api.endusers.
|
|
3266
|
+
_a.sent();
|
|
3267
|
+
return [4 /*yield*/, async_test("Journey state correctly set by add_to_journey (to default state)", function () { return sdk.api.endusers.getOne(enduser.id); }, { onResult: function (e) { var _a; return ((_a = e.journeys) === null || _a === void 0 ? void 0 : _a[journey.id]) === 'New'; } })];
|
|
3153
3268
|
case 7:
|
|
3154
3269
|
_a.sent();
|
|
3155
3270
|
return [4 /*yield*/, wait(undefined, 4000)]; // allow onJourneyStart step to trigger
|
|
3156
3271
|
case 8:
|
|
3272
|
+
_a.sent(); // allow onJourneyStart step to trigger
|
|
3273
|
+
return [4 /*yield*/, sdk.api.endusers.add_to_journey({ enduserIds: [enduser.id], journeyId: journey.id })];
|
|
3274
|
+
case 9:
|
|
3275
|
+
_a.sent();
|
|
3276
|
+
return [4 /*yield*/, wait(undefined, 4000)]; // allow onJourneyStart step to trigger
|
|
3277
|
+
case 10:
|
|
3157
3278
|
_a.sent(); // allow onJourneyStart step to trigger
|
|
3158
3279
|
return [4 /*yield*/, async_test("Enduser correctly added and re-added", function () { return sdk.api.automated_actions.getSome(); }, { onResult: function (es) { return es.length === 4
|
|
3159
3280
|
&& es.filter(function (e) { return e.status === 'cancelled' && e.automationStepId === follow.id; }).length === 1 // one afterAction is cancelled
|
|
3160
3281
|
&& es.filter(function (e) { return e.status === 'active' && e.automationStepId === follow.id; }).length === 1 // one afterAction is still active
|
|
3161
3282
|
&& es.filter(function (e) { return e.status === 'finished' && e.automationStepId === root.id; }).length === 2; } // two initial onJourneyStart
|
|
3162
3283
|
})];
|
|
3163
|
-
case
|
|
3284
|
+
case 11:
|
|
3164
3285
|
_a.sent();
|
|
3165
3286
|
return [4 /*yield*/, Promise.all([
|
|
3166
3287
|
sdk.api.journeys.deleteOne(journey.id),
|
|
3167
3288
|
sdk.api.endusers.deleteOne(enduser.id),
|
|
3168
3289
|
])];
|
|
3169
|
-
case
|
|
3290
|
+
case 12:
|
|
3170
3291
|
_a.sent();
|
|
3171
3292
|
return [2 /*return*/];
|
|
3172
3293
|
}
|
|
@@ -3177,32 +3298,35 @@ var automation_events_tests = function () { return __awaiter(void 0, void 0, voi
|
|
|
3177
3298
|
switch (_a.label) {
|
|
3178
3299
|
case 0:
|
|
3179
3300
|
log_header("Automation Events");
|
|
3180
|
-
return [4 /*yield*/,
|
|
3301
|
+
return [4 /*yield*/, formsSubmittedNoUnsubmittedTest()];
|
|
3181
3302
|
case 1:
|
|
3182
3303
|
_a.sent();
|
|
3183
|
-
return [4 /*yield*/,
|
|
3304
|
+
return [4 /*yield*/, automationSameJourneyTests()];
|
|
3184
3305
|
case 2:
|
|
3185
3306
|
_a.sent();
|
|
3186
|
-
return [4 /*yield*/,
|
|
3307
|
+
return [4 /*yield*/, formsUnsubmittedTest()];
|
|
3187
3308
|
case 3:
|
|
3188
3309
|
_a.sent();
|
|
3189
|
-
return [4 /*yield*/,
|
|
3310
|
+
return [4 /*yield*/, formsUnsubmittedCancelConditionTest()];
|
|
3190
3311
|
case 4:
|
|
3191
3312
|
_a.sent();
|
|
3192
|
-
return [4 /*yield*/,
|
|
3313
|
+
return [4 /*yield*/, formUnsubmittedCancelConditionTest()];
|
|
3193
3314
|
case 5:
|
|
3194
3315
|
_a.sent();
|
|
3195
|
-
return [4 /*yield*/,
|
|
3316
|
+
return [4 /*yield*/, addToJourneyTests()];
|
|
3196
3317
|
case 6:
|
|
3197
3318
|
_a.sent();
|
|
3198
|
-
return [4 /*yield*/,
|
|
3319
|
+
return [4 /*yield*/, sequenceTests()];
|
|
3199
3320
|
case 7:
|
|
3200
3321
|
_a.sent();
|
|
3201
|
-
return [4 /*yield*/,
|
|
3322
|
+
return [4 /*yield*/, formEventTests()];
|
|
3202
3323
|
case 8:
|
|
3203
3324
|
_a.sent();
|
|
3204
|
-
return [4 /*yield*/,
|
|
3325
|
+
return [4 /*yield*/, ticketEventTests()];
|
|
3205
3326
|
case 9:
|
|
3327
|
+
_a.sent();
|
|
3328
|
+
return [4 /*yield*/, removeFromJourneyTests()];
|
|
3329
|
+
case 10:
|
|
3206
3330
|
_a.sent();
|
|
3207
3331
|
return [2 /*return*/];
|
|
3208
3332
|
}
|
|
@@ -4614,11 +4738,11 @@ var auto_reply_tests = function () { return __awaiter(void 0, void 0, void 0, fu
|
|
|
4614
4738
|
}); };
|
|
4615
4739
|
var NO_TEST = function () { };
|
|
4616
4740
|
var tests = {
|
|
4741
|
+
automation_steps: automation_events_tests,
|
|
4617
4742
|
background_errors: NO_TEST,
|
|
4618
4743
|
enduser_views: NO_TEST,
|
|
4619
4744
|
availability_blocks: NO_TEST,
|
|
4620
4745
|
analytics_frames: NO_TEST,
|
|
4621
|
-
automation_steps: automation_events_tests,
|
|
4622
4746
|
products: NO_TEST,
|
|
4623
4747
|
purchase_credits: NO_TEST,
|
|
4624
4748
|
purchases: NO_TEST,
|