feat(project): add font options and selected goal text formatting

Restore the board header add button to the task side panel while keeping footer quick entry. Add safe, persisted goal text formatting and self-hosted Project font preferences with shared help updates and regression coverage.
This commit is contained in:
2026-10-02 17:28:54 +09:00
parent 035cb83d6f
commit 20232baf06
39 changed files with 756 additions and 54 deletions
+37
View File
@@ -0,0 +1,37 @@
import json
import unittest
from app.modules.project import store
def rich(runs):
return store.GOAL_RICH_PREFIX + json.dumps(runs, ensure_ascii=False)
class GoalRichTextTests(unittest.TestCase):
def test_selected_styles_are_safe_and_legacy_text_stays_literal(self):
body = rich([{"text": "<img src=x onerror=alert(1)>", "bold": True,
"color": "#FF0000", "size": 20, "onclick": "alert(1)"},
{"text": " untouched", "color": "url(javascript:x)", "size": 99}])
stored = store.validate_goal_text(body)
html = store.goal_text_html(stored)
assert '&lt;img' in html and '<img' not in html
assert 'font-weight:700' in html and 'color:#ff0000' in html and 'font-size:20px' in html
assert 'javascript' not in html and 'onclick' not in stored and '99px' not in html
assert store.goal_text_html('<b>legacy</b>') == '&lt;b&gt;legacy&lt;/b&gt;'
def test_rich_merge_preserves_styles_and_plain_meeting_plan(self):
value = store.merge_goal_texts(['first', rich([{"text": "second", "bold": True, "size": 18}])])
assert store.goal_text_plain(value) == 'first\nsecond'
assert 'font-size:18px' in store.goal_text_html(value)
assert store.merge_goal_texts(['a', 'b']) == 'a\nb'
assert store.validate_goal_text(rich([{"text": " "}])) == ''
def test_rich_payload_limits_and_malformed_data(self):
with self.assertRaises(ValueError):
store.validate_goal_text(rich([{"text": "x" * (store.GOAL_TEXT_MAX + 1)}]))
with self.assertRaises(ValueError):
store.validate_goal_text(store.GOAL_RICH_PREFIX + '{"unexpected":1}')
with self.assertRaises(ValueError):
store.validate_goal_text(store.GOAL_RICH_PREFIX + '[broken')