2026-02-18 21:23:15 +00:00
|
|
|
defmodule BerrypodWeb.Admin.ThemeTest do
|
|
|
|
|
use BerrypodWeb.ConnCase, async: false
|
feat: add Theme LiveView with preset switching
Implement basic theme editor interface with live preview:
- ThemeLive.Index LiveView with mount and event handlers
- Two-column layout: controls sidebar + preview area
- Display all 9 presets as clickable buttons
- Apply preset and regenerate CSS on click
- Show current theme settings (mood, typography, shape, density, color)
- Preview page switcher (7 pages: home, collection, product, cart, about, contact, 404)
- Inline <style> tag with generated CSS for instant preview
- Basic preview frame showing theme variables in action
- Authentication required via :require_authenticated_user pipeline
- Theme navigation link added to user menu
- 9 comprehensive LiveView tests
All tests passing (197 total).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 21:53:52 +00:00
|
|
|
|
|
|
|
|
import Phoenix.LiveViewTest
|
2026-02-18 21:23:15 +00:00
|
|
|
import Berrypod.AccountsFixtures
|
feat: add Theme LiveView with preset switching
Implement basic theme editor interface with live preview:
- ThemeLive.Index LiveView with mount and event handlers
- Two-column layout: controls sidebar + preview area
- Display all 9 presets as clickable buttons
- Apply preset and regenerate CSS on click
- Show current theme settings (mood, typography, shape, density, color)
- Preview page switcher (7 pages: home, collection, product, cart, about, contact, 404)
- Inline <style> tag with generated CSS for instant preview
- Basic preview frame showing theme variables in action
- Authentication required via :require_authenticated_user pipeline
- Theme navigation link added to user menu
- 9 comprehensive LiveView tests
All tests passing (197 total).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 21:53:52 +00:00
|
|
|
|
2026-02-18 21:23:15 +00:00
|
|
|
alias Berrypod.Settings
|
feat: add Theme LiveView with preset switching
Implement basic theme editor interface with live preview:
- ThemeLive.Index LiveView with mount and event handlers
- Two-column layout: controls sidebar + preview area
- Display all 9 presets as clickable buttons
- Apply preset and regenerate CSS on click
- Show current theme settings (mood, typography, shape, density, color)
- Preview page switcher (7 pages: home, collection, product, cart, about, contact, 404)
- Inline <style> tag with generated CSS for instant preview
- Basic preview frame showing theme variables in action
- Authentication required via :require_authenticated_user pipeline
- Theme navigation link added to user menu
- 9 comprehensive LiveView tests
All tests passing (197 total).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 21:53:52 +00:00
|
|
|
|
|
|
|
|
setup do
|
|
|
|
|
user = user_fixture()
|
|
|
|
|
%{user: user}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "Index (unauthenticated)" do
|
|
|
|
|
test "redirects to login when not authenticated", %{conn: conn} do
|
|
|
|
|
{:error, redirect} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
|
|
|
|
assert {:redirect, %{to: path}} = redirect
|
|
|
|
|
assert path == ~p"/users/log-in"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "Index (authenticated)" do
|
|
|
|
|
setup %{conn: conn, user: user} do
|
|
|
|
|
conn = log_in_user(conn, user)
|
|
|
|
|
%{conn: conn}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "renders theme editor page", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
2026-01-15 22:36:15 +00:00
|
|
|
assert html =~ "Theme Studio"
|
|
|
|
|
assert html =~ "preset"
|
feat: add Theme LiveView with preset switching
Implement basic theme editor interface with live preview:
- ThemeLive.Index LiveView with mount and event handlers
- Two-column layout: controls sidebar + preview area
- Display all 9 presets as clickable buttons
- Apply preset and regenerate CSS on click
- Show current theme settings (mood, typography, shape, density, color)
- Preview page switcher (7 pages: home, collection, product, cart, about, contact, 404)
- Inline <style> tag with generated CSS for instant preview
- Basic preview frame showing theme variables in action
- Authentication required via :require_authenticated_user pipeline
- Theme navigation link added to user menu
- 9 comprehensive LiveView tests
All tests passing (197 total).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 21:53:52 +00:00
|
|
|
end
|
|
|
|
|
|
2026-01-15 22:36:15 +00:00
|
|
|
test "displays all 8 presets", %{conn: conn} do
|
feat: add Theme LiveView with preset switching
Implement basic theme editor interface with live preview:
- ThemeLive.Index LiveView with mount and event handlers
- Two-column layout: controls sidebar + preview area
- Display all 9 presets as clickable buttons
- Apply preset and regenerate CSS on click
- Show current theme settings (mood, typography, shape, density, color)
- Preview page switcher (7 pages: home, collection, product, cart, about, contact, 404)
- Inline <style> tag with generated CSS for instant preview
- Basic preview frame showing theme variables in action
- Authentication required via :require_authenticated_user pipeline
- Theme navigation link added to user menu
- 9 comprehensive LiveView tests
All tests passing (197 total).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 21:53:52 +00:00
|
|
|
{:ok, _view, html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
|
|
|
|
assert html =~ "gallery"
|
|
|
|
|
assert html =~ "studio"
|
|
|
|
|
assert html =~ "boutique"
|
|
|
|
|
assert html =~ "bold"
|
|
|
|
|
assert html =~ "playful"
|
|
|
|
|
assert html =~ "minimal"
|
|
|
|
|
assert html =~ "night"
|
|
|
|
|
assert html =~ "classic"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "displays current theme settings", %{conn: conn} do
|
|
|
|
|
{:ok, _settings} = Settings.apply_preset(:gallery)
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
|
|
|
|
assert html =~ "warm"
|
|
|
|
|
assert html =~ "editorial"
|
|
|
|
|
assert html =~ "soft"
|
|
|
|
|
assert html =~ "spacious"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "displays generated CSS in preview", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
2026-01-17 21:43:26 +00:00
|
|
|
# CSS generator outputs accent colors and layout variables for shop pages
|
|
|
|
|
assert html =~ ".themed {"
|
feat: add Theme LiveView with preset switching
Implement basic theme editor interface with live preview:
- ThemeLive.Index LiveView with mount and event handlers
- Two-column layout: controls sidebar + preview area
- Display all 9 presets as clickable buttons
- Apply preset and regenerate CSS on click
- Show current theme settings (mood, typography, shape, density, color)
- Preview page switcher (7 pages: home, collection, product, cart, about, contact, 404)
- Inline <style> tag with generated CSS for instant preview
- Basic preview frame showing theme variables in action
- Authentication required via :require_authenticated_user pipeline
- Theme navigation link added to user menu
- 9 comprehensive LiveView tests
All tests passing (197 total).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 21:53:52 +00:00
|
|
|
assert html =~ "--t-accent-h:"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "applies preset and updates preview", %{conn: conn} do
|
|
|
|
|
{:ok, view, _html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
|
|
|
|
html =
|
|
|
|
|
view
|
|
|
|
|
|> element("button", "gallery")
|
|
|
|
|
|> render_click()
|
|
|
|
|
|
|
|
|
|
theme_settings = Settings.get_theme_settings()
|
|
|
|
|
assert theme_settings.mood == "warm"
|
|
|
|
|
assert theme_settings.typography == "editorial"
|
|
|
|
|
assert html =~ "warm"
|
|
|
|
|
assert html =~ "editorial"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "switches preview page", %{conn: conn} do
|
|
|
|
|
{:ok, view, _html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
|
|
|
|
html =
|
|
|
|
|
view
|
|
|
|
|
|> element("button", "Collection")
|
|
|
|
|
|> render_click()
|
|
|
|
|
|
feat: add preview page templates with theme styling
Implement all 7 preview pages showcasing theme customization:
- Home page: hero, featured products, testimonials, categories
- Collection page: product grid with filters and sorting
- Product detail page (PDP): gallery, variants, add to cart
- Cart page: cart items with quantity controls and order summary
- About page: company story and values
- Contact page: contact form and business information
- 404 error page: error message with product suggestions
Features:
- All pages use CSS custom properties for theming
- Preview data from PreviewData module (mock products, testimonials, categories)
- Responsive layouts with Tailwind utilities
- Grid columns respect theme settings
- Colors, typography, shapes, and spacing all theme-aware
- Components created as embed_templates for clean separation
Technical implementation:
- Created PreviewPages component module with embed_templates
- Wired up preview_data in LiveView mount
- Updated index.html.heex to render preview pages based on @preview_page
- All pages styled with inline styles using CSS variables
- Scrollable preview frame with max-height
All tests passing (197 total).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 22:06:04 +00:00
|
|
|
assert html =~ "All Products"
|
feat: add Theme LiveView with preset switching
Implement basic theme editor interface with live preview:
- ThemeLive.Index LiveView with mount and event handlers
- Two-column layout: controls sidebar + preview area
- Display all 9 presets as clickable buttons
- Apply preset and regenerate CSS on click
- Show current theme settings (mood, typography, shape, density, color)
- Preview page switcher (7 pages: home, collection, product, cart, about, contact, 404)
- Inline <style> tag with generated CSS for instant preview
- Basic preview frame showing theme variables in action
- Authentication required via :require_authenticated_user pipeline
- Theme navigation link added to user menu
- 9 comprehensive LiveView tests
All tests passing (197 total).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 21:53:52 +00:00
|
|
|
end
|
|
|
|
|
|
2026-01-15 22:36:15 +00:00
|
|
|
test "theme settings are saved when applying a preset", %{conn: conn} do
|
feat: add Theme LiveView with preset switching
Implement basic theme editor interface with live preview:
- ThemeLive.Index LiveView with mount and event handlers
- Two-column layout: controls sidebar + preview area
- Display all 9 presets as clickable buttons
- Apply preset and regenerate CSS on click
- Show current theme settings (mood, typography, shape, density, color)
- Preview page switcher (7 pages: home, collection, product, cart, about, contact, 404)
- Inline <style> tag with generated CSS for instant preview
- Basic preview frame showing theme variables in action
- Authentication required via :require_authenticated_user pipeline
- Theme navigation link added to user menu
- 9 comprehensive LiveView tests
All tests passing (197 total).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 21:53:52 +00:00
|
|
|
{:ok, view, _html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
2026-01-15 22:36:15 +00:00
|
|
|
# Apply a preset
|
feat: add Theme LiveView with preset switching
Implement basic theme editor interface with live preview:
- ThemeLive.Index LiveView with mount and event handlers
- Two-column layout: controls sidebar + preview area
- Display all 9 presets as clickable buttons
- Apply preset and regenerate CSS on click
- Show current theme settings (mood, typography, shape, density, color)
- Preview page switcher (7 pages: home, collection, product, cart, about, contact, 404)
- Inline <style> tag with generated CSS for instant preview
- Basic preview frame showing theme variables in action
- Authentication required via :require_authenticated_user pipeline
- Theme navigation link added to user menu
- 9 comprehensive LiveView tests
All tests passing (197 total).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 21:53:52 +00:00
|
|
|
view
|
2026-01-15 22:36:15 +00:00
|
|
|
|> element("button", "gallery")
|
feat: add Theme LiveView with preset switching
Implement basic theme editor interface with live preview:
- ThemeLive.Index LiveView with mount and event handlers
- Two-column layout: controls sidebar + preview area
- Display all 9 presets as clickable buttons
- Apply preset and regenerate CSS on click
- Show current theme settings (mood, typography, shape, density, color)
- Preview page switcher (7 pages: home, collection, product, cart, about, contact, 404)
- Inline <style> tag with generated CSS for instant preview
- Basic preview frame showing theme variables in action
- Authentication required via :require_authenticated_user pipeline
- Theme navigation link added to user menu
- 9 comprehensive LiveView tests
All tests passing (197 total).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 21:53:52 +00:00
|
|
|
|> render_click()
|
|
|
|
|
|
2026-01-15 22:36:15 +00:00
|
|
|
# Verify settings were persisted
|
|
|
|
|
theme_settings = Settings.get_theme_settings()
|
|
|
|
|
assert theme_settings.mood == "warm"
|
|
|
|
|
assert theme_settings.typography == "editorial"
|
feat: add Theme LiveView with preset switching
Implement basic theme editor interface with live preview:
- ThemeLive.Index LiveView with mount and event handlers
- Two-column layout: controls sidebar + preview area
- Display all 9 presets as clickable buttons
- Apply preset and regenerate CSS on click
- Show current theme settings (mood, typography, shape, density, color)
- Preview page switcher (7 pages: home, collection, product, cart, about, contact, 404)
- Inline <style> tag with generated CSS for instant preview
- Basic preview frame showing theme variables in action
- Authentication required via :require_authenticated_user pipeline
- Theme navigation link added to user menu
- 9 comprehensive LiveView tests
All tests passing (197 total).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 21:53:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "all preview page buttons are present", %{conn: conn} do
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
|
|
|
|
assert html =~ "Home"
|
|
|
|
|
assert html =~ "Collection"
|
|
|
|
|
assert html =~ "Product"
|
|
|
|
|
assert html =~ "Cart"
|
|
|
|
|
assert html =~ "About"
|
|
|
|
|
assert html =~ "Contact"
|
|
|
|
|
assert html =~ "404"
|
|
|
|
|
end
|
2025-12-31 00:24:53 +00:00
|
|
|
|
|
|
|
|
test "mood customization buttons work", %{conn: conn} do
|
|
|
|
|
{:ok, view, _html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
|
|
|
|
# Click the "dark" mood button
|
|
|
|
|
html =
|
|
|
|
|
view
|
2026-01-15 22:36:15 +00:00
|
|
|
|> element("button[phx-value-setting_value='dark']")
|
2025-12-31 00:24:53 +00:00
|
|
|
|> render_click()
|
|
|
|
|
|
|
|
|
|
# Verify the setting was updated
|
|
|
|
|
theme_settings = Settings.get_theme_settings()
|
|
|
|
|
assert theme_settings.mood == "dark"
|
|
|
|
|
assert html =~ "dark"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "shape customization buttons work", %{conn: conn} do
|
|
|
|
|
{:ok, view, _html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
|
|
|
|
# Click the "round" shape button
|
|
|
|
|
view
|
2026-01-15 22:36:15 +00:00
|
|
|
|> element("button[phx-value-setting_value='round']")
|
2025-12-31 00:24:53 +00:00
|
|
|
|> render_click()
|
|
|
|
|
|
|
|
|
|
# Verify the setting was updated
|
|
|
|
|
theme_settings = Settings.get_theme_settings()
|
|
|
|
|
assert theme_settings.shape == "round"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "density customization buttons work", %{conn: conn} do
|
|
|
|
|
{:ok, view, _html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
|
|
|
|
# Click the "compact" density button
|
|
|
|
|
view
|
2026-01-15 22:36:15 +00:00
|
|
|
|> element("button[phx-value-setting_value='compact']")
|
2025-12-31 00:24:53 +00:00
|
|
|
|> render_click()
|
|
|
|
|
|
|
|
|
|
# Verify the setting was updated
|
|
|
|
|
theme_settings = Settings.get_theme_settings()
|
|
|
|
|
assert theme_settings.density == "compact"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "grid columns customization buttons work", %{conn: conn} do
|
|
|
|
|
{:ok, view, _html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
2026-01-15 22:36:15 +00:00
|
|
|
# Click the "2 columns" grid columns button
|
2025-12-31 00:24:53 +00:00
|
|
|
view
|
2026-01-15 22:36:15 +00:00
|
|
|
|> element("button", "2 columns")
|
2025-12-31 00:24:53 +00:00
|
|
|
|> render_click()
|
|
|
|
|
|
|
|
|
|
# Verify the setting was updated
|
|
|
|
|
theme_settings = Settings.get_theme_settings()
|
|
|
|
|
assert theme_settings.grid_columns == "2"
|
|
|
|
|
end
|
|
|
|
|
|
2026-01-15 22:36:15 +00:00
|
|
|
test "typography customization buttons work", %{conn: conn} do
|
2025-12-31 00:24:53 +00:00
|
|
|
{:ok, view, _html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
2026-01-15 22:36:15 +00:00
|
|
|
# Click the "modern" typography button
|
2025-12-31 00:24:53 +00:00
|
|
|
view
|
2026-01-15 22:36:15 +00:00
|
|
|
|> element("button[phx-value-setting_value='modern']")
|
|
|
|
|
|> render_click()
|
2025-12-31 00:24:53 +00:00
|
|
|
|
|
|
|
|
# Verify the setting was updated
|
|
|
|
|
theme_settings = Settings.get_theme_settings()
|
|
|
|
|
assert theme_settings.typography == "modern"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "header layout customization buttons work", %{conn: conn} do
|
|
|
|
|
{:ok, view, _html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
|
|
|
|
# Click the "centered" header layout button
|
|
|
|
|
view
|
2026-01-15 22:36:15 +00:00
|
|
|
|> element("button[phx-value-setting_value='centered']")
|
2025-12-31 00:24:53 +00:00
|
|
|
|> render_click()
|
|
|
|
|
|
|
|
|
|
# Verify the setting was updated
|
|
|
|
|
theme_settings = Settings.get_theme_settings()
|
|
|
|
|
assert theme_settings.header_layout == "centered"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "CSS regenerates when settings change", %{conn: conn} do
|
|
|
|
|
{:ok, view, html} = live(conn, ~p"/admin/theme")
|
|
|
|
|
|
|
|
|
|
# Capture initial CSS
|
|
|
|
|
initial_css = html
|
|
|
|
|
|
|
|
|
|
# Change a setting
|
|
|
|
|
new_html =
|
|
|
|
|
view
|
2026-01-15 22:36:15 +00:00
|
|
|
|> element("button[phx-value-setting_value='dark']")
|
2025-12-31 00:24:53 +00:00
|
|
|
|> render_click()
|
|
|
|
|
|
2026-01-15 22:36:15 +00:00
|
|
|
# Verify CSS has changed
|
2025-12-31 00:24:53 +00:00
|
|
|
refute initial_css == new_html
|
2026-01-15 22:36:15 +00:00
|
|
|
assert new_html =~ "--t-accent-h:"
|
2025-12-31 00:24:53 +00:00
|
|
|
end
|
feat: add Theme LiveView with preset switching
Implement basic theme editor interface with live preview:
- ThemeLive.Index LiveView with mount and event handlers
- Two-column layout: controls sidebar + preview area
- Display all 9 presets as clickable buttons
- Apply preset and regenerate CSS on click
- Show current theme settings (mood, typography, shape, density, color)
- Preview page switcher (7 pages: home, collection, product, cart, about, contact, 404)
- Inline <style> tag with generated CSS for instant preview
- Basic preview frame showing theme variables in action
- Authentication required via :require_authenticated_user pipeline
- Theme navigation link added to user menu
- 9 comprehensive LiveView tests
All tests passing (197 total).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 21:53:52 +00:00
|
|
|
end
|
|
|
|
|
end
|