Commit Graph

4212 Commits

Author SHA1 Message Date
YashRE42 4ffdfb5f00 server_events_dispatch: Throw blueslip if wrong op in realm_bot case. 2021-03-24 15:04:00 -07:00
YashRE42 195b1b28ee server_events_dispatch: Throw blueslip if update_dict without prop. 2021-03-24 15:04:00 -07:00
YashRE42 e3b6cc61f3 server_events_dispatch: Throw from "reaction" based on event.op. 2021-03-24 15:04:00 -07:00
YashRE42 bc69521caa server_events_dispatch: Throw from "subscription" based on event.op. 2021-03-24 15:04:00 -07:00
Steve Howell 57d79e8fd6 refactor: Extract color_class module.
This breaks some indirect dependencies on subs
and message_view_header.
2021-03-24 12:22:27 -07:00
Steve Howell f3b1e723e0 typeahead: Eliminate render caches.
These were introduced in ff9a929d7a
with no explanation of why they were necessary.

Generally you only render a few things, and it's
important that they're up to date.

We weren't doing a good job of invalidating the cache.

Eliminating the cache will fix bugs (like presence circles
being out of date) and break some dependencies.

I removed some very fragile test code that was relying
on invalid values taken out of the cache.  (We now have
less line coverage, but if we want to test our rendering,
there are much cleaner ways to do it.)

As part of testing this, I renamed Hamlet to "aaron", so
that there are two aarons, and then I logged on as Iago
to see the "secondary" code in action that shows their
emails to distinguish them.
2021-03-24 12:15:36 -07:00
YashRE42 33fb78af42 server_events_dispatch: Refactor realm_domain to use switch/case.
This should make no functional changes.
2021-03-23 13:56:21 -07:00
shanukun d68a2677d2 event_schema: Add checker for restart event.
Part of #17568.
2021-03-23 12:16:20 -07:00
shanukun cfe0fa3788 event_schema: Add schema check for realm/deactivated event.
This add the schema checker, openapi schema, and also a test for
realm/deactivated event.

With several block comments by tabbott explaining the logic behind our
behavior here.

Part of #17568.
2021-03-23 12:16:16 -07:00
Steve Howell 65ec8f2000 refactor: Move suspect_offline logic into watchdog.
This breaks some indirect dependencies in presence.js.
2021-03-23 14:08:39 -04:00
YashRE42 4988f60a0f template.js: Add test for "numberFormat" helper. 2021-03-23 10:46:04 -07:00
YashRE42 6c0d070b4d template.js: Add test for "rendered_markdown" helper. 2021-03-23 10:46:04 -07:00
YashRE42 2e910842d8 template.js: Add test for "or" helper. 2021-03-23 10:46:04 -07:00
YashRE42 66c12c9022 template.js: Add test for "and" helper. 2021-03-23 10:46:04 -07:00
Anders Kaseorg 9553f11387 eslint: Forbid CommonJS variables in ES6 modules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-23 01:42:43 -07:00
Abhijeet Prasad Bodas 42aea49784 left sidebar: Add support to unstar all messages in topic.
This adds support for unstarring all (starred)
messages from a particular topic, from the topic
popover.

