diff --git a/test/simpleshop_theme/settings_test.exs b/test/simpleshop_theme/settings_test.exs index 10ecb2c..98a8efe 100644 --- a/test/simpleshop_theme/settings_test.exs +++ b/test/simpleshop_theme/settings_test.exs @@ -63,6 +63,31 @@ defmodule SimpleshopTheme.SettingsTest do assert settings.typography == "editorial" end + test "regenerates CSS cache when settings change" do + alias SimpleshopTheme.Theme.CSSCache + + # Get initial cached CSS + {:ok, initial_css} = CSSCache.get() + assert initial_css =~ ".themed {" + + # Update to a different accent color + {:ok, _settings} = Settings.update_theme_settings(%{accent_color: "#ff0000"}) + + # Cache should now contain new CSS with the red accent color + {:ok, updated_css} = CSSCache.get() + assert updated_css =~ ".themed {" + assert updated_css =~ "--t-accent-h: 0" # Red = hue 0 + + # Change to blue + {:ok, _settings} = Settings.update_theme_settings(%{accent_color: "#0000ff"}) + + {:ok, blue_css} = CSSCache.get() + assert blue_css =~ "--t-accent-h: 240" # Blue = hue 240 + + # Restore default + CSSCache.warm() + end + test "validates mood values" do {:error, changeset} = Settings.update_theme_settings(%{mood: "invalid"}) assert "is invalid" in errors_on(changeset).mood