Skip to content

Commit 7e733c1

Browse files
committed
bugfix: views: Handle empty search in PanelSearchBox's update functions.
This left strips search text to restrict empty search and avoid empty search results. Tests amended.
1 parent 2310775 commit 7e733c1

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

tests/ui/test_ui_tools.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def test_update_streams(self, mocker, stream_view, new_text, expected_log,
445445

446446
@pytest.mark.parametrize('new_text', [
447447
'',
448-
pytest.param(' ', marks=pytest.mark.xfail(reason='bug')),
448+
' ',
449449
])
450450
def test_update_streams_empty_string(self, mocker, stream_view, new_text):
451451
# NOTE: Only do a minimal arrangement to test whether the method
@@ -580,7 +580,7 @@ def test_update_topics(self, mocker, topic_view, new_text, expected_log):
580580

581581
@pytest.mark.parametrize('new_text', [
582582
'',
583-
pytest.param(' ', marks=pytest.mark.xfail(reason='bug')),
583+
' ',
584584
])
585585
def test_update_topics_empty_string(self, mocker, topic_view, new_text):
586586
# NOTE: Only do a minimal arrangement to test whether the method
@@ -1007,9 +1007,10 @@ def test_update_user_list_editor_mode(self, mocker, right_col_view):
10071007
@pytest.mark.parametrize(['search_string', 'assert_list',
10081008
'match_return_value'], [
10091009
('U', ["USER1", "USER2"], True),
1010-
('F', [], False)
1010+
('F', [], False),
1011+
(' ', ["USER1", "USER2"], True),
10111012
], ids=[
1012-
'user match', 'no user match',
1013+
'user match', 'no user match', 'empty search',
10131014
])
10141015
def test_update_user_list(self, right_col_view, mocker,
10151016
search_string, assert_list, match_return_value):
@@ -1030,7 +1031,6 @@ def test_update_user_presence(self, right_col_view, mocker,
10301031
set_body = mocker.patch(VIEWS + ".urwid.Frame.set_body")
10311032

10321033
right_col_view.update_user_list(user_list=user_list)
1033-
10341034
right_col_view.users_view.assert_called_with(user_list)
10351035
set_body.assert_called_once_with(right_col_view.body)
10361036

zulipterminal/ui_tools/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ def __init__(self, streams_btn_list: List[Any], view: Any) -> None:
264264

265265
@asynch
266266
def update_streams(self, search_box: Any, new_text: str) -> None:
267+
new_text = new_text.lstrip()
267268
if not self.view.controller.is_in_editor_mode() or not new_text:
268269
return
269270
# wait for any previously started search to finish to avoid
@@ -331,6 +332,7 @@ def __init__(self, topics_btn_list: List[Any], view: Any,
331332

332333
@asynch
333334
def update_topics(self, search_box: Any, new_text: str) -> None:
335+
new_text = new_text.lstrip()
334336
if not self.view.controller.is_in_editor_mode() or not new_text:
335337
return
336338
# wait for any previously started search to finish to avoid
@@ -568,6 +570,7 @@ def update_user_list(self, search_box: Any=None,
568570
or (user_list is not None and search_box is None
569571
and new_text == ""))
570572

573+
new_text = new_text.lstrip()
571574
if not self.view.controller.is_in_editor_mode() and not user_list:
572575
return
573576
if not self.allow_update_user_list and new_text == "":

0 commit comments

Comments
 (0)