Commit Graph

38437 Commits

Author SHA1 Message Date
Anders Kaseorg 0b4483c8d2 settings_panel_menu: Convert make_menu to an ES6 class SettingsPanelMenu.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-26 17:00:05 -07:00
Anders Kaseorg 025f49dbc4 poll_widget: Convert poll_data_holder to an ES6 class PollData.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-26 17:00:05 -07:00
Anders Kaseorg 2e94914be4 list_cursor: Convert list_cursor to an ES6 class ListCursor.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-26 17:00:05 -07:00
Anders Kaseorg 9d90ae0e69 fetch_status: Convert FetchStatus to an ES6 class.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-26 17:00:05 -07:00
Anders Kaseorg a1796325de buddy_list: Convert buddy_list_create to an ES6 class BuddyList.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-26 17:00:05 -07:00
Anders Kaseorg a1295936a4 message_list_view: Convert MessageListView to an ES6 class.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-26 17:00:05 -07:00
Anders Kaseorg 8e5574fbe6 message_list_data: Convert MessageListData to an ES6 class.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-26 17:00:05 -07:00
Anders Kaseorg 7249103ab4 message_list: Convert MessageList to an ES6 class.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-26 17:00:05 -07:00
Steve Howell 49db62c240 refactor: Have markdown depend directly on emoji.
Now that emoji is in our shared library, we can
require it directly from markdown without
re-introducing any `window` dependencies.
2020-07-26 16:50:14 -07:00
orientor 7bb5fac8e0 test_message_send: Mark tests using intentiionally undocumented features.
Some parameters such as `to` and `topic` have been intentionally
undocumentecd hence fail request validation. So mark tests which
fail due to this accordingly.
2020-07-26 16:26:57 -07:00
orientor bdf9d912e3 test_classes: Use OpenAPI request validator for validating requests.
Expand the `validate_api_response_openapi` function to also validate
requests to ensure better testing.
2020-07-26 16:26:57 -07:00
orientor c91c106cfb openapi_py: Change condition for invalid requests.
Change the condition for allowing failed validation to the condition
that `if the test fails, response status code begins with 4`. Also
add `intentionally_undocumented` argument in `validate_request` for
allowing passing of tests which return `200` responses but fail
validation due to some intentionally undocumented feature in
OpenAPI specification.
2020-07-26 16:26:56 -07:00
Mohit Gupta 8b8cfb2e73 test_link_embed: Add assertLogs to prevent spam in test-backend. 2020-07-26 16:14:17 -07:00
Mohit Gupta 0ca3c1d904 test_home: Use assertLogs to test info logs by do_soft_deactivate_users.
This will verify logs without spamming test-backend output.
2020-07-26 16:14:17 -07:00
Mohit Gupta 85fcd0ad99 test_events: Use assertLogs to avoid spam in test-backend output. 2020-07-26 16:14:17 -07:00
Mohit Gupta 4928b55996 test_cache: Use assertLogs to avoid spam in test-backend output. 2020-07-26 16:14:17 -07:00
Mohit Gupta 133a5f2a7c tests: Add assertLogs for test_auth_backends.
This commit tests logging of warning log using assertLogs instead of
printing it in test output hence avoiding spam in test output.
2020-07-26 16:14:17 -07:00
Mohit Gupta 67a67fcc02 tests: Avoid "import logging" and setting root logger level in tests.
Use assertLogs to avoid spamming the test-backend output.
2020-07-26 16:14:17 -07:00
Mohit Gupta c4fe91af74 test_push_notifications: Add assertLogs to verify logging in tests.
This will prevent spam in test-backend output and test logging of logs
by the code being tested.
2020-07-26 16:14:17 -07:00
Anders Kaseorg d2520cd7e0 js: Replace underscore with lodash and remove it from globals.
Tweaked by tabbott to bump PROVISION_VERSION.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-26 16:12:06 -07:00
Anders Kaseorg 9c7a3cc0f4 compose: Replace accidental usage of underscore for “translation”.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-26 16:08:52 -07:00
Steve Howell da8691d7d7 ci: Add new check-node-fixtures tool to CI.
This tool only takes a couple seconds to run,
so it's pretty low risk to add to CI.
2020-07-26 16:07:40 -07:00
Steve Howell f9808d0c15 tools: Add tools/check-node-fixtures.
This makes sure out fixture data for node tests
is realistic, according to the schemas in
zerver/lib/event_schema.py.

