Commit Graph

84 Commits

Author SHA1 Message Date
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
Dinesh 0b01a183e2 puppeteer: Migrate realm linkifier test from casper. 2020-08-27 11:45:35 -07:00
Dinesh 5a73c2ca42 puppeteer: Migrate copy paste test from casper. 2020-08-27 11:45:35 -07:00
Dinesh a32c5e5525 puppeteer: Migrate delete message test from Casper. 2020-08-27 11:45:35 -07:00
Dinesh 72b61a4a5f puppeteer: Migrate drafts test from casper. 2020-08-27 11:45:35 -07:00
Dinesh 21dd44cd1b puppeteer: Migrate user deactivation test from casper. 2020-08-27 11:45:35 -07:00
Dinesh 77bea3de7a puppeteer: Fix test flake in admin tests.
This flake occurs because the Verona dropdown menu couldn't be
clicked, in rare cases, because puppeteer would click it too
quickly before it appears and then fails. To fix this we wait for it
to fully appear and then click it. Around 1000 runs
passed without a failure.

The error the flake caused was:
TimeoutError: waiting for selector
"#org-submit-notifications[data-status="unsaved"]" ...
2020-08-21 07:41:28 -04:00
Dinesh b954ed2938 puppeteer: Migrate custom profile test from casper. 2020-08-13 16:24:15 -07:00
sahil839 f9651a1e98 puppeteer: Fix typo in comments in subscriptions tests. 2020-08-12 17:17:57 -07:00
Dinesh 62d3107ac9 puppeteer: Migrate mention test from casper.
Also add helper functions needed.
`select_item_via_typeahead` has been ported from casper
and is exactly same in puppeteer to as I couldn't find
any better way for that purpose.
2020-08-11 10:43:29 -07:00
Dinesh feb2556253 puppeteer: Migrate admin test from casper.
Also adds a required helper function to common.js.
2020-08-11 10:41:44 -07:00
Dinesh a1934797ea puppeteer: Migrate navigation test from casper.
Also adds a helper function that is used in later
tests too.
2020-08-11 10:41:44 -07:00
Dinesh 3b3ed0c2d5 puppeteer: Replace `hidden: false` with `visible: true`.
I had a misconception with hidden and visible options
and thought `hidden: false` was same as `visible: true`
and other way too.

But `hidden: false` or `visible: false` does nothing
more than checking if the selector exists.

Also, to mention, `visible: false`'s were fixed in
33e19fa7d1
2020-08-11 10:41:36 -07:00
Anders Kaseorg c155403884 docs: Fix various capitalization errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-08-11 10:25:52 -07:00