Skip to content

Commit

Permalink
tests: boxes: Ensure recipient box when editing is not writeable.
Browse files Browse the repository at this point in the history
Co-authored-by: zormit <[email protected]>
  • Loading branch information
Subhasish-Behera and zormit committed May 24, 2024
1 parent abab4f4 commit 9b5ca86
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/ui_tools/test_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest
from pytest import param as case
from pytest_mock import MockerFixture
from urwid import Widget
from urwid import Text, Widget
from urwid_readline import ReadlineEdit

from zulipterminal.api_types import (
Expand Down Expand Up @@ -1704,7 +1704,10 @@ def test_keypress_CYCLE_COMPOSE_FOCUS(
else:
write_box.stream_box_view(stream_id)
else:
write_box.private_box_view()
if message_being_edited:
write_box.private_box_edit_view()
else:
write_box.private_box_view()
size = widget_size(write_box)

def focus_val(x: str) -> int:
Expand All @@ -1730,6 +1733,7 @@ def focus_val(x: str) -> int:
expected_focus_col_name
)

@pytest.mark.parametrize("message_being_edited", [(True), (False)])
@pytest.mark.parametrize(
"recipient_ids, expected_recipient_text",
[
Expand All @@ -1749,14 +1753,19 @@ def test_private_box_recipient_editing(
user_id_email_dict: Dict[int, str],
recipient_ids: List[int],
expected_recipient_text: str,
message_being_edited: bool,
) -> None:
write_box.model.user_id_email_dict = user_id_email_dict
write_box.model.user_dict = user_dict
mocker.patch("urwid.connect_signal")

write_box.private_box_view(recipient_user_ids=recipient_ids)
if message_being_edited:
write_box.private_box_edit_view(recipient_user_ids=recipient_ids)
assert isinstance(write_box.to_write_box, Text)
else:
write_box.private_box_view(recipient_user_ids=recipient_ids)
assert isinstance(write_box.to_write_box, ReadlineEdit)

assert isinstance(write_box.to_write_box, ReadlineEdit)
assert write_box.to_write_box.text == expected_recipient_text

@pytest.mark.parametrize("key", keys_for_command("MARKDOWN_HELP"))
Expand Down

0 comments on commit 9b5ca86

Please sign in to comment.