Leon4gr45 commited on
Commit
fce4993
·
verified ·
1 Parent(s): ee1cb26

Delete test/workers/notify_annual_renewal_test.exs with huggingface_hub

Browse files
test/workers/notify_annual_renewal_test.exs DELETED
@@ -1,187 +0,0 @@
1
- defmodule Plausible.Workers.NotifyAnnualRenewalTest do
2
- use Plausible.DataCase, async: true
3
- use Bamboo.Test
4
- require Plausible.Billing.Subscription.Status
5
- alias Plausible.Workers.NotifyAnnualRenewal
6
- alias Plausible.Billing.Subscription
7
-
8
- setup [:create_user, :create_site]
9
- @monthly_plan "558018"
10
- @yearly_plan "572810"
11
- @v2_pricing_yearly_plan "653232"
12
-
13
- test "ignores user without subscription" do
14
- NotifyAnnualRenewal.perform(nil)
15
-
16
- assert_no_emails_delivered()
17
- end
18
-
19
- test "ignores user with monthly subscription", %{user: user} do
20
- subscribe_to_plan(user, @monthly_plan, next_bill_date: Date.shift(Date.utc_today(), day: 7))
21
-
22
- NotifyAnnualRenewal.perform(nil)
23
-
24
- assert_no_emails_delivered()
25
- end
26
-
27
- test "ignores user with yearly subscription that's not due for renewal in 7 days", %{user: user} do
28
- subscribe_to_plan(user, @yearly_plan, next_bill_date: Date.shift(Date.utc_today(), day: 10))
29
-
30
- NotifyAnnualRenewal.perform(nil)
31
-
32
- assert_no_emails_delivered()
33
- end
34
-
35
- test "ignores user with old yearly subscription that's been superseded by a newer one", %{
36
- user: user
37
- } do
38
- subscribe_to_plan(
39
- user,
40
- @yearly_plan,
41
- next_bill_date: Date.shift(Date.utc_today(), day: 5),
42
- inserted_at: NaiveDateTime.shift(NaiveDateTime.utc_now(), day: -1)
43
- )
44
-
45
- subscribe_to_plan(
46
- user,
47
- @yearly_plan,
48
- next_bill_date: Date.shift(Date.utc_today(), day: 30),
49
- inserted_at: NaiveDateTime.utc_now()
50
- )
51
-
52
- NotifyAnnualRenewal.perform(nil)
53
-
54
- assert_no_emails_delivered()
55
- end
56
-
57
- test "sends renewal notification to user whose subscription is due for renewal in 7 days", %{
58
- user: user
59
- } do
60
- subscribe_to_plan(
61
- user,
62
- @yearly_plan,
63
- next_bill_date: Date.shift(Date.utc_today(), day: 7)
64
- )
65
-
66
- team = team_of(user)
67
- billing_member = new_user()
68
- add_member(team, user: billing_member, role: :billing)
69
-
70
- NotifyAnnualRenewal.perform(nil)
71
-
72
- assert_email_delivered_with(
73
- to: [{user.name, user.email}],
74
- subject: "Your Plausible subscription is up for renewal"
75
- )
76
-
77
- assert_email_delivered_with(
78
- to: [{billing_member.name, billing_member.email}],
79
- subject: "Your Plausible subscription is up for renewal"
80
- )
81
- end
82
-
83
- test "sends renewal notification to user whose subscription is due for renewal in 2 days", %{
84
- user: user
85
- } do
86
- subscribe_to_plan(
87
- user,
88
- @yearly_plan,
89
- next_bill_date: Date.shift(Date.utc_today(), day: 2)
90
- )
91
-
92
- NotifyAnnualRenewal.perform(nil)
93
-
94
- assert_email_delivered_with(
95
- to: [{user.name, user.email}],
96
- subject: "Your Plausible subscription is up for renewal"
97
- )
98
- end
99
-
100
- test "does not send renewal notification multiple times", %{user: user} do
101
- subscribe_to_plan(user, @yearly_plan, next_bill_date: Date.shift(Date.utc_today(), day: 7))
102
-
103
- NotifyAnnualRenewal.perform(nil)
104
-
105
- assert_email_delivered_with(
106
- to: [{user.name, user.email}],
107
- subject: "Your Plausible subscription is up for renewal"
108
- )
109
-
110
- NotifyAnnualRenewal.perform(nil)
111
-
112
- assert_no_emails_delivered()
113
- end
114
-
115
- test "sends a renewal notification again a year after the previous one", %{user: user} do
116
- subscribe_to_plan(user, @yearly_plan, next_bill_date: Date.shift(Date.utc_today(), day: 7))
117
-
118
- Repo.insert_all("sent_renewal_notifications", [
119
- %{
120
- user_id: user.id,
121
- timestamp: Date.shift(Date.utc_today(), year: -1) |> NaiveDateTime.new!(~T[00:00:00])
122
- }
123
- ])
124
-
125
- NotifyAnnualRenewal.perform(nil)
126
-
127
- assert_email_delivered_with(
128
- to: [{user.name, user.email}],
129
- subject: "Your Plausible subscription is up for renewal"
130
- )
131
- end
132
-
133
- test "does not send multiple notifications on second year", %{user: user} do
134
- subscribe_to_plan(user, @yearly_plan, next_bill_date: Date.shift(Date.utc_today(), day: 7))
135
-
136
- year_ago = Date.shift(Date.utc_today(), year: -1)
137
-
138
- Repo.insert_all("sent_renewal_notifications", [
139
- %{
140
- user_id: user.id,
141
- timestamp: NaiveDateTime.new!(year_ago, ~T[00:00:00])
142
- }
143
- ])
144
-
145
- NotifyAnnualRenewal.perform(nil)
146
-
147
- assert_email_delivered_with(
148
- to: [{user.name, user.email}],
149
- subject: "Your Plausible subscription is up for renewal"
150
- )
151
-
152
- NotifyAnnualRenewal.perform(nil)
153
-
154
- assert_no_emails_delivered()
155
- end
156
-
157
- test "sends renewal notification to user on v2 yearly pricing plans", %{
158
- user: user
159
- } do
160
- subscribe_to_plan(user, @v2_pricing_yearly_plan,
161
- next_bill_date: Date.shift(Date.utc_today(), day: 7)
162
- )
163
-
164
- NotifyAnnualRenewal.perform(nil)
165
-
166
- assert_email_delivered_with(
167
- to: [{user.name, user.email}],
168
- subject: "Your Plausible subscription is up for renewal"
169
- )
170
- end
171
-
172
- describe "expiration" do
173
- test "if user subscription is 'deleted', notify them about expiration instead", %{user: user} do
174
- subscribe_to_plan(user, @yearly_plan,
175
- next_bill_date: Date.shift(Date.utc_today(), day: 7),
176
- status: Subscription.Status.deleted()
177
- )
178
-
179
- NotifyAnnualRenewal.perform(nil)
180
-
181
- assert_email_delivered_with(
182
- to: [{user.name, user.email}],
183
- subject: "Your Plausible subscription is about to expire"
184
- )
185
- end
186
- end
187
- end