Commit Graph

1624 Commits

Author SHA1 Message Date
Rohitt Vashishtha aa0c9a1a2a zblueslip: Convert node_tests/dict.js to zblueslip. 2018-04-30 10:12:55 -07:00
Rohitt Vashishtha 65bb2f3c40 zblueslip: Convert node_tests/channel.js to zblueslip. 2018-04-30 10:12:55 -07:00
Yashashvi Dave 7bbe44d7a0 org settings: Remove "Delete streams" administrative tab from settings.
Fixes #9227
2018-04-30 17:47:34 +05:30
Tim Abbott 7d6bb3dcb4 settings: Remove obsolete default_desktop_notifications setting.
This actually hasn't been hooked up to do anything in years.

While we're at it, we remove the entire "Zulip Labs" settings page.
2018-04-28 13:46:07 -07:00
Shubham Dhama 7f679bcdce org settings: Make allowed domain table status element fade out. 2018-04-28 13:24:59 -07:00
Shubham Dhama da8157d414 message: Extract function for editability of topic. 2018-04-28 13:00:29 -07:00
Steve Howell 160931377f node tests: Test deactivating streams. 2018-04-28 11:15:14 -07:00
Steve Howell 6e851f98f6 node tests: Test refreshing pinned streams. 2018-04-28 11:15:14 -07:00
Steve Howell cf24445809 node tests: Add test for stream_list.rename_stream. 2018-04-28 11:15:14 -07:00
Steve Howell 74e7c81c94 node tests: Add coverage for topic zooming.
These tests cover the stream_list side of the interaction.
2018-04-28 11:15:14 -07:00
Steve Howell c22a1d1f23 refactor: Simplify return values for would_receive_message().
Instead of treating false differently from undefined, our
function is now a regular boolean function, and we limit our
code comments to the one corner case where the true/false
decision is kind of arbitrary and possibly confusing.
2018-04-28 11:15:14 -07:00
Steve Howell fe62dacee0 node tests: Add coverage for stream sidebar search. 2018-04-28 11:15:14 -07:00
Steve Howell e9c6f3a07d stream list: Use newer code for the list cursor.
The new list_cursor class is more generic and saves the state
of your cursor across redraws.

Note that we no longer cycle from bottom to top or vice versa.

The node test code that was removed here was kind of complex
and didn't actually assert useful things after calling methods.
2018-04-28 11:15:14 -07:00
Steve Howell 779535fda3 minor: Extract some vars in stream_sort tests.
This is just to make the next commit a bit more convenient.
2018-04-28 11:15:14 -07:00
Steve Howell 605a90ce36 node tests: Reach 100% coverage for scroll_util.js. 2018-04-28 11:15:14 -07:00
Steve Howell 97b9367d20 refactor: Extract scroll_util.js.
We now use scroll_element_into_container() in two different
places, so it's worth extracting.
2018-04-28 11:15:14 -07:00
Steve Howell 068e4bf32b buddy list: Populate user-fade via templates.
When we populate the buddy list or update it for activity, we now
have buddy_data set a faded flag that is rendered in the template.
This avoids some re-rendering overhead and is on the eventual path
to having our widget be more data-oriented (and all rendering happens
"behind" the widget).

We still do direct DOM updates when the compose state changes or
when we get peer subscription events.
2018-04-28 11:15:14 -07:00
Steve Howell d4fc92c1c7 refactor: Rename method to compose_fade.update_all().
The function was misnamed before.
2018-04-28 11:15:14 -07:00
Steve Howell 5d6c9c1b47 compose_fade: Extract user_fade_config.
This commit extracts the key UI elements of updating the buddy
list for compose fade into a configuration, and we interact with
the buddy_list API.
2018-04-28 11:15:14 -07:00
Steve Howell fb712027bf buddy list: Fix and simplify up/down navigation.
This introduces a generic class called list_cursor to handle the
main details of navigating the buddy list and wires it into
activity.js.  It replaces some fairly complicated code that
was coupled to stream_list and used lots of jQuery.

The new code interacts with the buddy_list API instead of jQuery
directly.  It also persists the key across redraws, so we don't
lose our place when a focus ping happens or we type more characters.

Note that we no longer cycle to the top when we hit the bottom, or
vice versa.  Cycling can be kind of an anti-feature when you want to
just lay on the arrow keys until they hit the end.

