Compare commits
9 Commits
master
...
new-top-re
| Author | SHA1 | Date |
|---|---|---|
|
|
a65ad0f5b0 | 3 years ago |
|
|
66fa9fb1c4 | 3 years ago |
|
|
4bf01e9d74 | 3 years ago |
|
|
a21d5200d5 | 3 years ago |
|
|
c692229fad | 3 years ago |
|
|
37f4e53e79 | 3 years ago |
|
|
f8d128096a | 3 years ago |
|
|
0882a1db90 | 3 years ago |
|
|
9330fef138 | 3 years ago |
@ -0,0 +1,45 @@
|
||||
defmodule PlausibleWeb.Api.StatsController.TopReportTest do
|
||||
use PlausibleWeb.ConnCase
|
||||
|
||||
@user_id 123
|
||||
|
||||
describe "GET /api/stats/top-report" do
|
||||
setup [:create_user, :log_in, :create_new_site]
|
||||
|
||||
test "returns graph and top stats", %{conn: conn, site: site} do
|
||||
populate_stats(site, [
|
||||
build(:pageview, timestamp: ~N[2021-01-11 04:00:00]),
|
||||
build(:pageview, timestamp: ~N[2021-01-11 05:00:00]),
|
||||
build(:pageview, timestamp: ~N[2021-01-11 18:00:00])
|
||||
])
|
||||
|
||||
conn =
|
||||
get(
|
||||
conn,
|
||||
"/api/stats/#{site.domain}/top-report?period=day&date=2021-01-11&metric=pageviews"
|
||||
)
|
||||
|
||||
assert %{"plot" => curr, "top_stats" => top_stats} = json_response(conn, 200)
|
||||
assert [0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] = curr
|
||||
|
||||
assert %{
|
||||
"name" => "Unique visitors",
|
||||
"value" => 3,
|
||||
"graph_metric" => "visitors"
|
||||
} in top_stats
|
||||
end
|
||||
|
||||
test "always adds comparison for top stats"
|
||||
test "compares both top stats and graph when requested"
|
||||
|
||||
test "overrides metric with default when invalid metric provided", %{site: site, conn: conn} do
|
||||
# requires goal filter
|
||||
conn = get(conn, "/api/stats/#{site.domain}/top-report?period=day&metric=events")
|
||||
assert %{"metric" => "visitors"} = json_response(conn, 200)
|
||||
end
|
||||
|
||||
test "overrides interval with default when invalid interval provided"
|
||||
test "custom date range interval handling"
|
||||
test "all time date range interval handling"
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue