analytics/test/workers/notify_exported_analytics_test.exs
ruslandoga 972dd5d150
redirect to s3 url when downloading exports (#4002)
* redirect to s3 url

* use new on_ee macro, reduce wait time for email to five seconds
2024-05-02 19:53:12 +01:00

33 lines
906 B
Elixir

defmodule Plausible.Workers.NotifyExportedAnalyticsTest do
use Plausible
use Plausible.DataCase
use Bamboo.Test
describe "perform/1" do
setup do
user = insert(:user)
site = insert(:site, members: [user])
{:ok, user: user, site: site}
end
# for 'success' case please see Plausible.Imported.CSVImporterTest
test "delivers 'failure' email", %{user: user, site: site} do
job =
Plausible.Workers.NotifyExportedAnalytics.new(%{
"status" => "failure",
"storage" => on_ee(do: "s3", else: "local"),
"email_to" => user.email,
"site_id" => site.id
})
Oban.insert!(job)
assert %{success: 1} =
Oban.drain_queue(queue: :notify_exported_analytics, with_safety: false)
assert_receive {:delivered_email, email}
assert email.html_body =~ "was unsuccessful."
end
end
end