|
|
|
|
@ -139,6 +139,38 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do
|
|
|
|
|
"We were unable to authenticate your Google Analytics account"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "redirects to #{view} on timeout error with flash error (legacy: #{legacy})", %{
|
|
|
|
|
conn: conn,
|
|
|
|
|
site: site
|
|
|
|
|
} do
|
|
|
|
|
expect(
|
|
|
|
|
Plausible.HTTPClient.Mock,
|
|
|
|
|
:get,
|
|
|
|
|
fn _url, _opts ->
|
|
|
|
|
{:error, %Mint.TransportError{reason: :timeout}}
|
|
|
|
|
end
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
conn =
|
|
|
|
|
conn
|
|
|
|
|
|> get("/#{site.domain}/import/google-analytics/property-or-view", %{
|
|
|
|
|
"access_token" => "token",
|
|
|
|
|
"refresh_token" => "foo",
|
|
|
|
|
"expires_at" => "2022-09-22T20:01:37.112777",
|
|
|
|
|
"legacy" => unquote(legacy)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert redirected_to(conn, 302) ==
|
|
|
|
|
PlausibleWeb.Router.Helpers.site_path(
|
|
|
|
|
conn,
|
|
|
|
|
unquote(view),
|
|
|
|
|
site.domain
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
assert Phoenix.Flash.get(conn.assigns.flash, :error) =~
|
|
|
|
|
"Google Analytics API has timed out."
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "redirects to #{view} on list retrival failure with flash error (legacy: #{legacy})",
|
|
|
|
|
%{
|
|
|
|
|
conn: conn,
|
|
|
|
|
@ -460,6 +492,40 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do
|
|
|
|
|
assert Phoenix.Flash.get(conn.assigns.flash, :error) =~
|
|
|
|
|
"Google Analytics authentication seems to have expired."
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "redirects to #{view} on timeout with flash error (legacy: #{legacy})",
|
|
|
|
|
%{
|
|
|
|
|
conn: conn,
|
|
|
|
|
site: site
|
|
|
|
|
} do
|
|
|
|
|
expect(
|
|
|
|
|
Plausible.HTTPClient.Mock,
|
|
|
|
|
:post,
|
|
|
|
|
fn _url, _opts, _params ->
|
|
|
|
|
{:error, %Mint.TransportError{reason: :timeout}}
|
|
|
|
|
end
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
conn =
|
|
|
|
|
conn
|
|
|
|
|
|> post("/#{site.domain}/import/google-analytics/property-or-view", %{
|
|
|
|
|
"property_or_view" => "properties/428685906",
|
|
|
|
|
"access_token" => "token",
|
|
|
|
|
"refresh_token" => "foo",
|
|
|
|
|
"expires_at" => "2022-09-22T20:01:37.112777",
|
|
|
|
|
"legacy" => unquote(legacy)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert redirected_to(conn, 302) ==
|
|
|
|
|
PlausibleWeb.Router.Helpers.site_path(
|
|
|
|
|
conn,
|
|
|
|
|
unquote(view),
|
|
|
|
|
site.domain
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
assert Phoenix.Flash.get(conn.assigns.flash, :error) =~
|
|
|
|
|
"Google Analytics API has timed out."
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@ -624,6 +690,42 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do
|
|
|
|
|
assert Phoenix.Flash.get(conn.assigns.flash, :error) =~
|
|
|
|
|
"Google Analytics authentication seems to have expired."
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "redirects to #{view} on timeout with flash error (legacy: #{legacy})",
|
|
|
|
|
%{
|
|
|
|
|
conn: conn,
|
|
|
|
|
site: site
|
|
|
|
|
} do
|
|
|
|
|
expect(
|
|
|
|
|
Plausible.HTTPClient.Mock,
|
|
|
|
|
:get,
|
|
|
|
|
fn _url, _params ->
|
|
|
|
|
{:error, %Mint.TransportError{reason: :timeout}}
|
|
|
|
|
end
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
conn =
|
|
|
|
|
conn
|
|
|
|
|
|> get("/#{site.domain}/import/google-analytics/confirm", %{
|
|
|
|
|
"property_or_view" => "properties/428685906",
|
|
|
|
|
"access_token" => "token",
|
|
|
|
|
"refresh_token" => "foo",
|
|
|
|
|
"expires_at" => "2022-09-22T20:01:37.112777",
|
|
|
|
|
"start_date" => "2024-02-22",
|
|
|
|
|
"end_date" => "2024-02-26",
|
|
|
|
|
"legacy" => unquote(legacy)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert redirected_to(conn, 302) ==
|
|
|
|
|
PlausibleWeb.Router.Helpers.site_path(
|
|
|
|
|
conn,
|
|
|
|
|
unquote(view),
|
|
|
|
|
site.domain
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
assert Phoenix.Flash.get(conn.assigns.flash, :error) =~
|
|
|
|
|
"Google Analytics API has timed out."
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|