mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-13 02:26:37 +00:00
fix(web): legacy plugin-system toggles no longer count as a General save
auto_discover, auto_load_enabled and development_mode have left the General form, so a post carrying only one of them is not a general-settings save and must not treat web_display_autostart and auto_update as unchecked. The plugin_system block itself is left as on main for the branch that reworks it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -92,12 +92,23 @@ class TestJsonPartialSaves:
|
|||||||
assert config['web_display_autostart'] is True
|
assert config['web_display_autostart'] is True
|
||||||
assert config['auto_update'] == {'enabled': True}
|
assert config['auto_update'] == {'enabled': True}
|
||||||
|
|
||||||
def test_location_only_keeps_plugin_system_toggles(self, api_v3_client, saved):
|
def test_location_only_keeps_autostart_and_auto_update(self, api_v3_client, saved):
|
||||||
resp = _post_json(api_v3_client, {'city': 'Paris', 'plugins_directory': 'plugin-repos'})
|
resp = _post_json(api_v3_client, {'city': 'Paris', 'country': 'FR'})
|
||||||
assert resp.status_code == 200, resp.get_json()
|
assert resp.status_code == 200, resp.get_json()
|
||||||
assert saved['config']['plugin_system'] == {
|
config = saved['config']
|
||||||
'auto_discover': True, 'auto_load_enabled': True,
|
assert config['location'] == {'city': 'Paris', 'country': 'FR'}
|
||||||
'development_mode': True, 'plugins_directory': 'plugin-repos'}
|
assert config['web_display_autostart'] is True
|
||||||
|
assert config['auto_update'] == {'enabled': True}
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('key', ['auto_discover', 'auto_load_enabled', 'development_mode'])
|
||||||
|
def test_a_legacy_plugin_system_toggle_is_not_a_general_save(self, api_v3_client, saved, key):
|
||||||
|
# These left the General form; a client still sending one must not
|
||||||
|
# have the general-settings checkboxes treated as unchecked.
|
||||||
|
resp = api_v3_client.post('/api/v3/config/main', data={key: 'on'},
|
||||||
|
content_type='application/x-www-form-urlencoded')
|
||||||
|
assert resp.status_code == 200, resp.get_json()
|
||||||
|
assert saved['config']['web_display_autostart'] is True
|
||||||
|
assert saved['config']['auto_update'] == {'enabled': True}
|
||||||
|
|
||||||
def test_vegas_speed_only_keeps_vegas_toggles(self, api_v3_client, saved):
|
def test_vegas_speed_only_keeps_vegas_toggles(self, api_v3_client, saved):
|
||||||
resp = _post_json(api_v3_client, {'vegas_scroll_speed': 80})
|
resp = _post_json(api_v3_client, {'vegas_scroll_speed': 80})
|
||||||
|
|||||||
@@ -496,8 +496,7 @@ def save_main_config():
|
|||||||
# Note: Checkboxes don't send data when unchecked, so we need to check if we're updating general settings
|
# Note: Checkboxes don't send data when unchecked, so we need to check if we're updating general settings
|
||||||
# If any general setting is present, we're updating the general tab
|
# If any general setting is present, we're updating the general tab
|
||||||
is_general_update = any(k in data for k in ['timezone', 'city', 'state', 'country', 'web_display_autostart',
|
is_general_update = any(k in data for k in ['timezone', 'city', 'state', 'country', 'web_display_autostart',
|
||||||
'auto_discover', 'auto_load_enabled', 'development_mode', 'plugins_directory',
|
'plugins_directory', 'auto_update_enabled'])
|
||||||
'auto_update_enabled'])
|
|
||||||
|
|
||||||
if is_general_update:
|
if is_general_update:
|
||||||
# For checkbox: if not present in data during a general *form*
|
# For checkbox: if not present in data during a general *form*
|
||||||
@@ -560,7 +559,7 @@ def save_main_config():
|
|||||||
# Handle plugin system checkboxes - always set to handle unchecked state
|
# Handle plugin system checkboxes - always set to handle unchecked state
|
||||||
# HTML checkboxes omit the key when unchecked, so missing key = unchecked = False
|
# HTML checkboxes omit the key when unchecked, so missing key = unchecked = False
|
||||||
for checkbox in ['auto_discover', 'auto_load_enabled', 'development_mode']:
|
for checkbox in ['auto_discover', 'auto_load_enabled', 'development_mode']:
|
||||||
_set_checkbox(current_config['plugin_system'], checkbox, checkbox)
|
current_config['plugin_system'][checkbox] = _coerce_to_bool(data.get(checkbox))
|
||||||
|
|
||||||
# Handle plugins_directory
|
# Handle plugins_directory
|
||||||
if 'plugins_directory' in data:
|
if 'plugins_directory' in data:
|
||||||
|
|||||||
Reference in New Issue
Block a user