Commit Graph

3950 Commits

Author SHA1 Message Date
YashRE42 e0cedb15fc message_flags: Verify early return from update_starred_flag. 2021-03-30 14:40:13 -07:00
YashRE42 53473decc7 message_flags: Add coverage to setTimeout call from send_read. 2021-03-30 14:40:13 -07:00
YashRE42 bb51fe075a message_flags: Verify early return from send_read on_sucess. 2021-03-30 14:40:13 -07:00
YashRE42 ba8a6affd4 message_flags: Add collapse and uncollapse coverage. 2021-03-30 14:40:13 -07:00
YashRE42 6394a59a5f message_flags: Use override to mock ui.update_starred_view. 2021-03-30 14:40:13 -07:00
Steve Howell ec80d2d5db sidebar toggles: Lift code to display PM counts.
We now consistently set the PM counts for the right
sidebar toggle in unread_ui, similar to what we
do for the overall counts in the left sidebar toggle.
(Use a thin window to see the code in action.)

This breaks a dependency cycle.

In passing I improve the test coverage for the
actual job that pm_list still does (updating its
own total count in the "Private Messages" section).
2021-03-30 12:07:51 -07:00
Anders Kaseorg 6f764ce4b3 message_list: Downgrade message_list.all to MessageListData.
This data structure has never been one that we actually render into
the DOM; instead, its role is to support clicking into view that
contain muted streams and topics quickly.

This downgrade makes that situation much more explicit, and is also
useful refactoring to help simpify the upcoming changes in #16746.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-30 08:33:47 -07:00
Aman Agrawal e8b7ad886d recent_topics: Don't revive focus when RT is not in focus.
When there is any overlay or popover open or user is focused on
any other input, we don't revive focus within recent topics.

Fixes #17875
2021-03-30 07:53:37 -07:00
Anders Kaseorg d43ac7357a js: Move current_msg_list, home_msg_list to ES6 module message_lists.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-29 18:23:47 -07:00
Steve Howell e08bd9b1af refactor: Move all_topics_in_cache.
This is a pure code move.

The diff is bit cluttered by the necessity
to add with_field when we moved the test.
2021-03-29 14:53:57 -07:00
Steve Howell 415e6a486f refactor: Extract echo.update_message_lists.
We lift the code out of message_store.reify_ids
into its only calling module (echo.js).
2021-03-29 14:53:57 -07:00
Steve Howell 6bad6c8837 refactor: Move pm_conversations.process_message.
I lift this function out of message_store to
break some dependencies, and it's also more
consistent with the rest of the codebase:

    alert_words.process_message
    pm_conversations.process_message
    recent_topics.process_messages
    recent_senders.process_message_for_senders

We can do further cleanup to make these names
consistent (and possibly have them all work in
bulk), but that's out of the scope of the current PR.
2021-03-29 14:53:57 -07:00
Steve Howell 45d806d9aa refactor: Extract message_helper.process_new_message.
We move the message_store.add_message_metadata function
(and all its dependencies) into a new module called
message_helper and rename the function to process_new_message.
(It does a bit more than adding message metadata, such
as updating our message store.)

We also have a "protected" interface now in message_store,
so that message_helper can access the message store:

    update_message_cache
    get_cached_message

Because update_message_cache is identical to
the former create_mock_message, we just renamed it
in the tests.

Most callers should use these functions:

    message_helper.process_new_message (setting)
    message_store.get (getting)

It's slightly annoying that the setter interface
is in a different module than the getter interface,
but that's how you break a bunch of dependencies.

We also extract the tiny message_user_ids class:

    user_ids()
    add_user_ids()

All the code moves here are pretty trivial, and
the code that was moved maintains 100% line
coverage.

The module name `message_helper` is not ideal, but it's a single
function and it'll save time to just do the topology change now and
leave thinking through the right name to later.
2021-03-29 14:53:57 -07:00
Riken Shah a00225d603 puppeteer_tests: Log-out at the end of every test.
When migrating from Casper to Puppeteer, some tests
were missed for adding log-out calls at the end.

This commit adds log-out calls to those missed tests.

Also, As we are resetting the test database after each
run (from 99f8be6a12) it will better to log out because we are
not resetting Tornado's internal state. It'd help us prevent
any future flakes.
2021-03-29 08:14:59 -07:00
tushar912 5c50732008 user groups: Add remove event.
Before this we did not have remove event in server_events_dispatch.js
for the user group delete event even though server had. This was
leading to blueslip errors. Extracted the logic which was used in
 success() of channel.del for user_groups into the remove case in