The changes to stream_list.js here do not affect the left sidebar;
they only remove code that was used for the right sidebar.
2018-04-28 11:15:14 -07:00
Steve Howell f11b3c9934 buddy_list: Clean up selector references.
In this cleanup I make it so that all jQuery selector references
are toward the top of the module, and we do all finds relative
to the container ('#user_presences').

This will make it easier to make a better list abstraction for
the buddy list, for things like progressive rendering.
2018-04-28 11:15:14 -07:00
Steve Howell 65d8eb3189 buddy list: Extract user_search.js.
This was a bit more than moving code.  I extracted the
following things:

        $widget (and three helper methods)
        $input
        text()
        empty()
        expand_column
        close_widget
        activity.clear_highlight

There was a minor bug before this commit, where we were inconsistent
about trimming spaces.  The introduction of text() and empty() should
prevent bugs where users type the space bar into search.
2018-04-28 11:15:14 -07:00
Steve Howell 2879a63bcc buddy list: Relax count limit when doing searches.
A recent change filtered out offline users from the buddy list
whenever the list size would otherwise exceed 600.

This commit reverts half that change--we can now show 600+ users
again, but only when searching.
2018-04-28 11:15:14 -07:00
Shubham Dhama ccd5581bcd org settings: Handle floating point durations better for time limits.
Fixes: #9253.
2018-04-28 09:33:31 -07:00
YJDave 6bef44a9fa org setting: Add time limits for message deleting.
Add realm setting to set time limit for message deleitng.
Set default value of message_content_delete_limit_seconds
to 600 seconds(10 min).

Thanks to Shubham Dhama for rebasing and reworking this.  Some final
edits also done by Tim Abbott.

Fixes #7344.
2018-04-27 19:22:28 -07:00
Steve Howell e5885fa8e4 Add compose.needs_subscribe_warning.
This function replaces part of compose_fade.would_receive_message(),
which has a real janky interface of returning true, false, or
undefined.

We don't need to couple the semantics of compose fading to whether
we help subscribe a mentioned user.  They're mostly similar, but they
will probably diverge for things like bots, and the coupling makes
it difficult to do email -> user_id conversions.

One thing that changes here is that we get the stream name from
compose_state, instead of compose_fade.focused_recipient.  The
compose_fade code uses focused_recipient for kind of complicated
reasons that don't concern us here.
2018-04-26 08:42:47 -07:00
Steve Howell ebe6144326 node tests: Avoid sneaky throttle/debounce delays.
For all of our current tests, we want to just execute
throttled functions immediately.
2018-04-26 08:42:47 -07:00
Steve Howell 58c67d8cba zjquery: Improve errors when handlers aren't set correctly. 2018-04-26 08:42:47 -07:00
Tim Abbott d862bf7b48 casper: Attempt to fix nondeterministic failures in profile fields. 2018-04-26 08:33:56 -07:00
Umair Khan 93bb3e8d6e profile: Add UI for Choice field. 2018-04-26 00:35:54 -07:00
Shubham Dhama b411bc050e org settings: Change join org permissions to dropdown. 2018-04-25 16:00:55 -07:00
Tim Abbott ccb1a00e0a casper: Fix test sequencing for profile tests.
We check data only updated after the get_events call returned, without
actually waiting for that to happen.
2018-04-25 10:21:27 -07:00
Sampriti Panda e86d5139bb copy_and_paste.js: Remove excess newlines while pasting markdown html.
Fixes #8963
2018-04-24 08:27:43 -07:00
Shubham Dhama f19b0b3254 org settings: Change message_edit settings to dropdown.
This coverts the "checkbox" for `realm_allow_message_editing`  and
"input" for `realm_message_content_edit_limit_seconds` into a
dropdown with the option for custom time limit option.
2018-04-23 18:22:35 -07:00
Tim Abbott 3e49850d6b popovers: Fix broken node test.
This seems to have been introduced when rebasing
7533796ea9.
2018-04-23 17:29:15 -07:00
Vishnu Ks 7533796ea9 popover: Add an option to show user profile.
Fixes #8880
2018-04-23 16:56:24 -07:00
Rohitt Vashishtha c43f4e509c zblueslip: Improve usage documentation in test file. 2018-04-23 16:18:35 -07:00
Rohitt Vashishtha bddb6a1a14 zblueslip: Log output for all function calls.
Also adds asserts on blueslip.log() call in node_tests/people_errors.js.
2018-04-23 16:18:35 -07:00
Priyank Patel 7046409e12 Revert "quick fix: Revert ES6 idiom that istanbul warns about."
This reverts commit 55ff9a6806, the issue
about istanbul coverage not working for spread operator is fixed by using
nyc instead.
2018-04-23 15:27:16 -04:00
Tim Abbott 322fc52cd5 people: Suppress reporting late user additions when reloading.
If the browser is in the progress of reloading when it finishes
fetching some messages, it's not really a bug, and we shouldn't report
it as such.

