Commit Graph

97 Commits

Author SHA1 Message Date
Riken Shah e61f73c239 refactor: Lift out log-out call from individual tests to `common.ts`.
We recently added the commit to add the log-out call
after each test (52706908b).

This commit cleans that approach by using
just one log-out call after the test is executed at
`common.ts`
2021-03-31 08:57:18 -04:00
sahil839 46db1da9a9 puppeteer: Wait till background mouse events are enabled in settings test.
This commit adds waitForFunction to wait till the background mouse events
are enabled after closing the modal in the settings test.

This change is needed to avoid the failure that will be caused after we
change the code to handle re-enabling of mouse events only at one place
using 'hidden.bs.modal' event of bootstrap, as this event is fired only
after the modal is completely hidden, and we would want the mouse events
to be enabled before using clicks in further tests.
2021-03-30 17:02:46 -07:00
Riken Shah a00225d603 puppeteer_tests: Log-out at the end of every test.
When migrating from Casper to Puppeteer, some tests
were missed for adding log-out calls at the end.

This commit adds log-out calls to those missed tests.

Also, As we are resetting the test database after each
run (from 99f8be6a12) it will better to log out because we are
not resetting Tornado's internal state. It'd help us prevent
any future flakes.
2021-03-29 08:14:59 -07:00
Anders Kaseorg 38ffd47b90 js: Convert static/js/page_params.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 10:17:56 -07:00
Abhijeet Prasad Bodas 9223dced3b refactor: Rename filter to linkifier in frontend code and docs.
This only leaves `page_params.realm_filters`, which
will be changed in further commits along with the
API change.
2021-03-15 11:19:59 -07:00
Anders Kaseorg e0f0b7f4a7 puppeteer_lib: Remove jQuery dependency from select_item_via_typeahead.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-13 07:02:00 -05:00
Anders Kaseorg 73ca1afc53 puppeteer_lib: Remove wait_for_text.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-13 07:02:00 -05:00
Anders Kaseorg 054f8f8151 puppeteer_lib: Remove jQuery dependency from get_text_from_selector.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-13 07:02:00 -05:00
Riken Shah 3a386fcf44
puppeteer_tests: Fix invalid/incorrect selector for `waitFor`.
We're trying to wait for the subscriptions overlay to close, so we should actually do that.
2021-03-12 13:26:39 -08:00
Riken Shah 812d563bd4 puppeteer_test: Add missing `waitFor` to avoid occasional flakes. 2021-03-12 12:14:37 -08:00
Riken Shah 6421c1d8d9 puppeteer_test/16: Fix "not secure" warning hiding the button.
When typing the password in Firefox,
it shows a "Not Secure" warning which was
hiding the "#get_api_key_button". You can see
the screenshot of it in #17136.

This commit fixes that issue by focusing on the button.
2021-03-12 12:14:37 -08:00
Riken Shah d2980f1042 puppeteer_test/16: Fix `:focus` not working with Firefox.
This commit works around the issue of
`#change_password_modal:focus` not working
for some strange reason with Firefox.
2021-03-12 12:14:37 -08:00
Riken Shah 5e98f80dc3 puppeteer_test: Transform jQuery to puppeteer functions for Firefox.
This commit converts some jQuery code
to builtins puppeteer functions because
it was not working with Firefox.
2021-03-12 12:14:37 -08:00
Anders Kaseorg 4256567b4a puppeteer_tests: Correct {visible: false} to {hidden: true}.
{visible: false} just redundantly specifies the default behavior,
which is to wait for the selector to be present regardless of
visibility.  We want to wait for these selectors to be hidden.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-11 21:05:54 -08:00
Riken Shah b23cd2b7d4 puppeteer_test: Skip tests that require file upload for Firefox.
Right now Firefox does not support file upload with puppeteer.
2021-03-04 09:41:24 -08:00
Riken Shah dc5095bad9 puppeteer_test: Add `waitForNavigation` when reloading.
This commit ensures that it waits until the
page is reloaded which avoids uncertain
flake.
2021-03-04 09:40:14 -08:00
Riken Shah de96aeb822 puppeteer_test: Fix `page.url()` for Firefox.
This commit works around an issue with Puppeteer tests on Firefox
where `page.url()` does not show the URL fragment, by adding a
temporary function that solves the issue.
2021-03-04 09:40:14 -08:00
Anders Kaseorg 79ac5c25b5 zulip_test: Re-export internal functions used by Puppeteer tests.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 8947ff10a4 compose: Add setter for wildcard_mention_large_stream_threshold.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 15b1abef3d puppeteer_tests: Fix for recent topics title change.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-25 18:31:54 -08:00
Aman Agrawal f9537053ea narrow_title: Correct title of RT and all messages narrow.
Recent topics, being the default view, is no longer beta.
2021-02-25 17:32:51 -08:00
Aman Agrawal ce3f1355e1 zulip_logo: Remove custom click handling.
We don't need to handle user clicking on Zulip logo since
changing the hash via the `a` tag takes care of it automatically.

