make admin provider UI support both Printify and Printful
- Provider form accepts ?type= query param (printify/printful) - Conditional setup instructions per provider (API key steps, login URLs) - Dynamic labels, titles, and config handling (shop_id vs store_id) - Provider index shows dropdown with both provider options - Settings page renamed from @printify to @provider (generic) - Fix Printful shipping rates: add default state codes for US/CA/AU Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -33,13 +33,14 @@ defmodule SimpleshopThemeWeb.Admin.ProvidersTest do
|
||||
test "shows empty state when no connections exist", %{conn: conn} do
|
||||
{:ok, _view, html} = live(conn, ~p"/admin/providers")
|
||||
|
||||
assert html =~ "Connect your Printify account"
|
||||
assert html =~ "Connect a print-on-demand provider"
|
||||
end
|
||||
|
||||
test "shows connect button", %{conn: conn} do
|
||||
test "shows connect buttons for both providers", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/providers")
|
||||
|
||||
assert has_element?(view, ~s(a[href="/admin/providers/new"]))
|
||||
assert has_element?(view, ~s(a[href="/admin/providers/new?type=printify"]))
|
||||
assert has_element?(view, ~s(a[href="/admin/providers/new?type=printful"]))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -138,12 +139,26 @@ defmodule SimpleshopThemeWeb.Admin.ProvidersTest do
|
||||
%{conn: log_in_user(conn, user)}
|
||||
end
|
||||
|
||||
test "renders new form", %{conn: conn} do
|
||||
test "renders new Printify form", %{conn: conn} do
|
||||
{:ok, _view, html} = live(conn, ~p"/admin/providers/new?type=printify")
|
||||
|
||||
assert html =~ "Connect to Printify"
|
||||
assert html =~ "Printify API key"
|
||||
assert html =~ "Log in to Printify"
|
||||
end
|
||||
|
||||
test "renders new Printful form", %{conn: conn} do
|
||||
{:ok, _view, html} = live(conn, ~p"/admin/providers/new?type=printful")
|
||||
|
||||
assert html =~ "Connect to Printful"
|
||||
assert html =~ "Printful API key"
|
||||
assert html =~ "Log in to Printful"
|
||||
end
|
||||
|
||||
test "defaults to Printify when no type param", %{conn: conn} do
|
||||
{:ok, _view, html} = live(conn, ~p"/admin/providers/new")
|
||||
|
||||
assert html =~ "Connect to Printify"
|
||||
assert html =~ "connection key"
|
||||
assert html =~ "Log in to Printify"
|
||||
end
|
||||
|
||||
test "test connection shows error when no api key", %{conn: conn} do
|
||||
@@ -151,7 +166,7 @@ defmodule SimpleshopThemeWeb.Admin.ProvidersTest do
|
||||
|
||||
html = render_click(view, "test_connection")
|
||||
|
||||
assert html =~ "Please enter your connection key"
|
||||
assert html =~ "Please enter your API key"
|
||||
end
|
||||
|
||||
test "saves new connection", %{conn: conn} do
|
||||
|
||||
@@ -151,7 +151,7 @@ defmodule SimpleshopThemeWeb.Admin.SettingsTest do
|
||||
|
||||
assert html =~ "Products"
|
||||
assert html =~ "Not connected"
|
||||
assert has_element?(view, ~s(a[href="/admin/providers/new"]), "Connect to Printify")
|
||||
assert has_element?(view, ~s(a[href="/admin/providers"]), "Connect a provider")
|
||||
end
|
||||
|
||||
test "shows connection info when provider connected", %{conn: conn} do
|
||||
|
||||
Reference in New Issue
Block a user