Commit Graph

4278 Commits

Author SHA1 Message Date
Anders Kaseorg a9320accdc zjsunit: Remove unnecessary Handlebars wrapper function.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-14 12:20:56 -07:00
Steve Howell 398cdbd922 zjsunit: Remove stub_templates helper.
We now use mock_template everywhere.
2021-06-14 12:05:10 -04:00
Steve Howell 1e58e145ab node tests: Use mock_template in stream_list. 2021-06-14 12:05:10 -04:00
Steve Howell 1991218f6c node tests: Use mock_template in rendered_markdown. 2021-06-14 12:05:10 -04:00
Steve Howell 75f196b932 node tests: Use mock_template in recent_topics. 2021-06-14 12:05:10 -04:00
Steve Howell 107c0d480a zjsunit: Improve errors for non-invoked templates. 2021-06-14 12:05:10 -04:00
Abhijeet Prasad Bodas 5a36496ce5 node tests: Use mock_template in typeahead_helper. 2021-06-14 09:17:50 -04:00
Abhijeet Prasad Bodas 3c2dbf1537 node tests: Use mock_template in subs. 2021-06-14 09:17:50 -04:00
Abhijeet Prasad Bodas 9f857e5fc5 node tests: Use mock_template in stream_edit. 2021-06-14 09:17:50 -04:00
Abhijeet Prasad Bodas 1586907371 node tests: Use mock_template in settings_user_groups. 2021-06-14 09:17:50 -04:00
Abhijeet Prasad Bodas de6988b16d node tests: Use mock_template in settings_profile_fields. 2021-06-14 09:17:50 -04:00
Abhijeet Prasad Bodas 30023d4b76 node tests: Use mock_template in settings_org. 2021-06-14 09:17:50 -04:00
Abhijeet Prasad Bodas 9e324c0338 node tests: Use mock_template in popovers. 2021-06-14 09:17:50 -04:00
Abhijeet Prasad Bodas 8a214c9d63 node tests: Use mock_template in drafts. 2021-06-14 09:17:50 -04:00
Abhijeet Prasad Bodas 177eafb72b node tests: Use mock_template in compose_video. 2021-06-14 09:17:50 -04:00
Abhijeet Prasad Bodas b564d5c2f1 node tests: Use mock_template in compose_validate. 2021-06-14 09:17:50 -04:00
Abhijeet Prasad Bodas 09f8a8ec2b zjsunit: Clear require cache also for templates.
This is necessary for the new `mock_template` helper added in
97ad6b6b62 to work correctly without
leaks, since it uses `mock_cjs` under the hood.

This logic was added in 216493aae8.
2021-06-14 09:17:50 -04:00
Steve Howell 103c4c3995 zjquery: Split out zjquery_element.js.
The new file is an easier place to point developers
for the most typical questions about zjquery's
capabilities.
2021-06-12 12:21:44 -04:00
m-e-l-u-h-a-n f76e904154 minor: Add complete tests for pill_typeahead.
Functions for input pill typeahead in pill_typeahead.js
were dependent on other modules for testing, and most of
those only tested the part required to ensure coverage.

As part of changes done to pill_typeahead for code clarity we
split its functions logic to clearly handle three types of
pills instead of hacky checks. So to completely test the logic
for various possible combinations of types, we add separate tests
for these functions.
2021-06-12 07:59:43 -07:00
m-e-l-u-h-a-n 5ad850f1ff minor: Refactor pill_typeahead.js to use include_users check.
Functions in pill_typeahead.js assumed the type of required pills
to be user by default. But this created several readability
issues with its code, as a result, this codebase appeared
hard to change because of hacky checks involved due to this
assumption.

To improve these we use `include_users` check wherever possible
and simplify the code to clarify the logic involved in typeahead
functions in this module.

Also updated existing stream_edit tests to adjust them with changed
code.
2021-06-12 07:59:43 -07:00
Riken Shah 405073d590 puppeteer: Fix the selector for opening the message action menu.
In this 90041ff453,
we remove the `info` class from the message action
menu, that's why it was failing.

This commit replaces it with the correct selector.
2021-06-12 09:00:57 -04:00
Tim Abbott c18ef0b93f puppeteer: Stop using .info class to find element.
In 90041ff453, I failed to consider the
possibility we would be relying on this badly named element directly
in tests.
2021-06-11 18:08:36 -07:00
Anders Kaseorg 60f5a00c09 zjsunit: Undo mock_cjs abstraction violation.
There is no need for mock_template to reach into the internals of
mock_cjs.  Make it a normal caller of mock_cjs.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-11 13:25:40 -04:00
Steve Howell 0b4338b998 node tests: Use mock_template in poll_widget. 2021-06-11 09:54:25 -04:00
Steve Howell 25a0c700d3 node tests: Use mock_template in compose. 2021-06-11 09:54:25 -04:00
Steve Howell d067bdff2d node tests: Use mock_template in alert_words_ui. 2021-06-11 09:54:25 -04:00
Steve Howell ddeb15114d zjsunit: Add mock_template helper.
We want to eliminate stub_templates.
2021-06-11 09:54:25 -04:00
Aman Agrawal 88454307cd recent_topics: Split into three modules.
We split recent_topics module into recent_topics_(ui + data + util).

This allows us to reduce cyclical dependencies which were
created due to large list of imports in recent topics. Also, this
refactor on its own makes sense.
2021-06-10 15:53:05 -07:00
Ganesh Pawar 19fb6114d7 message_edit: Migrate to using `confirm_dialog`. 2021-06-10 12:23:48 -07:00
Ganesh Pawar 4ed643ab8c popovers: Remove `hide_user_profile` from `hide_all_except_sidebars`.
`user-profile-modal` is shown using `overlays.open_overlay` which
disables mouse pointer events. The user can't click anywhere while a
modal is present, except to close it.

