@tellescope/sdk 1.5.0 → 1.5.2
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 +159 -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 +157 -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 +118 -1
package/lib/cjs/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/cjs/tests/tests.js
CHANGED
|
@@ -82,7 +82,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
82
82
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
83
83
|
};
|
|
84
84
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
85
|
-
exports.role_based_access_permissions_tests = exports.self_serve_appointment_booking_tests = exports.filter_by_date_tests = exports.databases_tests = exports.calendar_event_RSVPs_tests = exports.managed_content_records_tests = exports.meetings_tests = exports.automationSameJourneyTests = exports.formsUnsubmittedTest = exports.formsUnsubmittedCancelConditionTest = exports.formUnsubmittedCancelConditionTest = void 0;
|
|
85
|
+
exports.role_based_access_permissions_tests = exports.self_serve_appointment_booking_tests = exports.filter_by_date_tests = exports.databases_tests = exports.calendar_event_RSVPs_tests = exports.managed_content_records_tests = exports.meetings_tests = exports.automationSameJourneyTests = exports.formsSubmittedNoUnsubmittedTest = exports.formsUnsubmittedTest = exports.formsUnsubmittedCancelConditionTest = exports.formUnsubmittedCancelConditionTest = void 0;
|
|
86
86
|
require('source-map-support').install();
|
|
87
87
|
var crypto_1 = __importDefault(require("crypto"));
|
|
88
88
|
var buffer = __importStar(require("buffer")); // only node >=15.7.0
|
|
@@ -3093,6 +3093,122 @@ var formsUnsubmittedTest = function () { return __awaiter(void 0, void 0, void 0
|
|
|
3093
3093
|
});
|
|
3094
3094
|
}); };
|
|
3095
3095
|
exports.formsUnsubmittedTest = formsUnsubmittedTest;
|
|
3096
|
+
var formsSubmittedNoUnsubmittedTest = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3097
|
+
var enduser, journey, form, field, triggerStep, form_responses;
|
|
3098
|
+
return __generator(this, function (_a) {
|
|
3099
|
+
switch (_a.label) {
|
|
3100
|
+
case 0:
|
|
3101
|
+
(0, testing_1.log_header)("formsSubmitted, with no unsubmitted branch, Tests");
|
|
3102
|
+
return [4 /*yield*/, sdk.api.endusers.createOne({ email: 'deletemeee@tellescope.com' })];
|
|
3103
|
+
case 1:
|
|
3104
|
+
enduser = _a.sent();
|
|
3105
|
+
return [4 /*yield*/, sdk.api.journeys.createOne({ title: 'test journey ' })];
|
|
3106
|
+
case 2:
|
|
3107
|
+
journey = _a.sent();
|
|
3108
|
+
return [4 /*yield*/, sdk.api.forms.createOne({ title: 'test form' })];
|
|
3109
|
+
case 3:
|
|
3110
|
+
form = _a.sent();
|
|
3111
|
+
return [4 /*yield*/, sdk.api.form_fields.createOne({
|
|
3112
|
+
formId: form.id, title: 'question', type: 'string',
|
|
3113
|
+
previousFields: [{ type: 'root', info: {} }]
|
|
3114
|
+
})
|
|
3115
|
+
// this action won't be fired, because patient isn't added to journey as part of tests
|
|
3116
|
+
];
|
|
3117
|
+
case 4:
|
|
3118
|
+
field = _a.sent();
|
|
3119
|
+
return [4 /*yield*/, sdk.api.automation_steps.createOne({
|
|
3120
|
+
journeyId: journey.id,
|
|
3121
|
+
events: [{ type: 'onJourneyStart', info: {} }],
|
|
3122
|
+
// in practice, this would send a form, so that the next step(s) could handle the response
|
|
3123
|
+
// but we don't want to send emails in testing, and can still attach this Id to a form response to test a trigger
|
|
3124
|
+
action: {
|
|
3125
|
+
type: 'setEnduserStatus',
|
|
3126
|
+
info: { status: 'start' },
|
|
3127
|
+
},
|
|
3128
|
+
})
|
|
3129
|
+
// test for all forms submitted triggering update
|
|
3130
|
+
];
|
|
3131
|
+
case 5:
|
|
3132
|
+
triggerStep = _a.sent();
|
|
3133
|
+
// test for all forms submitted triggering update
|
|
3134
|
+
return [4 /*yield*/, sdk.api.automation_steps.createOne({
|
|
3135
|
+
journeyId: journey.id,
|
|
3136
|
+
events: [{
|
|
3137
|
+
type: 'formResponses',
|
|
3138
|
+
info: { automationStepId: triggerStep.id }
|
|
3139
|
+
}],
|
|
3140
|
+
action: {
|
|
3141
|
+
type: 'setEnduserStatus',
|
|
3142
|
+
info: { status: 'formsSubmitted' },
|
|
3143
|
+
},
|
|
3144
|
+
})
|
|
3145
|
+
// simulates sending 2 outstanding forms to pt with expected follow-up
|
|
3146
|
+
];
|
|
3147
|
+
case 6:
|
|
3148
|
+
// test for all forms submitted triggering update
|
|
3149
|
+
_a.sent();
|
|
3150
|
+
// simulates sending 2 outstanding forms to pt with expected follow-up
|
|
3151
|
+
return [4 /*yield*/, sdk.api.templates.get_templated_message({
|
|
3152
|
+
channel: 'Email',
|
|
3153
|
+
enduserId: enduser.id,
|
|
3154
|
+
message: "{{forms.".concat(form.id, ".link:title}} {{forms.").concat(form.id, ".link:title}}"),
|
|
3155
|
+
userId: sdk.userInfo.id,
|
|
3156
|
+
automationStepId: triggerStep.id,
|
|
3157
|
+
})];
|
|
3158
|
+
case 7:
|
|
3159
|
+
// simulates sending 2 outstanding forms to pt with expected follow-up
|
|
3160
|
+
_a.sent();
|
|
3161
|
+
return [4 /*yield*/, sdk.api.form_responses.getSome()
|
|
3162
|
+
// trigger submission
|
|
3163
|
+
];
|
|
3164
|
+
case 8:
|
|
3165
|
+
form_responses = _a.sent();
|
|
3166
|
+
// trigger submission
|
|
3167
|
+
return [4 /*yield*/, sdk.api.form_responses.submit_form_response({ accessCode: form_responses[0].accessCode, automationStepId: triggerStep.id, responses: [{
|
|
3168
|
+
answer: {
|
|
3169
|
+
type: 'string',
|
|
3170
|
+
value: 'answer'
|
|
3171
|
+
},
|
|
3172
|
+
fieldId: field.id,
|
|
3173
|
+
fieldTitle: field.title,
|
|
3174
|
+
}] })];
|
|
3175
|
+
case 9:
|
|
3176
|
+
// trigger submission
|
|
3177
|
+
_a.sent();
|
|
3178
|
+
return [4 /*yield*/, (0, testing_1.wait)(undefined, 5000)]; // allow background creation with generous pause
|
|
3179
|
+
case 10:
|
|
3180
|
+
_a.sent(); // allow background creation with generous pause
|
|
3181
|
+
return [4 /*yield*/, (0, testing_1.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'; } })];
|
|
3182
|
+
case 11:
|
|
3183
|
+
_a.sent();
|
|
3184
|
+
return [4 /*yield*/, sdk.api.form_responses.submit_form_response({ accessCode: form_responses[1].accessCode, automationStepId: triggerStep.id, responses: [{
|
|
3185
|
+
answer: {
|
|
3186
|
+
type: 'string',
|
|
3187
|
+
value: 'answer'
|
|
3188
|
+
},
|
|
3189
|
+
fieldId: field.id,
|
|
3190
|
+
fieldTitle: field.title,
|
|
3191
|
+
}] })];
|
|
3192
|
+
case 12:
|
|
3193
|
+
_a.sent();
|
|
3194
|
+
return [4 /*yield*/, (0, testing_1.wait)(undefined, 5000)]; // allow background creation with generous pause
|
|
3195
|
+
case 13:
|
|
3196
|
+
_a.sent(); // allow background creation with generous pause
|
|
3197
|
+
return [4 /*yield*/, (0, testing_1.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'; } })];
|
|
3198
|
+
case 14:
|
|
3199
|
+
_a.sent();
|
|
3200
|
+
return [4 /*yield*/, Promise.all([
|
|
3201
|
+
sdk.api.forms.deleteOne(form.id),
|
|
3202
|
+
sdk.api.journeys.deleteOne(journey.id),
|
|
3203
|
+
sdk.api.endusers.deleteOne(enduser.id)
|
|
3204
|
+
])];
|
|
3205
|
+
case 15:
|
|
3206
|
+
_a.sent();
|
|
3207
|
+
return [2 /*return*/];
|
|
3208
|
+
}
|
|
3209
|
+
});
|
|
3210
|
+
}); };
|
|
3211
|
+
exports.formsSubmittedNoUnsubmittedTest = formsSubmittedNoUnsubmittedTest;
|
|
3096
3212
|
// ensure child steps come from the same journey
|
|
3097
3213
|
var automationSameJourneyTests = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3098
3214
|
var journey, journey2, badRoot;
|
|
@@ -3179,27 +3295,33 @@ var addToJourneyTests = function () { return __awaiter(void 0, void 0, void 0, f
|
|
|
3179
3295
|
case 5:
|
|
3180
3296
|
// add to journey and re-add
|
|
3181
3297
|
_a.sent();
|
|
3182
|
-
return [4 /*yield*/, (0, testing_1.wait)(undefined,
|
|
3298
|
+
return [4 /*yield*/, (0, testing_1.wait)(undefined, 250)];
|
|
3183
3299
|
case 6:
|
|
3184
|
-
_a.sent();
|
|
3185
|
-
return [4 /*yield*/, sdk.api.endusers.
|
|
3300
|
+
_a.sent();
|
|
3301
|
+
return [4 /*yield*/, (0, testing_1.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'; } })];
|
|
3186
3302
|
case 7:
|
|
3187
3303
|
_a.sent();
|
|
3188
3304
|
return [4 /*yield*/, (0, testing_1.wait)(undefined, 4000)]; // allow onJourneyStart step to trigger
|
|
3189
3305
|
case 8:
|
|
3306
|
+
_a.sent(); // allow onJourneyStart step to trigger
|
|
3307
|
+
return [4 /*yield*/, sdk.api.endusers.add_to_journey({ enduserIds: [enduser.id], journeyId: journey.id })];
|
|
3308
|
+
case 9:
|
|
3309
|
+
_a.sent();
|
|
3310
|
+
return [4 /*yield*/, (0, testing_1.wait)(undefined, 4000)]; // allow onJourneyStart step to trigger
|
|
3311
|
+
case 10:
|
|
3190
3312
|
_a.sent(); // allow onJourneyStart step to trigger
|
|
3191
3313
|
return [4 /*yield*/, (0, testing_1.async_test)("Enduser correctly added and re-added", function () { return sdk.api.automated_actions.getSome(); }, { onResult: function (es) { return es.length === 4
|
|
3192
3314
|
&& es.filter(function (e) { return e.status === 'cancelled' && e.automationStepId === follow.id; }).length === 1 // one afterAction is cancelled
|
|
3193
3315
|
&& es.filter(function (e) { return e.status === 'active' && e.automationStepId === follow.id; }).length === 1 // one afterAction is still active
|
|
3194
3316
|
&& es.filter(function (e) { return e.status === 'finished' && e.automationStepId === root.id; }).length === 2; } // two initial onJourneyStart
|
|
3195
3317
|
})];
|
|
3196
|
-
case
|
|
3318
|
+
case 11:
|
|
3197
3319
|
_a.sent();
|
|
3198
3320
|
return [4 /*yield*/, Promise.all([
|
|
3199
3321
|
sdk.api.journeys.deleteOne(journey.id),
|
|
3200
3322
|
sdk.api.endusers.deleteOne(enduser.id),
|
|
3201
3323
|
])];
|
|
3202
|
-
case
|
|
3324
|
+
case 12:
|
|
3203
3325
|
_a.sent();
|
|
3204
3326
|
return [2 /*return*/];
|
|
3205
3327
|
}
|
|
@@ -3210,32 +3332,35 @@ var automation_events_tests = function () { return __awaiter(void 0, void 0, voi
|
|
|
3210
3332
|
switch (_a.label) {
|
|
3211
3333
|
case 0:
|
|
3212
3334
|
(0, testing_1.log_header)("Automation Events");
|
|
3213
|
-
return [4 /*yield*/, (0, exports.
|
|
3335
|
+
return [4 /*yield*/, (0, exports.formsSubmittedNoUnsubmittedTest)()];
|
|
3214
3336
|
case 1:
|
|
3215
3337
|
_a.sent();
|
|
3216
|
-
return [4 /*yield*/, (0, exports.
|
|
3338
|
+
return [4 /*yield*/, (0, exports.automationSameJourneyTests)()];
|
|
3217
3339
|
case 2:
|
|
3218
3340
|
_a.sent();
|
|
3219
|
-
return [4 /*yield*/, (0, exports.
|
|
3341
|
+
return [4 /*yield*/, (0, exports.formsUnsubmittedTest)()];
|
|
3220
3342
|
case 3:
|
|
3221
3343
|
_a.sent();
|
|
3222
|
-
return [4 /*yield*/, (0, exports.
|
|
3344
|
+
return [4 /*yield*/, (0, exports.formsUnsubmittedCancelConditionTest)()];
|
|
3223
3345
|
case 4:
|
|
3224
3346
|
_a.sent();
|
|
3225
|
-
return [4 /*yield*/,
|
|
3347
|
+
return [4 /*yield*/, (0, exports.formUnsubmittedCancelConditionTest)()];
|
|
3226
3348
|
case 5:
|
|
3227
3349
|
_a.sent();
|
|
3228
|
-
return [4 /*yield*/,
|
|
3350
|
+
return [4 /*yield*/, addToJourneyTests()];
|
|
3229
3351
|
case 6:
|
|
3230
3352
|
_a.sent();
|
|
3231
|
-
return [4 /*yield*/,
|
|
3353
|
+
return [4 /*yield*/, sequenceTests()];
|
|
3232
3354
|
case 7:
|
|
3233
3355
|
_a.sent();
|
|
3234
|
-
return [4 /*yield*/,
|
|
3356
|
+
return [4 /*yield*/, formEventTests()];
|
|
3235
3357
|
case 8:
|
|
3236
3358
|
_a.sent();
|
|
3237
|
-
return [4 /*yield*/,
|
|
3359
|
+
return [4 /*yield*/, ticketEventTests()];
|
|
3238
3360
|
case 9:
|
|
3361
|
+
_a.sent();
|
|
3362
|
+
return [4 /*yield*/, removeFromJourneyTests()];
|
|
3363
|
+
case 10:
|
|
3239
3364
|
_a.sent();
|
|
3240
3365
|
return [2 /*return*/];
|
|
3241
3366
|
}
|
|
@@ -4654,11 +4779,11 @@ var auto_reply_tests = function () { return __awaiter(void 0, void 0, void 0, fu
|
|
|
4654
4779
|
}); };
|
|
4655
4780
|
var NO_TEST = function () { };
|
|
4656
4781
|
var tests = {
|
|
4782
|
+
automation_steps: automation_events_tests,
|
|
4657
4783
|
background_errors: NO_TEST,
|
|
4658
4784
|
enduser_views: NO_TEST,
|
|
4659
4785
|
availability_blocks: NO_TEST,
|
|
4660
4786
|
analytics_frames: NO_TEST,
|
|
4661
|
-
automation_steps: automation_events_tests,
|
|
4662
4787
|
products: NO_TEST,
|
|
4663
4788
|
purchase_credits: NO_TEST,
|
|
4664
4789
|
purchases: NO_TEST,
|
|
@@ -4857,4 +4982,22 @@ var tests = {
|
|
|
4857
4982
|
}
|
|
4858
4983
|
});
|
|
4859
4984
|
}); })();
|
|
4985
|
+
sdk.api.automated_actions.createOne({
|
|
4986
|
+
event: {
|
|
4987
|
+
type: "onJourneyStart",
|
|
4988
|
+
info: {},
|
|
4989
|
+
},
|
|
4990
|
+
action: {
|
|
4991
|
+
type: 'sendEmail',
|
|
4992
|
+
info: {
|
|
4993
|
+
senderId: 'USER_ID_HERE',
|
|
4994
|
+
templateId: 'TEMPLATE_ID_HERE',
|
|
4995
|
+
}
|
|
4996
|
+
},
|
|
4997
|
+
enduserId: 'ENDUSER_ID_HERE',
|
|
4998
|
+
status: 'active',
|
|
4999
|
+
processAfter: Date.now(),
|
|
5000
|
+
automationStepId: 'SOME_PLACEHOLDER_HERE',
|
|
5001
|
+
journeyId: 'SOME_PLACEHOLDER_HERE',
|
|
5002
|
+
});
|
|
4860
5003
|
//# sourceMappingURL=tests.js.map
|