From 328d33d280189020c8ac08670a363040fc28fcd0 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Sat, 8 Aug 2020 14:08:30 -0400 Subject: [PATCH] add check to ensure each user received exactly one first_payment notification --- .../confirm_first_payment_notification.json | 26 ++++++++ .../models/tests/promo/multi_promo.json | 62 ++++++++++++++++--- 2 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 bubble-server/src/test/resources/models/include/confirm_first_payment_notification.json diff --git a/bubble-server/src/test/resources/models/include/confirm_first_payment_notification.json b/bubble-server/src/test/resources/models/include/confirm_first_payment_notification.json new file mode 100644 index 00000000..121ace25 --- /dev/null +++ b/bubble-server/src/test/resources/models/include/confirm_first_payment_notification.json @@ -0,0 +1,26 @@ +[ + { + "comment": "declare default parameters for new_account test part", + "include": "_defaults", + "params": { + "email": "_required", + "rootSessionName": "rootSession", + "expectedCount": "1" + } + }, + { + "comment": "root: confirm <> received exactly one first_payment notification", + "request": { + "session": "rootSession", + "uri": "debug/inbox/email/<>?type=notice&action=first_payment&target=network" + }, + "response": { + "check": [ + {"condition": "json.length === <>"}, + {"condition": "'{{json.[0].ctx.message.messageType}}' === 'notice'"}, + {"condition": "'{{json.[0].ctx.message.action}}' === 'first_payment'"}, + {"condition": "'{{json.[0].ctx.message.target}}' === 'network'"} + ] + } + } +] \ No newline at end of file diff --git a/bubble-server/src/test/resources/models/tests/promo/multi_promo.json b/bubble-server/src/test/resources/models/tests/promo/multi_promo.json index 52d7f07e..da3456b9 100644 --- a/bubble-server/src/test/resources/models/tests/promo/multi_promo.json +++ b/bubble-server/src/test/resources/models/tests/promo/multi_promo.json @@ -308,7 +308,7 @@ // Second Month -- referred users use their referral credit. referring user pays with card { - "before": "fast_forward_and_bill 29d 60s", + "before": "fast_forward_and_bill 29d 40s", "comment": "root: fast-forward +29 days, verify referring user received notice about first real payment", "request": { "session": "rootSession", @@ -350,7 +350,7 @@ }, { - "before": "fast_forward_and_bill 2d 30s", + "before": "fast_forward_and_bill 2d 40s", "comment": "referring: fast-forward +2 days, verify a new bill exists for referring", "request": { "session": "referringUserSession", @@ -438,8 +438,34 @@ // Third Month -- referred users pay with card. referring user pays with 1st referral credit { - "before": "fast_forward_and_bill 31d 30s", - "comment": "referring: second fast-forward +31 days, verify a new bill exists for referring", + "before": "fast_forward_and_bill 29d 40s", + "comment": "root: second fast-forward +29 days, verify referred user 1 received notice about first real payment", + "request": { + "session": "rootSession", + "uri": "debug/inbox/email/referred_multi_1@example.com?type=notice&action=first_payment&target=network" + }, + "response": { + "check": [ + {"condition": "'{{json.[0].ctx.message.messageType}}' === 'notice'"}, + {"condition": "'{{json.[0].ctx.message.action}}' === 'first_payment'"}, + {"condition": "'{{json.[0].ctx.message.target}}' === 'network'"} + ] + } + }, + { + "comment": "root: verify referred user 2 received notice about first real payment", + "include": "confirm_first_payment_notification", + "params": { "email": "referred_multi_2@example.com" } + }, + { + "comment": "root: verify referred user 3 received notice about first real payment", + "include": "confirm_first_payment_notification", + "params": { "email": "referred_multi_3@example.com" } + }, + + { + "before": "fast_forward_and_bill 2d 40s", + "comment": "referring: second fast-forward +2 days, verify a new bill exists for referring", "request": { "session": "referringUserSession", "uri": "me/plans/{{referringAccountPlan.uuid}}/bills" @@ -541,7 +567,7 @@ // Fourth Month -- referreds pay with card, referring pays with 2nd referral credit { - "before": "fast_forward_and_bill 31d 30s", + "before": "fast_forward_and_bill 31d 40s", "comment": "referring: third fast-forward +31 days, verify a new bill exists for referring", "request": { "session": "referringUserSession", @@ -717,7 +743,7 @@ // 6th Month -- referreds pay with card, referring uses regular account credit + card { - "before": "fast_forward_and_bill 31d 30s", + "before": "fast_forward_and_bill 31d 40s", "comment": "referring: fifth fast-forward +31 days, verify a new bill exists for referring", "request": { "session": "referringUserSession", @@ -809,7 +835,7 @@ // 7th Month -- everyone pays with credit card { - "before": "fast_forward_and_bill 31d 30s", + "before": "fast_forward_and_bill 31d 40s", "comment": "referring: sixth fast-forward +31 days, verify a new bill exists for referring", "request": { "session": "referringUserSession", @@ -958,5 +984,27 @@ {"condition": "_find(json, function(p) { return p.getMaskedPaymentInfo() === 'AccountCredit5' && p.deleted(); }) !== null"} ] } + }, + + // confirm each user has received exactly one first_payment notification + { + "comment": "root: confirm referring user received exactly one first_payment notification", + "include": "confirm_first_payment_notification", + "params": { "email": "test_user_referring_multi@example.com" } + }, + { + "comment": "root: confirm referring user received exactly one first_payment notification", + "include": "confirm_first_payment_notification", + "params": { "email": "referred_multi_1@example.com" } + }, + { + "comment": "root: confirm referring user received exactly one first_payment notification", + "include": "confirm_first_payment_notification", + "params": { "email": "referred_multi_2@example.com" } + }, + { + "comment": "root: confirm referring user received exactly one first_payment notification", + "include": "confirm_first_payment_notification", + "params": { "email": "referred_multi_3@example.com" } } ] \ No newline at end of file