This should help make Zulip's browser error reporting less spammy.
2018-04-23 12:20:27 -07:00
Vishnu Ks c9e932a7ce settings: Add support for Hangouts as the video chat provider.
The only thing that's annoying about this feature is that you need to
be a paying G Suite customer to use it.
2018-04-23 09:39:47 -07:00
Tim Abbott de691e8564 casper: Fix race condition in stars test.
I have no idea why this started failing just now, but the test was
written without a proper wait in between actions, and fixing that
fixes the failure I'd been seeing.
2018-04-23 09:15:12 -07:00
Tim Abbott e4c50ff4fd narrow: Remove unnecessary select_first_unread option.
We consistently either pass a `then_select_id` into narrow.activate,
or were using the select_first_unread option.  Now, we just compute
select_first_unread based on the value of then_select_id.
2018-04-22 21:33:33 -07:00
Tim Abbott 1d5204c82b narrow: Fix incorrect values for use_first_unread_anchor.
Apparently, we were incorrectly passing through something related to
opts.use_initial_narrow_pointer as the value for `use_first_anchor`.

If you read the logic in narrow.js carefully,
use_initial_narrow_pointer was unconditionally false.

The correct value for this attribute is when we're trying to narrow to
the first unread message in a given context.  There are two things to
check:

* then_select_id is -1; i.e. we don't have a specific message ID we're
  trying to narrow around.
* select_first_unread is True, i.e. we're trying to narrow to the
  first unread message.

A bit more work should allow us to get rid of the second condition,
but I'm not quite confident enough to do that yet.
2018-04-22 21:33:14 -07:00
Steve Howell 4b3d07c805 node tests: Localize focus logic for activity.js.
This does a few things:
        * removes some unnecessary setup
        * puts some jQuery setup closer to where it's needed
        * renames some variables
        * adds an assertion about highlighting
2018-04-22 20:08:08 -07:00
Steve Howell 54389f7b41 buddy list: Shrink overly large lists.
If we would have more than 600 people in a buddy list, it's kind of
cumbersome to scroll through it, and it's also expensive to render
it (short of doing progressive rendering, which adds a lot of
complexity).

So, as a short term measure, we filter out offline users whenever the
list would exceed 600 users.  Note that if you are doing a search that
narrows to fewer 600 users, the offline users will appear again.
2018-04-22 20:08:08 -07:00
Steve Howell 3f1930f9c5 buddy list: Extract buddy_data.js. 2018-04-22 20:08:08 -07:00
Steve Howell 536236d9b1 buddy list: Extract buddy_list.js. 2018-04-22 20:08:08 -07:00
Utkarsh Patil 955d03b8a0 emoji: Prefix sort for emojis.
Emoji prefix sort for "popular emojis first". Fixes #7625.
2018-04-21 22:28:45 -07:00
Priyank Patel 55ff9a6806 quick fix: Revert ES6 idiom that istanbul warns about. 2018-04-20 16:33:33 -07:00
Steve Howell 5f53fb1561 refactor: Remove factory code for toggle component.
We now have components.toggle simply return an object, without
putting the object into a lookup table.  The consumers of the
objects have all been changed to just store the object in their
own module scope.

The diff is a bit hard to read here, but it's mostly de-denting
code and removing these things:

        - we don't have opts.name
        - we don't have __toggle.lookup
        - we don't have keys
        - we don't create a sibling object to the prototype object