Note that we are still in the process of extracting
schemas from test_events.py -> event_schema.py,
so the checks here are somewhat incomplete as of
now.

One nice thing is that the program will tell us
what checkers are missing, so this can motivate
us to move more checkers to event_schema.py.

I considered just making this happen as part of
tools/test-js-with-node, but it's convenient to
run by itself.  Also, it currently requires
Django (although we could fix that), which makes
it just expensive enough that I wouldn't want
to always run it before the node tests.
2020-07-26 16:07:33 -07:00
Steve Howell 0eb206f97e mobile sharing: Make emoji.js a shared ES6 module.
This is a pretty straightforward conversion.

The bulk of the diff is just changing emoji.js
to ES6 syntax.

There is one little todo that can be deferred
to the next commit--we are now set up to have
markdown.js require emoji.js directly, since
it is no longer on `window`.
2020-07-26 16:07:17 -07:00
Steve Howell a028aa5f8a emoji refactor: Avoid util dep with minor hack.
We copy in a one-line function from util that
will soon be replaced with lodash.
2020-07-26 16:07:17 -07:00
Steve Howell 92ed76e3c1 emoji refactor: Pass in emoji_codes from ui_init.
We don't want emoji.js to depend on a JSON file
(and specifically the location of said JSON file)
when we start sharing our code with mobile.
2020-07-26 16:07:17 -07:00
Steve Howell 3e30a7f66e emoji refactor: Move function higher in file.
This preps for ES6 linting rules.  (And it's
nicer for now, too.)
2020-07-26 16:07:17 -07:00
Steve Howell 979c126b07 emoji refactor: Avoid unnecessary exports.
`default_emoji_aliases` was around for a while, and
the `server_realm_emoji_data` was added really
recently by me (oops).
2020-07-26 16:07:17 -07:00
Steve Howell e7e3760588 tests: Extract markdown test for missing emojis.
We now show before/after, and we don't complicate
our other test that runs in a big loop.

And we take advantage of function injection to
not have to hack into the "real" emoji_codes
structure.

Note that we're simulating the missing emojis
at a slightly higher level, but we already had test
coverage that emoji.get_emoji_name returns
undefined for unknown codepoints.
2020-07-26 16:07:17 -07:00
Steve Howell 91de92ce2f ui_init test: Test with real emoji.js. 2020-07-26 16:07:17 -07:00
Steve Howell aedf1660f8 dispatch tests: Make realm_emoji test more robust.
The main thing here is that we check that the
actual data got put into our data structures.

(In general we want to move away from stubbing
data modules; any place where we stub data modules
is a relic of earlier days, where we were just
trying to set the bar for 100% line coverage,
even though some of the original coverage was
quite shallow.)

I also use real stubs instead of noops for
the calls out to UI-oriented modules.

In passing I tweak some comments in the actual
dispatch code.
2020-07-26 16:07:17 -07:00
Steve Howell 69c082e2f6 refactor: Have emoji_picker pull from emoji.
This makes it so that the authoritative holder
of all emoji data is emoji.js, and all our
UI components that need emoji data consistently
pull data from emoji.js as needed.

Or to put it another way, we no longer need the
dispatch module to know that emoji_picker is
coupled to emoji precisely by the active_realm_emojis
data; it can now make fewer assumptions.
2020-07-26 16:07:17 -07:00
Steve Howell 6e9d9b42ca refactor: Rename func to emoji_picker.rebuild_catalog. 2020-07-26 16:07:17 -07:00
Steve Howell ef40767edf emoji: Promote blueslip.error to caller.
The only function that called blueslip had only
one caller, and we are trying to get emoji.js
ready for ES6.
2020-07-26 16:07:17 -07:00
Steve Howell 65ea339a47 emoji tests: Clean up data setup.
With update_emojis, it is pretty easy
to set up the tests with reasonable
data without reaching into internal
data structures.

