extract site_name and site_description from theme settings into standalone settings

site_name and site_description are shop identity, not theme concerns.
They now live in the Settings table as first-class settings with their
own assigns (@site_name, @site_description) piped through hooks and
plugs. The setup wizard writes site_name on account creation, and the
theme editor reads/writes via Settings.put_setting. Removed the
"configure your shop" checklist item since currency/country aren't
built yet. Also adds shop name field to setup wizard step 1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-03-03 14:52:31 +00:00
parent 8ea77e5992
commit 5b41f3fedf
25 changed files with 464 additions and 255 deletions

View File

@@ -20,6 +20,7 @@ defmodule Berrypod.SetupTest do
refute status.can_go_live
refute status.theme_customised
refute status.has_orders
refute status.has_shipping
refute status.checklist_dismissed
end
@@ -89,7 +90,7 @@ defmodule Berrypod.SetupTest do
assert Setup.setup_status().setup_complete
end
test "can_go_live requires provider, products, and stripe" do
test "can_go_live requires provider, products, stripe, and shipping" do
{:ok, conn} =
Products.create_provider_connection(%{
name: "Test",
@@ -105,12 +106,25 @@ defmodule Berrypod.SetupTest do
status: "active"
})
# Still missing stripe
# Still missing stripe and shipping
refute Setup.setup_status().can_go_live
# Add stripe
{:ok, _} = Settings.put_secret("stripe_api_key", "sk_test_abc123")
# Still missing shipping
refute Setup.setup_status().can_go_live
Berrypod.Shipping.upsert_rates(conn.id, [
%{
blueprint_id: 1,
print_provider_id: 1,
country_code: "GB",
first_item_cost: 350,
additional_item_cost: 200,
currency: "GBP"
}
])
assert Setup.setup_status().can_go_live
end
@@ -121,5 +135,64 @@ defmodule Berrypod.SetupTest do
assert Setup.setup_status().theme_customised
end
test "detects shipping rates" do
refute Setup.setup_status().has_shipping
{:ok, conn} =
Products.create_provider_connection(%{
name: "Test",
provider_type: "printify",
api_key: "test_api_key"
})
Berrypod.Shipping.upsert_rates(conn.id, [
%{
blueprint_id: 1,
print_provider_id: 1,
country_code: "GB",
first_item_cost: 350,
additional_item_cost: 200,
currency: "GBP"
}
])
assert Setup.setup_status().has_shipping
end
test "can_go_live requires shipping rates" do
{:ok, conn} =
Products.create_provider_connection(%{
name: "Test",
provider_type: "printify",
api_key: "test_api_key"
})
{:ok, _product} =
Products.create_product(%{
title: "Test product",
provider_product_id: "ext-1",
provider_connection_id: conn.id,
status: "active"
})
{:ok, _} = Settings.put_secret("stripe_api_key", "sk_test_abc123")
# No shipping rates yet
refute Setup.setup_status().can_go_live
Berrypod.Shipping.upsert_rates(conn.id, [
%{
blueprint_id: 1,
print_provider_id: 1,
country_code: "GB",
first_item_cost: 350,
additional_item_cost: 200,
currency: "GBP"
}
])
assert Setup.setup_status().can_go_live
end
end
end

View File

@@ -27,6 +27,8 @@ defmodule BerrypodWeb.Admin.DashboardTest do
{:ok, _view, html} = live(conn, ~p"/admin")
assert html =~ "Launch checklist"
assert html =~ "Connect a print provider"
assert html =~ "Connect Stripe"
assert html =~ "Sync your products"
assert html =~ "Customise your theme"
assert html =~ "Go live"
@@ -39,17 +41,22 @@ defmodule BerrypodWeb.Admin.DashboardTest do
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")
test "collapse and expand checklist", %{conn: conn} do
{:ok, view, html} = live(conn, ~p"/admin")
assert html =~ "Sync your products"
html = render_click(view, "dismiss_checklist")
# Collapse
html = render_click(view, "toggle_checklist")
refute html =~ "Sync your products"
assert html =~ "Launch checklist"
refute html =~ "Launch checklist"
# Expand
html = render_click(view, "toggle_checklist")
assert html =~ "Sync your products"
end
test "go live button works", %{conn: conn} do
# Need provider + products + stripe for go live to be enabled
# Need provider + products + stripe + shipping for go live
{:ok, conn_record} =
Berrypod.Products.create_provider_connection(%{
name: "Test",
@@ -67,6 +74,17 @@ defmodule BerrypodWeb.Admin.DashboardTest do
{:ok, _} = Berrypod.Settings.put_secret("stripe_api_key", "sk_test_123")
Berrypod.Shipping.upsert_rates(conn_record.id, [
%{
blueprint_id: 1,
print_provider_id: 1,
country_code: "GB",
first_item_cost: 350,
additional_item_cost: 200,
currency: "GBP"
}
])
{:ok, view, _html} = live(conn, ~p"/admin")
html = render_click(view, "go_live")
@@ -74,6 +92,19 @@ defmodule BerrypodWeb.Admin.DashboardTest do
assert html =~ "Your shop is live"
assert Berrypod.Settings.site_live?()
end
test "shows test order guidance", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/admin")
assert html =~ "4242 4242 4242 4242"
end
test "shows email setup as optional", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/admin")
assert html =~ "Set up email"
assert html =~ "optional"
end
end
describe "stats" do

View File

@@ -10,7 +10,7 @@ defmodule BerrypodWeb.Setup.OnboardingTest do
test "accessible on fresh install (no admin)", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/setup")
assert html =~ "Set up your shop"
assert html =~ "Create admin account"
assert html =~ "Set up your account"
end
test "redirects to /admin when setup is complete", %{conn: conn} do
@@ -60,7 +60,7 @@ defmodule BerrypodWeb.Setup.OnboardingTest do
test "shows all three cards with email form active", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/setup")
assert html =~ "Create admin account"
assert html =~ "Set up your account"
assert html =~ "Connect a print provider"
assert html =~ "Connect payments"
end
@@ -114,7 +114,7 @@ defmodule BerrypodWeb.Setup.OnboardingTest do
{:ok, _view, html} = live(conn, ~p"/setup")
assert html =~ "Secret key"
assert html =~ "Connect Stripe"
assert html =~ "Connect payments"
end
end

View File

@@ -17,7 +17,7 @@ defmodule BerrypodWeb.Shop.ComingSoonTest do
end
test "displays the shop name", %{conn: conn} do
{:ok, _} = Settings.update_theme_settings(%{site_name: "My Test Shop"})
Settings.put_setting("site_name", "My Test Shop", "string")
{:ok, _view, html} = live(conn, ~p"/coming-soon")

View File

@@ -12,6 +12,7 @@ defmodule BerrypodWeb.PageRendererTest do
%{
__changed__: nil,
theme_settings: %ThemeSettings{},
site_name: "Test Store",
logo_image: nil,
header_image: nil,
mode: :shop,