Commit Graph

3458 Commits

Author SHA1 Message Date
Steve Howell 16ad65dd66 zjsunit: Restrict overrides to once-per-function.
We can relax this restriction in the future, but
basically every time it came up for me, the test
code was just disorganized, or it had an easy
workaround.
2021-02-11 11:29:21 -05:00
Steve Howell 90730a18d9 node tests: Simplify stream_events.
These are still kind of a mess.

The old code combined the worst of both worlds:

    - we had one monolithic test
    - we called the events multiple times,
      verifying a different stub each time

Now I make the tests more granular.

We could actually re-combine the tests, but
in a nicer way, so that we just set
up multiple stubs and verify that all stubs
get correctly invoked.
2021-02-11 11:29:21 -05:00
Steve Howell fcf5a66aeb node tests: Move streams tests to dispatch_subs.
There is also some code cleanup here--in dispatch_subs,
we don't stub stream_data, so it's easier to write
deeper tests that actually validate the data changes.
2021-02-11 11:29:21 -05:00
Steve Howell 90ca1ded13 node tests: Split up dispatch tests. 2021-02-11 11:29:21 -05:00
Steve Howell 6f25a372ab node tests: Reuse message_list stubs.
We now just override these functions to close
on local variables.
2021-02-11 11:29:21 -05:00
Anders Kaseorg 741c0ac8ca node_tests: Change stub/events pattern to work with non-global modules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-11 07:35:28 -05:00
Anders Kaseorg 2f6c9b8d0e zjsunit: Change override API to work with non-global modules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-11 07:35:28 -05:00
Steve Howell d67cc2d080 slugs: Fix regex for legacy stream slugs.
This prevents a bug where we interpret "2something"
as a modern slug instead of a legacy stream name.

The bug was probably somewhat unlikely to happen in
practice, since it only manifests if 2 is an actual
stream_id.
2021-02-10 14:37:34 -08:00
Anders Kaseorg 1ec9304eee js: Convert static/js/spoilers.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 4360a13dd6 js: Convert static/js/stream_ui_updates.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 8a6fdb662a js: Convert static/js/search_pill.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg e16687af83 js: Convert static/js/settings_ui.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 63ce32b36e js: Convert static/js/typing.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 881d6c437b js: Convert static/js/tutorial.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg f3fb01a430 js: Convert static/js/colorspace.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 4c37748712 js: Convert static/js/user_status_ui.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 583febeffd js: Convert static/js/user_status.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 229aacb819 js: Convert static/js/user_search.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 6775715b9f js: Convert static/js/server_events_dispatch.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 5655e326c9 js: Convert static/js/alert_words.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg f3af16db3f js: Convert static/js/invite.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg a935af9243 js: Convert static/js/pill_typeahead.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 118edf8982 js: Convert static/js/copy_and_paste.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 9dd03998f8 js: Convert static/js/zcommand.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 1a45d53f3a js: Convert static/js/echo.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg f66441adb2 js: Convert static/js/zform.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 4513ef8861 js: Convert static/js/todo_widget.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg a1dc8e37a2 js: Convert static/js/topic_zoom.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 2771434aad js: Convert static/js/stream_sort.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 8bbb0d9193 js: Convert static/js/search_util.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 37f362f75a js: Convert static/js/feature_flags.js to ES6 module with modzulator.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg c292342d0e node_tests: Remove irrelevant set_global calls for ES6 modules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg 89aa3155a9 node_tests: Don’t read from most deprecated global variables.
We still need to write to these globals with set_global because the
code being tested reads from them, but the tests themselves should
never need to read from them.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 07:40:22 -08:00
Anders Kaseorg 34e37cea1c puppeteer_tests: Don’t read from most deprecated global variables.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 07:35:11 -08:00
Anders Kaseorg 76b6ab78d8 node_tests: Remove unnecessary zrequire calls for ES6 modules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 07:35:11 -08:00
Abhijeet Prasad Bodas 9cb41c2976 refactor: Extract `excludes_muted_topics` logic.
This commit makes it so that MessageListData
methods always attempt to filter muted messages.
We later, in a new function
(`messages_filtered_for_topic_mutes`)
check if `excludes_muted_topics` is true or not,
and skip the filtering work if it isn't.
This new function consistently returns a new list.

