Added a theme selector

This commit is contained in:
2026-08-26 12:54:38 +02:00
parent fec4c8def5
commit 72a4741cac
19 changed files with 305 additions and 9 deletions
+28 -1
View File
@@ -62,9 +62,25 @@ def test_configuration_requires_authentication_and_admin_role():
assert client.get('/api/admin/smtp', headers=login_headers('bob')).status_code == 403
def test_admin_can_select_multiple_themes():
headers = login_headers()
response = client.put('/api/admin/themes', headers=headers, json={
'themes': ['plain-day', 'plain-night', 'latte', 'frappe', 'macchiato', 'mocha', 'dracula', 'nord', 'solarized'],
})
assert response.status_code == 200
assert response.json()['enabled'] == ['plain-day', 'plain-night', 'latte', 'frappe', 'macchiato', 'mocha', 'dracula', 'nord', 'solarized']
public_response = client.get('/api/public/themes')
assert public_response.status_code == 200
assert [theme['id'] for theme in public_response.json()] == response.json()['enabled']
assert client.put('/api/admin/themes', headers=headers, json={'themes': []}).status_code == 422
def test_admin_can_save_and_validate_smtp_settings():
headers = login_headers()
original = get_smtp_settings()
with get_connection() as conn:
original_row = conn.execute('SELECT value FROM app_settings WHERE name = ?', ('smtp',)).fetchone()
response = client.put('/api/admin/smtp', headers=headers, json={
'smtp_host': 'smtp.example.com',
'smtp_port': 587,
@@ -97,7 +113,18 @@ def test_admin_can_save_and_validate_smtp_settings():
'smtp_use_tls': False,
})
client.put('/api/admin/smtp', headers=headers, json=original)
with get_connection() as conn:
if original_row is None:
conn.execute('DELETE FROM app_settings WHERE name = ?', ('smtp',))
else:
conn.execute(
'UPDATE app_settings SET value = ?, updated_at = CURRENT_TIMESTAMP WHERE name = ?',
(original_row['value'], 'smtp'),
)
conn.commit()
with get_connection() as conn:
conn.execute('DELETE FROM app_settings WHERE name = ?', ('admin_smtp_mail_rate',))
conn.commit()
def test_admin_reports_smtp_validation_errors():