zulip/frontend_tests/node_tests
Steve Howell 06b1aece31 Simplify narrow/search interactions.
Before this change, if you hit ESC, then hotkey
code would call search.clear_search, which would
call narrow.deactivate(), which would then use
`$('#search_query')` to clear a value, but then
let search.clear_search blur the input and
disable the exit button.  It was all confusing.

Things are a bit more organized now.

Now the code works like this:

    hotkey.process_escape_key
        Just call narrow.deactivate.

    $('#search_exit').on('click', ...):
        Just call narrow.deactivate.

    narrow.deactivate:
        Just call search.clear_search_form

    search.clear_search_form:
        Just do simple jquery stuff.  Don't
        change the entire user's narrow, not
        even indirectly!

There's still a two-way interaction between
the narrow.js module and the search.js module,
but in each direction it's a one-liner.

The guiding principle here is that we only
want one top-level API, which is narrow.deactivate,
and that does the whole "kitchen sink" of
clearing searches, closing popovers, switching
in views, etc.  And then all the functions it
calls out to tend to have much smaller jobs to
do.

This commit can mostly be considered a refactoring, but the
order of operations changes slightly.  Basically, as
soon as you hit ESC or click on the search "X", we
clear the search widget.  Most users won't notice
any difference, because we don't have to hit the
server to populate the home view.  And it's arguably
an improvement to give more immediate feedback.
2018-10-24 16:54:35 -07:00
..
.eslintrc.json lint: Add JS indentation eslint rules for node_tests. 2018-05-06 19:35:18 -07:00
activity.js refactor: Move operators_to_hash to hash_utils. 2018-08-04 09:32:27 -07:00
alert_words_ui.js tests: Test closing alert word status msg. 2018-07-23 14:53:49 -04:00
alert_words.js node tests: Consolidate some set_global() calls. 2018-08-02 08:02:12 -04:00
bot_data.js node tests: Consolidate some set_global() calls. 2018-08-02 08:02:12 -04:00
buddy_data.js node tests: Consolidate some set_global() calls. 2018-08-02 08:02:12 -04:00
buddy_list.js buddy list: Add padding to progressive scrollings. 2018-08-02 16:59:27 -07:00
channel.js node tests: Consolidate some set_global() calls. 2018-08-02 08:02:12 -04:00
colorspace.js Add run_test helper for individual tests. 2018-05-15 08:24:44 -07:00
common.js node tests: Consolidate some set_global() calls. 2018-08-02 08:02:12 -04:00
components.js Rename markdown-help to message-formatting. 2018-08-31 11:51:22 -07:00
compose_actions.js compose_actions: Use people.get_mention_syntax in reply_with_mention. 2018-10-13 16:42:50 -07:00
compose_fade.js Add run_test helper for individual tests. 2018-05-15 08:24:44 -07:00
compose_pm_pill.js compose pill: Add has_unconverted_data() helper. 2018-10-12 11:20:30 -07:00
compose_ui.js compose_ui: Create the compose_ui.replace_syntax function. 2018-08-26 23:33:24 -07:00
compose.js compose.js: Move set rtl logic to keyup event. 2018-08-14 11:41:53 -07:00
composebox_typeahead.js typeahead: Insert extended mention syntax for users with same full name. 2018-08-31 14:16:47 -07:00
copy_and_paste.js jsdom: Upgrade jsdom to v11.10.0. 2018-05-20 11:11:03 -07:00
dict.js Add run_test helper for individual tests. 2018-05-15 08:24:44 -07:00
dispatch.js frontend: Create data structure for starred messages. 2018-08-21 13:42:23 -07:00
drafts.js drafts: Don't save drafts with 2 or less characters. 2018-08-22 16:52:18 -07:00
emoji_picker.js emoji: Move emoji_collection from emoji picker to emoji.js. 2018-07-23 12:35:08 -07:00
emoji.js emoji: Change fallback emojiset for text emojiset. 2018-09-21 18:34:12 -07:00
fetch_status.js Add run_test helper for individual tests. 2018-05-15 08:24:44 -07:00
filter.js eslint: Add and enable space-unary-ops rule. 2018-06-05 00:47:35 +05:30
general.js left sidebar: Fix scrolling bugs with zoomed topics. 2018-10-24 16:54:35 -07:00
hash_util.js Fix "Copy link to conversation" links. 2018-10-22 12:22:26 -07:00
hashchange.js Rename markdown-help to message-formatting. 2018-08-31 11:51:22 -07:00
hotkey.js Revert "hotkey: Add hotkey to narrow to starred messages." 2018-08-13 15:05:36 -07:00
i18n.js Add run_test helper for individual tests. 2018-05-15 08:24:44 -07:00
input_pill.js input_pill: Add is_pending() helper. 2018-10-12 11:20:30 -07:00
keydown_util.js tests: Reach 100% coverage for keydown_util. 2018-07-23 08:42:11 -04:00
lightbox.js thumbnails: Rename data-original to data-src-fullsize. 2018-07-30 13:00:23 -07:00
list_cursor.js node tests: Bring list_cursor to 100% coverage. 2018-08-24 10:00:04 -07:00
list_render.js list_render: Remove rows sort click handler from the body. 2018-06-22 09:21:47 -04:00
markdown.js markdown.js: Add @user|id syntax to support users with same name. 2018-08-31 14:16:47 -07:00
message_edit.js message_edit: Add coverage for get_deletability function. 2018-06-13 06:04:48 -04:00
message_events.js Add coverage for message_events.update_messages(). 2018-09-11 15:17:51 -04:00
message_fetch.js left sidebar: Make sure the selected stream is visible in left sidebar. 2018-07-23 10:32:10 -07:00
message_flags.js frontend: Create data structure for starred messages. 2018-08-21 13:42:23 -07:00
message_list_data.js Fix recent regressions with All Messages (muted topics). 2018-06-04 14:35:23 -07:00
message_list_view.js refactor: Avoid positional params for MessageList. 2018-05-15 14:25:21 -07:00
message_list.js eslint: Enable space-infix-ops rule. 2018-06-05 00:47:35 +05:30
message_store.js Use topic_data.js for topic typeaheads. 2018-07-23 16:08:24 -07:00
muting.js Add run_test helper for individual tests. 2018-05-15 08:24:44 -07:00
narrow_activate.js compose: Update the New topic button to New stream message in PMs. 2018-08-09 08:55:01 -07:00
narrow_local.js Remove redundant narrow_state.get_current_filter(). 2018-07-10 14:20:24 +05:30
narrow_state.js Add narrow_state.is_reading_mode(). 2018-07-10 14:20:24 +05:30
narrow_unread.js Expand get_unread_ids() to all local narrows. 2018-05-31 08:44:18 -07:00
narrow.js url decoding: Handle your own id being in PM slugs. 2018-10-22 12:22:26 -07:00
notifications.js node: Provide a default window object for the node tests. 2018-05-31 14:55:28 -07:00
password.js Add run_test helper for individual tests. 2018-05-15 08:24:44 -07:00
people_errors.js Add pm_perma_link helper. 2018-10-22 12:22:26 -07:00
people.js Add pm_perma_link helper. 2018-10-22 12:22:26 -07:00
pm_conversations.js Add run_test helper for individual tests. 2018-05-15 08:24:44 -07:00
pm_list.js refactor: Move pm_with_uri to hash_util. 2018-08-04 09:32:27 -07:00
popovers.js user profile popover: Rename user last seen. 2018-08-21 11:42:59 -07:00
presence.js refactor: Extract reload_state module. 2018-08-04 13:55:02 +00:00
reactions.js emoji: Move emoji_collection from emoji picker to emoji.js. 2018-07-23 12:35:08 -07:00
recent_senders.js Add run_test helper for individual tests. 2018-05-15 08:24:44 -07:00
rtl.js rtl.js: Fix support for supplementary planes of unicode characters (>= U+10000). 2018-08-14 11:39:29 -07:00
schema.js Add a schema checking concept to the web app. 2018-05-24 09:30:22 -07:00
scroll_util.js scroll_util: Account for element padding in height calculations. 2018-07-27 09:09:52 -07:00
search_legacy.js Simplify narrow/search interactions. 2018-10-24 16:54:35 -07:00
search_pill.js search: Add a basic implementation of search pills. 2018-07-23 11:29:10 -07:00
search_suggestion_legacy.js search: Duplicate search_suggestions.get_suggestions. 2018-07-23 11:29:10 -07:00
search_suggestion.js search: Do not display All messages suggestion if bar not empty. 2018-07-23 11:29:10 -07:00
search.js Simplify narrow/search interactions. 2018-10-24 16:54:35 -07:00
server_events.js refactor: Extract reload_state module. 2018-08-04 13:55:02 +00:00
settings_bots.js settings UI: Add copy zuliprc button to bot information box. 2018-07-10 15:19:05 +05:30
settings_muting.js style: Remove redundant brackets from typeof operator. 2018-06-05 09:22:26 -07:00
settings_org.js org settings: Disable topic editing checkbox when message editing is off. 2018-08-31 11:49:54 -07:00
settings_profile_fields.js custom profile field: Minor tweaks in field-table in admin settings. 2018-08-21 11:42:59 -07:00
settings_user_groups.js settings: Confirm before deleting user groups. 2018-10-12 10:38:56 -07:00
stream_color.js Add run_test helper for individual tests. 2018-05-15 08:24:44 -07:00
stream_data.js refactor: Break subs dependency in stream_data. 2018-08-04 14:06:19 -07:00
stream_events.js refactor: Break subs dependency in stream_data. 2018-08-04 14:06:19 -07:00
stream_list.js left sidebar: Fix scrolling bugs with zoomed topics. 2018-10-24 16:54:35 -07:00
stream_search.js Add run_test helper for individual tests. 2018-05-15 08:24:44 -07:00
stream_sort.js eslint: Enable no-extra-parens rule. 2018-06-11 07:51:24 -04:00
submessage.js submessages: Add update_message() function. 2018-05-30 14:47:36 -07:00
subs.js settings: Make unsubscribed streams less sticky. 2018-08-03 16:01:02 -07:00
templates.js custom profile fields: Add and restyle default user profile fields. 2018-10-04 17:02:09 -07:00
timerender.js timerender.js: Remove use of legacy font awesome base class 'icon-vector'. 2018-10-15 19:22:57 +05:30
top_left_corner.js PM sidebar: Expand PM sidebar for huddles. 2018-10-22 12:22:26 -07:00
topic_data.js node tests: Use run_test helper in topic_data.js. 2018-06-02 06:10:34 -04:00
topic_generator.js zblueslip: Convert node_tests/topic_generator.js to zblueslip. 2018-07-10 16:22:52 -04:00
topic_list.js Move stream-related uri helpers to hash_util. 2018-08-04 09:32:27 -07:00
transmit.js transmit.js: Use people.get_mention_syntax. 2018-10-13 16:42:50 -07:00
typeahead_helper.js refactor: Move list of frequent emojis to emoji.js. 2018-08-04 07:59:42 -07:00
typing_data.js Add run_test helper for individual tests. 2018-05-15 08:24:44 -07:00
typing_status.js Add run_test helper for individual tests. 2018-05-15 08:24:44 -07:00
ui.js hotkey: Update test for hotkey deprecation. 2018-09-21 10:59:55 -07:00
unread.js eslint: Enable space-infix-ops rule. 2018-06-05 00:47:35 +05:30
upload.js upload: Use a placeholder when uploading. 2018-08-26 23:33:24 -07:00
user_events.js zblueslip: Convert node_tests/user_events.js to zblueslip. 2018-07-10 16:22:52 -04:00
user_groups.js zblueslip: Convert node_tests/user_groups.js to zblueslip. 2018-07-10 16:22:52 -04:00
user_pill.js pills: Enable user avatar images for user pills. 2018-07-10 15:07:56 +05:30
util.js eslint: Enable space-infix-ops rule. 2018-06-05 00:47:35 +05:30
voting_widget.js voting_widget: Increase node test coverage to 100%. 2018-07-06 11:30:12 -04:00
widgetize.js zblueslip: Convert node_tests/widgetize.js to zblueslip. 2018-07-10 16:22:52 -04:00
zblueslip.js zblueslip: Add exception_msg and wrap_function functions. 2018-07-10 16:22:52 -04:00
zjquery.js zjquery: Show multiple handlers in demo code. 2018-07-18 08:25:15 -04:00