server_events_dispatch. Also removed the redundant reload call as
we already do that in server events.
2021-03-28 16:18:09 -07:00
Steve Howell d9e4c2285c refactor: Break stream_data's dep on stream_color.
We simply lift the DEFAULT_COLOR constant to stream_data.
2021-03-28 15:55:55 -07:00
Steve Howell 98372cd244 refactor: Make home_view_loaded into a callback.
This reduces our extraneous deps from 72 to 71.
2021-03-28 15:55:55 -07:00
Steve Howell c67f82b073 refactor: Extract narrow_banner module.
This is a mostly verbatim extraction.

I re-phrased one line of code to work around a lint
false alarm. (Look for `preamble` in the diff.)

There are about 8 lines missing coverage here, so
the new module might be a good candidate to get
100% line coverage on.

Before this change, you would need to remove 74
edges from our dependency graph to make it
acyclic. Now it's 72.
2021-03-28 15:55:55 -07:00
Steve Howell e72f208fde refactor: Move insert_message to echo.
This change does not impact the overall complexity
of our dependency graph (at least in terms of the
number of edges that we would need to remove to get
a tree), but it does clarify the picture a bit.
2021-03-28 15:55:55 -07:00
Anders Kaseorg 7f89cb9535 eslint: Enable spaced-comment rule.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 16:32:25 -07:00
shanukun bc2d58ad4a custom_profile_fields: Remove op field for the event.
* `op` (operation) field, added in f6fb88549f, was never intended for
`custom_profile_fields` event. This commit removes the `op` as it doesn't
have any use in the code.

* As a part of cleanup, this also eliminates the schema check warnings
for `custom_profile_fields` event, mentioned in #17568.
2021-03-26 16:28:33 -07:00
tushar912 2cf51139cf custom profile fields: Rename "CHOICE" to "SELECT" in frontend.
This requires a small backend change to the label.
2021-03-26 11:49:11 -07:00
Anders Kaseorg a05899f1b5 js: Convert static/js/csrf.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 10:17:56 -07:00
Anders Kaseorg 38ffd47b90 js: Convert static/js/page_params.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 10:17:56 -07:00
Anders Kaseorg bb1b2048bd js: Convert static/js/i18n.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 10:17:56 -07:00
Anders Kaseorg 84f4229194 node_tests: Remove unnecessary zrequire calls for ES6 modules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 10:17:56 -07:00
Anders Kaseorg 7656d44abc js: Simplify code using default parameters and destructuring.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 09:21:46 -07:00
Vishnu KS def1e01512 i18n: Translate quote and reply mention text.
Fixes #17479
2021-03-25 10:38:33 -07:00
Ganesh Pawar 947ce2b79d minor: Check if typeahead query exists.
When a user entered an invalid character (whitespace or characters not
present in a name), the cleaned-up array, and hence the query,
would be empty which resulted in an error.

Fixes #17542
2021-03-25 02:08:51 -07:00
Anders Kaseorg e62b0d6b5f puppeteer_tests: Translate logged traces and errors with source maps.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-25 02:05:19 -07:00
Anders Kaseorg da9783fd10 puppeteer_tests: Log page errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-25 02:05:19 -07:00
Anders Kaseorg ed8c4fec98 puppeteer_tests: Log browser console output.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-25 02:05:19 -07:00
Nishant Mittal b845694e72 dropdown_list_widget: Display default_text for invalid values.
Fixes #16946.
2021-03-25 01:25:18 -07:00
m-e-l-u-h-a-n 2699048208 markdown: Extend user mention syntax to support user_id for mentioning.
Extend our markdown system to support mentioning of users
by id also. Following these changes, it would be possible
to mention users with @**|user_id** and silently mention
using @_**|user_id**.

Main intention for extending the mention syntax is to make
it convenient for bots to mention a users using their ids. It
is to be noted that previous syntax are also supported.

Documentation tweaked by tabbott for better readability.

The changes were tested manually in development server, and also
by adding some new backend and frontend tests.

Fixes: #17487.
2021-03-25 00:44:56 -07:00
YashRE42 abd959cf6a server_events_dispatch: Throw blueslip from typing based on event.op. 2021-03-24 15:04:00 -07:00
YashRE42 a93adbfa76 server_events_dispatch: Throw blueslip from stream based on event.op. 2021-03-24 15:04:00 -07:00
YashRE42 f69de35267 server_events_dispatch: Throw blueslip from realm_user based on op. 2021-03-24 15:04:00 -07:00
YashRE42 27ac45e71b server_events_dispatch: Throw blueslip from realm_domains based on op. 2021-03-24 15:04:00 -07:00
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