From 8eda40f175ee61a1fcccad57aeb574df10242636 Mon Sep 17 00:00:00 2001 From: Jamey Greenwood Date: Mon, 19 Jan 2026 21:21:08 +0000 Subject: [PATCH] =?UTF-8?q?test:=20add=20settings=20=E2=86=92=20CSS=20cach?= =?UTF-8?q?e=20invalidation=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verifies that updating theme settings regenerates the CSS cache with the new values. Tests accent color changes from red to blue and confirms the correct HSL hue values appear in cached CSS. Co-Authored-By: Claude Opus 4.5 --- test/simpleshop_theme/settings_test.exs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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