|
|
|
|
@ -10,11 +10,14 @@ defmodule Plausible.FunnelsTest do
|
|
|
|
|
{:ok, g1} = Goals.create(site, %{"page_path" => "/go/to/blog/**"})
|
|
|
|
|
{:ok, g2} = Goals.create(site, %{"event_name" => "Signup"})
|
|
|
|
|
{:ok, g3} = Goals.create(site, %{"page_path" => "/checkout"})
|
|
|
|
|
{:ok, g4} = Goals.create(site, %{"event_name" => "Leave feedback"})
|
|
|
|
|
{:ok, g5} = Goals.create(site, %{"page_path" => "/recommend"})
|
|
|
|
|
{:ok, g6} = Goals.create(site, %{"event_name" => "Extra event"})
|
|
|
|
|
|
|
|
|
|
{:ok, %{site: site, goals: [g1, g2, g3]}}
|
|
|
|
|
{:ok, %{site: site, goals: [g1, g2, g3, g4, g5, g6]}}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "create and store a funnel given a set of goals", %{site: site, goals: [g1, g2, g3]} do
|
|
|
|
|
test "create and store a funnel given a set of goals", %{site: site, goals: [g1, g2, g3 | _]} do
|
|
|
|
|
{:ok, funnel} =
|
|
|
|
|
Funnels.create(
|
|
|
|
|
site,
|
|
|
|
|
@ -35,7 +38,10 @@ defmodule Plausible.FunnelsTest do
|
|
|
|
|
assert fg3.step_order == 3
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "retrieve a funnel by id and site, get steps in order", %{site: site, goals: [g1, g2, g3]} do
|
|
|
|
|
test "retrieve a funnel by id and site, get steps in order", %{
|
|
|
|
|
site: site,
|
|
|
|
|
goals: [g1, g2, g3 | _]
|
|
|
|
|
} do
|
|
|
|
|
{:ok, funnel} =
|
|
|
|
|
Funnels.create(
|
|
|
|
|
site,
|
|
|
|
|
@ -48,10 +54,22 @@ defmodule Plausible.FunnelsTest do
|
|
|
|
|
assert [%{step_order: 1}, %{step_order: 2}, %{step_order: 3}] = funnel.steps
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "a funnel can be made of max n(TBD) goals" do
|
|
|
|
|
test "a funnel cannot be made of < 2 goals", %{site: site, goals: [g1 | _]} do
|
|
|
|
|
assert {:error, :invalid_funnel_size} =
|
|
|
|
|
Funnels.create(
|
|
|
|
|
site,
|
|
|
|
|
"Lorem ipsum",
|
|
|
|
|
[g1]
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "a funnel can be deleted" do
|
|
|
|
|
test "a funnel can be made of 5 goals maximum", %{site: site, goals: too_many_goals} do
|
|
|
|
|
assert {:error, :invalid_funnel_size} =
|
|
|
|
|
Funnels.create(
|
|
|
|
|
site,
|
|
|
|
|
"Lorem ipsum",
|
|
|
|
|
too_many_goals
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "a goal can only appear once in a funnel", %{goals: [g1 | _], site: site} do
|
|
|
|
|
@ -63,7 +81,7 @@ defmodule Plausible.FunnelsTest do
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "funnels can be listed per site", %{site: site, goals: [g1, g2, g3]} do
|
|
|
|
|
test "funnels can be listed per site", %{site: site, goals: [g1, g2, g3 | _]} do
|
|
|
|
|
Funnels.create(site, "Funnel 1", [g3, g1, g2])
|
|
|
|
|
Funnels.create(site, "Funnel 2", [g2, g1, g3])
|
|
|
|
|
|
|
|
|
|
@ -71,12 +89,15 @@ defmodule Plausible.FunnelsTest do
|
|
|
|
|
assert [%{name: "Funnel 1"}, %{name: "Funnel 2"}] = funnels_list
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "funnels can be evaluated per site within a time range", %{site: site, goals: goals} do
|
|
|
|
|
test "funnels can be evaluated per site within a time range", %{
|
|
|
|
|
site: site,
|
|
|
|
|
goals: [g1, g2, g3 | _]
|
|
|
|
|
} do
|
|
|
|
|
{:ok, funnel} =
|
|
|
|
|
Funnels.create(
|
|
|
|
|
site,
|
|
|
|
|
"From blog to signup and purchase",
|
|
|
|
|
goals
|
|
|
|
|
[g1, g2, g3]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
populate_stats(site, [
|
|
|
|
|
|