Skip to content

Commit

Permalink
widget: Add support for updating title in process_todo_widget.
Browse files Browse the repository at this point in the history
Updated tests.
  • Loading branch information
rsashank authored and Ajnus committed Nov 14, 2024
1 parent 955355a commit 7190535
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/widget/test_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,53 @@ def test_find_widget_type(
},
id="title_and_description_and_finished_tasks",
),
case(
[
{
"id": 12143,
"message_id": 1958318,
"sender_id": 27294,
"msg_type": "widget",
"content": (
'{"widget_type": "todo", "extra_data": {'
'"task_list_title": "Today\'s Work", "tasks": [{"task": '
'"Update todo titles on ZT", "desc": ""}, '
'{"task": "Push todo update", "desc": ""}]}}'
),
},
{
"id": 12144,
"message_id": 1958318,
"sender_id": 27294,
"msg_type": "widget",
"content": (
'{"type":"new_task_list_title",'
'"title":"Today\'s Work [Updated]"}'
),
},
{
"id": 12145,
"message_id": 1958318,
"sender_id": 27294,
"msg_type": "widget",
"content": '{"type":"strike","key":"0,canned"}',
},
],
"Today's Work [Updated]",
{
"0,canned": {
"task": "Update todo titles on ZT",
"desc": "",
"completed": True,
},
"1,canned": {
"task": "Push todo update",
"desc": "",
"completed": False,
},
},
id="updated_title_and_finished_tasks",
),
],
)
def test_process_todo_widget(
Expand Down
3 changes: 3 additions & 0 deletions zulipterminal/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@ def process_todo_widget(
if task_id in tasks:
tasks[task_id]["completed"] = not tasks[task_id]["completed"]

elif widget.get("type") == "new_task_list_title":
title = widget["title"]

return title, tasks

0 comments on commit 7190535

Please sign in to comment.