Commit Graph

2984 Commits

Author SHA1 Message Date
Steve Howell bd034f5767 node tests: Exercise compose_pm_pill callbacks.
In the next commit we are stubbing out some
code in compose.js that only indirectly tested
these one-liner configs.
2021-02-25 13:42:47 -05:00
Steve Howell 98fc28c8ed node tests: Add explicit test for clearing input pills. 2021-02-25 13:42:47 -05:00
Steve Howell e971cff5b8 node tests: Use override in topic_list_data. 2021-02-24 11:56:40 -05:00
Steve Howell 983f1d66fd node tests: Break up reactions test. 2021-02-24 11:56:40 -05:00
Steve Howell 0ab3649182 reactions: Simplify code to choose popover target.
We now only assign target once, rather than
assigning it then overwriting it for the
not-sent-by-me use case.

I tried to extract a "selector" here but the linter
complained.

Splitting up the tests here ensures we don't
needlessly do extra work here.  (In the prior
clumsy implementation, the second test that
I split out here would fail due to the lack
of us setting up the jquery stub.)
2021-02-24 11:56:40 -05:00
Steve Howell da1cd57d5f node tests: Use override in more places. 2021-02-24 11:56:40 -05:00
Steve Howell b57873050f node tests: Consolidate message_store.get stubs. 2021-02-24 11:56:40 -05:00
Steve Howell fe28303376 node tests: Clean up narrow tests.
I do the following:
    - hoist some imports
    - split big test into three
    - use some of actual compose_state implementation
2021-02-24 11:56:40 -05:00
Steve Howell 70fff472c3 node tests: Use zjquery text() method for input_pill test. 2021-02-24 11:56:40 -05:00
Steve Howell aa21ccf61f node tests: Avoid silly stub in filter test. 2021-02-24 11:56:40 -05:00
Steve Howell dd2552e5f5 node tests: Split up echo test. 2021-02-24 11:56:40 -05:00
Anders Kaseorg 6ff28577cc js: Convert static/js/message_list_data.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-23 20:36:01 -08:00
Anders Kaseorg f9c4b5438e js: Convert static/js/localstorage.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-23 20:36:01 -08:00
Anders Kaseorg 901a1e16cf js: Convert static/js/list_cursor.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-23 20:36:01 -08:00
Anders Kaseorg 8add2ffc4e js: Convert static/js/fetch_status.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-23 20:36:01 -08:00
Anders Kaseorg 5a22e73cc6 ui: Remove warning for unsupported old Zulip desktop app.
This warning was added in #6551.  It’s not for any version of the
current Electron app, which we warn about on the server side with
DESKTOP_WARNING_VERSION, but rather some pre-Electron app so ancient I
don’t even know what it is.  Apparently it communicated using the
window.bridge global, so eradicate that too.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-23 18:14:12 -08:00
Anders Kaseorg ba0ee6ddfa dependencies: Upgrade Source Sans Pro font to Source Sans 3.
https://blog.adobe.com/en/2020/11/30/whats-new-in-source-sans-3.html

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-23 14:55:33 -08:00
Anders Kaseorg 174fa0a331 node_tests: Revert wrong conversion of some functions to arrows.
‘function’ and ‘=>’ are not equivalent because they bind ‘this’
differently.  For these functions, the ‘function’ semantics are
intentional.

