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>
2026-02-20 00:34:06 +00:00
|
|
|
defmodule BerrypodWeb.Setup.OnboardingTest do
|
|
|
|
|
use BerrypodWeb.ConnCase, async: false
|
|
|
|
|
|
|
|
|
|
import Phoenix.LiveViewTest
|
|
|
|
|
import Berrypod.AccountsFixtures
|
|
|
|
|
|
2026-02-21 10:24:26 +00:00
|
|
|
alias Berrypod.{Products, Settings}
|
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>
2026-02-20 00:34:06 +00:00
|
|
|
|
|
|
|
|
describe "access rules" do
|
|
|
|
|
test "accessible on fresh install (no admin)", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/setup")
|
|
|
|
|
assert html =~ "Set up your shop"
|
2026-03-03 14:52:31 +00:00
|
|
|
assert html =~ "Set up your account"
|
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>
2026-02-20 00:34:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "redirects to /admin when setup is complete", %{conn: conn} do
|
|
|
|
|
user = user_fixture()
|
|
|
|
|
conn = log_in_user(conn, user)
|
|
|
|
|
|
|
|
|
|
{:ok, _} =
|
|
|
|
|
Products.create_provider_connection(%{
|
|
|
|
|
name: "Test",
|
|
|
|
|
provider_type: "printify",
|
|
|
|
|
api_key: "test_key"
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
{:ok, _} = Settings.put_secret("stripe_api_key", "sk_test_123")
|
|
|
|
|
|
|
|
|
|
{:error, redirect} = live(conn, ~p"/setup")
|
|
|
|
|
assert {:live_redirect, %{to: "/admin"}} = redirect
|
|
|
|
|
end
|
|
|
|
|
|
2026-02-21 10:24:26 +00:00
|
|
|
test "redirects to login when admin exists but not logged in", %{conn: conn} do
|
|
|
|
|
_user = user_fixture()
|
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>
2026-02-20 00:34:06 +00:00
|
|
|
|
2026-02-21 10:24:26 +00:00
|
|
|
{:error, redirect} = live(conn, ~p"/setup")
|
|
|
|
|
assert {:live_redirect, %{to: "/users/log-in"}} = redirect
|
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>
2026-02-20 00:34:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "redirects to / when site is already live", %{conn: conn} do
|
|
|
|
|
user = user_fixture()
|
|
|
|
|
conn = log_in_user(conn, user)
|
|
|
|
|
|
|
|
|
|
{:ok, _} =
|
|
|
|
|
Products.create_provider_connection(%{
|
|
|
|
|
name: "Test",
|
|
|
|
|
provider_type: "printify",
|
|
|
|
|
api_key: "test_key"
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
{:ok, _} = Settings.put_secret("stripe_api_key", "sk_test_123")
|
|
|
|
|
{:ok, _} = Settings.set_site_live(true)
|
|
|
|
|
|
|
|
|
|
{:error, redirect} = live(conn, ~p"/setup")
|
|
|
|
|
assert {:live_redirect, %{to: "/"}} = redirect
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2026-02-21 10:24:26 +00:00
|
|
|
describe "fresh install (no admin)" do
|
|
|
|
|
test "shows all three cards with email form active", %{conn: conn} do
|
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>
2026-02-20 00:34:06 +00:00
|
|
|
{:ok, _view, html} = live(conn, ~p"/setup")
|
|
|
|
|
|
2026-03-03 14:52:31 +00:00
|
|
|
assert html =~ "Set up your account"
|
2026-02-21 10:24:26 +00:00
|
|
|
assert html =~ "Connect a print provider"
|
|
|
|
|
assert html =~ "Connect payments"
|
2026-02-20 21:07:07 +00:00
|
|
|
end
|
|
|
|
|
|
2026-02-21 10:24:26 +00:00
|
|
|
test "creating account auto-confirms and redirects to login", %{conn: conn} do
|
2026-02-20 21:07:07 +00:00
|
|
|
{:ok, view, _html} = live(conn, ~p"/setup")
|
|
|
|
|
|
2026-02-21 10:24:26 +00:00
|
|
|
view
|
2026-03-03 17:41:08 +00:00
|
|
|
|> form(~s(form[phx-submit="create_account"]),
|
|
|
|
|
account: %{
|
|
|
|
|
shop_name: "Test Shop",
|
|
|
|
|
email: "admin@example.com",
|
|
|
|
|
password: "valid_password_123"
|
|
|
|
|
}
|
|
|
|
|
)
|
2026-02-21 10:24:26 +00:00
|
|
|
|> render_submit()
|
2026-02-20 21:07:07 +00:00
|
|
|
|
2026-02-21 10:24:26 +00:00
|
|
|
# The LiveView redirects to /setup/login/:token
|
|
|
|
|
{path, _flash} = assert_redirect(view)
|
|
|
|
|
assert path =~ ~r"/setup/login/.+"
|
2026-02-20 21:07:07 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2026-02-21 10:24:26 +00:00
|
|
|
describe "configure (logged in)" do
|
2026-02-20 21:07:07 +00:00
|
|
|
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
|
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>
2026-02-20 00:34:06 +00:00
|
|
|
assert html =~ "Connect a print provider"
|
|
|
|
|
assert html =~ "Connect payments"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "shows provider cards", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/setup")
|
|
|
|
|
|
|
|
|
|
assert html =~ "Printify"
|
|
|
|
|
assert html =~ "Printful"
|
|
|
|
|
assert html =~ "Gelato"
|
|
|
|
|
assert html =~ "Coming soon"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "selecting a provider shows the API key form", %{conn: conn} do
|
|
|
|
|
{:ok, view, _html} = live(conn, ~p"/setup")
|
|
|
|
|
|
|
|
|
|
html =
|
|
|
|
|
view
|
2026-02-21 19:29:34 +00:00
|
|
|
|> form(~s(form[phx-change="select_provider"]), %{provider_select: %{type: "printify"}})
|
|
|
|
|
|> render_change()
|
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>
2026-02-20 00:34:06 +00:00
|
|
|
|
|
|
|
|
assert html =~ "API token"
|
|
|
|
|
assert html =~ "Printify"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "shows stripe form", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/setup")
|
|
|
|
|
|
|
|
|
|
assert html =~ "Secret key"
|
2026-03-03 14:52:31 +00:00
|
|
|
assert html =~ "Connect payments"
|
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>
2026-02-20 00:34:06 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "completion" do
|
|
|
|
|
setup :register_and_log_in_user
|
|
|
|
|
|
|
|
|
|
test "redirects to dashboard when all three steps done", %{conn: conn} do
|
|
|
|
|
{:ok, _} =
|
|
|
|
|
Products.create_provider_connection(%{
|
|
|
|
|
name: "Test",
|
|
|
|
|
provider_type: "printify",
|
|
|
|
|
api_key: "test_key"
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
{:ok, _} = Settings.put_secret("stripe_api_key", "sk_test_123")
|
|
|
|
|
|
|
|
|
|
{:error, redirect} = live(conn, ~p"/setup")
|
|
|
|
|
assert {:live_redirect, %{to: "/admin"}} = redirect
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|