add setup onboarding page, dashboard launch checklist, provider registry

- new /setup page with three-section onboarding (account, provider, payments)
- dashboard launch checklist with progress bar, go-live, dismiss
- provider registry on Provider module (single source of truth for metadata)
- payments registry for Stripe
- setup context made provider-agnostic (provider_connected, theme_customised, etc.)
- admin provider pages now fully registry-driven (no hardcoded provider names)
- auth flow: fresh installs redirect to /setup, signed_in_path respects setup state
- removed old /admin/setup wizard
- 840 tests, 0 failures

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-20 00:34:06 +00:00
parent 989c5cd4df
commit c2caeed64d
33 changed files with 1927 additions and 1053 deletions

View File

@@ -18,14 +18,61 @@ defmodule BerrypodWeb.Admin.DashboardTest do
end
end
describe "redirects to setup when not live" do
describe "launch checklist" do
setup %{conn: conn, user: user} do
%{conn: log_in_user(conn, user)}
end
test "redirects to /admin/setup when site not live", %{conn: conn} do
{:error, redirect} = live(conn, ~p"/admin")
assert {:live_redirect, %{to: "/admin/setup"}} = redirect
test "shows checklist when site not live", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/admin")
assert html =~ "Launch checklist"
assert html =~ "Sync your products"
assert html =~ "Customise your theme"
assert html =~ "Go live"
end
test "hides checklist when site is live", %{conn: conn} do
{:ok, _} = Berrypod.Settings.set_site_live(true)
{:ok, _view, html} = live(conn, ~p"/admin")
refute html =~ "Launch checklist"
end
test "dismiss checklist hides it", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/admin")
assert has_element?(view, "button", "Dismiss")
html = render_click(view, "dismiss_checklist")
refute html =~ "Launch checklist"
end
test "go live button works", %{conn: conn} do
# Need provider + products + stripe for go live to be enabled
{:ok, conn_record} =
Berrypod.Products.create_provider_connection(%{
name: "Test",
provider_type: "printify",
api_key: "test_key"
})
{:ok, _} =
Berrypod.Products.create_product(%{
title: "Test product",
provider_product_id: "ext-1",
provider_connection_id: conn_record.id,
status: "active"
})
{:ok, _} = Berrypod.Settings.put_secret("stripe_api_key", "sk_test_123")
{:ok, view, _html} = live(conn, ~p"/admin")
html = render_click(view, "go_live")
assert html =~ "Your shop is live"
assert Berrypod.Settings.site_live?()
end
end

View File

@@ -30,13 +30,6 @@ defmodule BerrypodWeb.Admin.LayoutTest do
refute has_element?(view, ~s(a.active[href="/admin/settings"]))
end
test "highlights setup on setup page", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/admin/setup")
assert has_element?(view, ~s(a.active[href="/admin/setup"]))
refute has_element?(view, ~s(a.active[href="/admin/orders"]))
end
test "highlights correct link on different pages", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/admin/settings")

View File

@@ -1,88 +0,0 @@
defmodule BerrypodWeb.Admin.SetupTest do
use BerrypodWeb.ConnCase, async: false
import Phoenix.LiveViewTest
import Berrypod.AccountsFixtures
import Berrypod.ProductsFixtures
setup do
user = user_fixture()
%{user: user}
end
describe "unauthenticated" do
test "redirects to login", %{conn: conn} do
{:error, redirect} = live(conn, ~p"/admin/setup")
assert {:redirect, %{to: path}} = redirect
assert path == ~p"/users/log-in"
end
end
describe "setup stepper" do
setup %{conn: conn, user: user} do
%{conn: log_in_user(conn, user)}
end
test "shows stepper with printify form when nothing connected", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/admin/setup")
assert html =~ "Setup steps"
assert html =~ "Connect to Printify"
assert html =~ "Printify API token"
assert html =~ "Connect Stripe"
assert html =~ "Go live"
end
test "shows stripe form when printify is done", %{conn: conn} do
conn_fixture = provider_connection_fixture(%{provider_type: "printify"})
_product = product_fixture(%{provider_connection: conn_fixture})
{:ok, view, _html} = live(conn, ~p"/admin/setup")
# Printify step should be completed
assert has_element?(view, "li:first-child [class*='bg-green-500']")
# Stripe step should be active with form
assert has_element?(view, "label", "Secret key")
end
test "shows go live button when all services connected", %{conn: conn} do
conn_fixture = provider_connection_fixture(%{provider_type: "printify"})
_product = product_fixture(%{provider_connection: conn_fixture})
{:ok, _} = Berrypod.Settings.put_secret("stripe_api_key", "sk_test_123")
{:ok, view, _html} = live(conn, ~p"/admin/setup")
assert has_element?(view, "button", "Go live")
end
test "go live shows celebration", %{conn: conn} do
conn_fixture = provider_connection_fixture(%{provider_type: "printify"})
_product = product_fixture(%{provider_connection: conn_fixture})
{:ok, _} = Berrypod.Settings.put_secret("stripe_api_key", "sk_test_123")
{:ok, view, _html} = live(conn, ~p"/admin/setup")
html = view |> element("button", "Go live") |> render_click()
assert html =~ "Your shop is live!"
assert html =~ "Go to dashboard"
assert html =~ "View your shop"
assert html =~ "Customise theme"
end
test "redirects to /admin when site is live", %{conn: conn} do
{:ok, _} = Berrypod.Settings.set_site_live(true)
{:error, redirect} = live(conn, ~p"/admin/setup")
assert {:live_redirect, %{to: "/admin"}} = redirect
end
test "completed steps show summary and are collapsible", %{conn: conn} do
conn_fixture = provider_connection_fixture(%{provider_type: "printify"})
_product = product_fixture(%{provider_connection: conn_fixture})
{:ok, _view, html} = live(conn, ~p"/admin/setup")
assert html =~ "products synced"
end
end
end