Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable cycling to recipients when editing PM #1504

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
30 changes: 30 additions & 0 deletions tests/ui_tools/test_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pytest import param as case
from pytest_mock import MockerFixture
from urwid import Widget
from urwid_readline import ReadlineEdit

from zulipterminal.api_types import (
TYPING_STARTED_EXPIRY_PERIOD,
Expand Down Expand Up @@ -1718,6 +1719,35 @@ def focus_val(x: str) -> int:
expected_focus_col_name
)

@pytest.mark.parametrize(
"recipient_ids, expected_recipient_text",
[
([], "To: "),
([11], "To: Human 1 <[email protected]>"),
(
[11, 12],
"To: Human 1 <[email protected]>, Human 2 <[email protected]>",
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test ids could be added, I assume.

],
)
def test_private_box_recipient_editing(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I learnt that sometimes using double underscores in the test function names helps, not sure about this test name in particular. Would test_private_box__recipient_editing be better? We don't have any other tests for private box, yet this is easier to read?

self,
mocker: MockerFixture,
write_box: WriteBox,
user_dict: List[Dict[str, Any]],
user_id_email_dict: Dict[int, str],
recipient_ids: List[int],
expected_recipient_text: str,
) -> 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)

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"))
def test_keypress_MARKDOWN_HELP(
self, write_box: WriteBox, key: str, widget_size: Callable[[Widget], urwid_Size]
Expand Down