rename project from SimpleshopTheme to Berrypod
All modules, configs, paths, and references updated. 836 tests pass, zero warnings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
defmodule SimpleshopTheme.AccountsTest do
|
||||
use SimpleshopTheme.DataCase
|
||||
defmodule Berrypod.AccountsTest do
|
||||
use Berrypod.DataCase
|
||||
|
||||
alias SimpleshopTheme.Accounts
|
||||
alias Berrypod.Accounts
|
||||
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
alias SimpleshopTheme.Accounts.{User, UserToken}
|
||||
import Berrypod.AccountsFixtures
|
||||
alias Berrypod.Accounts.{User, UserToken}
|
||||
|
||||
describe "has_admin?/0" do
|
||||
test "returns false when no users exist" do
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule SimpleshopTheme.CartTest do
|
||||
defmodule Berrypod.CartTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias SimpleshopTheme.Cart
|
||||
alias Berrypod.Cart
|
||||
|
||||
describe "add_item/3" do
|
||||
test "adds a new item to an empty cart" do
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule SimpleshopTheme.Clients.PrintfulTest do
|
||||
defmodule Berrypod.Clients.PrintfulTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias SimpleshopTheme.Clients.Printful
|
||||
alias Berrypod.Clients.Printful
|
||||
|
||||
describe "api_token/0" do
|
||||
test "reads from process dictionary when set" do
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule SimpleshopTheme.Images.OptimizeWorkerTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
use Oban.Testing, repo: SimpleshopTheme.Repo
|
||||
defmodule Berrypod.Images.OptimizeWorkerTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
use Oban.Testing, repo: Berrypod.Repo
|
||||
|
||||
alias SimpleshopTheme.Images.OptimizeWorker
|
||||
import SimpleshopTheme.ImageFixtures
|
||||
alias Berrypod.Images.OptimizeWorker
|
||||
import Berrypod.ImageFixtures
|
||||
|
||||
setup do
|
||||
cleanup_cache()
|
||||
@@ -1,8 +1,8 @@
|
||||
defmodule SimpleshopTheme.Images.OptimizerTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.Images.OptimizerTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
alias SimpleshopTheme.Images.Optimizer
|
||||
import SimpleshopTheme.ImageFixtures
|
||||
alias Berrypod.Images.Optimizer
|
||||
import Berrypod.ImageFixtures
|
||||
|
||||
setup do
|
||||
cleanup_cache()
|
||||
@@ -78,8 +78,8 @@ defmodule SimpleshopTheme.Images.OptimizerTest do
|
||||
{:ok, webp, _w, _h} = Optimizer.to_optimized_webp(sample_jpeg())
|
||||
|
||||
image =
|
||||
%SimpleshopTheme.Media.Image{}
|
||||
|> SimpleshopTheme.Media.Image.changeset(%{
|
||||
%Berrypod.Media.Image{}
|
||||
|> Berrypod.Media.Image.changeset(%{
|
||||
image_type: "product",
|
||||
filename: "small.jpg",
|
||||
content_type: "image/webp",
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule SimpleshopTheme.Media.SVGRecolorerTest do
|
||||
defmodule Berrypod.Media.SVGRecolorerTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias SimpleshopTheme.Media.SVGRecolorer
|
||||
alias Berrypod.Media.SVGRecolorer
|
||||
|
||||
describe "recolor/2" do
|
||||
test "replaces fill attributes" do
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule SimpleshopTheme.MediaTest do
|
||||
use SimpleshopTheme.DataCase, async: true
|
||||
defmodule Berrypod.MediaTest do
|
||||
use Berrypod.DataCase, async: true
|
||||
|
||||
alias SimpleshopTheme.Media
|
||||
alias Berrypod.Media
|
||||
|
||||
@valid_attrs %{
|
||||
image_type: "logo",
|
||||
@@ -1,21 +1,21 @@
|
||||
defmodule SimpleshopTheme.Orders.FulfilmentStatusWorkerTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.Orders.FulfilmentStatusWorkerTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
import Mox
|
||||
import SimpleshopTheme.OrdersFixtures
|
||||
import Berrypod.OrdersFixtures
|
||||
|
||||
alias SimpleshopTheme.Orders
|
||||
alias SimpleshopTheme.Orders.FulfilmentStatusWorker
|
||||
alias SimpleshopTheme.Providers.MockProvider
|
||||
alias Berrypod.Orders
|
||||
alias Berrypod.Orders.FulfilmentStatusWorker
|
||||
alias Berrypod.Providers.MockProvider
|
||||
|
||||
setup :verify_on_exit!
|
||||
|
||||
setup do
|
||||
Application.put_env(:simpleshop_theme, :provider_modules, %{
|
||||
Application.put_env(:berrypod, :provider_modules, %{
|
||||
"printify" => MockProvider
|
||||
})
|
||||
|
||||
on_exit(fn -> Application.delete_env(:simpleshop_theme, :provider_modules) end)
|
||||
on_exit(fn -> Application.delete_env(:berrypod, :provider_modules) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
defmodule SimpleshopTheme.Orders.OrderNotifierTest do
|
||||
use SimpleshopTheme.DataCase, async: true
|
||||
defmodule Berrypod.Orders.OrderNotifierTest do
|
||||
use Berrypod.DataCase, async: true
|
||||
|
||||
import Swoosh.TestAssertions
|
||||
import SimpleshopTheme.OrdersFixtures
|
||||
import Berrypod.OrdersFixtures
|
||||
|
||||
alias SimpleshopTheme.Orders
|
||||
alias SimpleshopTheme.Orders.OrderNotifier
|
||||
alias Berrypod.Orders
|
||||
alias Berrypod.Orders.OrderNotifier
|
||||
|
||||
describe "deliver_order_confirmation/1" do
|
||||
test "sends confirmation with order details" do
|
||||
@@ -1,21 +1,21 @@
|
||||
defmodule SimpleshopTheme.Orders.OrderSubmissionWorkerTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.Orders.OrderSubmissionWorkerTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
import Mox
|
||||
import SimpleshopTheme.OrdersFixtures
|
||||
import Berrypod.OrdersFixtures
|
||||
|
||||
alias SimpleshopTheme.Orders
|
||||
alias SimpleshopTheme.Orders.OrderSubmissionWorker
|
||||
alias SimpleshopTheme.Providers.MockProvider
|
||||
alias Berrypod.Orders
|
||||
alias Berrypod.Orders.OrderSubmissionWorker
|
||||
alias Berrypod.Providers.MockProvider
|
||||
|
||||
setup :verify_on_exit!
|
||||
|
||||
setup do
|
||||
Application.put_env(:simpleshop_theme, :provider_modules, %{
|
||||
Application.put_env(:berrypod, :provider_modules, %{
|
||||
"printify" => MockProvider
|
||||
})
|
||||
|
||||
on_exit(fn -> Application.delete_env(:simpleshop_theme, :provider_modules) end)
|
||||
on_exit(fn -> Application.delete_env(:berrypod, :provider_modules) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
defmodule SimpleshopTheme.OrdersTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.OrdersTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
import Mox
|
||||
import SimpleshopTheme.OrdersFixtures
|
||||
import Berrypod.OrdersFixtures
|
||||
|
||||
alias SimpleshopTheme.Orders
|
||||
alias SimpleshopTheme.Providers.MockProvider
|
||||
alias Berrypod.Orders
|
||||
alias Berrypod.Providers.MockProvider
|
||||
|
||||
setup :verify_on_exit!
|
||||
|
||||
@@ -69,11 +69,11 @@ defmodule SimpleshopTheme.OrdersTest do
|
||||
|
||||
describe "submit_to_provider/1" do
|
||||
setup do
|
||||
Application.put_env(:simpleshop_theme, :provider_modules, %{
|
||||
Application.put_env(:berrypod, :provider_modules, %{
|
||||
"printify" => MockProvider
|
||||
})
|
||||
|
||||
on_exit(fn -> Application.delete_env(:simpleshop_theme, :provider_modules) end)
|
||||
on_exit(fn -> Application.delete_env(:berrypod, :provider_modules) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
@@ -118,11 +118,11 @@ defmodule SimpleshopTheme.OrdersTest do
|
||||
|
||||
describe "refresh_fulfilment_status/1" do
|
||||
setup do
|
||||
Application.put_env(:simpleshop_theme, :provider_modules, %{
|
||||
Application.put_env(:berrypod, :provider_modules, %{
|
||||
"printify" => MockProvider
|
||||
})
|
||||
|
||||
on_exit(fn -> Application.delete_env(:simpleshop_theme, :provider_modules) end)
|
||||
on_exit(fn -> Application.delete_env(:berrypod, :provider_modules) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule SimpleshopTheme.Products.ProductImageTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.Products.ProductImageTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
alias SimpleshopTheme.Products.ProductImage
|
||||
alias Berrypod.Products.ProductImage
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
describe "changeset/2" do
|
||||
setup do
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule SimpleshopTheme.Products.ProductTest do
|
||||
use SimpleshopTheme.DataCase, async: true
|
||||
defmodule Berrypod.Products.ProductTest do
|
||||
use Berrypod.DataCase, async: true
|
||||
|
||||
alias SimpleshopTheme.Products.Product
|
||||
alias Berrypod.Products.Product
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
describe "changeset/2" do
|
||||
setup do
|
||||
@@ -212,7 +212,7 @@ defmodule SimpleshopTheme.Products.ProductTest do
|
||||
conn = provider_connection_fixture(%{provider_type: "gelato"})
|
||||
|
||||
assert {:error, changeset} =
|
||||
SimpleshopTheme.Products.create_product(
|
||||
Berrypod.Products.create_product(
|
||||
valid_product_attrs(%{
|
||||
provider_connection_id: conn.id,
|
||||
slug: "unique-product"
|
||||
@@ -227,7 +227,7 @@ defmodule SimpleshopTheme.Products.ProductTest do
|
||||
_product1 = product_fixture(%{provider_connection: conn, provider_product_id: "ext_123"})
|
||||
|
||||
assert {:error, changeset} =
|
||||
SimpleshopTheme.Products.create_product(
|
||||
Berrypod.Products.create_product(
|
||||
valid_product_attrs(%{
|
||||
provider_connection_id: conn.id,
|
||||
provider_product_id: "ext_123"
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule SimpleshopTheme.Products.ProductVariantTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.Products.ProductVariantTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
alias SimpleshopTheme.Products.ProductVariant
|
||||
alias Berrypod.Products.ProductVariant
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
describe "changeset/2" do
|
||||
setup do
|
||||
@@ -188,7 +188,7 @@ defmodule SimpleshopTheme.Products.ProductVariantTest do
|
||||
_variant1 = product_variant_fixture(%{product: product, provider_variant_id: "var_123"})
|
||||
|
||||
assert {:error, changeset} =
|
||||
SimpleshopTheme.Products.create_product_variant(
|
||||
Berrypod.Products.create_product_variant(
|
||||
valid_product_variant_attrs(%{
|
||||
product_id: product.id,
|
||||
provider_variant_id: "var_123"
|
||||
@@ -1,10 +1,10 @@
|
||||
defmodule SimpleshopTheme.Products.ProviderConnectionTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.Products.ProviderConnectionTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
alias SimpleshopTheme.Products.ProviderConnection
|
||||
alias SimpleshopTheme.Vault
|
||||
alias Berrypod.Products.ProviderConnection
|
||||
alias Berrypod.Vault
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
describe "changeset/2" do
|
||||
test "valid attributes create a valid changeset" do
|
||||
@@ -159,7 +159,7 @@ defmodule SimpleshopTheme.Products.ProviderConnectionTest do
|
||||
_first = provider_connection_fixture(%{provider_type: "printify"})
|
||||
|
||||
assert {:error, changeset} =
|
||||
SimpleshopTheme.Products.create_provider_connection(
|
||||
Berrypod.Products.create_provider_connection(
|
||||
valid_provider_connection_attrs(%{provider_type: "printify"})
|
||||
)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
defmodule SimpleshopTheme.ProductsTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.ProductsTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
alias SimpleshopTheme.Products
|
||||
alias SimpleshopTheme.Products.{ProviderConnection, Product, ProductImage, ProductVariant}
|
||||
alias Berrypod.Products
|
||||
alias Berrypod.Products.{ProviderConnection, Product, ProductImage, ProductVariant}
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
# =============================================================================
|
||||
# Provider Connections
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule SimpleshopTheme.ProductsUpsertTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.ProductsUpsertTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
alias SimpleshopTheme.Products
|
||||
alias Berrypod.Products
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
describe "upsert_product/2" do
|
||||
test "creates a new product when it doesn't exist" do
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule SimpleshopTheme.Providers.PrintfulTest do
|
||||
use SimpleshopTheme.DataCase, async: true
|
||||
defmodule Berrypod.Providers.PrintfulTest do
|
||||
use Berrypod.DataCase, async: true
|
||||
|
||||
alias SimpleshopTheme.Providers.Printful
|
||||
alias Berrypod.Providers.Printful
|
||||
|
||||
describe "provider_type/0" do
|
||||
test "returns printful" do
|
||||
@@ -11,7 +11,7 @@ defmodule SimpleshopTheme.Providers.PrintfulTest do
|
||||
|
||||
describe "test_connection/1" do
|
||||
test "returns error when no API key" do
|
||||
conn = %SimpleshopTheme.Products.ProviderConnection{
|
||||
conn = %Berrypod.Products.ProviderConnection{
|
||||
provider_type: "printful",
|
||||
api_key_encrypted: nil
|
||||
}
|
||||
@@ -22,7 +22,7 @@ defmodule SimpleshopTheme.Providers.PrintfulTest do
|
||||
|
||||
describe "fetch_products/1" do
|
||||
test "returns error when no store_id in config" do
|
||||
conn = %SimpleshopTheme.Products.ProviderConnection{
|
||||
conn = %Berrypod.Products.ProviderConnection{
|
||||
provider_type: "printful",
|
||||
api_key_encrypted: nil,
|
||||
config: %{}
|
||||
@@ -32,7 +32,7 @@ defmodule SimpleshopTheme.Providers.PrintfulTest do
|
||||
end
|
||||
|
||||
test "returns error when no API key" do
|
||||
conn = %SimpleshopTheme.Products.ProviderConnection{
|
||||
conn = %Berrypod.Products.ProviderConnection{
|
||||
provider_type: "printful",
|
||||
api_key_encrypted: nil,
|
||||
config: %{"store_id" => "12345"}
|
||||
@@ -44,7 +44,7 @@ defmodule SimpleshopTheme.Providers.PrintfulTest do
|
||||
|
||||
describe "submit_order/2" do
|
||||
test "returns error when no store_id in config" do
|
||||
conn = %SimpleshopTheme.Products.ProviderConnection{
|
||||
conn = %Berrypod.Products.ProviderConnection{
|
||||
provider_type: "printful",
|
||||
api_key_encrypted: nil,
|
||||
config: %{}
|
||||
@@ -54,7 +54,7 @@ defmodule SimpleshopTheme.Providers.PrintfulTest do
|
||||
end
|
||||
|
||||
test "returns error when no API key" do
|
||||
conn = %SimpleshopTheme.Products.ProviderConnection{
|
||||
conn = %Berrypod.Products.ProviderConnection{
|
||||
provider_type: "printful",
|
||||
api_key_encrypted: nil,
|
||||
config: %{"store_id" => "12345"}
|
||||
@@ -66,7 +66,7 @@ defmodule SimpleshopTheme.Providers.PrintfulTest do
|
||||
|
||||
describe "get_order_status/2" do
|
||||
test "returns error when no store_id in config" do
|
||||
conn = %SimpleshopTheme.Products.ProviderConnection{
|
||||
conn = %Berrypod.Products.ProviderConnection{
|
||||
provider_type: "printful",
|
||||
api_key_encrypted: nil,
|
||||
config: %{}
|
||||
@@ -76,7 +76,7 @@ defmodule SimpleshopTheme.Providers.PrintfulTest do
|
||||
end
|
||||
|
||||
test "returns error when no API key" do
|
||||
conn = %SimpleshopTheme.Products.ProviderConnection{
|
||||
conn = %Berrypod.Products.ProviderConnection{
|
||||
provider_type: "printful",
|
||||
api_key_encrypted: nil,
|
||||
config: %{"store_id" => "12345"}
|
||||
@@ -88,7 +88,7 @@ defmodule SimpleshopTheme.Providers.PrintfulTest do
|
||||
|
||||
describe "fetch_shipping_rates/2" do
|
||||
test "returns error when no API key" do
|
||||
conn = %SimpleshopTheme.Products.ProviderConnection{
|
||||
conn = %Berrypod.Products.ProviderConnection{
|
||||
provider_type: "printful",
|
||||
api_key_encrypted: nil,
|
||||
config: %{"store_id" => "12345"}
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule SimpleshopTheme.Providers.PrintifyTest do
|
||||
use SimpleshopTheme.DataCase, async: true
|
||||
defmodule Berrypod.Providers.PrintifyTest do
|
||||
use Berrypod.DataCase, async: true
|
||||
|
||||
alias SimpleshopTheme.Providers.Printify
|
||||
alias Berrypod.Providers.Printify
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
describe "provider_type/0" do
|
||||
test "returns printify" do
|
||||
@@ -13,7 +13,7 @@ defmodule SimpleshopTheme.Providers.PrintifyTest do
|
||||
|
||||
describe "test_connection/1" do
|
||||
test "returns error when no API key" do
|
||||
conn = %SimpleshopTheme.Products.ProviderConnection{
|
||||
conn = %Berrypod.Products.ProviderConnection{
|
||||
provider_type: "printify",
|
||||
api_key_encrypted: nil
|
||||
}
|
||||
@@ -24,7 +24,7 @@ defmodule SimpleshopTheme.Providers.PrintifyTest do
|
||||
|
||||
describe "fetch_products/1" do
|
||||
test "returns error when no shop_id in config" do
|
||||
conn = %SimpleshopTheme.Products.ProviderConnection{
|
||||
conn = %Berrypod.Products.ProviderConnection{
|
||||
provider_type: "printify",
|
||||
api_key_encrypted: nil,
|
||||
config: %{}
|
||||
@@ -34,7 +34,7 @@ defmodule SimpleshopTheme.Providers.PrintifyTest do
|
||||
end
|
||||
|
||||
test "returns error when no API key" do
|
||||
conn = %SimpleshopTheme.Products.ProviderConnection{
|
||||
conn = %Berrypod.Products.ProviderConnection{
|
||||
provider_type: "printify",
|
||||
api_key_encrypted: nil,
|
||||
config: %{"shop_id" => "12345"}
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule SimpleshopTheme.SearchTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.SearchTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
alias SimpleshopTheme.Search
|
||||
alias Berrypod.Search
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
setup do
|
||||
conn = provider_connection_fixture()
|
||||
@@ -170,19 +170,19 @@ defmodule SimpleshopTheme.SearchTest do
|
||||
describe "index_product/1" do
|
||||
test "indexes a single product", %{ocean: ocean} do
|
||||
# Clear FTS index
|
||||
SimpleshopTheme.Repo.query!("DELETE FROM products_search_map")
|
||||
SimpleshopTheme.Repo.query!("DELETE FROM products_search")
|
||||
Berrypod.Repo.query!("DELETE FROM products_search_map")
|
||||
Berrypod.Repo.query!("DELETE FROM products_search")
|
||||
|
||||
# Verify FTS index is empty
|
||||
%{rows: rows} = SimpleshopTheme.Repo.query!("SELECT COUNT(*) FROM products_search_map")
|
||||
%{rows: rows} = Berrypod.Repo.query!("SELECT COUNT(*) FROM products_search_map")
|
||||
assert rows == [[0]]
|
||||
|
||||
# Index just ocean
|
||||
ocean = SimpleshopTheme.Repo.preload(ocean, [:variants])
|
||||
ocean = Berrypod.Repo.preload(ocean, [:variants])
|
||||
Search.index_product(ocean)
|
||||
|
||||
# Verify ocean is now in the FTS index
|
||||
%{rows: [[count]]} = SimpleshopTheme.Repo.query!("SELECT COUNT(*) FROM products_search_map")
|
||||
%{rows: [[count]]} = Berrypod.Repo.query!("SELECT COUNT(*) FROM products_search_map")
|
||||
assert count == 1
|
||||
|
||||
results = Search.search("ocean")
|
||||
@@ -195,7 +195,7 @@ defmodule SimpleshopTheme.SearchTest do
|
||||
mountain =
|
||||
mountain
|
||||
|> Ecto.Changeset.change(title: "Alpine Sunrise Art Print")
|
||||
|> SimpleshopTheme.Repo.update!()
|
||||
|> Berrypod.Repo.update!()
|
||||
|
||||
Search.index_product(mountain)
|
||||
|
||||
@@ -221,7 +221,7 @@ defmodule SimpleshopTheme.SearchTest do
|
||||
test "removes a product from the index", %{ocean: ocean} do
|
||||
# Verify ocean is in the FTS index
|
||||
%{rows: [[rowid]]} =
|
||||
SimpleshopTheme.Repo.query!(
|
||||
Berrypod.Repo.query!(
|
||||
"SELECT rowid FROM products_search_map WHERE product_id = ?1",
|
||||
[ocean.id]
|
||||
)
|
||||
@@ -232,7 +232,7 @@ defmodule SimpleshopTheme.SearchTest do
|
||||
|
||||
# Verify it's gone from the FTS index
|
||||
%{rows: rows} =
|
||||
SimpleshopTheme.Repo.query!(
|
||||
Berrypod.Repo.query!(
|
||||
"SELECT rowid FROM products_search_map WHERE product_id = ?1",
|
||||
[ocean.id]
|
||||
)
|
||||
@@ -1,8 +1,8 @@
|
||||
defmodule SimpleshopTheme.SettingsTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.SettingsTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
alias SimpleshopTheme.Settings
|
||||
alias SimpleshopTheme.Settings.ThemeSettings
|
||||
alias Berrypod.Settings
|
||||
alias Berrypod.Settings.ThemeSettings
|
||||
|
||||
describe "get_setting/2 and put_setting/3" do
|
||||
test "stores and retrieves string settings" do
|
||||
@@ -64,7 +64,7 @@ defmodule SimpleshopTheme.SettingsTest do
|
||||
end
|
||||
|
||||
test "regenerates CSS cache when settings change" do
|
||||
alias SimpleshopTheme.Theme.CSSCache
|
||||
alias Berrypod.Theme.CSSCache
|
||||
|
||||
# Get initial cached CSS
|
||||
{:ok, initial_css} = CSSCache.get()
|
||||
@@ -154,7 +154,7 @@ defmodule SimpleshopTheme.SettingsTest do
|
||||
test "stores encrypted_value as binary, not plaintext" do
|
||||
{:ok, _} = Settings.put_secret("test_key", "plaintext_here")
|
||||
|
||||
setting = Repo.get_by(SimpleshopTheme.Settings.Setting, key: "test_key")
|
||||
setting = Repo.get_by(Berrypod.Settings.Setting, key: "test_key")
|
||||
assert setting.value_type == "encrypted"
|
||||
assert setting.value == "[encrypted]"
|
||||
assert is_binary(setting.encrypted_value)
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule SimpleshopTheme.SetupTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.SetupTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
alias SimpleshopTheme.{Setup, Settings, Products}
|
||||
alias Berrypod.{Setup, Settings, Products}
|
||||
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
describe "setup_status/0" do
|
||||
test "returns all false on fresh install" do
|
||||
@@ -1,10 +1,10 @@
|
||||
defmodule SimpleshopTheme.ShippingTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.ShippingTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
alias SimpleshopTheme.Shipping
|
||||
alias SimpleshopTheme.Shipping.ShippingRate
|
||||
alias Berrypod.Shipping
|
||||
alias Berrypod.Shipping.ShippingRate
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
describe "upsert_rates/2" do
|
||||
test "inserts new rates" do
|
||||
@@ -1,8 +1,8 @@
|
||||
defmodule SimpleshopTheme.Stripe.SetupTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.Stripe.SetupTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
alias SimpleshopTheme.Settings
|
||||
alias SimpleshopTheme.Stripe.Setup
|
||||
alias Berrypod.Settings
|
||||
alias Berrypod.Stripe.Setup
|
||||
|
||||
describe "localhost?/0" do
|
||||
test "returns true for localhost endpoint" do
|
||||
@@ -1,11 +1,11 @@
|
||||
defmodule SimpleshopTheme.Sync.ProductSyncWorkerTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
use Oban.Testing, repo: SimpleshopTheme.Repo
|
||||
defmodule Berrypod.Sync.ProductSyncWorkerTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
use Oban.Testing, repo: Berrypod.Repo
|
||||
|
||||
alias SimpleshopTheme.Products
|
||||
alias SimpleshopTheme.Sync.ProductSyncWorker
|
||||
alias Berrypod.Products
|
||||
alias Berrypod.Sync.ProductSyncWorker
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
describe "perform/1" do
|
||||
test "cancels for missing connection" do
|
||||
@@ -1,11 +1,11 @@
|
||||
defmodule SimpleshopTheme.Sync.ScheduledSyncWorkerTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
use Oban.Testing, repo: SimpleshopTheme.Repo
|
||||
defmodule Berrypod.Sync.ScheduledSyncWorkerTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
use Oban.Testing, repo: Berrypod.Repo
|
||||
|
||||
alias SimpleshopTheme.Sync.ScheduledSyncWorker
|
||||
alias SimpleshopTheme.Sync.ProductSyncWorker
|
||||
alias Berrypod.Sync.ScheduledSyncWorker
|
||||
alias Berrypod.Sync.ProductSyncWorker
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
describe "perform/1" do
|
||||
test "enqueues sync for enabled connections" do
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule SimpleshopTheme.Theme.CSSCacheTest do
|
||||
use SimpleshopTheme.DataCase
|
||||
defmodule Berrypod.Theme.CSSCacheTest do
|
||||
use Berrypod.DataCase
|
||||
|
||||
alias SimpleshopTheme.Theme.CSSCache
|
||||
alias SimpleshopTheme.Theme.CSSGenerator
|
||||
alias SimpleshopTheme.Settings.ThemeSettings
|
||||
alias Berrypod.Theme.CSSCache
|
||||
alias Berrypod.Theme.CSSGenerator
|
||||
alias Berrypod.Settings.ThemeSettings
|
||||
|
||||
describe "get/0" do
|
||||
test "returns cached CSS after warm" do
|
||||
@@ -1,8 +1,8 @@
|
||||
defmodule SimpleshopTheme.Theme.CSSGeneratorTest do
|
||||
defmodule Berrypod.Theme.CSSGeneratorTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias SimpleshopTheme.Theme.CSSGenerator
|
||||
alias SimpleshopTheme.Settings.ThemeSettings
|
||||
alias Berrypod.Theme.CSSGenerator
|
||||
alias Berrypod.Settings.ThemeSettings
|
||||
|
||||
describe "generate/1" do
|
||||
test "generates CSS for default theme settings" do
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule SimpleshopTheme.Theme.PresetsTest do
|
||||
defmodule Berrypod.Theme.PresetsTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias SimpleshopTheme.Theme.Presets
|
||||
alias Berrypod.Theme.Presets
|
||||
|
||||
describe "all/0" do
|
||||
test "returns all 8 presets" do
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule SimpleshopTheme.Theme.PreviewDataTest do
|
||||
defmodule Berrypod.Theme.PreviewDataTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias SimpleshopTheme.Theme.PreviewData
|
||||
alias Berrypod.Theme.PreviewData
|
||||
|
||||
describe "products/0" do
|
||||
test "returns a list of products" do
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule SimpleshopTheme.VaultTest do
|
||||
use SimpleshopTheme.DataCase, async: true
|
||||
defmodule Berrypod.VaultTest do
|
||||
use Berrypod.DataCase, async: true
|
||||
|
||||
alias SimpleshopTheme.Vault
|
||||
alias Berrypod.Vault
|
||||
|
||||
describe "encrypt/1 and decrypt/1" do
|
||||
test "round-trips a string successfully" do
|
||||
@@ -1,11 +1,11 @@
|
||||
defmodule SimpleshopTheme.Webhooks.ProductDeleteWorkerTest do
|
||||
use SimpleshopTheme.DataCase
|
||||
use Oban.Testing, repo: SimpleshopTheme.Repo
|
||||
defmodule Berrypod.Webhooks.ProductDeleteWorkerTest do
|
||||
use Berrypod.DataCase
|
||||
use Oban.Testing, repo: Berrypod.Repo
|
||||
|
||||
alias SimpleshopTheme.Webhooks.ProductDeleteWorker
|
||||
alias SimpleshopTheme.Products
|
||||
alias Berrypod.Webhooks.ProductDeleteWorker
|
||||
alias Berrypod.Products
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
describe "perform/1" do
|
||||
test "deletes product when found" do
|
||||
@@ -1,11 +1,11 @@
|
||||
defmodule SimpleshopTheme.WebhooksTest do
|
||||
use SimpleshopTheme.DataCase, async: false
|
||||
defmodule Berrypod.WebhooksTest do
|
||||
use Berrypod.DataCase, async: false
|
||||
|
||||
alias SimpleshopTheme.Orders
|
||||
alias SimpleshopTheme.Webhooks
|
||||
alias Berrypod.Orders
|
||||
alias Berrypod.Webhooks
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import SimpleshopTheme.OrdersFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
import Berrypod.OrdersFixtures
|
||||
|
||||
setup do
|
||||
conn = provider_connection_fixture(%{provider_type: "printify"})
|
||||
@@ -52,7 +52,7 @@ defmodule SimpleshopTheme.WebhooksTest do
|
||||
end
|
||||
|
||||
test "returns error when no provider connection" do
|
||||
SimpleshopTheme.Repo.delete_all(SimpleshopTheme.Products.ProviderConnection)
|
||||
Berrypod.Repo.delete_all(Berrypod.Products.ProviderConnection)
|
||||
|
||||
assert {:error, :no_connection} =
|
||||
Webhooks.handle_printify_event(
|
||||
@@ -175,10 +175,10 @@ defmodule SimpleshopTheme.WebhooksTest do
|
||||
# Delete the printful connection created in setup
|
||||
import Ecto.Query
|
||||
|
||||
from(pc in SimpleshopTheme.Products.ProviderConnection,
|
||||
from(pc in Berrypod.Products.ProviderConnection,
|
||||
where: pc.provider_type == "printful"
|
||||
)
|
||||
|> SimpleshopTheme.Repo.delete_all()
|
||||
|> Berrypod.Repo.delete_all()
|
||||
|
||||
assert {:error, :no_connection} =
|
||||
Webhooks.handle_printful_event("product_updated", %{})
|
||||
@@ -1,18 +1,18 @@
|
||||
defmodule SimpleshopThemeWeb.ErrorHTMLTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: true
|
||||
defmodule BerrypodWeb.ErrorHTMLTest do
|
||||
use BerrypodWeb.ConnCase, async: true
|
||||
|
||||
# Bring render_to_string/4 for testing custom views
|
||||
import Phoenix.Template, only: [render_to_string: 4]
|
||||
|
||||
test "renders 404.html with themed page" do
|
||||
html = render_to_string(SimpleshopThemeWeb.ErrorHTML, "404", "html", [])
|
||||
html = render_to_string(BerrypodWeb.ErrorHTML, "404", "html", [])
|
||||
assert html =~ "404"
|
||||
assert html =~ "Page Not Found"
|
||||
assert html =~ "shop-root"
|
||||
end
|
||||
|
||||
test "renders 500.html with themed page" do
|
||||
html = render_to_string(SimpleshopThemeWeb.ErrorHTML, "500", "html", [])
|
||||
html = render_to_string(BerrypodWeb.ErrorHTML, "500", "html", [])
|
||||
assert html =~ "500"
|
||||
assert html =~ "Server Error"
|
||||
assert html =~ "shop-root"
|
||||
14
test/berrypod_web/controllers/error_json_test.exs
Normal file
14
test/berrypod_web/controllers/error_json_test.exs
Normal file
@@ -0,0 +1,14 @@
|
||||
defmodule BerrypodWeb.ErrorJSONTest do
|
||||
use BerrypodWeb.ConnCase, async: true
|
||||
|
||||
test "renders 404" do
|
||||
assert BerrypodWeb.ErrorJSON.render("404.json", %{}) == %{
|
||||
errors: %{detail: "Not Found"}
|
||||
}
|
||||
end
|
||||
|
||||
test "renders 500" do
|
||||
assert BerrypodWeb.ErrorJSON.render("500.json", %{}) ==
|
||||
%{errors: %{detail: "Internal Server Error"}}
|
||||
end
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule SimpleshopThemeWeb.ImageControllerTest do
|
||||
use SimpleshopThemeWeb.ConnCase
|
||||
defmodule BerrypodWeb.ImageControllerTest do
|
||||
use BerrypodWeb.ConnCase
|
||||
|
||||
alias SimpleshopTheme.Media
|
||||
alias Berrypod.Media
|
||||
|
||||
@svg_content ~s(<svg xmlns="http://www.w3.org/2000/svg"><circle fill="#000000" r="10"/></svg>)
|
||||
@sample_jpeg File.read!("test/fixtures/sample_1200x800.jpg")
|
||||
@@ -1,11 +1,11 @@
|
||||
defmodule SimpleshopThemeWeb.PageControllerTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.PageControllerTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
setup do
|
||||
user_fixture()
|
||||
{:ok, _} = SimpleshopTheme.Settings.set_site_live(true)
|
||||
{:ok, _} = Berrypod.Settings.set_site_live(true)
|
||||
:ok
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
defmodule SimpleshopThemeWeb.UserSessionControllerTest do
|
||||
use SimpleshopThemeWeb.ConnCase
|
||||
defmodule BerrypodWeb.UserSessionControllerTest do
|
||||
use BerrypodWeb.ConnCase
|
||||
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
alias SimpleshopTheme.Accounts
|
||||
import Berrypod.AccountsFixtures
|
||||
alias Berrypod.Accounts
|
||||
|
||||
setup do
|
||||
%{unconfirmed_user: unconfirmed_user_fixture(), user: user_fixture()}
|
||||
@@ -38,7 +38,7 @@ defmodule SimpleshopThemeWeb.UserSessionControllerTest do
|
||||
}
|
||||
})
|
||||
|
||||
assert conn.resp_cookies["_simpleshop_theme_web_user_remember_me"]
|
||||
assert conn.resp_cookies["_berrypod_web_user_remember_me"]
|
||||
assert redirected_to(conn) == ~p"/admin"
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule SimpleshopThemeWeb.WebhookControllerTest do
|
||||
use SimpleshopThemeWeb.ConnCase
|
||||
defmodule BerrypodWeb.WebhookControllerTest do
|
||||
use BerrypodWeb.ConnCase
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
@webhook_secret "test_webhook_secret_123"
|
||||
|
||||
@@ -79,7 +79,7 @@ defmodule SimpleshopThemeWeb.WebhookControllerTest do
|
||||
|
||||
test "returns 401 when no webhook secret configured", %{conn: conn} do
|
||||
# Remove the provider connection to simulate no secret
|
||||
SimpleshopTheme.Repo.delete_all(SimpleshopTheme.Products.ProviderConnection)
|
||||
Berrypod.Repo.delete_all(Berrypod.Products.ProviderConnection)
|
||||
|
||||
body = Jason.encode!(%{type: "product:updated", resource: %{id: "123"}})
|
||||
signature = compute_signature(body, @webhook_secret)
|
||||
@@ -164,7 +164,7 @@ defmodule SimpleshopThemeWeb.WebhookControllerTest do
|
||||
end
|
||||
|
||||
test "returns 401 when no webhook secret configured", %{conn: conn} do
|
||||
SimpleshopTheme.Repo.delete_all(SimpleshopTheme.Products.ProviderConnection)
|
||||
Berrypod.Repo.delete_all(Berrypod.Products.ProviderConnection)
|
||||
|
||||
conn =
|
||||
conn
|
||||
@@ -1,10 +1,10 @@
|
||||
defmodule SimpleshopThemeWeb.Admin.DashboardTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Admin.DashboardTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import SimpleshopTheme.OrdersFixtures
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
import Berrypod.OrdersFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
setup do
|
||||
user = user_fixture()
|
||||
@@ -49,7 +49,7 @@ defmodule SimpleshopThemeWeb.Admin.DashboardTest do
|
||||
test "shows go live button when all services connected", %{conn: conn} do
|
||||
conn_fixture = provider_connection_fixture(%{provider_type: "printify"})
|
||||
_product = product_fixture(%{provider_connection: conn_fixture})
|
||||
{:ok, _} = SimpleshopTheme.Settings.put_secret("stripe_api_key", "sk_test_123")
|
||||
{:ok, _} = Berrypod.Settings.put_secret("stripe_api_key", "sk_test_123")
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin")
|
||||
|
||||
@@ -59,7 +59,7 @@ defmodule SimpleshopThemeWeb.Admin.DashboardTest do
|
||||
test "go live shows celebration", %{conn: conn} do
|
||||
conn_fixture = provider_connection_fixture(%{provider_type: "printify"})
|
||||
_product = product_fixture(%{provider_connection: conn_fixture})
|
||||
{:ok, _} = SimpleshopTheme.Settings.put_secret("stripe_api_key", "sk_test_123")
|
||||
{:ok, _} = Berrypod.Settings.put_secret("stripe_api_key", "sk_test_123")
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin")
|
||||
|
||||
@@ -71,7 +71,7 @@ defmodule SimpleshopThemeWeb.Admin.DashboardTest do
|
||||
end
|
||||
|
||||
test "hides stepper when shop is live", %{conn: conn} do
|
||||
{:ok, _} = SimpleshopTheme.Settings.set_site_live(true)
|
||||
{:ok, _} = Berrypod.Settings.set_site_live(true)
|
||||
{:ok, _view, html} = live(conn, ~p"/admin")
|
||||
|
||||
refute html =~ "Setup steps"
|
||||
@@ -1,8 +1,8 @@
|
||||
defmodule SimpleshopThemeWeb.Admin.LayoutTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Admin.LayoutTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
setup do
|
||||
user = user_fixture()
|
||||
@@ -78,7 +78,7 @@ defmodule SimpleshopThemeWeb.Admin.LayoutTest do
|
||||
|
||||
describe "admin bar on shop pages" do
|
||||
setup do
|
||||
{:ok, _} = SimpleshopTheme.Settings.set_site_live(true)
|
||||
{:ok, _} = Berrypod.Settings.set_site_live(true)
|
||||
:ok
|
||||
end
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule SimpleshopThemeWeb.Admin.OrdersTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Admin.OrdersTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import SimpleshopTheme.OrdersFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
import Berrypod.OrdersFixtures
|
||||
|
||||
setup do
|
||||
user = user_fixture()
|
||||
@@ -91,7 +91,7 @@ defmodule SimpleshopThemeWeb.Admin.OrdersTest do
|
||||
order = order_fixture(payment_status: "paid")
|
||||
|
||||
{:ok, updated_order} =
|
||||
SimpleshopTheme.Orders.update_order(order, %{
|
||||
Berrypod.Orders.update_order(order, %{
|
||||
shipping_address: %{
|
||||
"name" => "Jane Doe",
|
||||
"line1" => "42 Test Street",
|
||||
@@ -137,7 +137,7 @@ defmodule SimpleshopThemeWeb.Admin.OrdersTest do
|
||||
order = order_fixture(payment_status: "paid")
|
||||
|
||||
{:ok, order} =
|
||||
SimpleshopTheme.Orders.update_fulfilment(order, %{fulfilment_status: "failed"})
|
||||
Berrypod.Orders.update_fulfilment(order, %{fulfilment_status: "failed"})
|
||||
|
||||
{:ok, _view, html} = live(conn, ~p"/admin/orders/#{order}")
|
||||
|
||||
@@ -146,7 +146,7 @@ defmodule SimpleshopThemeWeb.Admin.OrdersTest do
|
||||
|
||||
test "shows refresh button for submitted orders", %{conn: conn} do
|
||||
{order, _v, _p, _c} =
|
||||
SimpleshopTheme.OrdersFixtures.submitted_order_fixture()
|
||||
Berrypod.OrdersFixtures.submitted_order_fixture()
|
||||
|
||||
{:ok, _view, html} = live(conn, ~p"/admin/orders/#{order}")
|
||||
|
||||
@@ -155,10 +155,10 @@ defmodule SimpleshopThemeWeb.Admin.OrdersTest do
|
||||
|
||||
test "shows tracking info when available", %{conn: conn} do
|
||||
{order, _v, _p, _c} =
|
||||
SimpleshopTheme.OrdersFixtures.submitted_order_fixture()
|
||||
Berrypod.OrdersFixtures.submitted_order_fixture()
|
||||
|
||||
{:ok, order} =
|
||||
SimpleshopTheme.Orders.update_fulfilment(order, %{
|
||||
Berrypod.Orders.update_fulfilment(order, %{
|
||||
fulfilment_status: "shipped",
|
||||
tracking_number: "TRACK123",
|
||||
tracking_url: "https://track.example.com/TRACK123",
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule SimpleshopThemeWeb.Admin.ProductsTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Admin.ProductsTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
setup do
|
||||
user = user_fixture()
|
||||
@@ -66,12 +66,12 @@ defmodule SimpleshopThemeWeb.Admin.ProductsTest do
|
||||
|> element("button[phx-value-id='#{product.id}']")
|
||||
|> render_click()
|
||||
|
||||
updated = SimpleshopTheme.Products.get_product(product.id)
|
||||
updated = Berrypod.Products.get_product(product.id)
|
||||
refute updated.visible
|
||||
end
|
||||
|
||||
test "filters by visibility", %{conn: conn, product: product} do
|
||||
SimpleshopTheme.Products.update_storefront(product, %{visible: false})
|
||||
Berrypod.Products.update_storefront(product, %{visible: false})
|
||||
|
||||
{:ok, view, _html} = live(conn, ~p"/admin/products")
|
||||
|
||||
@@ -120,7 +120,7 @@ defmodule SimpleshopThemeWeb.Admin.ProductsTest do
|
||||
end
|
||||
|
||||
test "shows empty state when no products", %{conn: conn, product: product} do
|
||||
SimpleshopTheme.Products.delete_product(product)
|
||||
Berrypod.Products.delete_product(product)
|
||||
|
||||
{:ok, _view, html} = live(conn, ~p"/admin/products")
|
||||
|
||||
@@ -168,7 +168,7 @@ defmodule SimpleshopThemeWeb.Admin.ProductsTest do
|
||||
|> element("form")
|
||||
|> render_submit(%{"product" => %{"visible" => "false", "category" => "New Category"}})
|
||||
|
||||
updated = SimpleshopTheme.Products.get_product(product.id)
|
||||
updated = Berrypod.Products.get_product(product.id)
|
||||
refute updated.visible
|
||||
assert updated.category == "New Category"
|
||||
end
|
||||
@@ -1,12 +1,12 @@
|
||||
defmodule SimpleshopThemeWeb.Admin.ProvidersTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Admin.ProvidersTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
import Mox
|
||||
|
||||
alias SimpleshopTheme.Providers.MockProvider
|
||||
alias Berrypod.Providers.MockProvider
|
||||
|
||||
setup :verify_on_exit!
|
||||
|
||||
@@ -106,11 +106,11 @@ defmodule SimpleshopThemeWeb.Admin.ProvidersTest do
|
||||
|
||||
describe "index - sync" do
|
||||
setup %{conn: conn, user: user} do
|
||||
Application.put_env(:simpleshop_theme, :provider_modules, %{
|
||||
Application.put_env(:berrypod, :provider_modules, %{
|
||||
"printify" => MockProvider
|
||||
})
|
||||
|
||||
on_exit(fn -> Application.delete_env(:simpleshop_theme, :provider_modules) end)
|
||||
on_exit(fn -> Application.delete_env(:berrypod, :provider_modules) end)
|
||||
|
||||
connection =
|
||||
provider_connection_fixture(%{
|
||||
@@ -188,11 +188,11 @@ defmodule SimpleshopThemeWeb.Admin.ProvidersTest do
|
||||
|
||||
describe "form - test connection" do
|
||||
setup %{conn: conn, user: user} do
|
||||
Application.put_env(:simpleshop_theme, :provider_modules, %{
|
||||
Application.put_env(:berrypod, :provider_modules, %{
|
||||
"printify" => MockProvider
|
||||
})
|
||||
|
||||
on_exit(fn -> Application.delete_env(:simpleshop_theme, :provider_modules) end)
|
||||
on_exit(fn -> Application.delete_env(:berrypod, :provider_modules) end)
|
||||
|
||||
%{conn: log_in_user(conn, user)}
|
||||
end
|
||||
@@ -1,12 +1,12 @@
|
||||
defmodule SimpleshopThemeWeb.Admin.SettingsTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Admin.SettingsTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
alias SimpleshopTheme.Accounts
|
||||
alias SimpleshopTheme.Settings
|
||||
alias Berrypod.Accounts
|
||||
alias Berrypod.Settings
|
||||
|
||||
setup do
|
||||
user = user_fixture()
|
||||
@@ -1,10 +1,10 @@
|
||||
defmodule SimpleshopThemeWeb.Admin.ThemeTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Admin.ThemeTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
alias SimpleshopTheme.Settings
|
||||
alias Berrypod.Settings
|
||||
|
||||
setup do
|
||||
user = user_fixture()
|
||||
@@ -1,10 +1,10 @@
|
||||
defmodule SimpleshopThemeWeb.Auth.ConfirmationTest do
|
||||
use SimpleshopThemeWeb.ConnCase
|
||||
defmodule BerrypodWeb.Auth.ConfirmationTest do
|
||||
use BerrypodWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
alias SimpleshopTheme.Accounts
|
||||
alias Berrypod.Accounts
|
||||
|
||||
setup do
|
||||
%{unconfirmed_user: unconfirmed_user_fixture(), confirmed_user: user_fixture()}
|
||||
@@ -1,8 +1,8 @@
|
||||
defmodule SimpleshopThemeWeb.Auth.LoginTest do
|
||||
use SimpleshopThemeWeb.ConnCase
|
||||
defmodule BerrypodWeb.Auth.LoginTest do
|
||||
use BerrypodWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
describe "login page" do
|
||||
test "renders login page", %{conn: conn} do
|
||||
@@ -27,7 +27,7 @@ defmodule SimpleshopThemeWeb.Auth.LoginTest do
|
||||
|
||||
assert html =~ "If your email is in our system"
|
||||
|
||||
assert SimpleshopTheme.Repo.get_by!(SimpleshopTheme.Accounts.UserToken, user_id: user.id).context ==
|
||||
assert Berrypod.Repo.get_by!(Berrypod.Accounts.UserToken, user_id: user.id).context ==
|
||||
"login"
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
defmodule SimpleshopThemeWeb.Auth.RegistrationTest do
|
||||
use SimpleshopThemeWeb.ConnCase
|
||||
defmodule BerrypodWeb.Auth.RegistrationTest do
|
||||
use BerrypodWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
describe "Registration page" do
|
||||
test "renders registration page when no admin exists", %{conn: conn} do
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule SimpleshopThemeWeb.Auth.SettingsTest do
|
||||
use SimpleshopThemeWeb.ConnCase
|
||||
defmodule BerrypodWeb.Auth.SettingsTest do
|
||||
use BerrypodWeb.ConnCase
|
||||
|
||||
alias SimpleshopTheme.Accounts
|
||||
alias Berrypod.Accounts
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
describe "settings redirect" do
|
||||
test "redirects to admin settings when logged in", %{conn: conn} do
|
||||
@@ -1,14 +1,14 @@
|
||||
defmodule SimpleshopThemeWeb.Shop.CartTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Shop.CartTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
alias SimpleshopTheme.ProductsFixtures
|
||||
alias Berrypod.ProductsFixtures
|
||||
|
||||
setup do
|
||||
user_fixture()
|
||||
{:ok, _} = SimpleshopTheme.Settings.set_site_live(true)
|
||||
{:ok, _} = Berrypod.Settings.set_site_live(true)
|
||||
:ok
|
||||
end
|
||||
|
||||
@@ -57,7 +57,7 @@ defmodule SimpleshopThemeWeb.Shop.CartTest do
|
||||
test "displays formatted subtotal", %{conn: conn, variant: variant} do
|
||||
{:ok, _view, html} = conn |> conn_with_cart(variant.id) |> live(~p"/cart")
|
||||
|
||||
assert html =~ SimpleshopTheme.Cart.format_price(variant.price)
|
||||
assert html =~ Berrypod.Cart.format_price(variant.price)
|
||||
end
|
||||
|
||||
test "displays checkout button", %{conn: conn, variant: variant} do
|
||||
@@ -1,15 +1,15 @@
|
||||
defmodule SimpleshopThemeWeb.Shop.CollectionTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Shop.CollectionTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
alias SimpleshopTheme.Products
|
||||
alias Berrypod.Products
|
||||
|
||||
setup do
|
||||
user_fixture()
|
||||
{:ok, _} = SimpleshopTheme.Settings.set_site_live(true)
|
||||
{:ok, _} = Berrypod.Settings.set_site_live(true)
|
||||
|
||||
pc = provider_connection_fixture()
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
defmodule SimpleshopThemeWeb.Shop.ComingSoonTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Shop.ComingSoonTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
alias SimpleshopTheme.Settings
|
||||
alias Berrypod.Settings
|
||||
|
||||
describe "coming soon page" do
|
||||
test "renders when site is not live and admin exists", %{conn: conn} do
|
||||
@@ -61,7 +61,7 @@ defmodule SimpleshopThemeWeb.Shop.ComingSoonTest do
|
||||
conn = log_in_user(conn, user)
|
||||
|
||||
# Delete the user — session cookie is now stale
|
||||
SimpleshopTheme.Repo.delete!(user)
|
||||
Berrypod.Repo.delete!(user)
|
||||
|
||||
assert {:error, {:redirect, %{to: "/users/register"}}} = live(conn, ~p"/")
|
||||
end
|
||||
@@ -1,12 +1,12 @@
|
||||
defmodule SimpleshopThemeWeb.Shop.ContentTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Shop.ContentTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
setup do
|
||||
user_fixture()
|
||||
{:ok, _} = SimpleshopTheme.Settings.set_site_live(true)
|
||||
{:ok, _} = Berrypod.Settings.set_site_live(true)
|
||||
:ok
|
||||
end
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
defmodule SimpleshopThemeWeb.Shop.HomeTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Shop.HomeTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
setup do
|
||||
user_fixture()
|
||||
{:ok, _} = SimpleshopTheme.Settings.set_site_live(true)
|
||||
{:ok, _} = Berrypod.Settings.set_site_live(true)
|
||||
|
||||
conn = provider_connection_fixture()
|
||||
|
||||
@@ -21,7 +21,7 @@ defmodule SimpleshopThemeWeb.Shop.HomeTest do
|
||||
product_variant_fixture(%{product: product, title: "8x10", price: 1999})
|
||||
|
||||
# Recompute so cheapest_price is set
|
||||
SimpleshopTheme.Products.recompute_cached_fields(product)
|
||||
Berrypod.Products.recompute_cached_fields(product)
|
||||
|
||||
%{product: product}
|
||||
end
|
||||
@@ -1,15 +1,15 @@
|
||||
defmodule SimpleshopThemeWeb.Shop.ProductShowTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Shop.ProductShowTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
alias SimpleshopTheme.Products
|
||||
alias Berrypod.Products
|
||||
|
||||
setup do
|
||||
user_fixture()
|
||||
{:ok, _} = SimpleshopTheme.Settings.set_site_live(true)
|
||||
{:ok, _} = Berrypod.Settings.set_site_live(true)
|
||||
|
||||
pc = provider_connection_fixture()
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
defmodule SimpleshopThemeWeb.Shop.SearchIntegrationTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
defmodule BerrypodWeb.Shop.SearchIntegrationTest do
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
alias SimpleshopTheme.Search
|
||||
alias Berrypod.Search
|
||||
|
||||
setup do
|
||||
user_fixture()
|
||||
{:ok, _} = SimpleshopTheme.Settings.set_site_live(true)
|
||||
{:ok, _} = Berrypod.Settings.set_site_live(true)
|
||||
|
||||
pc = provider_connection_fixture()
|
||||
|
||||
@@ -22,7 +22,7 @@ defmodule SimpleshopThemeWeb.Shop.SearchIntegrationTest do
|
||||
})
|
||||
|
||||
product_variant_fixture(%{product: mountain, title: "8x10", price: 1999})
|
||||
SimpleshopTheme.Products.recompute_cached_fields(mountain)
|
||||
Berrypod.Products.recompute_cached_fields(mountain)
|
||||
|
||||
ocean =
|
||||
product_fixture(%{
|
||||
@@ -33,7 +33,7 @@ defmodule SimpleshopThemeWeb.Shop.SearchIntegrationTest do
|
||||
})
|
||||
|
||||
product_variant_fixture(%{product: ocean, title: "A5", price: 1299})
|
||||
SimpleshopTheme.Products.recompute_cached_fields(ocean)
|
||||
Berrypod.Products.recompute_cached_fields(ocean)
|
||||
|
||||
Search.rebuild_index()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule SimpleshopThemeWeb.ThemeCSSConsistencyTest do
|
||||
defmodule BerrypodWeb.ThemeCSSConsistencyTest do
|
||||
@moduledoc """
|
||||
Tests that verify CSS works correctly for both the theme editor
|
||||
preview and the shop pages using the shared .themed class.
|
||||
@@ -10,12 +10,12 @@ defmodule SimpleshopThemeWeb.ThemeCSSConsistencyTest do
|
||||
- Component styles use .themed for shared styling (theme-layer2-attributes.css)
|
||||
"""
|
||||
|
||||
use SimpleshopThemeWeb.ConnCase, async: false
|
||||
use BerrypodWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
alias SimpleshopTheme.Settings
|
||||
alias Berrypod.Settings
|
||||
|
||||
setup do
|
||||
user = user_fixture()
|
||||
@@ -122,7 +122,7 @@ defmodule SimpleshopThemeWeb.ThemeCSSConsistencyTest do
|
||||
{:ok, settings} = Settings.apply_preset(:night)
|
||||
|
||||
# Generate CSS
|
||||
css = SimpleshopTheme.Theme.CSSGenerator.generate(settings)
|
||||
css = Berrypod.Theme.CSSGenerator.generate(settings)
|
||||
|
||||
# Mood tokens (surface, text, border colors)
|
||||
assert css =~ "--t-surface-base:"
|
||||
@@ -154,7 +154,7 @@ defmodule SimpleshopThemeWeb.ThemeCSSConsistencyTest do
|
||||
|
||||
test "generated CSS uses correct values for dark mood" do
|
||||
{:ok, settings} = Settings.apply_preset(:night)
|
||||
css = SimpleshopTheme.Theme.CSSGenerator.generate(settings)
|
||||
css = Berrypod.Theme.CSSGenerator.generate(settings)
|
||||
|
||||
# Dark mood should have dark surface colors
|
||||
assert css =~ "--t-surface-base: #0a0a0a"
|
||||
@@ -163,7 +163,7 @@ defmodule SimpleshopThemeWeb.ThemeCSSConsistencyTest do
|
||||
|
||||
test "generated CSS uses correct values for warm mood" do
|
||||
{:ok, settings} = Settings.apply_preset(:gallery)
|
||||
css = SimpleshopTheme.Theme.CSSGenerator.generate(settings)
|
||||
css = Berrypod.Theme.CSSGenerator.generate(settings)
|
||||
|
||||
# Warm mood should have warm surface colors
|
||||
assert css =~ "--t-surface-base: #fdf8f3"
|
||||
@@ -171,16 +171,16 @@ defmodule SimpleshopThemeWeb.ThemeCSSConsistencyTest do
|
||||
|
||||
test "CSS cache is warmed on startup and invalidated on settings change" do
|
||||
# Ensure cache has content
|
||||
SimpleshopTheme.Theme.CSSCache.warm()
|
||||
Berrypod.Theme.CSSCache.warm()
|
||||
|
||||
{:ok, css1} = SimpleshopTheme.Theme.CSSCache.get()
|
||||
{:ok, css1} = Berrypod.Theme.CSSCache.get()
|
||||
assert is_binary(css1)
|
||||
assert css1 =~ "--t-accent-h:"
|
||||
|
||||
# Change settings (this should invalidate and rewarm cache)
|
||||
{:ok, _settings} = Settings.apply_preset(:night)
|
||||
|
||||
{:ok, css2} = SimpleshopTheme.Theme.CSSCache.get()
|
||||
{:ok, css2} = Berrypod.Theme.CSSCache.get()
|
||||
assert is_binary(css2)
|
||||
|
||||
# The CSS should be different (different accent color)
|
||||
@@ -1,7 +1,7 @@
|
||||
defmodule SimpleshopThemeWeb.Plugs.CountryDetectTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: true
|
||||
defmodule BerrypodWeb.Plugs.CountryDetectTest do
|
||||
use BerrypodWeb.ConnCase, async: true
|
||||
|
||||
alias SimpleshopThemeWeb.Plugs.CountryDetect
|
||||
alias BerrypodWeb.Plugs.CountryDetect
|
||||
|
||||
defp with_cookies(conn) do
|
||||
Plug.Conn.fetch_cookies(conn)
|
||||
@@ -1,20 +1,20 @@
|
||||
defmodule SimpleshopThemeWeb.UserAuthTest do
|
||||
use SimpleshopThemeWeb.ConnCase
|
||||
defmodule BerrypodWeb.UserAuthTest do
|
||||
use BerrypodWeb.ConnCase
|
||||
|
||||
alias Phoenix.LiveView
|
||||
alias SimpleshopTheme.Accounts
|
||||
alias SimpleshopTheme.Accounts.Scope
|
||||
alias SimpleshopThemeWeb.UserAuth
|
||||
alias Berrypod.Accounts
|
||||
alias Berrypod.Accounts.Scope
|
||||
alias BerrypodWeb.UserAuth
|
||||
|
||||
import SimpleshopTheme.AccountsFixtures
|
||||
import Berrypod.AccountsFixtures
|
||||
|
||||
@remember_me_cookie "_simpleshop_theme_web_user_remember_me"
|
||||
@remember_me_cookie "_berrypod_web_user_remember_me"
|
||||
@remember_me_cookie_max_age 60 * 60 * 24 * 14
|
||||
|
||||
setup %{conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> Map.replace!(:secret_key_base, SimpleshopThemeWeb.Endpoint.config(:secret_key_base))
|
||||
|> Map.replace!(:secret_key_base, BerrypodWeb.Endpoint.config(:secret_key_base))
|
||||
|> init_test_session(%{})
|
||||
|
||||
%{user: %{user_fixture() | authenticated_at: DateTime.utc_now(:second)}, conn: conn}
|
||||
@@ -91,7 +91,7 @@ defmodule SimpleshopThemeWeb.UserAuthTest do
|
||||
conn =
|
||||
conn
|
||||
|> recycle()
|
||||
|> Map.replace!(:secret_key_base, SimpleshopThemeWeb.Endpoint.config(:secret_key_base))
|
||||
|> Map.replace!(:secret_key_base, BerrypodWeb.Endpoint.config(:secret_key_base))
|
||||
|> fetch_cookies()
|
||||
|> init_test_session(%{user_remember_me: true})
|
||||
|
||||
@@ -126,7 +126,7 @@ defmodule SimpleshopThemeWeb.UserAuthTest do
|
||||
|
||||
test "broadcasts to the given live_socket_id", %{conn: conn} do
|
||||
live_socket_id = "users_sessions:abcdef-token"
|
||||
SimpleshopThemeWeb.Endpoint.subscribe(live_socket_id)
|
||||
BerrypodWeb.Endpoint.subscribe(live_socket_id)
|
||||
|
||||
conn
|
||||
|> put_session(:live_socket_id, live_socket_id)
|
||||
@@ -261,7 +261,7 @@ defmodule SimpleshopThemeWeb.UserAuthTest do
|
||||
session = conn |> put_session(:user_token, user_token) |> get_session()
|
||||
|
||||
socket = %LiveView.Socket{
|
||||
endpoint: SimpleshopThemeWeb.Endpoint,
|
||||
endpoint: BerrypodWeb.Endpoint,
|
||||
assigns: %{__changed__: %{}, flash: %{}}
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ defmodule SimpleshopThemeWeb.UserAuthTest do
|
||||
session = conn |> get_session()
|
||||
|
||||
socket = %LiveView.Socket{
|
||||
endpoint: SimpleshopThemeWeb.Endpoint,
|
||||
endpoint: BerrypodWeb.Endpoint,
|
||||
assigns: %{__changed__: %{}, flash: %{}}
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ defmodule SimpleshopThemeWeb.UserAuthTest do
|
||||
session = conn |> put_session(:user_token, user_token) |> get_session()
|
||||
|
||||
socket = %LiveView.Socket{
|
||||
endpoint: SimpleshopThemeWeb.Endpoint,
|
||||
endpoint: BerrypodWeb.Endpoint,
|
||||
assigns: %{__changed__: %{}, flash: %{}}
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ defmodule SimpleshopThemeWeb.UserAuthTest do
|
||||
session = conn |> put_session(:user_token, user_token) |> get_session()
|
||||
|
||||
socket = %LiveView.Socket{
|
||||
endpoint: SimpleshopThemeWeb.Endpoint,
|
||||
endpoint: BerrypodWeb.Endpoint,
|
||||
assigns: %{__changed__: %{}, flash: %{}}
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ defmodule SimpleshopThemeWeb.UserAuthTest do
|
||||
tokens = [%{token: "token1"}, %{token: "token2"}]
|
||||
|
||||
for %{token: token} <- tokens do
|
||||
SimpleshopThemeWeb.Endpoint.subscribe("users_sessions:#{Base.url_encode64(token)}")
|
||||
BerrypodWeb.Endpoint.subscribe("users_sessions:#{Base.url_encode64(token)}")
|
||||
end
|
||||
|
||||
UserAuth.disconnect_sessions(tokens)
|
||||
@@ -1,14 +0,0 @@
|
||||
defmodule SimpleshopThemeWeb.ErrorJSONTest do
|
||||
use SimpleshopThemeWeb.ConnCase, async: true
|
||||
|
||||
test "renders 404" do
|
||||
assert SimpleshopThemeWeb.ErrorJSON.render("404.json", %{}) == %{
|
||||
errors: %{detail: "Not Found"}
|
||||
}
|
||||
end
|
||||
|
||||
test "renders 500" do
|
||||
assert SimpleshopThemeWeb.ErrorJSON.render("500.json", %{}) ==
|
||||
%{errors: %{detail: "Internal Server Error"}}
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule SimpleshopThemeWeb.ConnCase do
|
||||
defmodule BerrypodWeb.ConnCase do
|
||||
@moduledoc """
|
||||
This module defines the test case to be used by
|
||||
tests that require setting up a connection.
|
||||
@@ -11,7 +11,7 @@ defmodule SimpleshopThemeWeb.ConnCase do
|
||||
we enable the SQL sandbox, so changes done to the database
|
||||
are reverted at the end of every test. If you are using
|
||||
PostgreSQL, you can even run database tests asynchronously
|
||||
by setting `use SimpleshopThemeWeb.ConnCase, async: true`, although
|
||||
by setting `use BerrypodWeb.ConnCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
@@ -20,19 +20,19 @@ defmodule SimpleshopThemeWeb.ConnCase do
|
||||
using do
|
||||
quote do
|
||||
# The default endpoint for testing
|
||||
@endpoint SimpleshopThemeWeb.Endpoint
|
||||
@endpoint BerrypodWeb.Endpoint
|
||||
|
||||
use SimpleshopThemeWeb, :verified_routes
|
||||
use BerrypodWeb, :verified_routes
|
||||
|
||||
# Import conveniences for testing with connections
|
||||
import Plug.Conn
|
||||
import Phoenix.ConnTest
|
||||
import SimpleshopThemeWeb.ConnCase
|
||||
import BerrypodWeb.ConnCase
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
SimpleshopTheme.DataCase.setup_sandbox(tags)
|
||||
Berrypod.DataCase.setup_sandbox(tags)
|
||||
{:ok, conn: Phoenix.ConnTest.build_conn()}
|
||||
end
|
||||
|
||||
@@ -45,8 +45,8 @@ defmodule SimpleshopThemeWeb.ConnCase do
|
||||
test context.
|
||||
"""
|
||||
def register_and_log_in_user(%{conn: conn} = context) do
|
||||
user = SimpleshopTheme.AccountsFixtures.user_fixture()
|
||||
scope = SimpleshopTheme.Accounts.Scope.for_user(user)
|
||||
user = Berrypod.AccountsFixtures.user_fixture()
|
||||
scope = Berrypod.Accounts.Scope.for_user(user)
|
||||
|
||||
opts =
|
||||
context
|
||||
@@ -62,7 +62,7 @@ defmodule SimpleshopThemeWeb.ConnCase do
|
||||
It returns an updated `conn`.
|
||||
"""
|
||||
def log_in_user(conn, user, opts \\ []) do
|
||||
token = SimpleshopTheme.Accounts.generate_user_session_token(user)
|
||||
token = Berrypod.Accounts.generate_user_session_token(user)
|
||||
|
||||
maybe_set_token_authenticated_at(token, opts[:token_authenticated_at])
|
||||
|
||||
@@ -74,6 +74,6 @@ defmodule SimpleshopThemeWeb.ConnCase do
|
||||
defp maybe_set_token_authenticated_at(_token, nil), do: nil
|
||||
|
||||
defp maybe_set_token_authenticated_at(token, authenticated_at) do
|
||||
SimpleshopTheme.AccountsFixtures.override_token_authenticated_at(token, authenticated_at)
|
||||
Berrypod.AccountsFixtures.override_token_authenticated_at(token, authenticated_at)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule SimpleshopTheme.DataCase do
|
||||
defmodule Berrypod.DataCase do
|
||||
@moduledoc """
|
||||
This module defines the setup for tests requiring
|
||||
access to the application's data layer.
|
||||
@@ -10,7 +10,7 @@ defmodule SimpleshopTheme.DataCase do
|
||||
we enable the SQL sandbox, so changes done to the database
|
||||
are reverted at the end of every test. If you are using
|
||||
PostgreSQL, you can even run database tests asynchronously
|
||||
by setting `use SimpleshopTheme.DataCase, async: true`, although
|
||||
by setting `use Berrypod.DataCase, async: true`, although
|
||||
this option is not recommended for other databases.
|
||||
"""
|
||||
|
||||
@@ -18,17 +18,17 @@ defmodule SimpleshopTheme.DataCase do
|
||||
|
||||
using do
|
||||
quote do
|
||||
alias SimpleshopTheme.Repo
|
||||
alias Berrypod.Repo
|
||||
|
||||
import Ecto
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
import SimpleshopTheme.DataCase
|
||||
import Berrypod.DataCase
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
SimpleshopTheme.DataCase.setup_sandbox(tags)
|
||||
Berrypod.DataCase.setup_sandbox(tags)
|
||||
:ok
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@ defmodule SimpleshopTheme.DataCase do
|
||||
Sets up the sandbox based on the test tags.
|
||||
"""
|
||||
def setup_sandbox(tags) do
|
||||
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(SimpleshopTheme.Repo, shared: not tags[:async])
|
||||
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Berrypod.Repo, shared: not tags[:async])
|
||||
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
defmodule SimpleshopTheme.AccountsFixtures do
|
||||
defmodule Berrypod.AccountsFixtures do
|
||||
@moduledoc """
|
||||
This module defines test helpers for creating
|
||||
entities via the `SimpleshopTheme.Accounts` context.
|
||||
entities via the `Berrypod.Accounts` context.
|
||||
"""
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
alias SimpleshopTheme.Accounts
|
||||
alias SimpleshopTheme.Accounts.Scope
|
||||
alias Berrypod.Accounts
|
||||
alias Berrypod.Accounts.Scope
|
||||
|
||||
def unique_user_email, do: "user#{System.unique_integer()}@example.com"
|
||||
def valid_user_password, do: "hello world!"
|
||||
@@ -64,7 +64,7 @@ defmodule SimpleshopTheme.AccountsFixtures do
|
||||
end
|
||||
|
||||
def override_token_authenticated_at(token, authenticated_at) when is_binary(token) do
|
||||
SimpleshopTheme.Repo.update_all(
|
||||
Berrypod.Repo.update_all(
|
||||
from(t in Accounts.UserToken,
|
||||
where: t.token == ^token
|
||||
),
|
||||
@@ -74,14 +74,14 @@ defmodule SimpleshopTheme.AccountsFixtures do
|
||||
|
||||
def generate_user_magic_link_token(user) do
|
||||
{encoded_token, user_token} = Accounts.UserToken.build_email_token(user, "login")
|
||||
SimpleshopTheme.Repo.insert!(user_token)
|
||||
Berrypod.Repo.insert!(user_token)
|
||||
{encoded_token, user_token.token}
|
||||
end
|
||||
|
||||
def offset_user_token(token, amount_to_add, unit) do
|
||||
dt = DateTime.add(DateTime.utc_now(:second), amount_to_add, unit)
|
||||
|
||||
SimpleshopTheme.Repo.update_all(
|
||||
Berrypod.Repo.update_all(
|
||||
from(ut in Accounts.UserToken, where: ut.token == ^token),
|
||||
set: [inserted_at: dt, authenticated_at: dt]
|
||||
)
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
defmodule SimpleshopTheme.ImageFixtures do
|
||||
defmodule Berrypod.ImageFixtures do
|
||||
@moduledoc """
|
||||
Shared fixtures for image-related tests.
|
||||
"""
|
||||
|
||||
alias SimpleshopTheme.Repo
|
||||
alias SimpleshopTheme.Media.Image
|
||||
alias Berrypod.Repo
|
||||
alias Berrypod.Media.Image
|
||||
|
||||
@sample_jpeg File.read!("test/fixtures/sample_1200x800.jpg")
|
||||
|
||||
def sample_jpeg, do: @sample_jpeg
|
||||
|
||||
def image_fixture(attrs \\ %{}) do
|
||||
{:ok, webp, w, h} = SimpleshopTheme.Images.Optimizer.to_optimized_webp(@sample_jpeg)
|
||||
{:ok, webp, w, h} = Berrypod.Images.Optimizer.to_optimized_webp(@sample_jpeg)
|
||||
|
||||
defaults = %{
|
||||
image_type: "product",
|
||||
@@ -63,11 +63,11 @@ defmodule SimpleshopTheme.ImageFixtures do
|
||||
_ -> "#{id}-#{width}.#{ext}"
|
||||
end
|
||||
|
||||
Path.join(SimpleshopTheme.Images.Optimizer.cache_dir(), filename)
|
||||
Path.join(Berrypod.Images.Optimizer.cache_dir(), filename)
|
||||
end
|
||||
|
||||
def cleanup_cache do
|
||||
cache_dir = SimpleshopTheme.Images.Optimizer.cache_dir()
|
||||
cache_dir = Berrypod.Images.Optimizer.cache_dir()
|
||||
if File.exists?(cache_dir), do: File.rm_rf!(cache_dir)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
defmodule SimpleshopTheme.OrdersFixtures do
|
||||
defmodule Berrypod.OrdersFixtures do
|
||||
@moduledoc """
|
||||
Test helpers for creating orders.
|
||||
"""
|
||||
|
||||
alias SimpleshopTheme.Orders
|
||||
alias Berrypod.Orders
|
||||
|
||||
import SimpleshopTheme.ProductsFixtures
|
||||
import Berrypod.ProductsFixtures
|
||||
|
||||
def order_fixture(attrs \\ %{}) do
|
||||
attrs = Enum.into(attrs, %{})
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
defmodule SimpleshopTheme.ProductsFixtures do
|
||||
defmodule Berrypod.ProductsFixtures do
|
||||
@moduledoc """
|
||||
Test helpers for creating entities via the `SimpleshopTheme.Products` context.
|
||||
Test helpers for creating entities via the `Berrypod.Products` context.
|
||||
"""
|
||||
|
||||
alias SimpleshopTheme.Products
|
||||
alias Berrypod.Products
|
||||
|
||||
def unique_provider_product_id, do: "prov_#{System.unique_integer([:positive])}"
|
||||
def unique_slug, do: "product-#{System.unique_integer([:positive])}"
|
||||
@@ -186,7 +186,7 @@ defmodule SimpleshopTheme.ProductsFixtures do
|
||||
end
|
||||
|
||||
# Return product with preloaded associations
|
||||
SimpleshopTheme.Repo.preload(product, [:images, :variants])
|
||||
Berrypod.Repo.preload(product, [:images, :variants])
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Mox.defmock(SimpleshopTheme.Providers.MockProvider,
|
||||
for: SimpleshopTheme.Providers.Provider
|
||||
Mox.defmock(Berrypod.Providers.MockProvider,
|
||||
for: Berrypod.Providers.Provider
|
||||
)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
ExUnit.start()
|
||||
Ecto.Adapters.SQL.Sandbox.mode(SimpleshopTheme.Repo, :manual)
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Berrypod.Repo, :manual)
|
||||
|
||||
Reference in New Issue
Block a user