This reverts part of commit 1a241cef88
(#17388).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-23 11:35:55 -08:00
Steve Howell 1a241cef88 node tests: Use array syntax more aggressively. 2021-02-23 09:15:36 -05:00
Steve Howell 2262f79cc8 node tests: Use override/with_field in billing.
This prevents the possibility of future leaks.
2021-02-23 09:15:36 -05:00
Steve Howell 009a6e0145 node tests: Use override in widgetize. 2021-02-23 09:15:36 -05:00
Steve Howell dbf514a055 node tests: Remove unnecessary test_ui wrappers. 2021-02-23 07:55:43 -05:00
Steve Howell ac69450681 zjsunit: Clear $ elements in run_test.
We now call $.clear_all_elements at the top
of run_test.

We have to exempt two modules from the new regime:

    compose
    settings_user_groups

Also, if modules do set_global("$", ...) we don't
try to call the non-existent function.

It's possible we'll want to move to something like
this, but we might want to clean up the two
sloppy_$ modules first:

    // AVOID THIS:
    // const $ = require("zjquery")

    run_test("test widget", ({override, $}) => {
        override(foo, "bar", ...);
        $.create(...);
        // do stuff
    });
2021-02-23 07:55:43 -05:00
Steve Howell 81fd1a5e6a node tests: Introduce test_ui wrappers.
These are a prep step for the next commit.
2021-02-23 07:55:43 -05:00
Steve Howell 2fae9dc0a2 node test: Stub out first element of search box. 2021-02-23 07:55:43 -05:00
Steve Howell 0b711516c9 node tests: Fix zjquery leaks in recent_topics. 2021-02-23 07:55:43 -05:00
Anders Kaseorg 7e3735b9ba node_tests: Don’t read page_params from deprecated global variable.
Follow up to commit 89aa3155a9 (#17262).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 19:46:42 -08:00
Anders Kaseorg 7011f0911d node_tests: Fix misspelled pm_conversation global.
It’s pm_conversations.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 10:17:03 -08:00
Steve Howell ff3175f8a2 lightbox: Export method for testing purposes.
We weren't exercising this method in any
meaningful way during the tests, and when
do add coverage, we probably want to just
test it directly.

We also kill off stub_selector(), which was
never well-documented.
2021-02-22 12:38:07 -05:00
Steve Howell aed5b65525 node tests: Avoid use of stub_selector.
We will eliminate this soon.
2021-02-22 12:38:07 -05:00
Steve Howell d62ef78e9c node tests: Avoid stub_selector() in activity tests. 2021-02-22 12:38:07 -05:00
Steve Howell 42c2c9fb2d zjquery: Avoid array-related hacks.
Callers can either explicitly pass in children,
stub out $(...)[0] as needed, or just
circumvent jQuery complications with override.

Note the reactions test was broken before,
since $(...)[0] was always returning the same
stub.
2021-02-22 12:38:07 -05:00
Steve Howell 914533c8bc zjsunit: Prevent common mistakes with overrides.
We only allow you to replace functions with functions,
unless you have used set_global() or are dealing
with $ from zjquery.
2021-02-22 10:04:29 -05:00
Steve Howell 5caee967d3 zjquery: Remove bogus after/before functions. 2021-02-22 10:04:29 -05:00
Steve Howell 132e67cb28 zjquery: Prohibit extensions to $.fn.
We make an exception for the popovers code.

Luckily it's pretty rare that we extend $.fn
in our real code.
2021-02-22 10:04:29 -05:00
Steve Howell b40d8d5790 node tests: Inline setup for settings_bots.
I also use override in more places, and I add
$.validator to zjquery.

In passing I clean up some IIFEs that aren't
really needed.
2021-02-22 10:04:29 -05:00
Steve Howell 38e3aa490f node tests: Use override for $.post. 2021-02-22 10:04:29 -05:00
Steve Howell 623500bae1 node tests: Avoid zjquery for channel tests.
We create our own stub for $.ajax.
2021-02-22 10:04:29 -05:00
Steve Howell 0ffbea8650 node tests: Break up channel tests. 2021-02-22 10:04:29 -05:00
Steve Howell ffe1043bcc zjsunit: Remove stub_out_jquery.
We now either use zjquery or do whatever gross
things we need to do to work past document.trigger(...)
calls or $.now calls explicitly in the tests.
2021-02-21 17:34:55 -05:00
Steve Howell 64c7eb67eb zjquery: Make zjquery a singleton.
We no longer export make_zjquery().

We now instead have a singleton zjquery instance
that we attach to global.$ in index.js.

We call $.clear_all_elements() before each module.
(We will soon get even more aggressive about doing
it in run_test.)

Test functions can still override $ with set_global.
A good example of this is copy_and_paste using the
real jquery module.

We no longer exempt $ as a global variable, so
test modules that use the zjquery $ need to do:

    const $ = require("../zjsunit/zjquery");
2021-02-21 17:34:55 -05:00
Steve Howell 2e3406f0b8 node tests: Eliminate "silent" option for zjquery.
The "silent" option was kind of evil, as it had
$(...).find(...) passing back "self" instead of a stub.

Now we just use $(...).set_find_results(...) or
override(...) to simulate/bypass drawing code.

(It turns out hash_util didn't even need this option.)
2021-02-21 15:11:31 -05:00
Steve Howell 706e2baf7e node_test: Avoid make_zjquery.
We just use $.clear_all_elements() now.
2021-02-21 15:11:31 -05:00
Steve Howell 9938811759 node tests: Avoid $ override for compose test.
We just use zjquery now.
2021-02-21 15:11:31 -05:00
Steve Howell 895179e8f6 node tests: Make setup for ui_init more local. 2021-02-21 15:11:31 -05:00
Steve Howell b72575d98b node tests: Fix zjquery leaks in stream_list. 2021-02-21 15:11:31 -05:00
Steve Howell 496932bfc6 node tests: Share setup helpers for stream_list. 2021-02-21 15:11:31 -05:00
Steve Howell d207d71753 node tests: Make setup for stream_edit more local. 2021-02-21 15:11:31 -05:00
Steve Howell 3829ab0ea9 node tests: Fix zjquery leaks for popovers. 2021-02-21 15:11:31 -05:00
Steve Howell fc29ee02c8 node tests: Fix zjquery leaks in compose_actions. 2021-02-21 15:11:31 -05:00