The earlier implementation of this in #16898
was reverted in bc55aa6a01 (#17429)
because it had two problems-

1. The crash reported in bc55aa6a01
was due to message_store returning undefined. This happens
when the message itself hasn't been fetched from the server
yet, but we know that the message is starred from the ids
in `page_params` in `starred_messages.js`.
This commit handles this case explicitly.
Note that, we simply ignore those messages which
we haven't fetched, and because of this, it may
happen that we don't unstar some messages from that
topic. The correct implementation for this would
be to ask the backend for starred IDs in a topic.

2. The earlier implementation actually unstarred **all**
messages. This was because it grabbed the topic and stream_id
from the topic popover `data` attributes, after the topic
popover had been closed. This passed `undefined`, which
the function then interpreted as an action to unstar all
messages.
With this commit, we use the confirm_dialog widget,
which eliminates the need to store this data in the DOM.
2021-03-23 00:17:15 -07:00
Steve Howell 72e0f2e901 bots: Lift render_bots calls to dispatcher code.
This is mostly a refactoring to break the unnecessary
dependency of bot_data on settings_bots.

This is a bit more than a refactoring, as I remove all
the debounced calls to render bots during the
initialization of bot_data. (The debouncing probably
meant we only rendered once, but it was still needless
work.)

We don't need to explicitly render bots during
bot_data.initialize(), which you can verify by loading
"#settings/your-bots" as the home page. It was just an
artifact of how add() was implemented.

Note that for the **admin** screen, we did not and
still do not do live updates for add/remove; we only do
it for updates. Fixing that is out of the scope of this
change. The code that was moved here affects
**personal** bot settings.

Note that the debounce code is quite fragile. See my
code comment that explains it. I don't have time to go
down the rabbit hole of a deep fix here. The puppeteer
tests would fail without the debounce, even though I
was able to eliminate the debounce in an earlier
version of this fix and see good results during manual
testing. (My testing may have just been on the "lucky"
side of the race.) I created #17743 to address this
problem.
2021-03-22 19:40:06 -07:00
Steve Howell 746cc9e1f6 refactor: Extract browser_history module.
This mainly extracts a new module called
browser_history. It has much fewer dependencies
than hashchange.js, so any modules that just
need the smaller API from browser_history now
have fewer transitive dependencies.

Here are some details:
    * Move is_overlay_hash to hash_util.
    * Rename hashchange.update_browser_history to
      brower_history.update
    * Move go_to_location verbatim.
    * Remove unused argument for exit_overlay.
    * Introduce helper functions:
        * old_hash()
        * set_hash_before_overlay()
        * save_old_hash()

We now have 100% line coverage on the extracted
code.
2021-03-22 13:29:32 -07:00
Steve Howell dbf19fe8d7 refactor: Extract watchdog module.
We now have 100% code coverage on this somewhat
fiddly code.

We also break activity's dependency on server_events.
2021-03-22 13:17:37 -07:00
Steve Howell a429ecbb1b refactor: Move get_notifications_table_row_data.
The only caller for this function was settings_config,
so we put it there.

For the stream_edit test we no longer mock the function.
(The reason we mocked the function was more about avoiding
the heavy settings_notifications import than the function
itself.)  This gives some incidental coverage, but then I
also add some more real coverage on it.
2021-03-22 13:17:37 -07:00
Steve Howell 56698d4a9a node tests: Add test() wrapper for reload_state.
This is kinda overkill for such a tiny test, but
it should future-proof us from intra-test leaks.
2021-03-22 15:11:28 -04:00
Steve Howell 855ac26c48 compose fade: Extract compose_fade_users class.
We extract compose_fade_users and compose_fade_helper.

This is a pretty verbatim extraction of code, apart from adding a few
exports and changing the callers.

This change makes the buddy_data module no longer sit "above" these
files in the dependency graph (at least not via compose_fade):

    * jquery
    * lodash (not a big deal)
    * compose_state
    * floating_recipient_bar
    * message_viewport
    * rows

The new moules have dependencies that buddy_data already
had directly for other reasons:

    * people
    * util

And then buddy_data still depends on stream_data indirectly through
the compose-fade logic for stream_data. Even without compose-fade, it
would depend indirectly on stream_data via hash_util.

Note that we could have lifted the calls to compose_fade out of
buddy_data to move some dependencies around, but it's useful to have
buddy_data fully encapsulate what goes into the buddy list without
spreading responsibilities to things like activity.js and
buddy_list.js. We can now unit-test the logic at the level of
buddy_data, which is a lot easier than trying to do it via modules
that delegate drawing or do drawing (such as activity.js and
buddy_list.js).

Note that we still don't have 100% line coverage on the
compose_fade.js module, but all the code that we extracted now is
covered, mostly via buddy_data tests.
2021-03-21 20:16:08 -07:00
YashRE42 0b6b5f421f reload_state: Add 100% test coverage.
This commit adds a new reload_state.js file to node_tests/ which
completes the missing coverage from reload_state.
2021-03-21 17:14:28 -07:00
Steve Howell ec46827ebd refactor: Move user_can_change_* to settings_data.
This simplifies our dependency graph and puts easily
testable functions into a module where we enforce
100% coverage.

All the code was moved verbatim.
2021-03-21 17:07:41 -07:00
Steve Howell 0014bc1549 node tests: Add test() wrapper for channel. 2021-03-20 11:00:48 -04:00
Steve Howell 8f9126cd91 node tests: Add huddle_string test. 2021-03-19 13:24:55 -04:00
Anders Kaseorg 0d218a4b76 eslint: Enable @typescript-eslint/consistent-type-imports.
TypeScript type-only imports will probably become important eventually
for reducing our circular import problem.

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-18 17:26:19 -07:00
Abhijeet Prasad Bodas 91234b2a86 node tests: Add tests for starred_messages.js. 2021-03-18 15:55:39 -07:00
Abhijeet Prasad Bodas 206fe1ef3b node tests: Introduce message_store.create_mock_message() helper.
Previously, it was tedious to create actual message
objects in message_store for use in node tests.
This was mainly because, `add_message_metadata`
in message_store has many dependencies and
validation checks. Since it was difficult to create
actual message objects, many tests just mocked
the `message_store.get()` method to return the desired
message.

This commit adds a new helper method (`create_mock_message`)
to message_store, for use in node tests. This just stores
the object passed to it in the `stores_messages` map,
without any validation. We do not add any
default fields to the message object before saving
it from this helper, because doing so would decrease
the utility of this helper, and, if a test
depends on some field having a particular value,
then it would be better to just pass the field: value
pair from the test itself, for readability, rather
than relying on the helper to add the field for us.

This helper allows us to write deeper tests.

This commit also replaces some instances of mocking
`message_store.get()` to use this new helper method.
2021-03-18 15:55:39 -07:00
Steve Howell 728905d4bc node tests: Clean pm_conversations more simply. 2021-03-18 16:37:20 -04:00
Steve Howell b2be16c4d0 node tests: Use clean BuddyList instance in tests.
As part of this, we inline one function call rather
than changing it to have buddy_list be passed in.
2021-03-18 16:37:20 -04:00
YashRE42 2b03a74d97 channel: Add while_reloading test cases for 100% coverage.
The branches that depended on reload_state were introduced after a
refactor in 'presence' and never had relevant test cases added.
2021-03-18 10:09:22 -07:00
Anders Kaseorg 3ef6f6e2e2 js: Convert static/js/blueslip.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-17 08:47:15 -04:00
Anders Kaseorg b0ceaa1ea0 node_tests: Replace override(blueslip) with blueslip.expect.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-17 08:47:15 -04:00
100RABHpy 039dd256a1 markdown: Fix a bug in query_and_reply.
Fixes #17466
This commit will change encoding logic. Initial logic
was not encoding parenthesis, and this creates conflicts
with the markdown link format. To resolve this while encoding,
we're now replacing parenthesis with ".28" and ".29."

There is no need to change decoding logic because before
decoding any URL, we first convert all the “.” to “%.”

optimization: No need to replace parenthesis in popovers.js.
2021-03-16 16:40:37 -07:00
Steve Howell 5192dab31d node tests: Add explicit stub_templates calls. 2021-03-16 14:53:52 -04:00
Steve Howell 93ba7c7c02 node tests: Isolate message mutations for recent_topics. 2021-03-16 14:53:52 -04:00
Steve Howell 2a80c23484 node tests: Add test wrapper to recent_topics. 2021-03-16 14:53:52 -04:00
Steve Howell c05007b427 node tests: Use more overrides in composebox_typeahead. 2021-03-16 14:53:52 -04:00
Steve Howell 15d99f87fb node tests: Clear more data for typeahead_helper.
We also use a more realistic method of setting
recipient counts, and we make the pm count test
a bit more explicit.
2021-03-16 09:04:26 -04:00
Steve Howell 0523f96a1b node tests: Add test() wrapper for markdown tests. 2021-03-16 09:04:26 -04:00
Steve Howell 4d59fb1063 node tests: Set compose state for compose_actions tests. 2021-03-16 09:04:26 -04:00
Steve Howell 157ab156e7 node tests: Use override for current_msg_list. 2021-03-16 09:04:26 -04:00
Steve Howell 433d42e723 node tests: Add whiny_get() helper. 2021-03-16 09:04:26 -04:00
Steve Howell 764b83b890 node tests: Remove stub_channel_get().
A few years ago I introduced the anti-pattern
of automatically calling success functions within
channel.get stubs.  It's better to just capture
the success function and call it explicitly.

Also, we now have override(), so it's easy to
inline these types of things in a safe way.
2021-03-16 09:04:26 -04:00
Steve Howell 6b0ceeb3b0 node tests: Remove stub_selected_message. 2021-03-16 09:04:26 -04:00
Steve Howell c06dedf670 node tests: Add test() wrapper for filter tests. 2021-03-16 09:04:26 -04:00
Steve Howell 4f2170994a node tests: Move functions higher up in file. 2021-03-16 09:04:26 -04:00
Steve Howell e9e8bcd26e node tests: Add popovers.clear_for_testing(). 2021-03-16 09:04:26 -04:00
Steve Howell 9c9d381890 node tests: Add test() for composebox_typeahead. 2021-03-16 09:04:26 -04:00
Steve Howell 2093bc96f4 node tests: Extract get_results() helper. 2021-03-16 09:04:26 -04:00
Abhijeet Prasad Bodas 9223dced3b refactor: Rename filter to linkifier in frontend code and docs.
This only leaves `page_params.realm_filters`, which
will be changed in further commits along with the
API change.
2021-03-15 11:19:59 -07:00
Steve Howell 9a6cb441e1 node tests: Remove misleading subscribed fields.
The stream_data.create_streams() helper ignores
these booleans, so they are just confusing for
debugging purposes.
2021-03-15 13:05:49 -04:00
Steve Howell 0dc597bceb node tests: Move data setup higher in the file. 2021-03-15 13:05:49 -04:00
Steve Howell ece986bd10 node tests: Clear data for sort_recipients. 2021-03-15 13:05:49 -04:00
Steve Howell af292d550f node tests: Clean up render tests for typeahead_helper. 2021-03-15 13:05:49 -04:00
Steve Howell 3b75674b08 node tests: Localize all_obj consts. 2021-03-15 13:05:49 -04:00
Steve Howell d7d357f61e node tests: Add test_all() wrapper for widgetize.
I also move around a couple set_global/mock_esm
calls.
2021-03-15 13:05:49 -04:00
Steve Howell 09bad82131 node tests: Add test() wrapper for typing_data. 2021-03-15 13:05:49 -04:00
Steve Howell deaf633b04 node tests: Call initialize_state() earlier.
This makes the test re-runnable.
2021-03-15 13:05:49 -04:00
Steve Howell 198c67a9bd node tests: Split up tutorial into smaller examples.
I didn't bother to keep the very last test from
tutorial, which has some complications related
to clearing stream_list data and was kind of
overkill.
2021-03-15 10:46:00 -04:00
Nikhil Maske f5544e36ed markdown: Add fa-clock icon before markdown timestamps.
These sigils will help make it easier to see that this is a special
Zulip syntax feature, not just something the other user typed, which
might help set the expectation that we're showing the time in the
user's timezone.

Tweaked by tabbott to improve variable/template naming.
2021-03-14 22:57:01 -07:00
Steve Howell bbe12a3967 node tests: Ensure clean data for timerender tests.
We explicitly initialize things that future tests
could possibly mutate.
2021-03-14 11:38:21 -04:00
Steve Howell 7bb861303a node tests: Add test() wrapper to compose_actions.
I also do s/Bob/Steve/ in a test to avoid any
confusion about intra-test leaks.

In passing I clean up the dubious reply_to
fields.
2021-03-14 11:38:21 -04:00
Steve Howell 9db20afd19 node tests: Clean up stream_events.
* hoist dev_help
* extract narrow_to_frontend()
* use more explicit setup
* add test() wrapper
2021-03-14 10:46:45 -04:00
Steve Howell ce9c31ca6b node tests: Clean up settings_org.
I add a test() wrapper and use override()
more liberally.
2021-03-14 10:46:45 -04:00
Steve Howell f9101c91b5 node tests: Remove needless reset test.
We want to reset in the main test here to ensure
a clean slate, and doing so makes the other
test redundant.
2021-03-14 10:46:45 -04:00
Steve Howell 92e611a787 node tests: Add test() wrapper for lightbox. 2021-03-14 10:46:45 -04:00
Steve Howell 63a0f6b352 node tests: Extract override_random_id. 2021-03-14 08:11:25 -04:00
Steve Howell ae6c435bb4 node tests: Clean up hashchange tests.
* use override
* localize window_stub
* add clear_for_testing() helper
2021-03-14 08:11:25 -04:00
Steve Howell 45c433b346 node tests: Clean up drafts tests.
I add a test() wrapper and clean up some
of the date-related code.
2021-03-14 08:11:25 -04:00
Steve Howell 569a68a057 node tests: Clean up buddy_data tests.
We mostly add the test() wrapper to give
each test a clean slate.
2021-03-14 08:11:25 -04:00
Steve Howell 85bd196bfc node tests: Add test() wrapper to bot_data. 2021-03-14 08:11:25 -04:00
Steve Howell 612f79ea6f node tests: Add env var to components test.
This makes it easier to run the test multiple
times.
2021-03-14 08:11:25 -04:00
Steve Howell c0f2315dd5 node tests: Avoid __Rewire__ in stream_list. 2021-03-13 14:47:49 -05:00
Steve Howell 5f6b0bc831 node tests: Avoid __Rewire__ in stream_edit. 2021-03-13 14:47:49 -05:00
Steve Howell b1d59237b9 node tests: Avoid __Rewire__ call in drafts.. 2021-03-13 14:47:49 -05:00
Steve Howell 4b62f8c90f node tests: Avoid __Rewire__ in compose_actions. 2021-03-13 14:47:49 -05:00
Anders Kaseorg 9275489134 zjsunit: Truncate the stack trace only at run_one_module.
Commit 5bd73ce190 (#17367)
unintentionally truncated more of the traceback rather than less when
there’s more than one Module._compile frame.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-13 14:44:13 -05:00
Steve Howell 9c3f526fae node tests: Explicitly set hash for billing test. 2021-03-13 11:48:50 -05:00
Steve Howell fbd3669461 zjsunit: Do not run $(...) automatically.
We have generally gone away from using $(...)
initialization in modules that we test with
zjsunit, but there are a few remaining special
cases related to our billing and portico
codebases.
2021-03-13 11:48:50 -05:00
Steve Howell bc8647539c code cleanup: Remove obsolete stream_sort code.
I remove an obsolete comment--we use get_streams()
for the `n` key now.

I also remove a guard statement from sort_groups()
that returned `undefined` for empty lists.

That guard statement would break this code:

    const stream_groups = stream_sort.sort_groups(streams, get_search_term());

    if (stream_groups.same_as_before && ...

The calling code prevents the situation anyway:

    const streams = stream_data.subscribed_stream_ids();
    if (streams.length === 0) {
        return;
    }

I modify the "no_subscribed_streams" test to test
the new behavior.  (Even though stream_list currently
short-circuits the call here, that may change in the future.)

I also introduce the test() wrapper to explicitly clear
our data.
2021-03-13 11:48:50 -05:00
Steve Howell 9c4d7b3bd4 node tests: Add test() wrapper for stream_topic_history. 2021-03-13 11:48:50 -05:00
Steve Howell e5669f9087 zjsunit: Extract complain_about_unused_mocks.
This is prep toward allowing individual tests
to fail while continuing to run the test suite.

Most of the steps in namespace.finish() could
be put in a `finally` block, but once a test
fails, there's no reason to complain about
unused mocks, since there are bigger things
to address.
2021-03-13 08:59:06 -05:00
Anders Kaseorg e0f0b7f4a7 puppeteer_lib: Remove jQuery dependency from select_item_via_typeahead.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-13 07:02:00 -05:00
Anders Kaseorg 812adba5a3 puppeteer_lib: Remove jQuery dependency from get_rendered_messages.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-13 07:02:00 -05:00
Anders Kaseorg 73ca1afc53 puppeteer_lib: Remove wait_for_text.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-13 07:02:00 -05:00
Anders Kaseorg 054f8f8151 puppeteer_lib: Remove jQuery dependency from get_text_from_selector.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-13 07:02:00 -05:00
Anders Kaseorg 4434e2c687 puppeteer_lib: Remove jQuery dependency from pm_recipient.set.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-13 07:02:00 -05:00
Steve Howell bfb06c939c node tests: Add test() wrapper for topic_list_data. 2021-03-12 17:52:04 -05:00
Riken Shah 3a386fcf44
puppeteer_tests: Fix invalid/incorrect selector for `waitFor`.
We're trying to wait for the subscriptions overlay to close, so we should actually do that.
2021-03-12 13:26:39 -08:00
Steve Howell a0534b5b03 node tests: Clean up all_topics_in_cache test.
We use override() and clear the message data
explicitly.
2021-03-12 15:29:23 -05:00
Steve Howell 88357579fe node tests: Add test() wrapper for stream_data. 2021-03-12 15:29:23 -05:00
Steve Howell 154daf353b node tests: Add test() wrapper for suggestions. 2021-03-12 15:29:23 -05:00
Steve Howell 9c1e21689b node tests: Use override in search_suggestion. 2021-03-12 15:29:23 -05:00
Riken Shah 812d563bd4 puppeteer_test: Add missing `waitFor` to avoid occasional flakes. 2021-03-12 12:14:37 -08:00
Riken Shah 6421c1d8d9 puppeteer_test/16: Fix "not secure" warning hiding the button.
When typing the password in Firefox,
it shows a "Not Secure" warning which was
hiding the "#get_api_key_button". You can see
the screenshot of it in #17136.

This commit fixes that issue by focusing on the button.
2021-03-12 12:14:37 -08:00
Riken Shah d2980f1042 puppeteer_test/16: Fix `:focus` not working with Firefox.
This commit works around the issue of
`#change_password_modal:focus` not working
for some strange reason with Firefox.
2021-03-12 12:14:37 -08:00
Riken Shah 5e98f80dc3 puppeteer_test: Transform jQuery to puppeteer functions for Firefox.
This commit converts some jQuery code
to builtins puppeteer functions because
it was not working with Firefox.
2021-03-12 12:14:37 -08:00
Anders Kaseorg 37bd04054f zjsunit: Try to document the difference between CJS and ES modules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 11:18:13 -08:00
Anders Kaseorg ea9ca6b7d0 js: Use jQuery as a module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:08:25 -08:00
Anders Kaseorg ac36d59728 node_tests: Move set_global mock in components before zrequire call.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:06:34 -08:00
Anders Kaseorg 92a46888f0 node_tests: Mock sortablejs to avoid __Rewire__.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:06:34 -08:00
Anders Kaseorg 5fc8a12d7b node_tests: Mock clipboard to avoid __Rewire__.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:06:34 -08:00
Anders Kaseorg 7529491c67 node_tests: Mock @uppy/core to avoid __Rewire__.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:06:34 -08:00
Anders Kaseorg 5251fa81fb zjsunit: Lift restriction against mocking CJS modules.
Factor out mock_cjs from mock_esm because adding __esModule prevents
mocks for CJS modules from being imported correctly.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:06:34 -08:00
Anders Kaseorg 876806eb4d zjsunit: Lift restriction against mocking third party modules.
Use fully resolvable request paths because we need to be able to refer
to third party modules, and to increase uniformity and explicitness.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:06:30 -08:00
Steve Howell 87a3650176 node tests: Clean up recent_senders test.
This introduces the make_stream_message()
helper to avoid all the strange
`messages[0] === message1` confusion.

We also clear data explicitly at the beginning
of the test.

It's still a messy test.
2021-03-12 11:18:44 -05:00
Steve Howell bae508d1c9 node tests: Explicitly set filters for markdown test. 2021-03-12 11:18:44 -05:00
Steve Howell d1d0742e0a node tests: Move test to fenced_code.js. 2021-03-12 11:18:44 -05:00
Steve Howell 6cb255b559 node tests: Use clean data in reaction tests.
A bunch of tests were mutating the same message.
Now they just make their own copy.

I introduce the name "sample_message" for the common
message, but I remove the two bogus reactions, and
the "warning" test now just creates its own
test-specific data.
2021-03-12 11:18:44 -05:00
Steve Howell f5506c78aa node tests: Clear data for presence tests.
I considered using set_info({}, 0) to clear data,
but it has a lot of machinery that could lead
to accidental line coverage and/or extra test
complexity.
2021-03-12 11:18:44 -05:00
Steve Howell bbf529f2a5 node tests: Clear data for pm_list tests. 2021-03-12 11:18:44 -05:00
Steve Howell 67a5fe95dc minor: Remove empty pm_list.initialize().
The commit 3cfc3ca24b
made this function do nothing, but I guess that
we thought we might resurrect the click handler
in the short term.  We never did.
2021-03-12 11:18:44 -05:00
m-e-l-u-h-a-n e781136acd css: Add separate class for typeahead items with no presence circle.
This commit adds a new class for typeahead items that do not need
a presence circle. It is changed to support addition of new items
that do not require presence circle.

There should not be any visual change due to this.
2021-03-12 02:10:21 -08:00
Steve Howell d1e0aa1aa5 node tests: Break up password tests.
This diff is slightly noisy due to hoisting
one helper, but it's hoisted verbatim.
2021-03-12 04:42:37 -05:00
Steve Howell a97cfd06c0 node tests: Clean up muting tests.
* move one test below setup
    * add a test() wrapper to clear mutes
    * split up a test
    * use two different dates for java vs. gossip
    * deterministically sort by date

All these changes make it so that the order of
the tests is a lot less fragile.
2021-03-12 04:42:37 -05:00
Steve Howell 950effbb57 node tests: Add overrides for message_flags. 2021-03-12 04:42:37 -05:00
Steve Howell 71ccb99531 node tests: Clean up pm_conversations.
* Hoist zrequire("people") to the top.
    * Add clear_for_testing() hook.
    * Add initialize_recents() helper.
2021-03-12 04:42:37 -05:00
Steve Howell 7f700b6f5a minor: Use override in people_errors. 2021-03-12 04:42:37 -05:00
Steve Howell 0c2aa1d3e8 node tests: Clean up electron-related code. 2021-03-12 04:42:37 -05:00
Steve Howell 26fed458e6 node tests: Clean up dispatch tests.
These are minor cleanups to make tests more
idempotent.
2021-03-12 04:42:37 -05:00
Steve Howell b13af16ad0 node tests: Tweak test() wrapper.
We do the initialization inside run_test(),
so that if it fails, we see it as happening
within the test.
2021-03-12 04:42:37 -05:00
Steve Howell f5488b98eb node tests: Clean up robust_uri_decode. 2021-03-12 04:42:37 -05:00
Anders Kaseorg 4256567b4a puppeteer_tests: Correct {visible: false} to {hidden: true}.
{visible: false} just redundantly specifies the default behavior,
which is to wait for the selector to be present regardless of
visibility.  We want to wait for these selectors to be hidden.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-11 21:05:54 -08:00
Aman Agrawal e587c029f6 display_settings: Allow user to set default_view.
TextField is used to allow users to set long stream + topic narrow
names in the urls.

We currently restrict users to only set "all_messages" and
"recent_topics" as narrows.

This commit achieves 3 things:
* Removes recent topics as the default view which loads when
  hash is empty.
* Loads default_view when hash is empty.
* Loads default_view on pressing escape key when it is unhandled by
  other present UI elements.

NOTE: After this commit loading zulip with an empty hash will
automatically set hash to default_view.  Ideally, we'd just display
the default view without a hash, but that involves extra complexity.

One exception is when user is trying to load an overlay directly,
i.e. zulip is loaded with an overlay hash. In this case,
we render recent topics is background irrespective of default_view.

We consider this last detail to be a bug not important enough to block
adding this setting.
2021-03-11 18:09:08 -08:00
Steve Howell d74266ac75 zjsunit: Simplify zjquery patching.
This makes it so that we can bypass the Proxy
object in zjquery with less code in namespace.js.
2021-03-11 13:00:30 -05:00
Steve Howell a4ab6065cd node tests: Clear data for peer_data tests. 2021-03-10 07:07:34 -05:00
Steve Howell 1064690999 node tests. Use clean data for unread tests. 2021-03-10 07:07:34 -05:00
Steve Howell 164db57be1 node tests: Clear state in narrow_unread test. 2021-03-10 07:07:34 -05:00
Steve Howell dd7420ff11 minor: Don't export unread_topic_counter.
The only places we called it now use the
helper function.

In passing I move another const to the top
of the file.
2021-03-10 07:07:34 -05:00
Steve Howell 18dcdf1df5 node tests: Clear data for narrow_state tests. 2021-03-10 07:07:34 -05:00
Steve Howell 4621e54059 node tests: Clear data for message_store tests. 2021-03-10 07:07:34 -05:00
Steve Howell c6dc9e9014 refactor: Remove message_store.each helper. 2021-03-10 07:07:34 -05:00
Steve Howell da10d42f8a node tests: Remove unneeded set_global for pointer.
We eliminated the global pointer a while back.

In passing I move the remaining set_global calls
together.
2021-03-10 07:07:34 -05:00
Anders Kaseorg 59e5e9ba35 zjsunit: Move mock clearing to namespace.finish.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-10 07:07:34 -05:00
Anders Kaseorg 1b58f5a700 zjsunit: Remove objs_installed flag.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-10 07:07:34 -05:00
Anders Kaseorg 1689c57cc4 zjsunit: Fix filename resolution in _load hook.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-10 07:07:34 -05:00
Anders Kaseorg f4d38bc39f zjsunit: Add unmock_module function.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-10 07:07:34 -05:00
Anders Kaseorg e18171e1c5 zjsunit: Rename mocked_paths to used_module_mocks.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-10 07:07:34 -05:00
Anders Kaseorg d40bbde51c zjsunit: Remove redundant mock_names set.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-10 07:07:34 -05:00
Anders Kaseorg 3551cc5679 zjsunit: Convert mock_paths object to a Map.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-10 07:07:34 -05:00
Anders Kaseorg 7218a06cab zjsunit: Install Module._load hook in namespace.start.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-10 07:07:34 -05:00
Anders Kaseorg 6540285a9c channel: Sever dependency on reload.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-09 17:43:07 -08:00
Steve Howell b55a77f1cd node tests: Avoid test leaks in filter.
We want to be careful about MIT code, as it leads
to more lax checks in the filter code.

And then we just use with_field in a couple places
and clear subscriptions.
2021-03-08 14:03:39 -05:00
Steve Howell b2efb2e7b2 node tests: Localize MockDate.set call for echo test. 2021-03-08 14:03:39 -05:00
Steve Howell 0e4bf2cf53 node tests: Avoid test leaks for people. 2021-03-08 13:06:52 -05:00
Steve Howell 8c6469314b node tests: Avoid intra-test leaks in buddy_data. 2021-03-08 10:45:17 -05:00
Steve Howell f6f251671a node tests: Avoid intra-test leaks for alert_words. 2021-03-08 10:45:17 -05:00
Steve Howell ab34f63ad5 node tests: Clear pending channel requests. 2021-03-08 10:45:17 -05:00
sahil839 9a432b0c3b events: Remove name field from update subscription events.
This commit removes name field from update subscription
events, as it is not used by any of the clients, and use
stream_id in the events code instead.
2021-03-07 22:03:24 -08:00
Steve Howell 9c8fa3930f node tests: Eliminate many __Rewire__ calls.
For most functions that we were using __Rewire__ for,
it's better to just use the override helper, which
use __Rewire__ under the hood, but also resets
the reference at the end of run_tests.

Another nice thing about override() is that it reports
when you never actually needed the mock, and this
commit fixes the instances found here.

I didn't replace every call to __Rewire__. The
remaining ones fall under these categories:

    * I looked for ") =>" in my code sweep,
      so I missed stuff like "noop" helpers.

    * Sometimes we directly update something
      in a module that's not a function. This
      is generally evil, and we should use setters.

    * Some tests have setup() helpers or similar
      that complicated this code sweep, so I
      simply punted.

    * Somes modules rely on intra-test leaks. We
      should fix those, but I just punted for the
      main code sweep.
2021-03-07 11:19:33 -05:00
Steve Howell 8ab5475b37 zjsunit: Allow multiple overrides again.
I now let folks override the same target multiple
times inside of `with_overrides` (and then indirectly
inside of `run_test`.)

I may re-impose this restriction in the future, since
most violations are due to code smells, but there are
a few legitimate use cases for this, and the code
can handle it, plus I want to remove some other
ugliness first.
2021-03-07 11:19:33 -05:00
Steve Howell eea78df688 node tests: Clean up mock_module calls.
This is a deceptively ugly diff.  It makes
the actual code way more tidy.

I basically inlined some calls to mock_module
and put some statements in lexical order.
2021-03-07 09:35:58 -05:00
Steve Howell 7cf62cd6b1 node tests: Avoid __Rewire__ for clipboard API. 2021-03-06 14:33:30 -05:00
Steve Howell f54f7cfc33 node tests: Introduce mock_module helper. 2021-03-06 13:15:04 -05:00
Steve Howell 167fda142c node tests: Remove __esModule cruft.
We just set __esModule in our rewiremock helper.
2021-03-06 12:36:07 -05:00
Steve Howell 30c7108955 zjsunit: Remove rewiremock dependency.
We now just use a module._load hook to inject
stubs into our code.

For conversion purposes I temporarily maintain
the API of rewiremock, apart from the enable/disable
pieces, but I will make a better wrapper in an
upcoming commit.

We can detect when rewiremock is called after
zrequire now, and I fix all the violations in
this commit, mostly by using override.

We can also detect when a mock is needlessly
created, and I fix all the violations in this
commit.

The one minor nuisance that this commit introduces
is that you can only stub out modules in the Zulip
source tree, which is now static/js.  This should
not really be a problem--there are usually better
techniques to deal with third party depenencies.
In the prior commit I show a typical workaround,
which is to create a one-line wrapper in your
test code.  It's often the case that you can simply
use override(), as well.

In passing I kill off `reset_modules`, and I
eliminated the second argument to zrequire,
which dates back to pre-es6 days.
2021-03-06 11:10:57 -05:00
Steve Howell 8006c29748 node tests: Extract create_sortable for testing. 2021-03-06 11:10:57 -05:00
Steve Howell e81bf846a9 node tests: Remove ui_init test.
I created this test in Jan 2019 with
6b7a4f8611.

At the time I created this we were still migrating modules
over from using the $(() => {...}) style of initialization,
so the test served a purpose as an easy smoke test that we
weren't doing something really stupid in
ui_init.initialize().

Now that that migration is complete, the test's warts start
to outweigh its benefits.  Because it's just a smoke test,
we get credit for artificial line coverage where we're
exercising code without actually verifying anything other
than that it runs without crashing.

There are still possibilities for bugs within
ui_init.initialize() where we initialize modules in the
wrong sequence, but I am not confident that the node test
would catch them with any more likelihood (or clarity) than
either the puppeteer tests or czo bug reports.

And then on top of that, the zjquery setup in the node test
is hard to maintain. It's also hard to verify that some
of the setup isn't cruft.

If you want to see how much of a maintenance headache this
has been in recent times, just look at how many of the
recent commits have been related to things like es6
migrations or code cleanup sweeps.

We should just kill it.
2021-03-06 05:43:39 -05:00
Steve Howell 5b2d48aedb node test: Extract compose_video tests. 2021-03-05 18:33:01 -05:00
Josh Gilley de74d2fd7c settings: Use HTML table for "Alert Words" for better icon alignment.
"Alert Words" is one of Zulip's oldest settings UI elements, and as a
result is buggy.  This commit converts it to use our standard
progressive-table-wrapper system used for settings tables, which has
the side effect of fixing a bug that mad ethe tables look pretty bad
if one adds a very long word.

Fixes #17172.
2021-03-05 14:38:56 -08:00
Steve Howell ff09d8af03 node tests: Test empty string for input_pill. 2021-03-05 12:57:20 -05:00
Steve Howell f6edaaab96 node tests: Test upload.feature_check directly. 2021-03-05 12:57:20 -05:00
Steve Howell 779f56d411 node tests: Add test for compose_state. 2021-03-05 12:57:20 -05:00
Steve Howell 886e419731 node tests: Directly test how we add/remove rtl class. 2021-03-05 12:57:20 -05:00
Anders Kaseorg 62532777b1 server_events: Replace deprecated $.now alias.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-04 18:07:47 -08:00
m-e-l-u-h-a-n f4a111e314 compose: Add user presence circles in mention and pm typeahead.
This commit addresses the problem of user's status visibility to
some extent. It adds presence circles, like we have in buddy_list to the
typeahead suggestions that are given for mentioning users in messages.

Tweaked by tabbott to adjust vertical alignment of group mentions as well.

Testing for the changes is done manually in the developement server,
and also by updating frontend tests to address these changes.

Fixes: #17138
2021-03-04 17:06:02 -08:00
Riken Shah d12257e2c1 puppeteer_test: Add missing `await` checking compose content.
assert_compose_box_content should always be called with await.
2021-03-04 09:41:49 -08:00
Riken Shah b23cd2b7d4 puppeteer_test: Skip tests that require file upload for Firefox.
Right now Firefox does not support file upload with puppeteer.
2021-03-04 09:41:24 -08:00
Riken Shah dc5095bad9 puppeteer_test: Add `waitForNavigation` when reloading.
This commit ensures that it waits until the
page is reloaded which avoids uncertain
flake.
2021-03-04 09:40:14 -08:00
Riken Shah de96aeb822 puppeteer_test: Fix `page.url()` for Firefox.
This commit works around an issue with Puppeteer tests on Firefox
where `page.url()` does not show the URL fragment, by adding a
temporary function that solves the issue.
2021-03-04 09:40:14 -08:00
Riken Shah a6c1f02df0 puppeteer_test: Add `is_firefox` option to enable/disable some tests.
This commit introduces the `is_firefox`
option in CommonUtils to identify if a browser
is Firefox or not.

This helps us to avoid calling some tests
that is yet not compatible with Firefox.
2021-03-03 22:04:16 -08:00
Riken Shah 6676aa2f90 puppeteer_test: Change browser default viewport to allow Firefox.
When we run puppeteer with Firefox,
the `--window-size` option does not work,
which makes the bottom part of
the page cut off.

This commit fixes this issue
by setting the screen default viewport
to the maximum size of the window.
2021-03-03 22:01:36 -08:00
Steve Howell b1a871f2e0 node tests: Avoid reset_module for recent_topics. 2021-03-03 07:08:51 -05:00
Anders Kaseorg cce3257f2c zjsunit: Remove babel-plugin-lazy-require.
There are no more require() calls in tested modules.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 099e8fb00e js: Convert static/js/settings_profile_fields.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 7ec8b8980f js: Convert static/js/dropdown_list_widget.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 9e613b1487 js: Convert static/js/message_events.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg d8c793f791 js: Convert static/js/composebox_typeahead.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 5cc1f8d289 js: Convert static/js/ui.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 8dbaf2d680 js: Convert static/js/subs.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 0e90f3be6d js: Convert static/js/compose_actions.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg e74598da17 js: Convert static/js/narrow.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 7a67c06581 js: Convert static/js/message_list.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 68872f44f6 js: Convert static/js/widgetize.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 3e8ddc229b js: Convert static/js/stream_list.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 727208b84c js: Convert static/js/unread.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 9997e13032 js: Convert static/js/unread_ops.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 7ec3fc38fa js: Convert static/js/input_pill.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg ac4e293da5 settings_profile_fields: Use named export from sortablejs.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 19e4328a7b node_tests: Don’t use this in __esModule mock.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 4a2f937732 narrow: Add setter for narrow_title.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 1ec97070e8 node_tests: Move more set_global mocks before zrequire calls.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 79ac5c25b5 zulip_test: Re-export internal functions used by Puppeteer tests.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
sahil839 b53c773987 events: Remove email field from update subscription events.
This commit removes email field from update subscription
events, as email field is of no use in this case.
2021-03-01 14:52:06 -08:00
Anders Kaseorg 2a2373307f node_tests: Remove unused rewiremocks.
Found by running the tests after

sed -i 's/\.with(/.toBeUsed().with(/g' frontend_tests/node_tests/*.js

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 4b1b1950b2 node_tests: Fix ineffective rewiremocks installed after import.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg d8ad63126d js: Convert static/js/billing/helpers.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 2a49ce1b6c js: Convert static/js/search_pill_widget.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 1a8422b152 js: Convert static/js/recent_topics.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 934d4e4e10 js: Convert static/js/panels.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg dc95f06b62 js: Convert static/js/compose_ui.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 8191915e57 js: Convert static/js/emoji_picker.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg b9e1d320e8 js: Convert static/js/typing_events.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg e382389797 js: Convert static/js/reactions.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg a0caabe6c7 js: Convert static/js/bot_data.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 5438a04b84 js: Convert static/js/message_view_header.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg d36c6f23f6 js: Convert static/js/admin.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 972a52ca99 js: Convert static/js/settings.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 65840a2001 js: Convert static/js/settings_user_groups.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg b58b1f080e js: Convert static/js/settings_invites.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg e9c65834ff js: Convert static/js/settings_linkifiers.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 8953c9b6d6 js: Convert static/js/settings_streams.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 793ff996f6 js: Convert static/js/settings_users.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 2501a0412f js: Convert static/js/settings_org.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg d0ffb37320 js: Convert static/js/settings_exports.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 6ffcc0d25b js: Convert static/js/settings_emoji.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg f94b29356c js: Convert static/js/settings_sections.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg c66d616752 js: Convert static/js/settings_bots.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 7a1ce36d4f js: Convert static/js/settings_notifications.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 4d738ebe15 js: Convert static/js/settings_display.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 8e8a2840c4 js: Convert static/js/settings_account.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg db6e3a41d3 js: Convert static/js/confirm_dialog.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 542a77f5d5 js: Convert static/js/reminder.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 5ebc3f1477 js: Convert static/js/realm_logo.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg f577489aa4 js: Convert static/js/realm_icon.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg b2849edfd7 js: Convert static/js/avatar.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg e64c7a9efe js: Convert static/js/upload_widget.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg a7b2e5ba03 js: Convert static/js/hotspots.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 7e9b5efa8a js: Convert static/js/timerender.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 9a0fc5cc87 js: Convert static/js/user_events.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg a832983290 js: Convert static/js/activity.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg afe310f64c js: Convert static/js/buddy_list.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 85ae00ce16 js: Convert static/js/padded_widget.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 170905c065 js: Convert static/js/buddy_data.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 818b5aacb6 js: Convert static/js/presence.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 19bb5fa7ad js: Convert static/js/server_events.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 21c6a3d87a js: Convert static/js/message_fetch.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 7a45ed46af js: Convert static/js/message_util.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 7145cb4a0d js: Convert static/js/message_store.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg ac65935b16 js: Convert static/js/attachments_ui.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg ac4d3bf204 js: Convert static/js/alert_words_ui.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 636587665b js: Convert static/js/starred_messages.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 5ae2f172d0 js: Convert static/js/message_flags.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg e30df92944 js: Convert static/js/hashchange.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg c94ffb5319 js: Convert static/js/hash_util.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 9d318f054f js: Convert static/js/notifications.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 9a3dcb7305 js: Convert static/js/hotkey.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 9d7917749c js: Convert static/js/list_util.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 0200f48a12 js: Convert static/js/navigate.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg b9137e3de8 js: Convert static/js/search.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 9d9c716dd2 js: Convert static/js/search_suggestion.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 940861fd7e js: Convert static/js/typeahead_helper.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 45b8e0244e js: Convert static/js/overlays.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg b3f74af090 js: Convert static/js/popovers.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg c71af35461 js: Convert static/js/stream_popover.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg b408565111 js: Convert static/js/gear_menu.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg fb93be0d94 js: Convert static/js/scroll_bar.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 5b647e3d72 js: Convert static/js/settings_toggle.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg dd84974a15 js: Convert static/js/settings_panel_menu.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 7416022f20 js: Convert static/js/click_handlers.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg f59133db42 js: Convert static/js/ui_util.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 8a07ec5365 js: Convert static/js/night_mode.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 3a90ec30d5 js: Convert static/js/info_overlay.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 5b2b2924be js: Convert static/js/message_scroll.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 26710a4370 js: Convert static/js/ui_report.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 76bfa78beb js: Convert static/js/lightbox.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 68732d4581 js: Convert static/js/floating_recipient_bar.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg e58666e512 js: Convert static/js/list_widget.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 9f881ebe34 js: Convert static/js/resize.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 5ba7153a3b js: Convert static/js/condense.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg dd18b32e04 js: Convert static/js/message_edit.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 031fab7661 js: Convert static/js/stream_edit.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 72ffb33589 js: Convert static/js/stream_events.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg f47090136d js: Convert static/js/stream_muting.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg ad3390e395 js: Convert static/js/stream_topic_history.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 245d6c3a3e js: Convert static/js/stream_data.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg d81ba3698f js: Convert static/js/stream_color.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 374dfc2fda js: Convert static/js/color_data.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 6f660793e7 js: Convert static/js/upload.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 5d3baec4ef js: Convert static/js/compose.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 35afd078f3 js: Convert static/js/transmit.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 1547494e25 js: Convert static/js/compose_state.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg f499c4a858 js: Convert static/js/sent_messages.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 32288d245c js: Convert static/js/local_message.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 10a4d2bcbd js: Convert static/js/markdown.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg ea01e6da5e js: Convert static/js/compose_fade.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 527b6a36b3 js: Convert static/js/reload.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg e05293a257 js: Convert static/js/reload_state.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg b830f53eb5 js: Convert static/js/narrow_state.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg a1e9be884d js: Convert static/js/message_live_update.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 817358ce00 js: Convert static/js/message_list_view.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 68f7bfff56 js: Convert static/js/submessage.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 472f3bc478 js: Convert static/js/poll_widget.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg cfacf68fb8 js: Convert static/js/filter.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 16668904c1 js: Convert static/js/top_left_corner.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 1b151d0472 js: Convert static/js/recent_senders.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 850c3c65e7 js: Convert static/js/pm_list.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 666938f46c js: Convert static/js/pm_list_dom.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 20cfb9ef09 js: Convert static/js/topic_list.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 5a68bda15b js: Convert static/js/user_groups.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 592cd780f5 js: Convert static/js/rows.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg fe4d1e839c js: Convert static/js/message_viewport.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 6e045e4470 js: Convert static/js/muting_ui.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 94a5da325c js: Convert static/js/muting.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg ece27a19bc js: Convert static/js/unread_ui.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 09920af211 js: Convert static/js/channel.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 1dafb143e3 js: Convert static/js/compose_pm_pill.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 000865ceb1 js: Convert static/js/user_pill.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 977e7dfe07 js: Convert static/js/drafts.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 98c4ffa700 js: Convert static/js/scroll_util.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 6477b7631c js: Convert static/js/rtl.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg f85924dd0a js: Convert static/js/keydown_util.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg d5740d43f3 js: Convert static/js/vdom.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 3faae49dc0 js: Convert static/js/loading.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg a3e6ebb04c js: Convert static/js/common.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 4df3fef88f zjsunit: Add babel-plugin-lazy-require.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg b93e00f213 zjsunit: Enable Babel lazy imports.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 48c67700ed node_tests: Convert rewiremock.proxy uses to low level API.
This seems easier to understand and much easier to produce
automatically.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg aee94f141d zjsunit: Remove _patched_with_set_global check.
Most of our set_global usage will disappear as our globals do, anyway.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg db50451a5a zjsunit: Use __Rewire__ for ES modules in with_field.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 8985b5ffc7 zjsunit: Use __Rewire__ for ES modules in override.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 7c860caffc node_tests: Remove unnecessary zrequire calls for ES6 modules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 8947ff10a4 compose: Add setter for wildcard_mention_large_stream_threshold.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg cc3d33b386 node_tests: Unroll ignore_modules loop in ui_init test.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Steve Howell 07b213bd2e node tests: Remove unused parameters.
We were not setting shiftKey or ctrlKey to true.
2021-02-26 14:11:42 -05:00
Steve Howell 4543554daf node tests: Add overrides for hotkeys. 2021-02-26 14:11:42 -05:00
Steve Howell bfcb84774c node tests: Default overlay functions to false. 2021-02-26 14:11:42 -05:00
Steve Howell 87f4fa3323 node tests: Split up hotkey tests. 2021-02-26 14:11:42 -05:00
Steve Howell 70d204ddce node tests: Promote code to module level in hotkeys test. 2021-02-26 14:11:42 -05:00
Steve Howell 3035d1790b node tests: Inline return_true and return_false.
We just use the concise es6 idiom now.
2021-02-26 14:11:42 -05:00
Anders Kaseorg 54c97c4457 node_tests: Consistently move set_global mocks before zrequire calls.
This way, as we convert them to rewiremock, they will become available
before they are imported.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-26 07:55:53 -08:00
Anders Kaseorg 15b1abef3d puppeteer_tests: Fix for recent topics title change.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-25 18:31:54 -08:00
Wesley Aptekar-Cassels 673af19a4d typeahead: Always rank exact string match first.
Previously, exact matches could be pushed off the typeahead list in the
case where there were more prefix matches that happened to rank first,
which is confusing to the user: if an emoji, for instance, falls into
this category, it will never show up in typeahead, which is easy to
confuse with the emoji not existing.

This isn't a perfect fix — there are still cases where it's hard to find
emojis because the prefix-space is very crowded, but it does fix a
category of surprising and frustrating behaviour.

This doesn't come completely without downside - it means that the exact
match emoji will jump to the front of the list, which changes what is
currently conceptually a "filtering" operation to a "filtering and
sorting" operation, but it seems on the whole to be a more ideal
experience. This is particularly notable in the non-typeahead emoji
picker, which uses the same codepath, but this change seems somewhat
desirable even there, since it allows the user to type the name of an
emoji and press enter and have that emoji show up, without having to
visually confirm that they aren't inadvertently selecting a
prefix-matching emoji.

A better solution to this in the long term might be ordering emoji
results by shortest-first as a tiebreaker for alphabetical ordering,
since that should provide the same behaviour while keeping the mental
model as "filtering" (since the sort order won't change as the user
types), but this seems like a reasonable first pass, and changing to
shortest-first ordering after making this change won't break any muscle
memory for existing users.
2021-02-25 17:55:54 -08:00
Aman Agrawal f9537053ea narrow_title: Correct title of RT and all messages narrow.
Recent topics, being the default view, is no longer beta.
2021-02-25 17:32:51 -08:00
Aman Agrawal ce3f1355e1 zulip_logo: Remove custom click handling.
We don't need to handle user clicking on Zulip logo since
changing the hash via the `a` tag takes care of it automatically.

Also, cleanup the narrow.restore_home_state function since
it is no longer being used.
2021-02-25 17:32:32 -08:00
Aman Agrawal f4f37fca14 hashchange: Extract func which checks current hash is in RT. 2021-02-25 17:31:33 -08:00
Aman Agrawal 3e36fe6a1e recent_topics: Don't show topics from unsubscribed streams. 2021-02-25 17:31:33 -08:00
Aman Agrawal e887428dec stream_events: Re-render RT after a stream is (un)muted.
We manually trigger a re-render of RT after a stream is muted
to update the list of topic in RT for the active filter.

This fixes the bug that RT doesn't update correctly
after a stream is muted.
2021-02-25 17:31:33 -08:00
Aman Agrawal bbe1b742c6 recent_topics: Recalculate space for stream list when activating.
If user is in private message narrow, we reduce height of stream
list to allow height for pm list in the left sidebar. We need
to recalculate it when moving out of pm narrow and moving in
rt narrow.
2021-02-25 17:31:33 -08:00
Aman Agrawal a29b328854 MessageListView: Don't reselect message_id if RT is open.
When idle, we try to backfill messages and in the end reselect
the closest message in the list, which can be a unread message
if present.

When recent topics is open, we can backfill messages; but
shouldn't select the message_id otherwise it will mark the
message as read if the message is unread while triggering
`message_selected.zulip`.
2021-02-25 17:31:32 -08:00
Aman Agrawal b5036cd3b3 narrow: Explicitly hide recent topics when changing narrow.
User can go from recent topics to stream / topic narrow via various
means, but all go through narrow.activate, hence we make sure all the
state changes we do in recent_topics.hide are actually applied when we
hide recent topics and go to another narrow.

This fixes the bug that narrowing from left sidebar to a stream
takes user to the top of the narrow.
2021-02-25 17:31:32 -08:00
Aman Agrawal 8d398ddd54 recent_topics: Focus on first table row after first render.
We land user on the first row of the table instead of the search
box because here user can access hotkeys like `w`, `q`, `/`, etc,
which will not be directly available if user is focused in
recent topics search box.

For tests:
We set focus to search by default to avoid mocking a lot of
table html for getting the tests passing.
2021-02-25 17:31:32 -08:00
Aman Agrawal d2c2371c84 recent_topics: Call revive_current_focus as part of redraw process.
This makes more sense as it ensures we revive focus after every
redraw.
2021-02-25 17:31:32 -08:00
YashRE42 2cd234f1b7 recent_topics: Add persistence for filters via localstorage.
Previously the filter would be reset every time the page was
refreshed. This commit adds persistence via localstorage, the tests
follow the pattern used in tests for drafts.

Fixes: #15676.
2021-02-25 17:31:32 -08:00
Aman Agrawal 39d123e355 recent_topics: Make it the default view.
Go to Recent Topics on "#", no hash and "#recent_topics".
Go to Recent Topics as the last destination for escape key.
Map `a` key to All messages and change its hash to
`#all_messages`.
2021-02-25 17:31:32 -08:00
Aman Agrawal 1eafb1d8b3 recent_topics: Move from overlay to a narrow-like view.
Recent Topics is no longer an overlay now, but note that it is
also not a typical messages narrow. It can reside between
an overlay and a Filter in the sense that it is dispalyed as
a typical Filter narrow but has properties of an Overlay.

Compose box is not visible in this view as it will be confusing
to many users and hence compose shortcuts have also been disabled.

Keyboard shortcuts that apply on messages have also been disabled.

The remaining shortcuts that apply to a narrow are still accessible
here.
2021-02-25 17:31:32 -08:00
Steve Howell 092670b278 node tests: Break out view tests for reactions.
The old test here was overly complicated, and
while it got a lot of line coverage, it wasn't
verifying things very precisely.
2021-02-25 13:42:47 -05:00
Steve Howell a577004842 node tests: Test redundant actions in reactions. 2021-02-25 13:42:47 -05:00