@tellescope/sdk 1.256.6 → 1.256.7
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 +1 -1
- package/lib/cjs/enduser.d.ts.map +1 -1
- package/lib/cjs/enduser.js +1 -0
- package/lib/cjs/enduser.js.map +1 -1
- package/lib/cjs/tests/api_tests/calendar_event_create_and_bulk_triggers.test.d.ts +6 -0
- package/lib/cjs/tests/api_tests/calendar_event_create_and_bulk_triggers.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/calendar_event_create_and_bulk_triggers.test.js +505 -0
- package/lib/cjs/tests/api_tests/calendar_event_create_and_bulk_triggers.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/configurations_public_read.test.d.ts +6 -0
- package/lib/cjs/tests/api_tests/configurations_public_read.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/configurations_public_read.test.js +173 -0
- package/lib/cjs/tests/api_tests/configurations_public_read.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/form_started_trigger.test.d.ts.map +1 -1
- package/lib/cjs/tests/api_tests/form_started_trigger.test.js +87 -24
- package/lib/cjs/tests/api_tests/form_started_trigger.test.js.map +1 -1
- package/lib/cjs/tests/api_tests/form_translations.test.d.ts +6 -0
- package/lib/cjs/tests/api_tests/form_translations.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/form_translations.test.js +259 -0
- package/lib/cjs/tests/api_tests/form_translations.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/group_event_attendee_status_triggers.test.d.ts.map +1 -1
- package/lib/cjs/tests/api_tests/group_event_attendee_status_triggers.test.js +340 -124
- package/lib/cjs/tests/api_tests/group_event_attendee_status_triggers.test.js.map +1 -1
- package/lib/cjs/tests/api_tests/mdi_trigger_refill.test.d.ts +6 -0
- package/lib/cjs/tests/api_tests/mdi_trigger_refill.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/mdi_trigger_refill.test.js +277 -0
- package/lib/cjs/tests/api_tests/mdi_trigger_refill.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/purchase_made_trigger.test.d.ts.map +1 -1
- package/lib/cjs/tests/api_tests/purchase_made_trigger.test.js +262 -78
- package/lib/cjs/tests/api_tests/purchase_made_trigger.test.js.map +1 -1
- package/lib/cjs/tests/api_tests/security/F-0006-develop-health-benefit-verification-rbac.test.d.ts +31 -0
- package/lib/cjs/tests/api_tests/security/F-0006-develop-health-benefit-verification-rbac.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/security/F-0006-develop-health-benefit-verification-rbac.test.js +230 -0
- package/lib/cjs/tests/api_tests/security/F-0006-develop-health-benefit-verification-rbac.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/security/public_endpoint_auth_field_lock.test.d.ts.map +1 -1
- package/lib/cjs/tests/api_tests/security/public_endpoint_auth_field_lock.test.js +206 -198
- package/lib/cjs/tests/api_tests/security/public_endpoint_auth_field_lock.test.js.map +1 -1
- package/lib/cjs/tests/api_tests/stripe_webhook_triggers.test.d.ts.map +1 -1
- package/lib/cjs/tests/api_tests/stripe_webhook_triggers.test.js +343 -80
- package/lib/cjs/tests/api_tests/stripe_webhook_triggers.test.js.map +1 -1
- package/lib/cjs/tests/api_tests/welle_partner_token.test.d.ts.map +1 -1
- package/lib/cjs/tests/api_tests/welle_partner_token.test.js +74 -35
- package/lib/cjs/tests/api_tests/welle_partner_token.test.js.map +1 -1
- package/lib/cjs/tests/stripe_webhook_helpers.d.ts +134 -0
- package/lib/cjs/tests/stripe_webhook_helpers.d.ts.map +1 -1
- package/lib/cjs/tests/stripe_webhook_helpers.js +126 -1
- package/lib/cjs/tests/stripe_webhook_helpers.js.map +1 -1
- package/lib/cjs/tests/tests.d.ts.map +1 -1
- package/lib/cjs/tests/tests.js +238 -212
- package/lib/cjs/tests/tests.js.map +1 -1
- package/lib/esm/enduser.d.ts +1 -1
- package/lib/esm/enduser.d.ts.map +1 -1
- package/lib/esm/enduser.js +1 -0
- package/lib/esm/enduser.js.map +1 -1
- package/lib/esm/tests/api_tests/calendar_event_create_and_bulk_triggers.test.d.ts +6 -0
- package/lib/esm/tests/api_tests/calendar_event_create_and_bulk_triggers.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/calendar_event_create_and_bulk_triggers.test.js +501 -0
- package/lib/esm/tests/api_tests/calendar_event_create_and_bulk_triggers.test.js.map +1 -0
- package/lib/esm/tests/api_tests/configurations_public_read.test.d.ts +6 -0
- package/lib/esm/tests/api_tests/configurations_public_read.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/configurations_public_read.test.js +169 -0
- package/lib/esm/tests/api_tests/configurations_public_read.test.js.map +1 -0
- package/lib/esm/tests/api_tests/form_started_trigger.test.d.ts.map +1 -1
- package/lib/esm/tests/api_tests/form_started_trigger.test.js +87 -24
- package/lib/esm/tests/api_tests/form_started_trigger.test.js.map +1 -1
- package/lib/esm/tests/api_tests/form_translations.test.d.ts +6 -0
- package/lib/esm/tests/api_tests/form_translations.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/form_translations.test.js +255 -0
- package/lib/esm/tests/api_tests/form_translations.test.js.map +1 -0
- package/lib/esm/tests/api_tests/group_event_attendee_status_triggers.test.d.ts.map +1 -1
- package/lib/esm/tests/api_tests/group_event_attendee_status_triggers.test.js +340 -124
- package/lib/esm/tests/api_tests/group_event_attendee_status_triggers.test.js.map +1 -1
- package/lib/esm/tests/api_tests/mdi_trigger_refill.test.d.ts +6 -0
- package/lib/esm/tests/api_tests/mdi_trigger_refill.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/mdi_trigger_refill.test.js +273 -0
- package/lib/esm/tests/api_tests/mdi_trigger_refill.test.js.map +1 -0
- package/lib/esm/tests/api_tests/purchase_made_trigger.test.d.ts.map +1 -1
- package/lib/esm/tests/api_tests/purchase_made_trigger.test.js +262 -78
- package/lib/esm/tests/api_tests/purchase_made_trigger.test.js.map +1 -1
- package/lib/esm/tests/api_tests/security/F-0006-develop-health-benefit-verification-rbac.test.d.ts +31 -0
- package/lib/esm/tests/api_tests/security/F-0006-develop-health-benefit-verification-rbac.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/security/F-0006-develop-health-benefit-verification-rbac.test.js +226 -0
- package/lib/esm/tests/api_tests/security/F-0006-develop-health-benefit-verification-rbac.test.js.map +1 -0
- package/lib/esm/tests/api_tests/security/public_endpoint_auth_field_lock.test.d.ts.map +1 -1
- package/lib/esm/tests/api_tests/security/public_endpoint_auth_field_lock.test.js +206 -198
- package/lib/esm/tests/api_tests/security/public_endpoint_auth_field_lock.test.js.map +1 -1
- package/lib/esm/tests/api_tests/stripe_webhook_triggers.test.d.ts.map +1 -1
- package/lib/esm/tests/api_tests/stripe_webhook_triggers.test.js +344 -81
- package/lib/esm/tests/api_tests/stripe_webhook_triggers.test.js.map +1 -1
- package/lib/esm/tests/api_tests/welle_partner_token.test.d.ts.map +1 -1
- package/lib/esm/tests/api_tests/welle_partner_token.test.js +74 -35
- package/lib/esm/tests/api_tests/welle_partner_token.test.js.map +1 -1
- package/lib/esm/tests/stripe_webhook_helpers.d.ts +134 -0
- package/lib/esm/tests/stripe_webhook_helpers.d.ts.map +1 -1
- package/lib/esm/tests/stripe_webhook_helpers.js +119 -0
- package/lib/esm/tests/stripe_webhook_helpers.js.map +1 -1
- package/lib/esm/tests/tests.d.ts.map +1 -1
- package/lib/esm/tests/tests.js +238 -212
- package/lib/esm/tests/tests.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/enduser.ts +4 -2
- package/src/tests/api_tests/calendar_event_create_and_bulk_triggers.test.ts +293 -0
- package/src/tests/api_tests/configurations_public_read.test.ts +116 -0
- package/src/tests/api_tests/form_started_trigger.test.ts +49 -1
- package/src/tests/api_tests/form_translations.test.ts +205 -0
- package/src/tests/api_tests/group_event_attendee_status_triggers.test.ts +135 -0
- package/src/tests/api_tests/mdi_trigger_refill.test.ts +184 -0
- package/src/tests/api_tests/purchase_made_trigger.test.ts +137 -0
- package/src/tests/api_tests/security/F-0006-develop-health-benefit-verification-rbac.test.ts +144 -0
- package/src/tests/api_tests/security/public_endpoint_auth_field_lock.test.ts +16 -6
- package/src/tests/api_tests/stripe_webhook_triggers.test.ts +221 -0
- package/src/tests/api_tests/welle_partner_token.test.ts +49 -6
- package/src/tests/stripe_webhook_helpers.ts +116 -0
- package/src/tests/tests.ts +27 -12
- package/test_generated.pdf +0 -0
|
@@ -78,10 +78,10 @@ var host = process.env.API_URL || "http://localhost:8080";
|
|
|
78
78
|
var stripe_webhook_triggers_tests = function (_a) {
|
|
79
79
|
var sdk = _a.sdk, sdkNonAdmin = _a.sdkNonAdmin;
|
|
80
80
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
81
|
-
var RUN, tag, createdEnduserIds, createdTriggerIds, createdProductIds, _b, stripePublicKey, webhooksSecret, cleanup, new_enduser, new_trigger, new_product, poll_for_tag, expect_fired, expect_not_fired, B1_TAG, b1Enduser, b1Event, b1Res, b2Res, B3_TAG, b3Enduser, b3Res, B4_TAG, b4Enduser, b4Res, stripeProductA_1, stripeProductB, productA, productB, B5_TAG, b5Enduser, b5Res, B6_TAG, b6Enduser, B7_TAG, b7Enduser, B8_TAG, b8Enduser, run_scoped_payment_failed_case, f7Scoped, f7Fetched, rejectedInvalidProductId, e_1, run_pause_case, p14Scoped, p14Fetched, rejectedInvalidPausedProductId, e_2;
|
|
82
|
-
var _c, _d;
|
|
83
|
-
return __generator(this, function (
|
|
84
|
-
switch (
|
|
81
|
+
var RUN, tag, createdEnduserIds, createdTriggerIds, createdProductIds, _b, stripePublicKey, webhooksSecret, cleanup, new_enduser, new_trigger, new_product, poll_for_tag, expect_fired, expect_not_fired, B1_TAG, b1Enduser, b1Event, b1Res, b2Res, B3_TAG, b3Enduser, b3Res, B4_TAG, b4Enduser, b4Res, stripeProductA_1, stripeProductB, productA, productB, B5_TAG, b5Enduser, b5Res, B6_TAG, b6Enduser, B7_TAG, b7Enduser, B8_TAG, b8Enduser, run_scoped_payment_failed_case, f7Scoped, f7Fetched, rejectedInvalidProductId, e_1, run_pause_case, p14Scoped, p14Fetched, rejectedInvalidPausedProductId, e_2, poll_for_purchase, run_coupon_invoice_case, c1Enduser, c1Purchases, c1bDiscount, c1bEnduser, c1bPurchases, c5Discount, C7_TAG, C7_SCOPED_TAG, c7Enduser, c7Res, c7Purchases, C8_TAG, c8Enduser, c8Res, c9Trigger, c9Fetched;
|
|
82
|
+
var _c, _d, _e;
|
|
83
|
+
return __generator(this, function (_f) {
|
|
84
|
+
switch (_f.label) {
|
|
85
85
|
case 0:
|
|
86
86
|
(0, testing_1.log_header)("Stripe Webhook Triggers");
|
|
87
87
|
RUN = "".concat(Date.now());
|
|
@@ -93,7 +93,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
93
93
|
// Each enduser is matched by the handler on stripeCustomerId, so it must be unique per case.
|
|
94
94
|
];
|
|
95
95
|
case 1:
|
|
96
|
-
_b =
|
|
96
|
+
_b = _f.sent(), stripePublicKey = _b.stripePublicKey, webhooksSecret = _b.webhooksSecret, cleanup = _b.cleanup;
|
|
97
97
|
new_enduser = function (label) { return __awaiter(void 0, void 0, void 0, function () {
|
|
98
98
|
var stripeCustomerId, enduser;
|
|
99
99
|
return __generator(this, function (_a) {
|
|
@@ -209,20 +209,20 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
209
209
|
}
|
|
210
210
|
});
|
|
211
211
|
}); };
|
|
212
|
-
|
|
212
|
+
_f.label = 2;
|
|
213
213
|
case 2:
|
|
214
|
-
|
|
214
|
+
_f.trys.push([2, , 92, 95]);
|
|
215
215
|
B1_TAG = tag('b1-bad-signature');
|
|
216
216
|
return [4 /*yield*/, new_enduser('b1')];
|
|
217
217
|
case 3:
|
|
218
|
-
b1Enduser =
|
|
218
|
+
b1Enduser = _f.sent();
|
|
219
219
|
return [4 /*yield*/, new_trigger({
|
|
220
220
|
title: "Stripe payment failed (bad signature) ".concat(RUN),
|
|
221
221
|
event: { type: 'Subscription Payment Failed', info: {} },
|
|
222
222
|
tags: [B1_TAG],
|
|
223
223
|
})];
|
|
224
224
|
case 4:
|
|
225
|
-
|
|
225
|
+
_f.sent();
|
|
226
226
|
b1Event = (0, stripe_webhook_helpers_1.invoice_payment_failed_event)({ stripeCustomerId: b1Enduser.stripeCustomerId });
|
|
227
227
|
return [4 /*yield*/, (0, stripe_webhook_helpers_1.post_stripe_webhook)({
|
|
228
228
|
stripePublicKey: stripePublicKey,
|
|
@@ -231,57 +231,57 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
231
231
|
signature: (0, stripe_webhook_helpers_1.sign_stripe_payload)('{"tampered":true}', webhooksSecret),
|
|
232
232
|
})];
|
|
233
233
|
case 5:
|
|
234
|
-
b1Res =
|
|
234
|
+
b1Res = _f.sent();
|
|
235
235
|
(0, testing_1.assert)(b1Res.status === 400, "expected 400 for a mismatched signature, got ".concat(b1Res.status), 'invalid signature rejected');
|
|
236
236
|
return [4 /*yield*/, expect_not_fired(b1Enduser.id, B1_TAG, 'invalid signature does not fire triggers')
|
|
237
237
|
// B2: unknown public key in the URL -> no integration -> 404
|
|
238
238
|
];
|
|
239
239
|
case 6:
|
|
240
|
-
|
|
240
|
+
_f.sent();
|
|
241
241
|
return [4 /*yield*/, (0, stripe_webhook_helpers_1.post_stripe_webhook)({
|
|
242
242
|
stripePublicKey: "pk_test_missing_".concat(RUN),
|
|
243
243
|
secret: webhooksSecret,
|
|
244
244
|
event: (0, stripe_webhook_helpers_1.invoice_payment_failed_event)({ stripeCustomerId: "cus_test_missing_".concat(RUN) }),
|
|
245
245
|
})];
|
|
246
246
|
case 7:
|
|
247
|
-
b2Res =
|
|
247
|
+
b2Res = _f.sent();
|
|
248
248
|
(0, testing_1.assert)(b2Res.status === 404, "expected 404 for an unknown public key, got ".concat(b2Res.status), 'unknown integration rejected');
|
|
249
249
|
B3_TAG = tag('b3-unknown-customer');
|
|
250
250
|
return [4 /*yield*/, new_enduser('b3')];
|
|
251
251
|
case 8:
|
|
252
|
-
b3Enduser =
|
|
252
|
+
b3Enduser = _f.sent();
|
|
253
253
|
return [4 /*yield*/, new_trigger({
|
|
254
254
|
title: "Stripe payment failed (unknown customer) ".concat(RUN),
|
|
255
255
|
event: { type: 'Subscription Payment Failed', info: {} },
|
|
256
256
|
tags: [B3_TAG],
|
|
257
257
|
})];
|
|
258
258
|
case 9:
|
|
259
|
-
|
|
259
|
+
_f.sent();
|
|
260
260
|
return [4 /*yield*/, (0, stripe_webhook_helpers_1.post_stripe_webhook)({
|
|
261
261
|
stripePublicKey: stripePublicKey,
|
|
262
262
|
secret: webhooksSecret,
|
|
263
263
|
event: (0, stripe_webhook_helpers_1.invoice_payment_failed_event)({ stripeCustomerId: "cus_test_nobody_".concat(RUN) }),
|
|
264
264
|
})];
|
|
265
265
|
case 10:
|
|
266
|
-
b3Res =
|
|
266
|
+
b3Res = _f.sent();
|
|
267
267
|
(0, testing_1.assert)(b3Res.status === 200, "expected 200 for an unmatched customer, got ".concat(b3Res.status), 'unmatched customer accepted');
|
|
268
268
|
return [4 /*yield*/, expect_not_fired(b3Enduser.id, B3_TAG, 'unmatched customer does not fire triggers')
|
|
269
269
|
// B4: the baseline behavior the productIds feature must preserve — a Subscription Payment Failed
|
|
270
270
|
// trigger with no product scoping fires for any failed invoice.
|
|
271
271
|
];
|
|
272
272
|
case 11:
|
|
273
|
-
|
|
273
|
+
_f.sent();
|
|
274
274
|
B4_TAG = tag('b4-unscoped');
|
|
275
275
|
return [4 /*yield*/, new_enduser('b4')];
|
|
276
276
|
case 12:
|
|
277
|
-
b4Enduser =
|
|
277
|
+
b4Enduser = _f.sent();
|
|
278
278
|
return [4 /*yield*/, new_trigger({
|
|
279
279
|
title: "Stripe payment failed (unscoped) ".concat(RUN),
|
|
280
280
|
event: { type: 'Subscription Payment Failed', info: {} },
|
|
281
281
|
tags: [B4_TAG],
|
|
282
282
|
})];
|
|
283
283
|
case 13:
|
|
284
|
-
|
|
284
|
+
_f.sent();
|
|
285
285
|
return [4 /*yield*/, (0, stripe_webhook_helpers_1.post_stripe_webhook)({
|
|
286
286
|
stripePublicKey: stripePublicKey,
|
|
287
287
|
secret: webhooksSecret,
|
|
@@ -291,35 +291,35 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
291
291
|
}),
|
|
292
292
|
})];
|
|
293
293
|
case 14:
|
|
294
|
-
b4Res =
|
|
294
|
+
b4Res = _f.sent();
|
|
295
295
|
(0, testing_1.assert)(b4Res.status === 200, "expected 200, got ".concat(b4Res.status, " (").concat(b4Res.data, ")"), 'payment failed webhook accepted');
|
|
296
296
|
return [4 /*yield*/, expect_fired(b4Enduser.id, B4_TAG, 'unscoped Subscription Payment Failed trigger fires')
|
|
297
297
|
/* ===================== customer.subscription.deleted ===================== */
|
|
298
298
|
// Products A and B exist to distinguish "the subscription's product" from "some other product".
|
|
299
299
|
];
|
|
300
300
|
case 15:
|
|
301
|
-
|
|
301
|
+
_f.sent();
|
|
302
302
|
stripeProductA_1 = "prod_test_a_".concat(RUN);
|
|
303
303
|
stripeProductB = "prod_test_b_".concat(RUN);
|
|
304
304
|
return [4 /*yield*/, new_product('A', stripeProductA_1)];
|
|
305
305
|
case 16:
|
|
306
|
-
productA =
|
|
306
|
+
productA = _f.sent();
|
|
307
307
|
return [4 /*yield*/, new_product('B', stripeProductB)
|
|
308
308
|
// B5: unscoped Subscription Ended fires
|
|
309
309
|
];
|
|
310
310
|
case 17:
|
|
311
|
-
productB =
|
|
311
|
+
productB = _f.sent();
|
|
312
312
|
B5_TAG = tag('b5-ended-unscoped');
|
|
313
313
|
return [4 /*yield*/, new_enduser('b5')];
|
|
314
314
|
case 18:
|
|
315
|
-
b5Enduser =
|
|
315
|
+
b5Enduser = _f.sent();
|
|
316
316
|
return [4 /*yield*/, new_trigger({
|
|
317
317
|
title: "Stripe subscription ended (unscoped) ".concat(RUN),
|
|
318
318
|
event: { type: 'Subscription Ended', info: {} },
|
|
319
319
|
tags: [B5_TAG],
|
|
320
320
|
})];
|
|
321
321
|
case 19:
|
|
322
|
-
|
|
322
|
+
_f.sent();
|
|
323
323
|
return [4 /*yield*/, (0, stripe_webhook_helpers_1.post_stripe_webhook)({
|
|
324
324
|
stripePublicKey: stripePublicKey,
|
|
325
325
|
secret: webhooksSecret,
|
|
@@ -329,24 +329,24 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
329
329
|
}),
|
|
330
330
|
})];
|
|
331
331
|
case 20:
|
|
332
|
-
b5Res =
|
|
332
|
+
b5Res = _f.sent();
|
|
333
333
|
(0, testing_1.assert)(b5Res.status === 200, "expected 200, got ".concat(b5Res.status, " (").concat(b5Res.data, ")"), 'subscription deleted webhook accepted');
|
|
334
334
|
return [4 /*yield*/, expect_fired(b5Enduser.id, B5_TAG, 'unscoped Subscription Ended trigger fires')
|
|
335
335
|
// B6: an explicitly empty productIds list means "all products"
|
|
336
336
|
];
|
|
337
337
|
case 21:
|
|
338
|
-
|
|
338
|
+
_f.sent();
|
|
339
339
|
B6_TAG = tag('b6-ended-empty-list');
|
|
340
340
|
return [4 /*yield*/, new_enduser('b6')];
|
|
341
341
|
case 22:
|
|
342
|
-
b6Enduser =
|
|
342
|
+
b6Enduser = _f.sent();
|
|
343
343
|
return [4 /*yield*/, new_trigger({
|
|
344
344
|
title: "Stripe subscription ended (empty productIds) ".concat(RUN),
|
|
345
345
|
event: { type: 'Subscription Ended', info: { productIds: [] } },
|
|
346
346
|
tags: [B6_TAG],
|
|
347
347
|
})];
|
|
348
348
|
case 23:
|
|
349
|
-
|
|
349
|
+
_f.sent();
|
|
350
350
|
return [4 /*yield*/, (0, stripe_webhook_helpers_1.post_stripe_webhook)({
|
|
351
351
|
stripePublicKey: stripePublicKey,
|
|
352
352
|
secret: webhooksSecret,
|
|
@@ -356,25 +356,25 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
356
356
|
}),
|
|
357
357
|
})];
|
|
358
358
|
case 24:
|
|
359
|
-
|
|
359
|
+
_f.sent();
|
|
360
360
|
return [4 /*yield*/, expect_fired(b6Enduser.id, B6_TAG, 'Subscription Ended trigger with empty productIds fires')
|
|
361
361
|
// B7/B8 pin the existing product-matching semantics end-to-end, so any refactor of the
|
|
362
362
|
// productIds query clause is provably behavior-preserving.
|
|
363
363
|
// B7: productIds matching the subscription's product fires
|
|
364
364
|
];
|
|
365
365
|
case 25:
|
|
366
|
-
|
|
366
|
+
_f.sent();
|
|
367
367
|
B7_TAG = tag('b7-ended-matching');
|
|
368
368
|
return [4 /*yield*/, new_enduser('b7')];
|
|
369
369
|
case 26:
|
|
370
|
-
b7Enduser =
|
|
370
|
+
b7Enduser = _f.sent();
|
|
371
371
|
return [4 /*yield*/, new_trigger({
|
|
372
372
|
title: "Stripe subscription ended (matching product) ".concat(RUN),
|
|
373
373
|
event: { type: 'Subscription Ended', info: { productIds: [productA.id] } },
|
|
374
374
|
tags: [B7_TAG],
|
|
375
375
|
})];
|
|
376
376
|
case 27:
|
|
377
|
-
|
|
377
|
+
_f.sent();
|
|
378
378
|
return [4 /*yield*/, (0, stripe_webhook_helpers_1.post_stripe_webhook)({
|
|
379
379
|
stripePublicKey: stripePublicKey,
|
|
380
380
|
secret: webhooksSecret,
|
|
@@ -384,23 +384,23 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
384
384
|
}),
|
|
385
385
|
})];
|
|
386
386
|
case 28:
|
|
387
|
-
|
|
387
|
+
_f.sent();
|
|
388
388
|
return [4 /*yield*/, expect_fired(b7Enduser.id, B7_TAG, 'Subscription Ended trigger scoped to the matching product fires')
|
|
389
389
|
// B8: productIds naming a different product does not fire
|
|
390
390
|
];
|
|
391
391
|
case 29:
|
|
392
|
-
|
|
392
|
+
_f.sent();
|
|
393
393
|
B8_TAG = tag('b8-ended-nonmatching');
|
|
394
394
|
return [4 /*yield*/, new_enduser('b8')];
|
|
395
395
|
case 30:
|
|
396
|
-
b8Enduser =
|
|
396
|
+
b8Enduser = _f.sent();
|
|
397
397
|
return [4 /*yield*/, new_trigger({
|
|
398
398
|
title: "Stripe subscription ended (other product) ".concat(RUN),
|
|
399
399
|
event: { type: 'Subscription Ended', info: { productIds: [productB.id] } },
|
|
400
400
|
tags: [B8_TAG],
|
|
401
401
|
})];
|
|
402
402
|
case 31:
|
|
403
|
-
|
|
403
|
+
_f.sent();
|
|
404
404
|
return [4 /*yield*/, (0, stripe_webhook_helpers_1.post_stripe_webhook)({
|
|
405
405
|
stripePublicKey: stripePublicKey,
|
|
406
406
|
secret: webhooksSecret,
|
|
@@ -410,14 +410,14 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
410
410
|
}),
|
|
411
411
|
})];
|
|
412
412
|
case 32:
|
|
413
|
-
|
|
413
|
+
_f.sent();
|
|
414
414
|
return [4 /*yield*/, expect_not_fired(b8Enduser.id, B8_TAG, 'Subscription Ended trigger scoped to another product does not fire')
|
|
415
415
|
/* ============ invoice.payment_failed, scoped to products ============ */
|
|
416
416
|
// Shared shape for the cases below: a trigger scoped to productA, and an invoice whose line
|
|
417
417
|
// items are varied per case to cover how Stripe can reference a product.
|
|
418
418
|
];
|
|
419
419
|
case 33:
|
|
420
|
-
|
|
420
|
+
_f.sent();
|
|
421
421
|
run_scoped_payment_failed_case = function (_a) {
|
|
422
422
|
var label = _a.label, productIds = _a.productIds, lines = _a.lines, shouldFire = _a.shouldFire, title = _a.title;
|
|
423
423
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -470,7 +470,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
470
470
|
];
|
|
471
471
|
case 34:
|
|
472
472
|
// F1: the feature — a trigger scoped to the product that actually failed fires
|
|
473
|
-
|
|
473
|
+
_f.sent();
|
|
474
474
|
// F2: the point of the feature — a trigger scoped to a different product stays quiet
|
|
475
475
|
return [4 /*yield*/, run_scoped_payment_failed_case({
|
|
476
476
|
label: 'f2-nonmatching',
|
|
@@ -483,7 +483,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
483
483
|
];
|
|
484
484
|
case 35:
|
|
485
485
|
// F2: the point of the feature — a trigger scoped to a different product stays quiet
|
|
486
|
-
|
|
486
|
+
_f.sent();
|
|
487
487
|
// F3: "leave blank for all" — an empty list is not a filter
|
|
488
488
|
return [4 /*yield*/, run_scoped_payment_failed_case({
|
|
489
489
|
label: 'f3-empty-list',
|
|
@@ -496,7 +496,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
496
496
|
];
|
|
497
497
|
case 36:
|
|
498
498
|
// F3: "leave blank for all" — an empty list is not a filter
|
|
499
|
-
|
|
499
|
+
_f.sent();
|
|
500
500
|
// F4: price.product may arrive expanded as an object rather than a bare id
|
|
501
501
|
return [4 /*yield*/, run_scoped_payment_failed_case({
|
|
502
502
|
label: 'f4-expanded-product',
|
|
@@ -509,7 +509,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
509
509
|
];
|
|
510
510
|
case 37:
|
|
511
511
|
// F4: price.product may arrive expanded as an object rather than a bare id
|
|
512
|
-
|
|
512
|
+
_f.sent();
|
|
513
513
|
// F5: subscription/proration lines can carry plan.product with no price
|
|
514
514
|
return [4 /*yield*/, run_scoped_payment_failed_case({
|
|
515
515
|
label: 'f5-plan-product',
|
|
@@ -522,7 +522,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
522
522
|
];
|
|
523
523
|
case 38:
|
|
524
524
|
// F5: subscription/proration lines can carry plan.product with no price
|
|
525
|
-
|
|
525
|
+
_f.sent();
|
|
526
526
|
// F6: one matching line among several is enough
|
|
527
527
|
return [4 /*yield*/, run_scoped_payment_failed_case({
|
|
528
528
|
label: 'f6-multi-line',
|
|
@@ -537,17 +537,17 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
537
537
|
];
|
|
538
538
|
case 39:
|
|
539
539
|
// F6: one matching line among several is enough
|
|
540
|
-
|
|
540
|
+
_f.sent();
|
|
541
541
|
return [4 /*yield*/, new_trigger({
|
|
542
542
|
title: "Stripe payment failed (validator round-trip) ".concat(RUN),
|
|
543
543
|
event: { type: 'Subscription Payment Failed', info: { productIds: [productA.id] } },
|
|
544
544
|
tags: [tag('f7')],
|
|
545
545
|
})];
|
|
546
546
|
case 40:
|
|
547
|
-
f7Scoped =
|
|
547
|
+
f7Scoped = _f.sent();
|
|
548
548
|
return [4 /*yield*/, sdk.api.automation_triggers.getOne(f7Scoped.id)];
|
|
549
549
|
case 41:
|
|
550
|
-
f7Fetched =
|
|
550
|
+
f7Fetched = _f.sent();
|
|
551
551
|
(0, testing_1.assert)(JSON.stringify((_c = f7Fetched.event.info) === null || _c === void 0 ? void 0 : _c.productIds) === JSON.stringify([productA.id]), "expected productIds to round-trip, got ".concat(JSON.stringify(f7Fetched.event)), 'productIds round-trips through the validator');
|
|
552
552
|
return [4 /*yield*/, new_trigger({
|
|
553
553
|
title: "Stripe payment failed (empty info) ".concat(RUN),
|
|
@@ -555,7 +555,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
555
555
|
tags: [tag('f7-empty-info')],
|
|
556
556
|
})];
|
|
557
557
|
case 42:
|
|
558
|
-
|
|
558
|
+
_f.sent();
|
|
559
559
|
(0, testing_1.assert)(true, '', 'empty info accepted');
|
|
560
560
|
return [4 /*yield*/, new_trigger({
|
|
561
561
|
title: "Stripe payment failed (no info) ".concat(RUN),
|
|
@@ -563,22 +563,22 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
563
563
|
tags: [tag('f7-no-info')],
|
|
564
564
|
})];
|
|
565
565
|
case 43:
|
|
566
|
-
|
|
566
|
+
_f.sent();
|
|
567
567
|
(0, testing_1.assert)(true, '', 'omitted info still accepted');
|
|
568
568
|
rejectedInvalidProductId = false;
|
|
569
|
-
|
|
569
|
+
_f.label = 44;
|
|
570
570
|
case 44:
|
|
571
|
-
|
|
571
|
+
_f.trys.push([44, 46, , 47]);
|
|
572
572
|
return [4 /*yield*/, new_trigger({
|
|
573
573
|
title: "Stripe payment failed (invalid productId) ".concat(RUN),
|
|
574
574
|
event: { type: 'Subscription Payment Failed', info: { productIds: ['not-a-mongo-id'] } },
|
|
575
575
|
tags: [tag('f7-invalid')],
|
|
576
576
|
})];
|
|
577
577
|
case 45:
|
|
578
|
-
|
|
578
|
+
_f.sent();
|
|
579
579
|
return [3 /*break*/, 47];
|
|
580
580
|
case 46:
|
|
581
|
-
e_1 =
|
|
581
|
+
e_1 = _f.sent();
|
|
582
582
|
rejectedInvalidProductId = true;
|
|
583
583
|
return [3 /*break*/, 47];
|
|
584
584
|
case 47:
|
|
@@ -643,7 +643,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
643
643
|
// P1: the core pause path — pause_collection goes null -> set on customer.subscription.updated.
|
|
644
644
|
// This is how a pause from the billing portal or dashboard actually arrives; there is no
|
|
645
645
|
// dedicated event for it.
|
|
646
|
-
|
|
646
|
+
_f.sent();
|
|
647
647
|
// P2: the mirror — pause_collection cleared is a resume
|
|
648
648
|
return [4 /*yield*/, run_pause_case({
|
|
649
649
|
label: 'p2-pause-collection-cleared',
|
|
@@ -661,7 +661,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
661
661
|
];
|
|
662
662
|
case 49:
|
|
663
663
|
// P2: the mirror — pause_collection cleared is a resume
|
|
664
|
-
|
|
664
|
+
_f.sent();
|
|
665
665
|
// P3: a pause that is only *modified* (behavior or resumes_at changed) is neither a pause nor a
|
|
666
666
|
// resume — firing here would re-trigger every time a customer adjusts an existing pause
|
|
667
667
|
return [4 /*yield*/, run_pause_case({
|
|
@@ -682,7 +682,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
682
682
|
case 50:
|
|
683
683
|
// P3: a pause that is only *modified* (behavior or resumes_at changed) is neither a pause nor a
|
|
684
684
|
// resume — firing here would re-trigger every time a customer adjusts an existing pause
|
|
685
|
-
|
|
685
|
+
_f.sent();
|
|
686
686
|
// P4: the volume guard. customer.subscription.updated fires on every renewal, price change and
|
|
687
687
|
// cancel_at_period_end toggle; with no pause_collection key in previous_attributes the handler
|
|
688
688
|
// must do nothing (and, in the API, must not even reach the enduser lookup).
|
|
@@ -706,7 +706,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
706
706
|
// P4: the volume guard. customer.subscription.updated fires on every renewal, price change and
|
|
707
707
|
// cancel_at_period_end toggle; with no pause_collection key in previous_attributes the handler
|
|
708
708
|
// must do nothing (and, in the API, must not even reach the enduser lookup).
|
|
709
|
-
|
|
709
|
+
_f.sent();
|
|
710
710
|
// P4b: the idempotency case. previous_attributes carries only what changed, so an unrelated
|
|
711
711
|
// update to an already-paused subscription has no pause_collection key even though
|
|
712
712
|
// pause_collection is currently set. Firing here would re-trigger on every renewal, quantity
|
|
@@ -731,7 +731,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
731
731
|
// pause_collection is currently set. Firing here would re-trigger on every renewal, quantity
|
|
732
732
|
// change and coupon edit for the whole duration of a pause — which is what would happen if the
|
|
733
733
|
// gate were ever "simplified" to read current state instead of the transition.
|
|
734
|
-
|
|
734
|
+
_f.sent();
|
|
735
735
|
// P5/P6: the dedicated events, which Stripe emits for status='paused' transitions only
|
|
736
736
|
return [4 /*yield*/, run_pause_case({
|
|
737
737
|
label: 'p5-dedicated-paused',
|
|
@@ -742,7 +742,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
742
742
|
})];
|
|
743
743
|
case 53:
|
|
744
744
|
// P5/P6: the dedicated events, which Stripe emits for status='paused' transitions only
|
|
745
|
-
|
|
745
|
+
_f.sent();
|
|
746
746
|
return [4 /*yield*/, run_pause_case({
|
|
747
747
|
label: 'p6-dedicated-resumed',
|
|
748
748
|
type: 'Subscription Resumed',
|
|
@@ -753,7 +753,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
753
753
|
// P7: a Paused trigger must not fire on a resume, and vice versa — the two are separate types
|
|
754
754
|
];
|
|
755
755
|
case 54:
|
|
756
|
-
|
|
756
|
+
_f.sent();
|
|
757
757
|
// P7: a Paused trigger must not fire on a resume, and vice versa — the two are separate types
|
|
758
758
|
return [4 /*yield*/, run_pause_case({
|
|
759
759
|
label: 'p7-wrong-direction',
|
|
@@ -768,7 +768,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
768
768
|
];
|
|
769
769
|
case 55:
|
|
770
770
|
// P7: a Paused trigger must not fire on a resume, and vice versa — the two are separate types
|
|
771
|
-
|
|
771
|
+
_f.sent();
|
|
772
772
|
// P8: the dedupe guard — the .updated that accompanies a status='paused' transition must not
|
|
773
773
|
// fire on top of the dedicated event. Stripe isn't expected to send this combination at all;
|
|
774
774
|
// the case pins the guard so a future refactor can't quietly drop it.
|
|
@@ -791,7 +791,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
791
791
|
// P8: the dedupe guard — the .updated that accompanies a status='paused' transition must not
|
|
792
792
|
// fire on top of the dedicated event. Stripe isn't expected to send this combination at all;
|
|
793
793
|
// the case pins the guard so a future refactor can't quietly drop it.
|
|
794
|
-
|
|
794
|
+
_f.sent();
|
|
795
795
|
/* ---- product scoping, over the pause_collection path ---- */
|
|
796
796
|
// P9-P12: the same matrix the payment-failed cases cover, applied to the new triggers
|
|
797
797
|
return [4 /*yield*/, run_pause_case({
|
|
@@ -810,7 +810,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
810
810
|
case 57:
|
|
811
811
|
/* ---- product scoping, over the pause_collection path ---- */
|
|
812
812
|
// P9-P12: the same matrix the payment-failed cases cover, applied to the new triggers
|
|
813
|
-
|
|
813
|
+
_f.sent();
|
|
814
814
|
return [4 /*yield*/, run_pause_case({
|
|
815
815
|
label: 'p10-scoped-nonmatching',
|
|
816
816
|
type: 'Subscription Paused',
|
|
@@ -825,7 +825,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
825
825
|
title: 'Subscription Paused scoped to another product does not fire',
|
|
826
826
|
})];
|
|
827
827
|
case 58:
|
|
828
|
-
|
|
828
|
+
_f.sent();
|
|
829
829
|
return [4 /*yield*/, run_pause_case({
|
|
830
830
|
label: 'p11-empty-list',
|
|
831
831
|
type: 'Subscription Paused',
|
|
@@ -842,7 +842,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
842
842
|
// plan.product and expanded price.product objects both have to resolve, same as the invoice path
|
|
843
843
|
];
|
|
844
844
|
case 59:
|
|
845
|
-
|
|
845
|
+
_f.sent();
|
|
846
846
|
// plan.product and expanded price.product objects both have to resolve, same as the invoice path
|
|
847
847
|
return [4 /*yield*/, run_pause_case({
|
|
848
848
|
label: 'p12-plan-product',
|
|
@@ -859,7 +859,7 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
859
859
|
})];
|
|
860
860
|
case 60:
|
|
861
861
|
// plan.product and expanded price.product objects both have to resolve, same as the invoice path
|
|
862
|
-
|
|
862
|
+
_f.sent();
|
|
863
863
|
return [4 /*yield*/, run_pause_case({
|
|
864
864
|
label: 'p13-expanded-product',
|
|
865
865
|
type: 'Subscription Resumed',
|
|
@@ -875,17 +875,17 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
875
875
|
// P14: same round-trip guarantees as F7, for both new types
|
|
876
876
|
];
|
|
877
877
|
case 61:
|
|
878
|
-
|
|
878
|
+
_f.sent();
|
|
879
879
|
return [4 /*yield*/, new_trigger({
|
|
880
880
|
title: "Stripe subscription paused (validator round-trip) ".concat(RUN),
|
|
881
881
|
event: { type: 'Subscription Paused', info: { productIds: [productA.id] } },
|
|
882
882
|
tags: [tag('p14')],
|
|
883
883
|
})];
|
|
884
884
|
case 62:
|
|
885
|
-
p14Scoped =
|
|
885
|
+
p14Scoped = _f.sent();
|
|
886
886
|
return [4 /*yield*/, sdk.api.automation_triggers.getOne(p14Scoped.id)];
|
|
887
887
|
case 63:
|
|
888
|
-
p14Fetched =
|
|
888
|
+
p14Fetched = _f.sent();
|
|
889
889
|
(0, testing_1.assert)(JSON.stringify((_d = p14Fetched.event.info) === null || _d === void 0 ? void 0 : _d.productIds) === JSON.stringify([productA.id]), "expected productIds to round-trip, got ".concat(JSON.stringify(p14Fetched.event)), 'Subscription Paused productIds round-trips through the validator');
|
|
890
890
|
return [4 /*yield*/, new_trigger({
|
|
891
891
|
title: "Stripe subscription resumed (no info) ".concat(RUN),
|
|
@@ -893,41 +893,304 @@ var stripe_webhook_triggers_tests = function (_a) {
|
|
|
893
893
|
tags: [tag('p14-no-info')],
|
|
894
894
|
})];
|
|
895
895
|
case 64:
|
|
896
|
-
|
|
896
|
+
_f.sent();
|
|
897
897
|
(0, testing_1.assert)(true, '', 'Subscription Resumed with omitted info accepted');
|
|
898
898
|
rejectedInvalidPausedProductId = false;
|
|
899
|
-
|
|
899
|
+
_f.label = 65;
|
|
900
900
|
case 65:
|
|
901
|
-
|
|
901
|
+
_f.trys.push([65, 67, , 68]);
|
|
902
902
|
return [4 /*yield*/, new_trigger({
|
|
903
903
|
title: "Stripe subscription paused (invalid productId) ".concat(RUN),
|
|
904
904
|
event: { type: 'Subscription Paused', info: { productIds: ['not-a-mongo-id'] } },
|
|
905
905
|
tags: [tag('p14-invalid')],
|
|
906
906
|
})];
|
|
907
907
|
case 66:
|
|
908
|
-
|
|
908
|
+
_f.sent();
|
|
909
909
|
return [3 /*break*/, 68];
|
|
910
910
|
case 67:
|
|
911
|
-
e_2 =
|
|
911
|
+
e_2 = _f.sent();
|
|
912
912
|
rejectedInvalidPausedProductId = true;
|
|
913
913
|
return [3 /*break*/, 68];
|
|
914
914
|
case 68:
|
|
915
915
|
(0, testing_1.assert)(rejectedInvalidPausedProductId, 'expected a non-ObjectId productId to be rejected', 'invalid Subscription Paused productId rejected');
|
|
916
|
+
poll_for_purchase = function (enduserId, iterations) {
|
|
917
|
+
if (iterations === void 0) { iterations = 20; }
|
|
918
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
919
|
+
var i, purchases;
|
|
920
|
+
return __generator(this, function (_a) {
|
|
921
|
+
switch (_a.label) {
|
|
922
|
+
case 0:
|
|
923
|
+
i = 0;
|
|
924
|
+
_a.label = 1;
|
|
925
|
+
case 1:
|
|
926
|
+
if (!(i < iterations)) return [3 /*break*/, 5];
|
|
927
|
+
return [4 /*yield*/, (0, testing_1.wait)(undefined, 500)];
|
|
928
|
+
case 2:
|
|
929
|
+
_a.sent();
|
|
930
|
+
return [4 /*yield*/, sdk.api.purchases.getSome({ filter: { enduserId: enduserId } })];
|
|
931
|
+
case 3:
|
|
932
|
+
purchases = _a.sent();
|
|
933
|
+
if (purchases.length)
|
|
934
|
+
return [2 /*return*/, purchases];
|
|
935
|
+
_a.label = 4;
|
|
936
|
+
case 4:
|
|
937
|
+
i++;
|
|
938
|
+
return [3 /*break*/, 1];
|
|
939
|
+
case 5: return [2 /*return*/, []];
|
|
940
|
+
}
|
|
941
|
+
});
|
|
942
|
+
});
|
|
943
|
+
};
|
|
944
|
+
run_coupon_invoice_case = function (_a) {
|
|
945
|
+
var label = _a.label, couponCodes = _a.couponCodes, discounts = _a.discounts, discount = _a.discount, shouldFire = _a.shouldFire, title = _a.title;
|
|
946
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
947
|
+
var caseTag, enduser, res;
|
|
948
|
+
return __generator(this, function (_b) {
|
|
949
|
+
switch (_b.label) {
|
|
950
|
+
case 0:
|
|
951
|
+
caseTag = tag(label);
|
|
952
|
+
return [4 /*yield*/, new_enduser(label)];
|
|
953
|
+
case 1:
|
|
954
|
+
enduser = _b.sent();
|
|
955
|
+
return [4 /*yield*/, new_trigger({
|
|
956
|
+
title: "Stripe purchase made (".concat(label, ") ").concat(RUN),
|
|
957
|
+
event: { type: 'Purchase Made', info: couponCodes !== undefined ? { couponCodes: couponCodes } : {} },
|
|
958
|
+
tags: [caseTag],
|
|
959
|
+
})];
|
|
960
|
+
case 2:
|
|
961
|
+
_b.sent();
|
|
962
|
+
return [4 /*yield*/, (0, stripe_webhook_helpers_1.post_stripe_webhook)({
|
|
963
|
+
stripePublicKey: stripePublicKey,
|
|
964
|
+
secret: webhooksSecret,
|
|
965
|
+
event: (0, stripe_webhook_helpers_1.invoice_paid_event)({
|
|
966
|
+
stripeCustomerId: enduser.stripeCustomerId,
|
|
967
|
+
lines: [(0, stripe_webhook_helpers_1.invoice_paid_line)({ description: "Coupon Test ".concat(label, " ").concat(RUN) })],
|
|
968
|
+
discounts: discounts,
|
|
969
|
+
discount: discount,
|
|
970
|
+
}),
|
|
971
|
+
})];
|
|
972
|
+
case 3:
|
|
973
|
+
res = _b.sent();
|
|
974
|
+
(0, testing_1.assert)(res.status === 200, "expected 200, got ".concat(res.status, " (").concat(res.data, ")"), "".concat(label, " webhook accepted"));
|
|
975
|
+
if (!shouldFire) return [3 /*break*/, 5];
|
|
976
|
+
return [4 /*yield*/, expect_fired(enduser.id, caseTag, title)];
|
|
977
|
+
case 4:
|
|
978
|
+
_b.sent();
|
|
979
|
+
return [3 /*break*/, 7];
|
|
980
|
+
case 5: return [4 /*yield*/, expect_not_fired(enduser.id, caseTag, title)];
|
|
981
|
+
case 6:
|
|
982
|
+
_b.sent();
|
|
983
|
+
_b.label = 7;
|
|
984
|
+
case 7: return [2 /*return*/, enduser];
|
|
985
|
+
}
|
|
986
|
+
});
|
|
987
|
+
});
|
|
988
|
+
};
|
|
989
|
+
return [4 /*yield*/, run_coupon_invoice_case({
|
|
990
|
+
label: 'c1-matching-promo',
|
|
991
|
+
couponCodes: ['SUMMER20'],
|
|
992
|
+
discounts: [(0, stripe_webhook_helpers_1.discount_with_promo_code)('SUMMER20')],
|
|
993
|
+
shouldFire: true,
|
|
994
|
+
title: 'coupon-scoped Purchase Made trigger fires for a matching promo code',
|
|
995
|
+
})];
|
|
996
|
+
case 69:
|
|
997
|
+
c1Enduser = _f.sent();
|
|
998
|
+
return [4 /*yield*/, poll_for_purchase(c1Enduser.id)];
|
|
999
|
+
case 70:
|
|
1000
|
+
c1Purchases = _f.sent();
|
|
1001
|
+
(0, testing_1.assert)(c1Purchases.some(function (p) { var _a; return (_a = p.couponCodes) === null || _a === void 0 ? void 0 : _a.includes('SUMMER20'); }), "expected a purchase with couponCodes containing SUMMER20, got ".concat(JSON.stringify(c1Purchases.map(function (p) { return p.couponCodes; }))), 'couponCodes persisted on the webhook-created purchase');
|
|
1002
|
+
c1bDiscount = (0, stripe_webhook_helpers_1.discount_with_promo_code_ref)({ couponId: "coupon_test_c1b_".concat(RUN), couponName: 'Test coupon' });
|
|
1003
|
+
return [4 /*yield*/, run_coupon_invoice_case({
|
|
1004
|
+
label: 'c1b-real-shape',
|
|
1005
|
+
couponCodes: ['Test coupon'],
|
|
1006
|
+
discount: c1bDiscount,
|
|
1007
|
+
discounts: [c1bDiscount.id],
|
|
1008
|
+
shouldFire: true,
|
|
1009
|
+
title: 'real-shaped invoice.paid payload matches via coupon name',
|
|
1010
|
+
})];
|
|
1011
|
+
case 71:
|
|
1012
|
+
c1bEnduser = _f.sent();
|
|
1013
|
+
return [4 /*yield*/, poll_for_purchase(c1bEnduser.id)];
|
|
1014
|
+
case 72:
|
|
1015
|
+
c1bPurchases = _f.sent();
|
|
1016
|
+
(0, testing_1.assert)(c1bPurchases.some(function (p) { var _a, _b; return ((_a = p.couponCodes) === null || _a === void 0 ? void 0 : _a.includes('Test coupon')) && ((_b = p.couponCodes) === null || _b === void 0 ? void 0 : _b.includes("coupon_test_c1b_".concat(RUN))); }), "expected couponCodes with the coupon name and id, got ".concat(JSON.stringify(c1bPurchases.map(function (p) { return p.couponCodes; }))), 'coupon name and id persisted from a real-shaped payload');
|
|
1017
|
+
// C2: matching is case-sensitive — Stripe sends the canonical merchant-defined code, so a
|
|
1018
|
+
// differently-cased trigger value must stay quiet (staff can list multiple variants if needed)
|
|
1019
|
+
return [4 /*yield*/, run_coupon_invoice_case({
|
|
1020
|
+
label: 'c2-case-mismatch',
|
|
1021
|
+
couponCodes: ['summer20'],
|
|
1022
|
+
discounts: [(0, stripe_webhook_helpers_1.discount_with_promo_code)('SUMMER20')],
|
|
1023
|
+
shouldFire: false,
|
|
1024
|
+
title: 'coupon match is case-sensitive: a differently-cased code does not fire',
|
|
1025
|
+
})
|
|
1026
|
+
// C3: a different code stays quiet
|
|
1027
|
+
];
|
|
1028
|
+
case 73:
|
|
1029
|
+
// C2: matching is case-sensitive — Stripe sends the canonical merchant-defined code, so a
|
|
1030
|
+
// differently-cased trigger value must stay quiet (staff can list multiple variants if needed)
|
|
1031
|
+
_f.sent();
|
|
1032
|
+
// C3: a different code stays quiet
|
|
1033
|
+
return [4 /*yield*/, run_coupon_invoice_case({
|
|
1034
|
+
label: 'c3-nonmatching',
|
|
1035
|
+
couponCodes: ['SUMMER20'],
|
|
1036
|
+
discounts: [(0, stripe_webhook_helpers_1.discount_with_promo_code)('WINTER10')],
|
|
1037
|
+
shouldFire: false,
|
|
1038
|
+
title: 'coupon-scoped trigger does not fire for a different code',
|
|
1039
|
+
})
|
|
1040
|
+
// C4: an undiscounted invoice never matches a coupon-scoped trigger
|
|
1041
|
+
];
|
|
1042
|
+
case 74:
|
|
1043
|
+
// C3: a different code stays quiet
|
|
1044
|
+
_f.sent();
|
|
1045
|
+
// C4: an undiscounted invoice never matches a coupon-scoped trigger
|
|
1046
|
+
return [4 /*yield*/, run_coupon_invoice_case({
|
|
1047
|
+
label: 'c4-no-discounts',
|
|
1048
|
+
couponCodes: ['SUMMER20'],
|
|
1049
|
+
shouldFire: false,
|
|
1050
|
+
title: 'an invoice with no discounts does not fire a coupon-scoped trigger',
|
|
1051
|
+
})
|
|
1052
|
+
// C5: admin-applied coupons carry a name but no promotion code, and must still match. Built
|
|
1053
|
+
// once and referenced by id from `discounts`, mirroring the real single-discount payload shape.
|
|
1054
|
+
];
|
|
1055
|
+
case 75:
|
|
1056
|
+
// C4: an undiscounted invoice never matches a coupon-scoped trigger
|
|
1057
|
+
_f.sent();
|
|
1058
|
+
c5Discount = (0, stripe_webhook_helpers_1.discount_with_coupon)('Spring Promo');
|
|
1059
|
+
return [4 /*yield*/, run_coupon_invoice_case({
|
|
1060
|
+
label: 'c5-coupon-name',
|
|
1061
|
+
couponCodes: ['Spring Promo'],
|
|
1062
|
+
discount: c5Discount,
|
|
1063
|
+
discounts: [c5Discount.id],
|
|
1064
|
+
shouldFire: true,
|
|
1065
|
+
title: 'coupon-scoped trigger matches via coupon name (no promotion code)',
|
|
1066
|
+
})
|
|
1067
|
+
// C6: backward compat — an unscoped Purchase Made trigger fires for discounted and
|
|
1068
|
+
// undiscounted invoices alike
|
|
1069
|
+
];
|
|
1070
|
+
case 76:
|
|
1071
|
+
_f.sent();
|
|
1072
|
+
// C6: backward compat — an unscoped Purchase Made trigger fires for discounted and
|
|
1073
|
+
// undiscounted invoices alike
|
|
1074
|
+
return [4 /*yield*/, run_coupon_invoice_case({
|
|
1075
|
+
label: 'c6-unscoped-discounted',
|
|
1076
|
+
discounts: [(0, stripe_webhook_helpers_1.discount_with_promo_code)('SUMMER20')],
|
|
1077
|
+
shouldFire: true,
|
|
1078
|
+
title: 'unscoped Purchase Made trigger fires for a discounted invoice',
|
|
1079
|
+
})];
|
|
1080
|
+
case 77:
|
|
1081
|
+
// C6: backward compat — an unscoped Purchase Made trigger fires for discounted and
|
|
1082
|
+
// undiscounted invoices alike
|
|
1083
|
+
_f.sent();
|
|
1084
|
+
return [4 /*yield*/, run_coupon_invoice_case({
|
|
1085
|
+
label: 'c6b-unscoped-undiscounted',
|
|
1086
|
+
shouldFire: true,
|
|
1087
|
+
title: 'unscoped Purchase Made trigger fires for an undiscounted invoice',
|
|
1088
|
+
})
|
|
1089
|
+
// C7: charge.succeeded with payment_intent null — the coupon lookup is skipped entirely, so
|
|
1090
|
+
// the purchase is created, the unscoped trigger fires, and the coupon-scoped one does not
|
|
1091
|
+
];
|
|
1092
|
+
case 78:
|
|
1093
|
+
_f.sent();
|
|
1094
|
+
C7_TAG = tag('c7-charge-unscoped');
|
|
1095
|
+
C7_SCOPED_TAG = tag('c7-charge-coupon-scoped');
|
|
1096
|
+
return [4 /*yield*/, new_enduser('c7')];
|
|
1097
|
+
case 79:
|
|
1098
|
+
c7Enduser = _f.sent();
|
|
1099
|
+
return [4 /*yield*/, new_trigger({
|
|
1100
|
+
title: "Stripe purchase made (c7 unscoped) ".concat(RUN),
|
|
1101
|
+
event: { type: 'Purchase Made', info: {} },
|
|
1102
|
+
tags: [C7_TAG],
|
|
1103
|
+
})];
|
|
1104
|
+
case 80:
|
|
1105
|
+
_f.sent();
|
|
1106
|
+
return [4 /*yield*/, new_trigger({
|
|
1107
|
+
title: "Stripe purchase made (c7 coupon-scoped) ".concat(RUN),
|
|
1108
|
+
event: { type: 'Purchase Made', info: { couponCodes: ['SUMMER20'] } },
|
|
1109
|
+
tags: [C7_SCOPED_TAG],
|
|
1110
|
+
})];
|
|
1111
|
+
case 81:
|
|
1112
|
+
_f.sent();
|
|
1113
|
+
return [4 /*yield*/, (0, stripe_webhook_helpers_1.post_stripe_webhook)({
|
|
1114
|
+
stripePublicKey: stripePublicKey,
|
|
1115
|
+
secret: webhooksSecret,
|
|
1116
|
+
event: (0, stripe_webhook_helpers_1.charge_succeeded_event)({
|
|
1117
|
+
customer: {
|
|
1118
|
+
id: c7Enduser.stripeCustomerId,
|
|
1119
|
+
email: "stripe-webhook-c7-".concat(RUN, "@tellescope.com"),
|
|
1120
|
+
name: 'Stripe Webhook c7',
|
|
1121
|
+
},
|
|
1122
|
+
}),
|
|
1123
|
+
})];
|
|
1124
|
+
case 82:
|
|
1125
|
+
c7Res = _f.sent();
|
|
1126
|
+
(0, testing_1.assert)(c7Res.status === 200, "expected 200, got ".concat(c7Res.status, " (").concat(c7Res.data, ")"), 'charge.succeeded webhook accepted');
|
|
1127
|
+
return [4 /*yield*/, expect_fired(c7Enduser.id, C7_TAG, 'unscoped Purchase Made trigger fires for charge.succeeded')];
|
|
1128
|
+
case 83:
|
|
1129
|
+
_f.sent();
|
|
1130
|
+
return [4 /*yield*/, expect_not_fired(c7Enduser.id, C7_SCOPED_TAG, 'coupon-scoped trigger does not fire for a charge with no coupon data')];
|
|
1131
|
+
case 84:
|
|
1132
|
+
_f.sent();
|
|
1133
|
+
return [4 /*yield*/, poll_for_purchase(c7Enduser.id)];
|
|
1134
|
+
case 85:
|
|
1135
|
+
c7Purchases = _f.sent();
|
|
1136
|
+
(0, testing_1.assert)(c7Purchases.length > 0, 'expected charge.succeeded to create a purchase', 'charge.succeeded purchase created');
|
|
1137
|
+
C8_TAG = tag('c8-charge-failed-lookup');
|
|
1138
|
+
return [4 /*yield*/, new_enduser('c8')];
|
|
1139
|
+
case 86:
|
|
1140
|
+
c8Enduser = _f.sent();
|
|
1141
|
+
return [4 /*yield*/, new_trigger({
|
|
1142
|
+
title: "Stripe purchase made (c8 failed session lookup) ".concat(RUN),
|
|
1143
|
+
event: { type: 'Purchase Made', info: {} },
|
|
1144
|
+
tags: [C8_TAG],
|
|
1145
|
+
})];
|
|
1146
|
+
case 87:
|
|
1147
|
+
_f.sent();
|
|
1148
|
+
return [4 /*yield*/, (0, stripe_webhook_helpers_1.post_stripe_webhook)({
|
|
1149
|
+
stripePublicKey: stripePublicKey,
|
|
1150
|
+
secret: webhooksSecret,
|
|
1151
|
+
event: (0, stripe_webhook_helpers_1.charge_succeeded_event)({
|
|
1152
|
+
customer: {
|
|
1153
|
+
id: c8Enduser.stripeCustomerId,
|
|
1154
|
+
email: "stripe-webhook-c8-".concat(RUN, "@tellescope.com"),
|
|
1155
|
+
name: 'Stripe Webhook c8',
|
|
1156
|
+
},
|
|
1157
|
+
payment_intent: "pi_test_".concat(RUN),
|
|
1158
|
+
}),
|
|
1159
|
+
})];
|
|
1160
|
+
case 88:
|
|
1161
|
+
c8Res = _f.sent();
|
|
1162
|
+
(0, testing_1.assert)(c8Res.status === 200, "expected 200, got ".concat(c8Res.status, " (").concat(c8Res.data, ")"), 'charge.succeeded with failing session lookup still accepted');
|
|
1163
|
+
return [4 /*yield*/, expect_fired(c8Enduser.id, C8_TAG, 'a failing checkout-session lookup does not block the purchase or its triggers')
|
|
1164
|
+
// C9: couponCodes must round-trip on the trigger's event.info
|
|
1165
|
+
];
|
|
1166
|
+
case 89:
|
|
1167
|
+
_f.sent();
|
|
1168
|
+
return [4 /*yield*/, new_trigger({
|
|
1169
|
+
title: "Stripe purchase made (validator round-trip) ".concat(RUN),
|
|
1170
|
+
event: { type: 'Purchase Made', info: { couponCodes: ['SUMMER20'] } },
|
|
1171
|
+
tags: [tag('c9')],
|
|
1172
|
+
})];
|
|
1173
|
+
case 90:
|
|
1174
|
+
c9Trigger = _f.sent();
|
|
1175
|
+
return [4 /*yield*/, sdk.api.automation_triggers.getOne(c9Trigger.id)];
|
|
1176
|
+
case 91:
|
|
1177
|
+
c9Fetched = _f.sent();
|
|
1178
|
+
(0, testing_1.assert)(JSON.stringify((_e = c9Fetched.event.info) === null || _e === void 0 ? void 0 : _e.couponCodes) === JSON.stringify(['SUMMER20']), "expected couponCodes to round-trip, got ".concat(JSON.stringify(c9Fetched.event)), 'couponCodes round-trips through the validator');
|
|
916
1179
|
console.log("All Stripe webhook trigger tests passed!");
|
|
917
|
-
return [3 /*break*/,
|
|
918
|
-
case
|
|
1180
|
+
return [3 /*break*/, 95];
|
|
1181
|
+
case 92:
|
|
919
1182
|
// Best-effort only: the harness exits the process on the first failed assertion, which skips
|
|
920
1183
|
// this block. setup_stripe_test_integration clears integration residue on the next run.
|
|
921
1184
|
return [4 /*yield*/, cleanup().catch(console.error)];
|
|
922
|
-
case
|
|
1185
|
+
case 93:
|
|
923
1186
|
// Best-effort only: the harness exits the process on the first failed assertion, which skips
|
|
924
1187
|
// this block. setup_stripe_test_integration clears integration residue on the next run.
|
|
925
|
-
|
|
1188
|
+
_f.sent();
|
|
926
1189
|
return [4 /*yield*/, Promise.all(__spreadArray(__spreadArray(__spreadArray([], createdTriggerIds.map(function (id) { return sdk.api.automation_triggers.deleteOne(id).catch(console.error); }), true), createdProductIds.map(function (id) { return sdk.api.products.deleteOne(id).catch(console.error); }), true), createdEnduserIds.map(function (id) { return sdk.api.endusers.deleteOne(id).catch(console.error); }), true))];
|
|
927
|
-
case
|
|
928
|
-
|
|
1190
|
+
case 94:
|
|
1191
|
+
_f.sent();
|
|
929
1192
|
return [7 /*endfinally*/];
|
|
930
|
-
case
|
|
1193
|
+
case 95: return [2 /*return*/];
|
|
931
1194
|
}
|
|
932
1195
|
});
|
|
933
1196
|
});
|