Skip to content

Commit 433da5e

Browse files
committed
widget: Add handling for updating TODO title.
Updated tests.
1 parent 76f236e commit 433da5e

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

tests/widget/test_widget.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,48 @@ def test_find_widget_type(submessage: Any, expected_widget_type: str) -> None:
259259
},
260260
id="todo_with_title_and_description_and_some_tasks_completed",
261261
),
262+
case(
263+
[
264+
{
265+
"id": 12143,
266+
"message_id": 1958318,
267+
"sender_id": 27294,
268+
"msg_type": "widget",
269+
"content": '{"widget_type": "todo", "extra_data": {'
270+
'"task_list_title": "Today\'s Work", "tasks": [{"task": '
271+
'"Update todo titles on ZT", "desc": ""}, '
272+
'{"task": "Push todo update", "desc": ""}]}}',
273+
},
274+
{
275+
"id": 12144,
276+
"message_id": 1958318,
277+
"sender_id": 27294,
278+
"msg_type": "widget",
279+
"content": '{"type":"new_task_list_title",'
280+
'"title":"Today\'s Work [Updated]"}',
281+
},
282+
{
283+
"id": 12145,
284+
"message_id": 1958318,
285+
"sender_id": 27294,
286+
"msg_type": "widget",
287+
"content": '{"type":"strike","key":"0,canned"}',
288+
},
289+
],
290+
"Today's Work [Updated]",
291+
{
292+
"0,canned": {
293+
"task": "Update todo titles on ZT",
294+
"desc": "",
295+
"completed": True,
296+
},
297+
"1,canned": {
298+
"task": "Push todo update",
299+
"desc": "",
300+
"completed": False,
301+
},
302+
},
303+
),
262304
],
263305
)
264306
def test_process_todo_widget(

zulipterminal/widget.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,7 @@ def process_todo_widget(todo_list: Any) -> Tuple[str, Dict[str, Dict[str, Any]]]
6060
if task_id in tasks:
6161
tasks[task_id]["completed"] = not tasks[task_id]["completed"]
6262

63+
elif widget.get("type") == "new_task_list_title":
64+
title = widget["title"]
65+
6366
return title, tasks

0 commit comments

Comments
 (0)