fix: resolve compilation warnings and update tests to match implementation

- Remove unused generate_mood/1, generate_typography/1, generate_shape/1,
  generate_density/1 functions from CSSGenerator (now handled via CSS
  data attributes)
- Prefix unused _opts parameters in Printify.Client
- Remove unused created_products variable from MockupGenerator
- Update CSSGeneratorTest to test actual generated CSS (accent colors,
  font size scale, layout width, etc.)
- Update PresetsTest to match 8 presets (not 9)
- Fix PreviewDataTest to accept local image paths
- Update ThemeLiveTest to use correct selectors and match actual UI
This commit is contained in:
2026-01-15 22:36:15 +00:00
parent 974d91ce33
commit d4dbd8998f
10 changed files with 807 additions and 344 deletions

View File

@@ -29,12 +29,11 @@ defmodule SimpleshopThemeWeb.ThemeLiveTest do
test "renders theme editor page", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/admin/theme")
assert html =~ "Theme Editor"
assert html =~ "Save Theme"
assert html =~ "Presets"
assert html =~ "Theme Studio"
assert html =~ "preset"
end
test "displays all 9 presets", %{conn: conn} do
test "displays all 8 presets", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/admin/theme")
assert html =~ "gallery"
@@ -45,7 +44,6 @@ defmodule SimpleshopThemeWeb.ThemeLiveTest do
assert html =~ "minimal"
assert html =~ "night"
assert html =~ "classic"
assert html =~ "impulse"
end
test "displays current theme settings", %{conn: conn} do
@@ -61,10 +59,9 @@ defmodule SimpleshopThemeWeb.ThemeLiveTest do
test "displays generated CSS in preview", %{conn: conn} do
{:ok, _view, html} = live(conn, ~p"/admin/theme")
# CSS generator outputs accent colors and layout variables
assert html =~ ".preview-frame, .shop-root"
assert html =~ "--t-accent-h:"
assert html =~ "--t-surface-base:"
assert html =~ "--t-font-heading:"
end
test "applies preset and updates preview", %{conn: conn} do
@@ -93,14 +90,18 @@ defmodule SimpleshopThemeWeb.ThemeLiveTest do
assert html =~ "All Products"
end
test "save theme button works", %{conn: conn} do
test "theme settings are saved when applying a preset", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/admin/theme")
# Apply a preset
view
|> element("button", "Save Theme")
|> element("button", "gallery")
|> render_click()
assert view |> element("button", "Save Theme") |> has_element?()
# Verify settings were persisted
theme_settings = Settings.get_theme_settings()
assert theme_settings.mood == "warm"
assert theme_settings.typography == "editorial"
end
test "all preview page buttons are present", %{conn: conn} do
@@ -121,7 +122,7 @@ defmodule SimpleshopThemeWeb.ThemeLiveTest do
# Click the "dark" mood button
html =
view
|> element("button", "dark")
|> element("button[phx-value-setting_value='dark']")
|> render_click()
# Verify the setting was updated
@@ -135,7 +136,7 @@ defmodule SimpleshopThemeWeb.ThemeLiveTest do
# Click the "round" shape button
view
|> element("button", "round")
|> element("button[phx-value-setting_value='round']")
|> render_click()
# Verify the setting was updated
@@ -148,7 +149,7 @@ defmodule SimpleshopThemeWeb.ThemeLiveTest do
# Click the "compact" density button
view
|> element("button", "compact")
|> element("button[phx-value-setting_value='compact']")
|> render_click()
# Verify the setting was updated
@@ -159,9 +160,9 @@ defmodule SimpleshopThemeWeb.ThemeLiveTest do
test "grid columns customization buttons work", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/admin/theme")
# Click the "2" grid columns button
# Click the "2 columns" grid columns button
view
|> element("button", "2")
|> element("button", "2 columns")
|> render_click()
# Verify the setting was updated
@@ -169,13 +170,13 @@ defmodule SimpleshopThemeWeb.ThemeLiveTest do
assert theme_settings.grid_columns == "2"
end
test "typography customization select works", %{conn: conn} do
test "typography customization buttons work", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/admin/theme")
# Change typography via the form
# Click the "modern" typography button
view
|> element("form[phx-value-field='typography']")
|> render_change(%{"typography" => "modern"})
|> element("button[phx-value-setting_value='modern']")
|> render_click()
# Verify the setting was updated
theme_settings = Settings.get_theme_settings()
@@ -187,7 +188,7 @@ defmodule SimpleshopThemeWeb.ThemeLiveTest do
# Click the "centered" header layout button
view
|> element("button", "centered")
|> element("button[phx-value-setting_value='centered']")
|> render_click()
# Verify the setting was updated
@@ -204,12 +205,12 @@ defmodule SimpleshopThemeWeb.ThemeLiveTest do
# Change a setting
new_html =
view
|> element("button", "dark")
|> element("button[phx-value-setting_value='dark']")
|> render_click()
# Verify CSS has changed (dark mode should have different surface colors)
# Verify CSS has changed
refute initial_css == new_html
assert new_html =~ "--t-surface-base:"
assert new_html =~ "--t-accent-h:"
end
end
end