Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change password playwright tests #1358

Merged
merged 2 commits into from
Mar 25, 2022
Merged

Change password playwright tests #1358

merged 2 commits into from
Mar 25, 2022

Conversation

JeanneSon
Copy link
Contributor

@JeanneSon JeanneSon commented Mar 23, 2022

Description

The following tests have been converted to playwright

Bellows E2E Change Password app
✓ setup: login as user, go to change password page
✓ refuses to allow form submission if the confirm input does not match
✓ allows form submission if the confirm input matches
[previously commented out] should not allow a password less than 7 characters
✓ can successfully changes user's password after form submission

For details/remarks regarding converting the above tests, refer to the spreadsheet; https://docs.google.com/spreadsheets/d/1w9wjfm-02QHLhv0ObPAKKlqnDWeag379GIXwOcRU4W0/edit#gid=0

Type of Change

E2E test

Screenshots

Checklist

  • I have performed a self-review of my own code
  • I have reviewed the title/description of this PR which will be used as the squashed PR commit message
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works

@JeanneSon JeanneSon added the testing Pertaining to unit or e2e testing label Mar 23, 2022
@github-actions
Copy link

github-actions bot commented Mar 23, 2022

Unit Test Results

    1 files      1 suites   11s ⏱️
373 tests 373 ✔️ 0 💤 0

Results for commit 188262c.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@rmunn rmunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I believe I should let Chris review this too before it's merged. Because I've been looking at this code for days, and if there's a flaw in it, I'll miss it because of being too familiar with it by this point.

@rmunn rmunn requested a review from megahirt March 25, 2022 05:40
Copy link
Collaborator

@megahirt megahirt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @JeanneSon and @rmunn - you are paving the way for our E2E tests and in this PR we have established a good pattern:

  • we have a beforeAll() which opens the tab
  • each test() will re-use the existing tab
  • each playwright file will be a unit. Multiple files should be able to be run in parallel
  • test fixtures provide setup data for the application and ease of accessing that metadata

test/e2e/utils/fixtures.ts Outdated Show resolved Hide resolved
JeanneSon and others added 2 commits March 25, 2022 15:42
* Tab fixtures: extract data setup into own function

This is in preparation for creating new admin/member/etc. fixtures
that parallel adminTab, memberTab, etc., but which don't create a
new browser context; they will only carry data.

* Add new UserDetails fixtures (faster than UserTab)

If you just need user details like username, password, etc., it's overkill
to request a whole adminTab or memberTab just to access its username and
password. Instead, we create 'admin' and 'member' (and so on) fixtures to
just contain the data. These fixtures are extremely fast to create, speeding
up some tests that didn't need a full browser tab.

* Speed up change password tests by reusing fixtures

In some cases, it can make sense to reuse a browser context fixture
for efficiency's sake (it can take a second or two to create a new
browser context). The "change password" tests are one such case,
because the tests don't actually need a new browser tab for the ones
that simply verify whether a button is disabled.

Note that when beforeEach was changed to beforeAll, we had to remove
the page.close() and context.close() calls from the fixture setup.
Otherwise we'd have closed changePasswordPage over that browser tab
instance and then immediately closed it when the fixture went out of
scope at the end of beforeAll. Which would result in every test
failing due to its browser tab having been closed!

In this commit, we also use the more-efficient member fixtures instead
of memberTab when all we want is the username and password.

* Improve TypeScript typing of test function

With the `test.extend` feature in Playwright, it's better to extend it
once with a large number of fixture definitions, rather than extend it
multiple times with one fixture each. The former results in a much nicer
TypeScript type overlay when you over over the `test` function later.
@rmunn rmunn merged commit 8bb4430 into develop Mar 25, 2022
@rmunn rmunn deleted the chore/changePasswordTests branch March 25, 2022 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Pertaining to unit or e2e testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants