mirror of
https://github.com/plausible/analytics.git
synced 2024-12-29 20:42:01 +03:00
232298d327
* Auto-updating dashboard with realtime info * Remove extra route * Draw list of countries next to the map * Nice animations * Do not show bounce rates in realtime modals * Update countries and devices in realtime * Remove unused component * Show total pageviews in the last 30 minutes * Show proper labels * Remove unnecessary z-index * Fix label for main graph * Fix compiler warnings * Add tests * Fix copy pluralizations * Fix copy in countries modal * Real-time -> Realtime * Looser test assertion * Show last 30 minutes conversions on realtime report * Remove EventTarget API because it doesn't work on Safari * Get referrer drilldown from sessions table * Fix failing tests
43 lines
1.5 KiB
Elixir
43 lines
1.5 KiB
Elixir
defmodule PlausibleWeb.Api.StatsController.PagesTest do
|
|
use PlausibleWeb.ConnCase
|
|
import Plausible.TestUtils
|
|
|
|
describe "GET /api/stats/:domain/pages" do
|
|
setup [:create_user, :log_in, :create_site]
|
|
|
|
test "returns top pages sources by pageviews", %{conn: conn, site: site} do
|
|
conn = get(conn, "/api/stats/#{site.domain}/pages?period=day&date=2019-01-01")
|
|
|
|
assert json_response(conn, 200) == [
|
|
%{"count" => 2, "name" => "/"},
|
|
%{"count" => 2, "name" => "/register"},
|
|
%{"count" => 1, "name" => "/contact"},
|
|
%{"count" => 1, "name" => "/irrelevant"}
|
|
]
|
|
end
|
|
|
|
test "calculates bounce rate for pages", %{conn: conn, site: site} do
|
|
conn =
|
|
get(
|
|
conn,
|
|
"/api/stats/#{site.domain}/pages?period=day&date=2019-01-01&include=bounce_rate"
|
|
)
|
|
|
|
assert json_response(conn, 200) == [
|
|
%{"count" => 2, "name" => "/", "bounce_rate" => 33.0},
|
|
%{"bounce_rate" => nil, "count" => 2, "name" => "/register"},
|
|
%{"bounce_rate" => nil, "count" => 1, "name" => "/contact"},
|
|
%{"bounce_rate" => nil, "count" => 1, "name" => "/irrelevant"}
|
|
]
|
|
end
|
|
|
|
test "returns top pages in realtime report", %{conn: conn, site: site} do
|
|
conn = get(conn, "/api/stats/#{site.domain}/pages?period=realtime")
|
|
|
|
assert json_response(conn, 200) == [
|
|
%{"count" => 3, "name" => "/"}
|
|
]
|
|
end
|
|
end
|
|
end
|