Skip to content

Commit 2066b77

Browse files
rsashankneiljp
authored andcommitted
widget: Add support for updating title in process_todo_widget.
Updated tests.
1 parent f547b99 commit 2066b77

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

tests/widget/test_widget.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,53 @@ def test_find_widget_type(
285285
},
286286
id="title_and_description_and_finished_tasks",
287287
),
288+
case(
289+
[
290+
{
291+
"id": 12143,
292+
"message_id": 1958318,
293+
"sender_id": 27294,
294+
"msg_type": "widget",
295+
"content": (
296+
'{"widget_type": "todo", "extra_data": {'
297+
'"task_list_title": "Today\'s Work", "tasks": [{"task": '
298+
'"Update todo titles on ZT", "desc": ""}, '
299+
'{"task": "Push todo update", "desc": ""}]}}'
300+
),
301+
},
302+
{
303+
"id": 12144,
304+
"message_id": 1958318,
305+
"sender_id": 27294,
306+
"msg_type": "widget",
307+
"content": (
308+
'{"type":"new_task_list_title",'
309+
'"title":"Today\'s Work [Updated]"}'
310+
),
311+
},
312+
{
313+
"id": 12145,
314+
"message_id": 1958318,
315+
"sender_id": 27294,
316+
"msg_type": "widget",
317+
"content": '{"type":"strike","key":"0,canned"}',
318+
},
319+
],
320+
"Today's Work [Updated]",
321+
{
322+
"0,canned": {
323+
"task": "Update todo titles on ZT",
324+
"desc": "",
325+
"completed": True,
326+
},
327+
"1,canned": {
328+
"task": "Push todo update",
329+
"desc": "",
330+
"completed": False,
331+
},
332+
},
333+
id="updated_title_and_finished_tasks",
334+
),
288335
],
289336
)
290337
def test_process_todo_widget(

zulipterminal/widget.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,7 @@ def process_todo_widget(
7070
if task_id in tasks:
7171
tasks[task_id]["completed"] = not tasks[task_id]["completed"]
7272

73+
elif widget.get("type") == "new_task_list_title":
74+
title = widget["title"]
75+
7376
return title, tasks

0 commit comments

Comments
 (0)