-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do Not Send Digest Emails When Project Has No Workflow (#2858)
* Tests for digest emails when no activity * Project collaborators digest emails are by default turned off * Skip digest emails when project has no workflow * Update CL --------- Co-authored-by: Stuart Corbishley <[email protected]>
- Loading branch information
Showing
7 changed files
with
186 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,8 +271,6 @@ defmodule Lightning.Accounts.UserNotifierTest do | |
Click the link below to view this in the history page: | ||
#{UserNotifier.build_digest_url(workflow_c, start_date, end_date)} | ||
OpenFn | ||
""" | ||
) | ||
|
@@ -349,8 +347,6 @@ defmodule Lightning.Accounts.UserNotifierTest do | |
Click the link below to view this in the history page: | ||
#{UserNotifier.build_digest_url(workflow_c, start_date, end_date)} | ||
OpenFn | ||
""" | ||
) | ||
|
@@ -429,13 +425,65 @@ defmodule Lightning.Accounts.UserNotifierTest do | |
Click the link below to view this in the history page: | ||
#{UserNotifier.build_digest_url(workflow_c, start_date, end_date)} | ||
OpenFn | ||
""" | ||
) | ||
end | ||
|
||
test "digest emails with no activity" do | ||
user = %User{email: "[email protected]", first_name: "Elias"} | ||
project = %Project{name: "Real Project"} | ||
workflow = Lightning.WorkflowsFixtures.workflow_fixture(name: "Workflow A") | ||
|
||
data = [ | ||
%{ | ||
workflow: workflow, | ||
successful_workorders: 0, | ||
rerun_workorders: 0, | ||
failed_workorders: 0 | ||
} | ||
] | ||
|
||
for digest_type <- [:daily, :weekly, :monthly] do | ||
period = | ||
case digest_type do | ||
:daily -> "today" | ||
:weekly -> "this week" | ||
:monthly -> "this month" | ||
end | ||
|
||
start_date = DigestEmailWorker.digest_to_date(digest_type) | ||
end_date = Timex.now() | ||
|
||
UserNotifier.deliver_project_digest(data, %{ | ||
user: user, | ||
project: project, | ||
digest: digest_type, | ||
start_date: start_date, | ||
end_date: end_date | ||
}) | ||
|
||
assert_email_sent( | ||
subject: | ||
"#{String.capitalize("#{digest_type}")} digest for project Real Project", | ||
to: Swoosh.Email.Recipient.format(user), | ||
text_body: """ | ||
Hi Elias, | ||
Here's your #{digest_type} project digest for "Real Project", covering activity from #{start_date |> Calendar.strftime("%a %B %d %Y at %H:%M %Z")} to #{end_date |> Calendar.strftime("%a %B %d %Y at %H:%M %Z")}. | ||
Workflow A: | ||
- 0 workorders correctly processed #{period} | ||
- 0 work orders that failed, crashed or timed out | ||
Click the link below to view this in the history page: | ||
#{UserNotifier.build_digest_url(workflow, start_date, end_date)} | ||
OpenFn | ||
""" | ||
) | ||
end | ||
end | ||
|
||
test "Kafka trigger failure - alternate storage disabled" do | ||
stub(Lightning.MockConfig, :kafka_alternate_storage_enabled?, fn -> | ||
false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters