From 29fb94449455bce5ed7fa8b1d924f5d24031ba43 Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Tue, 24 Mar 2026 22:26:57 +0300 Subject: [PATCH] fix: resolve test pollution from freeze_saves and fix os_listener toggle - Add unfreeze_saves() to base_store.py and call it in e2e cleanup. The backup restore flow calls freeze_saves() which sets a module-level flag that silently disables all store _save() calls. Without reset, this poisoned all subsequent persistence tests (9 failures). - Fix os_listener toggle to use toggle-switch/toggle-slider CSS classes instead of nonexistent switch/slider classes (was showing plain checkbox). - Add mandatory test run to CLAUDE.md pre-commit checks. All 341 tests now pass. --- CLAUDE.md | 5 +++-- server/src/wled_controller/storage/base_store.py | 6 ++++++ server/src/wled_controller/templates/modals/css-editor.html | 4 ++-- server/tests/e2e/conftest.py | 5 +++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 06b3b5f..0ff977e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -76,13 +76,14 @@ Plain HTML selects break the visual consistency of the UI. ## Pre-Commit Checks (MANDATORY) -Before every commit, run the relevant linters and fix any issues: +Before every commit, run the relevant checks and fix any issues: - **Python changes**: `cd server && ruff check src/ tests/ --fix` - **TypeScript changes**: `cd server && npx tsc --noEmit && npm run build` - **Both**: Run both checks +- **Always run tests**: `cd server && py -3.13 -m pytest tests/ --no-cov -q` — all tests MUST pass before committing. Do NOT commit code that fails tests. -Do NOT commit code that fails linting. Fix the issues first. +Do NOT commit code that fails linting or tests. Fix the issues first. ## General Guidelines diff --git a/server/src/wled_controller/storage/base_store.py b/server/src/wled_controller/storage/base_store.py index 6b2a2e0..7ba6c32 100644 --- a/server/src/wled_controller/storage/base_store.py +++ b/server/src/wled_controller/storage/base_store.py @@ -24,6 +24,12 @@ def freeze_saves() -> None: logger.info("Store saves frozen — awaiting server restart") +def unfreeze_saves() -> None: + """Re-enable store saves (used in tests to reset after restore flow).""" + global _saves_frozen + _saves_frozen = False + + class EntityNotFoundError(ValueError): """Raised when an entity is not found in the store.""" pass diff --git a/server/src/wled_controller/templates/modals/css-editor.html b/server/src/wled_controller/templates/modals/css-editor.html index 2a34ba5..9378ca8 100644 --- a/server/src/wled_controller/templates/modals/css-editor.html +++ b/server/src/wled_controller/templates/modals/css-editor.html @@ -381,9 +381,9 @@ -