2018-04-20 13:45:58 -07:00
Priyank 02dddd6b35 node_test: Use let/const instead of var in activity.js.
This was left in previous cleanup.
2018-04-20 15:46:28 -04:00
Priyank 2dd2ab4f7e node_tests: Update alert_words.js to use es6. 2018-04-20 15:46:28 -04:00
Priyank 3174827f93 node_tests: Update channel.js to use es6. 2018-04-20 15:46:28 -04:00
Priyank b1c5f6c07d node_tests: Update bot_data.js to use es6.
bot_data.js uses let/const for variables, and uses rest operator
instead of _.extends.
2018-04-20 15:46:28 -04:00
Priyank 6c8753ef25 eslint: Update eslint config to have es6 env.
This will allow us to use spread operator.
2018-04-20 15:46:28 -04:00
Preston Hansen 76d6c71595 tests: Move zerver/fixtures to zerver/tests/fixtures for clarity.
Fixes #9153.
2018-04-19 21:50:17 -07:00
Rohitt Vashishtha ba21afe9a6 zblueslip: Convert node_tests/people_errors.js to zblueslip. 2018-04-19 15:02:00 -04:00
Rohitt Vashishtha a836473746 zblueslip: Convert node_tests/compose.js to zblueslip. 2018-04-19 15:02:00 -04:00
Rohitt Vashishtha 25c75b66d3 zblueslip: Convert node_tests/emoji.js to zblueslip. 2018-04-19 15:02:00 -04:00
Rohitt Vashishtha 4738644339 zblueslip: Create zblueslip.js for improved error handling.
Adds a basic API for controlling the allowed error messages and
documents the usage in the form of unit tests, similar to zjquery.

Fixes #8675.
2018-04-19 15:02:00 -04:00
Tarun Kumar 55f830c345 server_events_dispatch: Add node coverage for user groups. 2018-04-19 14:59:08 -04:00
Tarun Kumar deab3ac541 hash_util: Add 100% node-coverage for hash_util.js. 2018-04-19 14:59:08 -04:00
Shubham Dhama 9c096840be node tests: Increase coverage for settings_org. 2018-04-19 14:58:12 -04:00
Shubham Dhama 48fe77c61e node tests: Remove repeated zjquery code in settings_org tests. 2018-04-19 14:58:12 -04:00
Joshua Pan 99f07fe2e2 tests: Fully cover top_left_corner.js. 2018-04-19 14:56:55 -04:00
Joshua Pan 09469026c6 zjquery: Allow removeClass() to remove multiple classes simultaneously.
removeClass() now splits class_names by spaces to get multiple
class names. Then removes each individual class name.
2018-04-19 14:56:55 -04:00
Umair Khan 79ff89ed8b profile: Add hint field in the settings UI.
We still don't actually display it in the "Edit your profile" UI.
2018-04-19 11:32:45 -07:00
Steve Howell 6c4f02218e node tests: Add some coverage to list_render.js. 2018-04-17 17:52:19 -07:00
Steve Howell 6b44cdb286 zjquery: Extract make_event_store().
This pushes some of the most complex code of zjquery into its own
object.
2018-04-17 17:52:19 -07:00
Steve Howell 10d1c2fafa zjquery: Extract make_new_elem().
There was really no reason for this to be a nested function, since
we weren't closing on any variables.  Flatter is better.  Also, it
is plausible that folks will want more control over creating
individual jQuery elements (but still want this helper).
2018-04-17 17:52:19 -07:00
Steve Howell fca5cec2af node tests: Remove features to output HTML to files.
I don't think anybody ever really used this feature, which I
developed but don't even use myself.  It kind of runs counter
to the minimalist approach of the rest of node tests.

I would eventually like to re-think the template tests altogether.
They're slow, and we could solve that somewhat by replacing
jsdon/jquery with an HTML parser library to verify structural
things.

It's also possible that we can just rely on our template linters
to catch the biggest class of errors (malformed tags) and let
code review do the rest.

And it's also possible that we should make a second attempt to
ramp up tooling on making it easy to verify templates, but it
doesn't have to be part of the node tests.  If we did that, we
would also potentially use tooling for Python-side templates.
2018-04-17 17:52:19 -07:00
Steve Howell 74c939264b node tests: Add general.js.
This node test module is intended as a way for somebody to
quickly immerse themselves in our node testing methodologies,
plus it has the nice side effect of introducing several modules
(albeit very briefly).
2018-04-17 17:52:19 -07:00
Steve Howell da60d9c757 node tests: Remove unneeded zrequire in typeahead_helper.js. 2018-04-17 17:52:19 -07:00
Steve Howell 617bfa9275 node tests: Add coverage for popovers.js. 2018-04-17 17:52:19 -07:00
Steve Howell 94e9b85042 node tests: Add narrow_activate.js. 2018-04-17 17:52:19 -07:00
Steve Howell b1fd86c5c7 node tests: Add coverage to hashchange.js. 2018-04-17 17:52:19 -07:00
Steve Howell 1568df352d zjsunit: Extract read_fixture_data(). 2018-04-17 17:52:19 -07:00
Steve Howell e70203ad55 node tests: Use zjquery in hotkey.js. 2018-04-17 17:52:19 -07:00
Steve Howell c1a3c85a33 node tests: Clean up emoji tests.
A few things here:

    * Use _.each to follow our convention.
    * Just use new locals to avoid overwriting template and
      avoid strange Object.assign hack.
    * Just use simple string concatenation.
    * Use better var names: full_name, shortcut
    * Use chaining syntax.
