-
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
boxes: Enable autocomplete for PM recipients.
Currently, the recipients box has no autocomplete for users names. This commit adds a method to autocomplete names appended with their corresponding emails and enables it. The typeahead autocompletes the names with their emails, but only names are shown in the suggestions. Tests added.
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
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 |
---|---|---|
|
@@ -286,6 +286,52 @@ def test_generic_autocomplete_emojis(self, write_box, text, | |
typeahead_string = write_box.generic_autocomplete(text, state) | ||
assert typeahead_string == required_typeahead | ||
|
||
@pytest.mark.parametrize(['text', 'matching_users', | ||
'matching_users_info'], [ | ||
('', [ | ||
'Human Myself', | ||
'Human 1', | ||
'Human 2' | ||
], [ | ||
'Human Myself <[email protected]>', | ||
'Human 1 <[email protected]>', | ||
'Human 2 <[email protected]>' | ||
]), | ||
('My', ['Human Myself'], | ||
['Human Myself <[email protected]>']), | ||
], ids=[ | ||
'no_search_text', | ||
'single_word_search_text', | ||
]) | ||
def test__to_box_autocomplete(self, mocker, write_box, text, | ||
users_fixture, matching_users, | ||
matching_users_info, state=1): | ||
_process_typeaheads = mocker.patch(BOXES | ||
+ '.WriteBox._process_typeaheads') | ||
|
||
write_box._to_box_autocomplete(text, state) | ||
|
||
_process_typeaheads.assert_called_once_with(matching_users_info, state, | ||
matching_users) | ||
|
||
@pytest.mark.parametrize('text, expected_text', [ | ||
('Hu', 'Human Myself <[email protected]>'), | ||
('Human M', 'Human Myself <[email protected]>') | ||
]) | ||
def test__to_box_autocomplete_with_spaces(self, write_box, text, | ||
expected_text, widget_size): | ||
write_box.private_box_view(email='[email protected]', | ||
recipient_user_ids=[1]) | ||
write_box.to_write_box.set_edit_text(text) | ||
write_box.to_write_box.set_edit_pos(len(text)) | ||
write_box.focus_position = write_box.FOCUS_CONTAINER_HEADER | ||
size = widget_size(write_box) | ||
|
||
write_box.keypress(size, primary_key_for_command('AUTOCOMPLETE')) | ||
|
||
assert (write_box.to_write_box.edit_text | ||
== expected_text) | ||
|
||
@pytest.mark.parametrize(['text', 'state', 'to_pin', 'matching_streams'], [ | ||
('', 1, [], ['Secret stream', 'Some general stream', | ||
'Stream 1', 'Stream 2']), | ||
|
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