Commit Graph

44 Commits

Author SHA1 Message Date
Steve Howell 09ff0c400d tools: Rename tool to check-schemas. 2021-01-20 13:17:32 -08:00
Anders Kaseorg 41f509170b users: Canonicalize the timezone identifier.
While working on shifting toward native browser time zone APIs
(#16451), it was found that all but very recent Chrome and Node
versions reject certain legacy timezone aliases like US/Pacific
(https://crbug.com/364374).

For now, we only canonicalize the timezone property returned in user
objects and not the timezone setting itself.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-10-27 13:42:54 -07:00
Steve Howell 7ff3859136 subscriber events: Change schema for peer_add/peer_remove.
We now can send an implied matrix of user/stream tuples
for peer_add and peer_remove events.

The client code basically does this:

    for stream_id in event['stream_ids']:
        for user_id in event['user_ids']:
            update_sub(stream_id, user_id)

We used to send individual events, which gets real
expensive when you are creating new streams. For
the case of copy-to-stream case, we should see
events go from U to 1, where U is the number of users
added.

Note that we don't yet fully optimize the potential
of this schema.  For adding a new user with lots
of default streams, we still send S peer_add events.

And if you subscribe a bunch of users to a bunch of
private streams, we only go from U * S to S; we can't
optimize it down to one event easily.
2020-10-22 11:19:53 -07:00
orientor 372e010dbb events: Add `op` field to `update_message_flags` events.
`update_message_flags` events used `operation` instead of `op`, the
latter being the standard field used in other events. So add `op`
field to `update_message_flags` and mark `operation` as deprecated,
so that it can be removed later.
2020-08-24 12:42:03 -07:00
Steve Howell 25c3f052cd node fixture: Fix data for realm_user__remove. 2020-08-20 08:40:59 -04:00
Steve Howell b38353f3ff node fixtures: Add author_id key. 2020-08-18 10:43:42 -04:00
Steve Howell 2d5096ea8f minor: Make local var for test_user. 2020-08-18 10:43:42 -04:00
Steve Howell 4f5b214104 minor: Revise disclaimer on node fixtures data. 2020-08-18 10:43:42 -04:00
Steve Howell 35dd6ef93b node fixtures: Use better data for reactions. 2020-08-17 13:00:47 -04:00
Steve Howell 31fd872781 node fixtures: Use better data for subscription update.
The dispatch test here really only cares that values
get passed on.

Note that the dispatch code ignores the email field, because
we only send subscription/update events to the user
whose subscription has changed.
2020-08-17 13:00:47 -04:00
Steve Howell 60b16a92e3 node tests: Add has_zoom_token to event.fixtures. 2020-08-16 11:37:06 -04:00
sahil839 f046c9c58a streams: Add role field to Subscription objects passed to clients.
This commit adds "role" field to the Subscription objects passed to
clients.  This is important preparation for being able to work on the
frontend for this feature.
2020-08-14 16:33:11 -07:00
Steve Howell f4181ea300 node fixtures: Improve realm_user__add.
We also improve the relevant dispatch test a bit.
2020-08-14 10:40:29 -04:00
Steve Howell 8b34a2f755 node fixtures: Use better data for presence.
The dispatch for presence is a trivial one-liner,
so the test just makes sure three important parameters
get passed along.

We will eventually want to use the fixtures data in
other presence-related tests, but for now the only
goal is to make it pass the schema checks.
2020-08-14 10:40:29 -04:00
Steve Howell 8ba55b090a node fixtures: Add id field to realm_filters tuple. 2020-08-08 11:30:46 -04:00
Steve Howell 0825df76d9 node fixtures: Add timestamps for muted topics. 2020-08-06 12:29:43 -07:00
Steve Howell f8a0a3a87e node fixtures: Use more realistic timestamps. 2020-08-06 12:29:43 -07:00
Steve Howell e165629665 dispatch tests: Use better data for realm_export.
We also just make the test express what's actually
happening in the code; we just pass the entire
"exports" section of the event to the settings code
and let it do its thing.
2020-08-06 12:29:43 -07:00
Steve Howell e00e22553e node fixtures: Make attachment data realistic. 2020-08-06 12:29:43 -07:00
Steve Howell d512594382 node fixtures: Use more realistic data for hotspots.
The only thing the dispatch tests really test here is
that we copy the data verbatim from the event into
page_params.
2020-08-05 11:35:47 -07:00
Steve Howell a93a3dc90c node fixtures: Make "op" more explicit.
We follow the naming convention.

I also arbitrarily assign the "op" of
"add" to the attachment event, even
though we don't meaningfully test it.

The situation with attachment from the
dispatch test point of view is that
we just want to test that the one line
of code that calls into attachments_ui
(for all three ops) does get dispatched
correctly.  We eventually want to get
deeper coverage there, but attachments_ui
wasn't written in the most test-friendly
way.  I think it might actually be easy
to fix up attachments_ui to make it a
bit easier to test, but it's out of the
scope of my current PR.

The benefit here is check-node-fixtures
now gives a more concrete plan for
moving schemas to event_schema.py.
2020-08-05 11:35:44 -07:00
Steve Howell f4eaf077f8 node fixtures: Clean up realm_emoji data.
We extract test_realm_emojis, and we make
the name of the event more explicit (adding
the __update suffix).

We also add the "op" of "update" here, which
is sort of a quirk of the api, since we don't
actually have alternatives like add/remove,
and therefore the current frontend code doesn't
look at the "op", and thus the original tests
never had to provide a correct value for it.
2020-08-05 18:07:16 +00:00
Steve Howell 0c1f909c7a node fixtures: Fix stream__delete fixture. 2020-08-05 18:07:16 +00:00
Anders Kaseorg 6ec808b8df js: Add "use strict" directive to CommonJS files.
ES and TypeScript modules are strict by default and don’t need this
directive.  ESLint will remind us to add it to new CommonJS files and
remove it from ES and TypeScript modules.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-31 22:09:46 -07:00
Steve Howell 3be0777341 node fixtures: Sort all the fixture events. 2020-07-29 08:37:18 -04:00
Steve Howell 9a12b57154 node fixtures: Organize realm update events lexically.
I also use double-underscore more consistently.
2020-07-29 08:37:18 -04:00
Tim Abbott 49926bc07b node tests: Fix schema for stream events. 2020-07-27 16:52:29 -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
Steve Howell a6a9897abd node fixtures: Clean up user_group data. 2020-07-25 17:55:57 -04:00
Steve Howell 97c21ff4da node fixtures: Add all flags for update_message_flags. 2020-07-25 17:55:57 -04:00
Steve Howell 2462282631 node fixtures: Add users for various settings.
We should probably remove this field, as it
seems extraneous.
2020-07-25 17:55:57 -04:00
Steve Howell f22d0b8abe node fixtures: Add op for custom_profile_fields. 2020-07-25 17:55:57 -04:00
Steve Howell b63c7d1cbb node fixtures: Add more realistic data for typing. 2020-07-25 17:55:57 -04:00
Steve Howell b4a4f9d568 node fixtures: Add more realistic data for streams/subs. 2020-07-25 17:55:57 -04:00
Steve Howell 7092cbf6f5 node fixtures: Add more realistic data for user events. 2020-07-25 17:55:57 -04:00
Steve Howell aad98aa6cd node fixtures: Add more realistic data for bots. 2020-07-25 17:55:57 -04:00
Anders Kaseorg b65d2e063d js: Reformat with Prettier.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-17 14:31:25 -07:00
Anders Kaseorg f3726db89a js: Normalize strings to double quotes.
Prettier would do this anyway, but it’s separated out for a more
reviewable diff.  Generated by ESLint.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-17 14:31:24 -07:00
MariaGkoulta b10f156250 settings: Add automatic theme detection feature.
With this implementation of the feature of the automatic theme
detection, we make the following changes in the backend, frontend and
documentation.

This replaces the previous night_mode boolean with an enum, with the
default value being to use the prefers-color-scheme feature of the
operating system to determine which theme to use.

Fixes: #14451.

Co-authored-by: @kPerikou <44238834+kPerikou@users.noreply.github.com>
2020-06-21 01:09:01 -07:00
Steve Howell 00e60c0c91 events: Use stream_id for peer_add/peer_remove.
Two things were broken here:
    * we were using name(s) instead of id(s)
    * we were always sending lists that only
      had one element

Now we just send "stream_id" instead of "subscriptions".

If anything, we should start sending a list of users
instead of a list of streams.  For example, see
the code below:

    if peer_user_ids:
        for new_user_id in new_user_ids:
            event = dict(type="subscription", op="peer_add",
                         stream_id=stream.id,
                         user_id=new_user_id)
            send_event(realm, event, peer_user_ids)

Note that this only affects the webapp, as mobile/ZT
don't use this.
2020-06-19 14:48:42 -07:00
Aman Agrawal ccc0c8706c delete_message: Support `bulk_message_deletion`.
Fixes #15285
This event will be used more now for guest users when moving
topic between streams (See #15277). So, instead of deleting
messages in the topic as part of different events which is
very slow and a bad UX, we now handle the messages to delete in
bulk which is a much better UX.
2020-06-15 10:41:12 -07:00
Steve Howell 686ae3eef4 node tests: Use less mocking for stream events.
We now use the real implementation of
`stream_data` in our tests (as well as `people`),
while still just checking stubs for "heavier"
functions that we dispatch to.

Also, we use our regular blueslip helpers.
2020-06-13 15:35:39 -07:00
Steve Howell 186973cde2 refactor: Extract add_peer and remove_peer helpers.
These are basically shims for some deeper refactorings.

I basically just try to make the code express the
problems more clearly:

    - use stream_name instead of sub
    - make early-exit more explicit
    - make it clear that add_subscriber needlessly
      requires a name
    - make it clear we have an unnecessary loop

I also fixed some phony data in the test.
2020-06-13 15:35:39 -07:00
Steve Howell cc7e11f868 node tests: Extract lib/events.js.
The immediate goal here is to make it a little
easier to share code among the node tests.
2020-06-12 14:00:53 -07:00