2018-04-17 17:52:19 -07:00
Steve Howell 07591f03e2 node tests: Remove unneeded $ stub in compose_fade.js. 2018-04-17 17:52:19 -07:00
Steve Howell b3101ca41b node tests: Remove extra $ declaration. 2018-04-17 17:52:19 -07:00
Steve Howell 3a5b0841e4 node tests: Remove minor cruft from bots_data.js. 2018-04-17 17:52:19 -07:00
Priyank 26d8d98319 frontend_tests: Add prefer-const rule.
This rule checks for use of const wherever needed, currently does
nothing since we don't use `let`, instead we use `var`. This rule
can be used to use refactor a file to use const easily by replaceing
var with let using a editor and then by running
`./node_modules/.bin/eslint frontend_tests --fix --cache`. And then revert
those `let`'s back to `var`.
2018-04-17 12:56:25 -04:00
Priyank 6faa6f96e9 node_test: Convert function to arrow function where needed. 2018-04-17 12:56:25 -04:00
Priyank 7490932e1b node_tests: Use const for constants. 2018-04-17 12:56:25 -04:00
Cynthia Lin 7cbc9f40bf compose: Change styling of upload progress bar.
Related to #9095.
2018-04-16 09:46:35 -07:00
Tarun Kumar 0b62410f5e pm_pill: Achieve 100% node-test coverage for compose_pm_pill.js. 2018-04-13 11:59:57 -07:00
Tarun Kumar 51601fab44 muting: Achieve 100% node-test coverage for settings_muting.js. 2018-04-13 11:59:57 -07:00
Rohitt Vashishtha 7a4788b364 node-tests: Add basic tests for notifications API.
This commit exposes some inner variables of notifications.js to make
them easily testable. The first test added simply checks whether the
showing and closing of notifications works properly, and doesn't yet
verify the main code logic of the notification generation.
2018-04-13 09:13:50 -07:00
Rohitt Vashishtha 703351288a zjquery: Add replaceWith() and selector.location. 2018-04-13 09:13:50 -07:00
Rohitt Vashishtha 2e7f215f44 zjquery: Add option to silently ignore find() errors. 2018-04-13 09:13:50 -07:00
Steve Howell f56b4b7ec2 zjquery: Simplify validation for $(...).
We flatten the code a bit by removing a check that type is object,
and we replace it later with a check that type is string.

We also no longer allow document-like objects to be wrapped based
on the location-attribute-is-present hack.  Instead, we want the
tests to just set document to 'document-stub'.
2018-04-12 11:37:01 -07:00
Steve Howell 368b37e198 zjquery: Add a selector attribute to our wrapped elements.
We might as well have this for debugging purposes and to simplify
the code that happens when we double-wrap DOM elements.
2018-04-12 11:37:01 -07:00
Steve Howell f78947f2ba zjquery: Fix minor typo in comments.
This typo came from s/impl/self/ at some point :)
2018-04-12 11:37:01 -07:00
Steve Howell 174d065b2e zjquery: Add to_$ hook so elements can wrap themselves. 2018-04-12 11:37:01 -07:00
Steve Howell f505f3de04 zjquery: Support $.fn.foo mechanism.
We can now extend zjquery using the $.fn mechanism.  This isn't
necessarily recommended for test code (since you can just stub
individual objects directly), but some of our real code does this.
2018-04-12 11:37:00 -07:00
Steve Howell f5e0794d5c zjsquery: Give special treatment to "body" tag.
We don't do things like $('table') much in our code, but $('body')
is in the code.
2018-04-12 11:37:00 -07:00
Steve Howell 3971fae05d node tests: Fix some leaks with $(...). 2018-04-12 11:37:00 -07:00
Steve Howell 205bcb8ef9 Fix recently broken reactions tests with s/html/text/.
In the real code, as part of a quick security patch, we started
using text() to set values instead of html().  The tests now
reflect this.
2018-04-12 11:29:08 -07:00