feat: add admin provider setup UI with improved product sync

- Add /admin/providers LiveView for connecting and managing POD providers
- Implement pagination for Printify API (handles all products, not just first page)
- Add parallel processing (5 concurrent) for faster product sync
- Add slug-based fallback matching when provider_product_id changes
- Add error recovery with try/rescue to prevent stuck sync status
- Add checksum-based change detection to skip unchanged products
- Add upsert tests covering race conditions and slug matching
- Add Printify provider tests
- Document Printify integration research (product identity, order risks,
  open source vs managed hosting implications)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-01-31 22:08:34 +00:00
parent bbd748f123
commit 5b736b99fd
17 changed files with 1352 additions and 38 deletions

View File

@@ -2,6 +2,7 @@ defmodule SimpleshopTheme.Sync.ProductSyncWorkerTest do
use SimpleshopTheme.DataCase, async: false
use Oban.Testing, repo: SimpleshopTheme.Repo
alias SimpleshopTheme.Products
alias SimpleshopTheme.Sync.ProductSyncWorker
import SimpleshopTheme.ProductsFixtures
@@ -20,6 +21,20 @@ defmodule SimpleshopTheme.Sync.ProductSyncWorkerTest do
assert {:cancel, :connection_disabled} =
perform_job(ProductSyncWorker, %{provider_connection_id: conn.id})
end
test "sets status to syncing then updates on completion or failure" do
conn = provider_connection_fixture(%{enabled: true})
# The job will fail because we don't have a real API connection
# but it should still update the status properly
_result = perform_job(ProductSyncWorker, %{provider_connection_id: conn.id})
# Reload the connection
updated_conn = Products.get_provider_connection!(conn.id)
# Status should be either "completed" or "failed", not stuck at "syncing"
assert updated_conn.sync_status in ["completed", "failed"]
end
end
describe "enqueue/1" do