|
Some checks failed
Build, deploy, and test Brolendar / check_code (push) Failing after 3m5s
Signed-off-by: yoshi <joshua.martius@rwth-aachen.de> Update .forgejo/workflows/check_code.yml Signed-off-by: yoshi <joshua.martius@rwth-aachen.de> Update .forgejo/workflows/pr_playwright_check.yml Signed-off-by: yoshi <joshua.martius@rwth-aachen.de> |
||
|---|---|---|
| .forgejo | ||
| .husky | ||
| public/images | ||
| src | ||
| tests | ||
| .envrc | ||
| .gitignore | ||
| .yarnrc.yml | ||
| eslint.config.js | ||
| flake.lock | ||
| flake.nix | ||
| i18next.config.ts | ||
| index.html | ||
| LICENSE | ||
| package.json | ||
| playwright.config.ts | ||
| README.md | ||
| renovate.json | ||
| tsconfig.app.json | ||
| tsconfig.json | ||
| tsconfig.node.json | ||
| vite.config.ts | ||
| yarn.lock | ||
Brolendar
Its gonna be great
Deployed Instances
Tests
Implement Tests
General
- Tests are implemented with
playwright - Tests are stored in
tests/<name>.spec.ts - Configs for
playwrightare stored inplaywright.config.ts(you probably don't need to touch this)
Writing A New Test
-
Create a new file in
tests/called<name>.spec.ts -
Take inspiration by one of the existing tests, for example
calendar.spec.ts:- You can mostly copy the imports from the top
- Below that are environment variable imports that define, for example, backend and frontend urls
- If you want to run some logic before each test, define a
test.beforeEach( async ({ page }) => {}) - In
test.describeyou can define a number oftests liketest("description", async ({ page }) => {})
-
Find more information at playwright!
Test Structure
The structure of how tests are grouped is not yet final and might change in the future.
Framework
Fixtures
A fixtures is a page in a specific state.
For example, the brolendarPage fixture is logged in with Brolendar and DAV credentials with all events cleared.
It uses the Brolendar class for moving between pages and clicking on common buttons.
New fixtures can be added in tests/fixtures/fixtures.ts.
Brolendar Class
The BrolendarClass is defined in /tests/fixtures/brolendar.ts and implements common actions in Brolendar.
This includes common selectors and workflows.
For example, the login functions loads the /welcome page, enters credentials loaded from .env and loads /calendar.
Any common action a user could do in Brolendar should be implemented here.
Network Calls to Backend
The brolendarPage fixture intercepts all network calls and blocks them by default.
Therefore, any calls have to be specified in the test with the intendet status code and body.
Add the following code before the corresponding backend calls to enable the /caldav/sync, /caldav/calendars, and /caldav/events endpoints.
brolendarPage.page.route('**/caldav/sync', route => route.fulfill(
{
status: 200,
body: JSON.stringify({ success: true })
}
))
brolendarPage.page.route('**/caldav/calendars', route => route.fulfill(
{
status: 200,
headers: headers,
body: JSON.stringify({
success: true,
data: [
{
id: "personal",
writable: true,
name: "Personal",
color:"#2F2F2F"
}
]
})
}
))
brolendarPage.page.route('**/caldav/events?*', route => route.fulfill(
{
status: 200,
headers: headers,
body: []
}
))
The above can also be enabled using brolendarPage.enableDefaultCaldavResponse()
More info can be found here.
Run Tests
With GUI During Implementation
- Run
yarn playwright test --ui - At the top left, click on
Projectsand activatesetupplus at least of ofchromiumandfirefox - The setup function is cached, meaning you can disable the
setupproject after the first run. The page state after the login is then restored for each test run
Headless
- Run
yarn playwright test --reporter=list - The reporter is the output format