Skip to content

Commit

Permalink
Merge pull request #1 from Ajnus/issue_#1344
Browse files Browse the repository at this point in the history
Issue zulip#1344 (terminal cant find @issuezulip#1344 for cloning and local testing)
  • Loading branch information
Ajnus authored Oct 28, 2024
2 parents dc4d9bc + d9be1c3 commit a780310
Show file tree
Hide file tree
Showing 31 changed files with 165 additions and 165 deletions.
2 changes: 1 addition & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ through autocomplete depend upon the context automatically.
* `P` (with stream color) if the stream is valid and private,
* `` if the stream is invalid.

![PM recipients header](https://user-images.githubusercontent.com/55916430/118403345-9d422800-b68b-11eb-9005-6d2af74adab9.png)
![DM recipients header](https://user-images.githubusercontent.com/55916430/118403345-9d422800-b68b-11eb-9005-6d2af74adab9.png)

**NOTE:** If a direct message recipient's name contains comma(s) (`,`), they
are currently treated as comma-separated recipients.
Expand Down
4 changes: 2 additions & 2 deletions docs/developer-feature-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This tutorial shows how typing indicator was implemented in the client. The process for adding a new feature to zulip terminal varies greatly depending on the feature. This tutorial is intended to make you familiar with the general process.

Since the typing indicator data for the other user in pm cannot be generated locally, it should be received from the client.
Since the typing indicator data for the other user in dm cannot be generated locally, it should be received from the client.

A quick google search for `zulip typing indicator` points to https://zulip.readthedocs.io/en/latest/subsystems/typing-indicators.html. This document explains how typing indicator is implemented on the web client and is useful in understanding how typing indicator works internally.

Expand Down Expand Up @@ -113,7 +113,7 @@ To check for the above conditions, we create a function in `ui.py`:
```python

def handle_typing_event(self, event: Dict['str', Any]) -> None:
# If the user is in pm narrow with the person typing
# If the user is in dm narrow with the person typing
if len(self.model.narrow) == 1 and\
self.model.narrow[0][0] == 'pm_with' and\
event['sender']['email'] in self.model.narrow[0][1].split(','):
Expand Down
File renamed without changes
6 changes: 3 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ If you want to show you agree with the current message, type <kbd>+</kbd> to add

Let's try sending a direct message to the author of a message. Select the message you sent to the [#test here](https://chat.zulip.org/#narrow/stream/7-test-here) stream earlier and press <kbd>shift</kbd><kbd>r</kbd> to send a direct message to yourself. Type your message in the message editor that appears at the bottom of the middle column and then type <kbd>ctrl</kbd><kbd>d</kbd> to send. Press the <kbd>shift</kbd><kbd>p</kbd> hotkey as we did earlier in the tutorial to narrow to your direct messages and make sure everything worked properly.

<img src="getting-started-imgs/send-pm.png" width="85%">
<img src="getting-started-imgs/send-dm.png" width="85%">

### Send a Direct Message to Someone New

Expand All @@ -159,8 +159,8 @@ Try following the steps above to send a message to the Welcome Bot!

> It's best to use <kbd>ctrl</kbd><kbd>f</kbd> to autocomplete the name and Zulip address of the person (or bot) you want to message; if you just type in their full name, Zulip Terminal does not know for sure who you are trying to send to - and there may be multiple people with that name!
<img src="getting-started-imgs/send-pm-autocomplete1.png" width="85%">
<img src="getting-started-imgs/send-pm-autocomplete2.png" width="85%">
<img src="getting-started-imgs/send-dm-autocomplete1.png" width="85%">
<img src="getting-started-imgs/send-dm-autocomplete2.png" width="85%">

### Create a New Topic

Expand Down
2 changes: 1 addition & 1 deletion tests/config/test_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_display_key_for_urwid_key(urwid_key: str, display_key: str) -> None:
COMMAND_TO_DISPLAY_KEYS = [
("NEXT_LINE", ["Down", "Ctrl n"]),
("TOGGLE_STAR_STATUS", ["Ctrl s", "*"]),
("ALL_PM", ["P"]),
("ALL_DM", ["P"]),
]


Expand Down
68 changes: 34 additions & 34 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def display_recipient_factory(
recipient_details_list: List[Tuple[int, str]]
) -> List[Dict[str, Any]]:
"""
Generate display_recipient field for (PM/group) messages
Generate display_recipient field for (DM/group) messages
"""
return [
{
Expand All @@ -448,9 +448,9 @@ def msg_template_factory(
recipients: Union[str, List[Dict[str, Any]]] = "PTEST",
) -> Message:
"""
Generate message template for all types of messages(stream/PM/group)
Generate message template for all types of messages(stream/DM/group)
"""
# TODO: Separate Message into distinct types for stream and private messages.
# TODO: Separate Message into distinct types for stream and direct messages.
message = Message(
id=msg_id,
sender_full_name="Foo Foo",
Expand Down Expand Up @@ -500,31 +500,31 @@ def extra_stream_msg_template() -> Message:


@pytest.fixture
def pm_template() -> Message:
def dm_template() -> Message:
recipients = display_recipient_factory([(5179, "Boo Boo"), (5140, "Foo Foo")])
return msg_template_factory(537287, "private", 1520918736, recipients=recipients)


@pytest.fixture
def group_pm_template() -> Message:
def group_dm_template() -> Message:
recipients = display_recipient_factory(
[(5179, "Boo Boo"), (5140, "Foo Foo"), (5180, "Bar Bar")]
)
return msg_template_factory(537288, "private", 1520918737, recipients=recipients)


@pytest.fixture(params=["pm_template", "group_pm_template"])
def private_message_fixture(request: Any) -> Message:
@pytest.fixture(params=["dm_template", "group_dm_template"])
def direct_message_fixture(request: Any) -> Message:
return request.getfixturevalue(request.param)


@pytest.fixture(
params=["stream_msg_template", "pm_template", "group_pm_template"],
ids=["stream_message", "pm_message", "group_pm_message"],
params=["stream_msg_template", "dm_template", "group_dm_template"],
ids=["stream_message", "dm_message", "group_dm_message"],
)
def message_fixture(request: Any) -> Message:
"""
Acts as a parametrize fixture for stream msg, pms and group_pms.
Acts as a parametrize fixture for stream msg, dms and group_dms.
"""
# `request` currently does not have an exported Pytest type.
# TODO: Use the exported type when it's made available.
Expand All @@ -535,8 +535,8 @@ def message_fixture(request: Any) -> Message:
@pytest.fixture
def messages_successful_response(
stream_msg_template: Message,
pm_template: Message,
group_pm_template: Message,
dm_template: Message,
group_dm_template: Message,
) -> Dict[str, Any]:
"""
A successful response from a /messages API query.
Expand All @@ -546,8 +546,8 @@ def messages_successful_response(
"anchor": 10000000000000000,
"messages": [
stream_msg_template,
pm_template,
group_pm_template,
dm_template,
group_dm_template,
],
"result": "success",
"msg": "",
Expand Down Expand Up @@ -634,10 +634,10 @@ def topics() -> List[str]:
],
ids=[
"stream_mention__stream_wildcard",
"stream+pm_mention__no_wildcard",
"no_mention__stream+pm_wildcard",
"stream+group_mention__pm_wildcard",
"pm_mention__stream+group_wildcard",
"stream+dm_mention__no_wildcard",
"no_mention__stream+dm_wildcard",
"stream+group_mention__dm_wildcard",
"dm_mention__stream+group_wildcard",
"group_mention__all_wildcard",
"all_mention__stream_wildcard",
"stream+group_mention__wildcard",
Expand Down Expand Up @@ -1060,16 +1060,16 @@ def initial_index() -> Index:

@pytest.fixture
def empty_index(
stream_msg_template: Message, pm_template: Message, group_pm_template: Message
stream_msg_template: Message, dm_template: Message, group_dm_template: Message
) -> Index:
return deepcopy(
Index(
pointer=dict(),
all_msg_ids=set(),
starred_msg_ids=set(),
mentioned_msg_ids=set(),
private_msg_ids=set(),
private_msg_ids_by_user_ids=defaultdict(set, {}),
direct_msg_ids=set(),
direct_msg_ids_by_user_ids=defaultdict(set, {}),
stream_msg_ids_by_stream_id=defaultdict(set, {}),
topic_msg_ids=defaultdict(dict, {}),
edited_messages=set(),
Expand All @@ -1079,8 +1079,8 @@ def empty_index(
lambda: {},
{
stream_msg_template["id"]: stream_msg_template,
pm_template["id"]: pm_template,
group_pm_template["id"]: group_pm_template,
dm_template["id"]: dm_template,
group_dm_template["id"]: group_dm_template,
},
),
)
Expand All @@ -1104,7 +1104,7 @@ def index_stream(empty_index: Index) -> Index:
"""
index = empty_index
index["stream_msg_ids_by_stream_id"] = defaultdict(set, {205: {537286}})
index["private_msg_ids"] = {537287, 537288}
index["direct_msg_ids"] = {537287, 537288}
return index


Expand Down Expand Up @@ -1140,26 +1140,26 @@ def index_multiple_topic_msg(
@pytest.fixture
def index_user(empty_index: Index) -> Index:
"""
Expected index of initial_data when model.narrow = [['pm_with',
Expected index of initial_data when model.narrow = [['dm_with',
'[email protected]'],
"""
user_ids = frozenset({5179, 5140})
index = empty_index
index["private_msg_ids_by_user_ids"] = defaultdict(set, {user_ids: {537287}})
index["private_msg_ids"] = {537287, 537288}
index["direct_msg_ids_by_user_ids"] = defaultdict(set, {user_ids: {537287}})
index["direct_msg_ids"] = {537287, 537288}
return index


@pytest.fixture
def index_user_multiple(empty_index: Index) -> Index:
"""
Expected index of initial_data when model.narrow = [['pm_with',
Expected index of initial_data when model.narrow = [['dm_with',
'[email protected], [email protected]'],
"""
user_ids = frozenset({5179, 5140, 5180})
index = empty_index
index["private_msg_ids_by_user_ids"] = defaultdict(set, {user_ids: {537288}})
index["private_msg_ids"] = {537287, 537288}
index["direct_msg_ids_by_user_ids"] = defaultdict(set, {user_ids: {537288}})
index["direct_msg_ids"] = {537287, 537288}
return index


Expand All @@ -1178,7 +1178,7 @@ def index_all_starred(empty_index: Index, request: Any) -> Index:
msgs_with_stars = request.param
index = empty_index
index["starred_msg_ids"] = msgs_with_stars
index["private_msg_ids"] = {537287, 537288}
index["direct_msg_ids"] = {537287, 537288}
for msg_id, msg in index["messages"].items():
if msg_id in msgs_with_stars and "starred" not in msg["flags"]:
msg["flags"].append("starred")
Expand All @@ -1192,7 +1192,7 @@ def index_all_mentions(
mentioned_messages, wildcard_mentioned_messages = mentioned_messages_combination
index = empty_index
index["mentioned_msg_ids"] = mentioned_messages | wildcard_mentioned_messages
index["private_msg_ids"] = {537287, 537288}
index["direct_msg_ids"] = {537287, 537288}
for msg_id, msg in index["messages"].items():
if msg_id in mentioned_messages and "mentioned" not in msg["flags"]:
msg["flags"].append("mentioned")
Expand Down Expand Up @@ -1468,12 +1468,12 @@ def classified_unread_counts() -> Dict[str, Any]:
"""
return {
"all_msg": 12,
"all_pms": 8,
"all_dms": 8,
"unread_topics": {
(1000, "Some general unread topic"): 3,
(99, "Some private unread topic"): 1,
},
"unread_pms": {
"unread_dms": {
1: 2,
2: 1,
},
Expand Down
10 changes: 5 additions & 5 deletions tests/core/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def test_narrow_to_user(
recipients = frozenset([controller.model.user_id, user_id])
assert controller.model.recipients == recipients
widget = controller.view.message_view.log.extend.call_args_list[0][0][0][0]
id_list = index_user["private_msg_ids_by_user_ids"][recipients]
id_list = index_user["direct_msg_ids_by_user_ids"][recipients]
assert {widget.original_widget.message["id"]} == id_list

@pytest.mark.parametrize(
Expand Down Expand Up @@ -287,7 +287,7 @@ def test_narrow_to_all_messages(
assert msg_ids == id_list
assert final_focus_msg_id == expected_final_focus_msg_id

def test_narrow_to_all_pm(
def test_narrow_to_all_dm(
self, mocker: MockerFixture, controller: Controller, index_user: Index
) -> None:
controller.model.narrow = []
Expand All @@ -296,13 +296,13 @@ def test_narrow_to_all_pm(
controller.model.user_id = 1
controller.model.user_email = "some@email"

controller.narrow_to_all_pm() # FIXME: Add id narrowing test
controller.narrow_to_all_dm() # FIXME: Add id narrowing test

assert controller.model.narrow == [["is", "private"]]
controller.view.message_view.log.clear.assert_called_once_with()

widgets = controller.view.message_view.log.extend.call_args_list[0][0][0]
id_list = index_user["private_msg_ids"]
id_list = index_user["direct_msg_ids"]
msg_ids = {widget.original_widget.message["id"] for widget in widgets}
assert msg_ids == id_list

Expand Down Expand Up @@ -514,7 +514,7 @@ def test_stream_muting_confirmation_popup(
"Default_all_msg_search",
"redo_default_search",
"search_within_stream",
"pm_search_again",
"dm_search_again",
"search_within_topic_narrow",
],
)
Expand Down
4 changes: 2 additions & 2 deletions tests/helper/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_index_starred(
model.narrow = [["is", "starred"]]
model.is_search_narrow.return_value = False
expected_index: Dict[str, Any] = dict(
empty_index, private_msg_ids={537287, 537288}, starred_msg_ids=msgs_with_stars
empty_index, direct_msg_ids={537287, 537288}, starred_msg_ids=msgs_with_stars
)
for msg_id, msg in expected_index["messages"].items():
if msg_id in msgs_with_stars and "starred" not in msg["flags"]:
Expand Down Expand Up @@ -211,7 +211,7 @@ def test_index_mentioned_messages(
model.is_search_narrow.return_value = False
expected_index: Dict[str, Any] = dict(
empty_index,
private_msg_ids={537287, 537288},
direct_msg_ids={537287, 537288},
mentioned_msg_ids=(mentioned_messages | wildcard_mentioned_messages),
)

Expand Down
16 changes: 8 additions & 8 deletions tests/model/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,16 +477,16 @@ def test_set_narrow_not_already_set(
{"topic_msg_ids": {1: {"BOO": {0, 1}}}},
set(),
),
([["is", "private"]], {"private_msg_ids": {0, 1}}, {0, 1}),
([["is", "private"]], {"direct_msg_ids": {0, 1}}, {0, 1}),
(
[["pm-with", "[email protected]"]],
{"private_msg_ids_by_user_ids": {frozenset({1, 2}): {0, 1}}},
{"direct_msg_ids_by_user_ids": {frozenset({1, 2}): {0, 1}}},
{0, 1},
),
(
[["pm-with", "[email protected]"]],
{ # Covers recipient empty-set case
"private_msg_ids_by_user_ids": {
"direct_msg_ids_by_user_ids": {
frozenset({1, 3}): {0, 1} # NOTE {1,3} not {1,2}
}
},
Expand Down Expand Up @@ -3988,8 +3988,8 @@ def test__handle_user_settings_event(self, mocker, model, value):
assert model.user_settings()[setting] == value

@pytest.mark.parametrize("setting", [True, False])
def test_update_pm_content_in_desktop_notifications(self, mocker, model, setting):
setting_name = "pm_content_in_desktop_notifications"
def test_update_dm_content_in_desktop_notifications(self, mocker, model, setting):
setting_name = "dm_content_in_desktop_notifications"
event = {
"type": "update_global_notifications",
"notification_name": setting_name,
Expand Down Expand Up @@ -4291,20 +4291,20 @@ def test_next_unread_topic_from_message__empty_narrow(

assert unread_topic == next_unread_topic

def test_get_next_unread_pm(self, model):
def test_get_next_unread_dm(self, model):
model.unread_counts = {"unread_pms": {1: 1, 2: 1}}
return_value = model.get_next_unread_pm()
assert return_value == 1
assert model.last_unread_pm == 1

def test_get_next_unread_pm_again(self, model):
def test_get_next_unread_dm_again(self, model):
model.unread_counts = {"unread_pms": {1: 1, 2: 1}}
model.last_unread_pm = 1
return_value = model.get_next_unread_pm()
assert return_value == 2
assert model.last_unread_pm == 2

def test_get_next_unread_pm_no_unread(self, model):
def test_get_next_unread_dm_no_unread(self, model):
model.unread_counts = {"unread_pms": {}}
return_value = model.get_next_unread_pm()
assert return_value is None
Expand Down
Loading

0 comments on commit a780310

Please sign in to comment.