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

Add playwright e2e tests #868

Merged
merged 15 commits into from
Aug 3, 2023
Merged

Conversation

owi92
Copy link
Member

@owi92 owi92 commented Jun 7, 2023

This adds the playwright framework for e2e UI tests as outlined in #855.

Several tests are already included but are still subject to change and improve. Unfortunately some of these can be flaky and are prone to getting stuck when loading and or navigating (in like 10% of all runs). I'm unsure if that is caused by poor test design or outside conditions. Right now the config allows for 2 retries to be extra sure everything passes, but in in my experience 1 retry should suffice.
Edit: Actually, I haven't encountered any test failures in CI so I changed that back to 1 retry.

Especially the realm and block tests might still benefit from breaking them down into smaller chunks, but since so much of these tests depend on one another, I started by doing them in one swoop and in sequence.

I broke each test down into several steps and sub-steps using test.step, but there are definitely other ways of doing this. The benefit of using test.step is mainly for readability and sequentiality (is that even a word? google says it is 🤷)

Another thing to consider for these tests:
Right now they rely on certain events and series to be present somewhere in Tobira, and at least one series block to be present on the "welcome page". I believe this is suboptimal since that data might change in the future (correct me if I'm wrong of course).

@owi92 owi92 force-pushed the add-playwright branch 24 times, most recently from 2dfb5d9 to eab8606 Compare June 8, 2023 14:12
@github-actions github-actions bot temporarily deployed to test-deployment-pr868 June 8, 2023 14:27 Destroyed
@owi92 owi92 force-pushed the add-playwright branch 2 times, most recently from 58c550e to 39b2774 Compare June 8, 2023 15:06
@github-actions github-actions bot temporarily deployed to test-deployment-pr868 June 8, 2023 15:17 Destroyed
@github-actions github-actions bot temporarily deployed to test-deployment-pr868 June 8, 2023 15:30 Destroyed
@owi92 owi92 marked this pull request as ready for review June 12, 2023 08:31
@github-actions github-actions bot temporarily deployed to test-deployment-pr868 June 12, 2023 08:40 Destroyed
Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

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

Finally some tests 🎉

This is just a first review: I have not yet looked at all the files in tests, but at everything else. Most of these comments are mainly questions for me to understand decisions :D After resolving all of that I can have another look at the actual tests.

frontend/playwright.config.ts Outdated Show resolved Hide resolved
frontend/playwright.config.ts Outdated Show resolved Hide resolved
frontend/playwright.config.ts Outdated Show resolved Hide resolved
frontend/playwright.config.ts Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
frontend/tests/languageSelection.spec.ts Outdated Show resolved Hide resolved
frontend/tests/search.spec.ts Outdated Show resolved Hide resolved
frontend/tests/videoPage.spec.ts Outdated Show resolved Hide resolved
frontend/tests/search.spec.ts Outdated Show resolved Hide resolved
Comment on lines +11 to +12
await page.keyboard.press("s");
await expect(searchField).toBeFocused();
Copy link
Member

Choose a reason for hiding this comment

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

Nothing wrong with this, just reminded me: we certainly need tests of typing something in a different input that contains s and making sure in that case, it does NOT jump to the search bar.

@owi92 owi92 added the changelog:dev Changes primarily for developers label Jun 14, 2023
@github-actions github-actions bot added the status:conflicts This PR has conflicts that need to be resolved label Jun 15, 2023
@github-actions
Copy link

This pull request has conflicts ☹
Please resolve those so we can review the pull request.
Thanks.

owi92 added 15 commits June 18, 2023 20:21
Unfortunately, we can't test everything on safari because
it doesn't allow logins on http sites. On the other hand,
skipping some tests also speeds up the total run time...
This should speed up local test runs. Though using more than
4 workers apparently still produces more flaky results.
The implemented solution also doesn't work for multiple concurrent runs
(i.e. using `--repeat-each` in cli runs), because there is
a limited number of dummy users to test user realms simulaneously.
Where possible, text content (like placeholder, label etc) is used
instead. Some elements don't have any text or the text is variable.
In these cases this still uses the `_react=ReactComponent` locator,
but those could also be replaced by using `testId`s on the components
instead. It's not super clear for what reason that would be preferable,
but playwright's docs indicate that it might indeed be (the `_react`
locator is marked as experimental.. well I guess that's clear enough).
@github-actions github-actions bot removed the status:conflicts This PR has conflicts that need to be resolved label Jun 20, 2023
@github-actions github-actions bot temporarily deployed to test-deployment-pr868 June 20, 2023 16:07 Destroyed
@owi92
Copy link
Member Author

owi92 commented Jun 20, 2023

Dangit I pushed the rebase combined with my changes again 🤦.
Though I think I would suggest reviewing this file-by-file anyway.

@narickmann
Copy link

I took a look at the tests.

The tests are looking good so far and I think they cover pretty much everything.
I haven't noticed anything important that's still missing.

Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

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

Then let's just merge this! I still haven't done a full review due to time contraints, but that's fine. This is not code that is shipped anyway. The worst that could happen is a bit of flaky tests in CI, with random CI failures. But that's easy to fix and no big problem. No need to block this any longer. Makes more sense to test-drive these tests on master anyway.

@LukasKalbertodt LukasKalbertodt merged commit 6aba66a into elan-ev:master Aug 3, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:dev Changes primarily for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants