Commit Graph

39002 Commits

Author SHA1 Message Date
Anders Kaseorg d751e0cece puppet: Don’t install netcat.
It’s been unused since commit 0af22dad18
(#13239).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-03 10:33:47 -07:00
Steve Howell 81b6583d28 node tests: Show coverage link when we regress coverage.
In 6653e19e3a we added
the convenient line to tell folks about the coverage
report.  But if we failed coverage checks, we didn't
show the link.

Arguably we should just always show this, even if
tests fail, but that can also be potentially confusing.
2020-09-03 07:57:58 -04:00
Steve Howell dc1795a3da node tests: Find files in Python.
The code to run single files was added
in c15695e514,
and it's just kinda strange code.

We already do a lot of file logic in Python
to check for line-coverage, so it's easier
to just have all the logic in Python.

This adds a new feature--you can now specify
the actual file:

    ./tools/test-js-with-node frontend_tests/node_tests/people.js

(This is helpful if you just want to use
shell autocomplete.)

Another minor change is that if you specify
individual files, we won't sort them.  This is
important when you're trying to hunt down test
leaks.

Finally, we have a nicer message if we can't find
the file.
2020-09-03 07:57:58 -04:00
Steve Howell e9bbfbc624 node tests: Clean up nyc arguments.
nyc was added in 29f04511c0

All the stuff after "&&" was actually passed to
node, because we didn't use shell=True, so the
"nyc report" command didn't run, and the ugly
finder.js code just skipped over all the final tokens.
2020-09-03 07:57:58 -04:00
Anders Kaseorg b84260014a populate_analytics_db: Replace intermediate list with generator.
Followup to commit ab120a03bc (#16265).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 19:34:48 -07:00
Anders Kaseorg d9860d40a6 dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 19:34:37 -07:00
Aman Agrawal 66a1037f06 test: Use variable instead of hard coded value. 2020-09-02 17:58:19 -07:00
Anders Kaseorg 0682d5c0f3 provision: Convert "".format to Python 3.6 f-strings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 17:27:14 -07:00
Anders Kaseorg 424b441bb1 provision: Check for old Ubuntu or Python before starting Python.
This unblocks us from being able to use Python 3.6 syntax in
provision.py and its dependencies.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 17:27:14 -07:00
Anders Kaseorg c1618c16c1 eslint: Enable import/no-cycle.
Also remove import/no-unresolved, which is already implied by
plugin:import/errors.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 13:14:39 -07:00
Anders Kaseorg c5a904fb05 django_api, test_classes: Use Python 3 form of super().
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:31:46 -07:00
Anders Kaseorg 691f8f8e47 test_hash_reqs: Use mock from unittest.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:26:12 -07:00
Anders Kaseorg 02725d32dd python: Rewrite list() as [].
Suggested by the flake8-comprehensions plugin.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg a276eefcfe python: Rewrite dict() as {}.
Suggested by the flake8-comprehensions plugin.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg a610bd19a1 python: Simplify away various unnecessary lists and list comprehensions.
Loosely inspired by the flake8-comprehensions plugin.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg 9048f79e53 test_stripe: Simplify with iterable unpacking.
Issue suggested by the flake8-comprehensions plugin, although the
solution is simpler.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg 0e5e6d0890 email_notifications: Convert list() of generator to comprehensions.
Suggested by the flake8-comprehensions plugin.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg ab120a03bc python: Replace unnecessary intermediate lists with generators.
Mostly suggested by the flake8-comprehension plugin.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg 1ded51aa9d python: Replace list literal concatenation with * unpacking.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:15:41 -07:00
Anders Kaseorg a5dbab8fb0 python: Remove redundant dest for argparse arguments.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:04:10 -07:00
Anders Kaseorg 4d583e3d41 test_openapi: Drop Python 3.5 code in get_standardized_argument_type.
Also flip the Python 3.6 and 3.7+ cases to consider the modern version
as the “normal” case.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:02:55 -07:00
Anders Kaseorg edaed497ed lint: Remove unused ignorelongline and lint:ignore comments.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:00:44 -07:00
Anders Kaseorg 72d2e5df15 isort: Enable black profile.
Our isort configuration was almost Black-compatible, but we were
missing ensure_newline_before_comments.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-02 11:00:07 -07:00
Aman Agrawal 22665414fe landing-page: Fix carousel indicators alignment.
Reset to bootstrap v2.3.2 moved the indicators to top right, we
change it back to its previous location in this commit.
2020-09-02 10:59:22 -07:00
Steve Howell 8a210923e1 node tests: Prevent theoretical leak from Intl.
Because `util` is so late in the alphabet, this
leak never surfaced in practice, but I tried running
the node tests in reverse, and this leak came
up if you ran `util` before `stream_list`.  I guess
it's nice that `stream_list` actually exercises
the difference between a dumb sort and an
Intl-aware sort.

It's possible that we should just assume that
Intl.Collator is always available at this point,
which would eliminate the need for this test.
2020-09-02 13:45:03 -04:00
Steve Howell fb96407607 node tests: Avoid unnecessary people mocks.
The first mock here probably hasn't been
needed for a long time, and the second one
is easily addressed by making hamlet be
the current user.
2020-09-02 10:48:51 -04:00
Priyank Patel 551a19c90d js: Convert people module to ES6. 2020-09-01 19:55:58 -07:00
Priyank Patel aca77e9245 js: Convert pm_conversations module to ES6.
This was converted automatically using a jscodeshift script followed
by running eslint and prettier to convert let -> const (whenever
applicable) and removing "use strict;".
2020-09-01 19:55:58 -07:00
Priyank Patel a691f0c527 eslint: Disable no-use-before-define for functions.
There are lots of function that will be used before they are defined
when we migrate to ES6 from CommonJS, so disable this rule. Functions
are hoisted and processed by webpack so this is fine.
2020-09-01 19:55:58 -07:00
Priyank Patel b7998d3160 js: Purge people module from window. 2020-09-01 19:55:58 -07:00
Priyank Patel d774bba1b9 js: Purge pm_conversations module from window.
All the changes are done using a script followed by updates to Node
tests and running eslint and prettier to fix formatting issues.
2020-09-01 19:55:58 -07:00
Priyank Patel 305a1ac57d node_tests: Don't remove require cache of module in zrequire.
There is good reason to do this (explanation is bit long!). With the
TypeScript migration, and the require and ES6 migrations that come
with it, we use require instead of set_global which loads the entire
module. Suppose we have a util module, which is used by some other
module, say message_store, and util is being required in message_store
since it is removed from window. Then, if a test zrequires
message_store first, and then zrequires the util module qand mocks one
of its methods, it will not be mocked for the message_store
module. The reason is:
 1. zrequire('message_store') leads to require('util').
 2. zrequire('util') removes the util module from cache and it is
    reloaded. Now the util module in message_store and the one in
    the test will be different and any updates to it in tests won't
    be reflected in the actual code.

Which can lead to confusion for folks writing tests. I'll mention this
can be avoided doing zrequire('util') first but...that is not ideal.

And, since there was one outlier test that relied on this behavior,
we add the namespace.reset_module function.
2020-09-01 19:55:58 -07:00
Priyank Patel 5c53c44ee5 dependencies: Upgrade babel-plugin-rewire-ts to v1.4.0.
This version keeps the internal and external state of the ES6 module
in sync so its state is similar to a CommonJS module.  Since we don't
need to ask rewire for the internal state of the module, the tests
will be same as they were before the TS/ES6/remove from window
migrations.
2020-09-01 19:55:58 -07:00
S-Abhishek 55a23754c3 api: Fix trailing '/' at end of jitsi server url.
Some users setup zulip with trailing / at end, like 'https://meet.jit.si/
leading to extra / on clients while generating video chat link.

This commit removes trailing '/' if it exists to make it consistent. Manual
testing was done by generating jitsi url.

Fixes #16225
2020-09-01 17:29:31 -07:00
Tim Abbott 63101db3ce template context: Remove jitsi_server_url.
This field was not used in any of our templates; the actual encoding
of this value for clients is in zerver/lib/events.py.
2020-09-01 17:29:31 -07:00
Anders Kaseorg c74b1b22c1 eslint: Forbid unnecessary path segments in imports.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-01 16:43:02 -07:00
Anders Kaseorg 6398bcbd2f eslint: Forbid .js and .ts extensions on imports.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-01 16:43:02 -07:00
Anders Kaseorg 279e4b819e js: Elide .js and .ts extensions from imports and requires.
This will be required for TypeScript.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-01 16:43:02 -07:00
Anders Kaseorg b9184eee65 eslint: Use eslint-import-resolver-webpack.
This uses our Webpack configuration to more accurately predict how our
imports will actually behave; for example, it automatically resolves
the .ts extension.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-01 16:43:02 -07:00
Anders Kaseorg 2bfb590391 package.json: Move testing dependencies to devDependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-01 16:43:02 -07:00
Anders Kaseorg 10bd7a47c4 webpack: Move webpack.config.ts to top level.
We lost the war against top level configuration files many moons ago.
This is what developers and tools expect.  And it seems to be required
for eslint-import-resolver-webpack (there’s ostensibly a {"config":
"tools/webpack.config.ts"} option, but it doesn’t work correctly:
https://github.com/benmosher/eslint-plugin-import/issues/1861).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-01 16:43:02 -07:00
Steve Howell 8dc24e2a20 webhooks: Clean up args to log_exception_to_webhook_logger.
We eliminate optional parameters and replace `request_body`
with `payload`.

There is much less confusion if we just pass in `payload`,
and then we optionally re-format it if it's json.

For unclear reasons the original code was trying to
do `request_body = str(payload)` when `request_body`
was no longer being used.
2020-09-01 15:10:16 -07:00
Mateusz Mandera 9b50c49ea7 streams: Mark all messages as read when deactivating a stream.
The query to finds and marks all unread UserMessages in the stream as read
can be quite expensive, so we'll move that work to the deferred_work
queue and split it into batches.

Fixes #15770.
2020-09-01 11:24:27 -07:00
Aman Agrawal 2de98ab6e1 settings: Don't use css classes starting with `icon`.
Fixes #16252.

icon* classes are used by bootstrap for displaying glyphicons.
We removed these classes in our custom version of bootstrap 2.1.1;
but since our reset to v2.3.2, they have been added again and hence
any classes starting with icon* in zulip will have to be renamed.
2020-09-01 10:56:02 -07:00
Mateusz Mandera 74d3e83e24 tests: Use real path when getting commands in TestCommandsCanStart.
In 468c5b9a58 we changed the method of
getting the list of management commands. Using app_config.path has a
caveat in that the value depends on the path from which we're executing.
An example of things breaking can be reproduced by calling
/home/vagrant/zulip/tools/test-backend TestCommandsCanStart

This makes the app_config.path values to start with /home/vagrant/zulip,
but DEPLOY_ROOT in the dev environment is set to /srv/zulip.
/home/vagrant/zulip is a soft link to /srv/zulip, so it's a valid path
to call test-backend through, but it causes self.commands to end up
being an empty list. We fix this by converting app_config.path to the
real path.
2020-09-01 10:55:07 -07:00
Tim Abbott 40c840f88a message_edit: Remove duplicate tabindex declaration. 2020-08-31 22:57:21 -07:00
Mohit Gupta 353e36ea0b user_info_popover_content: Replace href="#" with tabindex="0".
Fixes: #15448.
2020-08-31 22:55:29 -07:00
Mohit Gupta 98da8cd7f2 popovers: Add keyboard support for user popovers in right sidebar.
This commits adds arrow, vim_up/vim_down and enter hotkey support for
navigating the open popover menu.
2020-08-31 22:55:29 -07:00
Mohit Gupta 937c85d278 popovers: Add keyboard support for starred message popovers in sidebar.
This commits add arrow, vim_up/vim_down and enter hotkey support for
navigating the popover menu when it is open.
2020-08-31 22:55:28 -07:00
Mohit Gupta a1d3707bfb popovers: Add keyboard support for All Messages popover in sidebar.
Even though right now it have one option added arrow, vim_up/vim_down
and enter hotkey support for navigating the popover menu if it is open.
2020-08-31 22:55:28 -07:00