Also, cleanup the narrow.restore_home_state function since
it is no longer being used.
2021-02-25 17:32:32 -08:00
Aman Agrawal 39d123e355 recent_topics: Make it the default view.
Go to Recent Topics on "#", no hash and "#recent_topics".
Go to Recent Topics as the last destination for escape key.
Map `a` key to All messages and change its hash to
`#all_messages`.
2021-02-25 17:31:32 -08:00
sahil839 6b5cf231a1 users: Add new user 'shiva' as realm moderator.
Note that at this point, it's not possible to create moderator users;
this just will make it easier to write tests for logic involving them
as we develop the feature.
2021-02-23 15:00:49 -08:00
Anders Kaseorg 279c4b0e24 puppeteer_tests: Port to TypeScript.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 16:03:10 -08:00
Anders Kaseorg 912c5a28f2 puppeteer_tests: Replace deprecated jQuery event trigger shorthand.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 16:03:10 -08:00
Anders Kaseorg 87e95f43c9 puppeteer_tests: Prefix selector with missing #.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 16:03:10 -08:00
Anders Kaseorg 72142273c0 puppeteer_tests: Remove buggy assert_selector_doesnt_exist helper.
It was checking whether the selector string is itself null, not
whether it selects anything!

Use page.waitForSelector(…, {hidden: true}) instead.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-22 16:03:10 -08:00
Steve Howell b4ab662442 puppeteer: Make subscribe/unsubscribe test more robust.
We generally want to avoid clicking on DOM elements
that may not actually be visible due to the prior
operation.  Instead, we can just find the visible
element after each step.

I also introduce a couple helper functions to
de-clutter the click/unclick/click steps, and I do
a couple extra clicks for good measure.

You can verify that the test will fail if you
add an early return to update_check_button_for_sub.
2021-02-18 11:05:46 -05:00
Anders Kaseorg 34e37cea1c puppeteer_tests: Don’t read from most deprecated global variables.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 07:35:11 -08:00
Anders Kaseorg aa650a4c88 js: Escape strings interpolated into CSS selectors with CSS.escape.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-04 11:00:06 -08:00
YashRE42 b047c03997 puppeteer: Update language_setting_status check for new language data.
Commit f0f6138f01 deleted the
translation for "Saved. Please <a class='reload_link'>reload</a> for
the change to take effect." which caused puppeteer test 16-settings to
fail as it had hardcoded the translation for German. This commit
changes the expected text and hence fixes the failing puppeteer test.
2021-01-20 06:35:41 -05:00
Steve Howell 58dcc70a35 refactor: Remove subscribers from stream_data subs.
This sets us up to use better system-wide data structures
for tracking subscribers.

Basically, instead of storing subscriber data on the
"sub" objects in stream_data.js, we instead have a
parallel data structure called stream_subscribers.

