Commit Graph

23 Commits

Author SHA1 Message Date
Dinesh 2e864d487e puppeteer: Add subscriptions test and required functions.
Tests stream subscriptions and stream creation.
2020-07-26 17:10:56 -07:00
Dinesh 2835092010 puppeteer: Make fill_form function empty text fields before filling. 2020-07-26 17:10:56 -07:00
Dinesh 56c5e0318f puppeteer: Remove set_pm_recipient.
Previous commit introduced same function in pm_recipient object.
So, this comit removes the duplicate `set_pm_recipient`.
2020-07-26 17:10:56 -07:00
Dinesh 4998e32b10 puppeteer: Add compose tests and required functions in common.js.
Thanks to Priyank Patel for helping debug flakes.
2020-07-26 17:10:56 -07:00
Anders Kaseorg e3b3df328d eslint: Replace sort-imports with import/order.
import/order sorts require() calls as well as import statements.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-24 09:42:56 -07: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 883e2fd325 js: Remove inner spacing from object literals.
We’re configuring Prettier with bracketSpacing: false.  Generated by
ESLint.

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
Anders Kaseorg e014ea966a eslint: Enable comma-dangle for functions.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-03 16:55:51 -07:00
Anders Kaseorg b0253c5a2e eslint: Enable arrow-parens.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-03 16:53:39 -07:00
Priyank Patel 8391250e60 puppeteer: Fix a flake in 02-message-basics.js.
The flake was caused due to the fact that current_msg_list was not
populated with any messages in rare cases. We were missing a check
to guard against current message list having no messages. The
failure screenshot show no messages to prove this.

Relevant error:
Evaluation failed: TypeError: Cannot read property 'raw_content' of undefined
2020-06-25 10:33:23 -07:00
Priyank Patel cb7237c3aa puppeteer: Update the structure of common.get_rendered_messages.
This structure will allows us to verify correct interleaved view.
Design of the API was by Tim.
2020-06-16 11:40:30 -07:00
Priyank Patel 0c239c9ede puppeteer: Add get_renderered_messages and check_messages_sent.
The get_rendered_messages now returns a Map, that is formatted as:
{
  'Verona > topic 1': ['message 1', 'message 2'],
  'You and Cordelia Lear': ['private message 1']
}

We also add check_messages_sent (which was expected_messages in
casper). It now takes in a object, formatted similar to
get_rendered_messages above, instead of an array with topic and
messages.
2020-06-14 13:19:35 -07:00
Dinesh 535fce8c45 puppeteer: Add common methods needed for 02-messages-basics.js.
We include all method needed from casper except
get_rendered_messages, and expected_messages. We will want to tweak
their API when we migrate them.

We also rename bunch of method here while migrating them.
2020-06-14 13:19:35 -07:00
Dinesh fcebf2905e puppeteer_tests: WaitForNavigation until DOMContentLoaded for log_in().
Waiting till DOMContentLoaded event is triggered helps avoid flakes since
puppeteer is very fast and starts doing another task before
everything on the page is loaded. Adding this to log_in function
as almost all tests depend on this which leads to flaky tests if
the other parts of tests just start without even the page being
loaded.
One example this commit helps is for the test `02-site.js`
which is dependent on a function that runs some jquery on the site.
But because of the page not being loaded, we miss jquery and thus
the test fails. `02-site.js` and related code is added in the next
commit.

Co-authored-by: Priyank Patel <priyankp390@gmail.com>
2020-06-07 12:29:59 -07:00
Dinesh 264513a0be puppeteer_tests: Use default user test credentials for log_in().
When no credentials are sent to `log_in` function we want to
use the default generated test credentials. This saves us the
work of importing test_credentials everytime we run this function
in a different test which doesn't focus on what credentials are sent
to login.
2020-06-07 12:29:59 -07:00
Anders Kaseorg f0a19ed8e6 puppeteer_tests: Use assert in strict mode.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-05 16:05:51 -07:00
Dinesh c8268865dc puppeteer_tests: Extract a common function to fill forms.
Co-authored-by: Priyank Patel <priyankp390@gmail.com>
2020-06-03 17:38:03 -07:00
Dinesh d9cc081b2d puppeteer_tests: Move `log_in` and `log_out` functions to `common.js`.
Since `log_in` and `log_out` functions will also be used
in other tests, these are moved to `common.js`.
2020-06-03 17:38:02 -07:00
Priyank Patel 0b698d1173 puppeteer: Take screenshot on failure.
To take a screenshot on failure where we have our common error
handling code in common.run_test method we need to have access to
the Page instance. Currently, we create a new Page in the test method
we pass into run_test, so we pass in a new Page instance to that method
so the test and the run_test method have access to the same Page. And,
then we take a screenshot on failure. It will be saved as `failure-${num}`
in var/puppeteer directory.
2020-05-27 12:50:22 -07:00
Priyank Patel b2f566f53e puppeteer: Add screenshot method to common module.
This will be useful for debugging purposes and we'll use it to take
a screenshot on failure.
2020-05-19 15:58:04 -07:00
Priyank Patel d0a7540534 puppeteer: Add run_test method to common.
This method does all error handling and removes ~5-6 lines of try/catch
block across each test file.
2020-05-19 15:58:04 -07:00
Priyank Patel 41447a0d5c puppeteer: Add a common module for resuable code.
In common.js, we now have a single browser instance for the whole
test. When we update the test-js-with-puppetter to spawn a single
node process, like we do for node tests, we will save time on having
to open an new browser for every test + puppetter start up cost.

We will also add some more helpers here like a method for
filling out a form easily etc.
2020-05-19 15:58:04 -07:00