Commit Graph

3333 Commits

Author SHA1 Message Date
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
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
bfb06c939c node tests: Add test() wrapper for topic_list_data. 2021-03-12 17:52:04 -05: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
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
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
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
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