We also have stream_create, stream_edit, and friends
use helper functions rather than accessing
sub.subscribers directly.
2021-01-17 10:40:17 -08:00
Anders Kaseorg 2c5e9f65f8 eslint: Fix new-cap errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-12-10 19:52:22 -08:00
Anders Kaseorg 72d6ff3c3b docs: Fix more capitalization issues.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-10-23 11:46:55 -07:00
Anders Kaseorg 0042cf51c1 eslint: Fix unicorn/better-regex.
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/better-regex.md

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-10-07 16:00:33 -07:00
Anders Kaseorg 70a0260ac1 eslint: Fix unicorn/prefer-text-content.
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/prefer-text-content.md

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-10-07 16:00:33 -07:00
sahil839 44cee1428a compose: Rename all_everyone_warn_threshold.
We rename all_everyone_warn_threshold to
wildcard_mention_large_stream_threshold as we would
be adding wildcard_mention_policy and this
constant will also be used to show error
in case when wildcard_mention_policy is set
to admins only.
2020-10-01 12:06:08 -07:00
Dinesh ade7cc4ef3 puppeteer: Fix typing issue in settings test.
The failures saying incorrect password were caused due to
change in focus. Some actual code of ours calls focus on
the modal when opened but puppeteer was starting to type
before this occurs due to which the test was only able
to enter a part of string.

This was happening with change full name too but less
frequently as it's a relatively shorter string.

As a fix, we wait till the focus is on the modal and then
start typing.
2020-09-28 10:54:53 -07:00
Anders Kaseorg d72423ef21 eslint: Replace empty-returns with consistent-return.
Instead of prohibiting ‘return undefined’ (#8669), we require that a
function must return an explicit value always or never.  This prevents
you from forgetting to return a value in some cases.  It will also be
important for TypeScript, which distinguishes between undefined and
void.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-25 15:17:59 -07:00
Anders Kaseorg 9238813135 js: Use destructuring for require statements.
This allows import/order to auto-fix blocks including these
statements.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-23 09:06:07 -04:00
Dinesh cc4f35bfa8 puppeteer: Wait for save button before checking the text.
Found a flake that this caused with runs for the previous fix.
The waitForSelector was in a wrong order.
2020-09-09 13:14:16 -04:00
Dinesh 6dc2547336 puppeteer: wait for visibility before click -- admin test.
Wait for disable_stream_notifications selector to be visible
before clicking as it could cause flakes if the test tries
to click without it being visible.
2020-09-09 13:14:16 -04:00
Dinesh 1f62ba5750 puppeteer: Fix unsaved status selector waitFor timeout.
Added a stronger validation of waiting for text "Verona" to
appear but that didn't really seem to have worked though it
seemed like fixing the flake by passing ~600 runs.
So, change the puppeteer click to a click through evaluate
as we had experiences where page.click() didn't work sometimes.

Though this has passed 1000 runs on CI, I'm not very certain
if this fixed it as this test passed 1000 times with my previous
PR fixing the same flake.
2020-09-09 13:14:16 -04: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
Dinesh 2d22d88700 casper: Remove few traces of casper.
Now that all casper tests have been migrated to
puppeteer, there's no need for having casper
related things.

Removed the casperjs package and removed/replaced
casper in few places with puppeteer.

Only removed few of them which I'm confident
about. Also didn't make any changes in docs
as it would be easier to remove them while
adding puppeteer docs.
2020-08-30 17:16:02 -07:00
Dinesh 62c69af6d5 puppeteer: Migrate narrow test from casper. 2020-08-30 15:02:52 -07:00
Dinesh 6bf231c576 puppeteer: Change table to zfilt in stars test.
check_messages_test should have table set to zfilt
instead of zhome as we are narrowed to only starred
messages.

Found it as the test failed with the previous commit.
2020-08-30 15:02:52 -07:00
Dinesh 28d65b391c puppeteer: Set visible: true to fix flakes.
These `waitForSelector`s appear just after page loads.
Though they worked most of the times, a few clicks weren't
getting registered because of these selectors not appearing
and thus causing flakes as the modal takes time to appear.
Adding visible: true asserts that it's visible and not just present.
2020-08-30 14:59:05 -07:00
Dinesh dcc47dcc12 puppeteer: Wait for display settings section to appear before clicking.
In few rare cases the click on display settings section wasn't working
which was causing the test to stay in the "your account" settings section.
This lead to a waitFor fail.

The screenshot in this failed CircleCI build suggests the above.
https://app.circleci.com/pipelines/github/chdinesh1089/zulip/525/workflows/cd77e269-6a3e-4283-b765-d1c4584ccf35/jobs/1807/artifacts

This and the previous commit along with the changes to prevent
logging out of user on changing password were tested by running
this test 1200 times and all of them passed!
2020-08-30 14:59:05 -07:00