rework setup wizard into phased flow
All checks were successful
deploy / deploy (push) Successful in 3m30s
All checks were successful
deploy / deploy (push) Successful in 3m30s
phase 1 (no admin): show only the email form phase 2 (admin created, not logged in): "check your inbox" gate with "wrong email? start over" link that deletes the unconfirmed user phase 3 (logged in via magic link): show provider + stripe steps removes the confusing redirect to /users/log-in after account creation. users now stay on /setup throughout the entire setup process. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ defmodule BerrypodWeb.Setup.OnboardingTest do
|
||||
import Phoenix.LiveViewTest
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
alias Berrypod.{Products, Settings}
|
||||
alias Berrypod.{Accounts, Products, Settings}
|
||||
|
||||
describe "access rules" do
|
||||
test "accessible on fresh install (no admin)", %{conn: conn} do
|
||||
@@ -30,11 +30,12 @@ defmodule BerrypodWeb.Setup.OnboardingTest do
|
||||
assert {:live_redirect, %{to: "/admin"}} = redirect
|
||||
end
|
||||
|
||||
test "redirects to login when admin exists but not logged in", %{conn: conn} do
|
||||
_user = user_fixture()
|
||||
test "shows check inbox when admin exists but not logged in", %{conn: conn} do
|
||||
_user = unconfirmed_user_fixture()
|
||||
|
||||
{:error, redirect} = live(conn, ~p"/setup")
|
||||
assert {:live_redirect, %{to: "/users/log-in"}} = redirect
|
||||
{:ok, _view, html} = live(conn, ~p"/setup")
|
||||
assert html =~ "Check your inbox"
|
||||
refute html =~ "Connect a print provider"
|
||||
end
|
||||
|
||||
test "redirects to / when site is already live", %{conn: conn} do
|
||||
@@ -56,11 +57,50 @@ defmodule BerrypodWeb.Setup.OnboardingTest do
|
||||
end
|
||||
end
|
||||
|
||||
describe "sections" do
|
||||
test "shows all three sections on fresh install", %{conn: conn} do
|
||||
describe "phase: email form" do
|
||||
test "shows only email form on fresh install", %{conn: conn} do
|
||||
{:ok, _view, html} = live(conn, ~p"/setup")
|
||||
|
||||
assert html =~ "Create admin account"
|
||||
refute html =~ "Connect a print provider"
|
||||
refute html =~ "Connect payments"
|
||||
end
|
||||
end
|
||||
|
||||
describe "phase: check inbox" do
|
||||
test "shows check inbox after creating account", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/setup")
|
||||
|
||||
html =
|
||||
view
|
||||
|> form("form", account: %{email: "admin@example.com"})
|
||||
|> render_submit()
|
||||
|
||||
assert html =~ "Check your inbox"
|
||||
assert html =~ "admin@example.com"
|
||||
refute html =~ "Connect a print provider"
|
||||
end
|
||||
|
||||
test "start over resets to email form", %{conn: conn} do
|
||||
_user = unconfirmed_user_fixture()
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/setup")
|
||||
|
||||
html = render_click(view, "start_over")
|
||||
|
||||
assert html =~ "Create admin account"
|
||||
refute html =~ "Check your inbox"
|
||||
refute Accounts.has_admin?()
|
||||
end
|
||||
end
|
||||
|
||||
describe "phase: configure (logged in)" do
|
||||
setup :register_and_log_in_user
|
||||
|
||||
test "shows provider and stripe steps", %{conn: conn, user: user} do
|
||||
{:ok, _view, html} = live(conn, ~p"/setup")
|
||||
|
||||
assert html =~ user.email
|
||||
assert html =~ "Connect a print provider"
|
||||
assert html =~ "Connect payments"
|
||||
end
|
||||
@@ -85,9 +125,7 @@ defmodule BerrypodWeb.Setup.OnboardingTest do
|
||||
assert html =~ "API token"
|
||||
assert html =~ "Printify"
|
||||
end
|
||||
end
|
||||
|
||||
describe "stripe section" do
|
||||
test "shows stripe form", %{conn: conn} do
|
||||
{:ok, _view, html} = live(conn, ~p"/setup")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user