Commit Graph

3854 Commits

Author SHA1 Message Date
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