Commit Graph

40425 Commits

Author SHA1 Message Date
Alex Vandiver 12ade4c49d lint: Rely on core gitlint skipping of revert commits.
gitlint 0.13.0 and above skip revert commits[1].  This obviates the
need for a custom rule.

[1] https://jorisroovers.com/gitlint/configuration/#ignore-revert-commits
2021-02-23 14:28:09 -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
Mateusz Mandera e43e0cb9bb docs: Fix Markdown for links in the authentication in development doc.
These were rendering as just plaintext instead of clickable links.
2021-02-23 08:59:11 -08:00
LoopThrough-i-j d1ee2d31c7 examples-python-api: Fix `message_id` type.
The `message_id` was made an `str` object because
the request expected `Dict[str, str]`. The request is now
casted to `Dict[str, Any]` to fix the issue and removed
typecast of `message_id` to str.

python-zulip-api reference:
https://github.com/zulip/python-zulip-api/pull/653
2021-02-23 08:58:00 -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 3ccb4391d8 zjsunit: Restore missing fields correctly in with_field.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 20:21:41 -08:00
Anders Kaseorg 58b18fd499 zjsunit: Handle exceptions in with_field, with_overrides.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 20:21:41 -08: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
Wesley Aptekar-Cassels be9ae9dac8 js: Don't escape "Last active" in buddy list.
This breaks the French translation, and is incorrect in general.
2021-02-22 16:08:25 -08:00
Alex Vandiver 0b736ef4cf puppet: Remove puppet_ops configuration for separate loadbalancer host. 2021-02-22 16:05:13 -08:00
Anders Kaseorg 279c4b0e24 puppeteer_tests: Port to TypeScript.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 16:03:10 -08:00
Anders Kaseorg cdff4cfe53 dependencies: Add ts-node.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 16:03:10 -08:00
Anders Kaseorg 3869727655 dependencies: Upgrade puppeteer from 7.0.4 to 7.1.0.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 16:03:10 -08:00
Anders Kaseorg 8dec7b9270 puppeteer_lib: Use class fields.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 16:03:10 -08:00
Anders Kaseorg 42f4156b36 test-js-with-puppeteer: Error on unhandled promise rejections.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 16:03:10 -08:00
Anders Kaseorg 912c5a28f2 puppeteer_tests: Replace deprecated jQuery event trigger shorthand.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 16:03:10 -08:00
Anders Kaseorg 87e95f43c9 puppeteer_tests: Prefix selector with missing #.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 16:03:10 -08:00
Anders Kaseorg ad540dac3a puppeteer_lib: Supply missing $eval arugment.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 16:03:10 -08:00
Anders Kaseorg 72142273c0 puppeteer_tests: Remove buggy assert_selector_doesnt_exist helper.
It was checking whether the selector string is itself null, not
whether it selects anything!

Use page.waitForSelector(…, {hidden: true}) instead.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 16:03:10 -08:00
Anders Kaseorg 0ca543396a zjsunit: Use clear_zulip_refs as the main way to undo zrequire.
Move clear_zulip_refs into restore, and rewrite it without lodash.  We
no longer need the requires array, and zrequire is now nothing more
than a wrapper around require.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 10:53:49 -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
Aman Agrawal 2b8921bf67 zjquery: Tell user why using tags as selector is invalid.
Like using $('input') is too broad a selector and shouldn't
be used in the codebase. With this error messages, contributors
can easily understand that now.
2021-02-22 10:24:59 -05:00
Aman Agrawal 269457c58b zjquery: Extract func to verify selector. 2021-02-22 10:24:59 -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 89ab76920f zjquery: Prevent direct patches to $.
We prohibit code from making direct patches to
$ unless you use override().
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