Some checks failed
Release & Docker / release (push) Has been cancelled
* feat(sidebar): add show_cron_sessions toggle to surface cron sessions (#3514, #2841) Co-authored-by: Rod Boev <rod.boev@gmail.com> * feat(sidebar): add manual session status labels (#3570) Co-authored-by: Rod Boev <rod.boev@gmail.com> * docs(changelog): v0.51.284 — Release IZ (stage-w4) * fix(settings): persist show_cron_sessions in the explicit Save Settings path too (#3514) Codex regression-gate follow-up: the autosave path (_preferencesPayloadFromUi) included show_cron_sessions but the explicit saveSettings() button path read/saved show_cli_sessions and dropped the cron checkbox — clicking Save Settings silently omitted it. Read settingsShowCronSessions + add body.show_cron_sessions (gated on CLI sessions, mirroring autosave). * fix(settings): gate show_cron_sessions identically in BOTH save paths (#3514) Codex round-2: my saveSettings() gate exposed that the autosave path (_preferencesPayloadFromUi) posted the raw cron checkbox state ungated, so show_cli_sessions=false + show_cron_sessions=true could persist via autosave. Gate autosave on showCliCb too; update the regression test to assert both paths gate on settingsShowCliSessions. --------- Co-authored-by: nesquena-hermes <[email protected]> Co-authored-by: Rod Boev <rod.boev@gmail.com>
89 lines
3.0 KiB
Python
89 lines
3.0 KiB
Python
"""Tests for #2841: show_cron_sessions toggle to surface cron sessions in the sidebar."""
|
|
import pathlib
|
|
|
|
from api.models import _hide_from_default_sidebar
|
|
|
|
ROOT = pathlib.Path(__file__).parent.parent
|
|
|
|
|
|
def _read(rel):
|
|
return (ROOT / rel).read_text(encoding="utf-8")
|
|
|
|
|
|
# --- _hide_from_default_sidebar behaviour ---
|
|
|
|
def test_cron_hidden_by_default():
|
|
assert _hide_from_default_sidebar({'source_tag': 'cron', 'session_id': 'cron_abc'}) is True
|
|
|
|
|
|
def test_cron_visible_when_show_cron_true():
|
|
assert _hide_from_default_sidebar({'source_tag': 'cron', 'session_id': 'cron_abc'}, show_cron=True) is False
|
|
|
|
|
|
def test_pre_compression_always_hidden_regardless_of_show_cron():
|
|
assert _hide_from_default_sidebar({'pre_compression_snapshot': True}, show_cron=True) is True
|
|
|
|
|
|
def test_cron_hidden_with_explicit_false():
|
|
assert _hide_from_default_sidebar({'source_tag': 'cron', 'session_id': 'cron_abc'}, show_cron=False) is True
|
|
|
|
|
|
# --- api/config.py string-scan ---
|
|
|
|
def test_show_cron_sessions_in_defaults():
|
|
src = _read("api/config.py")
|
|
assert '"show_cron_sessions": False' in src, (
|
|
'"show_cron_sessions": False must appear in _SETTINGS_DEFAULTS'
|
|
)
|
|
|
|
|
|
def test_show_cron_sessions_in_bool_keys():
|
|
src = _read("api/config.py")
|
|
assert '"show_cron_sessions"' in src, (
|
|
'"show_cron_sessions" must appear in _SETTINGS_BOOL_KEYS'
|
|
)
|
|
# Verify it appears at least twice: once in _SETTINGS_DEFAULTS, once in _SETTINGS_BOOL_KEYS
|
|
assert src.count('"show_cron_sessions"') >= 2, (
|
|
'"show_cron_sessions" must appear in both _SETTINGS_DEFAULTS and _SETTINGS_BOOL_KEYS'
|
|
)
|
|
|
|
|
|
# --- api/routes.py string-scan ---
|
|
|
|
def test_show_cron_sessions_kwarg_passthrough():
|
|
src = _read("api/routes.py")
|
|
assert "show_cron_sessions=show_cron_sessions" in src, (
|
|
"show_cron_sessions kwarg must be forwarded at the _dedupe_cli_sidebar_sessions_for_api call site"
|
|
)
|
|
|
|
|
|
# --- static/index.html string-scan ---
|
|
|
|
def test_settings_show_cron_sessions_in_html():
|
|
src = _read("static/index.html")
|
|
assert "settingsShowCronSessions" in src, (
|
|
"settingsShowCronSessions checkbox must appear in static/index.html"
|
|
)
|
|
|
|
|
|
# --- static/panels.js string-scans ---
|
|
|
|
def test_panels_save_wiring():
|
|
src = _read("static/panels.js")
|
|
# Both save paths (autosave _preferencesPayloadFromUi + explicit saveSettings)
|
|
# must gate cron sessions on the CLI-sessions checkbox so neither can persist
|
|
# show_cron_sessions=true while show_cli_sessions=false (#3514).
|
|
assert "payload.show_cron_sessions=!!(showCliCb&&showCliCb.checked&&showCronCb.checked)" in src, (
|
|
"autosave wiring must gate show_cron_sessions on settingsShowCliSessions in static/panels.js"
|
|
)
|
|
assert "body.show_cron_sessions=showCliSessions&&showCronSessions" in src, (
|
|
"explicit saveSettings() must gate show_cron_sessions on showCliSessions in static/panels.js"
|
|
)
|
|
|
|
|
|
def test_panels_load_wiring():
|
|
src = _read("static/panels.js")
|
|
assert "show_cron_sessions" in src, (
|
|
"load wiring for show_cron_sessions must appear in static/panels.js"
|
|
)
|