21
21
)
22
22
from zulipterminal .config .ui_mappings import StreamAccessType
23
23
from zulipterminal .helper import Index , MinimalUserData
24
- from zulipterminal .ui_tools .boxes import PanelSearchBox , WriteBox , _MessageEditState
24
+ from zulipterminal .ui_tools .boxes import (
25
+ MAX_MESSAGE_LENGTH_CONFIRMATION_POPUP ,
26
+ PanelSearchBox ,
27
+ WriteBox ,
28
+ _MessageEditState ,
29
+ )
25
30
from zulipterminal .urwid_types import urwid_Size
26
31
27
32
@@ -232,7 +237,7 @@ def test_not_calling_send_private_message_without_recipients(
232
237
assert not write_box .model .send_private_message .called
233
238
234
239
@pytest .mark .parametrize ("key" , keys_for_command ("GO_BACK" ))
235
- def test__compose_attributes_reset_for_private_compose (
240
+ def test__compose_attributes_reset_for_private_compose__no_popup (
236
241
self ,
237
242
key : str ,
238
243
mocker : MockerFixture ,
@@ -243,17 +248,39 @@ def test__compose_attributes_reset_for_private_compose(
243
248
mocker .patch ("urwid.connect_signal" )
244
249
write_box .model .user_id_email_dict = user_id_email_dict
245
250
write_box .private_box_view (recipient_user_ids = [11 ])
246
- write_box .msg_write_box .edit_text = "random text"
251
+
252
+ write_box .msg_write_box .edit_text = "." * (MAX_MESSAGE_LENGTH_CONFIRMATION_POPUP - 1 )
247
253
248
254
size = widget_size (write_box )
249
255
write_box .keypress (size , key )
250
256
257
+ write_box .view .controller .exit_compose_confirmation_popup .assert_not_called ()
251
258
assert write_box .to_write_box is None
252
259
assert write_box .msg_write_box .edit_text == ""
253
260
assert write_box .compose_box_status == "closed"
254
261
255
262
@pytest .mark .parametrize ("key" , keys_for_command ("GO_BACK" ))
256
- def test__compose_attributes_reset_for_stream_compose (
263
+ def test__compose_attributes_reset_for_private_compose__popup (
264
+ self ,
265
+ key : str ,
266
+ mocker : MockerFixture ,
267
+ write_box : WriteBox ,
268
+ widget_size : Callable [[Widget ], urwid_Size ],
269
+ user_id_email_dict : Dict [int , str ],
270
+ ) -> None :
271
+ mocker .patch ("urwid.connect_signal" )
272
+ write_box .model .user_id_email_dict = user_id_email_dict
273
+ write_box .private_box_view (recipient_user_ids = [11 ])
274
+
275
+ write_box .msg_write_box .edit_text = "." * MAX_MESSAGE_LENGTH_CONFIRMATION_POPUP
276
+
277
+ size = widget_size (write_box )
278
+ write_box .keypress (size , key )
279
+
280
+ write_box .view .controller .exit_compose_confirmation_popup .assert_called_once ()
281
+
282
+ @pytest .mark .parametrize ("key" , keys_for_command ("GO_BACK" ))
283
+ def test__compose_attributes_reset_for_stream_compose__no_popup (
257
284
self ,
258
285
key : str ,
259
286
mocker : MockerFixture ,
@@ -262,15 +289,35 @@ def test__compose_attributes_reset_for_stream_compose(
262
289
) -> None :
263
290
mocker .patch (WRITEBOX + "._set_stream_write_box_style" )
264
291
write_box .stream_box_view (stream_id = 1 )
265
- write_box .msg_write_box .edit_text = "random text"
292
+
293
+ write_box .msg_write_box .edit_text = "." * (MAX_MESSAGE_LENGTH_CONFIRMATION_POPUP - 1 )
266
294
267
295
size = widget_size (write_box )
268
296
write_box .keypress (size , key )
269
297
298
+ write_box .view .controller .exit_compose_confirmation_popup .assert_not_called ()
270
299
assert write_box .stream_id is None
271
300
assert write_box .msg_write_box .edit_text == ""
272
301
assert write_box .compose_box_status == "closed"
273
302
303
+ @pytest .mark .parametrize ("key" , keys_for_command ("GO_BACK" ))
304
+ def test__compose_attributes_reset_for_stream_compose__popup (
305
+ self ,
306
+ key : str ,
307
+ mocker : MockerFixture ,
308
+ write_box : WriteBox ,
309
+ widget_size : Callable [[Widget ], urwid_Size ],
310
+ ) -> None :
311
+ mocker .patch (WRITEBOX + "._set_stream_write_box_style" )
312
+ write_box .stream_box_view (stream_id = 1 )
313
+
314
+ write_box .msg_write_box .edit_text = "." * MAX_MESSAGE_LENGTH_CONFIRMATION_POPUP
315
+
316
+ size = widget_size (write_box )
317
+ write_box .keypress (size , key )
318
+
319
+ write_box .view .controller .exit_compose_confirmation_popup .assert_called_once_with ()
320
+
274
321
@pytest .mark .parametrize (
275
322
["raw_recipients" , "tidied_recipients" ],
276
323
[
@@ -1516,13 +1563,15 @@ def test_keypress_SEND_MESSAGE_no_topic(
1516
1563
)
1517
1564
def test_keypress_typeahead_mode_autocomplete_key (
1518
1565
self ,
1566
+ mocker : MockerFixture ,
1519
1567
write_box : WriteBox ,
1520
1568
widget_size : Callable [[Widget ], urwid_Size ],
1521
1569
current_typeahead_mode : bool ,
1522
1570
expected_typeahead_mode : bool ,
1523
1571
expect_footer_was_reset : bool ,
1524
1572
key : str ,
1525
1573
) -> None :
1574
+ write_box .msg_write_box = mocker .Mock (edit_text = "" )
1526
1575
write_box .is_in_typeahead_mode = current_typeahead_mode
1527
1576
size = widget_size (write_box )
1528
1577
0 commit comments