test: add settings → CSS cache invalidation test
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 <noreply@anthropic.com>
This commit is contained in:
parent
7c02323bf4
commit
8eda40f175
@ -63,6 +63,31 @@ defmodule SimpleshopTheme.SettingsTest do
|
|||||||
assert settings.typography == "editorial"
|
assert settings.typography == "editorial"
|
||||||
end
|
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
|
test "validates mood values" do
|
||||||
{:error, changeset} = Settings.update_theme_settings(%{mood: "invalid"})
|
{:error, changeset} = Settings.update_theme_settings(%{mood: "invalid"})
|
||||||
assert "is invalid" in errors_on(changeset).mood
|
assert "is invalid" in errors_on(changeset).mood
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user