@@ -237,6 +237,7 @@ def test_register_initial_desired_events(self, mocker, initial_data):
237
237
"message" ,
238
238
"update_message" ,
239
239
"reaction" ,
240
+ "submessage" ,
240
241
"subscription" ,
241
242
"typing" ,
242
243
"update_message_flags" ,
@@ -2913,6 +2914,214 @@ def test__handle_reaction_event_for_msg_in_index(
2913
2914
2914
2915
model ._update_rendered_view .assert_called_once_with (event_message_id )
2915
2916
2917
+ @pytest .mark .parametrize (
2918
+ "submessages, event, expected_updated_submessage" ,
2919
+ [
2920
+ case (
2921
+ [
2922
+ {
2923
+ "id" : 1 ,
2924
+ "message_id" : 1958326 ,
2925
+ "sender_id" : 27294 ,
2926
+ "msg_type" : "widget" ,
2927
+ "content" : '{"widget_type": "todo", "extra_data": '
2928
+ '{"task_list_title": "Today\' s Work", "tasks": [{"task"'
2929
+ ': "Handle submessages events on ZT", "desc": ""}, {"task": '
2930
+ '"Play ping pong", "desc": ""}]}}' ,
2931
+ }
2932
+ ],
2933
+ {
2934
+ "type" : "submessage" ,
2935
+ "msg_type" : "widget" ,
2936
+ "message_id" : 1958326 ,
2937
+ "submessage_id" : 1 ,
2938
+ "sender_id" : 27294 ,
2939
+ "content" : '{"type":"strike","key":"0,canned"}' ,
2940
+ "id" : 1 ,
2941
+ },
2942
+ [
2943
+ {
2944
+ "id" : 1 ,
2945
+ "message_id" : 1958326 ,
2946
+ "sender_id" : 27294 ,
2947
+ "msg_type" : "widget" ,
2948
+ "content" : '{"widget_type": "todo", "extra_data": '
2949
+ '{"task_list_title": "Today\' s Work", "tasks": '
2950
+ '[{"task": "Handle submessages events on ZT", "desc": ""}, '
2951
+ '{"task": "Play ping pong", "desc": ""}]}}' ,
2952
+ },
2953
+ {
2954
+ "type" : "submessage" ,
2955
+ "msg_type" : "widget" ,
2956
+ "message_id" : 1958326 ,
2957
+ "submessage_id" : 1 ,
2958
+ "sender_id" : 27294 ,
2959
+ "content" : '{"type":"strike","key":"0,canned"}' ,
2960
+ "id" : 1 ,
2961
+ },
2962
+ ],
2963
+ id = "submessage_strike_event_todo_widget" ,
2964
+ ),
2965
+ case (
2966
+ [
2967
+ {
2968
+ "id" : 1 ,
2969
+ "message_id" : 1958326 ,
2970
+ "sender_id" : 27294 ,
2971
+ "msg_type" : "widget" ,
2972
+ "content" : '{"widget_type": "todo", "extra_data": '
2973
+ '{"task_list_title": "Today\' s Work", "tasks": [{"task": '
2974
+ '"Handle submessages events on ZT", "desc": ""}, {"task": '
2975
+ '"Play ping pong", "desc": ""}]}}' ,
2976
+ },
2977
+ {
2978
+ "id" : 12154 ,
2979
+ "message_id" : 1958326 ,
2980
+ "sender_id" : 27294 ,
2981
+ "msg_type" : "widget" ,
2982
+ "content" : '{"type":"strike","key":"0,canned"}' ,
2983
+ },
2984
+ ],
2985
+ {
2986
+ "type" : "submessage" ,
2987
+ "msg_type" : "widget" ,
2988
+ "message_id" : 1958326 ,
2989
+ "submessage_id" : 12185 ,
2990
+ "sender_id" : 27294 ,
2991
+ "content" : '{"type":"new_task","key":2,"task":"Make a coffee",'
2992
+ '"desc":"","completed":false}' ,
2993
+ "id" : 0 ,
2994
+ },
2995
+ [
2996
+ {
2997
+ "id" : 1 ,
2998
+ "message_id" : 1958326 ,
2999
+ "sender_id" : 27294 ,
3000
+ "msg_type" : "widget" ,
3001
+ "content" : '{"widget_type": "todo", "extra_data": '
3002
+ '{"task_list_title": "Today\' s Work", "tasks": [{"task": '
3003
+ '"Handle submessages events on ZT", "desc": ""}, {"task": '
3004
+ '"Play ping pong", "desc": ""}]}}' ,
3005
+ },
3006
+ {
3007
+ "id" : 12154 ,
3008
+ "message_id" : 1958326 ,
3009
+ "sender_id" : 27294 ,
3010
+ "msg_type" : "widget" ,
3011
+ "content" : '{"type":"strike","key":"0,canned"}' ,
3012
+ },
3013
+ {
3014
+ "type" : "submessage" ,
3015
+ "msg_type" : "widget" ,
3016
+ "message_id" : 1958326 ,
3017
+ "submessage_id" : 12185 ,
3018
+ "sender_id" : 27294 ,
3019
+ "content" : '{"type":"new_task","key":2,"task":"Make a coffee",'
3020
+ '"desc":"","completed":false}' ,
3021
+ "id" : 0 ,
3022
+ },
3023
+ ],
3024
+ id = "submessage_new_task_event_todo_widget" ,
3025
+ ),
3026
+ case (
3027
+ [
3028
+ {
3029
+ "id" : 12153 ,
3030
+ "message_id" : 1958326 ,
3031
+ "sender_id" : 27294 ,
3032
+ "msg_type" : "widget" ,
3033
+ "content" : '{"widget_type": "todo", "extra_data": '
3034
+ '{"task_list_title": "Today\' s Work", "tasks": [{"task": '
3035
+ '"Handle submessages events on ZT", "desc": ""}, {"task": '
3036
+ '"Play ping pong", "desc": ""}]}}' ,
3037
+ },
3038
+ {
3039
+ "id" : 12154 ,
3040
+ "message_id" : 1958326 ,
3041
+ "sender_id" : 27294 ,
3042
+ "msg_type" : "widget" ,
3043
+ "content" : '{"type":"strike","key":"0,canned"}' ,
3044
+ },
3045
+ {
3046
+ "type" : "submessage" ,
3047
+ "msg_type" : "widget" ,
3048
+ "message_id" : 1958326 ,
3049
+ "submessage_id" : 12185 ,
3050
+ "sender_id" : 27294 ,
3051
+ "content" : '{"type":"new_task","key":2,"task":"Make a coffee"'
3052
+ ',"desc":"","completed":false}' ,
3053
+ "id" : 0 ,
3054
+ },
3055
+ ],
3056
+ {
3057
+ "type" : "submessage" ,
3058
+ "msg_type" : "widget" ,
3059
+ "message_id" : 1958326 ,
3060
+ "submessage_id" : 12186 ,
3061
+ "sender_id" : 27294 ,
3062
+ "content" : '{"type":"new_task_list_title","title":"Today\' s Work '
3063
+ '[Updated]"}' ,
3064
+ "id" : 11 ,
3065
+ },
3066
+ [
3067
+ {
3068
+ "id" : 12153 ,
3069
+ "message_id" : 1958326 ,
3070
+ "sender_id" : 27294 ,
3071
+ "msg_type" : "widget" ,
3072
+ "content" : '{"widget_type": "todo", "extra_data": '
3073
+ '{"task_list_title": "Today\' s Work", "tasks": [{"task": '
3074
+ '"Handle submessages events on ZT", "desc": ""}, {"task": '
3075
+ '"Play ping pong", "desc": ""}]}}' ,
3076
+ },
3077
+ {
3078
+ "id" : 12154 ,
3079
+ "message_id" : 1958326 ,
3080
+ "sender_id" : 27294 ,
3081
+ "msg_type" : "widget" ,
3082
+ "content" : '{"type":"strike","key":"0,canned"}' ,
3083
+ },
3084
+ {
3085
+ "type" : "submessage" ,
3086
+ "msg_type" : "widget" ,
3087
+ "message_id" : 1958326 ,
3088
+ "submessage_id" : 12185 ,
3089
+ "sender_id" : 27294 ,
3090
+ "content" : '{"type":"new_task","key":2,"task":"Make a coffee"'
3091
+ ',"desc":"","completed":false}' ,
3092
+ "id" : 0 ,
3093
+ },
3094
+ {
3095
+ "type" : "submessage" ,
3096
+ "msg_type" : "widget" ,
3097
+ "message_id" : 1958326 ,
3098
+ "submessage_id" : 12186 ,
3099
+ "sender_id" : 27294 ,
3100
+ "content" : '{"type":"new_task_list_title",'
3101
+ '"title":"Today\' s Work [Updated]"}' ,
3102
+ "id" : 11 ,
3103
+ },
3104
+ ],
3105
+ id = "submessage_new_task_list_title_event_todo_widget" ,
3106
+ ),
3107
+ ],
3108
+ )
3109
+ def test__handle_submessage_event (
3110
+ self ,
3111
+ mocker ,
3112
+ model ,
3113
+ submessages ,
3114
+ event ,
3115
+ expected_updated_submessage ,
3116
+ id = 1958326 ,
3117
+ ):
3118
+ model .index ["messages" ][id ]["submessages" ] = submessages
3119
+ model ._update_rendered_view = mocker .Mock ()
3120
+
3121
+ model ._handle_submessage_event (event )
3122
+
3123
+ assert model .index ["messages" ][id ]["submessages" ] == expected_updated_submessage
3124
+
2916
3125
@pytest .fixture (
2917
3126
params = [
2918
3127
("op" , 32 ), # At server feature level 32, event uses standard field
0 commit comments