mirror of
https://github.com/plausible/analytics.git
synced 2024-12-27 19:47:26 +03:00
22 lines
832 B
Elixir
22 lines
832 B
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
|
||
|
insert(:pageview, hostname: site.domain, pathname: "/", timestamp: ~N[2019-01-01 01:00:00])
|
||
|
insert(:pageview, hostname: site.domain, pathname: "/", timestamp: ~N[2019-01-01 01:00:00])
|
||
|
insert(:pageview, hostname: site.domain, pathname: "/contact", timestamp: ~N[2019-01-01 01:00:00])
|
||
|
|
||
|
conn = get(conn, "/api/stats/#{site.domain}/pages?period=day&date=2019-01-01")
|
||
|
|
||
|
assert json_response(conn, 200) == [
|
||
|
%{"name" => "/", "count" => 2},
|
||
|
%{"name" => "/contact", "count" => 1},
|
||
|
]
|
||
|
end
|
||
|
end
|
||
|
end
|