Basic onboading flow (#24)
* removed unused file * [WIP] Created onboarding form * Finished basic onboarding flow; added tests * Improved onboarding language
This commit is contained in:
@@ -22,6 +22,15 @@ defmodule PinchflatWeb.MediaProfileControllerTest do
|
||||
conn = get(conn, ~p"/media_profiles/new")
|
||||
assert html_response(conn, 200) =~ "New Media Profile"
|
||||
end
|
||||
|
||||
test "renders correct layout when onboarding", %{session_conn: session_conn} do
|
||||
session_conn =
|
||||
session_conn
|
||||
|> put_session(:onboarding, true)
|
||||
|> get(~p"/media_profiles/new")
|
||||
|
||||
refute html_response(session_conn, 200) =~ "MENU"
|
||||
end
|
||||
end
|
||||
|
||||
describe "create media_profile" do
|
||||
@@ -39,6 +48,24 @@ defmodule PinchflatWeb.MediaProfileControllerTest do
|
||||
conn = post(conn, ~p"/media_profiles", media_profile: @invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "New Media Profile"
|
||||
end
|
||||
|
||||
test "redirects to onboarding when onboarding", %{session_conn: session_conn} do
|
||||
session_conn =
|
||||
session_conn
|
||||
|> put_session(:onboarding, true)
|
||||
|> post(~p"/media_profiles", media_profile: @create_attrs)
|
||||
|
||||
assert redirected_to(session_conn) == ~p"/?onboarding=1"
|
||||
end
|
||||
|
||||
test "renders correct layout on error when onboarding", %{session_conn: session_conn} do
|
||||
session_conn =
|
||||
session_conn
|
||||
|> put_session(:onboarding, true)
|
||||
|> post(~p"/media_profiles", media_profile: @invalid_attrs)
|
||||
|
||||
refute html_response(session_conn, 200) =~ "MENU"
|
||||
end
|
||||
end
|
||||
|
||||
describe "edit media_profile" do
|
||||
|
||||
@@ -1,8 +1,52 @@
|
||||
defmodule PinchflatWeb.PageControllerTest do
|
||||
use PinchflatWeb.ConnCase
|
||||
|
||||
test "GET /", %{conn: conn} do
|
||||
conn = get(conn, ~p"/")
|
||||
assert html_response(conn, 200) =~ "Peace of mind from prototype to production"
|
||||
import Pinchflat.ProfilesFixtures
|
||||
import Pinchflat.MediaSourceFixtures
|
||||
|
||||
describe "GET / when testing onboarding" do
|
||||
test "sets the onboarding session to true when onboarding", %{conn: conn} do
|
||||
conn = get(conn, ~p"/")
|
||||
assert get_session(conn, :onboarding)
|
||||
end
|
||||
|
||||
test "displays the onboarding page when no media profiles exist", %{conn: conn} do
|
||||
conn = get(conn, ~p"/")
|
||||
assert html_response(conn, 200) =~ "Welcome to Pinchflat"
|
||||
end
|
||||
|
||||
test "displays the onboarding page when no sources exist", %{conn: conn} do
|
||||
_ = media_profile_fixture()
|
||||
|
||||
conn = get(conn, ~p"/")
|
||||
assert html_response(conn, 200) =~ "Welcome to Pinchflat"
|
||||
end
|
||||
|
||||
test "displays the onboarding page when onboarding is forced", %{conn: conn} do
|
||||
_ = media_profile_fixture()
|
||||
_ = source_fixture()
|
||||
|
||||
conn = get(conn, ~p"/?onboarding=1")
|
||||
assert html_response(conn, 200) =~ "Welcome to Pinchflat"
|
||||
end
|
||||
|
||||
test "sets the onboarding session to false when not onboarding", %{conn: conn} do
|
||||
conn = get(conn, ~p"/")
|
||||
assert get_session(conn, :onboarding)
|
||||
|
||||
_ = media_profile_fixture()
|
||||
_ = source_fixture()
|
||||
|
||||
conn = get(conn, ~p"/")
|
||||
refute get_session(conn, :onboarding)
|
||||
end
|
||||
|
||||
test "displays the home page when not onboarding", %{conn: conn} do
|
||||
_ = media_profile_fixture()
|
||||
_ = source_fixture()
|
||||
|
||||
conn = get(conn, ~p"/")
|
||||
assert html_response(conn, 200) =~ "MENU"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,6 +38,15 @@ defmodule PinchflatWeb.SourceControllerTest do
|
||||
conn = get(conn, ~p"/sources/new")
|
||||
assert html_response(conn, 200) =~ "New Source"
|
||||
end
|
||||
|
||||
test "renders correct layout when onboarding", %{session_conn: session_conn} do
|
||||
session_conn =
|
||||
session_conn
|
||||
|> put_session(:onboarding, true)
|
||||
|> get(~p"/sources/new")
|
||||
|
||||
refute html_response(session_conn, 200) =~ "MENU"
|
||||
end
|
||||
end
|
||||
|
||||
describe "create source" do
|
||||
@@ -56,6 +65,26 @@ defmodule PinchflatWeb.SourceControllerTest do
|
||||
conn = post(conn, ~p"/sources", source: invalid_attrs)
|
||||
assert html_response(conn, 200) =~ "New Source"
|
||||
end
|
||||
|
||||
test "redirects to onboarding when onboarding", %{session_conn: session_conn, create_attrs: create_attrs} do
|
||||
expect(YtDlpRunnerMock, :run, 1, &runner_function_mock/3)
|
||||
|
||||
session_conn =
|
||||
session_conn
|
||||
|> put_session(:onboarding, true)
|
||||
|> post(~p"/sources", source: create_attrs)
|
||||
|
||||
assert redirected_to(session_conn) == ~p"/?onboarding=1"
|
||||
end
|
||||
|
||||
test "renders correct layout on error when onboarding", %{session_conn: session_conn, invalid_attrs: invalid_attrs} do
|
||||
session_conn =
|
||||
session_conn
|
||||
|> put_session(:onboarding, true)
|
||||
|> post(~p"/sources", source: invalid_attrs)
|
||||
|
||||
refute html_response(session_conn, 200) =~ "MENU"
|
||||
end
|
||||
end
|
||||
|
||||
describe "edit source" do
|
||||
|
||||
Reference in New Issue
Block a user