We use `hide_all_except_sidebars` and `hide_all` to hide popovers.
But since the user can't interact while a modal is present,
closing it manually is redundant.
2021-06-10 12:16:23 -07:00
Riken Shah f95c539122 custom_check: Avoid use of assert to avoid confusion with assert.equal.
This commit bans the use of `assert` and replaces it
with `assert.ok` to avoid confusion with `assert.equal`.

Fixes #18687.
2021-06-10 09:15:57 -07:00
Anders Kaseorg 5e80068134 puppeteer_tests: Replace incorrect assert calls with assert.equal.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-10 09:15:36 -07:00
aryanshridhar 418c40b2ea settings_users: Refactor user_deactivation modal to confirm_dialog module.
The "email" span in the old modal was not used for styling, just to
support updating the field visually.
2021-06-08 17:57:27 -07:00
m-e-l-u-h-a-n 3f0ed46fa2 left-sidebar: Add topic filter input in zoomed topic view.
Fixes: #18505.
2021-06-08 15:09:26 -07:00
Palash Raghuwanshi 2718a8ea63 node tests: Replace incorrect assert with assert.equal in dispatch.js.
This commit fixes the invalid assert call in dispatch.js and also fixes the
invalid settings parameter of update_display_settings__default_view_all_messages
fixture in event.js, it should be all_messages instead of 1.

Fixes #18685.
2021-06-08 10:28:21 -07:00
Anders Kaseorg abce4b6555 puppeteer_tests: Use assert.equal.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-08 10:16:53 -07:00
Anders Kaseorg 40880aa496 node_tests: Use assert.equal.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-08 10:16:53 -07:00
Anders Kaseorg f6663fe0d1 node_tests: Use assert.deepEqual.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-08 10:16:53 -07:00
Anders Kaseorg 0d4c142f0b node_tests: Use assert.fail.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-08 10:16:53 -07:00
Anders Kaseorg c446435f54 puppeteer_tests: Use assert.match.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-08 10:16:53 -07:00
Anders Kaseorg b700b048eb node_tests: Use assert.notEqual.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-08 10:16:53 -07:00
Anders Kaseorg f4235b258e eslint: Fix import/extensions.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-08 10:15:52 -07:00
Steve Howell 94ffef4de9 zjquery: Eliminate css() helper.
We use css() pretty rarely in our codebase, and
it can sometimes be used mistakenly, when a better
alternative is to toggle a class for external css.

It's hard to support the full API in zjquery, so
we just punt and tell folks to create their own
stubs.

Most of the existing tests that were "fixed" here
weren't actually verifying the behavior of the css()
calls, and for those I just create no-op stubs.

In a few places I verify that css() was called as
expected.
2021-06-04 20:08:19 -07:00
Riken Shah 38d9e26a6c refactor: Rename `delete_draft_after_send` to `delete_active_draft`.
This commit renames `delete_draft_after_send` to
`delete_active_draft` for two main reasons:

1) This function does the job of deleting the draft that we
are currently using in compose box and it is independent
of the message sending functionality.

2) This is prep refactoring for new drafts behavior where
we delete the draft if the compose box is cleared and
closed.
2021-06-04 09:47:14 -07:00
sahil839 d8c4b96b12 setting: Divide user_invite_restriction into a checkbox and dropdown.
This commit divides the user_invite_restriction setting dropdown to
a checkbox and a dropdown.
The checkbox is used for 'realm_invite_required' setting and dropdown
for 'realm_invite_to_realm_policy'.

This separation of UI elements is fine as these two settings are
separate in database also and also helps in removing excess if-else
conditions and switch cases.
2021-06-03 18:45:29 -07:00
sahil839 8846df6b53 node_tests: Deduplicate test_sync_realm_settings in settings_org tests.
There was a lot of duplicate code in test_sync_realm_settings where
each value in common_policy_values was being tested for different
policies (create_stream_policy and invite_to_stream_policy).

This commit deduplicates is by using a for-loop for testing all
common_policy values and extracting the code as a function to test
different policies.
2021-06-03 18:45:29 -07:00
m-e-l-u-h-a-n fa34f793a7 recent topics: Display other sender names in tooltip.
It is a follow up for #18451.
2021-06-03 14:55:40 -07:00
Tim Abbott 746d3e8dcb presence: Disable 'Idle' for users with idle status.
Previously, we oddly displayed "Last active: Just now" for users in
this situation, which doesn't make any sense.
2021-06-03 14:53:21 -07:00
Tim Abbott 16bd6e6b1d presence: Use consistent logic for displaying last active time.
Previously, we had this complicated layering where the right sidebar
logic would display "Last active: foo" but the user popovers would
just display "foo", which doens't make any sense, since the two
settings have equal context about the string.

We deduplicate that and also arrange that the "Last active:" prefix is
used when it's not clear what we're talking about; i.e. all the values
except for "Active now".
2021-06-03 14:53:21 -07:00
Priyank Patel 2441138a7b settings_orgs: Use button element for save-discard button.
There is no clear reason to not use a button element here. According
to the spec pharasing content, which includes the <span> element,
are allowed in the button element.

Manually tested both buttons to make sure it works and made sure all
the selectors are updated by grepping all the selector classes/id in
the handlebars templates that are parents of the button or are
present on the button.

(One of the jQuery handler code got reformatted due to it fitting
the line limit due to one character deletion for the selector)
2021-06-03 12:41:10 -07:00