fix: resolve test pollution from freeze_saves and fix os_listener toggle
All checks were successful
Lint & Test / test (push) Successful in 27s
All checks were successful
Lint & Test / test (push) Successful in 27s
- 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.
This commit is contained in:
@@ -76,13 +76,14 @@ Plain HTML selects break the visual consistency of the UI.
|
|||||||
|
|
||||||
## Pre-Commit Checks (MANDATORY)
|
## 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`
|
- **Python changes**: `cd server && ruff check src/ tests/ --fix`
|
||||||
- **TypeScript changes**: `cd server && npx tsc --noEmit && npm run build`
|
- **TypeScript changes**: `cd server && npx tsc --noEmit && npm run build`
|
||||||
- **Both**: Run both checks
|
- **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
|
## General Guidelines
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,12 @@ def freeze_saves() -> None:
|
|||||||
logger.info("Store saves frozen — awaiting server restart")
|
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):
|
class EntityNotFoundError(ValueError):
|
||||||
"""Raised when an entity is not found in the store."""
|
"""Raised when an entity is not found in the store."""
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -381,9 +381,9 @@
|
|||||||
<button type="button" class="hint-toggle" onclick="toggleHint(this)" title="?" data-i18n-aria-label="aria.hint">?</button>
|
<button type="button" class="hint-toggle" onclick="toggleHint(this)" title="?" data-i18n-aria-label="aria.hint">?</button>
|
||||||
</div>
|
</div>
|
||||||
<small class="input-hint" style="display:none" data-i18n="color_strip.notification.os_listener.hint">When enabled, this source automatically fires when a desktop notification appears (Windows toast / Linux D-Bus). Requires the app to have notification access permission.</small>
|
<small class="input-hint" style="display:none" data-i18n="color_strip.notification.os_listener.hint">When enabled, this source automatically fires when a desktop notification appears (Windows toast / Linux D-Bus). Requires the app to have notification access permission.</small>
|
||||||
<label class="switch">
|
<label class="toggle-switch">
|
||||||
<input type="checkbox" id="css-editor-notification-os-listener">
|
<input type="checkbox" id="css-editor-notification-os-listener">
|
||||||
<span class="slider"></span>
|
<span class="toggle-slider"></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ def client(_test_client):
|
|||||||
|
|
||||||
def _clear_stores():
|
def _clear_stores():
|
||||||
"""Remove all entities from all stores for test isolation."""
|
"""Remove all entities from all stores for test isolation."""
|
||||||
|
# Reset the saves-frozen flag that freeze_saves() sets during restore flows.
|
||||||
|
# Without this, subsequent tests can't persist data because _save() is a no-op.
|
||||||
|
from wled_controller.storage.base_store import unfreeze_saves
|
||||||
|
unfreeze_saves()
|
||||||
|
|
||||||
from wled_controller.api import dependencies as deps
|
from wled_controller.api import dependencies as deps
|
||||||
|
|
||||||
store_clearers = [
|
store_clearers = [
|
||||||
|
|||||||
Reference in New Issue
Block a user