share provider connection logic between setup wizard and providers form
Extract Products.connect_provider/2 that tests the connection, fetches shop_id, creates the record, and enqueues sync. Both the setup wizard and the providers form now use this shared function instead of duplicating the flow. Also makes the products empty state context-aware (distinguishes "no provider" from "provider connected but no products"). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -136,6 +136,12 @@ defmodule BerrypodWeb.Admin.ProvidersTest do
|
||||
|
||||
describe "form - new" do
|
||||
setup %{conn: conn, user: user} do
|
||||
Application.put_env(:berrypod, :provider_modules, %{
|
||||
"printify" => MockProvider
|
||||
})
|
||||
|
||||
on_exit(fn -> Application.delete_env(:berrypod, :provider_modules) end)
|
||||
|
||||
%{conn: log_in_user(conn, user)}
|
||||
end
|
||||
|
||||
@@ -170,6 +176,10 @@ defmodule BerrypodWeb.Admin.ProvidersTest do
|
||||
end
|
||||
|
||||
test "saves new connection", %{conn: conn} do
|
||||
expect(MockProvider, :test_connection, fn _conn ->
|
||||
{:ok, %{shop_name: "My Printify Shop", shop_id: 12345}}
|
||||
end)
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/providers/new")
|
||||
|
||||
{:ok, _view, html} =
|
||||
|
||||
Reference in New Issue
Block a user