This refactor will later allow us to write clean
and concise code as part of mute users.

This commit also refactors the muting tests
for MessageListData, which were earlier
spread across two `run_test` functions.
These tests should remain organized,
since similar tests will be added as part of
user mutes in future commits.
2021-02-10 07:53:05 -05:00
Abhijeet Prasad Bodas 9ae44c769c refactor: Rename MessageList.muting_enabled.
Previously, the `muting_enabled` property of
MessageListData class was used to indicate whether
some messages in the message list need to be
filtered due to topic muting, depending on the
narrow. For example, we exclude messages belonging
to muted topics from stream narrows, but not from
search narrows.

The name `muting_enabled` is a bit confusing, and hence is
changed to `excludes_muted_topics`.
It is also important that the name be specific, since
a similar new property will be added for user mutes
in future commits.
2021-02-10 07:53:05 -05:00
Steve Howell a532c643c5 node tests: Improve copy_data_attribute_value test. 2021-02-09 10:42:33 -05:00
Steve Howell c1b499ea9e node tests: Simplify poll_widget test.
This is aided by adding a "toggle" helper to zjquery.
2021-02-09 10:42:33 -05:00
Steve Howell 66eaa1698c zjquery: Alphabetize methods. 2021-02-09 10:42:33 -05:00
Steve Howell 7bc4835114 node tests: Remove unnecessary zjquery stubs.
I have a local branch with a hacked up version of
zjquery that lets you basically detect when zjquery
stubs are never actually invoked by real code.

There are some nuances to that kind of audit, so
I haven't pushed the auditing code, but these
are low hanging fruit.
2021-02-09 10:42:33 -05:00
Steve Howell 55150c8195 node tests: Further simplify Mac shortcut tests.
I now just use inline the code to create stubs
for the line items in the markdown_content
container, and I don't add methods to the
zjquery stubs.

And then I use the new "children" feature in
zjquery's `$.create(sel, opts)` to set up
$(".markdown_content"), which means I don't
have to stub `each` any more.
2021-02-09 10:42:33 -05:00
Steve Howell 131375a26e zjquery: Allow passing children to $.create().
It's actually pretty rare in our codebase to
call methods like `$(...).map` or `$(...).each`,
but we now support them better in zjquery.

You can pass a list of child elements now to
`$.create(...)`.
2021-02-09 10:42:33 -05:00
Steve Howell 31f7f26a22 zjquery: Add set_height helper. 2021-02-09 10:42:33 -05:00
Steve Howell e93a4313f3 node tests: Split up adjust_mac_shortcuts test.
We also simplify the non-mac testing.
2021-02-09 10:42:33 -05:00
Anders Kaseorg 9896782fd1 dependencies: Remove XDate.
It’s even more unmaintained than Moment and doesn’t add any
functionality we don’t already have.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-07 06:41:33 -05:00
Anders Kaseorg 42a9e473ae components: Allow passing labels as HTML (but explicitly).
Fixes the sorting button labels in stream settings, which were
regressed by commit f8fbae4d8e (because
the HTML was not marked as being HTML).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-05 20:12:57 -08:00
Anders Kaseorg 87cbd3bf16 node_tests: Use MockDate in timerender test too.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-05 13:46:37 -08:00
aryanshridhar ba197ec97e node_tests: Fixed failing rendered_markdown tests.
Follow up of #16451, since the changes in blueslip
were still referring to Moment as a library within the markdown.
2021-02-05 12:19:08 -08:00
Abhijeet Prasad Bodas e8b4902c8a node tests: Refactor muting test in message_list.
This is a minor refactor in the muting test in
`message_list`.

The `unmuted_messages` function filters out messages only
considering topic mutes, and not stream mutes.
The test previously made it look like we were testing
stream muting, by stubbing the `is_topic_muted` on the
basis of `stream_id`.

This also replaces the stub and uses real data instead.
2021-02-05 11:17:46 -08:00