2026-02-18 21:23:15 +00:00
|
|
|
defmodule BerrypodWeb.Shop.HomeTest do
|
|
|
|
|
use BerrypodWeb.ConnCase, async: false
|
2026-02-08 14:57:10 +00:00
|
|
|
|
|
|
|
|
import Phoenix.LiveViewTest
|
2026-02-18 21:23:15 +00:00
|
|
|
import Berrypod.AccountsFixtures
|
|
|
|
|
import Berrypod.ProductsFixtures
|
2026-02-08 14:57:10 +00:00
|
|
|
|
2026-02-12 14:40:58 +00:00
|
|
|
setup do
|
|
|
|
|
user_fixture()
|
2026-02-18 21:23:15 +00:00
|
|
|
{:ok, _} = Berrypod.Settings.set_site_live(true)
|
2026-02-13 08:27:26 +00:00
|
|
|
|
|
|
|
|
conn = provider_connection_fixture()
|
|
|
|
|
|
|
|
|
|
product =
|
|
|
|
|
product_fixture(%{
|
|
|
|
|
provider_connection: conn,
|
|
|
|
|
title: "Mountain Sunrise Print",
|
|
|
|
|
category: "Art Prints"
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
product_variant_fixture(%{product: product, title: "8x10", price: 1999})
|
|
|
|
|
|
|
|
|
|
# Recompute so cheapest_price is set
|
2026-02-18 21:23:15 +00:00
|
|
|
Berrypod.Products.recompute_cached_fields(product)
|
2026-02-13 08:27:26 +00:00
|
|
|
|
|
|
|
|
%{product: product}
|
2026-02-12 14:40:58 +00:00
|
|
|
end
|
|
|
|
|
|
2026-02-08 14:57:10 +00:00
|
|
|
describe "Home page" do
|
|
|
|
|
test "renders the home page", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/")
|
|
|
|
|
|
2026-03-03 00:56:01 +00:00
|
|
|
assert html =~ "Your headline goes here"
|
2026-02-08 14:57:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "renders hero section with CTA", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/")
|
|
|
|
|
|
|
|
|
|
assert html =~ "Shop the collection"
|
|
|
|
|
end
|
|
|
|
|
|
2026-02-13 08:27:26 +00:00
|
|
|
test "renders category navigation with real categories", %{conn: conn} do
|
2026-02-08 14:57:10 +00:00
|
|
|
{:ok, _view, html} = live(conn, ~p"/")
|
|
|
|
|
|
2026-02-13 08:27:26 +00:00
|
|
|
assert html =~ "Art Prints"
|
2026-02-08 14:57:10 +00:00
|
|
|
end
|
|
|
|
|
|
2026-02-13 08:27:26 +00:00
|
|
|
test "renders featured products section", %{conn: conn, product: product} do
|
2026-02-08 14:57:10 +00:00
|
|
|
{:ok, _view, html} = live(conn, ~p"/")
|
|
|
|
|
|
|
|
|
|
assert html =~ "Featured products"
|
2026-02-13 08:27:26 +00:00
|
|
|
assert html =~ product.title
|
2026-02-08 14:57:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "renders image and text section", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/")
|
|
|
|
|
|
2026-03-03 00:56:01 +00:00
|
|
|
assert html =~ "Your story in a nutshell"
|
|
|
|
|
assert html =~ "Read more about us"
|
2026-02-08 14:57:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "renders header with shop name", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/")
|
|
|
|
|
|
2026-02-13 08:27:26 +00:00
|
|
|
assert html =~ "Store Name"
|
2026-02-08 14:57:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "renders footer with links", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/")
|
|
|
|
|
|
|
|
|
|
assert html =~ ~s(href="/about")
|
|
|
|
|
assert html =~ ~s(href="/contact")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "Navigation links" do
|
|
|
|
|
test "category links point to collections", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/")
|
|
|
|
|
|
|
|
|
|
assert html =~ ~s(href="/collections/)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "product links point to product pages", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/")
|
|
|
|
|
|
|
|
|
|
assert html =~ ~s(href="/products/)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "hero CTA links to collections", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/")
|
|
|
|
|
|
|
|
|
|
assert html =~ ~s(href="/collections/all")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "about link in image section", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/")
|
|
|
|
|
|
|
|
|
|
assert html =~ ~s(href="/about")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|