add setup foundations: site gate, registration lockdown, coming soon page

- Settings.site_live?/0 and set_site_live/1 for shop visibility control
- Accounts.has_admin?/0 to detect single-tenant admin existence
- Registration lockdown: /users/register redirects when admin exists
- Setup.setup_status/0 aggregates provider, product, and stripe checks
- Coming soon page at /coming-soon with themed styling
- ThemeHook :require_site_live gate on all public shop routes
  - Site live → everyone through
  - Authenticated → admin preview through
  - No admin → fresh install demo through
  - Otherwise → redirect to coming soon
- Go live / take offline toggle on /admin/settings
- 648 tests, 0 failures

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-11 22:58:58 +00:00
parent 093bdcc7a6
commit e64bf40a71
16 changed files with 471 additions and 74 deletions

View File

@@ -11,6 +11,44 @@ defmodule SimpleshopThemeWeb.AdminLive.SettingsTest do
%{user: user}
end
describe "shop status toggle" do
setup %{conn: conn, user: user} do
conn = log_in_user(conn, user)
%{conn: conn}
end
test "shows offline status by default", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/admin/settings")
assert html =~ "Offline"
assert html =~ "coming soon"
assert html =~ "Go live"
end
test "can go live", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/admin/settings")
html = render_click(view, "toggle_site_live")
assert html =~ "Shop is now live"
assert html =~ "Live"
assert html =~ "Take offline"
assert Settings.site_live?()
end
test "can take offline after going live", %{conn: conn} do
{:ok, _} = Settings.set_site_live(true)
{:ok, view, _html} = live(conn, ~p"/admin/settings")
html = render_click(view, "toggle_site_live")
assert html =~ "Shop taken offline"
assert html =~ "Offline"
assert html =~ "Go live"
refute Settings.site_live?()
end
end
describe "unauthenticated" do
test "redirects to login", %{conn: conn} do
{:error, redirect} = live(conn, ~p"/admin/settings")
@@ -28,7 +66,7 @@ defmodule SimpleshopThemeWeb.AdminLive.SettingsTest do
test "renders setup form when Stripe is not configured", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/admin/settings")
assert html =~ "Credentials"
assert html =~ "Settings"
assert html =~ "Not connected"
assert html =~ "Connect Stripe"
assert html =~ "Stripe dashboard"