Also, we can begin the process of
sharing the same data with our
dispatch tests (upcoming).
2020-07-26 16:07:17 -07:00
Priyank Patel 51199878ed tools/ci: Fix KeyError when running tools/ci/generate-dockerfiles.
This KeyError occurs because we remove extra_packages from
images.yml because it was no longer needed in a486872a8e.
2020-07-26 16:03:35 -07:00
Mateusz Mandera 9d1f77edc5 saml: Use self.logger in get_issuing_idp.
get_issuing_idp is no longer a class method, so that akward logger
fetching can be skipped and self.logger can be accessed.
2020-07-26 15:48:48 -07:00
Mateusz Mandera 389c190d49 saml: Fix incorrect settings object being passed in get_issuing_idp.
Fixes #15904.

settings is supposed to be a proper OneLogin_Saml2_Settings object,
rather than an empty dictionary. This bug wasn't easy to spot because
the codepath that causes this to demonstrate runs only if the
SAMLResponse contains encrypted assertions.
2020-07-26 15:48:48 -07:00
palash aba53551ec test: Add order_by in query for RealmAuditLog.
Added order_by("id") clause in query for RealmAuditLog
for consistent output.
It was causing zerver.tests.test_audit_log.TestRealmAuditLog
to fail due to order mismatch.
2020-07-26 15:47:16 -07:00
Steve Howell 28f5dfefea dispatch tests: Use run_test. 2020-07-26 12:50:07 -04:00
Steve Howell d0378b07c7 dispatch test: Remove unneeded blueslip wrapper.
I think this became irrelevant when I moved some
of the code to dispatch_subs a couple months ago.
2020-07-26 12:50:07 -04:00
Steve Howell 978c179e19 node tests: Tweak stream_sort to use run_test. 2020-07-26 12:50:07 -04:00
Steve Howell 7c8dd45da3 node tests: Simplify message_list overrides. 2020-07-26 12:50:07 -04:00
Steve Howell 0d68a23066 zjsunit: Handle duplicate overrides.
We want to undo overrides in reverse order,
which is important if you override the
same name more than once in the same
function.

Until today the code basically prevented
us from ever using the original implementation
of a name we stubbed, and most of them start
as undefined due to their parent modules
starting with `set_global`.

But I do want this proper, and I introduced
a tiny pitfall today.
2020-07-26 12:50:07 -04:00
Steve Howell 10bb60e13d node test: Use override in more places.
I also removed some useless stubs in passing.
2020-07-26 12:50:07 -04:00
Steve Howell c9bb6ab843 node tests: Simplify stream_events.
We use the new override helper passed in to
run_test.
2020-07-26 12:50:07 -04:00
Steve Howell ccfcd2c9ae zjsunit: Have run_test pass in override helper.
The subsequent commits will make it more clear
how this helps.
2020-07-26 12:50:07 -04:00
Steve Howell b086e987b8 zjsunit: Prevent spurious function overrides.
If you use the with_overrides() helper, we will
now detect bogus stubs.
2020-07-26 09:25:40 -04:00
Steve Howell 23e14124aa zjsunit: Only allow functions for overrides.
There was only one place where we weren't
overriding a function, and the use case there
was fairly unique.

Knowing that we're dealing with only functions
will simplify override and allow us to add
features like detecting spurious stubs.
2020-07-26 09:25:40 -04:00
Steve Howell b8b2e31463 zjsunit: Require explicit set_global for overrides.
This forces us to more explicitly document at the
top of the file what dependencies we are stubbing,
plus it's less magical.

Also, we may want to do occasional audits of
set_global to clean up places where we mock
things like stream_data, which are probably just
easier to use the real version of now that we
have cleaner APIs to set up stream data.

The modules most affected by this change are our
dispatch-oriented tests--basically, all the
modules that test handling of Zulip events
plus hotkey.js.
2020-07-26 09:25:40 -04:00