-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
Handling Empty Narrows #1543
Open
Niloth-p
wants to merge
10
commits into
zulip:main
Choose a base branch
from
Niloth-p:1506-empty-narrows/pr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Handling Empty Narrows #1543
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4992dbe
boxes: On opening application, display an empty recipient bar.
Niloth-p 936cf2f
core: Track if the current narrow is empty.
Niloth-p 6cac57d
messages/views: Disable keypresses from dummy messages.
Niloth-p f8503f8
messages: Customize recipient bar text for dummy messages.
Niloth-p dcb213a
messages: Turn off recipient header for dummy messages.
Niloth-p 0fb5bf0
model: Replace the dummy message on receiving a new message.
Niloth-p df2feb4
messages: Remove error handling for unreachable case.
Niloth-p 299a1c1
refactor: messages: Allow datetime field of current message to be empty.
Niloth-p 3444552
utils/messages: Add a dummy message for empty narrows.
Niloth-p 2a66297
core/boxes: Flash footer message on search misses, without narrowing.
Niloth-p File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -518,8 +518,8 @@ def test_stream_muting_confirmation_popup( | |
"search_within_topic_narrow", | ||
], | ||
) | ||
@pytest.mark.parametrize("msg_ids", [({200, 300, 400}), (set()), ({100})]) | ||
def test_search_message( | ||
@pytest.mark.parametrize("msg_ids", [({200, 300, 400}), ({100})]) | ||
def test_search_message__hits( | ||
self, | ||
initial_narrow: List[Any], | ||
final_narrow: List[Any], | ||
|
@@ -550,6 +550,60 @@ def set_msg_ids(*args: Any, **kwargs: Any) -> None: | |
create_msg.assert_called_once_with(controller.model, msg_ids) | ||
assert controller.model.index == dict(index_search_messages, search=msg_ids) | ||
|
||
@pytest.mark.parametrize( | ||
"initial_narrow, final_narrow", | ||
[ | ||
([], [["search", "FOO"]]), | ||
([["search", "BOO"]], [["search", "FOO"]]), | ||
([["stream", "PTEST"]], [["stream", "PTEST"], ["search", "FOO"]]), | ||
( | ||
[["pm-with", "[email protected]"], ["search", "BOO"]], | ||
[["pm-with", "[email protected]"], ["search", "FOO"]], | ||
), | ||
( | ||
[["stream", "PTEST"], ["topic", "RDS"]], | ||
[["stream", "PTEST"], ["topic", "RDS"], ["search", "FOO"]], | ||
), | ||
], | ||
ids=[ | ||
"Default_all_msg_search", | ||
"redo_default_search", | ||
"search_within_stream", | ||
"pm_search_again", | ||
"search_within_topic_narrow", | ||
], | ||
) | ||
def test_search_message__no_hits( | ||
self, | ||
initial_narrow: List[Any], | ||
final_narrow: List[Any], | ||
controller: Controller, | ||
mocker: MockerFixture, | ||
index_search_messages: Index, | ||
msg_ids: Set[int] = set(), | ||
) -> None: | ||
get_message = mocker.patch(MODEL + ".get_messages") | ||
create_msg = mocker.patch(MODULE + ".create_msg_box_list") | ||
mocker.patch(MODEL + ".get_message_ids_in_current_narrow", return_value=msg_ids) | ||
controller.model.index = index_search_messages # Any initial search index | ||
controller.view.message_view = mocker.patch("urwid.ListBox") | ||
controller.model.narrow = initial_narrow | ||
|
||
def set_msg_ids(*args: Any, **kwargs: Any) -> None: | ||
controller.model.index["search"].update(msg_ids) | ||
|
||
get_message.side_effect = set_msg_ids | ||
assert controller.model.index["search"] == {500} | ||
|
||
controller.search_messages("FOO") | ||
|
||
assert controller.model.narrow == final_narrow | ||
get_message.assert_called_once_with( | ||
num_after=0, num_before=30, anchor=10000000000 | ||
) | ||
create_msg.assert_not_called() | ||
assert controller.model.index == dict(index_search_messages, search=msg_ids) | ||
|
||
@pytest.mark.parametrize( | ||
"screen_size, expected_popup_size", | ||
[ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we want to take this approach rather than just have the empty result like the rest of this branch is pursuing, but it's an interesting extra change - I assume this is extra to the original version?