-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve UI tests by running each in isolation (separate Tobira proces…
…s & DB) with fixed offline data (#1093) This should improve our UI tests by isolating them, making them more robust and easier to write. Each test (well, worker) has its own Tobira process and DB. The DB test data is now fixed and statically specified and all referenced static files are served locally, contained inside the repository. That way we are not dependent on online resources or the ever-changing DB dumps. Tests can now assume this fixed dataset (only a few tests take advantage of that yet). See commits for more details on how this is achieved. This PR should likely be reviewed commit by commit anyway. All tests that previously worked, work with this as well. I also re-enabled a large part of the `realm.spec.ts` test, which I think runs reliably now. This still leaves some tests disabled/skipped that we should re-enable as well. And there are of course tons of new tests one could add. But this PR was took long enough already and presents an improvement in itself IMO. So the other tests can be added in follow up PRs. This PR also adds the `"@typescript-eslint/no-floating-promises": "warn",` lint, which helps a lot with writing these tests.
- Loading branch information
Showing
38 changed files
with
1,207 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.mp4 filter=lfs diff=lfs merge=lfs -text | ||
*.jpg filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
sidebar_position: 7 | ||
sidebar_position: 8 | ||
--- | ||
|
||
# Create a release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
sidebar_position: 7 | ||
--- | ||
|
||
# Tests | ||
|
||
Tobira comes with various different automated tests to prevent bugs or unintended changes. | ||
These are all automatically run by our GitHub-based continious integration (CI) for every pull request. | ||
But it is also useful to run the tests locally, for example to add new tests. | ||
|
||
|
||
## Backend & DB tests | ||
|
||
These are tests in `backend/`, written with the built-in Rust test framework, i.e. `#[test]`. | ||
You can find various ones throughout the backend codebase. | ||
|
||
There are some very simple tests that test a small piece of code and are completely isolated. | ||
But there are also "database tests" defined in the backend that make sure the DB with our migrations behaves as expected. | ||
These are defined in `db::tests`. | ||
Each DB test sets up an isolated new database and performs all tests inside so that tests running at the same time do not influence each other. | ||
|
||
You can run all of these tests via **`cargo test`** in the `backend/` folder. | ||
The DB tests require the development PostgreSQL database to be running, so make sure you ran `./x.sh containers start`. | ||
|
||
|
||
## Playwright UI tests | ||
|
||
These tests are "end to end" tests as they test the whole Tobira application in the same way a user would. | ||
We use [Playwright](https://playwright.dev/) to define those tests. | ||
They live in `frontend/tests`. | ||
|
||
In order for these tests to run without interfering with one another, each test is isolated, using its own Tobira binary and database. | ||
A small set of fixed test data can be inserted for the test and a number of small static files (videos, images) are available via a development container. | ||
|
||
Therefore, you also have to run `./x.sh containers start` before running these tests. | ||
Further, you have to run `npm ci` in `frontend/` and build the Tobira binary, both done by `./x.sh start`. | ||
Finally, in some situations, git might not have downloaded the static files properly, which you can fix by manually running `git lfs checkout` or `git lfs fetch`. | ||
With all that done, you can run the tests via `npx playwright test` inside `frontend/`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.