-

{@theme_settings.site_name}

+

{@site_name}

We're getting things ready. Check back soon.

diff --git a/lib/berrypod_web/live/shop/home.ex b/lib/berrypod_web/live/shop/home.ex index 461e104..067cf81 100644 --- a/lib/berrypod_web/live/shop/home.ex +++ b/lib/berrypod_web/live/shop/home.ex @@ -9,7 +9,7 @@ defmodule BerrypodWeb.Shop.Home do extra = Pages.load_block_data(page.blocks, socket.assigns) base = BerrypodWeb.Endpoint.url() - site_name = socket.assigns.theme_settings.site_name + site_name = socket.assigns.site_name org_ld = Jason.encode!( diff --git a/lib/berrypod_web/plugs/load_theme.ex b/lib/berrypod_web/plugs/load_theme.ex index 81e816d..1e5de67 100644 --- a/lib/berrypod_web/plugs/load_theme.ex +++ b/lib/berrypod_web/plugs/load_theme.ex @@ -34,6 +34,8 @@ defmodule BerrypodWeb.Plugs.LoadTheme do conn |> assign(:theme_settings, theme_settings) + |> assign(:site_name, Settings.site_name()) + |> assign(:site_description, Settings.site_description()) |> assign(:generated_css, generated_css) end end diff --git a/lib/berrypod_web/theme_hook.ex b/lib/berrypod_web/theme_hook.ex index f9f9da4..7002269 100644 --- a/lib/berrypod_web/theme_hook.ex +++ b/lib/berrypod_web/theme_hook.ex @@ -56,6 +56,8 @@ defmodule BerrypodWeb.ThemeHook do socket = socket |> assign(:theme_settings, theme_settings) + |> assign(:site_name, Settings.site_name()) + |> assign(:site_description, Settings.site_description()) |> assign(:generated_css, generated_css) |> assign(:logo_image, Media.get_logo()) |> assign(:header_image, Media.get_header()) diff --git a/test/berrypod/setup_test.exs b/test/berrypod/setup_test.exs index b93b270..e95fa87 100644 --- a/test/berrypod/setup_test.exs +++ b/test/berrypod/setup_test.exs @@ -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 diff --git a/test/berrypod_web/live/admin/dashboard_test.exs b/test/berrypod_web/live/admin/dashboard_test.exs index 5874ece..51094cf 100644 --- a/test/berrypod_web/live/admin/dashboard_test.exs +++ b/test/berrypod_web/live/admin/dashboard_test.exs @@ -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 diff --git a/test/berrypod_web/live/setup/onboarding_test.exs b/test/berrypod_web/live/setup/onboarding_test.exs index 3695eba..b2094ca 100644 --- a/test/berrypod_web/live/setup/onboarding_test.exs +++ b/test/berrypod_web/live/setup/onboarding_test.exs @@ -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 diff --git a/test/berrypod_web/live/shop/coming_soon_test.exs b/test/berrypod_web/live/shop/coming_soon_test.exs index 9e7a131..e013543 100644 --- a/test/berrypod_web/live/shop/coming_soon_test.exs +++ b/test/berrypod_web/live/shop/coming_soon_test.exs @@ -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") diff --git a/test/berrypod_web/page_renderer_test.exs b/test/berrypod_web/page_renderer_test.exs index 3e0a9f4..9e84109 100644 --- a/test/berrypod_web/page_renderer_test.exs +++ b/test/berrypod_web/page_renderer_test.exs @@ -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,