analytics/test/plausible_web/controllers/api/internal_controller_test.exs

26 lines
759 B
Elixir
Raw Normal View History

2019-09-02 14:29:19 +03:00
defmodule PlausibleWeb.Api.InternalControllerTest do
use PlausibleWeb.ConnCase
use Plausible.Repo
import Plausible.TestUtils
describe "GET /:domain/status" do
2020-05-22 12:33:17 +03:00
setup [:create_user, :log_in]
2019-09-02 14:29:19 +03:00
2020-05-22 12:33:17 +03:00
test "is WAITING when site has no pageviews", %{conn: conn, user: user} do
site = insert(:site, members: [user])
2019-09-02 14:29:19 +03:00
conn = get(conn, "/api/#{site.domain}/status")
assert json_response(conn, 200) == "WAITING"
end
2020-05-22 12:33:17 +03:00
test "is READY when site has at least 1 pageview", %{conn: conn, user: user} do
site = insert(:site, members: [user])
Plausible.TestUtils.create_pageviews([%{domain: site.domain}])
2019-09-02 14:29:19 +03:00
conn = get(conn, "/api/#{site.domain}/status")
assert json_response(conn, 200) == "READY"
end
end
end